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:

## 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, @NonNull Handler toI420Handler, @NonNull 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, @Nullable TextureBufferPool sourceTexturePool, int sequence)
TextureBuffer | withSequence (int sequence)
VideoFrame.TextureBuffer.Type | getType ()
int | getTextureId ()
Matrix | getTransformMatrix ()
EglBase.Context | getEglBaseContext ()
Object | getSourceTexturePool ()
long | getNativeEglContext ()
int | getEglContextType ()
float[] | getTransformMatrixArray ()
int | getSequence ()
int | getWidth ()
int | getHeight ()
YuvConverter | getYuvConverter ()
Handler | getToI420Handler ()
VideoFrame.Buffer | applyNewI420Handler ( @NonNull Handler toI420Handler, @NonNull YuvConverter yuvConverter)
VideoFrame.I420Buffer | toI420 ()
void | retain ()
void | release ()
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)
TextureBuffer | applyNewTextureInfo (Type newType, int newTextureId, Matrix newMatrix, 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

  sharedContext | egl 1.0 EGLContext javax.microedition.khronos.egl.EGLContext
  width | width
  height | height
  type | texture type TextureBuffer.Type
  id | texture id
  transformMatrix | the transform matrix associated with the texture id
  toI420Handler | nullable, the Handler related to the GL thread which create the texture
  yuvConverter | nullable, yuv converter YuvConverter
  releaseCallback | nullable, 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

  sharedContext | egl 1.4 EGLContextt android.opengl.EGLContext
  width | width
  height | height
  type | texture type TextureBuffer.Type
  id | texture id
  transformMatrix | the transform matrix associated with the texture id
  toI420Handler | nullable, the Handler related to the GL thread which create the texture
  yuvConverter | nullable, yuv converter YuvConverter
  releaseCallback | nullable, 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,
|  | @Nullable TextureBufferPool | sourceTexturePool,
|  | int | sequence
| ) |  |

Constructs a new TextureBuffer backed by the given texture id

Parameters

  eglContext | wrapped eglContext
  width | width
  height | height
  type | texture type TextureBuffer.Type
  id | texture id
  transformMatrix | the transform matrix associated with the texture id
  toI420Handler | nullable, the Handler related to the GL thread which create the texture
  yuvConverter | nullable, yuv converter YuvConverter
  releaseCallback | nullable, 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 | ( |  | ) |

Returns
  texture id

Implements io.agora.base.VideoFrame.TextureBuffer.

## ◆ 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.

## ◆ getEglBaseContext()

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

Retrieve the wrapped eglcontext EglBase.Context

Implements io.agora.base.VideoFrame.TextureBuffer.

## ◆ getSequence()

int io.agora.base.TextureBuffer.getSequence | ( |  | ) |

Sequence number managed by texture buffer creator.

Implements io.agora.base.VideoFrame.TextureBuffer.

## ◆ getWidth()

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

Resolution of the buffer in pixels.

Returns
  width.

Implements io.agora.base.VideoFrame.Buffer.

## ◆ getHeight()

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

Resolution of the buffer in pixels.

Returns
  height.

Implements io.agora.base.VideoFrame.Buffer.

## ◆ applyNewI420Handler()

VideoFrame.Buffer 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.

## ◆ 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.

## ◆ retain()

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

Increases ref count by one.

Implements io.agora.base.VideoFrame.Buffer.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ applyNewTextureInfo()

TextureBuffer io.agora.base.TextureBuffer.applyNewTextureInfo | ( | Type | newType,
|  | int | newTextureId,
|  | Matrix | newMatrix,
|  | int | newWidth,
|  | int | newHeight
| ) |  |

Create a new TextureBuffer with a new texture info. The existing buffer is unchanged and is reference counted by the new byffer.