Gst.Element

g GObject.InitiallyUnowned GObject.InitiallyUnowned Gst.Object Gst.Object GObject.InitiallyUnowned->Gst.Object Gst.Element Gst.Element Gst.Object->Gst.Element GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned

Subclasses:Gst.Bin

Methods

Inherited:Gst.Object (27), GObject.Object (40)
Structs:Gst.ElementClass (9), GObject.ObjectClass (5)
class add_metadata (key, value)
class add_pad_template (templ)
class add_static_metadata (key, value)
class add_static_pad_template (static_templ)
class get_metadata (key)
class get_pad_template (name)
class get_pad_template_list ()
class make_from_uri (type, uri, elementname)
class register (plugin, name, rank, type)
class set_metadata (longname, classification, description, author)
class set_static_metadata (longname, classification, description, author)
class state_change_return_get_name (state_ret)
class state_get_name (state)
  abort_state ()
  add_pad (pad)
  add_property_deep_notify_watch (property_name, include_value)
  add_property_notify_watch (property_name, include_value)
  call_async (func, *user_data)
  change_state (transition)
  continue_state (ret)
  create_all_pads ()
  get_base_time ()
  get_bus ()
  get_clock ()
  get_compatible_pad (pad, caps)
  get_compatible_pad_template (compattempl)
  get_context (context_type)
  get_context_unlocked (context_type)
  get_contexts ()
  get_factory ()
  get_request_pad (name)
  get_start_time ()
  get_state (timeout)
  get_static_pad (name)
  is_locked_state ()
  iterate_pads ()
  iterate_sink_pads ()
  iterate_src_pads ()
  link (dest)
  link_filtered (dest, filter)
  link_pads (srcpadname, dest, destpadname)
  link_pads_filtered (srcpadname, dest, destpadname, filter)
  link_pads_full (srcpadname, dest, destpadname, flags)
  lost_state ()
  message_full (type, domain, code, text, debug, file, function, line)
  message_full_with_details (type, domain, code, text, debug, file, function, line, structure)
  no_more_pads ()
  post_message (message)
  provide_clock ()
  query (query)
  query_convert (src_format, src_val, dest_format)
  query_duration (format)
  query_position (format)
  release_request_pad (pad)
  remove_pad (pad)
  remove_property_notify_watch (watch_id)
  request_pad (templ, name, caps)
  seek (rate, format, flags, start_type, start, stop_type, stop)
  seek_simple (format, seek_flags, seek_pos)
  send_event (event)
  set_base_time (time)
  set_bus (bus)
  set_clock (clock)
  set_context (context)
  set_locked_state (locked_state)
  set_start_time (time)
  set_state (state)
  sync_state_with_parent ()
  unlink (dest)
  unlink_pads (srcpadname, dest, destpadname)

Virtual Methods

Inherited:Gst.Object (1), GObject.Object (7)
  do_change_state (transition)
  do_get_state (timeout)
  do_no_more_pads ()
  do_pad_added (pad)
  do_pad_removed (pad)
  do_post_message (message)
  do_provide_clock ()
  do_query (query)
  do_release_pad (pad)
  do_request_new_pad (templ, name, caps)
  do_send_event (event)
  do_set_bus (bus)
  do_set_clock (clock)
  do_set_context (context)
  do_set_state (state)
  do_state_changed (oldstate, newstate, pending)

Properties

Inherited:Gst.Object (2)

Signals

Inherited:Gst.Object (1), GObject.Object (1)
Name Short Description
no-more-pads This signals that the element will not generate more dynamic pads.
pad-added a new Gst.Pad has been added to the element.
pad-removed a Gst.Pad has been removed from the element

Fields

Inherited:Gst.Object (1), GObject.Object (1)
Name Type Access Description
base_time int 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 Gst.Bus r the bus of the element. This bus is provided to the element by the parent element or the application. A Gst.Pipeline has a bus of its own.
clock Gst.Clock r the clock of the element. This clock is usually provided to the element by the toplevel Gst.Pipeline.
contexts [Gst.Context] r list of contexts
current_state Gst.State r the current state of an element
last_return Gst.StateChangeReturn r the last return value of an element state change
next_state Gst.State r the next state of an element, can be Gst.State.VOID_PENDING if the element is in the correct state.
numpads int r number of pads of the element, includes both source and sink pads.
numsinkpads int r number of sink pads of the element.
numsrcpads int r number of source pads of the element.
object Gst.Object r  
pads [Gst.Pad] r list of pads
pads_cookie int r updated whenever the a pad is added or removed
pending_state Gst.State r the final state the element should go to, can be Gst.State.VOID_PENDING if the element is in the correct state
sinkpads [Gst.Pad] r list of sink pads
srcpads [Gst.Pad] r list of source pads
start_time int r the running_time of the last PAUSED state
state_cond GLib.Cond r Used to signal completion of a state change
state_cookie int r Used to detect concurrent execution of Gst.Element.set_state() and Gst.Element.get_state()
state_lock GLib.RecMutex r Used to serialize execution of Gst.Element.set_state()
target_state Gst.State r the target state of an element as set by the application

Class Details

class Gst.Element(**kwargs)
Bases:Gst.Object
Abstract:Yes
Structure:Gst.ElementClass

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 creating Gst.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. A Gst.Element has a GLib.List of Gst.Pad 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 Gst.PadTemplate. 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 Gst.Caps. 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 Gst.State). 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 Gst.StateChange. To get a string representation of a Gst.State, use Gst.Element.state_get_name().

You can get and set a Gst.Clock 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.ElementFlags.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.ElementFlags.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 Gst.Pipeline so the clock functions are only to be used in very specific situations.

classmethod add_metadata(key, value)
Parameters:
  • key (str) – the key to set
  • value (str) – the value to set

Set key with value as metadata in self.

classmethod add_pad_template(templ)
Parameters:templ (Gst.PadTemplate) – a Gst.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.

classmethod add_static_metadata(key, value)
Parameters:
  • key (str) – the key to set
  • value (str) – the value to set

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 get_metadata(key)
Parameters:key (str) – the key to get
Returns:the metadata for key.
Return type:str

Get metadata with key in self.

classmethod get_pad_template(name)
Parameters:name (str) – the name of the Gst.PadTemplate to get.
Returns:the Gst.PadTemplate with the given name, or None if none was found. No unreferencing is necessary.
Return type:Gst.PadTemplate or None

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 the GObject.InstanceInitFunc here.

classmethod get_pad_template_list()
Returns:the GLib.List of pad templates.
Return type:[Gst.PadTemplate]

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 the GObject.InstanceInitFunc here.

classmethod make_from_uri(type, uri, elementname)[source]
Parameters:
  • type (Gst.URIType) – Whether to create a source or a sink
  • uri (str) – URI to create an element for
  • elementname (str or None) – Name of created element, can be None.
Raises:

GLib.Error

Returns:

a new element or None if none could be created

Return type:

Gst.Element

Creates an element for handling the given URI.

classmethod register(plugin, name, rank, type)[source]
Parameters:
Returns:

True, if the registering succeeded, False on error

Return type:

bool

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) – a Gst.StateChangeReturn to get the name of.
Returns:a string with the name of the state result.
Return type:str

Gets a string representing the given state change result.

classmethod state_get_name(state)[source]
Parameters:state (Gst.State) – a Gst.State to get the name of.
Returns:a string with the name of the state.
Return type:str

Gets a string representing the given state.

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:pad (Gst.Pad) – the Gst.Pad 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.

Return type:bool

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 not automatically activated so elements should perform the needed steps to activate the pad in case this pad is added in the PAUSED or PLAYING state. See Gst.Pad.set_active() for more information about activating pads.

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:
  • property_name (str or None) – name of property to watch for changes, or None to watch all properties
  • include_value (bool) – whether to include the new property value in the message
Returns:

a watch id, which can be used in connection with Gst.Element.remove_property_notify_watch() to remove the watch again.

Return type:

int

New in version 1.10.

add_property_notify_watch(property_name, include_value)[source]
Parameters:
  • property_name (str or None) – name of property to watch for changes, or None to watch all properties
  • include_value (bool) – whether to include the new property value in the message
Returns:

a watch id, which can be used in connection with Gst.Element.remove_property_notify_watch() to remove the watch again.

Return type:

int

New in version 1.10.

call_async(func, *user_data)[source]
Parameters:

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:Gst.StateChangeReturn

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:Gst.StateChangeReturn

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.

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.

get_base_time()[source]
Returns:the base time of the element.

MT safe.

Return type:int

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 element’s Gst.Bus. unref after usage.

MT safe.

Return type:Gst.Bus

Returns the bus of the element. Note that only a Gst.Pipeline will provide a bus for the application.

get_clock()[source]
Returns:the Gst.Clock of the element. unref after usage.

MT safe.

Return type:Gst.Clock

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, or None if one cannot be found. Gst.Object.unref() after usage.

Return type:

Gst.Pad or None

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) – the Gst.PadTemplate to find a compatible template for
Returns:a compatible Gst.PadTemplate, or None if none was found. No unreferencing is necessary.
Return type:Gst.PadTemplate or None

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 or None
Return type:Gst.Context

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 or None
Return type:Gst.Context

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:[Gst.Context]

Gets the contexts set on the element.

MT safe.

New in version 1.8.

get_factory()[source]
Returns:the Gst.ElementFactory used for creating this element. no refcounting is needed.
Return type:Gst.ElementFactory

Retrieves the factory that was used to create this element.

get_request_pad(name)[source]
Parameters:name (str) – the name of the request Gst.Pad to retrieve.
Returns:requested Gst.Pad if found, otherwise None. Release after usage.
Return type:Gst.Pad or None

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

get_start_time()[source]
Returns:the start time of the element.
Return type:int

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 or Gst.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 or Gst.StateChangeReturn.FAILURE if the last state change failed.

MT safe.

state:a pointer to Gst.State to hold the state. Can be None.
pending:a pointer to Gst.State to hold the pending state. Can be None.
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 of Gst.StateChangeReturn.SUCCESS or Gst.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 in Gst.State.PLAYING. While the state change return is equivalent to Gst.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:name (str) – the name of the static Gst.Pad to retrieve.
Returns:the requested Gst.Pad if found, otherwise None. unref after usage.

MT safe.

Return type:Gst.Pad or None

Retrieves a pad from self by name. This version only retrieves already-existing (i.e. ‘static’) pads.

is_locked_state()[source]
Returns:True, if the element’s state is locked.
Return type:bool

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 of Gst.Pad.

MT safe.

Return type:Gst.Iterator

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

iterate_sink_pads()[source]
Returns:the Gst.Iterator of Gst.Pad.

MT safe.

Return type:Gst.Iterator

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 of Gst.Pad.

MT safe.

Return type:Gst.Iterator

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.

Parameters:dest (Gst.Element) – the Gst.Element containing the destination pad.
Returns:True if the elements could be linked, False otherwise.
Return type:bool

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.

Parameters:
Returns:

True if the pads could be linked, False otherwise.

Return type:

bool

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.

Parameters:
Returns:

True if the pads could be linked, False otherwise.

Return type:

bool

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:
Returns:

True if the pads could be linked, False otherwise.

Return type:

bool

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.

Parameters:
Returns:

True if the pads could be linked, False otherwise.

Return type:

bool

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

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 return Gst.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 or Gst.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) – the Gst.MessageType
  • domain (int) – the GStreamer GLib.Error domain this message belongs to
  • code (int) – the GLib.Error code belonging to the domain
  • text (str or None) – an allocated text string to be used as a replacement for the default message connected to code, or None
  • debug (str or None) – an allocated debug message to be used as a replacement for the default debugging information, or None
  • file (str) – the source code file where the error was generated
  • function (str) – the source code function where the error was generated
  • line (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 or Gst.MessageType.INFO.

MT safe.

message_full_with_details(type, domain, code, text, debug, file, function, line, structure)[source]
Parameters:
  • type (Gst.MessageType) – the Gst.MessageType
  • domain (int) – the GStreamer GLib.Error domain this message belongs to
  • code (int) – the GLib.Error code belonging to the domain
  • text (str or None) – an allocated text string to be used as a replacement for the default message connected to code, or None
  • debug (str or None) – an allocated debug message to be used as a replacement for the default debugging information, or None
  • file (str) – the source code file where the error was generated
  • function (str) – the source code function where the error was generated
  • line (int) – the source code line where the error was generated
  • structure (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 or Gst.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) – a Gst.Message to post
Returns:True if the message was successfully posted. The function returns False if the element did not have a bus.

MT safe.

Return type:bool

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 or None if no clock could be provided. Unref after usage.

MT safe.

Return type:Gst.Clock or None

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:query (Gst.Query) – the Gst.Query.
Returns:True if the query could be performed.

MT safe.

Return type:bool

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:
Returns:

True if the query could be performed.

dest_val:a pointer to the result.

Return type:

(bool, dest_val: int)

Queries an element to convert src_val in src_format to dest_format.

query_duration(format)[source]
Parameters:format (Gst.Format) – the Gst.Format requested
Returns:True if the query could be performed.
duration:A location in which to store the total duration, or None.
Return type:(bool, duration: int)

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) – the Gst.Format requested
Returns:True if the query could be performed.
cur:a location in which to store the current position, or None.
Return type:(bool, cur: int)

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]
Parameters:pad (Gst.Pad) – the Gst.Pad to release.

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.

remove_pad(pad)[source]
Parameters:pad (Gst.Pad) – the Gst.Pad to remove from the element.
Returns:True if the pad could be removed. Can return False if the pad does not belong to the provided element.

MT safe.

Return type:bool

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 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 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:
Returns:

requested Gst.Pad if found, otherwise None. Release after usage.

Return type:

Gst.Pad or None

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

seek(rate, format, flags, start_type, start, stop_type, stop)[source]
Parameters:
  • rate (float) – The new playback rate
  • format (Gst.Format) – The format of the seek values
  • flags (Gst.SeekFlags) – The optional seek flags.
  • start_type (Gst.SeekType) – The type and flags for the new start position
  • start (int) – The value of the new start position
  • stop_type (Gst.SeekType) – The type and flags for the new stop position
  • stop (int) – The value of the new stop position
Returns:

True if the event was handled. Flushing seeks will trigger a preroll, which will emit Gst.MessageType.ASYNC_DONE.

Return type:

bool

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.

seek_simple(format, seek_flags, seek_pos)[source]
Parameters:
Returns:

True if the seek operation succeeded. Flushing seeks will trigger a preroll, which will emit Gst.MessageType.ASYNC_DONE.

Return type:

bool

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

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

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

send_event(event)[source]
Parameters:event (Gst.Event) – the Gst.Event to send to the element.
Returns:True if the event was handled. Events that trigger a preroll (such as flushing seeks and steps) will emit Gst.MessageType.ASYNC_DONE.
Return type:bool

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]
Parameters:bus (Gst.Bus) – the Gst.Bus to set.

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) – the Gst.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:bool

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) – the Gst.Context to set.

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

MT safe.

set_locked_state(locked_state)[source]
Parameters:locked_state (bool) – 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.
Return type:bool

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

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 to Gst.CLOCK_TIME_NONE on such a toplevel element will disable the distribution of the base_time to the children and can be useful if the application manages the base_time itself, for example if you want to synchronize capture from multiple pipelines, and you can also ensure that the pipelines have the same clock.

MT safe.

set_state(state)[source]
Parameters:state (Gst.State) – the element’s new Gst.State.
Returns:Result of the state change using Gst.StateChangeReturn.

MT safe.

Return type:Gst.StateChangeReturn

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 use Gst.Element.get_state() to wait for the completion of the state change or it can wait for a Gst.MessageType.ASYNC_DONE or Gst.MessageType.STATE_CHANGED on the bus.

State changes to Gst.State.READY or Gst.State.NULL never return Gst.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:bool

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.

Parameters:dest (Gst.Element) – the sink Gst.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 using Gst.Element.release_request_pad().

Parameters:

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:Gst.StateChangeReturn

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 or Gst.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 or Gst.StateChangeReturn.FAILURE if the last state change failed.

MT safe.

state:a pointer to Gst.State to hold the state. Can be None.
pending:a pointer to Gst.State to hold the pending state. Can be None.
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 of Gst.StateChangeReturn.SUCCESS or Gst.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 in Gst.State.PLAYING. While the state change return is equivalent to Gst.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_pad_added(pad) virtual
Parameters:pad (Gst.Pad) –
do_pad_removed(pad) virtual
Parameters:pad (Gst.Pad) –
do_post_message(message) virtual
Parameters:message (Gst.Message) – a Gst.Message to post
Returns:True if the message was successfully posted. The function returns False if the element did not have a bus.

MT safe.

Return type:bool

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 or None if no clock could be provided. Unref after usage.

MT safe.

Return type:Gst.Clock or None

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:query (Gst.Query) – the Gst.Query.
Returns:True if the query could be performed.

MT safe.

Return type:bool

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) –
do_request_new_pad(templ, name, caps) virtual
Parameters:
Returns:

requested Gst.Pad if found, otherwise None. Release after usage.

Return type:

Gst.Pad or None

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:event (Gst.Event) – the Gst.Event to send to the element.
Returns:True if the event was handled. Events that trigger a preroll (such as flushing seeks and steps) will emit Gst.MessageType.ASYNC_DONE.
Return type:bool

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
Parameters:bus (Gst.Bus) – the Gst.Bus to set.

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) – the Gst.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:bool

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) – the Gst.Context to set.

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

MT safe.

do_set_state(state) virtual
Parameters:state (Gst.State) – the element’s new Gst.State.
Returns:Result of the state change using Gst.StateChangeReturn.

MT safe.

Return type:Gst.StateChangeReturn

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 use Gst.Element.get_state() to wait for the completion of the state change or it can wait for a Gst.MessageType.ASYNC_DONE or Gst.MessageType.STATE_CHANGED on the bus.

State changes to Gst.State.READY or Gst.State.NULL never return Gst.StateChangeReturn.ASYNC.

do_state_changed(oldstate, newstate, pending) virtual
Parameters:

Signal Details

Gst.Element.signals.no_more_pads(element)
Signal Name:no-more-pads
Flags:RUN_LAST
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:

RUN_LAST

Parameters:
  • element (Gst.Element) – The object which received the signal
  • new_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 with Gst.Element.set_state() or Gst.Element.sync_state_with_parent().

Gst.Element.signals.pad_removed(element, old_pad)
Signal Name:

pad-removed

Flags:

RUN_LAST

Parameters:
  • element (Gst.Element) – The object which received the signal
  • old_pad (Gst.Pad) – the pad that has been removed

a Gst.Pad has been removed from the element