Video SDK v3.7.1 API Reference for All Platforms (C++)
agora::media::IVideoFrameObserver Class Referenceabstract

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

 IVideoFrameObserver ()
 
virtual ~IVideoFrameObserver ()
 
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 () AGORA_DEPRECATED_ATTRIBUTE
 
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: (Default) YUV 420

FRAME_TYPE_YUV422 

1: YUV 422

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.

Constructor & Destructor Documentation

◆ IVideoFrameObserver()

agora::media::IVideoFrameObserver::IVideoFrameObserver ( )
inline

◆ ~IVideoFrameObserver()

virtual agora::media::IVideoFrameObserver::~IVideoFrameObserver ( )
inlinevirtual

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.
  • 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
videoFramePointer to VideoFrame.
Returns
  • true: Sets the SDK to receive the video frame.
  • false: Sets the SDK to discard the video frame.

◆ 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
  • true: Sets the SDK to receive the video frame.
  • false: Sets the SDK to discard the video frame.

◆ 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
  • true: Sets the SDK to receive the video frame.
  • false: Sets the SDK to discard the video frame.

◆ 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.

YUV 420 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 to rotate the raw video frame according to the rotation member in the VideoFrame class.

The SDK does not rotate the raw video frame by default. If you want to receive the raw video frame rotated 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 to rotate the raw video frame in the return value of this callback.

Note
This callback applies to the video frame in the YUV 420 and RGBA formats only.
Returns
Sets whether to rotate the raw video frame:
  • 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 to mirror the raw video frame.

The SDK does not mirror the raw video frame by default. If you want to receive the raw video frame mirrored, register this callback in the IVideoFrameObserver class.

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

Note
This callback applies to the video frame in the YUV 420 and RGBA formats only.
Returns
Sets whether to mirror the raw video frame:
  • true: Mirror.
  • false: (Default) Do not mirror.

◆ getSmoothRenderingEnabled()

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

Sets whether to output the acquired video frame smoothly.

Since
v3.0.0
Deprecated:
As of v3.2.0, this callback function no longer works. The SDK smooths the video frames output by onRenderVideoFrame and onRenderVideoFrameEx by default.

If you want the video frames acquired from onRenderVideoFrame or onRenderVideoFrameEx 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 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
  • To observe multiple frame positions, use '|' (the OR operator).
  • 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.

Since
v3.0.1

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
  • true: Sets the SDK to receive the video frame.
  • false: Sets the SDK to discard the video frame.