From a7b194ef840e2f9fefb1210806adc8ae03fdbc22 Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Wed, 25 Sep 2024 11:34:49 +0200 Subject: [PATCH 1/2] Update the mirroring when the camera switches --- .../components/call/renderer/ParticipantVideo.kt | 16 +++++++++------- .../compose/ui/components/video/VideoRenderer.kt | 6 +++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt index 53496d75fe..c522016b0c 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt @@ -16,6 +16,7 @@ package io.getstream.video.android.compose.ui.components.call.renderer +import android.util.Log import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.RepeatMode import androidx.compose.animation.core.animateDpAsState @@ -250,18 +251,19 @@ public fun ParticipantVideoRenderer( val video by participant.video.collectAsStateWithLifecycle() val cameraDirection by call.camera.direction.collectAsStateWithLifecycle() val me by call.state.me.collectAsStateWithLifecycle() - val mirror by remember { - derivedStateOf { - participant.sessionId == me?.sessionId && cameraDirection == CameraDirection.Front + val mirror by remember(cameraDirection) { + mutableStateOf(cameraDirection == CameraDirection.Front && me?.sessionId == participant.sessionId) + } + val videoRendererConfig = remember(mirror, videoFallbackContent) { + videoRenderConfig { + mirrorStream = mirror + this.fallbackContent = videoFallbackContent } } VideoRenderer( call = call, video = video, - videoRendererConfig = videoRenderConfig { - mirrorStream = mirror - this.fallbackContent = videoFallbackContent - }, + videoRendererConfig = videoRendererConfig, ) } diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/video/VideoRenderer.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/video/VideoRenderer.kt index 4077f9e3c5..5b39f960ca 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/video/VideoRenderer.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/video/VideoRenderer.kt @@ -120,7 +120,10 @@ public fun VideoRenderer( view = this } }, - update = { v -> setupVideo(mediaTrack, v) }, + update = { v -> + v.setMirror(videoRendererConfig.mirrorStream) + setupVideo(mediaTrack, v) + }, modifier = modifier.testTag("video_renderer"), ) } @@ -180,6 +183,7 @@ private fun cleanTrack( } } } + private fun setupVideo( mediaTrack: MediaTrack?, renderer: VideoTextureViewRenderer, From 72f51f5cd13668b58cf2548175b3ff4b74808def Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Wed, 25 Sep 2024 11:35:38 +0200 Subject: [PATCH 2/2] Spotless --- .../compose/ui/components/call/renderer/ParticipantVideo.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt index c522016b0c..4414cb5f1c 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/ParticipantVideo.kt @@ -16,7 +16,6 @@ package io.getstream.video.android.compose.ui.components.call.renderer -import android.util.Log import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.RepeatMode import androidx.compose.animation.core.animateDpAsState @@ -252,7 +251,9 @@ public fun ParticipantVideoRenderer( val cameraDirection by call.camera.direction.collectAsStateWithLifecycle() val me by call.state.me.collectAsStateWithLifecycle() val mirror by remember(cameraDirection) { - mutableStateOf(cameraDirection == CameraDirection.Front && me?.sessionId == participant.sessionId) + mutableStateOf( + cameraDirection == CameraDirection.Front && me?.sessionId == participant.sessionId, + ) } val videoRendererConfig = remember(mirror, videoFallbackContent) { videoRenderConfig {