Agora Java API Reference for Android
Public Member Functions | Static Public Member Functions | List of all members
io.agora.rtc.gl.JavaI420Buffer Class Reference
Inheritance diagram for io.agora.rtc.gl.JavaI420Buffer:
io.agora.rtc.gl.VideoFrame.I420Buffer io.agora.rtc.gl.VideoFrame.Buffer

Public Member Functions

int getWidth ()
 
int getHeight ()
 
ByteBuffer getDataY ()
 
ByteBuffer getDataU ()
 
ByteBuffer getDataV ()
 
int getStrideY ()
 
int getStrideU ()
 
int getStrideV ()
 
VideoFrame.I420Buffer toI420 ()
 
void retain ()
 
void release ()
 
VideoFrame.Buffer cropAndScale (int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight)
 

Static Public Member Functions

static JavaI420Buffer wrap (int width, int height, ByteBuffer dataY, int strideY, ByteBuffer dataU, int strideU, ByteBuffer dataV, int strideV, Runnable releaseCallback)
 
static JavaI420Buffer createYUV (byte[] data, int width, int height)
 
static JavaI420Buffer allocate (int width, int height)
 

Detailed Description

Implementation of VideoFrame.I420Buffer backed by Java direct byte buffers.

Member Function Documentation

◆ wrap()

static JavaI420Buffer io.agora.rtc.gl.JavaI420Buffer.wrap ( int  width,
int  height,
ByteBuffer  dataY,
int  strideY,
ByteBuffer  dataU,
int  strideU,
ByteBuffer  dataV,
int  strideV,
Runnable  releaseCallback 
)
static

Wraps existing ByteBuffers into JavaI420Buffer object without copying the contents.

◆ allocate()

static JavaI420Buffer io.agora.rtc.gl.JavaI420Buffer.allocate ( int  width,
int  height 
)
static

Allocates an empty I420Buffer suitable for an image of the given dimensions.

◆ getWidth()

int io.agora.rtc.gl.JavaI420Buffer.getWidth ( )

Resolution of the buffer in pixels.

Implements io.agora.rtc.gl.VideoFrame.Buffer.

◆ getDataY()

ByteBuffer io.agora.rtc.gl.JavaI420Buffer.getDataY ( )

Returns a direct ByteBuffer containing Y-plane data. The buffer capacity is at least getStrideY() * getHeight() bytes. The position of the returned buffer is ignored and must be 0. Callers may mutate the ByteBuffer (eg. through relative-read operations), so implementations must return a new ByteBuffer or slice for each call.

Implements io.agora.rtc.gl.VideoFrame.I420Buffer.

◆ getDataU()

ByteBuffer io.agora.rtc.gl.JavaI420Buffer.getDataU ( )

Returns a direct ByteBuffer containing U-plane data. The buffer capacity is at least getStrideU() * ((getHeight() + 1) / 2) bytes. The position of the returned buffer is ignored and must be 0. Callers may mutate the ByteBuffer (eg. through relative-read operations), so implementations must return a new ByteBuffer or slice for each call.

Implements io.agora.rtc.gl.VideoFrame.I420Buffer.

◆ getDataV()

ByteBuffer io.agora.rtc.gl.JavaI420Buffer.getDataV ( )

Returns a direct ByteBuffer containing V-plane data. The buffer capacity is at least getStrideV() * ((getHeight() + 1) / 2) bytes. The position of the returned buffer is ignored and must be 0. Callers may mutate the ByteBuffer (eg. through relative-read operations), so implementations must return a new ByteBuffer or slice for each call.

Implements io.agora.rtc.gl.VideoFrame.I420Buffer.

◆ toI420()

VideoFrame.I420Buffer io.agora.rtc.gl.JavaI420Buffer.toI420 ( )

Returns a memory-backed frame in I420 format. If the pixel data is in another format, a conversion will take place. All implementations must provide a fallback to I420 for compatibility with e.g. the internal WebRTC software encoders.

Implements io.agora.rtc.gl.VideoFrame.Buffer.

◆ retain()

void io.agora.rtc.gl.JavaI420Buffer.retain ( )

Reference counting is needed since a video buffer can be shared between multiple VideoSinks, and the buffer needs to be returned to the VideoSource as soon as all references are gone.

Implements io.agora.rtc.gl.VideoFrame.Buffer.

◆ cropAndScale()

VideoFrame.Buffer io.agora.rtc.gl.JavaI420Buffer.cropAndScale ( int  cropX,
int  cropY,
int  cropWidth,
int  cropHeight,
int  scaleWidth,
int  scaleHeight 
)

Crops a region defined by |cropx|, |cropY|, |cropWidth| and |cropHeight|. Scales it to size |scaleWidth| x |scaleHeight|.

Implements io.agora.rtc.gl.VideoFrame.Buffer.