public class Pad extends GstObject
A 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(java.lang.String)
,
the pads can be link with link(org.gstreamer.Pad)
. (For quick links,
you can also use Element.link(org.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. getCaps()
and setCaps(org.gstreamer.Caps)
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.gstreamer.Event)
and pushEvent(org.gstreamer.Event)
.
PadTemplate
,
Element
,
Event
Modifier and Type | Class and Description |
---|---|
static interface |
Pad.EVENT_PROBE
Signal emitted when an event passes through this Pad.
|
static interface |
Pad.HAVE_DATA
Signal emitted when new data is available on the
Pad |
static interface |
Pad.LINKED
|
static interface |
Pad.REQUEST_LINK
Signal emitted when a connection to a peer
Pad is requested. |
static interface |
Pad.UNLINKED
|
GObject.GCallback
NativeObject.Initializer
defaultInit, ownsHandle
Constructor and Description |
---|
Pad(NativeObject.Initializer init)
Creates a new instance of Pad
|
Pad(PadTemplate template,
java.lang.String name)
Creates a new pad with the given name from the given template.
|
Pad(java.lang.String name,
PadDirection direction)
Creates a new pad with the given name in the given direction.
|
Modifier and Type | Method and Description |
---|---|
boolean |
acceptCaps(Caps caps)
Check if the pad accepts the given caps.
|
void |
addEventProbe(Pad.EVENT_PROBE listener) |
FlowReturn |
chain(Buffer buffer)
Chain a buffer to pad.
|
void |
connect(Pad.HAVE_DATA listener)
Add a listener for the
have-data signal on this Pad |
void |
connect(Pad.LINKED listener)
Add a listener for the
linked signal on this Pad |
void |
connect(Pad.REQUEST_LINK listener)
Add a listener for the
request-link signal on this Pad |
void |
connect(Pad.UNLINKED listener)
Add a listener for the
unlinked signal on this Pad |
void |
disconnect(Pad.HAVE_DATA listener)
Remove a listener for the
have-data signal on this Pad |
void |
disconnect(Pad.LINKED listener)
Remove a listener for the
linked signal on this Pad |
void |
disconnect(Pad.REQUEST_LINK listener)
Remove a listener for the
request-link 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 |
getCaps()
Get the capabilities this pad can produce or consume.
|
PadDirection |
getDirection()
Get the direction of the pad.
|
Caps |
getNegotiatedCaps()
Get the capabilities of the media type that currently flows through this pad
and its peer.
|
Element |
getParentElement()
Get the parent of this pad, cast to a
Element . |
Pad |
getPeer()
Get the peer of this pad.
|
Caps |
getPeerCaps()
Get the capabilities of the peer connected to this pad.
|
FlowReturn |
getRange(long offset,
int size,
Buffer[] buffer)
When pad is flushing this function returns
FlowReturn.WRONG_STATE immediatly. |
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.
|
PadLinkReturn |
link(Pad pad)
Links this pad and a sink pad.
|
boolean |
peerAcceptCaps(Caps caps)
Check if the peer of this pad accepts the caps.
|
FlowReturn |
pullRange(long offset,
int size,
Buffer[] buffer)
Pulls a buffer from the peer pad.
|
boolean |
pushEvent(Event event)
Sends the event to the peer of this pad.
|
void |
removeEventProbe(Pad.EVENT_PROBE listener) |
boolean |
sendEvent(Event event)
Sends the event to this pad.
|
boolean |
setActive(boolean active)
Activates or deactivates the given pad.
|
boolean |
setBlocked(boolean blocked)
Blocks or unblocks the dataflow on a pad.
|
boolean |
setBlockedAsync(boolean blocked,
GstPadAPI.PadBlockCallback callback) |
boolean |
setCaps(Caps caps)
Sets the capabilities of this pad.
|
boolean |
unlink(Pad pad)
Unlinks the source pad from the sink pad.
|
addListenerProxy, getName, getParent, initializer, initializer, ref, removeListenerProxy, setName, steal, toString, unref
addCallback, connect, connect, connect, disconnect, disconnect, disposeNativeHandle, emit, emit, g_signal_connect, get, getPointer, getPropertyDefaultValue, getPropertyMaximumValue, getPropertyMinimumValue, getType, invalidate, objectForX, removeCallback, set
classFor, disown, dispose, equals, finalize, getNativeAddress, handle, hashCode, initializer, instanceFor, isDisposed, nativeValue, objectFor, objectFor, objectFor, objectFor
public Pad(NativeObject.Initializer init)
public Pad(java.lang.String name, PadDirection direction)
name
- The name of the new pad.direction
- The direction of the new pad.public Pad(PadTemplate template, java.lang.String name)
template
- The pad template to use.name
- The name of the new pad.public Caps getCaps()
setCaps(org.gstreamer.Caps)
.
This returns the pad template caps if not explicitly set.
MT safe.Caps
of this pad.public boolean setCaps(Caps caps)
caps
- The Caps
to set.public Caps getAllowedCaps()
getCaps()
on this pad and its peer.
MT safe.Caps
of the pad link, or null if this pad has no peer.public Caps getNegotiatedCaps()
public Pad getPeer()
public Caps getPeerCaps()
Caps
of the peer pad, or null if there is no peer pad.public boolean acceptCaps(Caps caps)
caps
- a Caps
to check on the pad.public boolean peerAcceptCaps(Caps caps)
caps
- Caps
to check on the padpublic PadLinkReturn link(Pad pad)
pad
- the sink Pad to link.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)
active
- whether or not the pad should be active.public boolean setBlocked(boolean blocked)
blocked
- boolean indicating we should block or unblockpublic boolean isBlocked()
isBlocking()
).public boolean setBlockedAsync(boolean blocked, GstPadAPI.PadBlockCallback callback)
public boolean isBlocking()
Buffer
or a Event
.public void connect(Pad.HAVE_DATA listener)
have-data
signal on this Pad
listener
- The listener to be called when data is available.public void disconnect(Pad.HAVE_DATA listener)
have-data
signal on this Pad
listener
- The listener previously added for this signal.public void connect(Pad.LINKED listener)
linked
signal on this Pad
listener
- The listener to be called when a peer Pad
is linked.public void disconnect(Pad.LINKED listener)
linked
signal on this Pad
listener
- The listener previously added for this signal.public void connect(Pad.UNLINKED listener)
unlinked
signal on this Pad
listener
- The listener to be called when when a peer Pad
is unlinked.public void disconnect(Pad.UNLINKED listener)
unlinked
signal on this Pad
listener
- The listener previously added for this signal.public void connect(Pad.REQUEST_LINK listener)
request-link
signal on this Pad
listener
- The listener to be called when a peer Pad
requests
to be linked to this one.public void disconnect(Pad.REQUEST_LINK listener)
request-link
signal on this Pad
listener
- The listener previously added for this signal.public void addEventProbe(Pad.EVENT_PROBE listener)
public void removeEventProbe(Pad.EVENT_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.WRONG_STATE
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.WRONG_STATE
immediatly.
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.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.gstreamer.Buffer[])
on the peer pad. See getRange(long, int, org.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.