Class VideoFrame
-
Constructor Summary
ConstructorDescriptionAllocate a new VideoFrame.VideoFrame
(Arena arena) Allocate a new VideoFrame.VideoFrame
(MemorySegment address) Create a VideoFrame proxy instance for the provided memory address.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.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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
copy
(VideoFrame src) Copy the contents fromsrc
to this VideoFrame.boolean
copyPlane
(VideoFrame src, int plane) Copy the plane with indexplane
fromsrc
to this VideoFrame.static MemoryLayout
The memory layout of the native struct.static boolean
Useinfo
andbuffer
to fill in the values offrame
.static boolean
map
(VideoFrame frame, VideoInfo info, Buffer buffer, MapFlags... flags) Useinfo
andbuffer
to fill in the values offrame
.static boolean
Useinfo
andbuffer
to fill in the values offrame
with the video frame information of frameid
.static boolean
mapId
(VideoFrame frame, VideoInfo info, Buffer buffer, int id, MapFlags... flags) Useinfo
andbuffer
to fill in the values offrame
with the video frame information of frameid
.Read the value of the fieldbuffer
.readData()
Read the value of the fielddata
.Read the value of the fieldflags
.int
readId()
Read the value of the fieldid
.readInfo()
Read the value of the fieldinfo
.MapInfo[]
readMap()
Read the value of the fieldmap
.readMeta()
Read the value of the fieldmeta
.void
unmap()
Unmap the memory previously mapped with gst_video_frame_map.void
writeBuffer
(Buffer buffer) Write a value in the fieldbuffer
.void
writeData
(MemorySegment[] data, Arena _arena) Write a value in the fielddata
.void
writeFlags
(Set<VideoFrameFlags> flags) Write a value in the fieldflags
.void
writeId
(int id) Write a value in the fieldid
.void
Write a value in the fieldinfo
.void
Write a value in the fieldmap
.void
writeMeta
(MemorySegment meta) Write a value in the fieldmeta
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
VideoFrame
Create a VideoFrame proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
VideoFrame
Allocate a new VideoFrame.- Parameters:
arena
- to control the memory allocation scope
-
VideoFrame
public VideoFrame()Allocate a new VideoFrame. The memory is allocated withArena.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 fieldinfo
flags
- value for the fieldflags
buffer
- value for the fieldbuffer
meta
- value for the fieldmeta
id
- value for the fieldid
data
- value for the fielddata
map
- value for the fieldmap
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 withArena.ofAuto()
.- Parameters:
info
- value for the fieldinfo
flags
- value for the fieldflags
buffer
- value for the fieldbuffer
meta
- value for the fieldmeta
id
- value for the fieldid
data
- value for the fielddata
map
- value for the fieldmap
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readInfo
-
writeInfo
Write a value in the fieldinfo
.- Parameters:
info
- The new value for the fieldinfo
-
readFlags
Read the value of the fieldflags
.- Returns:
- The value of the field
flags
-
writeFlags
Write a value in the fieldflags
.- Parameters:
flags
- The new value for the fieldflags
-
readBuffer
Read the value of the fieldbuffer
.- Returns:
- The value of the field
buffer
-
writeBuffer
Write a value in the fieldbuffer
.- Parameters:
buffer
- The new value for the fieldbuffer
-
readMeta
Read the value of the fieldmeta
.- Returns:
- The value of the field
meta
-
writeMeta
Write a value in the fieldmeta
.- Parameters:
meta
- The new value for the fieldmeta
-
readId
public int readId()Read the value of the fieldid
.- Returns:
- The value of the field
id
-
writeId
public void writeId(int id) Write a value in the fieldid
.- Parameters:
id
- The new value for the fieldid
-
readData
Read the value of the fielddata
.- Returns:
- The value of the field
data
-
writeData
Write a value in the fielddata
.- Parameters:
data
- The new value for the fielddata
_arena
- to control the memory allocation scope
-
readMap
-
writeMap
-
map
Useinfo
andbuffer
to fill in the values offrame
.frame
is usually allocated on the stack, and you will pass the address to theGstVideoFrame
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 inframe
->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 toGstVideoFrame
info
- aGstVideoInfo
buffer
- the buffer to mapflags
-GstMapFlags
- Returns:
true
on success.
-
map
Useinfo
andbuffer
to fill in the values offrame
.frame
is usually allocated on the stack, and you will pass the address to theGstVideoFrame
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 inframe
->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 toGstVideoFrame
info
- aGstVideoInfo
buffer
- the buffer to mapflags
-GstMapFlags
- Returns:
true
on success.
-
mapId
public static boolean mapId(VideoFrame frame, VideoInfo info, Buffer buffer, int id, Set<MapFlags> flags) Useinfo
andbuffer
to fill in the values offrame
with the video frame information of frameid
.When
id
is -1, the default frame is mapped. Whenid
!= -1, this function will returnfalse
when there is no GstVideoMeta with that id.All video planes of
buffer
will be mapped and the pointers will be set inframe
->data.- Parameters:
frame
- pointer toGstVideoFrame
info
- aGstVideoInfo
buffer
- the buffer to mapid
- the frame id to mapflags
-GstMapFlags
- Returns:
true
on success.
-
mapId
public static boolean mapId(VideoFrame frame, VideoInfo info, Buffer buffer, int id, MapFlags... flags) Useinfo
andbuffer
to fill in the values offrame
with the video frame information of frameid
.When
id
is -1, the default frame is mapped. Whenid
!= -1, this function will returnfalse
when there is no GstVideoMeta with that id.All video planes of
buffer
will be mapped and the pointers will be set inframe
->data.- Parameters:
frame
- pointer toGstVideoFrame
info
- aGstVideoInfo
buffer
- the buffer to mapid
- the frame id to mapflags
-GstMapFlags
- Returns:
true
on success.
-
copy
Copy the contents fromsrc
to this VideoFrame.Note: Since: 1.18, this VideoFrame dimensions are allowed to be smaller than
src
dimensions.- Parameters:
src
- aGstVideoFrame
- Returns:
- TRUE if the contents could be copied.
-
copyPlane
Copy the plane with indexplane
fromsrc
to this VideoFrame.Note: Since: 1.18, this VideoFrame dimensions are allowed to be smaller than
src
dimensions.- Parameters:
src
- aGstVideoFrame
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.
-