Class Pad

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
AggregatorPad, ProxyPad

@Generated("org.javagi.JavaGI") public class Pad extends GstObject

A 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.

  • Constructor Details

    • Pad

      public Pad(MemorySegment address)
      Create a Pad instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Pad

      public Pad(@Nullable String name, PadDirection direction)
      Creates a new pad with the given name in the given direction. If name is null, 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 - the GstPadDirection of the pad.
    • Pad

      public Pad()
      Create a new Pad.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Pad class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Pad asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GstObject
      Returns:
      the instance as if it were its parent type
    • fromStaticTemplate

      public static Pad fromStaticTemplate(StaticPadTemplate templ, String name)
      Creates a new pad with the given name from the given static template. If name is null, 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 GstStaticPadTemplate to use
      name - the name of the pad
      Returns:
      a new GstPad.
    • fromTemplate

      public static Pad fromTemplate(PadTemplate templ, @Nullable String name)
      Creates a new pad with the given name from the given template. If name is null, 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 use
      name - the name of the pad
      Returns:
      a new GstPad.
    • linkGetName

      public static String linkGetName(PadLinkReturn ret)
      Gets a string representing the given pad-link return.
      Parameters:
      ret - a GstPadLinkReturn to get the name of.
      Returns:
      a static string with the name of the pad-link return.
      Since:
      1.4
    • activateMode

      public boolean activateMode(PadMode mode, boolean active)

      Activates or deactivates the given pad in mode 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 mode
      active - whether or not the pad should be active.
      Returns:

      true if the operation was successful.

      MT safe.

    • addProbe

      public int addProbe(Set<PadProbeType> mask, @Nullable PadProbeCallback callback)

      Be notified of different states of pads. The provided callback is called for every state that matches mask.

      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 mask
      callback - 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

      public int addProbe(PadProbeType mask, @Nullable PadProbeCallback callback)

      Be notified of different states of pads. The provided callback is called for every state that matches mask.

      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 mask
      callback - 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

      public boolean canLink(Pad sinkpad)
      Checks if the source pad and the sink pad are compatible so they can be linked.
      Parameters:
      sinkpad - the sink GstPad.
      Returns:
      true if the pads can be linked.
    • chain

      public FlowReturn chain(Buffer buffer)

      Chain a buffer to 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 - the GstBuffer to send, return GST_FLOW_ERROR if not.
      Returns:

      a GstFlowReturn from the pad.

      MT safe.

    • chainList

      public FlowReturn chainList(BufferList list)

      Chain a bufferlist to 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 - the GstBufferList to send, return GST_FLOW_ERROR if not.
      Returns:
      a GstFlowReturn from the pad.
    • checkReconfigure

      public boolean checkReconfigure()
      Check and clear the GST_PAD_FLAG_NEED_RECONFIGURE flag on this Pad and return true if the flag was set.
      Returns:
      true is the GST_PAD_FLAG_NEED_RECONFIGURE flag was set on pad.
    • createStreamId

      public String createStreamId(Element parent, @Nullable String streamId)

      Creates a stream-id for the source GstPad this Pad by combining the upstream information with the optional streamId of the stream of pad. this Pad must have a parent GstElement and which must have zero or one sinkpad. streamId can only be null 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 - Parent GstElement of this Pad
      streamId - The stream-id
      Returns:
      A stream-id for pad. g_free() after usage.
    • createStreamIdPrintf

      public String createStreamIdPrintf(Element parent, @Nullable String streamId, Object... varargs)

      Creates a stream-id for the source GstPad this Pad by combining the upstream information with the optional streamId of the stream of pad. this Pad must have a parent GstElement and which must have zero or one sinkpad. streamId can only be null 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 - Parent GstElement of this Pad
      streamId - The stream-id
      varargs - parameters for the streamId format string
      Returns:
      A stream-id for pad. g_free() after usage.
    • eventDefault

      public boolean eventDefault(@Nullable GstObject parent, Event event)

      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 of event.

      Parameters:
      parent - the parent of this Pad or null
      event - the GstEvent to handle.
      Returns:
      true if the event was sent successfully.
    • forward

      public boolean forward(@Nullable PadForwardFunction forward)

      Calls forward for all internally linked pads of pad. This function deals with dynamically changing internal pads and will make sure that the forward function is only called once for each pad.

      When forward returns true, no further pads will be processed.

      Parameters:
      forward - a GstPadForwardFunction
      Returns:
      true if one of the dispatcher functions returned true.
    • getAllowedCaps

      public @Nullable Caps 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 returns null when this Pad has no peer.

      MT safe.

    • getCurrentCaps

      public @Nullable Caps getCurrentCaps()
      Gets the capabilities currently configured on this Pad with the last GST_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

      public PadDirection 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

      public @Nullable MemorySegment getElementPrivate()
      Gets the private data of a pad. No locking is performed in this function.
      Returns:
      a gpointer to the private data.
    • getLastFlowReturn

      public FlowReturn getLastFlowReturn()
      Gets the GstFlowReturn return from the last data passed by this pad.
      Since:
      1.4
    • getOffset

      public long getOffset()
      Get the offset applied to the running time of pad. this Pad has to be a source pad.
      Returns:
      the offset.
    • getPadTemplate

      public @Nullable PadTemplate getPadTemplate()
      Gets the template for pad.
      Returns:
      the GstPadTemplate from which this pad was instantiated, or null if this pad has no template. Unref after usage.
    • getPadTemplateCaps

      public Caps getPadTemplateCaps()
      Gets the capabilities for pad's template.
      Returns:
      the GstCaps of this pad template. Unref after usage.
    • getParentElement

      public @Nullable Element getParentElement()
      Gets the parent of pad, cast to a GstElement. If a this Pad has no parent or its parent is not an element, return null.
      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

      public @Nullable Pad getPeer()
      Gets the peer of 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

      public FlowReturn getRange(long offset, int size, Out<Buffer> buffer)

      When this Pad is flushing this function returns GST_FLOW_FLUSHING immediately and buffer is null.

      Calls the getrange function of 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 returns GST_FLOW_NOT_SUPPORTED.

      If buffer points to a variable holding null, a valid new GstBuffer will be placed in buffer when this function returns GST_FLOW_OK. The new buffer must be freed with gst_buffer_unref() after usage.

      When buffer points to a variable that points to a valid GstBuffer, the buffer will be filled with the result data when this function returns GST_FLOW_OK. If the provided buffer is larger than size, only size bytes will be filled in the result buffer and its size will be updated accordingly.

      Note that less than size bytes can be returned in buffer when, for example, an EOS condition is near or when buffer is not large enough to hold size 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 buffer
      size - The length of the buffer
      buffer - a pointer to hold the GstBuffer, returns GST_FLOW_ERROR if null.
      Returns:

      a GstFlowReturn from the pad.

      MT safe.

    • getSingleInternalLink

      public @Nullable Pad 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, or null if this Pad has none or more than one internal links. Unref returned pad with gst_object_unref().
      Since:
      1.18
    • getStickyEvent

      public @Nullable Event getStickyEvent(EventType eventType, int idx)
      Returns a new reference of the sticky event of type eventType from the event.
      Parameters:
      eventType - the GstEventType that should be retrieved.
      idx - the index of the event
      Returns:
      a GstEvent of type eventType or null when no event of eventType was on pad. Unref after usage.
    • getStream

      public @Nullable Stream getStream()

      Returns the current GstStream for the pad, or null 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 pad, or null. unref the returned stream when no longer needed.
      Since:
      1.10
    • getStreamId

      public @Nullable String getStreamId()

      Returns the current stream-id for the pad, or null 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 pad, or null. g_free() the returned string when no longer needed.
      Since:
      1.2
    • getTaskState

      public TaskState getTaskState()
      Get this Pad task state. If no task is currently set, GST_TASK_STOPPED is returned.
      Returns:
      The current state of pad's task.
      Since:
      1.12
    • hasCurrentCaps

      public boolean hasCurrentCaps()
      Check if this Pad has caps set on it with a GST_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 a GstBuffer or a GstEvent.
      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

      public @Nullable Iterator 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 of GstPad or null when the pad does not have an iterator function configured. Use gst_iterator_free() after usage.
    • iterateInternalLinksDefault

      public @Nullable Iterator iterateInternalLinksDefault(@Nullable GstObject parent)

      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 or null
      Returns:
      a GstIterator of GstPad, or null if this Pad has no parent. Unref each returned pad with gst_object_unref().
    • link

      public PadLinkReturn link(Pad sinkpad)
      Links the source pad and the sink pad.
      Parameters:
      sinkpad - the sink GstPad to link.
      Returns:

      A result code indicating if the connection worked or what went wrong.

      MT Safe.

    • linkFull

      public PadLinkReturn linkFull(Pad sinkpad, Set<PadLinkCheck> flags)

      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 of GstPadLinkCheck for more information.

      MT Safe.

      Parameters:
      sinkpad - the sink GstPad to link.
      flags - the checks to validate when linking
      Returns:
      A result code indicating if the connection worked or what went wrong.
    • linkFull

      public PadLinkReturn linkFull(Pad sinkpad, PadLinkCheck... flags)

      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 of GstPadLinkCheck for more information.

      MT Safe.

      Parameters:
      sinkpad - the sink GstPad to link.
      flags - the checks to validate when linking
      Returns:
      A result code indicating if the connection worked or what went wrong.
    • linkMaybeGhosting

      public boolean linkMaybeGhosting(Pad sink)

      Links this Pad to sink, creating any GstGhostPad's in between as necessary.

      This is a convenience function to save having to create and add intermediate GstGhostPad's as required for linking across GstBin 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 - a GstPad
      Returns:
      whether the link succeeded.
      Since:
      1.10
    • linkMaybeGhostingFull

      public boolean linkMaybeGhostingFull(Pad sink, Set<PadLinkCheck> flags)

      Links this Pad to sink, creating any GstGhostPad's in between as necessary.

      This is a convenience function to save having to create and add intermediate GstGhostPad's as required for linking across GstBin 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 - a GstPad
      flags - some GstPadLinkCheck flags
      Returns:
      whether the link succeeded.
      Since:
      1.10
    • linkMaybeGhostingFull

      public boolean linkMaybeGhostingFull(Pad sink, PadLinkCheck... flags)

      Links this Pad to sink, creating any GstGhostPad's in between as necessary.

      This is a convenience function to save having to create and add intermediate GstGhostPad's as required for linking across GstBin 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 - a GstPad
      flags - some GstPadLinkCheck flags
      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 return true after this call.
    • needsReconfigure

      public boolean needsReconfigure()
      Check the GST_PAD_FLAG_NEED_RECONFIGURE flag on this Pad and return true if the flag was set.
      Returns:
      true is the GST_PAD_FLAG_NEED_RECONFIGURE flag is set on pad.
    • pauseTask

      public boolean pauseTask()
      Pause the task of 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 or false when the pad has no task.
    • peerQuery

      public boolean peerQuery(Query query)

      Performs gst_pad_query() on the peer of pad.

      The caller is responsible for both the allocation and deallocation of the query structure.

      Parameters:
      query - the GstQuery to perform.
      Returns:
      true if the query could be performed. This function returns false if this Pad has no peer.
    • peerQueryAcceptCaps

      public boolean peerQueryAcceptCaps(Caps caps)
      Check if the peer of this Pad accepts caps. If this Pad has no peer, this function returns true.
      Parameters:
      caps - a GstCaps to check on the pad
      Returns:
      true if the peer of this Pad can accept the caps or this Pad has no peer.
    • peerQueryCaps

      public Caps peerQueryCaps(@Nullable Caps filter)

      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 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.

      Parameters:
      filter - a GstCaps filter, or null.
      Returns:
      the caps of the peer pad with incremented ref-count. When there is no peer pad, this function returns filter or, when filter is null, 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 convert srcVal in srcFormat to destFormat.
      Parameters:
      srcFormat - a GstFormat to convert from.
      srcVal - a value to convert.
      destFormat - the GstFormat to convert to.
      destVal - a pointer to the result.
      Returns:
      true if the query could be performed.
    • peerQueryDuration

      public boolean peerQueryDuration(Format format, @Nullable Out<Long> duration)
      Queries the peer pad of a given sink pad for the total stream duration.
      Parameters:
      format - the GstFormat requested
      duration - a location in which to store the total duration, or null.
      Returns:
      true if the query could be performed.
    • peerQueryPosition

      public boolean peerQueryPosition(Format format, @Nullable Out<Long> cur)
      Queries the peer of a given sink pad for the stream position.
      Parameters:
      format - the GstFormat requested
      cur - a location in which to store the current position, or null.
      Returns:
      true if the query could be performed.
    • proxyQueryAcceptCaps

      public boolean proxyQueryAcceptCaps(Query query)

      Checks if all internally linked pads of this Pad accepts the caps in query 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_CAPS GstQuery.
      Returns:
      true if query could be executed
    • proxyQueryCaps

      public boolean proxyQueryCaps(Query query)

      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 CAPS GstQuery.
      Returns:
      true if query could be executed
    • pullRange

      public FlowReturn pullRange(long offset, int size, Out<Buffer> buffer)

      Pulls a buffer 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 holding null, a valid new GstBuffer will be placed in buffer when this function returns GST_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 to null.

      When buffer points to a variable that points to a valid GstBuffer, the buffer will be filled with the result data when this function returns GST_FLOW_OK. When this function returns any other result value, buffer will be unchanged. If the provided buffer is larger than size, only size bytes will be filled in the result buffer and its size will be updated accordingly.

      Note that less than size bytes can be returned in buffer when, for example, an EOS condition is near or when buffer is not large enough to hold size bytes. The caller should check the result buffer size to get the result size.

      Parameters:
      offset - The start offset of the buffer
      size - The length of the buffer
      buffer - a pointer to hold the GstBuffer, returns GST_FLOW_ERROR if null.
      Returns:

      a GstFlowReturn from the peer pad.

      MT safe.

    • push

      public FlowReturn push(Buffer buffer)

      Pushes a buffer to the peer of 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 - the GstBuffer to push returns GST_FLOW_ERROR if not.
      Returns:

      a GstFlowReturn from the peer pad.

      MT safe.

    • pushEvent

      public boolean pushEvent(Event event)

      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 - the GstEvent to push out of the pad.
      Returns:

      true if the event was handled.

      MT safe.

    • pushList

      public FlowReturn pushList(BufferList list)

      Pushes a buffer list to the peer of 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 normal GstBuffer 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 - the GstBufferList to push returns GST_FLOW_ERROR if not.
      Returns:

      a GstFlowReturn from the peer pad.

      MT safe.

    • query

      public boolean query(Query 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 - the GstQuery to perform.
      Returns:
      true if the query could be performed.
    • queryAcceptCaps

      public boolean queryAcceptCaps(Caps caps)
      Check if the given pad accepts the caps.
      Parameters:
      caps - a GstCaps to check on the pad
      Returns:
      true if the pad can accept the caps.
    • queryCaps

      public Caps queryCaps(@Nullable Caps filter)

      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 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 GstCaps, use gst_caps_make_writable() before modifying the caps.

      Parameters:
      filter - suggested GstCaps, or null
      Returns:
      the caps of the pad with incremented ref-count.
    • queryConvert

      public boolean queryConvert(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal)
      Queries a pad to convert srcVal in srcFormat to destFormat.
      Parameters:
      srcFormat - a GstFormat to convert from.
      srcVal - a value to convert.
      destFormat - the GstFormat to convert to.
      destVal - a pointer to the result.
      Returns:
      true if the query could be performed.
    • queryDefault

      public boolean queryDefault(@Nullable GstObject parent, Query query)
      Invokes the default query handler for the given pad. The query is sent to all pads internally linked to pad. Note that if there are many possible sink pads that are internally linked to pad, only one will be sent the query. Multi-sinkpad elements should implement custom query handlers.
      Parameters:
      parent - the parent of this Pad or null
      query - the GstQuery to handle.
      Returns:
      true if the query was performed successfully.
    • queryDuration

      public boolean queryDuration(Format format, @Nullable Out<Long> duration)
      Queries a pad for the total stream duration.
      Parameters:
      format - the GstFormat requested
      duration - a location in which to store the total duration, or null.
      Returns:
      true if the query could be performed.
    • queryPosition

      public boolean queryPosition(Format format, @Nullable Out<Long> cur)
      Queries a pad for the stream position.
      Parameters:
      format - the GstFormat requested
      cur - A location in which to store the current position, or null.
      Returns:
      true if the query could be performed.
    • removeProbe

      public void removeProbe(int id)

      Remove the probe with id from pad.

      MT safe.

      Parameters:
      id - the probe id to remove
    • sendEvent

      public boolean sendEvent(Event event)

      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 a GST_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, like GST_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, and GST_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 - the GstEvent to send to the pad.
      Returns:
      true if the event was handled.
    • setActivateFunctionFull

      public void setActivateFunctionFull(@Nullable PadActivateFunction activate)

      Sets the given activate function for 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 - the GstPadActivateFunction to set.
    • setActivatemodeFunctionFull

      public void setActivatemodeFunctionFull(@Nullable PadActivateModeFunction activatemode)
      Sets the given activate_mode function for the pad. An activate_mode function prepares the element for data passing.
      Parameters:
      activatemode - the GstPadActivateModeFunction 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 a false argument.

      Parameters:
      active - whether or not the pad should be active.
      Returns:

      true if the operation was successful.

      MT safe.

    • setChainFunctionFull

      public void setChainFunctionFull(@Nullable PadChainFunction chain)
      Sets the given chain function for the pad. The chain function is called to process a GstBuffer input buffer. see GstPadChainFunction for more details.
      Parameters:
      chain - the GstPadChainFunction to set.
    • setChainListFunctionFull

      public void setChainListFunctionFull(@Nullable PadChainListFunction chainlist)
      Sets the given chain list function for the pad. The chainlist function is called to process a GstBufferList input buffer list. See GstPadChainListFunction for more details.
      Parameters:
      chainlist - the GstPadChainListFunction to set.
    • setElementPrivate

      public void setElementPrivate(@Nullable MemorySegment priv)
      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

      public void setEventFullFunctionFull(@Nullable PadEventFullFunction event)
      Sets the given event handler for the pad.
      Parameters:
      event - the GstPadEventFullFunction to set.
      Since:
      1.8
    • setEventFunctionFull

      public void setEventFunctionFull(@Nullable PadEventFunction event)
      Sets the given event handler for the pad.
      Parameters:
      event - the GstPadEventFunction to set.
    • setGetrangeFunctionFull

      public void setGetrangeFunctionFull(@Nullable PadGetRangeFunction get)
      Sets the given getrange function for the pad. The getrange function is called to produce a new GstBuffer to start the processing pipeline. see GstPadGetRangeFunction for a description of the getrange function.
      Parameters:
      get - the GstPadGetRangeFunction to set.
    • setIterateInternalLinksFunctionFull

      public void setIterateInternalLinksFunctionFull(@Nullable PadIterIntLinkFunction iterintlink)
      Sets the given internal link iterator function for the pad.
      Parameters:
      iterintlink - the GstPadIterIntLinkFunction to set.
    • setLinkFunctionFull

      public void setLinkFunctionFull(@Nullable PadLinkFunction link)

      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 the GstPadLinkFunction of the peer sink pad, if present.

      Parameters:
      link - the GstPadLinkFunction to set.
    • setOffset

      public void setOffset(long offset)
      Set the offset that will be applied to the running time of pad. 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

      public void setQueryFunctionFull(@Nullable PadQueryFunction query)
      Set the given query function for the pad.
      Parameters:
      query - the GstPadQueryFunction to set.
    • setUnlinkFunctionFull

      public void setUnlinkFunctionFull(@Nullable PadUnlinkFunction unlink)

      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 - the GstPadUnlinkFunction to set.
    • startTask

      public boolean startTask(@Nullable TaskFunction func)
      Starts a task that repeatedly calls func with userData. This function is mostly used in pad activation functions to start the dataflow. The GST_PAD_STREAM_LOCK of this Pad will automatically be acquired before func is called.
      Parameters:
      func - the task function to call
      Returns:
      a true if the task could be started.
    • stickyEventsForeach

      public void stickyEventsForeach(@Nullable PadStickyEventsForeachFunction foreachFunc)
      Iterates all sticky events on this Pad and calls foreachFunc for every event. If foreachFunc returns false the iteration is immediately stopped.
      Parameters:
      foreachFunc - the GstPadStickyEventsForeachFunction that should be called for every event.
    • stopTask

      public boolean stopTask()

      Stop the task of 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 or false on error.
    • storeStickyEvent

      public FlowReturn storeStickyEvent(Event event)
      Store the sticky event on this Pad
      Parameters:
      event - a GstEvent
      Returns:
      GST_FLOW_OK on success, GST_FLOW_FLUSHING when the pad was flushing or GST_FLOW_EOS when the pad was EOS.
      Since:
      1.2
    • unlink

      public boolean unlink(Pad sinkpad)
      Unlinks the source pad from the sink pad. Will emit the GstPad::unlinked signal on both pads.
      Parameters:
      sinkpad - the sink GstPad to unlink.
      Returns:

      true if the pads were unlinked. This function returns false 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

      protected void linked(Pad peer)
    • unlinked

      protected void unlinked(Pad peer)
    • 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

      public void emitLinked(@Nullable Pad peer)
      Emits the "linked" signal. See onLinked(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

      public void emitUnlinked(@Nullable Pad peer)
      Emits the "unlinked" signal. See onUnlinked(Pad.UnlinkedCallback).
    • builder

      public static Pad.Builder<? extends Pad.Builder> builder()
      A Pad.Builder object constructs a Pad with the specified properties. Use the various set...() methods to set properties, and finish construction with Pad.Builder.build().
      Returns:
      the builder object