PR feedback

This commit is contained in:
ThomasSession 2024-07-11 09:35:48 +10:00
parent a1c8974e7b
commit ddd63965ad
2 changed files with 8 additions and 17 deletions

View File

@ -402,13 +402,9 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity() {
// the floating video inset (empty or not) should be shown // the floating video inset (empty or not) should be shown
// the moment we have either of the video streams // the moment we have either of the video streams
if(!state.userVideoEnabled && !state.remoteVideoEnabled){ val showFloatingContainer = state.userVideoEnabled || state.remoteVideoEnabled
binding.floatingRendererContainer.isVisible = false binding.floatingRendererContainer.isVisible = showFloatingContainer
binding.swapViewIcon.isVisible = false binding.swapViewIcon.isVisible = showFloatingContainer
} else {
binding.floatingRendererContainer.isVisible = true
binding.swapViewIcon.isVisible = true
}
// handle fullscreen video window // handle fullscreen video window
if(state.showFullscreenVideo()){ if(state.showFullscreenVideo()){

View File

@ -165,9 +165,6 @@ class CallManager(
var fullscreenRenderer: SurfaceViewRenderer? = null var fullscreenRenderer: SurfaceViewRenderer? = null
private var peerConnectionFactory: PeerConnectionFactory? = 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() { fun clearPendingIceUpdates() {
pendingOutgoingIceUpdates.clear() pendingOutgoingIceUpdates.clear()
pendingIncomingIceUpdates.clear() pendingIncomingIceUpdates.clear()
@ -624,13 +621,11 @@ class CallManager(
} }
fun swapVideos() { fun swapVideos() {
videoSwapped = !videoSwapped
// update the state // update the state
_videoState.update { it.copy(swapped = videoSwapped) } _videoState.update { it.copy(swapped = !it.swapped) }
handleMirroring() handleMirroring()
if (videoSwapped) { if (_videoState.value.swapped) {
peerConnection?.rotationVideoSink?.setSink(fullscreenRenderer) peerConnection?.rotationVideoSink?.setSink(fullscreenRenderer)
floatingRenderer?.let{remoteRotationSink?.setSink(it) } floatingRenderer?.let{remoteRotationSink?.setSink(it) }
} else { } else {
@ -649,12 +644,12 @@ class CallManager(
/** /**
* Returns the renderer currently showing the user's video, not the contact's * 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 * 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 * Makes sure the user's renderer applies mirroring if necessary
@ -791,7 +786,7 @@ class CallManager(
connection.setCommunicationMode() connection.setCommunicationMode()
setAudioEnabled(true) setAudioEnabled(true)
dataChannel?.let { channel -> 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) val buffer = DataChannel.Buffer(ByteBuffer.wrap(toSend.toString().encodeToByteArray()), false)
channel.send(buffer) channel.send(buffer)
} }