Gst.Element¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signals that the element will not generate more dynamic pads. |
|
a new |
|
a |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
base_time |
r |
the time of the clock right before the element is set to PLAYING. Subtracting base_time from the current clock time in the PLAYING state will yield the running_time against the clock. |
|
bus |
r |
the bus of the element. This bus is provided to the element by the parent element or the application. A |
|
clock |
r |
the clock of the element. This clock is usually provided to the element by the toplevel |
|
contexts |
r |
list of contexts |
|
current_state |
r |
the current state of an element |
|
last_return |
r |
the last return value of an element state change |
|
next_state |
r |
the next state of an element, can be |
|
numpads |
r |
number of pads of the element, includes both source and sink pads. |
|
numsinkpads |
r |
number of sink pads of the element. |
|
numsrcpads |
r |
number of source pads of the element. |
|
object |
r |
||
pads |
[ |
r |
list of pads |
pads_cookie |
r |
updated whenever the a pad is added or removed |
|
pending_state |
r |
the final state the element should go to, can be |
|
sinkpads |
[ |
r |
list of sink pads |
srcpads |
[ |
r |
list of source pads |
start_time |
r |
the running_time of the last PAUSED state |
|
state_cond |
r |
Used to signal completion of a state change |
|
state_cookie |
r |
Used to detect concurrent execution of |
|
state_lock |
r |
Used to serialize execution of |
|
target_state |
r |
the target state of an element as set by the application |
Class Details¶
- class Gst.Element(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
Gst.Element
is the abstract base class needed to construct an element that can be used in a GStreamer pipeline. Please refer to the plugin writers guide for more information on creatingGst.Element
subclasses.The name of a
Gst.Element
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
Gst.Pad
). These pads link to pads on other elements.Gst.Buffer
flow between these linked pads. AGst.Element
has aGLib.List
ofGst.Pad
structures for all their input (or sink) and output (or source) pads. Core and plug-in writers can add and remove pads withGst.Element.add_pad
() andGst.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 usingGst.Element.request_pad
() with aGst.PadTemplate
. An iterator of all pads can be retrieved withGst.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. UseGst.Element.link_filtered
() to link two elements constrained by a specified set ofGst.Caps
. For finer control, useGst.Element.link_pads
() andGst.Element.link_pads_filtered
() to specify the pads to link on each element by name.Each element has a state (see
Gst.State
). You can get and set the state of an element withGst.Element.get_state
() andGst.Element.set_state
(). Setting a state triggers aGst.StateChange
. To get a string representation of aGst.State
, useGst.Element.state_get_name
().You can get and set a
Gst.Clock
on an element usingGst.Element.get_clock
() andGst.Element.set_clock
(). Some elements can provide a clock for the pipeline if theGst.ElementFlags.PROVIDE_CLOCK
flag is set. With theGst.Element.provide_clock
() method one can retrieve the clock provided by such an element. Not all elements require a clock to operate correctly. If theGst.ElementFlags.REQUIRE_CLOCK
() flag is set, a clock should be set on the element withGst.Element.set_clock
().Note that clock selection and distribution is normally handled by the toplevel
Gst.Pipeline
so the clock functions are only to be used in very specific situations.- classmethod add_metadata(key, value)¶
-
Set key with value as metadata in self.
- classmethod add_pad_template(templ)¶
- Parameters:
templ (
Gst.PadTemplate
) – aGst.PadTemplate
to add to the element class.
Adds a padtemplate to an element class. This is mainly used in the _class_init functions of classes. If a pad template with the same name as an already existing one is added the old one is replaced by the new one.
templ's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())
- classmethod add_static_metadata(key, value)¶
-
Set key with value as metadata in self.
Same as
Gst.ElementClass.add_metadata
(), but value must be a static string or an inlined string, as it will not be copied. (GStreamer plugins will be made resident once loaded, so this function can be used even from dynamically loaded plugins.)
- classmethod add_static_pad_template(static_templ)¶
- Parameters:
static_templ (
Gst.StaticPadTemplate
) –Gst.StaticPadTemplate
to add as pad template to the element class.
Adds a pad template to an element class based on the static pad template templ. This is mainly used in the _class_init functions of element implementations. If a pad template with the same name already exists, the old one is replaced by the new one.
New in version 1.8.
- classmethod add_static_pad_template_with_gtype(static_templ, pad_type)¶
- Parameters:
static_templ (
Gst.StaticPadTemplate
) –Gst.StaticPadTemplate
to add as pad template to the element class.pad_type (
GObject.GType
) – TheGObject.GType
of the pad to create
Adds a pad template to an element class based on the static pad template templ. This is mainly used in the _class_init functions of element implementations. If a pad template with the same name already exists, the old one is replaced by the new one.
New in version 1.14.
- classmethod get_pad_template(name)[source]¶
- Parameters:
name (
str
) – the name of theGst.PadTemplate
to get.- Returns:
the
Gst.PadTemplate
with the given name, orNone
if none was found. No unreferencing is necessary.- Return type:
Retrieves a padtemplate from self with the given name.
If you use this function in the
GObject.InstanceInitFunc
of an object class that has subclasses, make sure to pass the g_class parameter of theGObject.InstanceInitFunc
here.
- classmethod get_pad_template_list()[source]¶
- Returns:
the
GLib.List
of pad templates.- Return type:
Retrieves a list of the pad templates associated with self. The list must not be modified by the calling code.
If you use this function in the
GObject.InstanceInitFunc
of an object class that has subclasses, make sure to pass the g_class parameter of theGObject.InstanceInitFunc
here.
- classmethod make_from_uri(type, uri, elementname)[source]¶
- Parameters:
type (
Gst.URIType
) – Whether to create a source or a sinkuri (
str
) – URI to create an element forelementname (
str
orNone
) – Name of created element, can beNone
.
- Raises:
- Returns:
a new element or
None
if none could be created- Return type:
Creates an element for handling the given URI.
- classmethod register(plugin, name, rank, type)[source]¶
- Parameters:
plugin (
Gst.Plugin
orNone
) –Gst.Plugin
to register the element with, orNone
for a static element.name (
str
) – name of elements of this typerank (
int
) – rank of element (higher rank means more importance when autoplugging)type (
GObject.GType
) –GObject.GType
of element to register
- Returns:
- Return type:
Create a new elementfactory capable of instantiating objects of the type and add the factory to plugin.
- classmethod set_metadata(longname, classification, description, author)¶
- Parameters:
longname (
str
) – The long English name of the element. E.g. “File Sink”classification (
str
) – String describing the type of element, as an unordered list separated with slashes (‘/’). See draft-klass.txt of the design docs for more details and common types. E.g: “Sink/File”description (
str
) – Sentence describing the purpose of the element. E.g: “Write stream to a file”author (
str
) – Name and contact details of the author(s). Use \n to separate multiple author metadata. E.g: “Joe Bloggs <joe.blogs at foo.com>”
Sets the detailed information for a
Gst.ElementClass
.This function is for use in _class_init functions only.
- classmethod set_static_metadata(longname, classification, description, author)¶
- Parameters:
longname (
str
) – The long English name of the element. E.g. “File Sink”classification (
str
) – String describing the type of element, as an unordered list separated with slashes (‘/’). See draft-klass.txt of the design docs for more details and common types. E.g: “Sink/File”description (
str
) – Sentence describing the purpose of the element. E.g: “Write stream to a file”author (
str
) – Name and contact details of the author(s). Use \n to separate multiple author metadata. E.g: “Joe Bloggs <joe.blogs at foo.com>”
Sets the detailed information for a
Gst.ElementClass
.This function is for use in _class_init functions only.
Same as
Gst.ElementClass.set_metadata
(), but longname, classification, description, and author must be static strings or inlined strings, as they will not be copied. (GStreamer plugins will be made resident once loaded, so this function can be used even from dynamically loaded plugins.)
- classmethod state_change_return_get_name(state_ret)[source]¶
- Parameters:
state_ret (
Gst.StateChangeReturn
) – aGst.StateChangeReturn
to get the name of.- Returns:
a string with the name of the state result.
- Return type:
Gets a string representing the given state change result.
- classmethod state_get_name(state)[source]¶
- Parameters:
- Returns:
a string with the name of the state.
- Return type:
Gets a string representing the given state.
- classmethod type_set_skip_documentation(type)[source]¶
- Parameters:
type (
GObject.GType
) – aGObject.GType
of element
Marks type as “documentation should be skipped”. Can be useful for dynamically registered element to be excluded from plugin documentation system.
Example: ```c
GObject.GType
my_type;GObject.TypeInfo
my_type_info;// Fill “my_type_info” …
my_type =
GObject.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); ```New in version 1.20.
- abort_state()[source]¶
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.
- add_pad(pad)[source]¶
- Parameters:
- 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.
- Return type:
Adds a pad (link point) to self. pad's parent will be set to self; 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
Gst.Element
::pad-added
signal on the element.
- add_property_deep_notify_watch(property_name, include_value)[source]¶
- Parameters:
- Returns:
a watch id, which can be used in connection with
Gst.Element.remove_property_notify_watch
() to remove the watch again.- Return type:
New in version 1.10.
- add_property_notify_watch(property_name, include_value)[source]¶
- Parameters:
- Returns:
a watch id, which can be used in connection with
Gst.Element.remove_property_notify_watch
() to remove the watch again.- Return type:
New in version 1.10.
- call_async(func, *user_data)[source]¶
- Parameters:
func (
Gst.ElementCallAsyncFunc
) – Function to call asynchronously from another thread
Calls func from another thread and passes user_data 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.
New in version 1.10.
- change_state(transition)[source]¶
- Parameters:
transition (
Gst.StateChange
) – the requested transition- Returns:
the
Gst.StateChangeReturn
of the state transition.- Return type:
Perform transition on self.
This function must be called with STATE_LOCK held and is mainly used internally.
- continue_state(ret)[source]¶
- Parameters:
ret (
Gst.StateChangeReturn
) – The previous state return value- Returns:
The result of the commit state change.
MT safe.
- Return type:
Commit the state change of the element and proceed to the next pending state if any. This function is used by elements that do asynchronous state changes. The core will normally call this method automatically when an element returned
Gst.StateChangeReturn.SUCCESS
from the state change function.If after calling this method the element still has not reached the pending state, the next state change is performed.
This method is used internally and should normally not be called by plugins or applications.
This function must be called with STATE_LOCK held.
- create_all_pads()[source]¶
Creates a pad for each pad template that is always available. This function is only useful during object initialization of subclasses of
Gst.Element
.
- decorate_stream_id(stream_id)[source]¶
-
Creates a stream-id for self by combining the upstream information with the stream_id.
This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending 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.
New in version 1.24.
- foreach_pad(func, *user_data)[source]¶
- Parameters:
func (
Gst.ElementForeachPadFunc
) – function to call for each pad
- Returns:
False
if self had no pads or if one of the calls to func returnedFalse
.- Return type:
Call func with user_data for each of self's pads. func will be called exactly once for each pad that exists at the time of this call, unless one of the calls to func returns
False
in which case we will stop iterating pads and return early. If new pads are added or pads are removed while pads are being iterated, this will not be taken into account until next time this function is used.New in version 1.14.
- foreach_sink_pad(func, *user_data)[source]¶
- Parameters:
func (
Gst.ElementForeachPadFunc
) – function to call for each sink pad
- Returns:
False
if self had no sink pads or if one of the calls to func returnedFalse
.- Return type:
Call func with user_data for each of self's sink pads. func will be called exactly once for each sink pad that exists at the time of this call, unless one of the calls to func returns
False
in which case we will stop iterating pads and return early. If new sink pads are added or sink pads are removed while the sink pads are being iterated, this will not be taken into account until next time this function is used.New in version 1.14.
- foreach_src_pad(func, *user_data)[source]¶
- Parameters:
func (
Gst.ElementForeachPadFunc
) – function to call for each source pad
- Returns:
False
if self had no source pads or if one of the calls to func returnedFalse
.- Return type:
Call func with user_data for each of self's source pads. func will be called exactly once for each source pad that exists at the time of this call, unless one of the calls to func returns
False
in which case we will stop iterating pads and return early. If new source pads are added or source pads are removed while the source pads are being iterated, this will not be taken into account until next time this function is used.New in version 1.14.
- get_base_time()[source]¶
- Returns:
the base time of the element.
MT safe.
- Return type:
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.
- get_bus()[source]¶
-
Returns the bus of the element. Note that only a
Gst.Pipeline
will provide a bus for the application.
- get_clock()[source]¶
-
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.
- get_compatible_pad(pad, caps)[source]¶
- Parameters:
- Returns:
the
Gst.Pad
to which a link can be made, orNone
if one cannot be found.Gst.Object.unref
() after usage.- Return type:
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 self.
- get_compatible_pad_template(compattempl)[source]¶
- Parameters:
compattempl (
Gst.PadTemplate
) – theGst.PadTemplate
to find a compatible template for- Returns:
a compatible
Gst.PadTemplate
, orNone
if none was found. No unreferencing is necessary.- Return type:
Retrieves a pad template from self that is compatible with compattempl. Pads from compatible templates can be linked together.
- get_context(context_type)[source]¶
- Parameters:
context_type (
str
) – a name of a context to retrieve- Returns:
A
Gst.Context
orNone
- Return type:
Gst.Context
orNone
Gets the context with context_type set on the element or
None
.MT safe.
New in version 1.8.
- get_context_unlocked(context_type)[source]¶
- Parameters:
context_type (
str
) – a name of a context to retrieve- Returns:
A
Gst.Context
orNone
- Return type:
Gst.Context
orNone
Gets the context with context_type set on the element or
None
.New in version 1.8.
- get_contexts()[source]¶
- Returns:
List of
Gst.Context
- Return type:
Gets the contexts set on the element.
MT safe.
New in version 1.8.
- get_current_clock_time()[source]¶
- Returns:
the clock time of the element, or
Gst.CLOCK_TIME_NONE
if there is no clock.- Return type:
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.New in version 1.18.
- get_current_running_time()[source]¶
- 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.- Return type:
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.New in version 1.18.
- get_factory()[source]¶
- Returns:
the
Gst.ElementFactory
used for creating this element orNone
if element has not been registered (static element). no refcounting is needed.- Return type:
Retrieves the factory that was used to create this element.
- get_pad_template(name)[source]¶
- Parameters:
name (
str
) – the name of theGst.PadTemplate
to get.- Returns:
the
Gst.PadTemplate
with the given name, orNone
if none was found. No unreferencing is necessary.- Return type:
Retrieves a padtemplate from self with the given name.
New in version 1.14.
- get_pad_template_list()[source]¶
- Returns:
the
GLib.List
of pad templates.- Return type:
Retrieves a list of the pad templates associated with self. The list must not be modified by the calling code.
New in version 1.14.
- get_request_pad(name)[source]¶
-
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 simplifiedGst.Element.request_pad
().Deprecated since version 1.20: Prefer using
Gst.Element.request_pad_simple
() which provides the exact same functionality.
- get_start_time()[source]¶
- Returns:
the start time of the element.
- Return type:
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
Gst.Pipeline
.MT safe.
- get_state(timeout)[source]¶
- Parameters:
timeout (
int
) – a #GstClockTime to specify the timeout for an async state change orGst.CLOCK_TIME_NONE
for infinite timeout.- Returns:
Gst.StateChangeReturn.SUCCESS
if the element has no more pending state and the last state change succeeded,Gst.StateChangeReturn.ASYNC
if the element is still performing a state change orGst.StateChangeReturn.FAILURE
if the last state change failed.MT safe.
- Return type:
(
Gst.StateChangeReturn
, state:Gst.State
, pending:Gst.State
)
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 ofGst.StateChangeReturn.SUCCESS
orGst.StateChangeReturn.FAILURE
respectively.For elements that did not return
Gst.StateChangeReturn.ASYNC
, this function returns the current and pending state immediately.This function returns
Gst.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 inGst.State.PLAYING
. While the state change return is equivalent toGst.StateChangeReturn.SUCCESS
, it is returned to the application to signal that some sink elements might not be able to complete their state change because an element is not producing data to complete the preroll. When setting the element to playing, the preroll will complete and playback will start.
- get_static_pad(name)[source]¶
- Parameters:
- Returns:
the requested
Gst.Pad
if found, otherwiseNone
. unref after usage.MT safe.
- Return type:
Retrieves a pad from self by name. This version only retrieves already-existing (i.e. ‘static’) pads.
- is_locked_state()[source]¶
-
Checks if the state of an element is locked. If the state of an element is locked, state changes of the parent don’t affect the element. This way you can leave currently unused elements inside bins. Just lock their state before changing the state from
Gst.State.NULL
.MT safe.
- iterate_pads()[source]¶
- Returns:
the
Gst.Iterator
ofGst.Pad
.MT safe.
- Return type:
Retrieves an iterator of self's pads. The iterator should be freed after usage. Also more specialized iterators exists such as
Gst.Element.iterate_src_pads
() orGst.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.
- iterate_sink_pads()[source]¶
- Returns:
the
Gst.Iterator
ofGst.Pad
.MT safe.
- Return type:
Retrieves an iterator of self's sink pads.
The order of pads returned by the iterator will be the order in which the pads were added to the element.
- iterate_src_pads()[source]¶
- Returns:
the
Gst.Iterator
ofGst.Pad
.MT safe.
- Return type:
Retrieves an iterator of self's source pads.
The order of pads returned by the iterator will be the order in which the pads were added to the element.
- link(dest)[source]¶
- Parameters:
dest (
Gst.Element
) – theGst.Element
containing the destination pad.- Returns:
- Return type:
Links self to dest. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren’t linked yet. It will request new pads if necessary. Such pads need to be released manually when unlinking. If multiple links are possible, only one is established.
Make sure you have added your elements to a bin or pipeline with
Gst.Bin.add
() before trying to link them.
- link_filtered(dest, filter)[source]¶
- Parameters:
dest (
Gst.Element
) – theGst.Element
containing the destination pad.filter (
Gst.Caps
orNone
) – theGst.Caps
to filter the link, orNone
for no filter.
- Returns:
- Return type:
Links self to dest using the given caps as filtercaps. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren’t linked yet. It will request new pads if necessary. If multiple links are possible, only one is established.
Make sure you have added your elements to a bin or pipeline with
Gst.Bin.add
() before trying to link them.
- link_pads(srcpadname, dest, destpadname)[source]¶
- Parameters:
srcpadname (
str
orNone
) – the name of theGst.Pad
in source element orNone
for any pad.dest (
Gst.Element
) – theGst.Element
containing the destination pad.destpadname (
str
orNone
) – the name of theGst.Pad
in destination element, orNone
for any pad.
- Returns:
- Return type:
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.
- link_pads_filtered(srcpadname, dest, destpadname, filter)[source]¶
- Parameters:
srcpadname (
str
orNone
) – the name of theGst.Pad
in source element orNone
for any pad.dest (
Gst.Element
) – theGst.Element
containing the destination pad.destpadname (
str
orNone
) – the name of theGst.Pad
in destination element orNone
for any pad.filter (
Gst.Caps
orNone
) – theGst.Caps
to filter the link, orNone
for no filter.
- Returns:
- Return type:
Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails. If caps is not
None
, makes sure that the caps of the link is a subset of caps.
- link_pads_full(srcpadname, dest, destpadname, flags)[source]¶
- Parameters:
srcpadname (
str
orNone
) – the name of theGst.Pad
in source element orNone
for any pad.dest (
Gst.Element
) – theGst.Element
containing the destination pad.destpadname (
str
orNone
) – the name of theGst.Pad
in destination element, orNone
for any pad.flags (
Gst.PadLinkCheck
) – theGst.PadLinkCheck
to be performed when linking pads.
- Returns:
- Return type:
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 ==Gst.PadLinkCheck.DEFAULT
is the same as callingGst.Element.link_pads
() and the recommended way of linking pads with safety checks applied.This is a convenience function for
Gst.Pad.link_full
().
- lost_state()[source]¶
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 returnGst.StateChangeReturn.ASYNC
.An ASYNC_START message is posted. If the element was PLAYING, it will go to PAUSED. The element will be restored to its PLAYING state by the parent pipeline when it prerolls again.
This is mostly used for elements that lost their preroll buffer in the
Gst.State.PAUSED
orGst.State.PLAYING
state after a flush, they will go to their pending state again when a new preroll buffer is queued. This function can only be called when the element is currently not in error or an async state change.This function is used internally and should normally not be called from plugins or applications.
- message_full(type, domain, code, text, debug, file, function, line)[source]¶
- Parameters:
type (
Gst.MessageType
) – theGst.MessageType
domain (
int
) – the GStreamerGLib.Error
domain this message belongs tocode (
int
) – theGLib.Error
code belonging to the domaintext (
str
orNone
) – an allocated text string to be used as a replacement for the default message connected to code, orNone
debug (
str
orNone
) – an allocated debug message to be used as a replacement for the default debugging information, orNone
file (
str
) – the source code file where the error was generatedfunction (
str
) – the source code function where the error was generatedline (
int
) – the source code line where the error was generated
Post an error, warning or info message on the bus from inside an element.
type must be of
Gst.MessageType.ERROR
,Gst.MessageType.WARNING
orGst.MessageType.INFO
.MT safe.
- message_full_with_details(type, domain, code, text, debug, file, function, line, structure)[source]¶
- Parameters:
type (
Gst.MessageType
) – theGst.MessageType
domain (
int
) – the GStreamerGLib.Error
domain this message belongs tocode (
int
) – theGLib.Error
code belonging to the domaintext (
str
orNone
) – an allocated text string to be used as a replacement for the default message connected to code, orNone
debug (
str
orNone
) – an allocated debug message to be used as a replacement for the default debugging information, orNone
file (
str
) – the source code file where the error was generatedfunction (
str
) – the source code function where the error was generatedline (
int
) – the source code line where the error was generatedstructure (
Gst.Structure
) – optional details structure
Post an error, warning or info message on the bus from inside an element.
type must be of
Gst.MessageType.ERROR
,Gst.MessageType.WARNING
orGst.MessageType.INFO
.New in version 1.10.
- no_more_pads()[source]¶
Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with
Gst.PadPresence.SOMETIMES
pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads.This function emits the
Gst.Element
::no-more-pads
signal.MT safe.
- post_message(message)[source]¶
- Parameters:
message (
Gst.Message
) – aGst.Message
to post- Returns:
True
if the message was successfully posted. The function returnsFalse
if the element did not have a bus.MT safe.
- Return type:
Post a message on the element’s
Gst.Bus
. 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.
- provide_clock()[source]¶
- Returns:
the
Gst.Clock
provided by the element orNone
if no clock could be provided. Unref after usage.MT safe.
- Return type:
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.
- query(query)[source]¶
- Parameters:
- Returns:
True
if the query could be performed.MT safe.
- Return type:
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.
- query_convert(src_format, src_val, dest_format)[source]¶
- Parameters:
src_format (
Gst.Format
) – aGst.Format
to convert from.src_val (
int
) – a value to convert.dest_format (
Gst.Format
) – theGst.Format
to convert to.
- Returns:
True
if the query could be performed.- dest_val:
a pointer to the result.
- Return type:
Queries an element to convert src_val in src_format to dest_format.
- query_duration(format)[source]¶
- Parameters:
format (
Gst.Format
) – theGst.Format
requested- Returns:
True
if the query could be performed.- duration:
A location in which to store the total duration, or
None
.
- Return type:
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.
- query_position(format)[source]¶
- Parameters:
format (
Gst.Format
) – theGst.Format
requested- Returns:
True
if the query could be performed.- cur:
a location in which to store the current position, or
None
.
- Return type:
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
().
- release_request_pad(pad)[source]¶
-
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 byGst.Object.unref
() to free the pad.MT safe.
- remove_pad(pad)[source]¶
- Parameters:
- Returns:
True
if the pad could be removed. Can returnFalse
if the pad does not belong to the provided element.MT safe.
- Return type:
Removes pad from self. 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 theGst.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
Gst.Element
::pad-removed
signal on the element.
- remove_property_notify_watch(watch_id)[source]¶
- Parameters:
watch_id (
int
) – watch id to remove
New in version 1.10.
- request_pad(templ, name, caps)[source]¶
- Parameters:
templ (
Gst.PadTemplate
) – aGst.PadTemplate
of which we want a pad of.name (
str
orNone
) – the name of the requestGst.Pad
to retrieve. Can beNone
.caps (
Gst.Caps
orNone
) – the caps of the pad we want to request. Can beNone
.
- Returns:
requested
Gst.Pad
if found, otherwiseNone
. Release after usage.- Return type:
Retrieves a request pad from the element according to the provided template. Pad templates can be looked up using
Gst.ElementFactory.get_static_pad_templates
().The pad should be released with
Gst.Element.release_request_pad
().
- request_pad_simple(name)[source]¶
-
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 useGst.Element.get_request_pad
() which provides the same functionality.New in version 1.20.
- seek(rate, format, flags, start_type, start, stop_type, stop)[source]¶
- Parameters:
rate (
float
) – The new playback rateformat (
Gst.Format
) – The format of the seek valuesflags (
Gst.SeekFlags
) – The optional seek flags.start_type (
Gst.SeekType
) – The type and flags for the new start positionstart (
int
) – The value of the new start positionstop_type (
Gst.SeekType
) – The type and flags for the new stop positionstop (
int
) – The value of the new stop position
- Returns:
True
if the event was handled. Flushing seeks will trigger a preroll, which will emitGst.MessageType.ASYNC_DONE
.- Return type:
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 usingGst.Element.send_event
().MT safe.
- seek_simple(format, seek_flags, seek_pos)[source]¶
- Parameters:
format (
Gst.Format
) – aGst.Format
to execute the seek in, such asGst.Format.TIME
seek_flags (
Gst.SeekFlags
) – seek options; playback applications will usually want to useGst.SeekFlags.FLUSH
|Gst.SeekFlags.KEY_UNIT
hereseek_pos (
int
) – 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 emitGst.MessageType.ASYNC_DONE
.- Return type:
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.
- send_event(event)[source]¶
- Parameters:
- Returns:
True
if the event was handled. Events that trigger a preroll (such as flushing seeks and steps) will emitGst.MessageType.ASYNC_DONE
.- Return type:
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.
- set_base_time(time)[source]¶
- Parameters:
time (
int
) – the base time to set.
Set the base time of an element. See
Gst.Element.get_base_time
().MT safe.
- set_bus(bus)[source]¶
-
Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you’re testing elements.
MT safe.
- set_clock(clock)[source]¶
- Parameters:
clock (
Gst.Clock
orNone
) – theGst.Clock
to set for the element.- Returns:
True
if the element accepted the clock. An element can refuse a clock when it, for example, is not able to slave its internal clock to the clock or when it requires a specific clock to operate.MT safe.
- Return type:
Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.
- set_context(context)[source]¶
- Parameters:
context (
Gst.Context
) – theGst.Context
to set.
Sets the context of the element. Increases the refcount of the context.
MT safe.
- set_locked_state(locked_state)[source]¶
- Parameters:
- Returns:
True
if the state was changed,False
if bad parameters were given or the elements state-locking needed no change.- Return type:
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.
- set_start_time(time)[source]¶
- Parameters:
time (
int
) – the base time to set.
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
Gst.Pipeline
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.
- set_state(state)[source]¶
- Parameters:
- Returns:
Result of the state change using
Gst.StateChangeReturn
.MT safe.
- Return type:
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.StateChangeReturn.ASYNC
, in which case the element will perform the remainder of the state change asynchronously in another thread. An application can useGst.Element.get_state
() to wait for the completion of the state change or it can wait for aGst.MessageType.ASYNC_DONE
orGst.MessageType.STATE_CHANGED
on the bus.State changes to
Gst.State.READY
orGst.State.NULL
never returnGst.StateChangeReturn.ASYNC
.
- sync_state_with_parent()[source]¶
- Returns:
True
, if the element’s state could be synced to the parent’s state.MT safe.
- Return type:
Tries to change the state of the element to the same as its parent. If this function returns
False
, the state of element is undefined.
- unlink(dest)[source]¶
- Parameters:
dest (
Gst.Element
) – the sinkGst.Element
to 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 usingGst.Element.release_request_pad
().
- unlink_pads(srcpadname, dest, destpadname)[source]¶
- Parameters:
srcpadname (
str
) – the name of theGst.Pad
in source element.dest (
Gst.Element
) – aGst.Element
containing the destination pad.destpadname (
str
) – the name of theGst.Pad
in destination element.
Unlinks the two named pads of the source and destination elements.
This is a convenience function for
Gst.Pad.unlink
().
- do_change_state(transition) virtual¶
- Parameters:
transition (
Gst.StateChange
) – the requested transition- Returns:
the
Gst.StateChangeReturn
of the state transition.- Return type:
Perform transition on element.
This function must be called with STATE_LOCK held and is mainly used internally.
- do_get_state(timeout) virtual¶
- Parameters:
timeout (
int
) – a #GstClockTime to specify the timeout for an async state change orGst.CLOCK_TIME_NONE
for infinite timeout.- Returns:
Gst.StateChangeReturn.SUCCESS
if the element has no more pending state and the last state change succeeded,Gst.StateChangeReturn.ASYNC
if the element is still performing a state change orGst.StateChangeReturn.FAILURE
if the last state change failed.MT safe.
- Return type:
(
Gst.StateChangeReturn
, state:Gst.State
, pending:Gst.State
)
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 ofGst.StateChangeReturn.SUCCESS
orGst.StateChangeReturn.FAILURE
respectively.For elements that did not return
Gst.StateChangeReturn.ASYNC
, this function returns the current and pending state immediately.This function returns
Gst.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 inGst.State.PLAYING
. While the state change return is equivalent toGst.StateChangeReturn.SUCCESS
, it is returned to the application to signal that some sink elements might not be able to complete their state change because an element is not producing data to complete the preroll. When setting the element to playing, the preroll will complete and playback will start.
- do_no_more_pads() virtual¶
Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with
Gst.PadPresence.SOMETIMES
pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads.This function emits the
Gst.Element
::no-more-pads
signal.MT safe.
- do_post_message(message) virtual¶
- Parameters:
message (
Gst.Message
) – aGst.Message
to post- Returns:
True
if the message was successfully posted. The function returnsFalse
if the element did not have a bus.MT safe.
- Return type:
Post a message on the element’s
Gst.Bus
. 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.
- do_provide_clock() virtual¶
- Returns:
the
Gst.Clock
provided by the element orNone
if no clock could be provided. Unref after usage.MT safe.
- Return type:
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.
- do_query(query) virtual¶
- Parameters:
- Returns:
True
if the query could be performed.MT safe.
- Return type:
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.
- do_release_pad(pad) virtual¶
- Parameters:
pad (
Gst.Pad
) –
called when a request pad is to be released
- do_request_new_pad(templ, name, caps) virtual¶
- Parameters:
templ (
Gst.PadTemplate
) – aGst.PadTemplate
of which we want a pad of.name (
str
orNone
) – the name of the requestGst.Pad
to retrieve. Can beNone
.caps (
Gst.Caps
orNone
) – the caps of the pad we want to request. Can beNone
.
- Returns:
requested
Gst.Pad
if found, otherwiseNone
. Release after usage.- Return type:
Retrieves a request pad from the element according to the provided template. Pad templates can be looked up using
Gst.ElementFactory.get_static_pad_templates
().The pad should be released with
Gst.Element.release_request_pad
().
- do_send_event(event) virtual¶
- Parameters:
- Returns:
True
if the event was handled. Events that trigger a preroll (such as flushing seeks and steps) will emitGst.MessageType.ASYNC_DONE
.- Return type:
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.
- do_set_bus(bus) virtual¶
-
Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you’re testing elements.
MT safe.
- do_set_clock(clock) virtual¶
- Parameters:
clock (
Gst.Clock
orNone
) – theGst.Clock
to set for the element.- Returns:
True
if the element accepted the clock. An element can refuse a clock when it, for example, is not able to slave its internal clock to the clock or when it requires a specific clock to operate.MT safe.
- Return type:
Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.
- do_set_context(context) virtual¶
- Parameters:
context (
Gst.Context
) – theGst.Context
to set.
Sets the context of the element. Increases the refcount of the context.
MT safe.
- do_set_state(state) virtual¶
- Parameters:
- Returns:
Result of the state change using
Gst.StateChangeReturn
.MT safe.
- Return type:
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.StateChangeReturn.ASYNC
, in which case the element will perform the remainder of the state change asynchronously in another thread. An application can useGst.Element.get_state
() to wait for the completion of the state change or it can wait for aGst.MessageType.ASYNC_DONE
orGst.MessageType.STATE_CHANGED
on the bus.State changes to
Gst.State.READY
orGst.State.NULL
never returnGst.StateChangeReturn.ASYNC
.
Signal Details¶
- Gst.Element.signals.no_more_pads(element)¶
- Signal Name:
no-more-pads
- Flags:
- Parameters:
element (
Gst.Element
) – The object which received the signal
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.
- Gst.Element.signals.pad_added(element, new_pad)¶
- Signal Name:
pad-added
- Flags:
- Parameters:
element (
Gst.Element
) – The object which received the signalnew_pad (
Gst.Pad
) – the pad that has been added
a new
Gst.Pad
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 withGst.Element.set_state
() orGst.Element.sync_state_with_parent
().
- Gst.Element.signals.pad_removed(element, old_pad)¶
- Signal Name:
pad-removed
- Flags:
- Parameters:
element (
Gst.Element
) – The object which received the signalold_pad (
Gst.Pad
) – the pad that has been removed
a
Gst.Pad
has been removed from the element