From 69e2b3cb14fbded62009fb730dfca167d450e0e1 Mon Sep 17 00:00:00 2001 From: littleGnAl Date: Tue, 4 Apr 2023 15:39:12 +0800 Subject: [PATCH] fix: should not mirror the screen sharing --- lib/src/impl/agora_video_view_impl.dart | 33 +++++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/src/impl/agora_video_view_impl.dart b/lib/src/impl/agora_video_view_impl.dart index 3b4ca99c7..4a2733221 100644 --- a/lib/src/impl/agora_video_view_impl.dart +++ b/lib/src/impl/agora_video_view_impl.dart @@ -322,15 +322,29 @@ class _AgoraRtcRenderTextureState extends State } } - Widget _applyMirrorMode(VideoMirrorModeType mirrorMode, Widget child) { - if (mirrorMode == VideoMirrorModeType.videoMirrorModeDisabled) { - return child; + bool _isScreenSource(VideoSourceType sourceType) { + final sourceTypeInt = sourceType.value(); + // int value of `VideoSourceType.videoSourceScreen` and `VideoSourceType.videoSourceScreenPrimary` is the same + return sourceTypeInt == VideoSourceType.videoSourceScreenPrimary.value() || + sourceTypeInt == VideoSourceType.videoSourceScreenSecondary.value(); + } + + Widget _applyMirrorMode(VideoMirrorModeType mirrorMode, Widget child, + VideoSourceType sourceType) { + bool enableMirror = true; + if (mirrorMode == VideoMirrorModeType.videoMirrorModeDisabled || + _isScreenSource(sourceType)) { + enableMirror = false; } - return Transform.scale( - scaleX: -1.0, - child: child, - ); + if (enableMirror) { + return Transform.scale( + scaleX: -1.0, + child: child, + ); + } + + return child; } @override @@ -353,7 +367,10 @@ class _AgoraRtcRenderTextureState extends State VideoMirrorModeType.videoMirrorModeDisabled; } - result = _applyMirrorMode(mirrorMode, result); + final sourceType = widget.controller.canvas.sourceType ?? + VideoSourceType.videoSourceCameraPrimary; + + result = _applyMirrorMode(mirrorMode, result, sourceType); } else { // Fit mode by default if does not need to handle render mode result = _applyRenderMode(RenderModeType.renderModeFit, result);