Class VideoFrame
-
Constructor Summary
ConstructorsConstructorDescriptionAllocate 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 TypeMethodDescriptionbooleancopy(VideoFrame src) Copy the contents fromsrctodest.booleancopyPlane(VideoFrame src, int plane) Copy the plane with indexplanefromsrctodest.static MemoryLayoutThe memory layout of the native struct.static booleanmap(VideoFrame frame, VideoInfo info, Buffer buffer, int flags) Useinfoandbufferto fill in the values offrame.frameis usually allocated on the stack, and you will pass the address to theGstVideoFramestructure 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.static booleanmapId(VideoFrame frame, VideoInfo info, Buffer buffer, int id, int flags) Useinfoandbufferto fill in the values offramewith the video frame information of frameid.Read the value of the fieldbuffer.@Nullable MemorySegment @Nullable []readData()Read the value of the fielddata.Read the value of the fieldflags.intreadId()Read the value of the fieldid.@Nullable VideoInforeadInfo()Read the value of the fieldinfo.@Nullable MapInfo @Nullable []readMap()Read the value of the fieldmap.readMeta()Read the value of the fieldmeta.voidunmap()Unmap the memory previously mapped with gst_video_frame_map.voidwriteBuffer(Buffer buffer) Write a value in the fieldbuffer.voidwriteData(@Nullable MemorySegment @Nullable [] data, Arena _arena) Write a value in the fielddata.voidwriteFlags(Set<VideoFrameFlags> flags) Write a value in the fieldflags.voidwriteId(int id) Write a value in the fieldid.voidWrite a value in the fieldinfo.voidWrite a value in the fieldmap.voidwriteMeta(MemorySegment meta) Write a value in the fieldmeta.Methods inherited from class org.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 fieldinfoflags- value for the fieldflagsbuffer- value for the fieldbuffermeta- value for the fieldmetaid- value for the fieldiddata- value for the fielddatamap- value for the fieldmaparena- 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 fieldinfoflags- value for the fieldflagsbuffer- value for the fieldbuffermeta- value for the fieldmetaid- value for the fieldiddata- value for the fielddatamap- value for the fieldmap
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readInfo
Read the value of the fieldinfo.- Returns:
- The value of the field
info
-
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
-
readMap
Read the value of the fieldmap.- Returns:
- The value of the field
map
-
writeMap
-
map
Useinfoandbufferto fill in the values offrame.frameis usually allocated on the stack, and you will pass the address to theGstVideoFramestructure 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
bufferwill 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
GstVideoFramestructure 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 toGstVideoFrameinfo- aGstVideoInfobuffer- the buffer to mapflags-GstMapFlags- Returns:
trueon success.
-
mapId
Useinfoandbufferto fill in the values offramewith the video frame information of frameid.When
idis -1, the default frame is mapped. Whenid!= -1, this function will returnfalsewhen there is no GstVideoMeta with that id.All video planes of
bufferwill be mapped and the pointers will be set inframe>data.- Parameters:
frame- pointer toGstVideoFrameinfo- aGstVideoInfobuffer- the buffer to mapid- the frame id to mapflags-GstMapFlags- Returns:
trueon success.
-
copy
Copy the contents fromsrctodest.Note: Since: 1.18, this VideoFrame dimensions are allowed to be smaller than
srcdimensions.- Parameters:
src- aGstVideoFrame- Returns:
- TRUE if the contents could be copied.
-
copyPlane
Copy the plane with indexplanefromsrctodest.Note: Since: 1.18, this VideoFrame dimensions are allowed to be smaller than
srcdimensions.- Parameters:
src- aGstVideoFrameplane- a plane- Returns:
- TRUE if the contents could be copied.
-
unmap
public void unmap()Unmap the memory previously mapped with gst_video_frame_map.
-