SES-1354 - Video call self viewer not mirrored (#1397)

* Fixes #874

* Removed accidentally left in line

* Fixed issue - push before cleanup

* Cleaned up

* Removed cruft

---------

Co-authored-by: = <=>
Co-authored-by: AL-Session <160798022+AL-Session@users.noreply.github.com>
This commit is contained in:
Al Lansley 2024-03-25 11:28:03 +11:00 committed by GitHub
parent 36edca855c
commit 8c2aaa06d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View File

@ -334,6 +334,10 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity() {
if (isEnabled) { if (isEnabled) {
viewModel.localRenderer?.let { surfaceView -> viewModel.localRenderer?.let { surfaceView ->
surfaceView.setZOrderOnTop(true) surfaceView.setZOrderOnTop(true)
// Mirror the video preview of the person making the call to prevent disorienting them
surfaceView.setMirror(true)
binding.localRenderer.addView(surfaceView) binding.localRenderer.addView(surfaceView)
} }
} }

View File

@ -408,6 +408,10 @@ class CallManager(
override fun onCameraSwitchCompleted(newCameraState: CameraState) { override fun onCameraSwitchCompleted(newCameraState: CameraState) {
localCameraState = newCameraState localCameraState = newCameraState
// If the camera we've switched to is the front one then mirror it to match what someone
// would see when looking in the mirror rather than the left<-->right flipped version.
localRenderer?.setMirror(localCameraState.activeDirection == CameraState.Direction.FRONT)
} }
fun onPreOffer(callId: UUID, recipient: Recipient, onSuccess: () -> Unit) { fun onPreOffer(callId: UUID, recipient: Recipient, onSuccess: () -> Unit) {
@ -639,7 +643,11 @@ class CallManager(
peerConnection?.let { connection -> peerConnection?.let { connection ->
connection.flipCamera() connection.flipCamera()
localCameraState = connection.getCameraState() localCameraState = connection.getCameraState()
localRenderer?.setMirror(localCameraState.activeDirection == CameraState.Direction.FRONT)
// Note: We cannot set the mirrored state of the localRenderer here because
// localCameraState.activeDirection is still PENDING (not FRONT or BACK) until the flip
// completes and we hit Camera.onCameraSwitchDone (followed by PeerConnectionWrapper.onCameraSwitchCompleted
// and CallManager.onCameraSwitchCompleted).
} }
} }

View File

@ -326,8 +326,6 @@ class PeerConnectionWrapper(private val context: Context,
} }
override fun onCameraSwitchCompleted(newCameraState: CameraState) { override fun onCameraSwitchCompleted(newCameraState: CameraState) {
// mirror rotation offset
rotationVideoSink.mirrored = newCameraState.activeDirection == CameraState.Direction.FRONT
cameraEventListener.onCameraSwitchCompleted(newCameraState) cameraEventListener.onCameraSwitchCompleted(newCameraState)
} }

View File

@ -54,7 +54,7 @@ class Camera(context: Context,
Log.w(TAG, "Tried to flip camera without capturer or less than 2 cameras") Log.w(TAG, "Tried to flip camera without capturer or less than 2 cameras")
return return
} }
activeDirection = PENDING activeDirection = PENDING // Note: The activeDirection will be PENDING until `onCameraSwitchDone`
capturer.switchCamera(this) capturer.switchCamera(this)
} }