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
nullif the pad received an EOS event. When all pads returnnullfrom 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
Nested ClassesModifier and TypeClassDescriptionstatic classCollectPads.Builder<B extends CollectPads.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.Object$Impl, GstObject.ObjectClassNested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new CollectPads.CollectPads(MemorySegment address) Create a CollectPads proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescription@Nullable CollectDataaddPad(Pad pad, int size, @Nullable CollectDataDestroyNotify destroyNotify, boolean lock) Add a pad to the collection of collect pads.protected CollectPadsasParent()Returns this instance as if it were its parent type.intQuery how much bytes can be read from each queued buffer.static CollectPads.Builder<? extends CollectPads.Builder> builder()ACollectPads.Builderobject constructs aCollectPadswith 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.booleaneventDefault(CollectData data, Event event, boolean discard) DefaultGstCollectPadsevent handling that elements should always chain up to to ensure proper operation.intflush(CollectData data, int size) Flushsizebytes from the paddata.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the CollectPads class@Nullable Bufferpeek(CollectData data) 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.@Nullable Bufferpop(CollectData data) Pop the buffer currently queued indata.This function should be called with the this CollectPads STREAM_LOCK held, such as in the callback handler.booleanqueryDefault(CollectData data, Query query, boolean discard) DefaultGstCollectPadsquery handling that elements should always chain up to to ensure proper operation.@Nullable BufferreadBuffer(CollectData data, int size) Get a subbuffer ofsizebytes from the given paddata.booleanRemove a pad from the collection of collect pads.voidsetBufferFunction(@Nullable CollectPadsBufferFunction func) Set the callback function and user data that will be called with the oldest buffer when all pads have been collected, ornullon EOS.voidsetClipFunction(@Nullable CollectPadsClipFunction clipfunc) Install a clipping function that is called right after a buffer is received on a pad managed bypads.SeeGstCollectPadsClipFunctionfor more info.voidsetCompareFunction(@Nullable CollectPadsCompareFunction func) Set the timestamp comparison function.voidsetEventFunction(@Nullable CollectPadsEventFunction func) 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.voidsetFlushFunction(@Nullable CollectPadsFlushFunction func) Install a flush function that is called when the internal state of all pads should be flushed as part of flushing seek handling.voidsetFlushing(boolean flushing) Change the flushing state of all the pads in the collection.voidsetFunction(@Nullable CollectPadsFunction func) 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.voidsetQueryFunction(@Nullable CollectPadsQueryFunction func) 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.voidsetWaiting(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.booleansrcEventDefault(Pad pad, Event event) DefaultGstCollectPadsevent handling for the src pad of elements.voidstart()Starts the processing of data in the collect_pads.voidstop()Stops the processing of data in the collect_pads.@Nullable BuffertakeBuffer(CollectData data, int size) Get a subbuffer ofsizebytes from the given paddata.Flushes the amount of read bytes.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, unrefMethods 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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()Creates a new CollectPads.
-
-
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 Javasuperkeyword, 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
public @Nullable CollectData addPad(Pad pad, int size, @Nullable CollectDataDestroyNotify destroyNotify, boolean lock) 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
GstCollectDatastructure so that you can use it to store additional information.You can also specify a
GstCollectDataDestroyNotifythat will be called just before theGstCollectDatastructure 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 returnedGstCollectDatastructuredestroyNotify- function to be called before the returnedGstCollectDatastructure is freedlock- whether to lock this pad in usual waiting state- Returns:
- a new
GstCollectDatato identify the new pad. Ornullif 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 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.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
DefaultGstCollectPadsevent 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
Flushsizebytes 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
sizeand 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
dataornullif 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
dataornullif no buffer was queued. You should unref the buffer after usage.
-
queryDefault
DefaultGstCollectPadsquery 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 ofsizebytes 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
nullsignals 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 theGstCollectDataand 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:
trueif 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, ornullon 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 bypads.SeeGstCollectPadsClipFunctionfor 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. SeeGstCollectPadsFlushFunctionfor more info.- Parameters:
func- flush function to install- Since:
- 1.4
-
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 whenflushingistrue. Calling this function withflushingfalsemakes 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
DefaultGstCollectPadsevent handling for the src pad of elements. Elements can chain up to this to let flushing seek event handling be done byGstCollectPads.- Parameters:
pad- srcGstPadthat received the eventevent- event being processed- Since:
- 1.4
-
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 ofsizebytes 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
nullsignals that the pad is end-of-stream. Unref the buffer after use.
-
builder
ACollectPads.Builderobject constructs aCollectPadswith the specified properties. Use the variousset...()methods to set properties, and finish construction withCollectPads.Builder.build().- Returns:
- the builder object
-