Agora Java API Reference for Android

Public Member Functions | Static Public Member Functions | List of all members
io.agora.base.JavaI420Buffer Class Reference
Inheritance diagram for io.agora.base.JavaI420Buffer:

## Public Member Functions
int | getWidth ()
int | getHeight ()
ByteBuffer | getDataY ()
ByteBuffer | getDataU ()
ByteBuffer | getDataV ()
int | getStrideY ()
int | getStrideU ()
int | getStrideV ()
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)

## Static Public Member Functions
static JavaI420Buffer | wrap (int width, int height, ByteBuffer dataY, int strideY, ByteBuffer dataU, int strideU, ByteBuffer dataV, int strideV, @Nullable Runnable releaseCallback)
static JavaI420Buffer | allocate (int width, int height)
static VideoFrame.Buffer | cropAndScaleI420 (final I420Buffer buffer, int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight)

## Detailed Description

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

## Member Function Documentation

## ◆ wrap()

static JavaI420Buffer io.agora.base.JavaI420Buffer.wrap | ( | int | width,
|  | int | height,
|  | ByteBuffer | dataY,
|  | int | strideY,
|  | ByteBuffer | dataU,
|  | int | strideU,
|  | ByteBuffer | dataV,
|  | int | strideV,
|  | @Nullable Runnable | releaseCallback
| ) |  |
| static

Wraps existing ByteBuffers into JavaI420Buffer object without copying the contents.

Parameters

  width | width.
  height | height.
  dataY | direct buffer, not allowed to be null, otherwise exception will throw.
  strideY | stride y.
  dataU | direct buffer, not allowed to be null, otherwise exception will throw.
  strideU | stride u.
  dataV | direct buffer, not allowed to be null, otherwise exception will throw.
  strideV | stride v.
  releaseCallback | nullable, invoked the this buffer released.

Returns
  the JavaI420Buffer.

## ◆ allocate()

static JavaI420Buffer io.agora.base.JavaI420Buffer.allocate | ( | int | width,
|  | int | height
| ) |  |
| static

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

Parameters

  width | width.
  height | height.

Returns
  an empty I420Buffer.

## ◆ getWidth()

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

Resolution of the buffer in pixels.

Returns
  width.

Implements io.agora.base.VideoFrame.Buffer.

## ◆ getHeight()

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

Resolution of the buffer in pixels.

Returns
  height.

Implements io.agora.base.VideoFrame.Buffer.

## ◆ getDataY()

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

## ◆ getDataU()

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

## ◆ getDataV()

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

## ◆ toI420()

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

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.JavaI420Buffer.retain | ( |  | ) |

Increases ref count by one.

Implements io.agora.base.VideoFrame.Buffer.

## ◆ release()

void io.agora.base.JavaI420Buffer.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.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|.

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.JavaI420Buffer.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.JavaI420Buffer.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.JavaI420Buffer.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.

## ◆ cropAndScaleI420()

static VideoFrame.Buffer io.agora.base.JavaI420Buffer.cropAndScaleI420 | ( | final I420Buffer | buffer,
|  | int | cropX,
|  | int | cropY,
|  | int | cropWidth,
|  | int | cropHeight,
|  | int | scaleWidth,
|  | int | scaleHeight
| ) |  |
| static

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.