AgoraVideoSinkProtocol Protocol Reference
Conforms to | NSObject |
---|---|
Declared in | AgoraMediaIO.h |
Overview
Defines a set of protocols to implement the custom video sink and pass it to the underlying media engine to replace the default video sink.
AgoraVideoSinkProtocol allows you to implement the custom video source. By default, when you try to enable real-time communications, the Agora SDK enables the default video sink to start video rendering. By calling setLocalVideoRenderer and setRemoteVideoRenderer, you can change the default video sink. Once you implement this interface, you receive callbacks from the media engine to indicate the state of the custom video sink, the underlying media engine, and enable their synchronization. Follow each callback to handle the resource allocation, and to release and receive the video frame from the media engine. AgoraVideoSinkProtocol defines a set of protocols to create a customized video sink. The AgoraVideoFrameConsumer interface passes the video frames to the media engine, which then passes them to the renderer. After a customized video sink is created, the app passes it to the media engine, see setLocalVideoRenderer and setRemoteVideoRenderer. AgoraVideoSinkProtocol consists of the following methods:
- Initializes the Video Sink (shouldInitialize)
- Enables the Video Sink (shouldStart)
- Disables the Video Sink (shouldStop)
- Releases the Video Sink (shouldDispose)
- Gets the Buffer Type (bufferType)
- Gets the Pixel Format (pixelFormat)
- (Optional) Outputs the Video in the Pixel Buffer (renderPixelBuffer)
- (Optional) Outputs the Video in the Raw Data (renderRawData)
Note: All methods defined in AgoraVideoSinkProtocol are callbacks. The media engine uses these methods to inform the customized renderer of its internal changes. An example is shown in the following steps to customize the video sink:
- Call bufferType and AgoraVideoPixelFormat to set the buffer type and pixel format of the video frame.
- Implement shouldInitialize, shouldStart, shouldStop, and shouldDispose to manage the customized video sink.
- Implement the buffer type and pixel format as specified in AgoraVideoFrameConsumer.
- Create the customized video sink object.
- Call the setLocalVideoRenderer and setRemoteVideoRenderer methods to set the local and remote renderers.
- The media engine calls functions in AgoraVideoSinkProtocol according to its internal state.