VoIP: handle ice restart

This commit is contained in:
ganfra 2020-12-02 11:40:02 +01:00
parent 7af82af935
commit 97c3e50e7d
2 changed files with 6 additions and 8 deletions

View File

@ -19,7 +19,6 @@ package im.vector.app.features.call.webrtc
import im.vector.app.features.call.CallAudioManager
import org.matrix.android.sdk.api.session.call.CallState
import org.matrix.android.sdk.api.session.call.MxPeerConnectionState
import org.matrix.android.sdk.api.session.room.model.call.CallHangupContent
import org.webrtc.DataChannel
import org.webrtc.IceCandidate
import org.webrtc.MediaStream
@ -133,7 +132,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall,
* It is, however, possible that the ICE agent did find compatible connections for some components.
*/
PeerConnection.IceConnectionState.FAILED -> {
webRtcCall.endCall(true, CallHangupContent.Reason.ICE_FAILED)
webRtcCall.onRenegationNeeded(restartIce = true)
}
/**
* The ICE agent has finished gathering candidates, has checked all pairs against one another, and has found a connection for all components.
@ -172,7 +171,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall,
override fun onRenegotiationNeeded() {
Timber.v("## VOIP StreamObserver onRenegotiationNeeded")
webRtcCall.onRenegationNeeded()
webRtcCall.onRenegationNeeded(restartIce = false)
}
/**

View File

@ -165,17 +165,16 @@ class WebRtcCall(val mxCall: MxCall,
fun onIceCandidate(iceCandidate: IceCandidate) = iceCandidateSource.onNext(iceCandidate)
fun onRenegationNeeded() {
fun onRenegationNeeded(restartIce: Boolean) {
GlobalScope.launch(dispatcher) {
if (mxCall.state != CallState.CreateOffer && mxCall.opponentVersion == 0) {
Timber.v("Opponent does not support renegotiation: ignoring onRenegotiationNeeded event")
return@launch
}
val constraints = MediaConstraints()
// These are deprecated options
// constraints.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"))
// constraints.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveVideo", if (currentCall?.mxCall?.isVideoCall == true) "true" else "false"))
if (restartIce) {
constraints.mandatory.add(MediaConstraints.KeyValuePair("IceRestart", "true"))
}
val peerConnection = peerConnection ?: return@launch
Timber.v("## VOIP creating offer...")
makingOffer = true