Kotlin

Creating the Mirror Video Capturer

We need to create a MirrorVideoCapturer, its job is to:

  • open and configure the camera,
  • grab frames from the camera,
  • mirror the frames horizontally,
  • push those frames to the Vonage SDK as publisher video.
  1. Create a separate kotlin file with the MirrorVideoCapturer

As the file is quite large, copy the contents of the MirrorVideoCapturer.kt to your project. We'll just focus on the key aspects of the custom video capturing in this tutorial in next steps, so don't worry if you don't understand the whole capturer right away.

  1. How the capturer exposes its settings

The SDK needs to know what kind of video stream your capturer is going to provide. This is done through getCaptureSettings() in the custom capturer:

Settings here are configuring the capture as follows:

fps: how many frames per second you will deliver. width and height: the resolution of the frames (can be derived from the actual camera output or your configured capture size). format: the pixel format you’re going to provide to the SDK (for example, NV21). expectedDelay: an estimate (in ms) of how much time it takes between capturing and delivering a frame.

These settings are communicated to the Vonage SDK via MirrorVideoCapturer. When these are set, SDK knows: how to allocate buffers, how to encode the frames, and how to adapt network/encoding behavior to your capture profile.