Class CollectPads
- All Implemented Interfaces:
Proxy
- Collectpads are created with gst_collect_pads_new(). A callback should then be installed with gst_collect_pads_set_function ().
- Pads are added to the collection with gst_collect_pads_add_pad()/ gst_collect_pads_remove_pad(). The pad has to be a sinkpad. When added, the chain, event and query functions of the pad are overridden. The element_private of the pad is used to store private information for the collectpads.
- For each pad, data is queued in the _chain function or by performing a pull_range.
- When data is queued on all pads in waiting mode, the callback function is called.
- Data can be dequeued from the pad with the gst_collect_pads_pop() method.
One can peek at the data with the gst_collect_pads_peek() function.
These functions will return
null
if the pad received an EOS event. When all pads returnnull
from a gst_collect_pads_peek(), the element can emit an EOS event itself.
- Data can also be dequeued in byte units using the gst_collect_pads_available(), gst_collect_pads_read_buffer() and gst_collect_pads_flush() calls.
- Elements should call gst_collect_pads_start() and gst_collect_pads_stop() in their state change functions to start and stop the processing of the collectpads. The gst_collect_pads_stop() call should be called before calling the parent element state change function in the PAUSED_TO_READY state change to ensure no pad is blocked and the element can finish streaming.
- gst_collect_pads_set_waiting() sets a pad to waiting or non-waiting mode. CollectPads element is not waiting for data to be collected on non-waiting pads. Thus these pads may but need not have data when the callback is called. All pads are in waiting mode by default.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
CollectPads.Builder<B extends CollectPads.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.ObjectClass, GstObject.ObjectImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback
-
Constructor Summary
ConstructorDescriptionCreate a new instance ofGstCollectPads
.CollectPads
(MemorySegment address) Create a CollectPads proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionaddPad
(Pad pad, int size, CollectDataDestroyNotify destroyNotify, boolean lock) Add a pad to the collection of collect pads.protected CollectPads
asParent()
Returns this instance as if it were its parent type.int
Query how much bytes can be read from each queued buffer.static CollectPads.Builder
<? extends CollectPads.Builder> builder()
ACollectPads.Builder
object constructs aCollectPads
with the specified properties.clipRunningTime
(CollectData cdata, Buffer buf, @Nullable Out<Buffer> outbuf, @Nullable MemorySegment userData) Convenience clipping function that converts incoming buffer's timestamp to running time, or clips the buffer if outside configured segment.boolean
eventDefault
(CollectData data, Event event, boolean discard) DefaultGstCollectPads
event handling that elements should always chain up to to ensure proper operation.int
flush
(CollectData data, int size) Flushsize
bytes from the paddata
.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the CollectPads classpeek
(CollectData data) Peek at the buffer currently queued indata
.pop
(CollectData data) Pop the buffer currently queued indata
.boolean
queryDefault
(CollectData data, Query query, boolean discard) DefaultGstCollectPads
query handling that elements should always chain up to to ensure proper operation.readBuffer
(CollectData data, int size) Get a subbuffer ofsize
bytes from the given paddata
.boolean
Remove a pad from the collection of collect pads.void
Set the callback function and user data that will be called with the oldest buffer when all pads have been collected, ornull
on EOS.void
setClipFunction
(CollectPadsClipFunction clipfunc) Install a clipping function that is called right after a buffer is received on a pad managed by this CollectPads.void
Set the timestamp comparison function.void
Set the event callback function and user data that will be called when collectpads has received an event originating from one of the collected pads.void
Install a flush function that is called when the internal state of all pads should be flushed as part of flushing seek handling.void
setFlushing
(boolean flushing) Change the flushing state of all the pads in the collection.void
CollectPads provides a default collection algorithm that will determine the oldest buffer available on all of its pads, and then delegate to a configured callback.void
Set the query callback function and user data that will be called after collectpads has received a query originating from one of the collected pads.void
setWaiting
(CollectData data, boolean waiting) Sets a pad to waiting or non-waiting mode, if at least this pad has not been created with locked waiting state, in which case nothing happens.boolean
srcEventDefault
(Pad pad, Event event) DefaultGstCollectPads
event handling for the src pad of elements.void
start()
Starts the processing of data in the collect_pads.void
stop()
Stops the processing of data in the collect_pads.takeBuffer
(CollectData data, int size) Get a subbuffer ofsize
bytes from the given paddata
.Methods inherited from class org.freedesktop.gstreamer.gst.GstObject
addControlBinding, checkUniqueness, deepNotify, defaultDeepNotify, defaultError, emitDeepNotify, getControlBinding, getControlRate, getGValueArray, getName, getParent, getPathString, getValue, getValueArray, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, onDeepNotify, ref, refSink, removeControlBinding, replace, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setName, setParent, suggestNextSync, syncValues, unparent, unref
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
CollectPads
Create a CollectPads proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
CollectPads
public CollectPads()Create a new instance ofGstCollectPads
.MT safe.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
addPad
Add a pad to the collection of collect pads. The pad has to be a sinkpad. The refcount of the pad is incremented. Use gst_collect_pads_remove_pad() to remove the pad from the collection again.You specify a size for the returned
GstCollectData
structure so that you can use it to store additional information.You can also specify a
GstCollectDataDestroyNotify
that will be called just before theGstCollectData
structure is freed. It is passed the pointer to the structure and should free any custom memory and resources allocated for it.Keeping a pad locked in waiting state is only relevant when using the default collection algorithm (providing the oldest buffer). It ensures a buffer must be available on this pad for a collection to take place. This is of typical use to a muxer element where non-subtitle streams should always be in waiting state, e.g. to assure that caps information is available on all these streams when initial headers have to be written.
The pad will be automatically activated in push mode when this CollectPads is started.
MT safe.
- Parameters:
pad
- the pad to addsize
- the size of the returnedGstCollectData
structuredestroyNotify
- function to be called before the returnedGstCollectData
structure is freedlock
- whether to lock this pad in usual waiting state- Returns:
- a new
GstCollectData
to identify the new pad. Ornull
if wrong parameters are supplied.
-
available
public int available()Query how much bytes can be read from each queued buffer. This means that the result of this call is the maximum number of bytes that can be read from each of the pads.This function should be called with this CollectPads STREAM_LOCK held, such as in the callback.
MT safe.
- Returns:
- The maximum number of bytes queued on all pads. This function returns 0 if a pad has no queued buffer.
-
clipRunningTime
public FlowReturn clipRunningTime(CollectData cdata, Buffer buf, @Nullable @Nullable Out<Buffer> outbuf, @Nullable @Nullable MemorySegment userData) Convenience clipping function that converts incoming buffer's timestamp to running time, or clips the buffer if outside configured segment.Since 1.6, this clipping function also sets the DTS parameter of the GstCollectData structure. This version of the running time DTS can be negative. G_MININT64 is used to indicate invalid value.
- Parameters:
cdata
- collect data of corresponding padbuf
- buffer being clippedoutbuf
- output buffer with running time, or NULL if clippeduserData
- user data (unused)
-
eventDefault
DefaultGstCollectPads
event handling that elements should always chain up to to ensure proper operation. Element might however indicate event should not be forwarded downstream.- Parameters:
data
- collect data of corresponding padevent
- event being processeddiscard
- process but do not send event downstream
-
flush
Flushsize
bytes from the paddata
.This function should be called with this CollectPads STREAM_LOCK held, such as in the callback.
MT safe.
- Parameters:
data
- the data to usesize
- the number of bytes to flush- Returns:
- The number of bytes flushed This can be less than
size
and is 0 if the pad was end-of-stream.
-
peek
Peek at the buffer currently queued indata
. This function should be called with the this CollectPads STREAM_LOCK held, such as in the callback handler.MT safe.
- Parameters:
data
- the data to use- Returns:
- The buffer in
data
ornull
if no buffer is queued. should unref the buffer after usage.
-
pop
Pop the buffer currently queued indata
. This function should be called with the this CollectPads STREAM_LOCK held, such as in the callback handler.MT safe.
- Parameters:
data
- the data to use- Returns:
- The buffer in
data
ornull
if no buffer was queued. You should unref the buffer after usage.
-
queryDefault
DefaultGstCollectPads
query handling that elements should always chain up to to ensure proper operation. Element might however indicate query should not be forwarded downstream.- Parameters:
data
- collect data of corresponding padquery
- query being processeddiscard
- process but do not send event downstream
-
readBuffer
Get a subbuffer ofsize
bytes from the given paddata
.This function should be called with this CollectPads STREAM_LOCK held, such as in the callback.
MT safe.
- Parameters:
data
- the data to usesize
- the number of bytes to read- Returns:
- A sub buffer. The size of the buffer can
be less that requested. A return of
null
signals that the pad is end-of-stream. Unref the buffer after use.
-
removePad
Remove a pad from the collection of collect pads. This function will also free theGstCollectData
and all the resources that were allocated with gst_collect_pads_add_pad().The pad will be deactivated automatically when this CollectPads is stopped.
MT safe.
- Parameters:
pad
- the pad to remove- Returns:
true
if the pad could be removed.
-
setBufferFunction
Set the callback function and user data that will be called with the oldest buffer when all pads have been collected, ornull
on EOS. If a buffer is passed, the callback owns a reference and must unref it.MT safe.
- Parameters:
func
- the function to set
-
setClipFunction
Install a clipping function that is called right after a buffer is received on a pad managed by this CollectPads. SeeGstCollectPadsClipFunction
for more info.- Parameters:
clipfunc
- clip function to install
-
setCompareFunction
Set the timestamp comparison function.MT safe.
- Parameters:
func
- the function to set
-
setEventFunction
Set the event callback function and user data that will be called when collectpads has received an event originating from one of the collected pads. If the event being processed is a serialized one, this callback is called with this CollectPads STREAM_LOCK held, otherwise not. As this lock should be held when calling a number of CollectPads functions, it should be acquired if so (unusually) needed.MT safe.
- Parameters:
func
- the function to set
-
setFlushFunction
Install a flush function that is called when the internal state of all pads should be flushed as part of flushing seek handling. SeeGstCollectPadsFlushFunction
for more info.- Parameters:
func
- flush function to install
-
setFlushing
public void setFlushing(boolean flushing) Change the flushing state of all the pads in the collection. No pad is able to accept anymore data whenflushing
istrue
. Calling this function withflushing
false
makes this CollectPads accept data again. Caller must ensure that downstream streaming (thread) is not blocked, e.g. by sending a FLUSH_START downstream.MT safe.
- Parameters:
flushing
- desired state of the pads
-
setFunction
CollectPads provides a default collection algorithm that will determine the oldest buffer available on all of its pads, and then delegate to a configured callback. However, if circumstances are more complicated and/or more control is desired, this sets a callback that will be invoked instead when all the pads added to the collection have buffers queued. Evidently, this callback is not compatible with gst_collect_pads_set_buffer_function() callback. If this callback is set, the former will be unset.MT safe.
- Parameters:
func
- the function to set
-
setQueryFunction
Set the query callback function and user data that will be called after collectpads has received a query originating from one of the collected pads. If the query being processed is a serialized one, this callback is called with this CollectPads STREAM_LOCK held, otherwise not. As this lock should be held when calling a number of CollectPads functions, it should be acquired if so (unusually) needed.MT safe.
- Parameters:
func
- the function to set
-
setWaiting
Sets a pad to waiting or non-waiting mode, if at least this pad has not been created with locked waiting state, in which case nothing happens.This function should be called with this CollectPads STREAM_LOCK held, such as in the callback.
MT safe.
- Parameters:
data
- the data to usewaiting
- boolean indicating whether this pad should operate in waiting or non-waiting mode
-
srcEventDefault
-
start
public void start()Starts the processing of data in the collect_pads.MT safe.
-
stop
public void stop()Stops the processing of data in the collect_pads. this function will also unblock any blocking operations.MT safe.
-
takeBuffer
Get a subbuffer ofsize
bytes from the given paddata
. Flushes the amount of read bytes.This function should be called with this CollectPads STREAM_LOCK held, such as in the callback.
MT safe.
- Parameters:
data
- the data to usesize
- the number of bytes to read- Returns:
- A sub buffer. The size of the buffer can
be less that requested. A return of
null
signals that the pad is end-of-stream. Unref the buffer after use.
-
builder
ACollectPads.Builder
object constructs aCollectPads
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withCollectPads.Builder.build()
.
-