Class BufferList
- All Implemented Interfaces:
Proxy
Buffer lists are created with gst_buffer_list_new() and filled with data using gst_buffer_list_insert().
Buffer lists can be pushed on a srcpad with gst_pad_push_list(). This is interesting when multiple buffers need to be pushed in one go because it can reduce the amount of overhead for pushing each buffer individually.
-
Constructor Summary
ConstructorDescriptionCreates a new, emptyGstBufferList
.BufferList
(MemorySegment address) Create a BufferList proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionlong
Calculates the size of the data contained in this BufferList by adding the size of all buffers.copy()
Creates a shallow copy of the given buffer list.copyDeep()
Creates a copy of the given buffer list.boolean
foreach
(BufferListFunc func) Callsfunc
withdata
for each buffer in this BufferList.get
(int idx) Gets the buffer atidx
.static Type
getType()
Get the GType of the BufferList classgetWritable
(int idx) Gets the buffer atidx
, ensuring it is a writable buffer.void
Insertsbuffer
atidx
in this BufferList.int
length()
Returns the number of buffers in this BufferList.ref()
Increases the refcount of the given buffer list by one.void
remove
(int idx, int length) Removeslength
buffers starting fromidx
in this BufferList.static boolean
replace
(@Nullable Out<BufferList> oldList, @Nullable BufferList newList) Modifies a pointer to aGstBufferList
to point to a differentGstBufferList
.static BufferList
sized
(int size) Creates a new, emptyGstBufferList
.static boolean
take
(Out<BufferList> oldList, @Nullable BufferList newList) Modifies a pointer to aGstBufferList
to point to a differentGstBufferList
.void
unref()
Decreases the refcount of the buffer list.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
BufferList
Create a BufferList proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
BufferList
public BufferList()Creates a new, emptyGstBufferList
.
-
-
Method Details
-
getType
-
sized
Creates a new, emptyGstBufferList
. The list will havesize
space preallocated so that memory reallocations can be avoided.- Parameters:
size
- an initial reserved size- Returns:
- the new
GstBufferList
.
-
replace
public static boolean replace(@Nullable @Nullable Out<BufferList> oldList, @Nullable @Nullable BufferList newList) Modifies a pointer to aGstBufferList
to point to a differentGstBufferList
. The modification is done atomically (so this is useful for ensuring thread safety in some cases), and the reference counts are updated appropriately (the old buffer list is unreffed, the new is reffed).Either
newList
or theGstBufferList
pointed to byoldList
may benull
.- Parameters:
oldList
- pointer to a pointer to aGstBufferList
to be replaced.newList
- pointer to aGstBufferList
that will replace the buffer list pointed to byoldList
.- Returns:
true
ifnewList
was different fromoldList
-
take
Modifies a pointer to aGstBufferList
to point to a differentGstBufferList
. This function is similar to gst_buffer_list_replace() except that it takes ownership ofnewList
.- Parameters:
oldList
- pointer to a pointer to aGstBufferList
to be replaced.newList
- pointer to aGstBufferList
that will replace the bufferlist pointed to byoldList
.- Returns:
true
ifnewList
was different fromoldList
-
calculateSize
public long calculateSize()Calculates the size of the data contained in this BufferList by adding the size of all buffers.- Returns:
- the size of the data contained in this BufferList in bytes.
-
copy
Creates a shallow copy of the given buffer list. This will make a newly allocated copy of the source list with copies of buffer pointers. The refcount of buffers pointed to will be increased by one.- Returns:
- a new copy of this BufferList.
-
copyDeep
Creates a copy of the given buffer list. This will make a newly allocated copy of the buffers that the source buffer list contains.- Returns:
- a new copy of this BufferList.
-
foreach
Callsfunc
withdata
for each buffer in this BufferList.func
can modify the passed buffer pointer or its contents. The return value offunc
defines if this function returns or if the remaining buffers in the list should be skipped.- Parameters:
func
- aGstBufferListFunc
to call- Returns:
true
whenfunc
returnedtrue
for each buffer in this BufferList or when this BufferList is empty.
-
get
Gets the buffer atidx
.You must make sure that
idx
does not exceed the number of buffers available.- Parameters:
idx
- the index- Returns:
- the buffer at
idx
ingroup
ornull
when there is no buffer. The buffer remains valid as long as this BufferList is valid and buffer is not removed from the list.
-
getWritable
Gets the buffer atidx
, ensuring it is a writable buffer.You must make sure that
idx
does not exceed the number of buffers available.- Parameters:
idx
- the index- Returns:
- the buffer at
idx
ingroup
. The returned buffer remains valid as long as this BufferList is valid and the buffer is not removed from the list.
-
insert
Insertsbuffer
atidx
in this BufferList. Other buffers are moved to make room for this new buffer.A -1 value for
idx
will append the buffer at the end.- Parameters:
idx
- the indexbuffer
- aGstBuffer
-
length
public int length()Returns the number of buffers in this BufferList.- Returns:
- the number of buffers in the buffer list
-
ref
Increases the refcount of the given buffer list by one.Note that the refcount affects the writability of this BufferList and its data, see gst_buffer_list_make_writable(). It is important to note that keeping additional references to GstBufferList instances can potentially increase the number of memcpy operations in a pipeline.
- Returns:
- this BufferList
-
remove
public void remove(int idx, int length) Removeslength
buffers starting fromidx
in this BufferList. The following buffers are moved to close the gap.- Parameters:
idx
- the indexlength
- the amount to remove
-
unref
public void unref()Decreases the refcount of the buffer list. If the refcount reaches 0, the buffer list will be freed.
-