Skip to content

Commit

Permalink
Update mirroring (#1190)
Browse files Browse the repository at this point in the history
* Update the mirroring when the camera switches

* Spotless
  • Loading branch information
aleksandar-apostolov authored Sep 25, 2024
1 parent c1a546e commit 70041f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,21 @@ 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,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
}
Expand Down Expand Up @@ -180,6 +183,7 @@ private fun cleanTrack(
}
}
}

private fun setupVideo(
mediaTrack: MediaTrack?,
renderer: VideoTextureViewRenderer,
Expand Down

0 comments on commit 70041f5

Please sign in to comment.