Class Element
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Aggregator
,AudioDecoder
,AudioEncoder
,BaseParse
,BaseSink
,BaseSrc
,BaseTransform
,Bin
,Element.ElementImpl
,TagSetter.TagSetterImpl
,TocSetter.TocSetterImpl
,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
Modifier and TypeClassDescriptionstatic class
Element.Builder<B extends Element.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
GStreamer element class.static class
The ElementImpl type represents a native instance of the abstract Element class.static interface
Functional interface declaration of theNoMorePadsCallback
callback.static interface
Functional interface declaration of thePadAddedCallback
callback.static interface
Functional interface declaration of thePadRemovedCallback
callback.Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.ObjectClass, GstObject.ObjectImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback
-
Constructor Summary
ConstructorDescriptionElement
(MemorySegment address) Create a Element proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Abort the state change of the element.boolean
Adds a pad (link point) to this Element.int
addPropertyDeepNotifyWatch
(@Nullable String propertyName, boolean includeValue) int
addPropertyNotifyWatch
(@Nullable String propertyName, boolean includeValue) protected Element
asParent()
Returns this instance as if it were its parent type.static Element.Builder
<? extends Element.Builder> builder()
AElement.Builder
object constructs aElement
with the specified properties.void
Callsfunc
from another thread and passesuserData
to it.changeState
(StateChange transition) Performtransition
on this Element.Commit the state change of the element and proceed to the next pending state if any.void
Creates 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
.void
Emits the "no-more-pads" signal.void
emitPadAdded
(Pad newPad) Emits the "pad-added" signal.void
emitPadRemoved
(Pad oldPad) Emits the "pad-removed" signal.boolean
Callfunc
withuserData
for each of this Element's pads.boolean
Callfunc
withuserData
for each of this Element's sink pads.boolean
Callfunc
withuserData
for each of this Element's source pads.Returns the base time of the element.getBus()
Returns the bus of the element.getClock()
Gets the currently configured clock of the element.getCompatiblePad
(Pad pad, @Nullable Caps caps) Looks for an unlinked pad to which the given pad can link.getCompatiblePadTemplate
(PadTemplate compattempl) Retrieves a pad template from this Element that is compatible withcompattempl
.getContext
(String contextType) Gets the context withcontextType
set on the element or NULL.Gets the contexts set on the element.getContextUnlocked
(String contextType) Gets the context withcontextType
set 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.Retrieves the factory that was used to create this element.static MemoryLayout
The memory layout of the native struct.getMetadata
(String key) Get metadata withkey
inklass
.getPadTemplate
(String name) Retrieves a padtemplate from this Element with the given name.Retrieves a list of the pad templates associated with this Element.getRequestPad
(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.getStaticPad
(String name) Retrieves a pad from this Element by name.static Type
getType()
Get the GType of the Element classboolean
Checks if the state of an element is locked.Retrieves an iterator of this Element's pads.Retrieves an iterator of this Element's sink pads.Retrieves an iterator of this Element's source pads.boolean
Links this Element todest
.boolean
linkFiltered
(Element dest, @Nullable Caps filter) Links this Element todest
using the given caps as filtercaps.boolean
Chain together a series of elements.boolean
Links the two named pads of the source and destination elements.boolean
linkPadsFiltered
(@Nullable String srcpadname, Element dest, @Nullable String destpadname, @Nullable Caps filter) Links the two named pads of the source and destination elements.boolean
linkPadsFull
(@Nullable String srcpadname, Element dest, @Nullable String destpadname, Set<PadLinkCheck> flags) Links the two named pads of the source and destination elements.boolean
linkPadsFull
(@Nullable String srcpadname, Element dest, @Nullable String destpadname, PadLinkCheck... flags) Links the two named pads of the source and destination elements.void
Brings the element to the lost state.static Element
makeFromUri
(URIType type, String uri, @Nullable String elementname) Creates an element for handling the given URI.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.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.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.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.void
Use 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 newGstPad
has been added to the element.onPadRemoved
(Element.PadRemovedCallback handler) aGstPad
has been removed from the elementprotected void
protected void
padRemoved
(Pad pad) boolean
postMessage
(Message message) Post a message on the element'sGstBus
.Get the clock provided by the given element.boolean
Performs a query on the given element.boolean
queryConvert
(Format srcFormat, long srcVal, Format destFormat, Out<Long> destVal) Queries an element to convertsrcVal
insrcFormat
todestFormat
.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.boolean
queryPosition
(Format format, @Nullable Out<Long> cur) Queries an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds.static boolean
Create a new elementfactory capable of instantiating objects of thetype
and add the factory toplugin
.protected void
releasePad
(Pad pad) called when a request pad is to be releasedvoid
releaseRequestPad
(Pad pad) Makes the element free the previously requested pad as obtained with gst_element_request_pad().boolean
Removespad
from this Element.void
removePropertyNotifyWatch
(int watchId) requestPad
(PadTemplate templ, @Nullable String name, @Nullable Caps caps) Retrieves a request pad from the element according to the provided template.requestPadSimple
(String name) Retrieves a pad from the element by name (e.g.boolean
seek
(double rate, Format format, Set<SeekFlags> flags, SeekType startType, long start, SeekType stopType, long stop) Sends a seek event to an element.boolean
seek
(double rate, Format format, SeekFlags flags, SeekType startType, long start, SeekType stopType, long stop) Sends a seek event to an element.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.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.boolean
Sends an event to an element.void
setBaseTime
(ClockTime time) Set the base time of an element.void
Sets the bus of the element.boolean
Sets the clock for the element.void
setContext
(Context context) Sets the context of the element.boolean
setLockedState
(boolean lockedState) Locks the state of an element, so state changes of the parent don't affect this element anymore.void
setStartTime
(ClockTime time) Set the start time of an element.Sets the state of the element.protected void
stateChanged
(State oldstate, State newstate, State pending) called immediately after a new state was set.static String
stateChangeReturnGetName
(StateChangeReturn stateRet) Gets a string representing the given state change result.static String
stateGetName
(State state) Gets a string representing the given state.boolean
Tries to change the state of the element to the same as its parent.static void
typeSetSkipDocumentation
(Type type) Markstype
as "documentation should be skipped".void
Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked.void
unlinkMany
(Element element2, Object... varargs) Unlinks a series of elements.void
unlinkPads
(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, unref
Methods 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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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
-
-
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 Javasuper
keyword, 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 @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
null
if none could be created - Throws:
GErrorException
- seeGError
-
register
Create a new elementfactory capable of instantiating objects of thetype
and add the factory toplugin
.- Parameters:
plugin
-GstPlugin
to register the element with, ornull
for 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,false
on error
-
stateChangeReturnGetName
Gets a string representing the given state change result.- Parameters:
stateRet
- aGstStateChangeReturn
to get the name of.- Returns:
- a string with the name of the state result.
-
stateGetName
-
typeSetSkipDocumentation
Markstype
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
- aGType
of element
-
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) to this Element.pad
's parent will be set to this 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
- theGstPad
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 @Nullable String propertyName, boolean includeValue) -
addPropertyNotifyWatch
-
callAsync
Callsfunc
from another thread and passesuserData
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
-
changeState
Performtransition
on this 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
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.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 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
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 this Element.
-
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 \\
03u
instead of \\u
.- Parameters:
format
- The stream-id- Returns:
- A stream-id for this Element.
-
foreachPad
Callfunc
withuserData
for each of this 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 tofunc
returnsfalse
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 tofunc
returnedfalse
.
-
foreachSinkPad
Callfunc
withuserData
for each of this 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 tofunc
returnsfalse
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 tofunc
returnedfalse
.
-
foreachSrcPad
Callfunc
withuserData
for each of this 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 tofunc
returnsfalse
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 tofunc
returnedfalse
.
-
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 aGstPipeline
will 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
GstClock
of 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 this Element.
- Parameters:
pad
- theGstPad
to find a compatible one for.caps
- theGstCaps
to use as a filter.- Returns:
- the
GstPad
to which a link can be made, ornull
if 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
- theGstPadTemplate
to find a compatible template for- Returns:
- a compatible
GstPadTemplate
, ornull
if 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.
-
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.
-
getFactory
Retrieves the factory that was used to create this element.- Returns:
- the
GstElementFactory
used for creating this element ornull
if 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 theGstPadTemplate
to get.- Returns:
- the
GstPadTemplate
with the given name, ornull
if none was found. No unreferencing is necessary.
-
getPadTemplateList
Retrieves a list of the pad templates associated with this Element. The list must not be modified by the calling code.- Returns:
- the
GList
of pad templates.
-
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 requestGstPad
to retrieve.- Returns:
- requested
GstPad
if 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 @Nullable Out<State> state, @Nullable @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
orStateChangeReturn.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 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 toGstState
to hold the state. Can benull
.pending
- a pointer toGstState
to hold the pending state. Can benull
.timeout
- aGstClockTime
to specify the timeout for an async state change orGST_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 orStateChangeReturn.FAILURE
if the last state change failed.MT safe.
-
getStaticPad
-
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 of this 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
ofGstPad
.MT safe.
-
iterateSinkPads
Retrieves an iterator of this 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
ofGstPad
.MT safe.
-
iterateSrcPads
Retrieves an iterator of this 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
ofGstPad
.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
- theGstElement
containing the destination pad.- Returns:
true
if the elements could be linked,false
otherwise.
-
linkFiltered
Links this Element todest
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
- theGstElement
containing the destination pad.filter
- theGstCaps
to filter the link, ornull
for no filter.- Returns:
true
if the pads could be linked,false
otherwise.
-
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 secondGstElement
in the link chain.varargs
- thenull
-terminated list of elements to link in order.- Returns:
true
on success,false
otherwise.
-
linkPads
public boolean linkPads(@Nullable @Nullable String srcpadname, Element dest, @Nullable @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 theGstPad
in source element ornull
for any pad.dest
- theGstElement
containing the destination pad.destpadname
- the name of theGstPad
in destination element, ornull
for any pad.- Returns:
true
if the pads could be linked,false
otherwise.
-
linkPadsFiltered
public boolean linkPadsFiltered(@Nullable @Nullable String srcpadname, Element dest, @Nullable @Nullable String destpadname, @Nullable @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. Ifcaps
is notnull
, makes sure that the caps of the link is a subset ofcaps
.- Parameters:
srcpadname
- the name of theGstPad
in source element ornull
for any pad.dest
- theGstElement
containing the destination pad.destpadname
- the name of theGstPad
in destination element ornull
for any pad.filter
- theGstCaps
to filter the link, ornull
for no filter.- Returns:
true
if the pads could be linked,false
otherwise.
-
linkPadsFull
public boolean linkPadsFull(@Nullable @Nullable String srcpadname, Element dest, @Nullable @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 theGstPad
in source element ornull
for any pad.dest
- theGstElement
containing the destination pad.destpadname
- the name of theGstPad
in destination element, ornull
for any pad.flags
- theGstPadLinkCheck
to be performed when linking pads.- Returns:
true
if the pads could be linked,false
otherwise.
-
linkPadsFull
public boolean linkPadsFull(@Nullable @Nullable String srcpadname, Element dest, @Nullable @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 theGstPad
in source element ornull
for any pad.dest
- theGstElement
containing the destination pad.destpadname
- the name of theGstPad
in destination element, ornull
for any pad.flags
- theGstPadLinkCheck
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 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.PAUSED
orState.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 @Nullable String text, @Nullable @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 ofGST_MESSAGE_ERROR
,GST_MESSAGE_WARNING
orGST_MESSAGE_INFO
.MT safe.
- Parameters:
type
- theGstMessageType
domain
- 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, ornull
debug
- an allocated debug message to be used as a replacement for the default debugging information, ornull
file
- 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 @Nullable String text, @Nullable @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 ofGST_MESSAGE_ERROR
,GST_MESSAGE_WARNING
orGST_MESSAGE_INFO
.MT safe.
- Parameters:
type
- theGstMessageType
domain
- 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, ornull
debug
- an allocated debug message to be used as a replacement for the default debugging information, ornull
file
- 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 @Nullable String text, @Nullable @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 ofGST_MESSAGE_ERROR
,GST_MESSAGE_WARNING
orGST_MESSAGE_INFO
.- Parameters:
type
- theGstMessageType
domain
- 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, ornull
debug
- an allocated debug message to be used as a replacement for the default debugging information, ornull
file
- 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
-
messageFullWithDetails
public void messageFullWithDetails(MessageType type, Quark domain, int code, @Nullable @Nullable String text, @Nullable @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 ofGST_MESSAGE_ERROR
,GST_MESSAGE_WARNING
orGST_MESSAGE_INFO
.- Parameters:
type
- theGstMessageType
domain
- 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, ornull
debug
- an allocated debug message to be used as a replacement for the default debugging information, ornull
file
- 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
-
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_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
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
- aGstMessage
to post- Returns:
true
if the message was successfully posted. The function returnsfalse
if 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
null
if 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:
true
if the query could be performed.MT safe.
-
queryConvert
Queries an element to convertsrcVal
insrcFormat
todestFormat
.- Parameters:
srcFormat
- aGstFormat
to convert from.srcVal
- a value to convert.destFormat
- theGstFormat
to convert to.destVal
- a pointer to the result.- Returns:
true
if 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
- theGstFormat
requestedduration
- A location in which to store the total duration, ornull
.- Returns:
true
if 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
- theGstFormat
requestedcur
- a location in which to store the current position, ornull
.- Returns:
true
if 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
- theGstPad
to release.
-
removePad
Removespad
from this 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
- theGstPad
to remove from the element.- Returns:
true
if the pad could be removed. Can returnfalse
if the pad does not belong to the provided element.MT safe.
-
removePropertyNotifyWatch
public void removePropertyNotifyWatch(int watchId) -
requestPad
public Pad requestPad(PadTemplate templ, @Nullable @Nullable String name, @Nullable @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
- aGstPadTemplate
of which we want a pad of.name
- the name of the requestGstPad
to retrieve. Can benull
.caps
- the caps of the pad we want to request. Can benull
.- Returns:
- requested
GstPad
if 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.
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 requestGstPad
to retrieve.- Returns:
- requested
GstPad
if found, otherwisenull
. Release after usage.
-
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:
true
if 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:
true
if 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
true
on a seekable media type orfalse
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
- aGstFormat
to execute the seek in, such asGST_FORMAT_TIME
seekFlags
- 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_TIME
this value is in nanoseconds - multiply withGST_SECOND
to convert seconds to nanoseconds or withGST_MSECOND
to convert milliseconds to nanoseconds.- Returns:
true
if 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
true
on a seekable media type orfalse
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
- aGstFormat
to execute the seek in, such asGST_FORMAT_TIME
seekFlags
- 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_TIME
this value is in nanoseconds - multiply withGST_SECOND
to convert seconds to nanoseconds or withGST_MSECOND
to convert milliseconds to nanoseconds.- Returns:
true
if 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
- theGstEvent
to send to the element.- Returns:
true
if 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
- theGstBus
to 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
- theGstClock
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 theclock
or 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
- theGstContext
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
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 toGST_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
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_DONE
orMessageType.STATE_CHANGED
on the bus.State changes to
State.READY
orState.NULL
never 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 sinkGstElement
to 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 theGstPad
in source element.dest
- aGstElement
containing the destination pad.destpadname
- the name of theGstPad
in 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 newGstPad
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
Emits the "pad-added" signal. SeeonPadAdded(org.freedesktop.gstreamer.gst.Element.PadAddedCallback)
. -
onPadRemoved
public SignalConnection<Element.PadRemovedCallback> onPadRemoved(Element.PadRemovedCallback handler) aGstPad
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
Emits the "pad-removed" signal. SeeonPadRemoved(org.freedesktop.gstreamer.gst.Element.PadRemovedCallback)
. -
builder
AElement.Builder
object constructs aElement
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withElement.Builder.build()
.
-