Agora C++ API Reference for All Platforms

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
agora::media::IVideoFrameObserver Class Referenceabstract

`#include <AgoraMediaBase.h>`

Inherited by agora::media::IVideoFrameObserverEx.

## Public Types
enum | VIDEO_FRAME_PROCESS_MODE { PROCESS_MODE_READ_ONLY , PROCESS_MODE_READ_WRITE }
typedef media::base::VideoFrame | VideoFrame

## Public Member Functions
virtual | ~IVideoFrameObserver ()
virtual bool | onCaptureVideoFrame (agora::rtc::VIDEO_SOURCE_TYPE sourceType, VideoFrame &videoFrame)=0
virtual bool | onPreEncodeVideoFrame (agora::rtc::VIDEO_SOURCE_TYPE sourceType, VideoFrame &videoFrame)=0
virtual bool | onMediaPlayerVideoFrame (VideoFrame &videoFrame, int mediaPlayerId)=0
virtual bool | onRenderVideoFrame (const char *channelId, rtc::uid_t remoteUid, VideoFrame &videoFrame)=0
virtual bool | onTranscodedVideoFrame (VideoFrame &videoFrame)=0
virtual VIDEO_FRAME_PROCESS_MODE | getVideoFrameProcessMode ()
virtual base::VIDEO_PIXEL_FORMAT | getVideoFormatPreference ()
virtual bool | getRotationApplied ()
virtual bool | getMirrorApplied ()
virtual uint32_t | getObservedFramePosition ()
virtual bool | isExternal ()

## Detailed Description

The IVideoFrameObserver class.

## Member Typedef Documentation

## ◆ VideoFrame

typedef media::base::VideoFrame agora::media::IVideoFrameObserver::VideoFrame

## Member Enumeration Documentation

## ◆ VIDEO_FRAME_PROCESS_MODE

enum agora::media::IVideoFrameObserver::VIDEO_FRAME_PROCESS_MODE

The process mode of the video frame:

Enumerator
PROCESS_MODE_READ_ONLY | Read-only mode. In this mode, you do not modify the video frame. The video frame observer is a renderer.
PROCESS_MODE_READ_WRITE | Read and write mode. In this mode, you modify the video frame. The video frame observer is a video filter.

## Constructor & Destructor Documentation

## ◆ ~IVideoFrameObserver()

virtual agora::media::IVideoFrameObserver::~IVideoFrameObserver | ( |  | ) |
| inline virtual

## Member Function Documentation

## ◆ onCaptureVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onCaptureVideoFrame | ( | agora::rtc::VIDEO_SOURCE_TYPE | sourceType,
|  | 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
  - If you get the video data in RGBA color encoding format, Agora does not support using this callback to send the processed data in RGBA color encoding format back to the SDK.
  - The video data that this callback gets has not been pre-processed, such as watermarking, cropping content, rotating, or image enhancement.

Parameters

  videoFrame | A pointer to the video frame: VideoFrame
  sourceType | source type of video frame. See #VIDEO_SOURCE_TYPE.

Returns
  Determines whether to ignore the current video frame if the pre-processing fails:
  - true: Do not ignore.
  - false: Ignore, in which case this method does not sent the current video frame to the SDK.

Implemented in agora::media::IVideoFrameObserverEx.

## ◆ onPreEncodeVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onPreEncodeVideoFrame | ( | agora::rtc::VIDEO_SOURCE_TYPE | sourceType,
|  | VideoFrame & | videoFrame )
| pure virtual

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
  - 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 pre-processed, such as watermarking, cropping content, rotating, or image enhancement.
  - This callback does not support sending processed RGBA video data back to the SDK.

Parameters

  videoFrame | A pointer to the video frame: VideoFrame
  sourceType | source type of video frame. See #VIDEO_SOURCE_TYPE.

Returns
  Determines whether to ignore the current video frame if the pre-processing fails:
  - true: Do not ignore.
  - false: Ignore, in which case this method does not sent the current video frame to the SDK.

Implemented in agora::media::IVideoFrameObserverEx.

## ◆ onMediaPlayerVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onMediaPlayerVideoFrame | ( | VideoFrame & | videoFrame,
|  | int | mediaPlayerId )
| pure virtual

Occurs each time the SDK receives a video frame decoded by the MediaPlayer.

After you successfully register the video frame observer, the SDK triggers this callback each time a video frame is decoded. In this callback, you can get the video data decoded by the MediaPlayer. 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 will not be affected by the return values of getVideoFrameProcessMode, getRotationApplied, getMirrorApplied, getObservedFramePosition.
  - On Android, this callback is not affected by the return value of getVideoFormatPreference

Parameters

  videoFrame | A pointer to the video frame: VideoFrame
  mediaPlayerId | ID of the mediaPlayer.

Returns
  Determines whether to ignore the current video frame if the pre-processing fails:
  - true: Do not ignore.
  - false: Ignore, in which case this method does not sent the current video frame to the SDK.

Implemented in agora::media::IVideoFrameObserverEx.

## ◆ onRenderVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onRenderVideoFrame | ( | const char * | channelId,
|  | rtc::uid_t | remoteUid,
|  | 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, 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

  channelId | The channel name
  remoteUid | ID of the remote user who sends the current video frame.
  videoFrame | A pointer to the video frame: VideoFrame

Returns
  Determines whether to ignore the current video frame if the post-processing fails:
  - true: Do not ignore.
  - false: Ignore, in which case this method does not sent the current video frame to the SDK.

Implemented in agora::media::IVideoFrameObserverEx.

## ◆ onTranscodedVideoFrame()

virtual bool agora::media::IVideoFrameObserver::onTranscodedVideoFrame | ( | VideoFrame & | videoFrame | ) |
| pure virtual

Implemented in agora::media::IVideoFrameObserverEx.

## ◆ getVideoFrameProcessMode()

virtual VIDEO_FRAME_PROCESS_MODE agora::media::IVideoFrameObserver::getVideoFrameProcessMode | ( |  | ) |
| inline virtual

Occurs each time the SDK receives a video frame and prompts you to set the process mode of the video frame.

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

## ◆ getVideoFormatPreference()

virtual base::VIDEO_PIXEL_FORMAT agora::media::IVideoFrameObserver::getVideoFormatPreference | ( |  | ) |
| inline virtual

Sets the format of the raw video data output by the SDK.

If you want to get raw video data in a color encoding format other than YUV 420, register this callback when calling `registerVideoFrameObserver`. 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.

Note
  If you want the video captured by the sender to be the original format, set the original video data format to VIDEO_PIXEL_DEFAULT in the return value. On different platforms, the original video pixel format is also different, for the actual video pixel format, see `VideoFrame`.

Returns
  Sets the video format. See VIDEO_PIXEL_FORMAT.

## ◆ getRotationApplied()

virtual bool agora::media::IVideoFrameObserver::getRotationApplied | ( |  | ) |
| inline virtual

Occurs each time the SDK receives a video frame, and prompts you whether to rotate the captured video.

If you want to rotate the captured video according to the rotation member in the `VideoFrame` class, register this callback by calling `registerVideoFrameObserver`. 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 video frame in the return value of this callback.

Note
  This function only supports video data in RGBA or YUV420.

Returns
  Determines whether to rotate.
  - `true`: Rotate the captured video.
  - `false`: (Default) Do not rotate the captured video.

## ◆ getMirrorApplied()

virtual bool agora::media::IVideoFrameObserver::getMirrorApplied | ( |  | ) |
| inline virtual

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

If the video data you want to obtain is a mirror image of the original video, you need to register this callback when calling `registerVideoFrameObserver`. 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.

Note
  This function only supports video data in RGBA and YUV420 formats.

Returns
  Determines whether to mirror.
  - `true`: Mirror the captured video.
  - `false`: (Default) Do not mirror the captured video.

## ◆ getObservedFramePosition()

virtual uint32_t agora::media::IVideoFrameObserver::getObservedFramePosition | ( |  | ) |
| inline virtual

Sets the frame position for the video observer.

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.

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.

## ◆ isExternal()

virtual bool agora::media::IVideoFrameObserver::isExternal | ( |  | ) |
| inline virtual

Indicate if the observer is for internal use. Note: Never override this function

Returns
  - true: the observer is for external use
  - false: the observer is for internal use

Reimplemented in agora::media::IVideoFrameObserverEx.