Agora Java API Reference for Android
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
io.agora.rtc2.video.VideoCanvas Class Reference

Attributes of the video canvas object. More...

Public Member Functions

 VideoCanvas (View view)
 
 VideoCanvas (View view, int renderMode, int uid)
 
 VideoCanvas (View view, int renderMode, int uid, int subviewUid)
 

Public Attributes

int uid
 
int subviewUid
 
View view
 
SurfaceTexture surfaceTexture
 
int renderMode
 
int mirrorMode
 
int setupMode = VIEW_SETUP_MODE_REPLACE
 
int sourceType
 
int mediaPlayerId
 
Rect rect
 
boolean enableAlphaMask
 
int backgroundColor
 
Constants.VideoModulePosition position
 

Static Public Attributes

static final int RENDER_MODE_HIDDEN = 1
 
static final int RENDER_MODE_FIT = 2
 
static final int RENDER_MODE_ADAPTIVE = 3
 
static final int VIEW_SETUP_MODE_REPLACE = 0
 
static final int VIEW_SETUP_MODE_ADD = 1
 
static final int VIEW_SETUP_MODE_REMOVE = 2
 

Detailed Description

Attributes of the video canvas object.

Member Data Documentation

◆ uid

int io.agora.rtc2.video.VideoCanvas.uid

User ID that publishes the video source.

◆ subviewUid

int io.agora.rtc2.video.VideoCanvas.subviewUid

The ID of the user who publishes a specific sub-video stream within the mixed video stream.

◆ RENDER_MODE_HIDDEN

final int io.agora.rtc2.video.VideoCanvas.RENDER_MODE_HIDDEN = 1
static

1: Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.

◆ RENDER_MODE_FIT

final int io.agora.rtc2.video.VideoCanvas.RENDER_MODE_FIT = 2
static

2: Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.

◆ RENDER_MODE_ADAPTIVE

final int io.agora.rtc2.video.VideoCanvas.RENDER_MODE_ADAPTIVE = 3
static

3: This mode is deprecated and Agora does not recommend using it.

◆ view

View io.agora.rtc2.video.VideoCanvas.view

The video display window. It must be one SurfaceView or TextureView object.

Note
In one VideoCanvas, you can only choose to set either view or surfaceTexture. If both are set, only the settings in view take effect.

◆ surfaceTexture

SurfaceTexture io.agora.rtc2.video.VideoCanvas.surfaceTexture

A container that provides video images. When you use this member, you need to implement texture drawing in OPENGL yourself. See SurfaceTexture.

Note
In one VideoCanvas, you can only choose to set either view or surfaceTexture. If both are set, only the settings in view take effect.

◆ renderMode

int io.agora.rtc2.video.VideoCanvas.renderMode
  • RENDER_MODE_HIDDEN (1): Hidden mode. Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT (2): Fit mode. Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
  • RENDER_MODE_ADAPTIVE (3): Adaptive mode. Deprecated: This enumerator is deprecated and not recommended for use.

◆ mirrorMode

int io.agora.rtc2.video.VideoCanvas.mirrorMode
  • VIDEO_MIRROR_MODE_AUTO (0): The SDK determines whether to enable the mirror mode. If you use a front camera, the SDK enables the mirror mode by default; if you use a rear camera, the SDK disables the mirror mode by default.
  • VIDEO_MIRROR_MODE_ENABLED (1): Enable the mirroring mode of the local view.
  • VIDEO_MIRROR_MODE_DISABLED (2): Disable the mirroring mode of the local view.
    Note
  • For the mirror mode of the local video view: If you use a front camera, the SDK enables the mirror mode by default; if you use a rear camera, the SDK disables the mirror mode by default.
  • For the remote user: The mirror mode is disabled by default.

◆ setupMode

int io.agora.rtc2.video.VideoCanvas.setupMode = VIEW_SETUP_MODE_REPLACE

Setting mode of the view.

  • VIEW_SETUP_MODE_REPLACE (0): (Default) Replaces a view.
  • VIEW_SETUP_MODE_ADD (1): Adds a view.
  • VIEW_SETUP_MODE_REMOVE (2): Deletes a view.
    Note
    When you no longer need to use a certain view, it is recommended to delete the view by setting setupMode to VIEW_SETUP_MODE_REMOVE, otherwise it may lead to leak of rendering resources.

◆ sourceType

int io.agora.rtc2.video.VideoCanvas.sourceType

The type of the video source. See VideoSourceType.

◆ mediaPlayerId

int io.agora.rtc2.video.VideoCanvas.mediaPlayerId

The ID of the media player. You can get the Device ID by calling getMediaPlayerId.

◆ rect

Rect io.agora.rtc2.video.VideoCanvas.rect

(Optional) Display area for the video frame. See Rect. width and height represent the video pixel width and height of the area. The default value is null (width or height is 0), which means that the actual resolution of the video frame is displayed.

◆ enableAlphaMask

boolean io.agora.rtc2.video.VideoCanvas.enableAlphaMask

(Optional) Whether to enable alpha mask rendering:

  • true: Enable alpha mask rendering.
  • false: (Default) Disable alpha mask rendering. Alpha mask rendering can create images with transparent effects and extract portraits from videos. When used in combination with other methods, you can implement effects such as portrait-in-picture and watermarking.

◆ backgroundColor

int io.agora.rtc2.video.VideoCanvas.backgroundColor

The background color of the video canvas in RGBA format. The default value is 0x00000000, which represents black.

Note
  • If you are developing with Kotlin, and encounter a compilation error after setting this parameter to 0xFFFFFFFF, you can use (0xFFFFFFFF).toInt() or android.graphics.Color.parseColor("#FFFFFFFF").
  • Currently, the backgroundColor parameter does not support the alpha channel when using the RGBA format.

◆ position

Constants.VideoModulePosition io.agora.rtc2.video.VideoCanvas.position
Initial value:
=
Constants.VideoModulePosition.VIDEO_MODULE_POSITION_POST_CAPTURER

The observation position of the video frame in the video link. See VideoModulePosition.