Search code examples
androidcamerawebrtcwebrtc-android

Web rtc, android library, mirror front camera display


I use webRTC's android library and I want to mirror image(footage) displayed on SurfaceView. (It is front camera footage)

I did same in IOS easily with changing scale of surfaceView like this self.LocalView.transform = CGAffineTransformMakeScale(-1.0, 1.0); But in android localRenderer.scaleX = -1f gives black screen result.

This is only source I found which is talking about this: link

It says something like this: WebRTC Android provides VideoRenderGui as a video rendering interface

VideoRenderGui's update interface provides mirroring parameters. Set to true to mirror reverse when rendering.
public static void update(Callbacks renderer, int x, int y, int width, int height, VideoRendererGui.ScalingType scalingType, boolean mirror)

But I can't find an example how to implement this VideoRenderGui class.


Solution

  • I am not sure whether just want to mirror your local view or you want the camera stream to be mirrored. But if you just want to show front camera footage mirrored then the below solution will do the work.

    Here localVideoView is SurfaceViewRenderer.

    localVideoView?.setMirror(true)