David Zhao

remove ICE candidate outgoing buffer, send asap

... ... @@ -13,11 +13,7 @@ class PublisherTransportObserver(
override fun onIceCandidate(iceCandidate: IceCandidate?) {
val candidate = iceCandidate ?: return
if (engine.rtcConnected) {
engine.client.sendCandidate(candidate, target = LivekitRtc.SignalTarget.PUBLISHER)
} else {
engine.pendingCandidates.add(candidate)
}
engine.client.sendCandidate(candidate, target = LivekitRtc.SignalTarget.PUBLISHER)
}
override fun onRenegotiationNeeded() {
... ...
... ... @@ -43,7 +43,6 @@ constructor(
joinResponse = null
}
}
val pendingCandidates = mutableListOf<IceCandidate>()
private val pendingTrackResolvers: MutableMap<String, Continuation<LivekitModels.TrackInfo>> =
mutableMapOf()
... ... @@ -85,7 +84,6 @@ constructor(
}
fun negotiate() {
if (!client.isConnected) {
return
}
... ... @@ -114,10 +112,6 @@ constructor(
private fun onRTCConnected() {
Timber.v { "RTC Connected" }
rtcConnected = true
pendingCandidates.forEach { candidate ->
client.sendCandidate(candidate, LivekitRtc.SignalTarget.PUBLISHER)
}
pendingCandidates.clear()
}
interface Listener {
... ... @@ -204,6 +198,7 @@ constructor(
when (val outcome = publisher.peerConnection.setLocalDescription(sdpOffer)) {
is Either.Right -> {
Timber.d { "error setting local description: ${outcome.value}" }
return@launch
}
}
... ...
... ... @@ -152,7 +152,6 @@ constructor(
override fun onJoin(response: LivekitRtc.JoinResponse) {
Timber.v { "engine did join, version: ${response.serverVersion}" }
state = State.CONNECTED
sid = Sid(response.room.sid)
name = response.room.name
... ... @@ -170,6 +169,7 @@ constructor(
}
}
state = State.CONNECTED
connectContinuation?.resume(Unit)
connectContinuation = null
}
... ...