Agora Java API Reference for Android
Public Member Functions | List of all members
io.agora.rtc.mediaio.AgoraDefaultRender Class Reference
Inheritance diagram for io.agora.rtc.mediaio.AgoraDefaultRender:
io.agora.rtc.mediaio.IVideoSink io.agora.rtc.mediaio.IVideoFrameConsumer

Public Member Functions

boolean onInitialize ()
 
boolean onStart ()
 
void onStop ()
 
void onDispose ()
 
int getBufferType ()
 
int getPixelFormat ()
 
void consumeByteBufferFrame (ByteBuffer buffer, int pixelFormat, int width, int height, int rotation, long ts)
 
void consumeByteArrayFrame (byte[] data, int pixelFormat, int width, int height, int rotation, long ts)
 
void consumeTextureFrame (int texId, int pixelFormat, int width, int height, int rotation, long ts, float[] matrix)
 
long getEGLContextHandle ()
 

Member Function Documentation

◆ onInitialize()

boolean io.agora.rtc.mediaio.AgoraDefaultRender.onInitialize ( )

Initializes the video sink.

This callback initializes the video sink. You can also initialize the video sink before calling this callback and return @ true to the media engine in this callback. You need to pass true or false in this callback to tell the media engine if the video sink is initialized.

Returns
Pass one of the following return values to the media engine:
  • true: If the video sink is initialized.
  • false: If the video sink is not ready or fails to initialize, the media engine stops and reports the error.

Implements io.agora.rtc.mediaio.IVideoSink.

◆ onStart()

boolean io.agora.rtc.mediaio.AgoraDefaultRender.onStart ( )

Enables the video sink.

This SDK triggers this callback when the media engine starts streaming.

Returns
  • true: If the video sink is ready.
  • false: If the video sink is not ready.

Implements io.agora.rtc.mediaio.IVideoSink.

◆ onStop()

void io.agora.rtc.mediaio.AgoraDefaultRender.onStop ( )

Stops the video sink.

The SDK triggers this callback when the media engine stops video streaming. You should then stop the video sink.

Implements io.agora.rtc.mediaio.IVideoSink.

◆ onDispose()

void io.agora.rtc.mediaio.AgoraDefaultRender.onDispose ( )

Releases the video source.

The SDK triggers this callback when the media engine wants to release the video sink.

Implements io.agora.rtc.mediaio.IVideoSink.

◆ getBufferType()

int io.agora.rtc.mediaio.AgoraDefaultRender.getBufferType ( )

Gets the buffer type.

The SDK triggers this callback to get the buffer type of the video frame when it is being initialized. You need to specify one buffer type and then pass it to the media engine.

Returns
Video buffer type

Implements io.agora.rtc.mediaio.IVideoSink.

◆ getPixelFormat()

int io.agora.rtc.mediaio.AgoraDefaultRender.getPixelFormat ( )

Gets the pixel format.

The SDK triggers this callback to get the pixel format of the video frame when it is being initialized. You need to specify one pixel format and then pass it to the media engine. Choose the YUV (YUV420P) or RGBA format if the custom sink expects ByteArray or ByteBuffer; choose Texture of the custom expects textured frames.

Returns
Pixel format

Implements io.agora.rtc.mediaio.IVideoSink.

◆ consumeByteBufferFrame()

void io.agora.rtc.mediaio.AgoraDefaultRender.consumeByteBufferFrame ( ByteBuffer  buffer,
int  format,
int  width,
int  height,
int  rotation,
long  timestamp 
)

Receives the video frame in a byte buffer.

Parameters
bufferVideo in the format of ByteBuffer
formatPixel format of the video frame:
widthWidth of the video frame
heightHeight of the video frame
rotationClockwise rotating angle (0, 90, 180, and 270 degrees) of the video frame
timestampTimestamp of the video frame. For each video frame, you need to set a timestamp

Implements io.agora.rtc.mediaio.IVideoFrameConsumer.

◆ consumeByteArrayFrame()

void io.agora.rtc.mediaio.AgoraDefaultRender.consumeByteArrayFrame ( byte []  data,
int  format,
int  width,
int  height,
int  rotation,
long  timestamp 
)

Receives the video frame in a byte array.

Parameters
dataVideo in the format of ByteArray
formatPixel format of the video frame:
widthWidth of the video frame
heightHeight of the video frame
rotationClockwise rotating angle (0, 90, 180, and 270 degrees) of the video frame
timestampTimestamp of the video frame. For each video frame, you need to set a timestamp

Implements io.agora.rtc.mediaio.IVideoFrameConsumer.

◆ consumeTextureFrame()

void io.agora.rtc.mediaio.AgoraDefaultRender.consumeTextureFrame ( int  textureId,
int  format,
int  width,
int  height,
int  rotation,
long  timestamp,
float []  matrix 
)

Receives the video frame in texture.

Parameters
textureIdID of the texture
formatPixel format of the video frame:
widthWidth of the video frame
heightHeight of the video frame
rotationClockwise rotating angle (0, 90, 180, and 270 degrees) of the video frame
timestampTimestamp of the video frame. For each video frame, you need to set a timestamp
matrixMatrix of the texture. The float value is between 0 and 1, such as 0.1, 0.2, and so on

Implements io.agora.rtc.mediaio.IVideoFrameConsumer.

◆ getEGLContextHandle()

long io.agora.rtc.mediaio.AgoraDefaultRender.getEGLContextHandle ( )

Gets EGLContextHandle.

This callback returns the native handle of EGLContext if you use OpenGL and have your own EGLContext. You can share your EGLContext using the Texture ID returned by the SDK in your own EGLContext. If you do not have EGLContext, this callback returns 0; if the buffer type is set to Texture, the media engine creates EGLContext internally and return the Texture ID.

Returns
EGLContext

Implements io.agora.rtc.mediaio.IVideoSink.