Kotlin

How mirroring actually works

The “mirror” effect itself is implemented at the point where you transform raw camera frames into frames that are given to the SDK:

Obtain the raw camera frame For Camera2: from the ImageReader callback. Apply a horizontal flip (mirror)

  • Software mirroring: manipulate the pixel buffer (e.g., reverse columns per row).
  • Texture/GL mirroring: if using OpenGL, flip the texture coordinates horizontally when drawing to the surface that feeds the SDK.
  • In either case, the final frame the SDK sees has left/right swapped vs. the raw camera output.
  • Deliver the mirrored frame to the SDK
  • Convert the frame to the configured pixel format (e.g., NV21) if necessary. Call the appropriate callback method on BaseVideoCapturer to hand off the mirrored frame.