Exploring the Code
In this example, the app uses a custom video renderer to display a black-and-white version of the OTPublisher object's video.
In the main ViewController, after initializing the OTPublisher object, the videoRender property of the OTPublisher object is set to an instance of OTKBasicVideoRender:
OTKBasicVideoRender is a custom class that implements the OTVideoRender protocol (defined in the iOS SDK). This protocol lets you define a custom video renderer to be used by a Vonage Video publisher or subscriber.
The [OTKBasicVideoRender init:] method sets a _renderView property to a UIView object. This is the UIView object that will contain the view to be rendered (by the publisher or subscriber). In this sample, the UIView object is defined by the custom OTKCustomRenderView class, which extends UIView:
The OTKCustomRenderView class includes methods (discussed later) that convert a video frame to a black-and-white representation.
The [OTVideoRender renderVideoFrame:] method is called when the publisher (or subscriber) renders a video frame to the video renderer. The frame an OTVideoFrame object (defined by the iOS SDK). In the OTKCustomRenderView implementation of this method, it takes the frame and passes it along to the [renderVideoFrame] method of the OTKCustomRenderView object:
The [OTKCustomRenderView renderVideoFrame] method iterates through the pixels in the plane, adjusts each pixel to a black-and-white value, adds the value to a buffer. It then writes the buffer to a CGImageRef representing the view's image, and calls [self setNeedsDisplay] to render the image view:
Custom video rendering (Mobile Only)
Add custom video rendering to your application using the Vonage Video API.