io.agora.rtc

## Class ExternalVideoFrame

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

-     public class ExternalVideoFrame
      extends java.lang.Object

  External video frame for custom video source.

- - ### 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 java.nio.ByteBuffer` | `buffer` The video buffer.Must be DirectByteBuffer
    `private ColorSpace` | `colorSpace` The color space type.
    `private int` | `cropBottom` [Raw data related parameter] The number of pixels trimmed from the bottom.
    `private int` | `cropLeft` [Raw data related parameter] The number of pixels trimmed from the left.
    `private int` | `cropRight` [Raw data related parameter] The number of pixels trimmed from the right.
    `private int` | `cropTop` [Raw data related parameter] The number of pixels trimmed from the top.
    `private java.lang.Object` | `eglContext` [Texture-related parameter] When using the OpenGL interface (javax.microedition.khronos.egl.*) defined by Khronos, set EGLContext to this field.
    `private int` | `eglType` [Texture related parameter] Texture ID used by the video frame.
    `private int` | `fillAlphaBuffer` [For bgra or rgba only] Extract alphaBuffer from bgra or rgba data.
    `private int` | `format` The pixel format.
    `private int` | `height` Height of the incoming video frame.
    `private float` | `matrix` [Texture related parameter] Incoming 4 × 4 transformational matrix.
    `private java.nio.ByteBuffer` | `metadataBuffer` [Texture related parameter] The MetaData buffer.
    `private int` | `rotation` [Raw data related parameter] The clockwise rotation of the video frame.
    `private int` | `stride` Line spacing of the incoming video frame, which must be in pixels instead of bytes.
    `private int` | `textureId` [Texture related parameter] Incoming 4 × 4 transformational matrix.
    `private long` | `timestamp` Timestamp of the incoming video frame (ms).
    `private int` | `type` The buffer type.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExternalVideoFrame()` Default constructor for ExternalVideoFrame.
    `ExternalVideoFrame(int type, int format, java.nio.ByteBuffer buffer, int stride, int height, int cropLeft, int cropTop, int cropRight, int cropBottom, int rotation, long timestamp, java.lang.Object eglContext, int eglType, int textureId, float matrix, java.nio.ByteBuffer metadataBuffer, java.nio.ByteBuffer alphaBuffer, int fillAlphaBuffer, int alphaMode, ColorSpace colorSpace)` Constructs ExternalVideoFrame 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.
    `java.nio.ByteBuffer` | `getBuffer()` Gets the video buffer (must be DirectByteBuffer).
    `ColorSpace` | `getColorSpace()` Gets the color space type.
    `int` | `getCropBottom()` Gets the number of pixels trimmed from the bottom.
    `int` | `getCropLeft()` Gets the number of pixels trimmed from the left.
    `int` | `getCropRight()` Gets the number of pixels trimmed from the right.
    `int` | `getCropTop()` Gets the number of pixels trimmed from the top.
    `java.lang.Object` | `getEglContext()` Gets the EGL context for texture.
    `int` | `getEglType()` Gets the EGL type.
    `int` | `getFillAlphaBuffer()` Gets whether to extract alphaBuffer from bgra or rgba data.
    `int` | `getFormat()` Gets the pixel format.
    `int` | `getHeight()` Gets the height of the incoming video frame.
    `float` | `getMatrix()` Gets the incoming 4x4 transformational matrix.
    `java.nio.ByteBuffer` | `getMetadataBuffer()` Gets the MetaData buffer.
    `int` | `getRotation()` Gets the clockwise rotation of the video frame (0, 90, 180, or 270).
    `int` | `getStride()` Gets the line spacing of the incoming video frame in pixels.
    `int` | `getTextureId()` Gets the texture ID used by the video frame.
    `long` | `getTimestamp()` Gets the timestamp of the incoming video frame (ms).
    `int` | `getType()` Gets the buffer type.
    `void` | `setAlphaBuffer(java.nio.ByteBuffer buffer)` Sets the Portrait Segmentation meta buffer.
    `void` | `setAlphaMode(int alphaMode)` Sets the relative position between alphabuffer and the frame.
    `void` | `setBuffer(java.nio.ByteBuffer buffer)` Sets the video buffer (must be DirectByteBuffer).
    `void` | `setColorSpace(ColorSpace colorSpace)` Sets the color space type.
    `void` | `setCropBottom(int cropBottom)` Sets the number of pixels trimmed from the bottom.
    `void` | `setCropLeft(int cropLeft)` Sets the number of pixels trimmed from the left.
    `void` | `setCropRight(int cropRight)` Sets the number of pixels trimmed from the right.
    `void` | `setCropTop(int cropTop)` Sets the number of pixels trimmed from the top.
    `void` | `setEglContext(java.lang.Object eglContext)` Sets the EGL context for texture.
    `void` | `setEglType(int eglType)` Sets the EGL type.
    `void` | `setFillAlphaBuffer(int fillAlphaBuffer)` Sets whether to extract alphaBuffer from bgra or rgba data.
    `void` | `setFormat(int format)` Sets the pixel format.
    `void` | `setHeight(int height)` Sets the height of the incoming video frame.
    `void` | `setMatrix(float matrix)` Sets the incoming 4x4 transformational matrix.
    `void` | `setMetadataBuffer(java.nio.ByteBuffer metadataBuffer)` Sets the MetaData buffer.
    `void` | `setRotation(int rotation)` Sets the clockwise rotation of the video frame (0, 90, 180, or 270).
    `void` | `setStride(int stride)` Sets the line spacing of the incoming video frame in pixels.
    `void` | `setTextureId(int textureId)` Sets the texture ID used by the video frame.
    `void` | `setTimestamp(long timestamp)` Sets the timestamp of the incoming video frame (ms).
    `void` | `setType(int type)` Sets the buffer type.
    `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

      The buffer type. See #VIDEO_BUFFER_TYPE

    - #### format

          private int format

      The pixel format. See #VIDEO_PIXEL_FORMAT

    - #### buffer

          private java.nio.ByteBuffer buffer

      The video buffer.Must be DirectByteBuffer

    - #### stride

          private int stride

      Line spacing of the incoming video frame, which must be in pixels instead of bytes. For textures, it is the width of the texture.

    - #### height

          private int height

      Height of the incoming video frame.

    - #### cropLeft

          private int cropLeft

      [Raw data related parameter] The number of pixels trimmed from the left. The default value is 0.

    - #### cropTop

          private int cropTop

      [Raw data related parameter] The number of pixels trimmed from the top. The default value is 0.

    - #### cropRight

          private int cropRight

      [Raw data related parameter] The number of pixels trimmed from the right. The default value is 0.

    - #### cropBottom

          private int cropBottom

      [Raw data related parameter] The number of pixels trimmed from the bottom. The default value is 0.

    - #### rotation

          private int rotation

      [Raw data related parameter] The clockwise rotation of the video frame. You can set the rotation angle as 0, 90, 180, or 270. The default value is 0.

    - #### timestamp

          private long timestamp

      Timestamp of the incoming video frame (ms). An incorrect timestamp results in frame loss or unsynchronized audio and video.

    - #### eglContext

          private java.lang.Object eglContext

      [Texture-related parameter] When using the OpenGL interface (javax.microedition.khronos.egl.*) defined by Khronos, set EGLContext to this field. When using the OpenGL interface (android.opengl.*) defined by Android, set EGLContext to this field.

    - #### eglType

          private int eglType

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

    - #### textureId

          private int textureId

      [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix.

    - #### matrix

          private float matrix

      [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix.

    - #### metadataBuffer

          private java.nio.ByteBuffer metadataBuffer

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

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

    - #### fillAlphaBuffer

          private int fillAlphaBuffer

      [For bgra or rgba only] Extract alphaBuffer from bgra or rgba data. Set it true if you do not explicitly specify the alphabuffer. The default value is false

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

    - #### colorSpace

          private ColorSpace colorSpace

      The color space type.

  - ### Constructor Detail

    - #### ExternalVideoFrame

          public ExternalVideoFrame()

      Default constructor for ExternalVideoFrame.

    - #### ExternalVideoFrame

          public ExternalVideoFrame(int type,
                                    int format,
                                    java.nio.ByteBuffer buffer,
                                    int stride,
                                    int height,
                                    int cropLeft,
                                    int cropTop,
                                    int cropRight,
                                    int cropBottom,
                                    int rotation,
                                    long timestamp,
                                    java.lang.Object eglContext,
                                    int eglType,
                                    int textureId,
                                    float matrix,
                                    java.nio.ByteBuffer metadataBuffer,
                                    java.nio.ByteBuffer alphaBuffer,
                                    int fillAlphaBuffer,
                                    int alphaMode,
                                    ColorSpace colorSpace)

      Constructs ExternalVideoFrame with all parameters.
      Parameters:
        `type` - The buffer type
        `format` - The pixel format
        `buffer` - The video buffer (must be DirectByteBuffer)
        `stride` - Line spacing of the incoming video frame in pixels
        `height` - Height of the incoming video frame
        `cropLeft` - The number of pixels trimmed from the left
        `cropTop` - The number of pixels trimmed from the top
        `cropRight` - The number of pixels trimmed from the right
        `cropBottom` - The number of pixels trimmed from the bottom
        `rotation` - The clockwise rotation of the video frame (0, 90, 180, or 270)
        `timestamp` - Timestamp of the incoming video frame (ms)
        `eglContext` - EGL context for texture
        `eglType` - EGL type
        `textureId` - Texture ID used by the video frame
        `matrix` - Incoming 4x4 transformational matrix
        `metadataBuffer` - The MetaData buffer
        `alphaBuffer` - Portrait Segmentation meta buffer
        `fillAlphaBuffer` - Extract alphaBuffer from bgra or rgba data
        `alphaMode` - The relative position between alphabuffer and the frame
        `colorSpace` - The color space type

  - ### Method Detail

    - #### getType

          public int getType()

      Gets the buffer type.
      Returns:
        The buffer type

    - #### setType

          public void setType(int type)

      Sets the buffer type.
      Parameters:
        `type` - The buffer type

    - #### getFormat

          public int getFormat()

      Gets the pixel format.
      Returns:
        The pixel format

    - #### setFormat

          public void setFormat(int format)

      Sets the pixel format.
      Parameters:
        `format` - The pixel format

    - #### getBuffer

          public java.nio.ByteBuffer getBuffer()

      Gets the video buffer (must be DirectByteBuffer).
      Returns:
        The video buffer

    - #### setBuffer

          public void setBuffer(java.nio.ByteBuffer buffer)

      Sets the video buffer (must be DirectByteBuffer).
      Parameters:
        `buffer` - The video buffer

    - #### getStride

          public int getStride()

      Gets the line spacing of the incoming video frame in pixels.
      Returns:
        Line spacing of the incoming video frame in pixels

    - #### setStride

          public void setStride(int stride)

      Sets the line spacing of the incoming video frame in pixels.
      Parameters:
        `stride` - Line spacing of the incoming video frame in pixels

    - #### getHeight

          public int getHeight()

      Gets the height of the incoming video frame.
      Returns:
        Height of the incoming video frame

    - #### setHeight

          public void setHeight(int height)

      Sets the height of the incoming video frame.
      Parameters:
        `height` - Height of the incoming video frame

    - #### getCropLeft

          public int getCropLeft()

      Gets the number of pixels trimmed from the left.
      Returns:
        The number of pixels trimmed from the left

    - #### setCropLeft

          public void setCropLeft(int cropLeft)

      Sets the number of pixels trimmed from the left.
      Parameters:
        `cropLeft` - The number of pixels trimmed from the left

    - #### getCropTop

          public int getCropTop()

      Gets the number of pixels trimmed from the top.
      Returns:
        The number of pixels trimmed from the top

    - #### setCropTop

          public void setCropTop(int cropTop)

      Sets the number of pixels trimmed from the top.
      Parameters:
        `cropTop` - The number of pixels trimmed from the top

    - #### getCropRight

          public int getCropRight()

      Gets the number of pixels trimmed from the right.
      Returns:
        The number of pixels trimmed from the right

    - #### setCropRight

          public void setCropRight(int cropRight)

      Sets the number of pixels trimmed from the right.
      Parameters:
        `cropRight` - The number of pixels trimmed from the right

    - #### getCropBottom

          public int getCropBottom()

      Gets the number of pixels trimmed from the bottom.
      Returns:
        The number of pixels trimmed from the bottom

    - #### setCropBottom

          public void setCropBottom(int cropBottom)

      Sets the number of pixels trimmed from the bottom.
      Parameters:
        `cropBottom` - The number of pixels trimmed from the bottom

    - #### getRotation

          public int getRotation()

      Gets the clockwise rotation of the video frame (0, 90, 180, or 270).
      Returns:
        The clockwise rotation of the video frame

    - #### setRotation

          public void setRotation(int rotation)

      Sets the clockwise rotation of the video frame (0, 90, 180, or 270).
      Parameters:
        `rotation` - The clockwise rotation of the video frame

    - #### getTimestamp

          public long getTimestamp()

      Gets the timestamp of the incoming video frame (ms).
      Returns:
        Timestamp of the incoming video frame (ms)

    - #### setTimestamp

          public void setTimestamp(long timestamp)

      Sets the timestamp of the incoming video frame (ms).
      Parameters:
        `timestamp` - Timestamp of the incoming video frame (ms)

    - #### getEglContext

          public java.lang.Object getEglContext()

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

    - #### setEglContext

          public void setEglContext(java.lang.Object eglContext)

      Sets the EGL context for texture.
      Parameters:
        `eglContext` - EGL context for texture

    - #### getEglType

          public int getEglType()

      Gets the EGL type.
      Returns:
        EGL type

    - #### setEglType

          public void setEglType(int eglType)

      Sets the EGL type.
      Parameters:
        `eglType` - EGL type

    - #### getTextureId

          public int getTextureId()

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

    - #### setTextureId

          public void setTextureId(int textureId)

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

    - #### getMatrix

          public float getMatrix()

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

    - #### setMatrix

          public void setMatrix(float matrix)

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

    - #### getMetadataBuffer

          public java.nio.ByteBuffer getMetadataBuffer()

      Gets the MetaData buffer.
      Returns:
        The MetaData buffer

    - #### setMetadataBuffer

          public void setMetadataBuffer(java.nio.ByteBuffer metadataBuffer)

      Sets the MetaData buffer.
      Parameters:
        `metadataBuffer` - The MetaData buffer

    - #### getAlphaBuffer

          public java.nio.ByteBuffer getAlphaBuffer()

      Gets the Portrait Segmentation meta buffer.
      Returns:
        Portrait Segmentation meta buffer

    - #### setAlphaBuffer

          public void setAlphaBuffer(java.nio.ByteBuffer buffer)

      Sets the Portrait Segmentation meta buffer.
      Parameters:
        `buffer` - Portrait Segmentation meta buffer

    - #### getFillAlphaBuffer

          public int getFillAlphaBuffer()

      Gets whether to extract alphaBuffer from bgra or rgba data.
      Returns:
        Whether to extract alphaBuffer from bgra or rgba data

    - #### setFillAlphaBuffer

          public void setFillAlphaBuffer(int fillAlphaBuffer)

      Sets whether to extract alphaBuffer from bgra or rgba data.
      Parameters:
        `fillAlphaBuffer` - Whether to extract alphaBuffer from bgra or rgba data

    - #### getAlphaMode

          public int getAlphaMode()

      Gets the relative position between alphabuffer and the frame.
      Returns:
        The relative position between alphabuffer and the frame

    - #### setAlphaMode

          public void setAlphaMode(int alphaMode)

      Sets the relative position between alphabuffer and the frame.
      Parameters:
        `alphaMode` - The relative position between alphabuffer and the frame

    - #### getColorSpace

          public ColorSpace getColorSpace()

      Gets the color space type.
      Returns:
        The color space type

    - #### setColorSpace

          public void setColorSpace(ColorSpace colorSpace)

      Sets the color space type.
      Parameters:
        `colorSpace` - The color space type

    - #### toString

          public java.lang.String toString()

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