VideoFrameObserver
Video observer.
You can call registerVideoFrameObserver to register or unregister the VideoFrameObserver.
onCaptureVideoFrame
Gets the video data captured by the local device.
final void Function(VideoSourceType sourceType, VideoFrame videoFrame)?
onCaptureVideoFrame;
You can get the raw video data captured by the local device in the callback.
- If the video data you get is of RGBA type, the SDK does not support processing the Alpha channel.
- It is recommended that you ensure the modified parameters in
videoFramematch the actual video frame in the buffer; otherwise, unexpected rotation, distortion, etc., may occur in the local preview or remote video. - Due to framework limitations, this callback does not support sending the processed video data back to the SDK.
Trigger Timing
Triggered by the SDK when each video frame is captured after successfully registering the video data observer.
Parameters
- sourceType
- Type of video source, which may include camera, screen, or media player. See VideoSourceType.
- videoFrame
- Video frame data. See VideoFrame.
Note: The default format of the video frame data obtained through this callback is as follows:
- Android: I420
- iOS: I420
- macOS: I420
- Windows: YUV420
onPreEncodeVideoFrame
Gets the video data before local encoding.
final void Function(VideoFrame videoFrame)? onPreEncodeVideoFrame;
After successfully registering the video data observer, the SDK triggers this callback each time a video frame is captured. You can get the video data before encoding in the callback and process it as needed for your scenario.
- Due to framework limitations, this callback does not support sending the processed video data back to the SDK.
- The video data obtained here has already undergone preprocessing such as cropping, rotation, and beauty effects.
- It is recommended that you ensure the modified parameters in
videoFramematch the actual video frame in the buffer; otherwise, unexpected rotation, distortion, etc., may occur in the local preview or remote video.
Parameters
- sourceType
- Type of video source. See VideoSourceType.
- videoFrame
- Video frame data. See VideoFrame.
Note: The default format of the video frame data obtained through this callback is as follows:
- Android: I420
- iOS: I420
- macOS: I420
- Windows: YUV420
onRenderVideoFrame
Gets the video data sent from the remote user.
final void Function(String channelId, int remoteUid, VideoFrame videoFrame)?
onRenderVideoFrame;
After successfully registering the video data observer, the SDK triggers this callback each time a video frame is captured. You can get the video data sent from the remote user before rendering and process it as needed for your scenario.
- If the video data you get is of RGBA type, the SDK does not support processing the Alpha channel.
- Due to framework limitations, this callback does not support sending the processed video data back to the SDK.
- It is recommended that you ensure the modified parameters in
videoFramematch the actual video frame in the buffer; otherwise, unexpected rotation, distortion, etc., may occur in the local preview or remote video.
Parameters
- remoteUid
- Remote user ID who sent the video frame.
- videoFrame
- Video frame data. See VideoFrame.
Note: The default format of the video frame data obtained through this callback is as follows:
- Android: I420
- iOS: I420
- macOS: I420
- Windows: YUV420
- channelId
- Channel ID.