Class Pad
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
AggregatorPad
,ProxyPad
GstElement
is linked to other elements via "pads", which are extremely
light-weight generic link points.
Pads have a GstPadDirection
, source pads produce data, sink pads consume
data.
Pads are typically created from a GstPadTemplate
with
gst_pad_new_from_template() and are then added to a GstElement
. This usually
happens when the element is created but it can also happen dynamically based
on the data that the element is processing or based on the pads that the
application requests.
Pads without pad templates can be created with gst_pad_new(),
which takes a direction and a name as an argument. If the name is null
,
then a guaranteed unique name will be assigned to it.
A GstElement
creating a pad will typically use the various
gst_pad_set_*_function\\() calls to register callbacks for events, queries or
dataflow on the pads.
gst_pad_get_parent() will retrieve the GstElement
that owns the pad.
After two pads are retrieved from an element by gst_element_get_static_pad(), the pads can be linked with gst_pad_link(). (For quick links, you can also use gst_element_link(), which will make the obvious link for you if it's straightforward.). Pads can be unlinked again with gst_pad_unlink(). gst_pad_get_peer() can be used to check what the pad is linked to.
Before dataflow is possible on the pads, they need to be activated with gst_pad_set_active().
gst_pad_query() and gst_pad_peer_query() can be used to query various properties of the pad and the stream.
To send a GstEvent
on a pad, use gst_pad_send_event() and
gst_pad_push_event(). Some events will be sticky on the pad, meaning that
after they pass on the pad they can be queried later with
gst_pad_get_sticky_event() and gst_pad_sticky_events_foreach().
gst_pad_get_current_caps() and gst_pad_has_current_caps() are convenience
functions to query the current sticky CAPS event on a pad.
GstElements will use gst_pad_push() and gst_pad_pull_range() to push out or pull in a buffer.
The dataflow, events and queries that happen on a pad can be monitored with probes that can be installed with gst_pad_add_probe(). gst_pad_is_blocked() can be used to check if a block probe is installed on the pad. gst_pad_is_blocking() checks if the blocking probe is currently blocking the pad. gst_pad_remove_probe() is used to remove a previously installed probe and unblock blocking probes if any.
Pad have an offset that can be retrieved with gst_pad_get_offset(). This offset will be applied to the running_time of all data passing over the pad. gst_pad_set_offset() can be used to change the offset.
Convenience functions exist to start, pause and stop the task on a pad with gst_pad_start_task(), gst_pad_pause_task() and gst_pad_stop_task() respectively.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Pad.Builder<B extends Pad.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theLinkedCallback
callback.static class
static interface
Functional interface declaration of theUnlinkedCallback
callback.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
ConstructorDescriptionPad
(@Nullable String name, PadDirection direction) Creates a new pad with the given name in the given direction.Pad
(MemorySegment address) Create a Pad proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
activateMode
(PadMode mode, boolean active) Activates or deactivates the given pad inmode
via dispatching to the pad's activatemodefunc.int
addProbe
(Set<PadProbeType> mask, PadProbeCallback callback) Be notified of different states of pads.int
addProbe
(PadProbeType mask, PadProbeCallback callback) Be notified of different states of pads.protected Pad
asParent()
Returns this instance as if it were its parent type.static Pad.Builder
<? extends Pad.Builder> builder()
APad.Builder
object constructs aPad
with the specified properties.boolean
Checks if the source pad and the sink pad are compatible so they can be linked.Chain a buffer to this Pad.chainList
(BufferList list) Chain a bufferlist to this Pad.boolean
Check and clear theGST_PAD_FLAG_NEED_RECONFIGURE
flag on this Pad and returntrue
if the flag was set.createStreamId
(Element parent, @Nullable String streamId) Creates a stream-id for the sourceGstPad
this Pad by combining the upstream information with the optionalstreamId
of the stream of this Pad.createStreamIdPrintf
(Element parent, @Nullable String streamId, Object... varargs) Creates a stream-id for the sourceGstPad
this Pad by combining the upstream information with the optionalstreamId
of the stream of this Pad.void
emitLinked
(Pad peer) Emits the "linked" signal.void
emitUnlinked
(Pad peer) Emits the "unlinked" signal.boolean
eventDefault
(@Nullable GstObject parent, Event event) Invokes the default event handler for the given pad.boolean
forward
(PadForwardFunction forward) Callsforward
for all internally linked pads of this Pad.static Pad
fromStaticTemplate
(StaticPadTemplate templ, String name) Creates a new pad with the given name from the given static template.static Pad
fromTemplate
(PadTemplate templ, @Nullable String name) Creates a new pad with the given name from the given template.Gets the capabilities of the allowed media types that can flow through this Pad and its peer.Gets the capabilities currently configured on this Pad with the lastGST_EVENT_CAPS
event.Gets the direction of the pad.Gets the private data of a pad.Gets theGstFlowReturn
return from the last data passed by this pad.static MemoryLayout
The memory layout of the native struct.long
Get the offset applied to the running time of this Pad.Gets the template for this Pad.Gets the capabilities for this Pad's template.Gets the parent of this Pad, cast to aGstElement
.getPeer()
Gets the peer of this Pad.When this Pad is flushing this function returnsGST_FLOW_FLUSHING
immediately andbuffer
isnull
.If there is a single internal link of the given pad, this function will return it.getStickyEvent
(EventType eventType, int idx) Returns a new reference of the sticky event of typeeventType
from the event.Returns the currentGstStream
for the this Pad, ornull
if none has been set yet, i.e.Returns the current stream-id for the this Pad, ornull
if none has been set yet, i.e.Get this Pad task state.static Type
getType()
Get the GType of the Pad classboolean
Check if this Pad has caps set on it with aGST_EVENT_CAPS
event.boolean
isActive()
Query if a pad is activeboolean
Checks if the pad is blocked or not.boolean
Checks if the pad is blocking or not.boolean
isLinked()
Checks if a this Pad is linked to another pad or not.Gets an iterator for the pads to which the given pad is linked to inside of the parent element.iterateInternalLinksDefault
(@Nullable GstObject parent) Iterate the list of pads to which the given pad is linked to inside of the parent element.Links the source pad and the sink pad.protected void
linkFull
(Pad sinkpad, Set<PadLinkCheck> flags) Links the source pad and the sink pad.linkFull
(Pad sinkpad, PadLinkCheck... flags) Links the source pad and the sink pad.static String
linkGetName
(PadLinkReturn ret) Gets a string representing the given pad-link return.boolean
linkMaybeGhosting
(Pad sink) Links this Pad tosink
, creating anyGstGhostPad
's in between as necessary.boolean
linkMaybeGhostingFull
(Pad sink, Set<PadLinkCheck> flags) Links this Pad tosink
, creating anyGstGhostPad
's in between as necessary.boolean
linkMaybeGhostingFull
(Pad sink, PadLinkCheck... flags) Links this Pad tosink
, creating anyGstGhostPad
's in between as necessary.void
Mark a pad for needing reconfiguration.boolean
Check theGST_PAD_FLAG_NEED_RECONFIGURE
flag on this Pad and returntrue
if the flag was set.onLinked
(Pad.LinkedCallback handler) Signals that a pad has been linked to the peer pad.onUnlinked
(Pad.UnlinkedCallback handler) Signals that a pad has been unlinked from the peer pad.boolean
Pause the task of this Pad.boolean
Performs gst_pad_query() on the peer of this Pad.boolean
peerQueryAcceptCaps
(Caps caps) Check if the peer of this Pad acceptscaps
.peerQueryCaps
(@Nullable Caps filter) Gets the capabilities of the peer connected to this pad.boolean
peerQueryConvert
(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal) Queries the peer pad of a given sink pad to convertsrcVal
insrcFormat
todestFormat
.boolean
peerQueryDuration
(Format format, @Nullable Out<Long> duration) Queries the peer pad of a given sink pad for the total stream duration.boolean
peerQueryPosition
(Format format, @Nullable Out<Long> cur) Queries the peer of a given sink pad for the stream position.boolean
proxyQueryAcceptCaps
(Query query) Checks if all internally linked pads of this Pad accepts the caps inquery
and returns the intersection of the results.boolean
proxyQueryCaps
(Query query) Calls gst_pad_query_caps() for all internally linked pads of this Pad and returns the intersection of the results.Pulls abuffer
from the peer pad or fills up a provided buffer.Pushes a buffer to the peer of this Pad.boolean
Sends the event to the peer of the given pad.pushList
(BufferList list) Pushes a buffer list to the peer of this Pad.boolean
Dispatches a query to a pad.boolean
queryAcceptCaps
(Caps caps) Check if the given pad accepts the caps.Gets the capabilities this pad can produce or consume.boolean
queryConvert
(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal) Queries a pad to convertsrcVal
insrcFormat
todestFormat
.boolean
queryDefault
(@Nullable GstObject parent, Query query) Invokes the default query handler for the given pad.boolean
queryDuration
(Format format, @Nullable Out<Long> duration) Queries a pad for the total stream duration.boolean
queryPosition
(Format format, @Nullable Out<Long> cur) Queries a pad for the stream position.void
removeProbe
(int id) Remove the probe withid
from this Pad.boolean
Sends the event to the pad.void
setActivateFunctionFull
(PadActivateFunction activate) Sets the given activate function for this Pad.void
setActivatemodeFunctionFull
(PadActivateModeFunction activatemode) Sets the given activate_mode function for the pad.boolean
setActive
(boolean active) Activates or deactivates the given pad.void
Sets the given chain function for the pad.void
setChainListFunctionFull
(PadChainListFunction chainlist) Sets the given chain list function for the pad.void
setElementPrivate
(@Nullable MemorySegment priv) Set the given private data gpointer on the pad.void
Sets the given event handler for the pad.void
Sets the given event handler for the pad.void
Sets the given getrange function for the pad.void
Sets the given internal link iterator function for the pad.void
Sets the given link function for the pad.void
setOffset
(long offset) Set the offset that will be applied to the running time of this Pad.void
Set the given query function for the pad.void
Sets the given unlink function for the pad.boolean
startTask
(TaskFunction func) Starts a task that repeatedly callsfunc
withuserData
.void
stickyEventsForeach
(PadStickyEventsForeachFunction foreachFunc) Iterates all sticky events on this Pad and callsforeachFunc
for every event.boolean
stopTask()
Stop the task of this Pad.storeStickyEvent
(Event event) Store the stickyevent
on this Padboolean
Unlinks the source pad from the sink pad.protected void
void
A helper function you can use that sets the FIXED_CAPS flag This way the default CAPS query will always return the negotiated caps or in case the pad is not negotiated, the padtemplate caps.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
-
Pad
Create a Pad proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Pad
Creates a new pad with the given name in the given direction. If name isnull
, a guaranteed unique name (across all pads) will be assigned. This function makes a copy of the name so you can safely free the name.- Parameters:
name
- the name of the new pad.direction
- theGstPadDirection
of the pad.
-
-
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. -
fromStaticTemplate
Creates a new pad with the given name from the given static template. If name isnull
, a guaranteed unique name (across all pads) will be assigned. This function makes a copy of the name so you can safely free the name.- Parameters:
templ
- theGstStaticPadTemplate
to usename
- the name of the pad- Returns:
- a new
GstPad
.
-
fromTemplate
Creates a new pad with the given name from the given template. If name isnull
, a guaranteed unique name (across all pads) will be assigned. This function makes a copy of the name so you can safely free the name.- Parameters:
templ
- the pad template to usename
- the name of the pad- Returns:
- a new
GstPad
.
-
linkGetName
Gets a string representing the given pad-link return.- Parameters:
ret
- aGstPadLinkReturn
to get the name of.- Returns:
- a static string with the name of the pad-link return.
-
activateMode
Activates or deactivates the given pad inmode
via dispatching to the pad's activatemodefunc. For use from within pad activation functions only.If you don't know what this is, you probably don't want to call it.
- Parameters:
mode
- the requested activation modeactive
- whether or not the pad should be active.- Returns:
true
if the operation was successful.MT safe.
-
addProbe
Be notified of different states of pads. The provided callback is called for every state that matchesmask
.Probes are called in groups: First GST_PAD_PROBE_TYPE_BLOCK probes are called, then others, then finally GST_PAD_PROBE_TYPE_IDLE. The only exception here are GST_PAD_PROBE_TYPE_IDLE probes that are called immediately if the pad is already idle while calling gst_pad_add_probe(). In each of the groups, probes are called in the order in which they were added.
- Parameters:
mask
- the probe maskcallback
-GstPadProbeCallback
that will be called with notifications of the pad state- Returns:
- an id or 0 if no probe is pending. The id can be used to remove the
probe with gst_pad_remove_probe(). When using GST_PAD_PROBE_TYPE_IDLE it can
happen that the probe can be run immediately and if the probe returns
GST_PAD_PROBE_REMOVE this functions returns 0.
MT safe.
-
addProbe
Be notified of different states of pads. The provided callback is called for every state that matchesmask
.Probes are called in groups: First GST_PAD_PROBE_TYPE_BLOCK probes are called, then others, then finally GST_PAD_PROBE_TYPE_IDLE. The only exception here are GST_PAD_PROBE_TYPE_IDLE probes that are called immediately if the pad is already idle while calling gst_pad_add_probe(). In each of the groups, probes are called in the order in which they were added.
- Parameters:
mask
- the probe maskcallback
-GstPadProbeCallback
that will be called with notifications of the pad state- Returns:
- an id or 0 if no probe is pending. The id can be used to remove the
probe with gst_pad_remove_probe(). When using GST_PAD_PROBE_TYPE_IDLE it can
happen that the probe can be run immediately and if the probe returns
GST_PAD_PROBE_REMOVE this functions returns 0.
MT safe.
-
canLink
Checks if the source pad and the sink pad are compatible so they can be linked.- Parameters:
sinkpad
- the sinkGstPad
.- Returns:
true
if the pads can be linked.
-
chain
Chain a buffer to this Pad.The function returns
GST_FLOW_FLUSHING
if the pad was flushing.If the buffer type is not acceptable for this Pad (as negotiated with a preceding GST_EVENT_CAPS event), this function returns
GST_FLOW_NOT_NEGOTIATED
.The function proceeds calling the chain function installed on this Pad (see gst_pad_set_chain_function()) and the return value of that function is returned to the caller.
GST_FLOW_NOT_SUPPORTED
is returned if this Pad has no chain function.In all cases, success or failure, the caller loses its reference to
buffer
after calling this function.- Parameters:
buffer
- theGstBuffer
to send, return GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturn
from the pad.MT safe.
-
chainList
Chain a bufferlist to this Pad.The function returns
GST_FLOW_FLUSHING
if the pad was flushing.If this Pad was not negotiated properly with a CAPS event, this function returns
GST_FLOW_NOT_NEGOTIATED
.The function proceeds calling the chainlist function installed on this Pad (see gst_pad_set_chain_list_function()) and the return value of that function is returned to the caller.
GST_FLOW_NOT_SUPPORTED
is returned if this Pad has no chainlist function.In all cases, success or failure, the caller loses its reference to
list
after calling this function.MT safe.
- Parameters:
list
- theGstBufferList
to send, return GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturn
from the pad.
-
checkReconfigure
public boolean checkReconfigure()Check and clear theGST_PAD_FLAG_NEED_RECONFIGURE
flag on this Pad and returntrue
if the flag was set.- Returns:
true
is the GST_PAD_FLAG_NEED_RECONFIGURE flag was set on this Pad.
-
createStreamId
Creates a stream-id for the sourceGstPad
this Pad by combining the upstream information with the optionalstreamId
of the stream of this Pad. this Pad must have a parentGstElement
and which must have zero or one sinkpad.streamId
can only benull
if the parent element of this Pad has only a single source pad.This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending
streamId
to it. If the element has no sinkpad it will generate an upstream stream-id by doing an URI query on the element and in the worst case just uses a random number. Source elements that don't implement the URI handler interface should ideally generate a unique, deterministic stream-id manually instead.Since stream IDs are sorted alphabetically, any numbers in the stream ID should be printed with a fixed number of characters, preceded by 0's, such as by using the format \\
03u
instead of \\u
.- Parameters:
parent
- ParentGstElement
of this PadstreamId
- The stream-id- Returns:
- A stream-id for this Pad. g_free() after usage.
-
createStreamIdPrintf
public String createStreamIdPrintf(Element parent, @Nullable @Nullable String streamId, Object... varargs) Creates a stream-id for the sourceGstPad
this Pad by combining the upstream information with the optionalstreamId
of the stream of this Pad. this Pad must have a parentGstElement
and which must have zero or one sinkpad.streamId
can only benull
if the parent element of this Pad has only a single source pad.This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending
streamId
to it. If the element has no sinkpad it will generate an upstream stream-id by doing an URI query on the element and in the worst case just uses a random number. Source elements that don't implement the URI handler interface should ideally generate a unique, deterministic stream-id manually instead.- Parameters:
parent
- ParentGstElement
of this PadstreamId
- The stream-idvarargs
- parameters for thestreamId
format string- Returns:
- A stream-id for this Pad. g_free() after usage.
-
eventDefault
Invokes the default event handler for the given pad.The EOS event will pause the task associated with this Pad before it is forwarded to all internally linked pads,
The event is sent to all pads internally linked to this Pad. This function takes ownership of
event
.- Parameters:
parent
- the parent of this Pad ornull
event
- theGstEvent
to handle.- Returns:
true
if the event was sent successfully.
-
forward
Callsforward
for all internally linked pads of this Pad. This function deals with dynamically changing internal pads and will make sure that theforward
function is only called once for each pad.When
forward
returnstrue
, no further pads will be processed.- Parameters:
forward
- aGstPadForwardFunction
- Returns:
true
if one of the dispatcher functions returnedtrue
.
-
getAllowedCaps
Gets the capabilities of the allowed media types that can flow through this Pad and its peer.The allowed capabilities is calculated as the intersection of the results of calling gst_pad_query_caps() on this Pad and its peer. The caller owns a reference on the resulting caps.
- Returns:
- the allowed
GstCaps
of the pad link. Unref the caps when you no longer need it. This function returnsnull
when this Pad has no peer.MT safe.
-
getCurrentCaps
Gets the capabilities currently configured on this Pad with the lastGST_EVENT_CAPS
event.- Returns:
- the current caps of the pad with
incremented ref-count or
null
when pad has no caps. Unref after usage.
-
getDirection
Gets the direction of the pad. The direction of the pad is decided at construction time so this function does not take the LOCK.- Returns:
- the
GstPadDirection
of the pad.MT safe.
-
getElementPrivate
Gets the private data of a pad. No locking is performed in this function.- Returns:
- a
gpointer
to the private data.
-
getLastFlowReturn
Gets theGstFlowReturn
return from the last data passed by this pad. -
getOffset
public long getOffset()Get the offset applied to the running time of this Pad. this Pad has to be a source pad.- Returns:
- the offset.
-
getPadTemplate
Gets the template for this Pad.- Returns:
- the
GstPadTemplate
from which this pad was instantiated, ornull
if this pad has no template. Unref after usage.
-
getPadTemplateCaps
Gets the capabilities for this Pad's template.- Returns:
- the
GstCaps
of this pad template. Unref after usage.
-
getParentElement
Gets the parent of this Pad, cast to aGstElement
. If a this Pad has no parent or its parent is not an element, returnnull
.- Returns:
- the parent of the pad. The
caller has a reference on the parent, so unref when you're finished
with it.
MT safe.
-
getPeer
Gets the peer of this Pad. This function refs the peer pad so you need to unref it after use.- Returns:
- the peer
GstPad
. Unref after usage.MT safe.
-
getRange
When this Pad is flushing this function returnsGST_FLOW_FLUSHING
immediately andbuffer
isnull
.Calls the getrange function of this Pad, see
GstPadGetRangeFunction
for a description of a getrange function. If this Pad has no getrange function installed (see gst_pad_set_getrange_function()) this function returnsGST_FLOW_NOT_SUPPORTED
.If
buffer
points to a variable holdingnull
, a valid newGstBuffer
will be placed inbuffer
when this function returnsGST_FLOW_OK
. The new buffer must be freed with gst_buffer_unref() after usage.When
buffer
points to a variable that points to a validGstBuffer
, the buffer will be filled with the result data when this function returnsGST_FLOW_OK
. If the provided buffer is larger thansize
, onlysize
bytes will be filled in the result buffer and its size will be updated accordingly.Note that less than
size
bytes can be returned inbuffer
when, for example, an EOS condition is near or whenbuffer
is not large enough to holdsize
bytes. The caller should check the result buffer size to get the result size.When this function returns any other result value than
GST_FLOW_OK
,buffer
will be unchanged.This is a lowlevel function. Usually gst_pad_pull_range() is used.
- Parameters:
offset
- The start offset of the buffersize
- The length of the bufferbuffer
- a pointer to hold theGstBuffer
, returnsGST_FLOW_ERROR
ifnull
.- Returns:
- a
GstFlowReturn
from the pad.MT safe.
-
getSingleInternalLink
If there is a single internal link of the given pad, this function will return it. Otherwise, it will return NULL.- Returns:
- a
GstPad
, ornull
if this Pad has none or more than one internal links. Unref returned pad with gst_object_unref().
-
getStickyEvent
Returns a new reference of the sticky event of typeeventType
from the event.- Parameters:
eventType
- theGstEventType
that should be retrieved.idx
- the index of the event- Returns:
- a
GstEvent
of typeeventType
ornull
when no event ofeventType
was on this Pad. Unref after usage.
-
getStream
Returns the currentGstStream
for the this Pad, ornull
if none has been set yet, i.e. the pad has not received a stream-start event yet.This is a convenience wrapper around gst_pad_get_sticky_event() and gst_event_parse_stream().
- Returns:
- the current
GstStream
for this Pad, ornull
. unref the returned stream when no longer needed.
-
getStreamId
Returns the current stream-id for the this Pad, ornull
if none has been set yet, i.e. the pad has not received a stream-start event yet.This is a convenience wrapper around gst_pad_get_sticky_event() and gst_event_parse_stream_start().
The returned stream-id string should be treated as an opaque string, its contents should not be interpreted.
- Returns:
- a newly-allocated copy of the stream-id for
this Pad, or
null
. g_free() the returned string when no longer needed.
-
getTaskState
Get this Pad task state. If no task is currently set,GST_TASK_STOPPED
is returned.- Returns:
- The current state of this Pad's task.
-
hasCurrentCaps
public boolean hasCurrentCaps()Check if this Pad has caps set on it with aGST_EVENT_CAPS
event.- Returns:
true
when this Pad has caps associated with it.
-
isActive
public boolean isActive()Query if a pad is active- Returns:
true
if the pad is active.MT safe.
-
isBlocked
public boolean isBlocked()Checks if the pad is blocked or not. This function returns the last requested state of the pad. It is not certain that the pad is actually blocking at this point (see gst_pad_is_blocking()).- Returns:
true
if the pad is blocked.MT safe.
-
isBlocking
public boolean isBlocking()Checks if the pad is blocking or not. This is a guaranteed state of whether the pad is actually blocking on aGstBuffer
or aGstEvent
.- Returns:
true
if the pad is blocking.MT safe.
-
isLinked
public boolean isLinked()Checks if a this Pad is linked to another pad or not.- Returns:
true
if the pad is linked,false
otherwise.MT safe.
-
iterateInternalLinks
Gets an iterator for the pads to which the given pad is linked to inside of the parent element.Each
GstPad
element yielded by the iterator will have its refcount increased, so unref after use.Free-function: gst_iterator_free
- Returns:
- a new
GstIterator
ofGstPad
ornull
when the pad does not have an iterator function configured. Use gst_iterator_free() after usage.
-
iterateInternalLinksDefault
Iterate the list of pads to which the given pad is linked to inside of the parent element. This is the default handler, and thus returns an iterator of all of the pads inside the parent element with opposite direction.The caller must free this iterator after use with gst_iterator_free().
- Parameters:
parent
- the parent of this Pad ornull
- Returns:
- a
GstIterator
ofGstPad
, ornull
if this Pad has no parent. Unref each returned pad with gst_object_unref().
-
link
Links the source pad and the sink pad.- Parameters:
sinkpad
- the sinkGstPad
to link.- Returns:
- A result code indicating if the connection worked or
what went wrong.
MT Safe.
-
linkFull
Links the source pad and the sink pad.This variant of
gst_pad_link
provides a more granular control on the checks being done when linking. While providing some considerable speedups the caller of this method must be aware that wrong usage of those flags can cause severe issues. Refer to the documentation ofGstPadLinkCheck
for more information.MT Safe.
- Parameters:
sinkpad
- the sinkGstPad
to link.flags
- the checks to validate when linking- Returns:
- A result code indicating if the connection worked or what went wrong.
-
linkFull
Links the source pad and the sink pad.This variant of
gst_pad_link
provides a more granular control on the checks being done when linking. While providing some considerable speedups the caller of this method must be aware that wrong usage of those flags can cause severe issues. Refer to the documentation ofGstPadLinkCheck
for more information.MT Safe.
- Parameters:
sinkpad
- the sinkGstPad
to link.flags
- the checks to validate when linking- Returns:
- A result code indicating if the connection worked or what went wrong.
-
linkMaybeGhosting
Links this Pad tosink
, creating anyGstGhostPad
's in between as necessary.This is a convenience function to save having to create and add intermediate
GstGhostPad
's as required for linking acrossGstBin
boundaries.If this Pad or
sink
pads don't have parent elements or do not share a common ancestor, the link will fail.- Parameters:
sink
- aGstPad
- Returns:
- whether the link succeeded.
-
linkMaybeGhostingFull
Links this Pad tosink
, creating anyGstGhostPad
's in between as necessary.This is a convenience function to save having to create and add intermediate
GstGhostPad
's as required for linking acrossGstBin
boundaries.If this Pad or
sink
pads don't have parent elements or do not share a common ancestor, the link will fail.Calling gst_pad_link_maybe_ghosting_full() with
flags
==PadLinkCheck.DEFAULT
is the recommended way of linking pads with safety checks applied.- Parameters:
sink
- aGstPad
flags
- someGstPadLinkCheck
flags- Returns:
- whether the link succeeded.
-
linkMaybeGhostingFull
Links this Pad tosink
, creating anyGstGhostPad
's in between as necessary.This is a convenience function to save having to create and add intermediate
GstGhostPad
's as required for linking acrossGstBin
boundaries.If this Pad or
sink
pads don't have parent elements or do not share a common ancestor, the link will fail.Calling gst_pad_link_maybe_ghosting_full() with
flags
==PadLinkCheck.DEFAULT
is the recommended way of linking pads with safety checks applied.- Parameters:
sink
- aGstPad
flags
- someGstPadLinkCheck
flags- Returns:
- whether the link succeeded.
-
markReconfigure
public void markReconfigure()Mark a pad for needing reconfiguration. The next call to gst_pad_check_reconfigure() will returntrue
after this call. -
needsReconfigure
public boolean needsReconfigure()Check theGST_PAD_FLAG_NEED_RECONFIGURE
flag on this Pad and returntrue
if the flag was set.- Returns:
true
is the GST_PAD_FLAG_NEED_RECONFIGURE flag is set on this Pad.
-
pauseTask
public boolean pauseTask()Pause the task of this Pad. This function will also wait until the function executed by the task is finished if this function is not called from the task function.- Returns:
- a
true
if the task could be paused orfalse
when the pad has no task.
-
peerQuery
Performs gst_pad_query() on the peer of this Pad.The caller is responsible for both the allocation and deallocation of the query structure.
- Parameters:
query
- theGstQuery
to perform.- Returns:
true
if the query could be performed. This function returnsfalse
if this Pad has no peer.
-
peerQueryAcceptCaps
Check if the peer of this Pad acceptscaps
. If this Pad has no peer, this function returnstrue
.- Parameters:
caps
- aGstCaps
to check on the pad- Returns:
true
if the peer of this Pad can accept the caps or this Pad has no peer.
-
peerQueryCaps
Gets the capabilities of the peer connected to this pad. Similar to gst_pad_query_caps().When called on srcpads
filter
contains the caps that upstream could produce in the order preferred by upstream. When called on sinkpadsfilter
contains the caps accepted by downstream in the preferred order.filter
might benull
but if it is notnull
the returned caps will be a subset offilter
.- Parameters:
filter
- aGstCaps
filter, ornull
.- Returns:
- the caps of the peer pad with incremented
ref-count. When there is no peer pad, this function returns
filter
or, whenfilter
isnull
, ANY caps.
-
peerQueryConvert
public boolean peerQueryConvert(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal) Queries the peer pad of a given sink pad to convertsrcVal
insrcFormat
todestFormat
.- Parameters:
srcFormat
- aGstFormat
to convert from.srcVal
- a value to convert.destFormat
- theGstFormat
to convert to.destVal
- a pointer to the result.- Returns:
true
if the query could be performed.
-
peerQueryDuration
Queries the peer pad of a given sink pad for the total stream duration.- Parameters:
format
- theGstFormat
requestedduration
- a location in which to store the total duration, ornull
.- Returns:
true
if the query could be performed.
-
peerQueryPosition
Queries the peer of a given sink pad for the stream position.- Parameters:
format
- theGstFormat
requestedcur
- a location in which to store the current position, ornull
.- Returns:
true
if the query could be performed.
-
proxyQueryAcceptCaps
Checks if all internally linked pads of this Pad accepts the caps inquery
and returns the intersection of the results.This function is useful as a default accept caps query function for an element that can handle any stream format, but requires caps that are acceptable for all opposite pads.
- Parameters:
query
- an ACCEPT_CAPSGstQuery
.- Returns:
true
ifquery
could be executed
-
proxyQueryCaps
Calls gst_pad_query_caps() for all internally linked pads of this Pad and returns the intersection of the results.This function is useful as a default caps query function for an element that can handle any stream format, but requires all its pads to have the same caps. Two such elements are tee and adder.
- Parameters:
query
- a CAPSGstQuery
.- Returns:
true
ifquery
could be executed
-
pullRange
Pulls abuffer
from the peer pad or fills up a provided buffer.This function will first trigger the pad block signal if it was installed.
When this Pad is not linked
GST_FLOW_NOT_LINKED
is returned else this function returns the result of gst_pad_get_range() on the peer pad. See gst_pad_get_range() for a list of return values and for the semantics of the arguments of this function.If
buffer
points to a variable holdingnull
, a valid newGstBuffer
will be placed inbuffer
when this function returnsGST_FLOW_OK
. The new buffer must be freed with gst_buffer_unref() after usage. When this function returns any other result value,buffer
will still point tonull
.When
buffer
points to a variable that points to a validGstBuffer
, the buffer will be filled with the result data when this function returnsGST_FLOW_OK
. When this function returns any other result value,buffer
will be unchanged. If the provided buffer is larger thansize
, onlysize
bytes will be filled in the result buffer and its size will be updated accordingly.Note that less than
size
bytes can be returned inbuffer
when, for example, an EOS condition is near or whenbuffer
is not large enough to holdsize
bytes. The caller should check the result buffer size to get the result size.- Parameters:
offset
- The start offset of the buffersize
- The length of the bufferbuffer
- a pointer to hold theGstBuffer
, returns GST_FLOW_ERROR ifnull
.- Returns:
- a
GstFlowReturn
from the peer pad.MT safe.
-
push
Pushes a buffer to the peer of this Pad.This function will call installed block probes before triggering any installed data probes.
The function proceeds calling gst_pad_chain() on the peer pad and returns the value from that function. If this Pad has no peer,
GST_FLOW_NOT_LINKED
will be returned.In all cases, success or failure, the caller loses its reference to
buffer
after calling this function.- Parameters:
buffer
- theGstBuffer
to push returns GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturn
from the peer pad.MT safe.
-
pushEvent
Sends the event to the peer of the given pad. This function is mainly used by elements to send events to their peer elements.This function takes ownership of the provided event so you should gst_event_ref() it if you want to reuse the event after this call.
- Parameters:
event
- theGstEvent
to send to the pad.- Returns:
true
if the event was handled.MT safe.
-
pushList
Pushes a buffer list to the peer of this Pad.This function will call installed block probes before triggering any installed data probes.
The function proceeds calling the chain function on the peer pad and returns the value from that function. If this Pad has no peer,
GST_FLOW_NOT_LINKED
will be returned. If the peer pad does not have any installed chainlist function every group buffer of the list will be merged into a normalGstBuffer
and chained via gst_pad_chain().In all cases, success or failure, the caller loses its reference to
list
after calling this function.- Parameters:
list
- theGstBufferList
to push returns GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturn
from the peer pad.MT safe.
-
query
Dispatches a query to a pad. The query should have been allocated by the caller via one of the type-specific allocation functions. The element that the pad belongs to is responsible for filling the query with an appropriate response, which should then be parsed with a type-specific query parsing function.Again, the caller is responsible for both the allocation and deallocation of the query structure.
Please also note that some queries might need a running pipeline to work.
- Parameters:
query
- theGstQuery
to perform.- Returns:
true
if the query could be performed.
-
queryAcceptCaps
Check if the given pad accepts the caps.- Parameters:
caps
- aGstCaps
to check on the pad- Returns:
true
if the pad can accept the caps.
-
queryCaps
Gets the capabilities this pad can produce or consume. Note that this method doesn't necessarily return the caps set by sending a gst_event_new_caps() - use gst_pad_get_current_caps() for that instead. gst_pad_query_caps returns all possible caps a pad can operate with, using the pad's CAPS query function, If the query fails, this function will returnfilter
, if notnull
, otherwise ANY.When called on sinkpads
filter
contains the caps that upstream could produce in the order preferred by upstream. When called on srcpadsfilter
contains the caps accepted by downstream in the preferred order.filter
might benull
but if it is notnull
the returned caps will be a subset offilter
.Note that this function does not return writable
GstCaps
, use gst_caps_make_writable() before modifying the caps.- Parameters:
filter
- suggestedGstCaps
, ornull
- Returns:
- the caps of the pad with incremented ref-count.
-
queryConvert
Queries a pad to convertsrcVal
insrcFormat
todestFormat
.- Parameters:
srcFormat
- aGstFormat
to convert from.srcVal
- a value to convert.destFormat
- theGstFormat
to convert to.destVal
- a pointer to the result.- Returns:
true
if the query could be performed.
-
queryDefault
Invokes the default query handler for the given pad. The query is sent to all pads internally linked to this Pad. Note that if there are many possible sink pads that are internally linked to this Pad, only one will be sent the query. Multi-sinkpad elements should implement custom query handlers.- Parameters:
parent
- the parent of this Pad ornull
query
- theGstQuery
to handle.- Returns:
true
if the query was performed successfully.
-
queryDuration
-
queryPosition
-
removeProbe
public void removeProbe(int id) Remove the probe withid
from this Pad.MT safe.
- Parameters:
id
- the probe id to remove
-
sendEvent
Sends the event to the pad. This function can be used by applications to send events in the pipeline.If this Pad is a source pad,
event
should be an upstream event. If this Pad is a sink pad,event
should be a downstream event. For example, you would not send aGST_EVENT_EOS
on a src pad; EOS events only propagate downstream. Furthermore, some downstream events have to be serialized with data flow, like EOS, while some can travel out-of-band, likeGST_EVENT_FLUSH_START
. If the event needs to be serialized with data flow, this function will take the pad's stream lock while calling its event function.To find out whether an event type is upstream, downstream, or downstream and serialized, see
GstEventTypeFlags
, gst_event_type_get_flags(),GST_EVENT_IS_UPSTREAM
,GST_EVENT_IS_DOWNSTREAM
, andGST_EVENT_IS_SERIALIZED
. Note that in practice that an application or plugin doesn't need to bother itself with this information; the core handles all necessary locks and checks.This function takes ownership of the provided event so you should gst_event_ref() it if you want to reuse the event after this call.
- Parameters:
event
- theGstEvent
to send to the pad.- Returns:
true
if the event was handled.
-
setActivateFunctionFull
Sets the given activate function for this Pad. The activate function will dispatch to gst_pad_activate_mode() to perform the actual activation. Only makes sense to set on sink pads.Call this function if your sink pad can start a pull-based task.
- Parameters:
activate
- theGstPadActivateFunction
to set.
-
setActivatemodeFunctionFull
Sets the given activate_mode function for the pad. An activate_mode function prepares the element for data passing.- Parameters:
activatemode
- theGstPadActivateModeFunction
to set.
-
setActive
public boolean setActive(boolean active) Activates or deactivates the given pad. Normally called from within core state change functions.If
active
, makes sure the pad is active. If it is already active, either in push or pull mode, just return. Otherwise dispatches to the pad's activate function to perform the actual activation.If not
active
, calls gst_pad_activate_mode() with the pad's current mode and afalse
argument.- Parameters:
active
- whether or not the pad should be active.- Returns:
true
if the operation was successful.MT safe.
-
setChainFunctionFull
Sets the given chain function for the pad. The chain function is called to process aGstBuffer
input buffer. seeGstPadChainFunction
for more details.- Parameters:
chain
- theGstPadChainFunction
to set.
-
setChainListFunctionFull
Sets the given chain list function for the pad. The chainlist function is called to process aGstBufferList
input buffer list. SeeGstPadChainListFunction
for more details.- Parameters:
chainlist
- theGstPadChainListFunction
to set.
-
setElementPrivate
Set the given private data gpointer on the pad. This function can only be used by the element that owns the pad. No locking is performed in this function.- Parameters:
priv
- The private data to attach to the pad.
-
setEventFullFunctionFull
Sets the given event handler for the pad.- Parameters:
event
- theGstPadEventFullFunction
to set.
-
setEventFunctionFull
Sets the given event handler for the pad.- Parameters:
event
- theGstPadEventFunction
to set.
-
setGetrangeFunctionFull
Sets the given getrange function for the pad. The getrange function is called to produce a newGstBuffer
to start the processing pipeline. seeGstPadGetRangeFunction
for a description of the getrange function.- Parameters:
get
- theGstPadGetRangeFunction
to set.
-
setIterateInternalLinksFunctionFull
Sets the given internal link iterator function for the pad.- Parameters:
iterintlink
- theGstPadIterIntLinkFunction
to set.
-
setLinkFunctionFull
Sets the given link function for the pad. It will be called when the pad is linked with another pad.The return value
GST_PAD_LINK_OK
should be used when the connection can be made.The return value
GST_PAD_LINK_REFUSED
should be used when the connection cannot be made for some reason.If
link
is installed on a source pad, it should call theGstPadLinkFunction
of the peer sink pad, if present.- Parameters:
link
- theGstPadLinkFunction
to set.
-
setOffset
public void setOffset(long offset) Set the offset that will be applied to the running time of this Pad.- Parameters:
offset
- the offset
-
setQueryFunctionFull
Set the given query function for the pad.- Parameters:
query
- theGstPadQueryFunction
to set.
-
setUnlinkFunctionFull
Sets the given unlink function for the pad. It will be called when the pad is unlinked.Note that the pad's lock is already held when the unlink function is called, so most pad functions cannot be called from within the callback.
- Parameters:
unlink
- theGstPadUnlinkFunction
to set.
-
startTask
Starts a task that repeatedly callsfunc
withuserData
. This function is mostly used in pad activation functions to start the dataflow. TheGST_PAD_STREAM_LOCK
of this Pad will automatically be acquired beforefunc
is called.- Parameters:
func
- the task function to call- Returns:
- a
true
if the task could be started.
-
stickyEventsForeach
Iterates all sticky events on this Pad and callsforeachFunc
for every event. IfforeachFunc
returnsfalse
the iteration is immediately stopped.- Parameters:
foreachFunc
- theGstPadStickyEventsForeachFunction
that should be called for every event.
-
stopTask
public boolean stopTask()Stop the task of this Pad. This function will also make sure that the function executed by the task will effectively stop if not called from the GstTaskFunction.This function will deadlock if called from the GstTaskFunction of the task. Use gst_task_pause() instead.
Regardless of whether the pad has a task, the stream lock is acquired and released so as to ensure that streaming through this pad has finished.
- Returns:
- a
true
if the task could be stopped orfalse
on error.
-
storeStickyEvent
Store the stickyevent
on this Pad- Parameters:
event
- aGstEvent
- Returns:
GST_FLOW_OK
on success,GST_FLOW_FLUSHING
when the pad was flushing orGST_FLOW_EOS
when the pad was EOS.
-
unlink
Unlinks the source pad from the sink pad. Will emit theGstPad
::unlinked signal on both pads.- Parameters:
sinkpad
- the sinkGstPad
to unlink.- Returns:
true
if the pads were unlinked. This function returnsfalse
if the pads were not linked together.MT safe.
-
useFixedCaps
public void useFixedCaps()A helper function you can use that sets the FIXED_CAPS flag This way the default CAPS query will always return the negotiated caps or in case the pad is not negotiated, the padtemplate caps.The negotiated caps are the caps of the last CAPS event that passed on the pad. Use this function on a pad that, once it negotiated to a CAPS, cannot be renegotiated to something else.
-
linked
-
unlinked
-
onLinked
Signals that a pad has been linked to the peer pad.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitLinked
Emits the "linked" signal. SeeonLinked(org.freedesktop.gstreamer.gst.Pad.LinkedCallback)
. -
onUnlinked
Signals that a pad has been unlinked from the peer pad.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitUnlinked
Emits the "unlinked" signal. SeeonUnlinked(org.freedesktop.gstreamer.gst.Pad.UnlinkedCallback)
. -
builder
APad.Builder
object constructs aPad
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withPad.Builder.build()
.
-