|
Agora Java API Reference for Android
|
Public Member Functions | |
| boolean | onCaptureVideoFrame (int sourceType, VideoFrame videoFrame) |
| Occurs each time the SDK receives a video frame captured by local devices. More... | |
| boolean | onPreEncodeVideoFrame (int sourceType, VideoFrame videoFrame) |
| Occurs each time the SDK receives a video frame before encoding. More... | |
| boolean | onMediaPlayerVideoFrame (VideoFrame videoFrame, int mediaPlayerId) |
| int | getVideoFrameProcessMode () |
| Occurs each time the SDK receives a video frame and prompts you to set the process mode of the video frame. More... | |
| int | getVideoFormatPreference () |
| Sets the format of the raw video data output by the SDK. More... | |
| boolean | getRotationApplied () |
| Occurs each time the SDK receives a video frame, and prompts you whether to rotate the captured video. More... | |
| boolean | getMirrorApplied () |
| Occurs each time the SDK receives a video frame and prompts you whether or not to mirror the captured video. More... | |
| int | getObservedFramePosition () |
| Sets the frame position for the video observer. More... | |
| boolean | onRenderVideoFrame (String channelId, int uid, VideoFrame videoFrame) |
| Occurs each time the SDK receives a video frame sent by the remote user. More... | |
Public Attributes | |
| int | PROCESS_MODE_READ_ONLY = 0 |
| int | PROCESS_MODE_READ_WRITE = 1 |
| int | POSITION_POST_CAPTURER = 1 |
| int | POSITION_PRE_RENDERER = 1 << 1 |
| int | POSITION_PRE_ENCODER = 1 << 2 |
| int | VIDEO_PIXEL_DEFAULT = 0 |
| int | VIDEO_PIXEL_I420 = 1 |
| int | VIDEO_PIXEL_BGRA = 2 |
| int | VIDEO_PIXEL_NV21 = 3 |
| int | VIDEO_PIXEL_RGBA = 4 |
| int | VIDEO_PIXEL_NV12 = 8 |
| int | VIDEO_TEXTURE_2D = 10 |
| int | VIDEO_TEXTURE_OES = 11 |
| int | VIDEO_PIXEL_I422 = 16 |
| int | VIDEO_PIXEL_I010 = 18 |
| boolean io.agora.rtc2.video.IVideoFrameObserver.onCaptureVideoFrame | ( | int | sourceType, |
| VideoFrame | videoFrame | ||
| ) |
Occurs each time the SDK receives a video frame captured by local devices.
You can get raw video data collected by the local device through this callback and preprocess it as needed. Once the preprocessing is complete, you can directly modify videoFrame in this callback, and set the return value to true to send the modified video data to the SDK. If you need to send the preprocessed data to the SDK, you need to call getVideoFrameProcessMode first to set the video processing mode to read and write mode ( PROCESS_MODE_READ_WRITE ). Applicable scenarios: - Preprocess the locally collected video data before it is processed by the SDK. For example, get video data through this callback and process it with filters, watermarks, cropping, rotation, etc.
videoFrame are consistent with the actual situation of the video frames in the video frame buffer. Otherwise, it may cause unexpected rotation, distortion, and other issues in the local preview and remote video display. The default video format that you get from this callback may be I420Buffer or TextureBuffer. The texture format of TextureBuffer can be either 0ES format or RGB format. If you need video data in other formats, you can set the expected data format in the return value of the getVideoFormatPreference callback.| sourceType | Video source types, including cameras, screens, or media player. See VideoSourceType. |
| videoFrame | The video frame. See VideoFrame.Note: The default value of the video frame data format obtained through this callback is as follows:
|
PROCESS_MODE_READ_ONLY:true: Reserved for future use.false: Reserved for future use.PROCESS_MODE_READ_WRITE:true: Sets the SDK to receive the video frame.false: Sets the SDK to discard the video frame. | boolean io.agora.rtc2.video.IVideoFrameObserver.onPreEncodeVideoFrame | ( | int | sourceType, |
| VideoFrame | videoFrame | ||
| ) |
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 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.
getVideoFrameProcessMode first to set the video processing mode to read and write mode ( PROCESS_MODE_READ_WRITE ).VIDEO_MODULE_POSITION_PRE_ENCODER (1 << 2) as a frame position through getObservedFramePosition.videoFrame are consistent with the actual situation of the video frames in the video frame buffer. Otherwise, it may cause unexpected rotation, distortion, and other issues in the local preview and remote video display.| sourceType | The type of the video source. See VideoSourceType. |
| videoFrame | The video frame. See VideoFrame.Note: The default value of the video frame data format obtained through this callback is as follows:
|
PROCESS_MODE_READ_ONLY:true: Reserved for future use.false: Reserved for future use.PROCESS_MODE_READ_WRITE:true: Sets the SDK to receive the video frame.false: Sets the SDK to discard the video frame. | boolean io.agora.rtc2.video.IVideoFrameObserver.onMediaPlayerVideoFrame | ( | VideoFrame | videoFrame, |
| int | mediaPlayerId | ||
| ) |
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.
| videoFrame | A pointer to the video frame: VideoFrame |
| mediaPlayerId | of the mediaPlayer. |
| int io.agora.rtc2.video.IVideoFrameObserver.getVideoFrameProcessMode | ( | ) |
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.
| int io.agora.rtc2.video.IVideoFrameObserver.getVideoFormatPreference | ( | ) |
Sets the format of the raw video data output by the SDK.
You need to register the callback when calling the registerVideoFrameObserver method. 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.
getVideoFormatPreference, you need to adapt to I420Buffer or TextureBuffer when processing video data. The cases where the video frame type is fixed as I420Buffer include but are not limited to:| boolean io.agora.rtc2.video.IVideoFrameObserver.getRotationApplied | ( | ) |
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, ensure that you 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 to rotate the video frame in the return value of this callback.
true: Rotate the captured video.false: (Default) Do not rotate the captured video. | boolean io.agora.rtc2.video.IVideoFrameObserver.getMirrorApplied | ( | ) |
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.
setVideoEncoderConfiguration method support setting the mirroring effect. Agora recommends that you only choose one method to set it up. Using both methods at the same time causes the mirroring effect to overlap, and the mirroring settings fail.true: Mirror the captured video.false: (Default) Do not mirror the captured video. | int io.agora.rtc2.video.IVideoFrameObserver.getObservedFramePosition | ( | ) |
Sets the frame position for the video observer.
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:
VIDEO_MODULE_POSITION_POST_CAPTURER (1 << 0): The position after capturing the video data, which corresponds to the onCaptureVideoFrame callback.VIDEO_MODULE_POSITION_PRE_RENDERER (1 << 1): The position of the received remote video data before rendering, which corresponds to the onRenderVideoFrame callback.VIDEO_MODULE_POSITION_PRE_ENCODER (1 << 2): The position before encoding the video data, which corresponds to the onPreEncodeVideoFrame callback.VIDEO_MODULE_POSITION_POST_CAPTURER (1 << 0) and VIDEO_MODULE_POSITION_PRE_RENDERER (1 << 1) by default.PROCESS_MODE_READ_WRITE and the observation position is set to VIDEO_MODULE_POSITION_PRE_ENCODER | VIDEO_MODULE_POSITION_POST_CAPTURER, the getMirrorApplied does not take effect; you need to modify the video processing mode or the position of the observer.VIDEO_MODULE_POSITION_POST_CAPTURER (1 << 0): The position after capturing the video data, which corresponds to the onCaptureVideoFrame callback.VIDEO_MODULE_POSITION_PRE_RENDERER (1 << 1): The position of the received remote video data before rendering, which corresponds to the onRenderVideoFrame callback.VIDEO_MODULE_POSITION_PRE_ENCODER (1 << 2): The position before encoding the video data, which corresponds to the onPreEncodeVideoFrame callback. | boolean io.agora.rtc2.video.IVideoFrameObserver.onRenderVideoFrame | ( | String | channelId, |
| int | uid, | ||
| VideoFrame | videoFrame | ||
| ) |
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 it receives a video frame. In this callback, you can get the video data sent from the remote end before rendering, and then process it according to the particular scenarios. The default video format that you get from this callback may be I420Buffer or TextureBuffer. The texture format of TextureBuffer can be either 0ES format or RGB format. If you need video data in other formats, you can set the expected data format in the return value of the getVideoFormatPreference callback.
getVideoFrameProcessMode first to set the video processing mode to read and write mode ( PROCESS_MODE_READ_WRITE ).videoFrame are consistent with the actual situation of the video frames in the video frame buffer. Otherwise, it may cause unexpected rotation, distortion, and other issues in the local preview and remote video display.| uid | The user ID of the remote user who sends the current video frame. |
| videoFrame | The video frame. See VideoFrame.Note: The default value of the video frame data format obtained through this callback is as follows:
|
| channelId | The channel ID. |
PROCESS_MODE_READ_ONLY:true: Reserved for future use.false: Reserved for future use.PROCESS_MODE_READ_WRITE:true: Sets the SDK to receive the video frame.false: Sets the SDK to discard the video frame. | int io.agora.rtc2.video.IVideoFrameObserver.PROCESS_MODE_READ_ONLY = 0 |
Observer works as a pure renderer and will not modify the original frame.
| int io.agora.rtc2.video.IVideoFrameObserver.PROCESS_MODE_READ_WRITE = 1 |
Observer works as a filter that will process the video frame and affect the following frame processing in SDK.
| int io.agora.rtc2.video.IVideoFrameObserver.POSITION_POST_CAPTURER = 1 |
The position after capturing the video data, which corresponds to the onCaptureVideoFrame callback.
| int io.agora.rtc2.video.IVideoFrameObserver.POSITION_PRE_RENDERER = 1 << 1 |
The position before receiving the remote video data, which corresponds to the onRenderVideoFrame callback.
| int io.agora.rtc2.video.IVideoFrameObserver.POSITION_PRE_ENCODER = 1 << 2 |
The position before encoding the video data, which corresponds to the onPreEncodeVideoFrame callback.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_DEFAULT = 0 |
0: Default format.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_I420 = 1 |
1: I420.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_BGRA = 2 |
2: BGRA.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_NV21 = 3 |
3: NV21.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_RGBA = 4 |
4: RGBA.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_NV12 = 8 |
8: NV12.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_TEXTURE_2D = 10 |
10: GL_TEXTURE_2D
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_TEXTURE_OES = 11 |
11: GL_TEXTURE_OES
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_I422 = 16 |
16: I422.
| int io.agora.rtc2.video.IVideoFrameObserver.VIDEO_PIXEL_I010 = 18 |
18: I010. 10bit I420 data. @technical preview
1.8.18