mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 02:15:46 +03:00
VoIP: handle ice restart
This commit is contained in:
parent
7af82af935
commit
97c3e50e7d
2 changed files with 6 additions and 8 deletions
|
@ -19,7 +19,6 @@ package im.vector.app.features.call.webrtc
|
||||||
import im.vector.app.features.call.CallAudioManager
|
import im.vector.app.features.call.CallAudioManager
|
||||||
import org.matrix.android.sdk.api.session.call.CallState
|
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.call.MxPeerConnectionState
|
||||||
import org.matrix.android.sdk.api.session.room.model.call.CallHangupContent
|
|
||||||
import org.webrtc.DataChannel
|
import org.webrtc.DataChannel
|
||||||
import org.webrtc.IceCandidate
|
import org.webrtc.IceCandidate
|
||||||
import org.webrtc.MediaStream
|
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.
|
* It is, however, possible that the ICE agent did find compatible connections for some components.
|
||||||
*/
|
*/
|
||||||
PeerConnection.IceConnectionState.FAILED -> {
|
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.
|
* 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() {
|
override fun onRenegotiationNeeded() {
|
||||||
Timber.v("## VOIP StreamObserver onRenegotiationNeeded")
|
Timber.v("## VOIP StreamObserver onRenegotiationNeeded")
|
||||||
webRtcCall.onRenegationNeeded()
|
webRtcCall.onRenegationNeeded(restartIce = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -165,17 +165,16 @@ class WebRtcCall(val mxCall: MxCall,
|
||||||
|
|
||||||
fun onIceCandidate(iceCandidate: IceCandidate) = iceCandidateSource.onNext(iceCandidate)
|
fun onIceCandidate(iceCandidate: IceCandidate) = iceCandidateSource.onNext(iceCandidate)
|
||||||
|
|
||||||
fun onRenegationNeeded() {
|
fun onRenegationNeeded(restartIce: Boolean) {
|
||||||
GlobalScope.launch(dispatcher) {
|
GlobalScope.launch(dispatcher) {
|
||||||
if (mxCall.state != CallState.CreateOffer && mxCall.opponentVersion == 0) {
|
if (mxCall.state != CallState.CreateOffer && mxCall.opponentVersion == 0) {
|
||||||
Timber.v("Opponent does not support renegotiation: ignoring onRenegotiationNeeded event")
|
Timber.v("Opponent does not support renegotiation: ignoring onRenegotiationNeeded event")
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val constraints = MediaConstraints()
|
val constraints = MediaConstraints()
|
||||||
// These are deprecated options
|
if (restartIce) {
|
||||||
// constraints.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"))
|
constraints.mandatory.add(MediaConstraints.KeyValuePair("IceRestart", "true"))
|
||||||
// constraints.mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveVideo", if (currentCall?.mxCall?.isVideoCall == true) "true" else "false"))
|
}
|
||||||
|
|
||||||
val peerConnection = peerConnection ?: return@launch
|
val peerConnection = peerConnection ?: return@launch
|
||||||
Timber.v("## VOIP creating offer...")
|
Timber.v("## VOIP creating offer...")
|
||||||
makingOffer = true
|
makingOffer = true
|
||||||
|
|
Loading…
Reference in a new issue