Agora Java API Reference for Android
Public Member Functions | List of all members
io.agora.base.TextureBuffer Class Reference
Inheritance diagram for io.agora.base.TextureBuffer:
io.agora.base.VideoFrame.TextureBuffer io.agora.base.VideoFrame.Buffer io.agora.mediaplayer.gl.TextureBufferImpl

Public Member Functions

 TextureBuffer (@NonNull javax.microedition.khronos.egl.EGLContext sharedContext, int width, int height, Type type, int id, Matrix transformMatrix, @Nullable Handler toI420Handler, @Nullable YuvConverter yuvConverter, @Nullable Runnable releaseCallback)
 
 TextureBuffer (@NonNull android.opengl.EGLContext sharedContext, int width, int height, Type type, int id, Matrix transformMatrix, @Nullable Handler toI420Handler, @Nullable YuvConverter yuvConverter, @Nullable Runnable releaseCallback)
 
 TextureBuffer (@NonNull EglBase.Context eglContext, int width, int height, Type type, int id, Matrix transformMatrix, @Nullable Handler toI420Handler, @Nullable YuvConverter yuvConverter, @Nullable Runnable releaseCallback)
 
VideoFrame.TextureBuffer.Type getType ()
 
int getTextureId ()
 
Matrix getTransformMatrix ()
 
EglBase.Context getEglBaseContext ()
 
long getNativeEglContext ()
 
int getEglContextType ()
 
float[] getTransformMatrixArray ()
 
int getWidth ()
 
int getHeight ()
 
YuvConverter getYuvConverter ()
 
Handler getToI420Handler ()
 
VideoFrame.I420Buffer toI420 ()
 
void retain ()
 
void release ()
 
TextureBuffer applyNewI420Handler ( @NonNull Handler toI420Handler, @NonNull YuvConverter yuvConverter)
 
VideoFrame.Buffer cropAndScale (int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight)
 
VideoFrame.Buffer mirror (int frameRotation)
 
VideoFrame.Buffer rotate (int frameRotation)
 
VideoFrame.Buffer transform (int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight, int rotation)
 
TextureBuffer applyTransformMatrix (Matrix transformMatrix, int newWidth, int newHeight)
 

Detailed Description

Android texture buffer that glues together the necessary information together with a generic release callback. ToI420() is implemented by providing a Handler and a YuvConverter.

Constructor & Destructor Documentation

◆ TextureBuffer() [1/3]

io.agora.base.TextureBuffer.TextureBuffer ( @NonNull javax.microedition.khronos.egl.EGLContext  sharedContext,
int  width,
int  height,
Type  type,
int  id,
Matrix  transformMatrix,
@Nullable Handler  toI420Handler,
@Nullable YuvConverter  yuvConverter,
@Nullable Runnable  releaseCallback 
)

Constructs a new TextureBuffer backed by the given texture id.

Parameters
sharedContextegl 1.0 EGLContext javax.microedition.khronos.egl.EGLContext
widthwidth
heightheight
typetexture type TextureBuffer.Type
idtexture id
transformMatrixthe transform matrix associated with the texture id
toI420Handlernullable, the Handler related to the GL thread which create the texture
yuvConverternullable, yuv converter YuvConverter
releaseCallbacknullable, invoked the this buffer released.

@apiNote either toI420Handler or yuvConverter is null, toI420() will throw exception, but sdk will try to complete these two parameter in some inner component.

◆ TextureBuffer() [2/3]

io.agora.base.TextureBuffer.TextureBuffer ( @NonNull android.opengl.EGLContext  sharedContext,
int  width,
int  height,
Type  type,
int  id,
Matrix  transformMatrix,
@Nullable Handler  toI420Handler,
@Nullable YuvConverter  yuvConverter,
@Nullable Runnable  releaseCallback 
)

Constructs a new TextureBuffer backed by the given texture id.

Parameters
sharedContextegl 1.4 EGLContextt android.opengl.EGLContext
widthwidth
heightheight
typetexture type TextureBuffer.Type
idtexture id
transformMatrixthe transform matrix associated with the texture id
toI420Handlernullable, the Handler related to the GL thread which create the texture
yuvConverternullable, yuv converter YuvConverter
releaseCallbacknullable, invoked the this buffer released.

@apiNote either toI420Handler or yuvConverter is null, toI420() will throw exception, but sdk will try to complete these two parameter in some inner component.

◆ TextureBuffer() [3/3]

io.agora.base.TextureBuffer.TextureBuffer ( @NonNull EglBase.Context  eglContext,
int  width,
int  height,
Type  type,
int  id,
Matrix  transformMatrix,
@Nullable Handler  toI420Handler,
@Nullable YuvConverter  yuvConverter,
@Nullable Runnable  releaseCallback 
)

Constructs a new TextureBuffer backed by the given texture id

Parameters
eglContextwrapped eglContext
widthwidth
heightheight
typetexture type TextureBuffer.Type
idtexture id
transformMatrixthe transform matrix associated with the texture id
toI420Handlernullable, the Handler related to the GL thread which create the texture
yuvConverternullable, yuv converter YuvConverter
releaseCallbacknullable, invoked the this buffer released.

@apiNote either toI420Handler or yuvConverter is null, toI420() will throw exception, but sdk will try to complete these two parameter in some inner component.

Member Function Documentation

◆ getTextureId()

int io.agora.base.TextureBuffer.getTextureId ( )

◆ getTransformMatrix()

Matrix io.agora.base.TextureBuffer.getTransformMatrix ( )

Retrieve the transform matrix associated with the frame. This transform matrix maps 2D homogeneous coordinates of the form (s, t, 1) with s and t in the inclusive range [0, 1] to the coordinate that should be used to sample that location from the buffer.

Implements io.agora.base.VideoFrame.TextureBuffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ getEglBaseContext()

EglBase.Context io.agora.base.TextureBuffer.getEglBaseContext ( )

Retrieve the wrapped eglcontext EglBase.Context

Implements io.agora.base.VideoFrame.TextureBuffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ getWidth()

int io.agora.base.TextureBuffer.getWidth ( )

Resolution of the buffer in pixels.

Returns
width.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ getHeight()

int io.agora.base.TextureBuffer.getHeight ( )

Resolution of the buffer in pixels.

Returns
height.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ toI420()

VideoFrame.I420Buffer io.agora.base.TextureBuffer.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.

Note
invoke release() to release the memory or decreases ref count by one, otherwise memory may be leaked.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ retain()

void io.agora.base.TextureBuffer.retain ( )

Increases ref count by one.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ release()

void io.agora.base.TextureBuffer.release ( )

Decreases ref count by one. When the ref count reaches zero, resources related to the object will be freed.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ applyNewI420Handler()

TextureBuffer io.agora.base.TextureBuffer.applyNewI420Handler ( @NonNull Handler  toI420Handler,
@NonNull YuvConverter  yuvConverter 
)

Create a new TextureBuffer with an applied transform toI420Handler and a new yuvConverter. The existing buffer is unchanged.

◆ cropAndScale()

VideoFrame.Buffer io.agora.base.TextureBuffer.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|.

Returns
a new buffer which match the request, null if not supported.
Note
invoke release() to release the memory or decreases ref count by one, otherwise memory may be leaked.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ mirror()

VideoFrame.Buffer io.agora.base.TextureBuffer.mirror ( int  frameRotation)

Apply mirror

Returns
a new buffer which match the request, null if not supported.
Note
invoke release() to release the memory or decreases ref count by one, otherwise memory may be leaked.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ rotate()

VideoFrame.Buffer io.agora.base.TextureBuffer.rotate ( int  frameRotation)

Apply rotate

Returns
a new buffer which match the request, null if not supported.
Note
invoke release() to release the memory or decreases ref count by one, otherwise memory may be leaked.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ transform()

VideoFrame.Buffer io.agora.base.TextureBuffer.transform ( int  cropX,
int  cropY,
int  cropWidth,
int  cropHeight,
int  scaleWidth,
int  scaleHeight,
int  frameRotation 
)

Apply crop/scale/mirror/rotate

Returns
a new buffer which match the request, null if not supported.
Note
invoke release() to release the memory or decreases ref count by one, otherwise memory may be leaked.

Implements io.agora.base.VideoFrame.Buffer.

Reimplemented in io.agora.mediaplayer.gl.TextureBufferImpl.

◆ applyTransformMatrix()

TextureBuffer io.agora.base.TextureBuffer.applyTransformMatrix ( Matrix  transformMatrix,
int  newWidth,
int  newHeight 
)

Create a new TextureBuffer with an applied transform matrix and a new size. The existing buffer is unchanged. The given transform matrix is applied first when texture coordinates are still in the unmodified [0, 1] range.