public class Pad extends GstObject
See upstream documentation at https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstPad.html
An Element is linked to other elements via "pads", which are extremely
light-weight generic link points. After two pads are retrieved from an
element with Element#getPad, the pads can be link with link(org.freedesktop.gstreamer.Pad).
(For quick links, you can also use Element.link(org.freedesktop.gstreamer.Element), which will make the
obvious link for you if it's straightforward.)
Pads are typically created from a PadTemplate with
Pad(PadTemplate, String).
Pads have Caps attached to it to describe the media type they are
capable of dealing with. queryCaps(org.freedesktop.gstreamer.Caps) and #setCaps are used to
manipulate the caps of the pads. Pads created from a pad template cannot set
capabilities that are incompatible with the pad template capabilities.
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.
getParentElement() will retrieve the Element that owns the pad.
An Element creating a pad will typically use the various gst_pad_set_*_function() calls to register callbacks for various events on the pads.
GstElements will use gst_pad_push() and gst_pad_pull_range() to push out or pull in a buffer.
To send an Event on a pad, use sendEvent(org.freedesktop.gstreamer.event.Event) and pushEvent(org.freedesktop.gstreamer.event.Event).
PadTemplate,
Element,
Event| Modifier and Type | Class and Description |
|---|---|
static interface |
Pad.DATA_PROBE
Probe for listening when new data is available on the Pad.
|
static interface |
Pad.EVENT_PROBE
Probe for listening when an event passes through this Pad.
|
static interface |
Pad.LINKED
|
static interface |
Pad.PROBE
Callback used by
#addProbe(java.util.EnumSet, org.freedesktop.gstreamer.Pad.PROBE) |
static interface |
Pad.UNLINKED
|
GObject.GCallback, GObject.GInterfaceNativeObject.Initializer, NativeObject.TypeProvider, NativeObject.TypeRegistration<T extends NativeObject>| Modifier and Type | Field and Description |
|---|---|
static String |
GTYPE_NAME |
| Constructor and Description |
|---|
Pad(PadTemplate template,
String name)
Creates a new pad with the given name from the given template.
|
Pad(String name,
PadDirection direction)
Creates a new pad with the given name in the given direction.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDataProbe(Pad.DATA_PROBE listener) |
void |
addEventProbe(Pad.EVENT_PROBE listener) |
void |
addProbe(PadProbeType mask,
Pad.PROBE callback)
Be notified of different states of pads.
|
void |
addProbe(Set<PadProbeType> mask,
Pad.PROBE callback)
Be notified of different states of pads.
|
void |
block(Runnable callback)
Run a runnable under a blocked state
|
FlowReturn |
chain(Buffer buffer)
Chain a buffer to pad.
|
void |
connect(Pad.LINKED listener)
Add a listener for the
linked signal on this Pad |
void |
connect(Pad.UNLINKED listener)
Add a listener for the
unlinked signal on this Pad |
void |
disconnect(Pad.LINKED listener)
Remove a listener for the
linked signal on this Pad |
void |
disconnect(Pad.UNLINKED listener)
Remove a listener for the
unlinked signal on this
Pad |
Caps |
getAllowedCaps()
Gets the capabilities of the allowed media types that can flow through
this pad and its peer.
|
Caps |
getCurrentCaps()
Gets the capabilities currently configured on pad with the last
GST_EVENT_CAPS event.
|
PadDirection |
getDirection()
Get the direction of the pad.
|
Element |
getParentElement()
Get the parent of this pad, cast to an
Element. |
Pad |
getPeer()
Get the peer of this pad.
|
FlowReturn |
getRange(long offset,
int size,
Buffer[] buffer)
When pad is flushing this function returns
FlowReturn.FLUSHING immediately. |
PadTemplate |
getTemplate()
Gets the template for pad.
|
boolean |
hasCurrentCaps()
Check if the pad has caps set on it with a GST_EVENT_CAPS events
|
boolean |
isBlocked()
Checks if the pad is blocked or not.
|
boolean |
isBlocking()
Checks if the pad is blocking or not.
|
boolean |
isLinked()
Check if this pad is linked to another pad or not.
|
void |
link(Pad sink)
Links this source pad and a sink pad.
|
boolean |
peerQueryAcceptCaps(Caps caps)
Check if the peer of this pad accepts the caps.
|
Caps |
peerQueryCaps(Caps filter)
Get the capabilities of the peer connected to this pad.
|
FlowReturn |
pullRange(long offset,
int size,
Buffer[] buffer)
Pulls a buffer from the peer pad.
|
FlowReturn |
push(Buffer buffer)
Pushes a buffer to the peer of pad .
|
boolean |
pushEvent(Event event)
Sends the event to the peer of this pad.
|
boolean |
queryAcceptCaps(Caps caps)
Check if the pad accepts the given caps.
|
Caps |
queryCaps(Caps filter)
Gets the capabilities this pad can produce or consume.
|
void |
removeDataProbe(Pad.DATA_PROBE listener) |
void |
removeEventProbe(Pad.EVENT_PROBE listener) |
void |
removeProbe(Pad.PROBE callback)
Remove the provided probe callback from the Pad.
|
boolean |
sendEvent(Event event)
Sends the event to this pad.
|
boolean |
setActive(boolean active)
Activates or deactivates the given pad.
|
boolean |
unlink(Pad pad)
Unlinks the source pad from the sink pad.
|
addControlBinding, getAsString, getControlBinding, getName, getParent, hasActiveControlBindings, removeControlBinding, setAsString, setControlBindingDisabled, setControlBindingsDisabled, setName, suggestNextSync, syncValues, toStringaddCallback, connect, connect, disconnect, dispose, emit, emit, get, getPropertyDefaultValue, getPropertyMaximumValue, getPropertyMinimumValue, getRefCount, getTypeName, invalidate, listPropertyNames, removeCallback, setclose, disown, equals, getPointer, getRawPointer, hashCodepublic static final String GTYPE_NAME
public Pad(String name, PadDirection direction)
name - The name of the new pad.direction - The direction of the new pad.public Pad(PadTemplate template, String name)
template - The pad template to use.name - The name of the new pad.public Caps queryCaps(Caps filter)
getCurrentCaps() for that instead.
queryCaps returns all possible caps a pad can operate with,
using the pad's CAPS query function, If the query fails, this function
will return filter, if not NULL, otherwise ANY.
When called on sinkpads filter contains the caps that upstream could produce in the order preferred by upstream. When called on srcpads filter contains the caps accepted by downstream in the preferred order. filter might be NULL but if it is not NULL the returned caps will be a subset of filter .
Note that this function does not return writable Caps.
filter - suggested Caps or nullCaps of this pad.public Caps getAllowedCaps()
The allowed capabilities is calculated as the intersection of the results
of calling queryCaps(org.freedesktop.gstreamer.Caps) on this pad and its peer.
MT safe.
Caps of the pad link, or null if this pad has
no peer.public Caps getCurrentCaps()
public Pad getPeer()
public Caps peerQueryCaps(Caps filter)
When called on srcpads filter contains the caps that upstream could produce in the order preferred by upstream. When called on sinkpads filter contains the caps accepted by downstream in the preferred order. filter might be NULL but if it is not NULL the returned caps will be a subset of filter .
filter - Caps to filter by, or nullCaps of the peer pad, or null if there is no peer
pad.public boolean queryAcceptCaps(Caps caps)
caps - a Caps to check on the pad.public boolean peerQueryAcceptCaps(Caps caps)
caps - Caps to check on the padpublic void link(Pad sink) throws PadLinkException
sink - the sink Pad to link.PadLinkException - if pads cannot be linked.public boolean unlink(Pad pad)
pad - the sink Pad to unlink.public boolean isLinked()
public PadDirection getDirection()
PadDirection of the pad.public Element getParentElement()
Element. If this pad has no
parent or its parent is not an element, returns null.public boolean setActive(boolean active)
If active is true, 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, checks the pad's current mode and calls gst_pad_activate_push() or gst_pad_activate_pull(), as appropriate, with a FALSE argument.
active - whether or not the pad should be active.public boolean isBlocked()
isBlocking()).public void block(Runnable callback)
callback - The code to run when pad is blockedpublic boolean isBlocking()
Buffer or an
Event.public void connect(Pad.LINKED listener)
linked signal on this Padlistener - The listener to be called when a peer Pad is
linked.public void disconnect(Pad.LINKED listener)
linked signal on this Padlistener - The listener previously added for this signal.public void connect(Pad.UNLINKED listener)
unlinked signal on this Padlistener - The listener to be called when when a peer Pad is
unlinked.public void disconnect(Pad.UNLINKED listener)
unlinked signal on this
Padlistener - The listener previously added for this signal.public void addProbe(Set<PadProbeType> mask, Pad.PROBE callback)
Probes are called in groups: First PadProbeType.BLOCK probes are
called, then others, then finally PadProbeType.IDLE. The only
exception here are IDLE probes that are called immediately if the pad is
already idle while calling addProbe(). In each of the groups, probes are
called in the order in which they were added.
mask - set of mask flags for probe - common options are fields of
PadProbeTypecallback - callback that will be called with notifications of the
pad statepublic void addProbe(PadProbeType mask, Pad.PROBE callback)
Probes are called in groups: First PadProbeType.BLOCK probes are
called, then others, then finally PadProbeType.IDLE. The only
exception here are IDLE probes that are called immediately if the pad is
already idle while calling addProbe(). In each of the groups, probes are
called in the order in which they were added.
mask - mask flag for probecallback - callback that will be called with notifications of the
pad statepublic void removeProbe(Pad.PROBE callback)
callback - callback to removepublic void addEventProbe(Pad.EVENT_PROBE listener)
public void removeEventProbe(Pad.EVENT_PROBE listener)
public void addDataProbe(Pad.DATA_PROBE listener)
public void removeDataProbe(Pad.DATA_PROBE listener)
public boolean sendEvent(Event event)
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 a EventType#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, like
EventType#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.
event - the event to send.public boolean pushEvent(Event event)
This function is mainly used by elements to send events to their peer elements.
event - the event to sendpublic FlowReturn chain(Buffer buffer)
The function returns FlowReturn.FLUSHING if the
pad was flushing.
If the caps on buffer are different from the current caps on pad, this
function will call any function installed on pad (see
gst_pad_set_setcaps_function()). If the new caps are not acceptable for
pad, this function returns
FlowReturn.NOT_NEGOTIATED.
The function proceeds calling the chain function installed on pad and the
return value of that function is returned to the caller.
FlowReturn.NOT_SUPPORTED is returned if pad has no
chain function.
In all cases, success or failure, the caller loses its reference to buffer after calling this function.
buffer - the Buffer, returns FlowReturn.ERROR
if NULL.public FlowReturn getRange(long offset, int size, Buffer[] buffer)
FlowReturn.FLUSHING immediately.
Calls the getRange function of pad, see GstPadGetRangeFunction for a
description of a getRange function. If pad has no getRange function
installed (see gst_pad_set_getrange_function()) this function returns
FlowReturn.NOT_SUPPORTED.
This is a lowlevel function. Usualy pullRange(long, int, org.freedesktop.gstreamer.Buffer[]) is used.
offset - The start offset of the buffersize - The length of the bufferbuffer - the Buffer, returns FlowReturn.ERROR if NULL.public FlowReturn pullRange(long offset, int size, Buffer[] buffer)
This function will first trigger the pad block signal if it was installed.
When pad is not linked FlowReturn.NOT_LINKED is returned else
this function returns the result of getRange(long, int, org.freedesktop.gstreamer.Buffer[]) on the peer pad.
See getRange(long, int, org.freedesktop.gstreamer.Buffer[]) for a list of return values and for the
semantics of the arguments of this function.
buffer's caps must either be unset or the same as what is already configured on pad. Renegotiation within a running pull-mode pipeline is not supported.
offset - The start offset of the buffersize - The length of the bufferbuffer - the Buffer, returns FlowReturn.ERROR if NULL.public FlowReturn push(Buffer buffer)
The function proceeds calling gst_pad_chain() on the peer pad and returns
the value from that function. If pad has no peer, FlowReturn.NOT_LINKED
will be returned.
In all cases, success or failure, the caller loses its reference to buffer after calling this function.
buffer - the GstBuffer to push returns GST_FLOW_ERROR if not.
[transfer full]public PadTemplate getTemplate()
public boolean hasCurrentCaps()
Copyright © 2021 gstreamer-java. All rights reserved.