Agora Java API Reference for Android
Classes | Public Member Functions | List of all members
io.agora.base.VideoFrame Class Reference
Inheritance diagram for io.agora.base.VideoFrame:

Classes

interface  Buffer
 
interface  ColorSpace
 
interface  I420Buffer
 
interface  TextureBuffer
 

Public Member Functions

 VideoFrame (Buffer buffer, int rotation, long timestampNs)
 
 VideoFrame (Buffer buffer, int rotation, long timestampNs, ColorSpace colorSpace, float sampleAspectRatio)
 
float getSampleAspectRatio ()
 
Buffer getBuffer ()
 
int getRotation ()
 
long getTimestampNs ()
 
VideoFrameMetaInfo getMetaInfo ()
 
int getRotatedWidth ()
 
int getRotatedHeight ()
 
void replaceBuffer (Buffer buffer, int rotation, long timestampNs)
 
ColorSpace getColorSpace ()
 
void retain ()
 
void release ()
 

Detailed Description

Java version of webrtc::VideoFrame and webrtc::VideoFrameBuffer. A difference from the C++ version is that no explicit tag is used, and clients are expected to use 'instanceof' to find the right subclass of the buffer. This allows clients to create custom VideoFrame.Buffer in arbitrary format in their custom VideoSources, and then cast it back to the correct subclass in their custom VideoSinks. All implementations must also implement the toI420() function, converting from the underlying representation if necessary. I420 is the most widely accepted format and serves as a fallback for video sinks that can only handle I420, e.g. the internal WebRTC software encoders.

Constructor & Destructor Documentation

◆ VideoFrame()

io.agora.base.VideoFrame.VideoFrame ( Buffer  buffer,
int  rotation,
long  timestampNs 
)

Constructs a new VideoFrame backed by the given

buffer

.

Parameters
buffernot allowed to be null, otherwise exception will throw
rotationmust be a multiple of 90, otherwise exception will throw
timestampNsin nanosecond, otherwise video frame may not been sent
Note
Ownership of the buffer object is tranferred to the new VideoFrame.

Member Function Documentation

◆ getBuffer()

Buffer io.agora.base.VideoFrame.getBuffer ( )
Returns
the inner buffer Buffer.

◆ getRotation()

int io.agora.base.VideoFrame.getRotation ( )

Rotation of the frame in degrees.

◆ getTimestampNs()

long io.agora.base.VideoFrame.getTimestampNs ( )

Timestamp of the frame in nano seconds.

◆ getRotatedWidth()

int io.agora.base.VideoFrame.getRotatedWidth ( )
Returns
rotated width.

◆ getRotatedHeight()

int io.agora.base.VideoFrame.getRotatedHeight ( )
Returns
rotated height.

◆ replaceBuffer()

void io.agora.base.VideoFrame.replaceBuffer ( Buffer  buffer,
int  rotation,
long  timestampNs 
)

replace VideoFrame content.

Note
Ownership of the buffer object is tranferred to the VideoFrame.

◆ retain()

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

Increases inner buffer's ref count by one.

◆ release()

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

Decreases inner buffer's ref count by one. When the ref count reaches zero, resources related to the inner buffer will be freed.