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
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classElement.Builder<B extends Element.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe Element$Impl type represents a native instance of the abstract Element class.static classGStreamer element class.static interfaceFunctional interface declaration of theNoMorePadsCallbackcallback.static interfaceFunctional interface declaration of thePadAddedCallbackcallback.static interfaceFunctional interface declaration of thePadRemovedCallbackcallback.Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.Object$Impl, GstObject.ObjectClassNested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback -
Constructor Summary
ConstructorsConstructorDescriptionElement()Creates a new Element.Element(MemorySegment address) Create a Element proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidAbort the state change of the element.booleanAdds a pad (link point) toelement.pad'sparent will be set toelement;see gst_object_set_parent() for refcounting information.intaddPropertyDeepNotifyWatch(@Nullable String propertyName, boolean includeValue) intaddPropertyNotifyWatch(@Nullable String propertyName, boolean includeValue) protected ElementasParent()Returns this instance as if it were its parent type.voidcallAsync(@Nullable ElementCallAsyncFunc func) Callsfuncfrom another thread and passesuserDatato it.changeState(StateChange transition) Performtransitiononelement.Commit the state change of the element and proceed to the next pending state if any.voidCreates a pad for each pad template that is always available.decorateStreamId(String streamId) Creates a stream-id for this Element by combining the upstream information with thestreamId.decorateStreamIdPrintf(String format, Object... varargs) Creates a stream-id for this Element by combining the upstream information with theformat.voidEmits the "no-more-pads" signal.voidemitPadAdded(@Nullable Pad newPad) Emits the "pad-added" signal.voidemitPadRemoved(@Nullable Pad oldPad) Emits the "pad-removed" signal.booleanforeachPad(@Nullable ElementForeachPadFunc func) CallfuncwithuserDatafor each ofelement'spads.booleanforeachSinkPad(@Nullable ElementForeachPadFunc func) CallfuncwithuserDatafor each ofelement'ssink pads.booleanforeachSrcPad(@Nullable ElementForeachPadFunc func) CallfuncwithuserDatafor each ofelement'ssource pads.Returns the base time of the element.@Nullable BusgetBus()Returns the bus of the element.@Nullable ClockgetClock()Gets the currently configured clock of the element.@Nullable PadgetCompatiblePad(Pad pad, @Nullable Caps caps) Looks for an unlinked pad to which the given pad can link.@Nullable PadTemplategetCompatiblePadTemplate(PadTemplate compattempl) Retrieves a pad template from this Element that is compatible withcompattempl.Pads from compatible templates can be linked together.@Nullable ContextgetContext(String contextType) Gets the context withcontextTypeset on the element or NULL.Gets the contexts set on the element.@Nullable ContextgetContextUnlocked(String contextType) Gets the context withcontextTypeset on the element or NULL.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 running time of the element.@Nullable ElementFactoryRetrieves the factory that was used to create this element.static MemoryLayoutThe memory layout of the native struct.getMetadata(String key) Get metadata withkeyinklass.@Nullable PadTemplategetPadTemplate(String name) Retrieves a padtemplate from this Element with the given name.Retrieves a list of the pad templates associated withelement.The list must not be modified by the calling code.@Nullable PadgetRequestPad(String name) Deprecated.Prefer using gst_element_request_pad_simple() which provides the exact same functionality.Returns the start time of the element.Gets the state of the element.@Nullable PadgetStaticPad(String name) Retrieves a pad from this Element by name.static @Nullable TypegetType()Get the GType of the Element classbooleanChecks if the state of an element is locked.Retrieves an iterator ofelement'spads.Retrieves an iterator ofelement'ssink pads.Retrieves an iterator ofelement'ssource pads.booleanLinks this Element todest.The link must be from source to destination; the other direction will not be tried.booleanlinkFiltered(Element dest, @Nullable Caps filter) Links this Element todestusing the given caps as filtercaps.booleanChain together a series of elements.booleanLinks the two named pads of the source and destination elements.booleanlinkPadsFiltered(@Nullable String srcpadname, Element dest, @Nullable String destpadname, @Nullable Caps filter) Links the two named pads of the source and destination elements.booleanlinkPadsFull(@Nullable String srcpadname, Element dest, @Nullable String destpadname, Set<PadLinkCheck> flags) Links the two named pads of the source and destination elements.booleanlinkPadsFull(@Nullable String srcpadname, Element dest, @Nullable String destpadname, PadLinkCheck... flags) Links the two named pads of the source and destination elements.voidBrings the element to the lost state.static ElementmakeFromUri(URIType type, String uri, @Nullable String elementname) Creates an element for handling the given URI.voidmessageFull(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.voidmessageFull(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.voidmessageFullWithDetails(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.voidmessageFullWithDetails(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.voidUse this function to signal that the element does not expect any more pads to show up in the current pipeline.onNoMorePads(Element.NoMorePadsCallback handler) This signals that the element will not generate more dynamic pads.onPadAdded(Element.PadAddedCallback handler) a newGstPadhas been added to the element.onPadRemoved(Element.PadRemovedCallback handler) aGstPadhas been removed from the elementprotected voidprotected voidpadRemoved(Pad pad) booleanpostMessage(Message message) Post a message on the element'sGstBus.@Nullable ClockGet the clock provided by the given element.booleanPerforms a query on the given element.booleanqueryConvert(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal) Queries an element to convertsrcValinsrcFormattodestFormat.booleanqueryDuration(Format format, @Nullable Out<Long> duration) Queries an element (usually top-level pipeline or playbin element) for the total stream duration in nanoseconds.booleanqueryPosition(Format format, @Nullable Out<Long> cur) Queries an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds.static booleanCreate a new elementfactory capable of instantiating objects of thetypeand add the factory toplugin.protected voidreleasePad(Pad pad) called when a request pad is to be releasedvoidreleaseRequestPad(Pad pad) Makes the element free the previously requested pad as obtained with gst_element_request_pad().booleanRemovespadfromelement.padwill be destroyed if it has not been referenced elsewhere using gst_object_unparent().voidremovePropertyNotifyWatch(int watchId) @Nullable PadrequestPad(PadTemplate templ, @Nullable String name, @Nullable Caps caps) Retrieves a request pad from the element according to the provided template.@Nullable PadrequestPadSimple(String name) Retrieves a pad from the element by name (e.g.booleanseek(double rate, Format format, Set<SeekFlags> flags, SeekType startType, long start, SeekType stopType, long stop) Sends a seek event to an element.booleanseek(double rate, Format format, SeekFlags flags, SeekType startType, long start, SeekType stopType, long stop) Sends a seek event to an element.booleanseekSimple(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.booleanseekSimple(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.booleanSends an event to an element.voidsetBaseTime(ClockTime time) Set the base time of an element.voidSets the bus of the element.booleanSets the clock for the element.voidsetContext(Context context) Sets the context of the element.booleansetLockedState(boolean lockedState) Locks the state of an element, so state changes of the parent don't affect this element anymore.voidsetStartTime(ClockTime time) Set the start time of an element.Sets the state of the element.protected voidstateChanged(State oldstate, State newstate, State pending) called immediately after a new state was set.static StringstateChangeReturnGetName(StateChangeReturn stateRet) Gets a string representing the given state change result.static StringstateGetName(State state) Gets a string representing the given state.booleanTries to change the state of the element to the same as its parent.static voidtypeSetSkipDocumentation(Type type) Markstypeas "documentation should be skipped".voidUnlinks all source pads of the source element with all sink pads of the sink element to which they are linked.voidunlinkMany(Element element2, Object... varargs) Unlinks a series of elements.voidunlinkPads(String srcpadname, Element dest, String destpadname) Unlinks the two named pads of the source and destination elements.Methods inherited from class org.freedesktop.gstreamer.gst.GstObject
addControlBinding, checkUniqueness, deepNotify, defaultDeepNotify, defaultError, emitDeepNotify, getControlBinding, getControlRate, getGValueArray, getName, getParent, getPathString, getValue, getValueArray, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, onDeepNotify, ref, refSink, removeControlBinding, replace, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setName, setParent, suggestNextSync, syncValues, unparent, unrefMethods inherited from class org.gnome.gobject.InitiallyUnowned
builderMethods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Element
Create a Element proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Element
public Element()Creates a new Element.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
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 sinkuri- URI to create an element forelementname- Name of created element, can benull.- Returns:
- a new element or
nullif none could be created - Throws:
GErrorException- seeGError
-
register
Create a new elementfactory capable of instantiating objects of thetypeand add the factory toplugin.- Parameters:
plugin-GstPluginto register the element with, ornullfor a static element.name- name of elements of this typerank- rank of element (higher rank means more importance when autoplugging)type- GType of element to register- Returns:
true, if the registering succeeded,falseon error
-
stateChangeReturnGetName
Gets a string representing the given state change result.- Parameters:
stateRet- aGstStateChangeReturnto get the name of.- Returns:
- a string with the name of the state result.
-
stateGetName
-
typeSetSkipDocumentation
Markstypeas "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- aGTypeof 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
Adds a pad (link point) toelement.pad'sparent will be set toelement;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- theGstPadto add to the element.- Returns:
trueif 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
-
addPropertyNotifyWatch
-
callAsync
Callsfuncfrom another thread and passesuserDatato 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
Performtransitiononelement.This function must be called with STATE_LOCK held and is mainly used internally.
- Parameters:
transition- the requested transition- Returns:
- the
GstStateChangeReturnof the state transition.
-
continueState
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 returnedStateChangeReturn.SUCCESSfrom 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 ofGstElement. -
decorateStreamId
Creates a stream-id for this Element by combining the upstream information with thestreamId.This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending
streamIdto it. If the element has no sinkpad it will generate an upstream stream-id by doing an URI query on the element and in the worst case just uses a random number. Source elements that don't implement the URI handler interface should ideally generate a unique, deterministic stream-id manually instead.Since stream IDs are sorted alphabetically, any numbers in the stream ID should be printed with a fixed number of characters, preceded by 0's, such as by using the format \\
03uinstead of \\u.- Parameters:
streamId- The stream-id- Returns:
- A stream-id for
element. - Since:
- 1.24
-
decorateStreamIdPrintf
Creates a stream-id for this Element by combining the upstream information with theformat.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 \\
03uinstead of \\u.- Parameters:
format- The stream-id- Returns:
- A stream-id for
element. - Since:
- 1.24
-
foreachPad
CallfuncwithuserDatafor each ofelement'spads.funcwill be called exactly once for each pad that exists at the time of this call, unless one of the calls tofuncreturnsfalsein 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:
falseif this Element had no pads or if one of the calls tofuncreturnedfalse.- Since:
- 1.14
-
foreachSinkPad
CallfuncwithuserDatafor each ofelement'ssink pads.funcwill be called exactly once for each sink pad that exists at the time of this call, unless one of the calls tofuncreturnsfalsein 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:
falseif this Element had no sink pads or if one of the calls tofuncreturnedfalse.- Since:
- 1.14
-
foreachSrcPad
CallfuncwithuserDatafor each ofelement'ssource pads.funcwill be called exactly once for each source pad that exists at the time of this call, unless one of the calls tofuncreturnsfalsein 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:
falseif this Element had no source pads or if one of the calls tofuncreturnedfalse.- Since:
- 1.14
-
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
Returns the bus of the element. Note that only aGstPipelinewill provide a bus for the application.- Returns:
- the element's
GstBus. unref after usage.MT safe.
-
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
GstClockof the element. unref after usage.MT safe.
-
getCompatiblePad
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- theGstPadto find a compatible one for.caps- theGstCapsto use as a filter.- Returns:
- the
GstPadto which a link can be made, ornullif one cannot be found. gst_object_unref() after usage.
-
getCompatiblePadTemplate
Retrieves a pad template from this Element that is compatible withcompattempl.Pads from compatible templates can be linked together.- Parameters:
compattempl- theGstPadTemplateto find a compatible template for- Returns:
- a compatible
GstPadTemplate, ornullif none was found. No unreferencing is necessary.
-
getContext
-
getContextUnlocked
-
getContexts
-
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
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
Retrieves the factory that was used to create this element.- Returns:
- the
GstElementFactoryused for creating this element ornullif element has not been registered (static element). no refcounting is needed.
-
getMetadata
-
getPadTemplate
Retrieves a padtemplate from this Element with the given name.- Parameters:
name- the name of theGstPadTemplateto get.- Returns:
- the
GstPadTemplatewith the given name, ornullif none was found. No unreferencing is necessary. - Since:
- 1.14
-
getPadTemplateList
Retrieves a list of the pad templates associated withelement.The list must not be modified by the calling code.- Returns:
- the
GListof pad templates. - Since:
- 1.14
-
getRequestPad
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 requestGstPadto retrieve.- Returns:
- requested
GstPadif found, otherwisenull. Release after usage.
-
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.SUCCESSorStateChangeReturn.FAILURErespectively.For elements that did not return
StateChangeReturn.ASYNC, this function returns the current and pending state immediately.This function returns
StateChangeReturn.NO_PREROLLif the element successfully changed its state but is not able to provide data yet. This mostly happens for live sources that only produce data inState.PLAYING. While the state change return is equivalent toStateChangeReturn.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 toGstStateto hold the state. Can benull.pending- a pointer toGstStateto hold the pending state. Can benull.timeout- aGstClockTimeto specify the timeout for an async state change orGST_CLOCK_TIME_NONEfor infinite timeout.- Returns:
StateChangeReturn.SUCCESSif the element has no more pending state and the last state change succeeded,StateChangeReturn.ASYNCif the element is still performing a state change orStateChangeReturn.FAILUREif the last state change failed.MT safe.
-
getStaticPad
Retrieves a pad from this Element by name. This version only retrieves already-existing (i.e. 'static') pads.- Parameters:
name- the name of the staticGstPadto retrieve.- Returns:
- the requested
GstPadif found, otherwisenull. 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 fromGST_STATE_NULL.MT safe.
- Returns:
true, if the element's state is locked.
-
iteratePads
Retrieves an iterator ofelement'spads. 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
GstIteratorofGstPad.MT safe.
-
iterateSinkPads
Retrieves an iterator ofelement'ssink pads.The order of pads returned by the iterator will be the order in which the pads were added to the element.
- Returns:
- the
GstIteratorofGstPad.MT safe.
-
iterateSrcPads
Retrieves an iterator ofelement'ssource pads.The order of pads returned by the iterator will be the order in which the pads were added to the element.
- Returns:
- the
GstIteratorofGstPad.MT safe.
-
link
Links this Element todest.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- theGstElementcontaining the destination pad.- Returns:
trueif the elements could be linked,falseotherwise.
-
linkFiltered
Links this Element todestusing 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- theGstElementcontaining the destination pad.filter- theGstCapsto filter the link, ornullfor no filter.- Returns:
trueif the pads could be linked,falseotherwise.
-
linkMany
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 secondGstElementin the link chain.varargs- thenull-terminated list of elements to link in order.- Returns:
trueon success,falseotherwise.
-
linkPads
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 theGstPadin source element ornullfor any pad.dest- theGstElementcontaining the destination pad.destpadname- the name of theGstPadin destination element, ornullfor any pad.- Returns:
trueif the pads could be linked,falseotherwise.
-
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. Ifcapsis notnull, makes sure that the caps of the link is a subset ofcaps.- Parameters:
srcpadname- the name of theGstPadin source element ornullfor any pad.dest- theGstElementcontaining the destination pad.destpadname- the name of theGstPadin destination element ornullfor any pad.filter- theGstCapsto filter the link, ornullfor no filter.- Returns:
trueif the pads could be linked,falseotherwise.
-
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.DEFAULTis 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 theGstPadin source element ornullfor any pad.dest- theGstElementcontaining the destination pad.destpadname- the name of theGstPadin destination element, ornullfor any pad.flags- theGstPadLinkCheckto be performed when linking pads.- Returns:
trueif the pads could be linked,falseotherwise.
-
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.DEFAULTis 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 theGstPadin source element ornullfor any pad.dest- theGstElementcontaining the destination pad.destpadname- the name of theGstPadin destination element, ornullfor any pad.flags- theGstPadLinkCheckto be performed when linking pads.- Returns:
trueif the pads could be linked,falseotherwise.
-
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 returnStateChangeReturn.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.PAUSEDorState.PLAYINGstate 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.typemust be ofGST_MESSAGE_ERROR,GST_MESSAGE_WARNINGorGST_MESSAGE_INFO.MT safe.
- Parameters:
type- theGstMessageTypedomain- the GStreamer GError domain this message belongs tocode- the GError code belonging to the domaintext- an allocated text string to be used as a replacement for the default message connected to code, ornulldebug- an allocated debug message to be used as a replacement for the default debugging information, ornullfile- the source code file where the error was generatedfunction- the source code function where the error was generatedline- 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.typemust be ofGST_MESSAGE_ERROR,GST_MESSAGE_WARNINGorGST_MESSAGE_INFO.MT safe.
- Parameters:
type- theGstMessageTypedomain- the GStreamer GError domain this message belongs tocode- the GError code belonging to the domaintext- an allocated text string to be used as a replacement for the default message connected to code, ornulldebug- an allocated debug message to be used as a replacement for the default debugging information, ornullfile- the source code file where the error was generatedfunction- the source code function where the error was generatedline- 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.typemust be ofGST_MESSAGE_ERROR,GST_MESSAGE_WARNINGorGST_MESSAGE_INFO.- Parameters:
type- theGstMessageTypedomain- the GStreamer GError domain this message belongs tocode- the GError code belonging to the domaintext- an allocated text string to be used as a replacement for the default message connected to code, ornulldebug- an allocated debug message to be used as a replacement for the default debugging information, ornullfile- the source code file where the error was generatedfunction- the source code function where the error was generatedline- the source code line where the error was generatedstructure- 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.typemust be ofGST_MESSAGE_ERROR,GST_MESSAGE_WARNINGorGST_MESSAGE_INFO.- Parameters:
type- theGstMessageTypedomain- the GStreamer GError domain this message belongs tocode- the GError code belonging to the domaintext- an allocated text string to be used as a replacement for the default message connected to code, ornulldebug- an allocated debug message to be used as a replacement for the default debugging information, ornullfile- the source code file where the error was generatedfunction- the source code function where the error was generatedline- the source code line where the error was generatedstructure- 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 withGST_PAD_SOMETIMESpad 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
Post a message on the element'sGstBus. 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- aGstMessageto post- Returns:
trueif the message was successfully posted. The function returnsfalseif the element did not have a bus.MT safe.
-
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
nullif no clock could be provided. Unref after usage.MT safe.
-
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- theGstQuery.- Returns:
trueif the query could be performed.MT safe.
-
queryConvert
Queries an element to convertsrcValinsrcFormattodestFormat.- Parameters:
srcFormat- aGstFormatto convert from.srcVal- a value to convert.destFormat- theGstFormatto convert to.destVal- a pointer to the result.- Returns:
trueif the query could be performed.
-
queryDuration
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- theGstFormatrequestedduration- A location in which to store the total duration, ornull.- Returns:
trueif the query could be performed.
-
queryPosition
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- theGstFormatrequestedcur- a location in which to store the current position, ornull.- Returns:
trueif the query could be performed.
-
releaseRequestPad
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- theGstPadto release.
-
removePad
Removespadfromelement.padwill 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- theGstPadto remove from the element.- Returns:
trueif the pad could be removed. Can returnfalseif the pad does not belong to the provided element.MT safe.
-
removePropertyNotifyWatch
public void removePropertyNotifyWatch(int watchId) -
requestPad
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- aGstPadTemplateof which we want a pad of.name- the name of the requestGstPadto retrieve. Can benull.caps- the caps of the pad we want to request. Can benull.- Returns:
- requested
GstPadif found, otherwisenull. Release after usage.
-
requestPadSimple
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.
nameis "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 requestGstPadto retrieve.- Returns:
- requested
GstPadif found, otherwisenull. 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 rateformat- The format of the seek valuesflags- The optional seek flags.startType- The type and flags for the new start positionstart- The value of the new start positionstopType- The type and flags for the new stop positionstop- The value of the new stop position- Returns:
trueif the event was handled. Flushing seeks will trigger a preroll, which will emitMessageType.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 rateformat- The format of the seek valuesflags- The optional seek flags.startType- The type and flags for the new start positionstart- The value of the new start positionstopType- The type and flags for the new stop positionstop- The value of the new stop position- Returns:
trueif the event was handled. Flushing seeks will trigger a preroll, which will emitMessageType.ASYNC_DONE.
-
seekSimple
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
trueon a seekable media type orfalsewhen 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
truewhen it receives the event in the READY state.- Parameters:
format- aGstFormatto execute the seek in, such asGST_FORMAT_TIMEseekFlags- seek options; playback applications will usually want to use GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT hereseekPos- position to seek to (relative to the start); if you are doing a seek inGST_FORMAT_TIMEthis value is in nanoseconds - multiply withGST_SECONDto convert seconds to nanoseconds or withGST_MSECONDto convert milliseconds to nanoseconds.- Returns:
trueif the seek operation succeeded. Flushing seeks will trigger a preroll, which will emitMessageType.ASYNC_DONE.
-
seekSimple
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
trueon a seekable media type orfalsewhen 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
truewhen it receives the event in the READY state.- Parameters:
format- aGstFormatto execute the seek in, such asGST_FORMAT_TIMEseekFlags- seek options; playback applications will usually want to use GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT hereseekPos- position to seek to (relative to the start); if you are doing a seek inGST_FORMAT_TIMEthis value is in nanoseconds - multiply withGST_SECONDto convert seconds to nanoseconds or withGST_MSECONDto convert milliseconds to nanoseconds.- Returns:
trueif the seek operation succeeded. Flushing seeks will trigger a preroll, which will emitMessageType.ASYNC_DONE.
-
sendEvent
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- theGstEventto send to the element.- Returns:
trueif the event was handled. Events that trigger a preroll (such as flushing seeks and steps) will emitMessageType.ASYNC_DONE.
-
setBaseTime
Set the base time of an element. See gst_element_get_base_time().MT safe.
- Parameters:
time- the base time to set.
-
setBus
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- theGstBusto set.
-
setClock
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- theGstClockto set for the element.- Returns:
trueif the element accepted the clock. An element can refuse a clock when it, for example, is not able to slave its internal clock to theclockor when it requires a specific clock to operate.MT safe.
-
setContext
Sets the context of the element. Increases the refcount of the context.MT safe.
- Parameters:
context- theGstContextto 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-trueto lock the element's state- Returns:
trueif the state was changed,falseif bad parameters were given or the elements state-locking needed no change.
-
setStartTime
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
GstPipelinewill manage the start_time and base_time on its children. Setting the start_time toGST_CLOCK_TIME_NONEon 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
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 aMessageType.ASYNC_DONEorMessageType.STATE_CHANGEDon the bus.State changes to
State.READYorState.NULLnever returnGST_STATE_CHANGE_ASYNC.- Parameters:
state- the element's newGstState.- 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 returnsfalse, the state of element is undefined.- Returns:
true, if the element's state could be synced to the parent's state.MT safe.
-
unlink
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 sinkGstElementto unlink.
-
unlinkMany
-
unlinkPads
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 theGstPadin source element.dest- aGstElementcontaining the destination pad.destpadname- the name of theGstPadin destination element.
-
padAdded
-
padRemoved
-
releasePad
called when a request pad is to be released -
stateChanged
-
onNoMorePads
public SignalConnection<Element.NoMorePadsCallback> onNoMorePads(Element.NoMorePadsCallback handler) 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. SeeonNoMorePads(org.freedesktop.gstreamer.gst.Element.NoMorePadsCallback). -
onPadAdded
a newGstPadhas 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
Emits the "pad-added" signal. SeeonPadAdded(org.freedesktop.gstreamer.gst.Element.PadAddedCallback). -
onPadRemoved
public SignalConnection<Element.PadRemovedCallback> onPadRemoved(Element.PadRemovedCallback handler) aGstPadhas 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
Emits the "pad-removed" signal. SeeonPadRemoved(org.freedesktop.gstreamer.gst.Element.PadRemovedCallback).
-