Skip to content

Commit

Permalink
fix: should not mirror the screen sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Apr 4, 2023
1 parent 42b3d7c commit 69e2b3c
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions lib/src/impl/agora_video_view_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,29 @@ class _AgoraRtcRenderTextureState extends State<AgoraRtcRenderTexture>
}
}

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
Expand All @@ -353,7 +367,10 @@ class _AgoraRtcRenderTextureState extends State<AgoraRtcRenderTexture>
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);
Expand Down

0 comments on commit 69e2b3c

Please sign in to comment.