Class Element

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
Aggregator, AudioDecoder, AudioEncoder, AudioVisualizer, BaseParse, BaseSink, BaseSrc, BaseTransform, Bin, Element.Element$Impl, TagSetter.TagSetter$Impl, TocSetter.TocSetter$Impl, VideoDecoder, VideoEncoder

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

GstElement is the abstract base class needed to construct an element that can be used in a GStreamer pipeline. Please refer to the plugin writers guide for more information on creating GstElement subclasses.

The name of a GstElement can be get with gst_element_get_name() and set with gst_element_set_name(). For speed, GST_ELEMENT_NAME() can be used in the core when using the appropriate locking. Do not use this in plug-ins or applications in order to retain ABI compatibility.

Elements can have pads (of the type GstPad). These pads link to pads on other elements. GstBuffer flow between these linked pads. A GstElement has a GList of GstPad structures for all their input (or sink) and output (or source) pads. Core and plug-in writers can add and remove pads with gst_element_add_pad() and gst_element_remove_pad().

An existing pad of an element can be retrieved by name with gst_element_get_static_pad(). A new dynamic pad can be created using gst_element_request_pad() with a GstPadTemplate. An iterator of all pads can be retrieved with gst_element_iterate_pads().

Elements can be linked through their pads. If the link is straightforward, use the gst_element_link() convenience function to link two elements, or gst_element_link_many() for more elements in a row. Use gst_element_link_filtered() to link two elements constrained by a specified set of GstCaps. For finer control, use gst_element_link_pads() and gst_element_link_pads_filtered() to specify the pads to link on each element by name.

Each element has a state (see GstState). You can get and set the state of an element with gst_element_get_state() and gst_element_set_state(). Setting a state triggers a GstStateChange. To get a string representation of a GstState, use gst_element_state_get_name().

You can get and set a GstClock on an element using gst_element_get_clock() and gst_element_set_clock(). Some elements can provide a clock for the pipeline if the GST_ELEMENT_FLAG_PROVIDE_CLOCK flag is set. With the gst_element_provide_clock() method one can retrieve the clock provided by such an element. Not all elements require a clock to operate correctly. If the GST_ELEMENT_FLAG_REQUIRE_CLOCK() flag is set, a clock should be set on the element with gst_element_set_clock().

Note that clock selection and distribution is normally handled by the toplevel GstPipeline so the clock functions are only to be used in very specific situations.

  • Constructor Details

    • Element

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

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

    • getType

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

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

      protected Element 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
    • makeFromUri

      public static Element makeFromUri(URIType type, String uri, @Nullable String elementname) throws GErrorException
      Creates an element for handling the given URI.
      Parameters:
      type - Whether to create a source or a sink
      uri - URI to create an element for
      elementname - Name of created element, can be null.
      Returns:
      a new element or null if none could be created
      Throws:
      GErrorException - see GError
    • register

      public static boolean register(@Nullable Plugin plugin, String name, int rank, Type type)
      Create a new elementfactory capable of instantiating objects of the type and add the factory to plugin.
      Parameters:
      plugin - GstPlugin to register the element with, or null for a static element.
      name - name of elements of this type
      rank - rank of element (higher rank means more importance when autoplugging)
      type - GType of element to register
      Returns:
      true, if the registering succeeded, false on error
    • stateChangeReturnGetName

      public static String stateChangeReturnGetName(StateChangeReturn stateRet)
      Gets a string representing the given state change result.
      Parameters:
      stateRet - a GstStateChangeReturn to get the name of.
      Returns:
      a string with the name of the state result.
    • stateGetName

      public static String stateGetName(State state)
      Gets a string representing the given state.
      Parameters:
      state - a GstState to get the name of.
      Returns:
      a string with the name of the state.
    • typeSetSkipDocumentation

      public static void typeSetSkipDocumentation(Type type)

      Marks type as "documentation should be skipped". Can be useful for dynamically registered element to be excluded from plugin documentation system.

      Example:

      GType my_type;
      GTypeInfo my_type_info;
      
      // Fill "my_type_info"
      ...
      
      my_type = g_type_register_static (GST_TYPE_MY_ELEMENT, "my-type-name",
         &my_type_info, 0);
      gst_element_type_set_skip_documentation (my_type);
      gst_element_register (plugin, "my-plugin-feature-name", rank, my_type);
      
      Parameters:
      type - a GType of element
      Since:
      1.20
    • abortState

      public void abortState()

      Abort the state change of the element. This function is used by elements that do asynchronous state changes and find out something is wrong.

      This function should be called with the STATE_LOCK held.

      MT safe.

    • addPad

      public boolean addPad(Pad pad)

      Adds a pad (link point) to element. pad's parent will be set to element; see gst_object_set_parent() for refcounting information.

      Pads are automatically activated when added in the PAUSED or PLAYING state.

      The pad and the element should be unlocked when calling this function.

      This function will emit the GstElement::pad-added signal on the element.

      Parameters:
      pad - the GstPad to add to the element.
      Returns:

      true if the pad could be added. This function can fail when a pad with the same name already existed or the pad already had another parent.

      MT safe.

    • addPropertyDeepNotifyWatch

      public int addPropertyDeepNotifyWatch(@Nullable String propertyName, boolean includeValue)
    • addPropertyNotifyWatch

      public int addPropertyNotifyWatch(@Nullable String propertyName, boolean includeValue)
    • callAsync

      public void callAsync(@Nullable ElementCallAsyncFunc func)

      Calls func from another thread and passes userData to it. This is to be used for cases when a state change has to be performed from a streaming thread, directly via gst_element_set_state() or indirectly e.g. via SEEK events.

      Calling those functions directly from the streaming thread will cause deadlocks in many situations, as they might involve waiting for the streaming thread to shut down from this very streaming thread.

      MT safe.

      Parameters:
      func - Function to call asynchronously from another thread
      Since:
      1.10
    • changeState

      public StateChangeReturn changeState(StateChange transition)

      Perform transition on element.

      This function must be called with STATE_LOCK held and is mainly used internally.

      Parameters:
      transition - the requested transition
      Returns:
      the GstStateChangeReturn of the state transition.
    • continueState

      public StateChangeReturn continueState(StateChangeReturn ret)

      Commit the state change of the element and proceed to the next pending state if any. This function is used by elements that do asynchronous state changes. The core will normally call this method automatically when an element returned StateChangeReturn.SUCCESS from the state change function.

      If after calling this method the element still has not reached the pending state, the next state change is performed.

      This method is used internally and should normally not be called by plugins or applications.

      This function must be called with STATE_LOCK held.

      Parameters:
      ret - The previous state return value
      Returns:

      The result of the commit state change.

      MT safe.

    • createAllPads

      public void createAllPads()
      Creates a pad for each pad template that is always available. This function is only useful during object initialization of subclasses of GstElement.
    • decorateStreamId

      public String decorateStreamId(String streamId)

      Creates a stream-id for this Element by combining the upstream information with the streamId.

      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:
      streamId - The stream-id
      Returns:
      A stream-id for element.
      Since:
      1.24
    • decorateStreamIdPrintf

      public String decorateStreamIdPrintf(String format, Object... varargs)

      Creates a stream-id for this Element by combining the upstream information with the format.

      This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending the stream-id 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:
      format - The stream-id
      Returns:
      A stream-id for element.
      Since:
      1.24
    • foreachPad

      public boolean foreachPad(@Nullable ElementForeachPadFunc func)
      Call func with userData for each of element's pads. func will be called exactly once for each pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new pads are added or pads are removed while pads are being iterated, this will not be taken into account until next time this function is used.
      Parameters:
      func - function to call for each pad
      Returns:
      false if this Element had no pads or if one of the calls to func returned false.
      Since:
      1.14
    • foreachSinkPad

      public boolean foreachSinkPad(@Nullable ElementForeachPadFunc func)
      Call func with userData for each of element's sink pads. func will be called exactly once for each sink pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new sink pads are added or sink pads are removed while the sink pads are being iterated, this will not be taken into account until next time this function is used.
      Parameters:
      func - function to call for each sink pad
      Returns:
      false if this Element had no sink pads or if one of the calls to func returned false.
      Since:
      1.14
    • foreachSrcPad

      public boolean foreachSrcPad(@Nullable ElementForeachPadFunc func)
      Call func with userData for each of element's source pads. func will be called exactly once for each source pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new source pads are added or source pads are removed while the source pads are being iterated, this will not be taken into account until next time this function is used.
      Parameters:
      func - function to call for each source pad
      Returns:
      false if this Element had no source pads or if one of the calls to func returned false.
      Since:
      1.14
    • getBaseTime

      public ClockTime getBaseTime()
      Returns the base time of the element. The base time is the absolute time of the clock when this element was last put to PLAYING. Subtracting the base time from the clock time gives the running time of the element.
      Returns:

      the base time of the element.

      MT safe.

    • getBus

      public @Nullable Bus getBus()
      Returns the bus of the element. Note that only a GstPipeline will provide a bus for the application.
      Returns:

      the element's GstBus. unref after usage.

      MT safe.

    • getClock

      public @Nullable Clock getClock()

      Gets the currently configured clock of the element. This is the clock as was last set with gst_element_set_clock().

      Elements in a pipeline will only have their clock set when the pipeline is in the PLAYING state.

      Returns:

      the GstClock of the element. unref after usage.

      MT safe.

    • getCompatiblePad

      public @Nullable Pad getCompatiblePad(Pad pad, @Nullable Caps caps)

      Looks for an unlinked pad to which the given pad can link. It is not guaranteed that linking the pads will work, though it should work in most cases.

      This function will first attempt to find a compatible unlinked ALWAYS pad, and if none can be found, it will request a compatible REQUEST pad by looking at the templates of element.

      Parameters:
      pad - the GstPad to find a compatible one for.
      caps - the GstCaps to use as a filter.
      Returns:
      the GstPad to which a link can be made, or null if one cannot be found. gst_object_unref() after usage.
    • getCompatiblePadTemplate

      public @Nullable PadTemplate getCompatiblePadTemplate(PadTemplate compattempl)
      Retrieves a pad template from this Element that is compatible with compattempl. Pads from compatible templates can be linked together.
      Parameters:
      compattempl - the GstPadTemplate to find a compatible template for
      Returns:
      a compatible GstPadTemplate, or null if none was found. No unreferencing is necessary.
    • getContext

      public @Nullable Context getContext(String contextType)

      Gets the context with contextType set on the element or NULL.

      MT safe.

      Parameters:
      contextType - a name of a context to retrieve
      Returns:
      A GstContext or NULL
      Since:
      1.8
    • getContextUnlocked

      public @Nullable Context getContextUnlocked(String contextType)
      Gets the context with contextType set on the element or NULL.
      Parameters:
      contextType - a name of a context to retrieve
      Returns:
      A GstContext or NULL
      Since:
      1.8
    • getContexts

      public List<Context> getContexts()

      Gets the contexts set on the element.

      MT safe.

      Returns:
      List of GstContext
      Since:
      1.8
    • getCurrentClockTime

      public ClockTime getCurrentClockTime()
      Returns the current clock time of the element, as in, the time of the element's clock, or GST_CLOCK_TIME_NONE if there is no clock.
      Returns:
      the clock time of the element, or GST_CLOCK_TIME_NONE if there is no clock.
      Since:
      1.18
    • getCurrentRunningTime

      public ClockTime getCurrentRunningTime()
      Returns the running time of the element. The running time is the element's clock time minus its base time. Will return GST_CLOCK_TIME_NONE if the element has no clock, or if its base time has not been set.
      Returns:
      the running time of the element, or GST_CLOCK_TIME_NONE if the element has no clock or its base time has not been set.
      Since:
      1.18
    • getFactory

      public @Nullable ElementFactory getFactory()
      Retrieves the factory that was used to create this element.
      Returns:
      the GstElementFactory used for creating this element or null if element has not been registered (static element). no refcounting is needed.
    • getMetadata

      public String getMetadata(String key)
      Get metadata with key in klass.
      Parameters:
      key - the key to get
      Returns:
      the metadata for key.
      Since:
      1.14
    • getPadTemplate

      public @Nullable PadTemplate getPadTemplate(String name)
      Retrieves a padtemplate from this Element with the given name.
      Parameters:
      name - the name of the GstPadTemplate to get.
      Returns:
      the GstPadTemplate with the given name, or null if none was found. No unreferencing is necessary.
      Since:
      1.14
    • getPadTemplateList

      public List<PadTemplate> getPadTemplateList()
      Retrieves a list of the pad templates associated with element. The list must not be modified by the calling code.
      Returns:
      the GList of pad templates.
      Since:
      1.14
    • getRequestPad

      @Deprecated public @Nullable Pad getRequestPad(String name)
      Deprecated.
      Prefer using gst_element_request_pad_simple() which provides the exact same functionality.
      The name of this function is confusing to people learning GStreamer. gst_element_request_pad_simple() aims at making it more explicit it is a simplified gst_element_request_pad().
      Parameters:
      name - the name of the request GstPad to retrieve.
      Returns:
      requested GstPad if found, otherwise null. Release after usage.
    • getStartTime

      public ClockTime getStartTime()

      Returns the start time of the element. The start time is the running time of the clock when this element was last put to PAUSED.

      Usually the start_time is managed by a toplevel element such as GstPipeline.

      MT safe.

      Returns:
      the start time of the element.
    • getState

      public StateChangeReturn getState(@Nullable Out<State> state, @Nullable Out<State> pending, ClockTime timeout)

      Gets the state of the element.

      For elements that performed an ASYNC state change, as reported by gst_element_set_state(), this function will block up to the specified timeout value for the state change to complete. If the element completes the state change or goes into an error, this function returns immediately with a return value of StateChangeReturn.SUCCESS or StateChangeReturn.FAILURE respectively.

      For elements that did not return StateChangeReturn.ASYNC, this function returns the current and pending state immediately.

      This function returns StateChangeReturn.NO_PREROLL if the element successfully changed its state but is not able to provide data yet. This mostly happens for live sources that only produce data in State.PLAYING. While the state change return is equivalent to StateChangeReturn.SUCCESS, it is returned to the application to signal that some sink elements might not be able to complete their state change because an element is not producing data to complete the preroll. When setting the element to playing, the preroll will complete and playback will start.

      Parameters:
      state - a pointer to GstState to hold the state. Can be null.
      pending - a pointer to GstState to hold the pending state. Can be null.
      timeout - a GstClockTime to specify the timeout for an async state change or GST_CLOCK_TIME_NONE for infinite timeout.
      Returns:

      StateChangeReturn.SUCCESS if the element has no more pending state and the last state change succeeded, StateChangeReturn.ASYNC if the element is still performing a state change or StateChangeReturn.FAILURE if the last state change failed.

      MT safe.

    • getStaticPad

      public @Nullable Pad getStaticPad(String name)
      Retrieves a pad from this Element by name. This version only retrieves already-existing (i.e. 'static') pads.
      Parameters:
      name - the name of the static GstPad to retrieve.
      Returns:

      the requested GstPad if found, otherwise null. unref after usage.

      MT safe.

    • isLockedState

      public boolean isLockedState()

      Checks if the state of an element is locked. If the state of an element is locked, state changes of the parent don't affect the element. This way you can leave currently unused elements inside bins. Just lock their state before changing the state from GST_STATE_NULL.

      MT safe.

      Returns:
      true, if the element's state is locked.
    • iteratePads

      public Iterator iteratePads()

      Retrieves an iterator of element's pads. The iterator should be freed after usage. Also more specialized iterators exists such as gst_element_iterate_src_pads() or gst_element_iterate_sink_pads().

      The order of pads returned by the iterator will be the order in which the pads were added to the element.

      Returns:

      the GstIterator of GstPad.

      MT safe.

    • iterateSinkPads

      public Iterator iterateSinkPads()

      Retrieves an iterator of element's sink pads.

      The order of pads returned by the iterator will be the order in which the pads were added to the element.

      Returns:

      the GstIterator of GstPad.

      MT safe.

    • iterateSrcPads

      public Iterator iterateSrcPads()

      Retrieves an iterator of element's source pads.

      The order of pads returned by the iterator will be the order in which the pads were added to the element.

      Returns:

      the GstIterator of GstPad.

      MT safe.

    • link

      public boolean link(Element dest)

      Links this Element to dest. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. Such pads need to be released manually when unlinking. If multiple links are possible, only one is established.

      Make sure you have added your elements to a bin or pipeline with gst_bin_add() before trying to link them.

      Parameters:
      dest - the GstElement containing the destination pad.
      Returns:
      true if the elements could be linked, false otherwise.
    • linkFiltered

      public boolean linkFiltered(Element dest, @Nullable Caps filter)

      Links this Element to dest using the given caps as filtercaps. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. If multiple links are possible, only one is established.

      Make sure you have added your elements to a bin or pipeline with gst_bin_add() before trying to link them.

      Parameters:
      dest - the GstElement containing the destination pad.
      filter - the GstCaps to filter the link, or null for no filter.
      Returns:
      true if the pads could be linked, false otherwise.
    • linkMany

      public boolean linkMany(Element element2, Object... varargs)
      Chain together a series of elements. Uses gst_element_link(). Make sure you have added your elements to a bin or pipeline with gst_bin_add() before trying to link them.
      Parameters:
      element2 - the second GstElement in the link chain.
      varargs - the null-terminated list of elements to link in order.
      Returns:
      true on success, false otherwise.
    • linkPads

      public boolean linkPads(@Nullable String srcpadname, Element dest, @Nullable String destpadname)
      Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.
      Parameters:
      srcpadname - the name of the GstPad in source element or null for any pad.
      dest - the GstElement containing the destination pad.
      destpadname - the name of the GstPad in destination element, or null for any pad.
      Returns:
      true if the pads could be linked, false otherwise.
    • linkPadsFiltered

      public boolean linkPadsFiltered(@Nullable String srcpadname, Element dest, @Nullable String destpadname, @Nullable Caps filter)
      Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails. If caps is not null, makes sure that the caps of the link is a subset of caps.
      Parameters:
      srcpadname - the name of the GstPad in source element or null for any pad.
      dest - the GstElement containing the destination pad.
      destpadname - the name of the GstPad in destination element or null for any pad.
      filter - the GstCaps to filter the link, or null for no filter.
      Returns:
      true if the pads could be linked, false otherwise.
    • linkPadsFull

      public boolean linkPadsFull(@Nullable String srcpadname, Element dest, @Nullable String destpadname, Set<PadLinkCheck> flags)

      Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

      Calling gst_element_link_pads_full() with flags == PadLinkCheck.DEFAULT is the same as calling gst_element_link_pads() and the recommended way of linking pads with safety checks applied.

      This is a convenience function for gst_pad_link_full().

      Parameters:
      srcpadname - the name of the GstPad in source element or null for any pad.
      dest - the GstElement containing the destination pad.
      destpadname - the name of the GstPad in destination element, or null for any pad.
      flags - the GstPadLinkCheck to be performed when linking pads.
      Returns:
      true if the pads could be linked, false otherwise.
    • linkPadsFull

      public boolean linkPadsFull(@Nullable String srcpadname, Element dest, @Nullable String destpadname, PadLinkCheck... flags)

      Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

      Calling gst_element_link_pads_full() with flags == PadLinkCheck.DEFAULT is the same as calling gst_element_link_pads() and the recommended way of linking pads with safety checks applied.

      This is a convenience function for gst_pad_link_full().

      Parameters:
      srcpadname - the name of the GstPad in source element or null for any pad.
      dest - the GstElement containing the destination pad.
      destpadname - the name of the GstPad in destination element, or null for any pad.
      flags - the GstPadLinkCheck to be performed when linking pads.
      Returns:
      true if the pads could be linked, false otherwise.
    • lostState

      public void lostState()

      Brings the element to the lost state. The current state of the element is copied to the pending state so that any call to gst_element_get_state() will return StateChangeReturn.ASYNC.

      An ASYNC_START message is posted. If the element was PLAYING, it will go to PAUSED. The element will be restored to its PLAYING state by the parent pipeline when it prerolls again.

      This is mostly used for elements that lost their preroll buffer in the State.PAUSED or State.PLAYING state after a flush, they will go to their pending state again when a new preroll buffer is queued. This function can only be called when the element is currently not in error or an async state change.

      This function is used internally and should normally not be called from plugins or applications.

    • messageFull

      public void messageFull(Set<MessageType> type, Quark domain, int code, @Nullable String text, @Nullable String debug, String file, String function, int line)

      Post an error, warning or info message on the bus from inside an element.

      type must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or GST_MESSAGE_INFO.

      MT safe.

      Parameters:
      type - the GstMessageType
      domain - the GStreamer GError domain this message belongs to
      code - the GError code belonging to the domain
      text - an allocated text string to be used as a replacement for the default message connected to code, or null
      debug - an allocated debug message to be used as a replacement for the default debugging information, or null
      file - the source code file where the error was generated
      function - the source code function where the error was generated
      line - the source code line where the error was generated
    • messageFull

      public void messageFull(MessageType type, Quark domain, int code, @Nullable String text, @Nullable String debug, String file, String function, int line)

      Post an error, warning or info message on the bus from inside an element.

      type must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or GST_MESSAGE_INFO.

      MT safe.

      Parameters:
      type - the GstMessageType
      domain - the GStreamer GError domain this message belongs to
      code - the GError code belonging to the domain
      text - an allocated text string to be used as a replacement for the default message connected to code, or null
      debug - an allocated debug message to be used as a replacement for the default debugging information, or null
      file - the source code file where the error was generated
      function - the source code function where the error was generated
      line - the source code line where the error was generated
    • messageFullWithDetails

      public void messageFullWithDetails(Set<MessageType> type, Quark domain, int code, @Nullable String text, @Nullable String debug, String file, String function, int line, Structure structure)

      Post an error, warning or info message on the bus from inside an element.

      type must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or GST_MESSAGE_INFO.

      Parameters:
      type - the GstMessageType
      domain - the GStreamer GError domain this message belongs to
      code - the GError code belonging to the domain
      text - an allocated text string to be used as a replacement for the default message connected to code, or null
      debug - an allocated debug message to be used as a replacement for the default debugging information, or null
      file - the source code file where the error was generated
      function - the source code function where the error was generated
      line - the source code line where the error was generated
      structure - optional details structure
      Since:
      1.10
    • messageFullWithDetails

      public void messageFullWithDetails(MessageType type, Quark domain, int code, @Nullable String text, @Nullable String debug, String file, String function, int line, Structure structure)

      Post an error, warning or info message on the bus from inside an element.

      type must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or GST_MESSAGE_INFO.

      Parameters:
      type - the GstMessageType
      domain - the GStreamer GError domain this message belongs to
      code - the GError code belonging to the domain
      text - an allocated text string to be used as a replacement for the default message connected to code, or null
      debug - an allocated debug message to be used as a replacement for the default debugging information, or null
      file - the source code file where the error was generated
      function - the source code function where the error was generated
      line - the source code line where the error was generated
      structure - optional details structure
      Since:
      1.10
    • noMorePads

      public void noMorePads()

      Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with GST_PAD_SOMETIMES pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads.

      This function emits the GstElement::no-more-pads signal.

      MT safe.

    • postMessage

      public boolean postMessage(Message message)
      Post a message on the element's GstBus. This function takes ownership of the message; if you want to access the message after this call, you should add an additional reference before calling.
      Parameters:
      message - a GstMessage to post
      Returns:

      true if the message was successfully posted. The function returns false if the element did not have a bus.

      MT safe.

    • provideClock

      public @Nullable Clock provideClock()

      Get the clock provided by the given element.

      An element is only required to provide a clock in the PAUSED state. Some elements can provide a clock in other states.

      Returns:

      the GstClock provided by the element or null if no clock could be provided. Unref after usage.

      MT safe.

    • query

      public boolean query(Query query)

      Performs a query on the given element.

      For elements that don't implement a query handler, this function forwards the query to a random srcpad or to the peer of a random linked sinkpad of this element.

      Please note that some queries might need a running pipeline to work.

      Parameters:
      query - the GstQuery.
      Returns:

      true if the query could be performed.

      MT safe.

    • queryConvert

      public boolean queryConvert(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal)
      Queries an element 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.
    • queryDuration

      public boolean queryDuration(Format format, @Nullable Out<Long> duration)

      Queries an element (usually top-level pipeline or playbin element) for the total stream duration in nanoseconds. This query will only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.

      If the duration changes for some reason, you will get a DURATION_CHANGED message on the pipeline bus, in which case you should re-query the duration using this function.

      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 an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds. This will be a value between 0 and the stream duration (if the stream duration is known). This query will usually only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.

      If one repeatedly calls this function one can also create a query and reuse it in gst_element_query().

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

      public void releaseRequestPad(Pad pad)

      Makes the element free the previously requested pad as obtained with gst_element_request_pad().

      This does not unref the pad. If the pad was created by using gst_element_request_pad(), gst_element_release_request_pad() needs to be followed by gst_object_unref() to free the pad.

      MT safe.

      Parameters:
      pad - the GstPad to release.
    • removePad

      public boolean removePad(Pad pad)

      Removes pad from element. pad will be destroyed if it has not been referenced elsewhere using gst_object_unparent().

      This function is used by plugin developers and should not be used by applications. Pads that were dynamically requested from elements with gst_element_request_pad() should be released with the gst_element_release_request_pad() function instead.

      Pads are not automatically deactivated so elements should perform the needed steps to deactivate the pad in case this pad is removed in the PAUSED or PLAYING state. See gst_pad_set_active() for more information about deactivating pads.

      The pad and the element should be unlocked when calling this function.

      This function will emit the GstElement::pad-removed signal on the element.

      Parameters:
      pad - the GstPad to remove from the element.
      Returns:

      true if the pad could be removed. Can return false if the pad does not belong to the provided element.

      MT safe.

    • removePropertyNotifyWatch

      public void removePropertyNotifyWatch(int watchId)
    • requestPad

      public @Nullable Pad requestPad(PadTemplate templ, @Nullable String name, @Nullable Caps caps)

      Retrieves a request pad from the element according to the provided template. Pad templates can be looked up using gst_element_factory_get_static_pad_templates().

      The pad should be released with gst_element_release_request_pad().

      Parameters:
      templ - a GstPadTemplate of which we want a pad of.
      name - the name of the request GstPad to retrieve. Can be null.
      caps - the caps of the pad we want to request. Can be null.
      Returns:
      requested GstPad if found, otherwise null. Release after usage.
    • requestPadSimple

      public @Nullable Pad requestPadSimple(String name)

      Retrieves a pad from the element by name (e.g. "src_\d"). This version only retrieves request pads. The pad should be released with gst_element_release_request_pad().

      This method is slower than manually getting the pad template and calling gst_element_request_pad() if the pads should have a specific name (e.g. name is "src_1" instead of "src_\u").

      Note that this function was introduced in GStreamer 1.20 in order to provide a better name to gst_element_get_request_pad(). Prior to 1.20, users should use gst_element_get_request_pad() which provides the same functionality.

      Parameters:
      name - the name of the request GstPad to retrieve.
      Returns:
      requested GstPad if found, otherwise null. Release after usage.
      Since:
      1.20
    • seek

      public boolean seek(double rate, Format format, Set<SeekFlags> flags, SeekType startType, long start, SeekType stopType, long stop)

      Sends a seek event to an element. See gst_event_new_seek() for the details of the parameters. The seek event is sent to the element using gst_element_send_event().

      MT safe.

      Parameters:
      rate - The new playback rate
      format - The format of the seek values
      flags - The optional seek flags.
      startType - The type and flags for the new start position
      start - The value of the new start position
      stopType - The type and flags for the new stop position
      stop - The value of the new stop position
      Returns:
      true if the event was handled. Flushing seeks will trigger a preroll, which will emit MessageType.ASYNC_DONE.
    • seek

      public boolean seek(double rate, Format format, SeekFlags flags, SeekType startType, long start, SeekType stopType, long stop)

      Sends a seek event to an element. See gst_event_new_seek() for the details of the parameters. The seek event is sent to the element using gst_element_send_event().

      MT safe.

      Parameters:
      rate - The new playback rate
      format - The format of the seek values
      flags - The optional seek flags.
      startType - The type and flags for the new start position
      start - The value of the new start position
      stopType - The type and flags for the new stop position
      stop - The value of the new stop position
      Returns:
      true if the event was handled. Flushing seeks will trigger a preroll, which will emit MessageType.ASYNC_DONE.
    • seekSimple

      public boolean seekSimple(Format format, Set<SeekFlags> seekFlags, long seekPos)

      Simple API to perform a seek on the given element, meaning it just seeks to the given position relative to the start of the stream. For more complex operations like segment seeks (e.g. for looping) or changing the playback rate or seeking relative to the last configured playback segment you should use gst_element_seek().

      In a completely prerolled PAUSED or PLAYING pipeline, seeking is always guaranteed to return true on a seekable media type or false when the media type is certainly not seekable (such as a live stream).

      Some elements allow for seeking in the READY state, in this case they will store the seek event and execute it when they are put to PAUSED. If the element supports seek in READY, it will always return true when it receives the event in the READY state.

      Parameters:
      format - a GstFormat to execute the seek in, such as GST_FORMAT_TIME
      seekFlags - seek options; playback applications will usually want to use GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here
      seekPos - position to seek to (relative to the start); if you are doing a seek in GST_FORMAT_TIME this value is in nanoseconds - multiply with GST_SECOND to convert seconds to nanoseconds or with GST_MSECOND to convert milliseconds to nanoseconds.
      Returns:
      true if the seek operation succeeded. Flushing seeks will trigger a preroll, which will emit MessageType.ASYNC_DONE.
    • seekSimple

      public boolean seekSimple(Format format, SeekFlags seekFlags, long seekPos)

      Simple API to perform a seek on the given element, meaning it just seeks to the given position relative to the start of the stream. For more complex operations like segment seeks (e.g. for looping) or changing the playback rate or seeking relative to the last configured playback segment you should use gst_element_seek().

      In a completely prerolled PAUSED or PLAYING pipeline, seeking is always guaranteed to return true on a seekable media type or false when the media type is certainly not seekable (such as a live stream).

      Some elements allow for seeking in the READY state, in this case they will store the seek event and execute it when they are put to PAUSED. If the element supports seek in READY, it will always return true when it receives the event in the READY state.

      Parameters:
      format - a GstFormat to execute the seek in, such as GST_FORMAT_TIME
      seekFlags - seek options; playback applications will usually want to use GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here
      seekPos - position to seek to (relative to the start); if you are doing a seek in GST_FORMAT_TIME this value is in nanoseconds - multiply with GST_SECOND to convert seconds to nanoseconds or with GST_MSECOND to convert milliseconds to nanoseconds.
      Returns:
      true if the seek operation succeeded. Flushing seeks will trigger a preroll, which will emit MessageType.ASYNC_DONE.
    • sendEvent

      public boolean sendEvent(Event event)

      Sends an event to an element. If the element doesn't implement an event handler, the event will be pushed on a random linked sink pad for downstream events or a random linked source pad for upstream events.

      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.

      MT safe.

      Parameters:
      event - the GstEvent to send to the element.
      Returns:
      true if the event was handled. Events that trigger a preroll (such as flushing seeks and steps) will emit MessageType.ASYNC_DONE.
    • setBaseTime

      public void setBaseTime(ClockTime time)

      Set the base time of an element. See gst_element_get_base_time().

      MT safe.

      Parameters:
      time - the base time to set.
    • setBus

      public void setBus(@Nullable Bus bus)

      Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you're testing elements.

      MT safe.

      Parameters:
      bus - the GstBus to set.
    • setClock

      public boolean setClock(@Nullable Clock clock)
      Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.
      Parameters:
      clock - the GstClock to set for the element.
      Returns:

      true if the element accepted the clock. An element can refuse a clock when it, for example, is not able to slave its internal clock to the clock or when it requires a specific clock to operate.

      MT safe.

    • setContext

      public void setContext(Context context)

      Sets the context of the element. Increases the refcount of the context.

      MT safe.

      Parameters:
      context - the GstContext to set.
    • setLockedState

      public boolean setLockedState(boolean lockedState)

      Locks the state of an element, so state changes of the parent don't affect this element anymore.

      Note that this is racy if the state lock of the parent bin is not taken. The parent bin might've just checked the flag in another thread and as the next step proceed to change the child element's state.

      MT safe.

      Parameters:
      lockedState - true to lock the element's state
      Returns:
      true if the state was changed, false if bad parameters were given or the elements state-locking needed no change.
    • setStartTime

      public void setStartTime(ClockTime time)

      Set the start time of an element. The start time of the element is the running time of the element when it last went to the PAUSED state. In READY or after a flushing seek, it is set to 0.

      Toplevel elements like GstPipeline will manage the start_time and base_time on its children. Setting the start_time to GST_CLOCK_TIME_NONE on such a toplevel element will disable the distribution of the base_time to the children and can be useful if the application manages the base_time itself, for example if you want to synchronize capture from multiple pipelines, and you can also ensure that the pipelines have the same clock.

      MT safe.

      Parameters:
      time - the base time to set.
    • setState

      public StateChangeReturn setState(State state)

      Sets the state of the element. This function will try to set the requested state by going through all the intermediary states and calling the class's state change function for each.

      This function can return GST_STATE_CHANGE_ASYNC, in which case the element will perform the remainder of the state change asynchronously in another thread. An application can use gst_element_get_state() to wait for the completion of the state change or it can wait for a MessageType.ASYNC_DONE or MessageType.STATE_CHANGED on the bus.

      State changes to State.READY or State.NULL never return GST_STATE_CHANGE_ASYNC.

      Parameters:
      state - the element's new GstState.
      Returns:

      Result of the state change using GstStateChangeReturn.

      MT safe.

    • syncStateWithParent

      public boolean syncStateWithParent()
      Tries to change the state of the element to the same as its parent. If this function returns false, the state of element is undefined.
      Returns:

      true, if the element's state could be synced to the parent's state.

      MT safe.

    • unlink

      public void unlink(Element dest)

      Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked.

      If the link has been made using gst_element_link(), it could have created an requestpad, which has to be released using gst_element_release_request_pad().

      Parameters:
      dest - the sink GstElement to unlink.
    • unlinkMany

      public void unlinkMany(Element element2, Object... varargs)
      Unlinks a series of elements. Uses gst_element_unlink().
      Parameters:
      element2 - the second GstElement in the link chain.
      varargs - the null-terminated list of elements to unlink in order.
    • unlinkPads

      public void unlinkPads(String srcpadname, Element dest, String destpadname)

      Unlinks the two named pads of the source and destination elements.

      This is a convenience function for gst_pad_unlink().

      Parameters:
      srcpadname - the name of the GstPad in source element.
      dest - a GstElement containing the destination pad.
      destpadname - the name of the GstPad in destination element.
    • padAdded

      protected void padAdded(Pad pad)
    • padRemoved

      protected void padRemoved(Pad pad)
    • releasePad

      protected void releasePad(Pad pad)
      called when a request pad is to be released
    • stateChanged

      protected void stateChanged(State oldstate, State newstate, State pending)
      called immediately after a new state was set.
    • onNoMorePads

      This signals that the element will not generate more dynamic pads. Note that this signal will usually be emitted from the context of the streaming thread.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitNoMorePads

      public void emitNoMorePads()
      Emits the "no-more-pads" signal. See onNoMorePads(Element.NoMorePadsCallback).
    • onPadAdded

      a new GstPad has been added to the element. Note that this signal will usually be emitted from the context of the streaming thread. Also keep in mind that if you add new elements to the pipeline in the signal handler you will need to set them to the desired target state with gst_element_set_state() or gst_element_sync_state_with_parent().
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitPadAdded

      public void emitPadAdded(@Nullable Pad newPad)
      Emits the "pad-added" signal. See onPadAdded(Element.PadAddedCallback).
    • onPadRemoved

      a GstPad has been removed from the element
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitPadRemoved

      public void emitPadRemoved(@Nullable Pad oldPad)
      Emits the "pad-removed" signal. See onPadRemoved(Element.PadRemovedCallback).