Swift

Summary

How it works

  1. The Protocol (OTVideoCapture): You create a custom class (e.g., BasicVideoCapturer) that conforms to this protocol. This defines the lifecycle methods Vonage SDK needs to control your camera (start, stop, init, release).
  2. The Consumer (OTVideoCaptureConsumer): When you assign your custom capturer to a publisher, the SDK hands you a "Consumer" object. Think of this as the input pipe to the Vonage session.
  3. The Frame (OTVideoFrame): Your job is to produce video frames. These are wrappers around raw image data (pixels).
  4. The Loop:
    • Capture: You generate a frame.
    • Wrap: You wrap the raw byte buffer into an OTVideoFrame.
    • Consume: You pass the frame to videoCaptureConsumer.consumeFrame(frame).
  5. Transmission: The SDK takes the frame from the consumer, encodes it (e.g., to H.264 or VP8), and transmits it to the session.

Testing

This example should be tested on an iOS device only (don't forget to add proper permissions to your app)

Test on Physical Device

  1. Connect an iOS device
  2. Select it as the run destination
  3. Grant camera permissions when prompted
  4. You should see your camera feed in grayscale

Test with Multiple Participants

  1. Run the app on a device or simulator
  2. Use the Vonage Video Playground to join the same session
  3. You should see both your custom-rendered stream and the standard subscriber stream