Classes

struct  VideoFrame
 

Public Types

enum  VIDEO_FRAME_TYPE { FRAME_TYPE_YUV420 = 0, FRAME_TYPE_YUV422 = 1, FRAME_TYPE_RGBA = 2 }
 
enum  VIDEO_OBSERVER_POSITION { POSITION_POST_CAPTURER = 1 << 0, POSITION_PRE_RENDERER = 1 << 1, POSITION_PRE_ENCODER = 1 << 2 }
 

Public Member Functions

virtual bool onCaptureVideoFrame (VideoFrame &videoFrame)=0
 
virtual bool onPreEncodeVideoFrame (VideoFrame &videoFrame)
 
virtual bool onRenderVideoFrame (unsigned int uid, VideoFrame &videoFrame)=0
 
virtual VIDEO_FRAME_TYPE getVideoFormatPreference ()
 
virtual bool getRotationApplied ()
 
virtual bool getMirrorApplied ()
 
virtual bool getSmoothRenderingEnabled ()
 
virtual uint32_t getObservedFramePosition ()
 
virtual bool isMultipleChannelFrameWanted ()
 
virtual bool onRenderVideoFrameEx (const char *channelId, unsigned int uid, VideoFrame &videoFrame)
 

Detailed Description

Member Enumeration Documentation

◆ VIDEO_FRAME_TYPE

The video frame type.

Enumerator
FRAME_TYPE_YUV420 

0: YUV420

FRAME_TYPE_YUV422 

1: YUV422

FRAME_TYPE_RGBA 

2: RGBA

◆ VIDEO_OBSERVER_POSITION

The frame position of the video observer.

Enumerator
POSITION_POST_CAPTURER 

1: The post-capturer position, which corresponds to the video data in the onCaptureVideoFrame callback.

POSITION_PRE_RENDERER 

2: The pre-renderer position, which corresponds to the video data in the onRenderVideoFrame callback.

POSITION_PRE_ENCODER 

4: The pre-encoder position, which corresponds to the video data in the onPreEncodeVideoFrame callback.

Member Function Documentation

◆ onCaptureVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onCaptureVideoFrame ( VideoFrame videoFrame)
pure virtual

Occurs each time the SDK receives a video frame captured by the local camera.

After you successfully register the video frame observer, the SDK triggers this callback each time a video frame is received. 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 setting the videoFrame parameter in this callback.

Note
This callback does not support sending processed RGBA video data back to the SDK.
Parameters
videoFramePointer to VideoFrame.
Returns
Whether or not to ignore the current video frame if the pre-processing fails:
  • true: Do not ignore.
  • false: Ignore the current video frame, and do not send it back to the SDK.

◆ onPreEncodeVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onPreEncodeVideoFrame ( VideoFrame videoFrame)
inlinevirtual
Since
v3.0.0

Occurs each time the SDK receives a video frame before encoding.

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 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 by setting the VideoFrame parameter in this callback.

Note
  • As of v3.0.1, if you want to receive this callback, you also need to set POSITION_PRE_ENCODE(1 << 2) as a frame position in the getObservedFramePosition callback.
  • The video data that this callback gets has been pre-processed, with its content cropped, rotated, and the image enhanced.
  • This callback does not support sending processed RGBA video data back to the SDK.
Parameters
videoFrameA pointer to VideoFrame
Returns
Whether to ignore the current video frame if the processing fails:
  • true: Do not ignore the current video frame.
  • false: Ignore the current video frame, and do not send it back to the SDK.

◆ onRenderVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onRenderVideoFrame ( unsigned int  uid,
VideoFrame videoFrame 
)
pure virtual

Occurs each time the SDK receives a video frame sent by the remote user.

After you successfully register the video frame observer and isMultipleChannelFrameWanted return false, the SDK triggers this callback each time a video frame is received. In this callback, you can get the video data sent by the remote user. You can then post-process the data according to your scenarios.

After post-processing, you can send the processed data back to the SDK by setting the videoFrame parameter in this callback.

Note
This callback does not support sending processed RGBA video data back to the SDK.
Parameters
uidID of the remote user who sends the current video frame.
videoFramePointer to VideoFrame.
Returns
Whether or not to ignore the current video frame if the post-processing fails:
  • true: Do not ignore.
  • false: Ignore the current video frame, and do not send it back to the SDK.

◆ getVideoFormatPreference()

virtual VIDEO_FRAME_TYPE agora::media::IVideoFrameObserver::getVideoFormatPreference ( )
inlinevirtual

Occurs each time the SDK receives a video frame and prompts you to set the video format.

YUV420 is the default video format. If you want to receive other video formats, register this callback in the IVideoFrameObserver class.

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 video data in the return value of this callback.

Returns
Sets the video format: VIDEO_FRAME_TYPE

◆ getRotationApplied()

virtual bool agora::media::IVideoFrameObserver::getRotationApplied ( )
inlinevirtual

Occurs each time the SDK receives a video frame and prompts you whether or not to rotate the captured video according to the rotation member in the VideoFrame class.

The SDK does not rotate the captured video by default. If you want to rotate the captured video according to the rotation member in the VideoFrame class, register this callback in the IVideoFrameObserver class.

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 rotate the video frame in the return value of this callback.

Note
This callback applies to RGBA video data only.
Returns
Sets whether or not to rotate the captured video:
  • true: Rotate.
  • false: (Default) Do not rotate.

◆ getMirrorApplied()

virtual bool agora::media::IVideoFrameObserver::getMirrorApplied ( )
inlinevirtual

Occurs each time the SDK receives a video frame and prompts you whether or not to mirror the captured video.

The SDK does not mirror the captured video by default. Register this callback in the IVideoFrameObserver class if you want to mirror the captured video.

After you successfully register the video frame observer, the SDK triggers this callback each time a video frame is received. You need to set whether or not to mirror the captured video in the return value of this callback.

Note
This callback applies to RGBA video data only.
Returns
Sets whether or not to mirror the captured video:
  • true: Mirror.
  • false: (Default) Do not mirror.

◆ getSmoothRenderingEnabled()

virtual bool agora::media::IVideoFrameObserver::getSmoothRenderingEnabled ( )
inlinevirtual
Since
v3.0.0

Sets whether to output the acquired video frame smoothly.

If you want the video frames acquired from onRenderVideoFrame to be more evenly spaced, you can register the getSmoothRenderingEnabled callback in the IVideoFrameObserver class and set its return value as true.

Note
  • Register this callback before joining a channel.
  • This callback applies to scenarios where the acquired video frame is self-rendered after being processed, not to scenarios where the video frame is sent back to the SDK after being processed.
Returns
Set whether or not to smooth the video frames:
  • true: Smooth the video frame.
  • false: (Default) Do not smooth.

◆ getObservedFramePosition()

virtual uint32_t agora::media::IVideoFrameObserver::getObservedFramePosition ( )
inlinevirtual

Sets the frame position for the video observer.

Since
v3.0.1

After you successfully register the video observer, the SDK triggers this callback each time it receives a video frame. You can determine which position to observe by setting the return value. The SDK provides 3 positions for observer. Each position corresponds to a callback function:

  • POSITION_POST_CAPTURER(1 << 0): The position after capturing the video data, which corresponds to the onCaptureVideoFrame callback.
  • POSITION_PRE_RENDERER(1 << 1): The position before receiving the remote video data, which corresponds to the onRenderVideoFrame callback.
  • POSITION_PRE_ENCODER(1 << 2): The position before encoding the video data, which corresponds to the onPreEncodeVideoFrame callback.
Note
  • Use '|' (the OR operator) to observe multiple frame positions.
  • This callback observes POSITION_POST_CAPTURER(1 << 0) and POSITION_PRE_RENDERER(1 << 1) by default.
  • To conserve the system consumption, you can reduce the number of frame positions that you want to observe.
Returns
A bit mask that controls the frame position of the video observer: VIDEO_OBSERVER_POSITION.

◆ isMultipleChannelFrameWanted()

virtual bool agora::media::IVideoFrameObserver::isMultipleChannelFrameWanted ( )
inlinevirtual

Determines whether to receive video data from multiple channels.

After you register the video frame observer, the SDK triggers this callback every time it captures a video frame.

In the multi-channel scenario, if you want to get video data from multiple channels, set the return value of this callback as true. After that, the SDK triggers the onRenderVideoFrameEx callback to send you the video data from various channels. You can also get the channel ID of each video frame.

Note
  • Once you set the return value of this callback as true, the SDK triggers only the onRenderVideoFrameEx callback to send the video frame. onRenderVideoFrame will not be triggered. In the multi-channel scenario, Agora recommends setting the return value as true.
  • If you set the return value of this callback as false, the SDK triggers only the onRenderVideoFrame callback to send the video data.
Returns
  • true: Receive video data from multiple channels.
  • false: Do not receive video data from multiple channels.

◆ onRenderVideoFrameEx()

virtual bool agora::media::IVideoFrameObserver::onRenderVideoFrameEx ( const char *  channelId,
unsigned int  uid,
VideoFrame videoFrame 
)
inlinevirtual

Gets the video frame from multiple channels.

After you successfully register the video frame observer, if you set the return value of isMultipleChannelFrameWanted as true, the SDK triggers this callback each time it receives a video frame from any of the channel.

You can process the video data retrieved from this callback according to your scenario, and send the processed data back to the SDK using the videoFrame parameter in this callback.

Note
This callback does not support sending RGBA video data back to the SDK.
Parameters
channelIdThe channel ID of this video frame.
uidThe ID of the user sending this video frame.
videoFrameThe pointer to VideoFrame.
Returns
Whether to send this video frame to the SDK if post-processing fails:
  • true: Send this video frame.
  • false: Do not send this video frame.