Agora Java API Reference for Android
io.agora.rtc.mediaio.IVideoSink Interface Reference

Inherits io.agora.rtc.mediaio.IVideoFrameConsumer.

Public Member Functions

boolean onInitialize ()
 
boolean onStart ()
 
void onStop ()
 
void onDispose ()
 
long getEGLContextHandle ()
 
int getBufferType ()
 
int getPixelFormat ()
 
- Public Member Functions inherited from io.agora.rtc.mediaio.IVideoFrameConsumer
void consumeByteBufferFrame (ByteBuffer buffer, int format, int width, int height, int rotation, long timestamp)
 
void consumeByteArrayFrame (byte[] data, int format, int width, int height, int rotation, long timestamp)
 
void consumeTextureFrame (int textureId, int format, int width, int height, int rotation, long timestamp, float[] matrix)
 

Detailed Description

The IVideoSink interface.

By default, when you try to enable real-time communications, the Agora SDK enables the default video sink to start video rendering. However, by calling the setLocalVideoRenderer and setRemoteVideoRenderer methods, you can change the default video sink.

The IVideoSink interface defines a set of protocols to create a customized video sink and pass it to the media engine to replace the default video renderer.

Once you implement this interface, you receive callbacks from the media engine indicating the state of the custom video sink and the underlying media engine and to enable their synchronization. Follow each callback to handle the resource allocation and to release and receive the video frame from the media engine.

Member Function Documentation

◆ onInitialize()

boolean io.agora.rtc.mediaio.IVideoSink.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.

◆ onStart()

boolean io.agora.rtc.mediaio.IVideoSink.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.

◆ onStop()

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

Stops the video sink.

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

◆ onDispose()

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

Releases the video source.

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

◆ getEGLContextHandle()

long io.agora.rtc.mediaio.IVideoSink.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

◆ getBufferType()

int io.agora.rtc.mediaio.IVideoSink.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

◆ getPixelFormat()

int io.agora.rtc.mediaio.IVideoSink.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