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
Nested ClassesModifier and TypeClassDescriptionstatic classPad.Builder<B extends Pad.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theLinkedCallbackcallback.static classstatic interfaceFunctional interface declaration of theUnlinkedCallbackcallback.Nested 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
ConstructorsConstructorDescriptionPad()Creates a new Pad.Pad(@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 TypeMethodDescriptionbooleanactivateMode(PadMode mode, boolean active) Activates or deactivates the given pad inmodevia dispatching to the pad's activatemodefunc.intaddProbe(Set<PadProbeType> mask, @Nullable PadProbeCallback callback) Be notified of different states of pads.intaddProbe(PadProbeType mask, @Nullable PadProbeCallback callback) Be notified of different states of pads.protected PadasParent()Returns this instance as if it were its parent type.static Pad.Builder<? extends Pad.Builder> builder()APad.Builderobject constructs aPadwith the specified properties.booleanChecks if the source pad and the sink pad are compatible so they can be linked.Chain a buffer topad.chainList(BufferList list) Chain a bufferlist topad.booleanCheck and clear theGST_PAD_FLAG_NEED_RECONFIGUREflag on this Pad and returntrueif the flag was set.createStreamId(Element parent, @Nullable String streamId) Creates a stream-id for the sourceGstPadthis Pad by combining the upstream information with the optionalstreamIdof the stream ofpad.this Pad must have a parentGstElementand which must have zero or one sinkpad.createStreamIdPrintf(Element parent, @Nullable String streamId, Object... varargs) Creates a stream-id for the sourceGstPadthis Pad by combining the upstream information with the optionalstreamIdof the stream ofpad.this Pad must have a parentGstElementand which must have zero or one sinkpad.voidemitLinked(@Nullable Pad peer) Emits the "linked" signal.voidemitUnlinked(@Nullable Pad peer) Emits the "unlinked" signal.booleaneventDefault(@Nullable GstObject parent, Event event) Invokes the default event handler for the given pad.booleanforward(@Nullable PadForwardFunction forward) Callsforwardfor all internally linked pads ofpad.This function deals with dynamically changing internal pads and will make sure that theforwardfunction is only called once for each pad.static PadfromStaticTemplate(StaticPadTemplate templ, String name) Creates a new pad with the given name from the given static template.static PadfromTemplate(PadTemplate templ, @Nullable String name) Creates a new pad with the given name from the given template.@Nullable CapsGets the capabilities of the allowed media types that can flow through this Pad and its peer.@Nullable CapsGets the capabilities currently configured on this Pad with the lastGST_EVENT_CAPSevent.Gets the direction of the pad.@Nullable MemorySegmentGets the private data of a pad.Gets theGstFlowReturnreturn from the last data passed by this pad.static MemoryLayoutThe memory layout of the native struct.longGet the offset applied to the running time ofpad.this Pad has to be a source pad.@Nullable PadTemplateGets the template forpad.Gets the capabilities forpad'stemplate.@Nullable ElementGets the parent ofpad,cast to aGstElement.@Nullable PadgetPeer()Gets the peer ofpad.This function refs the peer pad so you need to unref it after use.When this Pad is flushing this function returnsGST_FLOW_FLUSHINGimmediately andbufferisnull.@Nullable PadIf there is a single internal link of the given pad, this function will return it.@Nullable EventgetStickyEvent(EventType eventType, int idx) Returns a new reference of the sticky event of typeeventTypefrom the event.@Nullable StreamReturns the currentGstStreamfor thepad,ornullif none has been set yet, i.e.@Nullable StringReturns the current stream-id for thepad,ornullif none has been set yet, i.e.Get this Pad task state.static @Nullable TypegetType()Get the GType of the Pad classbooleanCheck if this Pad has caps set on it with aGST_EVENT_CAPSevent.booleanisActive()Query if a pad is activebooleanChecks if the pad is blocked or not.booleanChecks if the pad is blocking or not.booleanisLinked()Checks if a this Pad is linked to another pad or not.@Nullable IteratorGets an iterator for the pads to which the given pad is linked to inside of the parent element.@Nullable IteratoriterateInternalLinksDefault(@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 voidlinkFull(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 StringlinkGetName(PadLinkReturn ret) Gets a string representing the given pad-link return.booleanlinkMaybeGhosting(Pad sink) Links this Pad tosink,creating anyGstGhostPad's in between as necessary.booleanlinkMaybeGhostingFull(Pad sink, Set<PadLinkCheck> flags) Links this Pad tosink,creating anyGstGhostPad's in between as necessary.booleanlinkMaybeGhostingFull(Pad sink, PadLinkCheck... flags) Links this Pad tosink,creating anyGstGhostPad's in between as necessary.voidMark a pad for needing reconfiguration.booleanCheck theGST_PAD_FLAG_NEED_RECONFIGUREflag on this Pad and returntrueif 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.booleanPause the task ofpad.This function will also wait until the function executed by the task is finished if this function is not called from the task function.booleanPerforms gst_pad_query() on the peer ofpad.booleanpeerQueryAcceptCaps(Caps caps) Check if the peer of this Pad acceptscaps.If this Pad has no peer, this function returnstrue.peerQueryCaps(@Nullable Caps filter) Gets the capabilities of the peer connected to this pad.booleanpeerQueryConvert(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal) Queries the peer pad of a given sink pad to convertsrcValinsrcFormattodestFormat.booleanpeerQueryDuration(Format format, @Nullable Out<Long> duration) Queries the peer pad of a given sink pad for the total stream duration.booleanpeerQueryPosition(Format format, @Nullable Out<Long> cur) Queries the peer of a given sink pad for the stream position.booleanproxyQueryAcceptCaps(Query query) Checks if all internally linked pads of this Pad accepts the caps inqueryand returns the intersection of the results.booleanproxyQueryCaps(Query query) Calls gst_pad_query_caps() for all internally linked pads of this Pad and returns the intersection of the results.Pulls abufferfrom the peer pad or fills up a provided buffer.Pushes a buffer to the peer ofpad.booleanSends the event to the peer of the given pad.pushList(BufferList list) Pushes a buffer list to the peer ofpad.booleanDispatches a query to a pad.booleanqueryAcceptCaps(Caps caps) Check if the given pad accepts the caps.Gets the capabilities this pad can produce or consume.booleanqueryConvert(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal) Queries a pad to convertsrcValinsrcFormattodestFormat.booleanqueryDefault(@Nullable GstObject parent, Query query) Invokes the default query handler for the given pad.booleanqueryDuration(Format format, @Nullable Out<Long> duration) Queries a pad for the total stream duration.booleanqueryPosition(Format format, @Nullable Out<Long> cur) Queries a pad for the stream position.voidremoveProbe(int id) Remove the probe withidfrompad.booleanSends the event to the pad.voidsetActivateFunctionFull(@Nullable PadActivateFunction activate) Sets the given activate function forpad.The activate function will dispatch to gst_pad_activate_mode() to perform the actual activation.voidsetActivatemodeFunctionFull(@Nullable PadActivateModeFunction activatemode) Sets the given activate_mode function for the pad.booleansetActive(boolean active) Activates or deactivates the given pad.voidsetChainFunctionFull(@Nullable PadChainFunction chain) Sets the given chain function for the pad.voidsetChainListFunctionFull(@Nullable PadChainListFunction chainlist) Sets the given chain list function for the pad.voidsetElementPrivate(@Nullable MemorySegment priv) Set the given private data gpointer on the pad.voidsetEventFullFunctionFull(@Nullable PadEventFullFunction event) Sets the given event handler for the pad.voidsetEventFunctionFull(@Nullable PadEventFunction event) Sets the given event handler for the pad.voidsetGetrangeFunctionFull(@Nullable PadGetRangeFunction get) Sets the given getrange function for the pad.voidsetIterateInternalLinksFunctionFull(@Nullable PadIterIntLinkFunction iterintlink) Sets the given internal link iterator function for the pad.voidsetLinkFunctionFull(@Nullable PadLinkFunction link) Sets the given link function for the pad.voidsetOffset(long offset) Set the offset that will be applied to the running time ofpad.Upon next buffer, every sticky events (notably segment) will be pushed again with their running time adjusted.voidsetQueryFunctionFull(@Nullable PadQueryFunction query) Set the given query function for the pad.voidsetUnlinkFunctionFull(@Nullable PadUnlinkFunction unlink) Sets the given unlink function for the pad.booleanstartTask(@Nullable TaskFunction func) Starts a task that repeatedly callsfuncwithuserData.This function is mostly used in pad activation functions to start the dataflow.voidstickyEventsForeach(@Nullable PadStickyEventsForeachFunction foreachFunc) Iterates all sticky events on this Pad and callsforeachFuncfor every event.booleanstopTask()Stop the task ofpad.This function will also make sure that the function executed by the task will effectively stop if not called from the GstTaskFunction.storeStickyEvent(Event event) Store the stickyeventon this PadbooleanUnlinks the source pad from the sink pad.protected voidvoidA 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, 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
-
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- theGstPadDirectionof the pad.
-
Pad
public Pad()Creates a new 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 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. -
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- theGstStaticPadTemplateto 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- aGstPadLinkReturnto get the name of.- Returns:
- a static string with the name of the pad-link return.
- Since:
- 1.4
-
activateMode
Activates or deactivates the given pad inmodevia 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:
trueif 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-GstPadProbeCallbackthat 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-GstPadProbeCallbackthat 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:
trueif the pads can be linked.
-
chain
Chain a buffer topad.The function returns
GST_FLOW_FLUSHINGif 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_SUPPORTEDis returned if this Pad has no chain function.In all cases, success or failure, the caller loses its reference to
bufferafter calling this function.- Parameters:
buffer- theGstBufferto send, return GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturnfrom the pad.MT safe.
-
chainList
Chain a bufferlist topad.The function returns
GST_FLOW_FLUSHINGif 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_SUPPORTEDis returned if this Pad has no chainlist function.In all cases, success or failure, the caller loses its reference to
listafter calling this function.MT safe.
- Parameters:
list- theGstBufferListto send, return GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturnfrom the pad.
-
checkReconfigure
public boolean checkReconfigure()Check and clear theGST_PAD_FLAG_NEED_RECONFIGUREflag on this Pad and returntrueif the flag was set.- Returns:
trueis the GST_PAD_FLAG_NEED_RECONFIGURE flag was set onpad.
-
createStreamId
Creates a stream-id for the sourceGstPadthis Pad by combining the upstream information with the optionalstreamIdof the stream ofpad.this Pad must have a parentGstElementand which must have zero or one sinkpad.streamIdcan only benullif 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
streamIdto 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 \\
03uinstead of \\u.- Parameters:
parent- ParentGstElementof this PadstreamId- The stream-id- Returns:
- A stream-id for
pad.g_free() after usage.
-
createStreamIdPrintf
Creates a stream-id for the sourceGstPadthis Pad by combining the upstream information with the optionalstreamIdof the stream ofpad.this Pad must have a parentGstElementand which must have zero or one sinkpad.streamIdcan only benullif 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
streamIdto 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- ParentGstElementof this PadstreamId- The stream-idvarargs- parameters for thestreamIdformat string- Returns:
- A stream-id for
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
pad.This function takes ownership ofevent.- Parameters:
parent- the parent of this Pad ornullevent- theGstEventto handle.- Returns:
trueif the event was sent successfully.
-
forward
Callsforwardfor all internally linked pads ofpad.This function deals with dynamically changing internal pads and will make sure that theforwardfunction is only called once for each pad.When
forwardreturnstrue, no further pads will be processed.- Parameters:
forward- aGstPadForwardFunction- Returns:
trueif 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
GstCapsof the pad link. Unref the caps when you no longer need it. This function returnsnullwhen this Pad has no peer.MT safe.
-
getCurrentCaps
Gets the capabilities currently configured on this Pad with the lastGST_EVENT_CAPSevent.- Returns:
- the current caps of the pad with
incremented ref-count or
nullwhen 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
GstPadDirectionof the pad.MT safe.
-
getElementPrivate
Gets the private data of a pad. No locking is performed in this function.- Returns:
- a
gpointerto the private data.
-
getLastFlowReturn
Gets theGstFlowReturnreturn from the last data passed by this pad.- Since:
- 1.4
-
getOffset
public long getOffset()Get the offset applied to the running time ofpad.this Pad has to be a source pad.- Returns:
- the offset.
-
getPadTemplate
Gets the template forpad.- Returns:
- the
GstPadTemplatefrom which this pad was instantiated, ornullif this pad has no template. Unref after usage.
-
getPadTemplateCaps
Gets the capabilities forpad'stemplate.- Returns:
- the
GstCapsof this pad template. Unref after usage.
-
getParentElement
Gets the parent ofpad,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 ofpad.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_FLUSHINGimmediately andbufferisnull.Calls the getrange function of
pad,seeGstPadGetRangeFunctionfor 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
bufferpoints to a variable holdingnull, a valid newGstBufferwill be placed inbufferwhen this function returnsGST_FLOW_OK. The new buffer must be freed with gst_buffer_unref() after usage.When
bufferpoints 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,onlysizebytes will be filled in the result buffer and its size will be updated accordingly.Note that less than
sizebytes can be returned inbufferwhen, for example, an EOS condition is near or whenbufferis not large enough to holdsizebytes. 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,bufferwill 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_ERRORifnull.- Returns:
- a
GstFlowReturnfrom 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, ornullif this Pad has none or more than one internal links. Unref returned pad with gst_object_unref(). - Since:
- 1.18
-
getStickyEvent
Returns a new reference of the sticky event of typeeventTypefrom the event.- Parameters:
eventType- theGstEventTypethat should be retrieved.idx- the index of the event- Returns:
- a
GstEventof typeeventTypeornullwhen no event ofeventTypewas onpad.Unref after usage.
-
getStream
Returns the currentGstStreamfor thepad,ornullif 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
GstStreamforpad,ornull. unref the returned stream when no longer needed. - Since:
- 1.10
-
getStreamId
Returns the current stream-id for thepad,ornullif 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
pad,ornull. g_free() the returned string when no longer needed. - Since:
- 1.2
-
getTaskState
Get this Pad task state. If no task is currently set,GST_TASK_STOPPEDis returned.- Returns:
- The current state of
pad'stask. - Since:
- 1.12
-
hasCurrentCaps
public boolean hasCurrentCaps()Check if this Pad has caps set on it with aGST_EVENT_CAPSevent.- Returns:
truewhen this Pad has caps associated with it.
-
isActive
public boolean isActive()Query if a pad is active- Returns:
trueif 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:
trueif 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 aGstBufferor aGstEvent.- Returns:
trueif the pad is blocking.MT safe.
-
isLinked
public boolean isLinked()Checks if a this Pad is linked to another pad or not.- Returns:
trueif the pad is linked,falseotherwise.MT safe.
-
iterateInternalLinks
Gets an iterator for the pads to which the given pad is linked to inside of the parent element.Each
GstPadelement yielded by the iterator will have its refcount increased, so unref after use.Free-function: gst_iterator_free
- Returns:
- a new
GstIteratorofGstPadornullwhen 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
GstIteratorofGstPad, ornullif 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 sinkGstPadto 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_linkprovides 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 ofGstPadLinkCheckfor more information.MT Safe.
- Parameters:
sinkpad- the sinkGstPadto 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_linkprovides 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 ofGstPadLinkCheckfor more information.MT Safe.
- Parameters:
sinkpad- the sinkGstPadto 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 acrossGstBinboundaries.If this Pad or
sinkpads don't have parent elements or do not share a common ancestor, the link will fail.- Parameters:
sink- aGstPad- Returns:
- whether the link succeeded.
- Since:
- 1.10
-
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 acrossGstBinboundaries.If this Pad or
sinkpads 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.DEFAULTis the recommended way of linking pads with safety checks applied.- Parameters:
sink- aGstPadflags- someGstPadLinkCheckflags- Returns:
- whether the link succeeded.
- Since:
- 1.10
-
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 acrossGstBinboundaries.If this Pad or
sinkpads 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.DEFAULTis the recommended way of linking pads with safety checks applied.- Parameters:
sink- aGstPadflags- someGstPadLinkCheckflags- Returns:
- whether the link succeeded.
- Since:
- 1.10
-
markReconfigure
public void markReconfigure()Mark a pad for needing reconfiguration. The next call to gst_pad_check_reconfigure() will returntrueafter this call. -
needsReconfigure
public boolean needsReconfigure()Check theGST_PAD_FLAG_NEED_RECONFIGUREflag on this Pad and returntrueif the flag was set.- Returns:
trueis the GST_PAD_FLAG_NEED_RECONFIGURE flag is set onpad.
-
pauseTask
public boolean pauseTask()Pause the task ofpad.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
trueif the task could be paused orfalsewhen the pad has no task.
-
peerQuery
Performs gst_pad_query() on the peer ofpad.The caller is responsible for both the allocation and deallocation of the query structure.
- Parameters:
query- theGstQueryto perform.- Returns:
trueif the query could be performed. This function returnsfalseif 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- aGstCapsto check on the pad- Returns:
trueif 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
filtercontains the caps that upstream could produce in the order preferred by upstream. When called on sinkpadsfiltercontains the caps accepted by downstream in the preferred order.filtermight benullbut if it is notnullthe returned caps will be a subset offilter.- Parameters:
filter- aGstCapsfilter, ornull.- Returns:
- the caps of the peer pad with incremented
ref-count. When there is no peer pad, this function returns
filteror, whenfilterisnull, 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 convertsrcValinsrcFormattodestFormat.- Parameters:
srcFormat- aGstFormatto convert from.srcVal- a value to convert.destFormat- theGstFormatto convert to.destVal- a pointer to the result.- Returns:
trueif the query could be performed.
-
peerQueryDuration
Queries the peer pad of a given sink pad for the total stream duration.- Parameters:
format- theGstFormatrequestedduration- a location in which to store the total duration, ornull.- Returns:
trueif the query could be performed.
-
peerQueryPosition
-
proxyQueryAcceptCaps
Checks if all internally linked pads of this Pad accepts the caps inqueryand 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:
trueifquerycould 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:
trueifquerycould be executed
-
pullRange
Pulls abufferfrom 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_LINKEDis 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
bufferpoints to a variable holdingnull, a valid newGstBufferwill be placed inbufferwhen 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,bufferwill still point tonull.When
bufferpoints 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,bufferwill be unchanged. If the provided buffer is larger thansize,onlysizebytes will be filled in the result buffer and its size will be updated accordingly.Note that less than
sizebytes can be returned inbufferwhen, for example, an EOS condition is near or whenbufferis not large enough to holdsizebytes. 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
GstFlowReturnfrom the peer pad.MT safe.
-
push
Pushes a buffer to the peer ofpad.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_LINKEDwill be returned.In all cases, success or failure, the caller loses its reference to
bufferafter calling this function.- Parameters:
buffer- theGstBufferto push returns GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturnfrom 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- theGstEventto push out of the pad.- Returns:
trueif the event was handled.MT safe.
-
pushList
Pushes a buffer list to the peer ofpad.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_LINKEDwill be returned. If the peer pad does not have any installed chainlist function every group buffer of the list will be merged into a normalGstBufferand chained via gst_pad_chain().In all cases, success or failure, the caller loses its reference to
listafter calling this function.- Parameters:
list- theGstBufferListto push returns GST_FLOW_ERROR if not.- Returns:
- a
GstFlowReturnfrom 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- theGstQueryto perform.- Returns:
trueif the query could be performed.
-
queryAcceptCaps
Check if the given pad accepts the caps.- Parameters:
caps- aGstCapsto check on the pad- Returns:
trueif 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
filtercontains the caps that upstream could produce in the order preferred by upstream. When called on srcpadsfiltercontains the caps accepted by downstream in the preferred order.filtermight benullbut if it is notnullthe 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 convertsrcValinsrcFormattodestFormat.- Parameters:
srcFormat- aGstFormatto convert from.srcVal- a value to convert.destFormat- theGstFormatto convert to.destVal- a pointer to the result.- Returns:
trueif the query could be performed.
-
queryDefault
Invokes the default query handler for the given pad. The query is sent to all pads internally linked topad.Note that if there are many possible sink pads that are internally linked topad,only one will be sent the query. Multi-sinkpad elements should implement custom query handlers.- Parameters:
parent- the parent of this Pad ornullquery- theGstQueryto handle.- Returns:
trueif the query was performed successfully.
-
queryDuration
-
queryPosition
-
removeProbe
public void removeProbe(int id) Remove the probe withidfrompad.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,
eventshould be an upstream event. If this Pad is a sink pad,eventshould be a downstream event. For example, you would not send aGST_EVENT_EOSon 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- theGstEventto send to the pad.- Returns:
trueif the event was handled.
-
setActivateFunctionFull
Sets the given activate function forpad.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- theGstPadActivateFunctionto set.
-
setActivatemodeFunctionFull
Sets the given activate_mode function for the pad. An activate_mode function prepares the element for data passing.- Parameters:
activatemode- theGstPadActivateModeFunctionto 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 afalseargument.- Parameters:
active- whether or not the pad should be active.- Returns:
trueif the operation was successful.MT safe.
-
setChainFunctionFull
Sets the given chain function for the pad. The chain function is called to process aGstBufferinput buffer. seeGstPadChainFunctionfor more details.- Parameters:
chain- theGstPadChainFunctionto set.
-
setChainListFunctionFull
Sets the given chain list function for the pad. The chainlist function is called to process aGstBufferListinput buffer list. SeeGstPadChainListFunctionfor more details.- Parameters:
chainlist- theGstPadChainListFunctionto 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- theGstPadEventFullFunctionto set.- Since:
- 1.8
-
setEventFunctionFull
Sets the given event handler for the pad.- Parameters:
event- theGstPadEventFunctionto set.
-
setGetrangeFunctionFull
Sets the given getrange function for the pad. The getrange function is called to produce a newGstBufferto start the processing pipeline. seeGstPadGetRangeFunctionfor a description of the getrange function.- Parameters:
get- theGstPadGetRangeFunctionto set.
-
setIterateInternalLinksFunctionFull
Sets the given internal link iterator function for the pad.- Parameters:
iterintlink- theGstPadIterIntLinkFunctionto 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_OKshould be used when the connection can be made.The return value
GST_PAD_LINK_REFUSEDshould be used when the connection cannot be made for some reason.If
linkis installed on a source pad, it should call theGstPadLinkFunctionof the peer sink pad, if present.- Parameters:
link- theGstPadLinkFunctionto set.
-
setOffset
public void setOffset(long offset) Set the offset that will be applied to the running time ofpad.Upon next buffer, every sticky events (notably segment) will be pushed again with their running time adjusted. For that reason this is only reliable on source pads.- Parameters:
offset- the offset
-
setQueryFunctionFull
Set the given query function for the pad.- Parameters:
query- theGstPadQueryFunctionto 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- theGstPadUnlinkFunctionto set.
-
startTask
Starts a task that repeatedly callsfuncwithuserData.This function is mostly used in pad activation functions to start the dataflow. TheGST_PAD_STREAM_LOCKof this Pad will automatically be acquired beforefuncis called.- Parameters:
func- the task function to call- Returns:
- a
trueif the task could be started.
-
stickyEventsForeach
Iterates all sticky events on this Pad and callsforeachFuncfor every event. IfforeachFuncreturnsfalsethe iteration is immediately stopped.- Parameters:
foreachFunc- theGstPadStickyEventsForeachFunctionthat should be called for every event.
-
stopTask
public boolean stopTask()Stop the task ofpad.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
trueif the task could be stopped orfalseon error.
-
storeStickyEvent
Store the stickyeventon this Pad- Parameters:
event- aGstEvent- Returns:
GST_FLOW_OKon success,GST_FLOW_FLUSHINGwhen the pad was flushing orGST_FLOW_EOSwhen the pad was EOS.- Since:
- 1.2
-
unlink
Unlinks the source pad from the sink pad. Will emit theGstPad::unlinked signal on both pads.- Parameters:
sinkpad- the sinkGstPadto unlink.- Returns:
trueif the pads were unlinked. This function returnsfalseif 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.Builderobject constructs aPadwith the specified properties. Use the variousset...()methods to set properties, and finish construction withPad.Builder.build().- Returns:
- the builder object
-