diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt index 681a0caeac..f6e2caf72c 100644 --- a/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt @@ -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) } /** diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt index 0f5518c64c..a8f5942a1a 100644 --- a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt @@ -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