Class VideoFrame

java.lang.Object
org.javagi.base.ProxyInstance
org.freedesktop.gstreamer.video.VideoFrame
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class VideoFrame extends ProxyInstance
A video frame obtained from gst_video_frame_map()
  • Constructor Details

    • VideoFrame

      public VideoFrame(MemorySegment address)
      Create a VideoFrame proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • VideoFrame

      public VideoFrame(Arena arena)
      Allocate a new VideoFrame.
      Parameters:
      arena - to control the memory allocation scope
    • VideoFrame

      public VideoFrame()
      Allocate a new VideoFrame. The memory is allocated with Arena.ofAuto().
    • VideoFrame

      public VideoFrame(VideoInfo info, Set<VideoFrameFlags> flags, Buffer buffer, MemorySegment meta, int id, MemorySegment[] data, MapInfo[] map, Arena arena)
      Allocate a new VideoFrame with the fields set to the provided values.
      Parameters:
      info - value for the field info
      flags - value for the field flags
      buffer - value for the field buffer
      meta - value for the field meta
      id - value for the field id
      data - value for the field data
      map - value for the field map
      arena - to control the memory allocation scope
    • VideoFrame

      public VideoFrame(VideoInfo info, Set<VideoFrameFlags> flags, Buffer buffer, MemorySegment meta, int id, MemorySegment[] data, MapInfo[] map)
      Allocate a new VideoFrame with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      info - value for the field info
      flags - value for the field flags
      buffer - value for the field buffer
      meta - value for the field meta
      id - value for the field id
      data - value for the field data
      map - value for the field map
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readInfo

      public @Nullable VideoInfo readInfo()
      Read the value of the field info.
      Returns:
      The value of the field info
    • writeInfo

      public void writeInfo(@Nullable VideoInfo info)
      Write a value in the field info.
      Parameters:
      info - The new value for the field info
    • readFlags

      public Set<VideoFrameFlags> readFlags()
      Read the value of the field flags.
      Returns:
      The value of the field flags
    • writeFlags

      public void writeFlags(Set<VideoFrameFlags> flags)
      Write a value in the field flags.
      Parameters:
      flags - The new value for the field flags
    • readBuffer

      public Buffer readBuffer()
      Read the value of the field buffer.
      Returns:
      The value of the field buffer
    • writeBuffer

      public void writeBuffer(Buffer buffer)
      Write a value in the field buffer.
      Parameters:
      buffer - The new value for the field buffer
    • readMeta

      public MemorySegment readMeta()
      Read the value of the field meta.
      Returns:
      The value of the field meta
    • writeMeta

      public void writeMeta(MemorySegment meta)
      Write a value in the field meta.
      Parameters:
      meta - The new value for the field meta
    • readId

      public int readId()
      Read the value of the field id.
      Returns:
      The value of the field id
    • writeId

      public void writeId(int id)
      Write a value in the field id.
      Parameters:
      id - The new value for the field id
    • readData

      public @Nullable MemorySegment @Nullable [] readData()
      Read the value of the field data.
      Returns:
      The value of the field data
    • writeData

      public void writeData(@Nullable MemorySegment @Nullable [] data, Arena _arena)
      Write a value in the field data.
      Parameters:
      data - The new value for the field data
    • readMap

      public @Nullable MapInfo @Nullable [] readMap()
      Read the value of the field map.
      Returns:
      The value of the field map
    • writeMap

      public void writeMap(@Nullable MapInfo @Nullable [] map, Arena _arena)
      Write a value in the field map.
      Parameters:
      map - The new value for the field map
    • map

      public static boolean map(VideoFrame frame, VideoInfo info, Buffer buffer, int flags)

      Use info and buffer to fill in the values of frame. frame is usually allocated on the stack, and you will pass the address to the GstVideoFrame structure allocated on the stack; gst_video_frame_map() will then fill in the structures with the various video-specific information you need to access the pixels of the video buffer. You can then use accessor macros such as GST_VIDEO_FRAME_COMP_DATA(), GST_VIDEO_FRAME_PLANE_DATA(), GST_VIDEO_FRAME_COMP_STRIDE(), GST_VIDEO_FRAME_PLANE_STRIDE() etc. to get to the pixels.

        GstVideoFrame vframe;
        ...
        // set RGB pixels to black one at a time
        if (gst_video_frame_map (&vframe, video_info, video_buffer, GST_MAP_WRITE)) {
          guint8 *pixels = GST_VIDEO_FRAME_PLANE_DATA (vframe, 0);
          guint stride = GST_VIDEO_FRAME_PLANE_STRIDE (vframe, 0);
          guint pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (vframe, 0);
      
          for (h = 0; h < height; ++h) {
            for (w = 0; w < width; ++w) {
              guint8 *pixel = pixels + h * stride + w * pixel_stride;
      
              memset (pixel, 0, pixel_stride);
            }
          }
      
          gst_video_frame_unmap (&vframe);
        }
        ...
      

      All video planes of buffer will be mapped and the pointers will be set in frame>data.

      The purpose of this function is to make it easy for you to get to the video pixels in a generic way, without you having to worry too much about details such as whether the video data is allocated in one contiguous memory chunk or multiple memory chunks (e.g. one for each plane); or if custom strides and custom plane offsets are used or not (as signalled by GstVideoMeta on each buffer). This function will just fill the GstVideoFrame structure with the right values and if you use the accessor macros everything will just work and you can access the data easily. It also maps the underlying memory chunks for you.

      Parameters:
      frame - pointer to GstVideoFrame
      info - a GstVideoInfo
      buffer - the buffer to map
      flags - GstMapFlags
      Returns:
      true on success.
    • mapId

      public static boolean mapId(VideoFrame frame, VideoInfo info, Buffer buffer, int id, int flags)

      Use info and buffer to fill in the values of frame with the video frame information of frame id.

      When id is -1, the default frame is mapped. When id != -1, this function will return false when there is no GstVideoMeta with that id.

      All video planes of buffer will be mapped and the pointers will be set in frame>data.

      Parameters:
      frame - pointer to GstVideoFrame
      info - a GstVideoInfo
      buffer - the buffer to map
      id - the frame id to map
      flags - GstMapFlags
      Returns:
      true on success.
    • copy

      public boolean copy(VideoFrame src)

      Copy the contents from src to dest.

      Note: Since: 1.18, this VideoFrame dimensions are allowed to be smaller than src dimensions.

      Parameters:
      src - a GstVideoFrame
      Returns:
      TRUE if the contents could be copied.
    • copyPlane

      public boolean copyPlane(VideoFrame src, int plane)

      Copy the plane with index plane from src to dest.

      Note: Since: 1.18, this VideoFrame dimensions are allowed to be smaller than src dimensions.

      Parameters:
      src - a GstVideoFrame
      plane - a plane
      Returns:
      TRUE if the contents could be copied.
    • unmap

      public void unmap()
      Unmap the memory previously mapped with gst_video_frame_map.