Fix stop sharing button state.

This commit is contained in:
Onuray Sahin 2022-05-05 12:57:53 +03:00
parent b358863a1e
commit ba4413e702
2 changed files with 11 additions and 2 deletions

View file

@ -224,7 +224,8 @@ class VectorCallViewModel @AssistedInject constructor(
formattedDuration = webRtcCall.formattedDuration(), formattedDuration = webRtcCall.formattedDuration(),
isHD = webRtcCall.mxCall.isVideoCall && webRtcCall.currentCaptureFormat() is CaptureFormat.HD, isHD = webRtcCall.mxCall.isVideoCall && webRtcCall.currentCaptureFormat() is CaptureFormat.HD,
canOpponentBeTransferred = webRtcCall.mxCall.capabilities.supportCallTransfer(), canOpponentBeTransferred = webRtcCall.mxCall.capabilities.supportCallTransfer(),
transferee = computeTransfereeState(webRtcCall.mxCall) transferee = computeTransfereeState(webRtcCall.mxCall),
isSharingScreen = webRtcCall.isSharingScreen()
) )
} }
updateOtherKnownCall(webRtcCall) updateOtherKnownCall(webRtcCall)

View file

@ -97,6 +97,7 @@ import kotlin.coroutines.CoroutineContext
private const val STREAM_ID = "userMedia" private const val STREAM_ID = "userMedia"
private const val AUDIO_TRACK_ID = "${STREAM_ID}a0" private const val AUDIO_TRACK_ID = "${STREAM_ID}a0"
private const val VIDEO_TRACK_ID = "${STREAM_ID}v0" private const val VIDEO_TRACK_ID = "${STREAM_ID}v0"
private const val SCREEN_TRACK_ID = "${STREAM_ID}s0"
private val DEFAULT_AUDIO_CONSTRAINTS = MediaConstraints() private val DEFAULT_AUDIO_CONSTRAINTS = MediaConstraints()
private const val INVITE_TIMEOUT_IN_MS = 60_000L private const val INVITE_TIMEOUT_IN_MS = 60_000L
@ -805,7 +806,7 @@ class WebRtcCall(
} }
private fun showScreenLocally(factory: PeerConnectionFactory, videoSource: VideoSource?, localMediaStream: MediaStream?) { private fun showScreenLocally(factory: PeerConnectionFactory, videoSource: VideoSource?, localMediaStream: MediaStream?) {
localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource).apply { setEnabled(true) } localVideoTrack = factory.createVideoTrack(SCREEN_TRACK_ID, videoSource).apply { setEnabled(true) }
localMediaStream?.addTrack(localVideoTrack) localMediaStream?.addTrack(localVideoTrack)
localSurfaceRenderers.forEach { it.get()?.let { localVideoTrack?.addSink(it) } } localSurfaceRenderers.forEach { it.get()?.let { localVideoTrack?.addSink(it) } }
} }
@ -820,6 +821,13 @@ class WebRtcCall(
videoCapturer.startCapture(currentCaptureFormat.width, currentCaptureFormat.height, currentCaptureFormat.fps) videoCapturer.startCapture(currentCaptureFormat.width, currentCaptureFormat.height, currentCaptureFormat.fps)
} }
/**
* Returns true if the user is sharing the screen, false otherwise.
*/
fun isSharingScreen(): Boolean {
return localVideoTrack?.id() == SCREEN_TRACK_ID
}
private suspend fun release() { private suspend fun release() {
listeners.clear() listeners.clear()
mxCall.removeListener(this) mxCall.removeListener(this)