Package tvi.webrtc

Class VideoFrame

java.lang.Object
tvi.webrtc.VideoFrame
All Implemented Interfaces:
RefCounted

public class VideoFrame extends Object implements RefCounted
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 Details

    • VideoFrame

      public VideoFrame(VideoFrame.Buffer buffer, int rotation, long timestampNs)
      Constructs a new VideoFrame backed by the given buffer. Note: Ownership of the buffer object is tranferred to the new VideoFrame.
  • Method Details

    • getBuffer

      public VideoFrame.Buffer getBuffer()
    • getRotation

      public int getRotation()
      Rotation of the frame in degrees.
    • getTimestampNs

      public long getTimestampNs()
      Timestamp of the frame in nano seconds.
    • getRotatedWidth

      public int getRotatedWidth()
    • getRotatedHeight

      public int getRotatedHeight()
    • retain

      public void retain()
      Description copied from interface: RefCounted
      Increases ref count by one.
      Specified by:
      retain in interface RefCounted
    • release

      public void release()
      Description copied from interface: RefCounted
      Decreases ref count by one. When the ref count reaches zero, resources related to the object will be freed.
      Specified by:
      release in interface RefCounted