From ddd63965adc92446dcafed4998442920da05d9d1 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Thu, 11 Jul 2024 09:35:48 +1000 Subject: [PATCH] PR feedback --- .../securesms/calls/WebRtcCallActivity.kt | 10 +++------- .../thoughtcrime/securesms/webrtc/CallManager.kt | 15 +++++---------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt index 92f1e27736..acc92c3c94 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt @@ -402,13 +402,9 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity() { // the floating video inset (empty or not) should be shown // the moment we have either of the video streams - if(!state.userVideoEnabled && !state.remoteVideoEnabled){ - binding.floatingRendererContainer.isVisible = false - binding.swapViewIcon.isVisible = false - } else { - binding.floatingRendererContainer.isVisible = true - binding.swapViewIcon.isVisible = true - } + val showFloatingContainer = state.userVideoEnabled || state.remoteVideoEnabled + binding.floatingRendererContainer.isVisible = showFloatingContainer + binding.swapViewIcon.isVisible = showFloatingContainer // handle fullscreen video window if(state.showFullscreenVideo()){ diff --git a/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt index 7f0cd5f859..52cc0ad322 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt @@ -165,9 +165,6 @@ class CallManager( var fullscreenRenderer: SurfaceViewRenderer? = null private var peerConnectionFactory: PeerConnectionFactory? = null - // false when the user's video is in the floating render and true when it's in fullscreen - private var videoSwapped: Boolean = false - fun clearPendingIceUpdates() { pendingOutgoingIceUpdates.clear() pendingIncomingIceUpdates.clear() @@ -624,13 +621,11 @@ class CallManager( } fun swapVideos() { - videoSwapped = !videoSwapped - // update the state - _videoState.update { it.copy(swapped = videoSwapped) } + _videoState.update { it.copy(swapped = !it.swapped) } handleMirroring() - if (videoSwapped) { + if (_videoState.value.swapped) { peerConnection?.rotationVideoSink?.setSink(fullscreenRenderer) floatingRenderer?.let{remoteRotationSink?.setSink(it) } } else { @@ -649,12 +644,12 @@ class CallManager( /** * Returns the renderer currently showing the user's video, not the contact's */ - private fun getUserRenderer() = if(videoSwapped) fullscreenRenderer else floatingRenderer + private fun getUserRenderer() = if(_videoState.value.swapped) fullscreenRenderer else floatingRenderer /** * Returns the renderer currently showing the contact's video, not the user's */ - private fun getRemoteRenderer() = if(videoSwapped) floatingRenderer else fullscreenRenderer + private fun getRemoteRenderer() = if(_videoState.value.swapped) floatingRenderer else fullscreenRenderer /** * Makes sure the user's renderer applies mirroring if necessary @@ -791,7 +786,7 @@ class CallManager( connection.setCommunicationMode() setAudioEnabled(true) dataChannel?.let { channel -> - val toSend = if (!_videoState.value.userVideoEnabled) VIDEO_DISABLED_JSON else VIDEO_ENABLED_JSON + val toSend = if (_videoState.value.userVideoEnabled) VIDEO_ENABLED_JSON else VIDEO_DISABLED_JSON val buffer = DataChannel.Buffer(ByteBuffer.wrap(toSend.toString().encodeToByteArray()), false) channel.send(buffer) }