AgoraVideoFrameDelegate
The IVideoFrameObserver class.
You can call setVideoFrameDelegate to register or unregister an AgoraVideoFrameDelegate object.
getMirrorApplied
Occurs each time the SDK receives a video frame and prompts you whether or not to mirror the captured video.
- (BOOL)getMirrorApplied;
If the video data you want to obtain is a mirror image of the original video, you need to register this callback when calling setVideoFrameDelegate. After you successfully register the video frame observer, the SDK triggers this callback each time it receives a video frame. You need to set whether or not to mirror the video frame in the return value of this callback.
Returns
YES
: Mirror the captured video.NO
: (Default) Do not mirror the captured video.
getObservedFramePosition
Sets the frame position for the video observer.
- (unsigned int)getObservedFramePosition;
After successfully registering the video data observer, the SDK uses this callback to determine whether to trigger onCaptureVideoFrame , onRenderVideoFrame and onPreEncodeVideoFrame callback at each specific video frame processing position, so that you can observe the locally collected video data, the video data sent by the remote end, and the video data before encoding. You can set one or more positions you need to observe by modifying the return value according to your scenario:
- (1 << 0) : The position after capturing the video data, which corresponds to the onCaptureVideoFrame callback.
- (1 << 1): The position before receiving the remote video data, which corresponds to the onRenderVideoFrame callback.
- (1 << 2): The position before encoding the video data, which corresponds to the onPreEncodeVideoFrame callback.
- Use '|' (the OR operator) to observe multiple frame positions.
- This callback observes (1 << 0) and (1 << 1) by default.
- To conserve the system consumption, you can reduce the number of frame positions that you want to observe.
Returns
- (1 << 0) : The position after capturing the video data, which corresponds to the onCaptureVideoFrame callback.
- (1 << 1): The position before receiving the remote video data, which corresponds to the onRenderVideoFrame callback.
- (1 << 2): The position before encoding the video data, which corresponds to the onPreEncodeVideoFrame callback.
getRotationApplied
Occurs each time the SDK receives a video frame, and prompts you whether to rotate the captured video.
- (BOOL)getRotationApplied;
If the video has been rotated according to the rotation in AgoraOutputVideoFrame on the capture device, you do not need to call this method to set the video rotation.
Returns
YES
: Rotate the captured video.NO
: (Default) Do not rotate the captured video.
getVideoFrameProcessMode
Occurs each time the SDK receives a video frame and prompts you to set the process mode of the video frame.
- (AgoraVideoFrameProcessMode)getVideoFrameProcessMode;
After you successfully register the video frame observer, the SDK triggers this callback each time it receives a video frame. You need to set your preferred process mode in the return value of this callback.
Returns
For details, see AgoraVideoFrameProcessMode.
onCaptureVideoFrame
Occurs each time the SDK receives a video frame captured by the local camera.
- (BOOL)onCaptureVideoFrame:(AgoraOutputVideoFrame * _Nonnull)videoFrame;
After you successfully register the video frame observer, the SDK triggers this callback each time it receives a video frame. In this callback, you can get the video data captured by the local camera. You can then pre-process the data according to your scenarios.
After pre-processing, you can send the processed video data back to the SDK by this callback.
- This callback does not support sending processed RGBA video data back to the SDK.
- The video data that this callback gets has not been pre-processed, without the watermark, the cropped content, the rotation, and the image enhancement.
Parameters
- VideoFrame
- Video frame data. See AgoraOutputVideoFrame for details.
Returns
YES
: Do not ignore.NO
: Ignore the current video frame, and do not send it back to the SDK.
onMediaPlayerVideoFrame
Gets the video data of the media player.
- (BOOL)onMediaPlayerVideoFrame:(AgoraOutputVideoFrame * _Nonnull)videoFrame mediaPlayerId:(NSInteger)mediaPlayerId;
After you successfully register the video frame observer and calling the createMediaPlayerWithDelegate method, the SDK triggers this callback each time when it receives a video frame. In this callback, you can get the video data of the media player. You can then process the data according to your particular scenarios.
After pre-processing, you can send the processed video data back to the SDK by this callback.
Parameters
- VideoFrame
- Video frame data. See AgoraOutputVideoFrame for details.
- mediaPlayerId
- The ID of the media player.
Returns
YES
: Do not ignore.NO
: Ignore the current video frame, and do not send it back to the SDK.
onPreEncodeScreenVideoFrame
Gets the video data captured from the screen before encoding.
- (BOOL)onPreEncodeScreenVideoFrame:(AgoraOutputVideoFrame * _Nonnull)videoFrame;
After you successfully register the video frame observer, the SDK triggers this callback each time it receives a video frame. In this callback, you can get the video data captured from the screen before encoding and then process the data according to your particular scenarios.
After processing, you can send the processed video data back to the SDK in this callback.
- To get the video data captured from the second screen before encoding, you need to set (1 << 2) as a frame position through getObservedFramePosition.
- The video data that this callback gets has been preprocessed, with its content cropped and rotated, and the image enhanced.
- This callback does not support sending processed RGBA video data back to the SDK.
Parameters
- VideoFrame
- Video frame data. See AgoraOutputVideoFrame for details.
Returns
YES
: Do not ignore.NO
: Ignore the current video frame, and do not send it back to the SDK.
onPreEncodeVideoFrame
Occurs each time the SDK receives a video frame before encoding.
- (BOOL)onPreEncodeVideoFrame:(AgoraOutputVideoFrame * _Nonnull)srcFrame dstFrame:(AgoraOutputVideoFrame *_Nullable* _Nullable)dstFrame;
After you successfully register the video frame observer, the SDK triggers this callback each time it receives a video frame. In this callback, you can get the video data before encoding and then process the data according to your particular scenarios.
After processing, you can send the processed video data back to the SDK in this callback.
- To get the video data captured from the second screen before encoding, you need to set (1 << 2) as a frame position through getObservedFramePosition.
- The video data that this callback gets has been preprocessed, with its content cropped and rotated, and the image enhanced.
- This callback does not support sending processed RGBA video data back to the SDK.
Parameters
- VideoFrame
- Video frame data. See AgoraOutputVideoFrame for details.
Returns
YES
: Do not ignore.NO
: Ignore the current video frame, and do not send it back to the SDK.
onScreenCaptureVideoFrame
Occurs each time the SDK receives a video frame captured by the screen.
- (BOOL)onScreenCaptureVideoFrame:(AgoraOutputVideoFrame * _Nonnull)videoFrame;
After you successfully register the video frame observer, the SDK triggers this callback each time when it receives a video frame. In this callback, you can get the video data for screen sharing. You can then pre-process the data according to your scenarios.
After pre-processing, you can send the processed video data back to the SDK by this callback.
- This callback does not support sending processed RGBA video data back to the SDK.
- The video data that this callback gets has not been pre-processed, without the watermark, the cropped content, the rotation, and the image enhancement.
Parameters
- VideoFrame
- Video frame data. See AgoraOutputVideoFrame for details.
Returns
YES
: Do not ignore.NO
: Ignore the current video frame, and do not send it back to the SDK.
onRenderVideoFrame
Occurs each time the SDK receives a video frame sent by the remote user.
- (BOOL)onRenderVideoFrame:(AgoraOutputVideoFrame * _Nonnull)videoFrame uid:(NSUInteger)uid channelId:(NSString * _Nonnull)channelId;
After you successfully register the video frame observer, the SDK triggers this callback each time it receives a video frame. In this callback, you can get the video data before encoding. You can then process the data according to your particular scenarios.
After processing, you can send the processed video data back to the SDK in this callback.
Parameters
- uid
- The ID of the remote user who sends the current video frame.
- VideoFrame
- Video frame data. See AgoraOutputVideoFrame for details.
- channelId
- The channel ID.
Returns
YES
: Do not ignore.NO
: Ignore the current video frame, and do not send it back to the SDK.