Summary
How it works
A timer runs at ~10 fps. On each tick, the capturer renders the target view (a UIView) into a UIImage via drawHierarchy(in:afterScreenUpdates:), resizes and pads the image for encoder compatibility, converts it to a CVPixelBuffer, wraps it in an OTVideoFrame, and passes it to the Vonage SDK via videoCaptureConsumer?.consumeFrame(_:). The SDK encodes and publishes the frames as a screen-share stream. The target view can be the full root view or any UIView you provide—including one produced by a UIViewRepresentable (see alternative below).
Testing
This example should with multiple participants ( at least 2 ), to see the screensharing working for another person in the call.
Test on iOS Simulator
- Run the app in the iOS Simulator
- The simulator will use a demo video (no camera access)
- You should see the timer text
Test on Physical Device
- Connect an iOS device
- Select it as the run destination
- Grant camera permissions when prompted
- You should see the timer text
Test with Multiple Participants
- Run the app on a device or simulator
- Use the Vonage Video Playground to join the same session
- You should see both your custom-rendered stream and the standard subscriber stream
Screen sharing
Learn how to implement tha screensharing capability using the Vonage Video API platform.