io.agora.rtc

## Class VideoFrame

- java.lang.Object
- - io.agora.rtc.VideoFrame

-     public class VideoFrame
      extends java.lang.Object

  Video frame class. Represents a video frame with YUV data, texture information, and metadata.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.nio.ByteBuffer` | `alphaBuffer` Portrait Segmentation meta buffer, dimension of which is the same as VideoFrame.
    `private int` | `alphaMode` The relative position between alphabuffer and the frame.
    `private int` | `avsyncType` Audio-video synchronization type.
    `private int` | `height` Video pixel height.
    `private float[]` | `matrix` [Texture related parameter], Incoming 4 × 4 transformational matrix.
    `private java.nio.ByteBuffer` | `metadataBuffer` [Texture related parameter] The MetaData buffer.
    `private long` | `renderTimeMs` Timestamp to render the video stream.
    `private int` | `rotation` rotation of this frame (0, 90, 180, 270)
    `private java.lang.Object` | `sharedContext` [Texture related parameter], egl context.
    `private int` | `textureId` [Texture related parameter], Texture ID used by the video frame.
    `private int` | `type` Video frame type.
    `private java.nio.ByteBuffer` | `uBuffer` U data buffer
    `private int` | `uStride` Line span of U buffer in YUV data.
    `private java.nio.ByteBuffer` | `vBuffer` V data buffer
    `private int` | `vStride` Line span of V buffer in YUV data.
    `private int` | `width` Video pixel width.
    `private java.nio.ByteBuffer` | `yBuffer` Y data buffer
    `private int` | `yStride` Line span of Y buffer in YUV data.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `VideoFrame()` Default constructor.
    `VideoFrame(int type, int width, int height, int yStride, int uStride, int vStride, java.nio.ByteBuffer yBuffer, java.nio.ByteBuffer uBuffer, java.nio.ByteBuffer vBuffer, int rotation, long renderTimeMs, int avsyncType, java.nio.ByteBuffer metadataBuffer, java.lang.Object sharedContext, int textureId, float[] matrix, java.nio.ByteBuffer alphaBuffer, int alphaMode)` Constructor with all parameters.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.nio.ByteBuffer` | `getAlphaBuffer()` Gets the portrait segmentation meta buffer.
    `int` | `getAlphaMode()` Gets the relative position between alphabuffer and the frame.
    `int` | `getAvsyncType()` Gets the audio-video synchronization type.
    `int` | `getHeight()` Gets the video pixel height.
    `float[]` | `getMatrix()` Gets the incoming 4x4 transformational matrix.
    `java.nio.ByteBuffer` | `getMetadataBuffer()` Gets the MetaData buffer (for texture).
    `long` | `getRenderTimeMs()` Gets the timestamp to render the video stream.
    `int` | `getRotation()` Gets the rotation of this frame.
    `java.lang.Object` | `getSharedContext()` Gets the EGL context (for texture).
    `int` | `getTextureId()` Gets the texture ID used by the video frame.
    `int` | `getType()` Gets the video frame type.
    `java.nio.ByteBuffer` | `getUBuffer()` Gets the U data buffer.
    `int` | `getUStride()` Gets the line span of U buffer in YUV data.
    `java.nio.ByteBuffer` | `getVBuffer()` Gets the V data buffer.
    `int` | `getVStride()` Gets the line span of V buffer in YUV data.
    `int` | `getWidth()` Gets the video pixel width.
    `java.nio.ByteBuffer` | `getYBuffer()` Gets the Y data buffer.
    `int` | `getYStride()` Gets the line span of Y buffer in YUV data.
    `void` | `setAlphaBuffer(java.nio.ByteBuffer alphaBuffer)` Sets the portrait segmentation meta buffer.
    `void` | `setAlphaMode(int alphaMode)` Sets the relative position between alphabuffer and the frame.
    `void` | `setAvsyncType(int avsyncType)` Sets the audio-video synchronization type.
    `void` | `setHeight(int height)` Sets the video pixel height.
    `void` | `setMatrix(float[] matrix)` Sets the incoming 4x4 transformational matrix.
    `void` | `setMetadataBuffer(java.nio.ByteBuffer metadataBuffer)` Sets the MetaData buffer (for texture).
    `void` | `setRenderTimeMs(long renderTimeMs)` Sets the timestamp to render the video stream.
    `void` | `setRotation(int rotation)` Sets the rotation of this frame.
    `void` | `setSharedContext(java.lang.Object sharedContext)` Sets the EGL context (for texture).
    `void` | `setTextureId(int textureId)` Sets the texture ID used by the video frame.
    `void` | `setType(int type)` Sets the video frame type.
    `void` | `setUBuffer(java.nio.ByteBuffer uBuffer)` Sets the U data buffer.
    `void` | `setUStride(int uStride)` Sets the line span of U buffer in YUV data.
    `void` | `setVBuffer(java.nio.ByteBuffer vBuffer)` Sets the V data buffer.
    `void` | `setVStride(int vStride)` Sets the line span of V buffer in YUV data.
    `void` | `setWidth(int width)` Sets the video pixel width.
    `void` | `setYBuffer(java.nio.ByteBuffer yBuffer)` Sets the Y data buffer.
    `void` | `setYStride(int yStride)` Sets the line span of Y buffer in YUV data.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### type

          private int type

      Video frame type.

    - #### width

          private int width

      Video pixel width.

    - #### height

          private int height

      Video pixel height.

    - #### yStride

          private int yStride

      Line span of Y buffer in YUV data.

    - #### uStride

          private int uStride

      Line span of U buffer in YUV data.

    - #### vStride

          private int vStride

      Line span of V buffer in YUV data.

    - #### yBuffer

          private java.nio.ByteBuffer yBuffer

      Y data buffer

    - #### uBuffer

          private java.nio.ByteBuffer uBuffer

      U data buffer

    - #### vBuffer

          private java.nio.ByteBuffer vBuffer

      V data buffer

    - #### rotation

          private int rotation

      rotation of this frame (0, 90, 180, 270)

    - #### renderTimeMs

          private long renderTimeMs

      Timestamp to render the video stream. It instructs the users to use this timestamp to synchronize the video stream render while rendering the video streams. Note: This timestamp is for rendering the video stream, not for capturing the video stream.

    - #### avsyncType

          private int avsyncType

      Audio-video synchronization type.

    - #### metadataBuffer

          private java.nio.ByteBuffer metadataBuffer

      [Texture related parameter] The MetaData buffer. The default value is NULL

    - #### sharedContext

          private java.lang.Object sharedContext

      [Texture related parameter], egl context.

    - #### textureId

          private int textureId

      [Texture related parameter], Texture ID used by the video frame.

    - #### matrix

          private float[] matrix

      [Texture related parameter], Incoming 4 × 4 transformational matrix.

    - #### alphaBuffer

          private java.nio.ByteBuffer alphaBuffer

      Portrait Segmentation meta buffer, dimension of which is the same as VideoFrame. Pixl value is between 0-255, 0 represents totally background, 255 represents totally foreground. The default value is NULL

    - #### alphaMode

          private int alphaMode

      The relative position between alphabuffer and the frame. 0: Normal frame; 1: Alphabuffer is above the frame; 2: Alphabuffer is below the frame; 3: Alphabuffer is on the left of frame; 4: Alphabuffer is on the right of frame; The default value is 0.

  - ### Constructor Detail

    - #### VideoFrame

          public VideoFrame()

      Default constructor.

    - #### VideoFrame

          public VideoFrame(int type,
                            int width,
                            int height,
                            int yStride,
                            int uStride,
                            int vStride,
                            java.nio.ByteBuffer yBuffer,
                            java.nio.ByteBuffer uBuffer,
                            java.nio.ByteBuffer vBuffer,
                            int rotation,
                            long renderTimeMs,
                            int avsyncType,
                            java.nio.ByteBuffer metadataBuffer,
                            java.lang.Object sharedContext,
                            int textureId,
                            float[] matrix,
                            java.nio.ByteBuffer alphaBuffer,
                            int alphaMode)

      Constructor with all parameters.
      Parameters:
        `type` - Video frame type
        `width` - Video pixel width
        `height` - Video pixel height
        `yStride` - Line span of Y buffer in YUV data
        `uStride` - Line span of U buffer in YUV data
        `vStride` - Line span of V buffer in YUV data
        `yBuffer` - Y data buffer
        `uBuffer` - U data buffer
        `vBuffer` - V data buffer
        `rotation` - Rotation of this frame (0, 90, 180, 270)
        `renderTimeMs` - Timestamp to render the video stream
        `avsyncType` - Audio-video synchronization type
        `metadataBuffer` - MetaData buffer (for texture)
        `sharedContext` - EGL context (for texture)
        `textureId` - Texture ID used by the video frame
        `matrix` - Incoming 4x4 transformational matrix
        `alphaBuffer` - Portrait Segmentation meta buffer
        `alphaMode` - The relative position between alphabuffer and the frame

  - ### Method Detail

    - #### getType

          public int getType()

      Gets the video frame type.
      Returns:
        Video frame type

    - #### setType

          public void setType(int type)

      Sets the video frame type.
      Parameters:
        `type` - Video frame type

    - #### getWidth

          public int getWidth()

      Gets the video pixel width.
      Returns:
        Video pixel width

    - #### setWidth

          public void setWidth(int width)

      Sets the video pixel width.
      Parameters:
        `width` - Video pixel width

    - #### getHeight

          public int getHeight()

      Gets the video pixel height.
      Returns:
        Video pixel height

    - #### setHeight

          public void setHeight(int height)

      Sets the video pixel height.
      Parameters:
        `height` - Video pixel height

    - #### getYStride

          public int getYStride()

      Gets the line span of Y buffer in YUV data.
      Returns:
        Line span of Y buffer

    - #### setYStride

          public void setYStride(int yStride)

      Sets the line span of Y buffer in YUV data.
      Parameters:
        `yStride` - Line span of Y buffer

    - #### getUStride

          public int getUStride()

      Gets the line span of U buffer in YUV data.
      Returns:
        Line span of U buffer

    - #### setUStride

          public void setUStride(int uStride)

      Sets the line span of U buffer in YUV data.
      Parameters:
        `uStride` - Line span of U buffer

    - #### getVStride

          public int getVStride()

      Gets the line span of V buffer in YUV data.
      Returns:
        Line span of V buffer

    - #### setVStride

          public void setVStride(int vStride)

      Sets the line span of V buffer in YUV data.
      Parameters:
        `vStride` - Line span of V buffer

    - #### getYBuffer

          public java.nio.ByteBuffer getYBuffer()

      Gets the Y data buffer.
      Returns:
        Y data buffer

    - #### setYBuffer

          public void setYBuffer(java.nio.ByteBuffer yBuffer)

      Sets the Y data buffer.
      Parameters:
        `yBuffer` - Y data buffer

    - #### getUBuffer

          public java.nio.ByteBuffer getUBuffer()

      Gets the U data buffer.
      Returns:
        U data buffer

    - #### setUBuffer

          public void setUBuffer(java.nio.ByteBuffer uBuffer)

      Sets the U data buffer.
      Parameters:
        `uBuffer` - U data buffer

    - #### getVBuffer

          public java.nio.ByteBuffer getVBuffer()

      Gets the V data buffer.
      Returns:
        V data buffer

    - #### setVBuffer

          public void setVBuffer(java.nio.ByteBuffer vBuffer)

      Sets the V data buffer.
      Parameters:
        `vBuffer` - V data buffer

    - #### getRotation

          public int getRotation()

      Gets the rotation of this frame.
      Returns:
        Rotation of this frame (0, 90, 180, 270)

    - #### setRotation

          public void setRotation(int rotation)

      Sets the rotation of this frame.
      Parameters:
        `rotation` - Rotation of this frame (0, 90, 180, 270)

    - #### getRenderTimeMs

          public long getRenderTimeMs()

      Gets the timestamp to render the video stream.
      Returns:
        Timestamp to render the video stream (in milliseconds)

    - #### setRenderTimeMs

          public void setRenderTimeMs(long renderTimeMs)

      Sets the timestamp to render the video stream.
      Parameters:
        `renderTimeMs` - Timestamp to render the video stream (in milliseconds)

    - #### getAvsyncType

          public int getAvsyncType()

      Gets the audio-video synchronization type.
      Returns:
        Audio-video synchronization type

    - #### setAvsyncType

          public void setAvsyncType(int avsyncType)

      Sets the audio-video synchronization type.
      Parameters:
        `avsyncType` - Audio-video synchronization type

    - #### getMetadataBuffer

          public java.nio.ByteBuffer getMetadataBuffer()

      Gets the MetaData buffer (for texture).
      Returns:
        MetaData buffer

    - #### setMetadataBuffer

          public void setMetadataBuffer(java.nio.ByteBuffer metadataBuffer)

      Sets the MetaData buffer (for texture).
      Parameters:
        `metadataBuffer` - MetaData buffer

    - #### getSharedContext

          public java.lang.Object getSharedContext()

      Gets the EGL context (for texture).
      Returns:
        EGL context

    - #### setSharedContext

          public void setSharedContext(java.lang.Object sharedContext)

      Sets the EGL context (for texture).
      Parameters:
        `sharedContext` - EGL context

    - #### getTextureId

          public int getTextureId()

      Gets the texture ID used by the video frame.
      Returns:
        Texture ID

    - #### setTextureId

          public void setTextureId(int textureId)

      Sets the texture ID used by the video frame.
      Parameters:
        `textureId` - Texture ID

    - #### getMatrix

          public float[] getMatrix()

      Gets the incoming 4x4 transformational matrix.
      Returns:
        4x4 transformational matrix

    - #### setMatrix

          public void setMatrix(float[] matrix)

      Sets the incoming 4x4 transformational matrix.
      Parameters:
        `matrix` - 4x4 transformational matrix

    - #### getAlphaBuffer

          public java.nio.ByteBuffer getAlphaBuffer()

      Gets the portrait segmentation meta buffer.
      Returns:
        Portrait segmentation meta buffer

    - #### setAlphaBuffer

          public void setAlphaBuffer(java.nio.ByteBuffer alphaBuffer)

      Sets the portrait segmentation meta buffer.
      Parameters:
        `alphaBuffer` - Portrait segmentation meta buffer

    - #### getAlphaMode

          public int getAlphaMode()

      Gets the relative position between alphabuffer and the frame.
      Returns:
        Alpha mode (0: Normal frame, 1: Above, 2: Below, 3: Left, 4: Right)

    - #### setAlphaMode

          public void setAlphaMode(int alphaMode)

      Sets the relative position between alphabuffer and the frame.
      Parameters:
        `alphaMode` - Alpha mode (0: Normal frame, 1: Above, 2: Below, 3: Left, 4: Right)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`