Gst.Object

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

Subclasses:

Gst.Allocator, Gst.BufferPool, Gst.Bus, Gst.Clock, Gst.ControlBinding, Gst.ControlSource, Gst.Device, Gst.DeviceMonitor, Gst.DeviceProvider, Gst.Element, Gst.Pad, Gst.PadTemplate, Gst.Plugin, Gst.PluginFeature, Gst.Registry, Gst.Stream, Gst.StreamCollection, Gst.Task, Gst.TaskPool, Gst.Tracer, Gst.TracerRecord

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

check_uniqueness (list, name)

class

default_deep_notify (object, orig, pspec, excluded_props)

class

replace (oldobj, newobj)

add_control_binding (binding)

default_error (error, debug)

get_control_binding (property_name)

get_control_rate ()

get_g_value_array (property_name, timestamp, interval, values)

get_name ()

get_parent ()

get_path_string ()

get_value (property_name, timestamp)

has_active_control_bindings ()

has_ancestor (ancestor)

has_as_ancestor (ancestor)

has_as_parent (parent)

ref ()

remove_control_binding (binding)

set_control_binding_disabled (property_name, disabled)

set_control_bindings_disabled (disabled)

set_control_rate (control_rate)

set_name (name)

set_parent (parent)

suggest_next_sync ()

sync_values (timestamp)

unparent ()

unref ()

Virtual Methods

Inherited:

GObject.Object (7)

do_deep_notify (orig, pspec)

Properties

Name

Type

Flags

Short Description

name

str

r/w/c

The name of the object

parent

Gst.Object

r/w

The parent of the object

Signals

Inherited:

GObject.Object (1)

Name

Short Description

deep-notify

The deep notify signal is used to be notified of property changes.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

control_bindings

[object]

r

control_rate

int

r

flags

int

r

flags for this object

last_sync

int

r

lock

GLib.Mutex

r

object LOCK

name

str

r

The name of the object

object

GObject.InitiallyUnowned

r

parent

Gst.Object

r

this object’s parent, weak ref

Class Details

class Gst.Object(**kwargs)
Bases:

GObject.InitiallyUnowned

Abstract:

Yes

Structure:

Gst.ObjectClass

Gst.Object provides a root for the object hierarchy tree filed in by the GStreamer library. It is currently a thin wrapper on top of GObject.InitiallyUnowned. It is an abstract class that is not very usable on its own.

Gst.Object gives us basic refcounting, parenting functionality and locking. Most of the functions are just extended for special GStreamer needs and can be found under the same name in the base class of Gst.Object which is GObject.Object (e.g. GObject.Object.ref() becomes Gst.Object.ref()).

Since Gst.Object derives from GObject.InitiallyUnowned, it also inherits the floating reference. Be aware that functions such as Gst.Bin.add() and Gst.Element.add_pad() take ownership of the floating reference.

In contrast to GObject.Object instances, Gst.Object adds a name property. The functions Gst.Object.set_name() and Gst.Object.get_name() are used to set/get the name of the object.

controlled properties

Controlled properties offers a lightweight way to adjust gobject properties over stream-time. It works by using time-stamped value pairs that are queued for element-properties. At run-time the elements continuously pull value changes for the current stream-time.

What needs to be changed in a Gst.Element? Very little - it is just two steps to make a plugin controllable!

  • mark gobject-properties paramspecs that make sense to be controlled, by Gst.PARAM_CONTROLLABLE.

  • when processing data (get, chain, loop function) at the beginning call Gst.Object.sync_values(element,timestamp). This will make the controller update all GObject.Object properties that are under its control with the current values based on the timestamp.

What needs to be done in applications? Again it’s not a lot to change.

  • create a Gst.ControlSource. csource = gst_interpolation_control_source_new (); g_object_set (csource, “mode”, GST_INTERPOLATION_MODE_LINEAR, None);

  • Attach the Gst.ControlSource on the controller to a property. Gst.Object.add_control_binding (object, gst_direct_control_binding_new (object, “prop1”, csource));

  • Set the control values gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * Gst.SECOND, value1); gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * Gst.SECOND, value2);

  • start your pipeline

classmethod check_uniqueness(list, name)[source]
Parameters:
Returns:

True if a Gst.Object named name does not appear in list, False if it does.

MT safe. Grabs and releases the LOCK of each object in the list.

Return type:

bool

Checks to see if there is any object named name in list. This function does not do any locking of any kind. You might want to protect the provided list with the lock of the owner of the list. This function will lock each Gst.Object in the list to compare the name, so be careful when passing a list with a locked object.

classmethod default_deep_notify(object, orig, pspec, excluded_props)[source]
Parameters:

A default deep_notify signal callback for an object. The user data should contain a pointer to an array of strings that should be excluded from the notify. The default handler will print the new value of the property using g_print.

MT safe. This function grabs and releases object's LOCK for getting its path string.

classmethod replace(oldobj, newobj)[source]
Parameters:
Returns:

True if newobj was different from oldobj

oldobj:

pointer to a place of a Gst.Object to replace

Return type:

(bool, oldobj: Gst.Object or None)

Atomically modifies a pointer to point to a new object. The reference count of oldobj is decreased and the reference count of newobj is increased.

Either newobj and the value pointed to by oldobj may be None.

add_control_binding(binding)[source]
Parameters:

binding (Gst.ControlBinding) – the Gst.ControlBinding that should be used

Returns:

False if the given binding has not been setup for this object or has been setup for a non suitable property, True otherwise.

Return type:

bool

Attach the Gst.ControlBinding to the object. If there already was a Gst.ControlBinding for this property it will be replaced.

The object’s reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())

default_error(error, debug)[source]
Parameters:

A default error function that uses g_printerr() to display the error message and the optional debug string..

The default handler will simply print the error string using g_print.

get_control_binding(property_name)[source]
Parameters:

property_name (str) – name of the property

Returns:

the Gst.ControlBinding for property_name or None if the property is not controlled.

Return type:

Gst.ControlBinding or None

Gets the corresponding Gst.ControlBinding for the property. This should be unreferenced again after use.

get_control_rate()[source]
Returns:

the control rate in nanoseconds

Return type:

int

Obtain the control-rate for this self. Audio processing Gst.Element objects will use this rate to sub-divide their processing loop and call Gst.Object.sync_values() in between. The length of the processing segment should be up to control-rate nanoseconds.

If the self is not under property control, this will return Gst.CLOCK_TIME_NONE. This allows the element to avoid the sub-dividing.

The control-rate is not expected to change if the element is in Gst.State.PAUSED or Gst.State.PLAYING.

get_g_value_array(property_name, timestamp, interval, values)[source]
Parameters:
  • property_name (str) – the name of the property to get

  • timestamp (int) – the time that should be processed

  • interval (int) – the time spacing between subsequent values

  • values ([GObject.Value]) – array to put control-values in

Returns:

True if the given array could be filled, False otherwise

Return type:

bool

Gets a number of GObject.Values for the given controlled property starting at the requested time. The array values need to hold enough space for n_values of GObject.Value.

This function is useful if one wants to e.g. draw a graph of the control curve or apply a control curve sample by sample.

get_name()[source]
Returns:

the name of self. GLib.free() after usage.

MT safe. This function grabs and releases self's LOCK.

Return type:

str or None

Returns a copy of the name of self. Caller should GLib.free() the return value after usage. For a nameless object, this returns None, which you can safely GLib.free() as well.

Free-function: GLib.free

get_parent()[source]
Returns:

parent of self, this can be None if self has no parent. unref after usage.

MT safe. Grabs and releases self's LOCK.

Return type:

Gst.Object or None

Returns the parent of self. This function increases the refcount of the parent object so you should Gst.Object.unref() it after usage.

get_path_string()[source]
Returns:

a string describing the path of self. You must GLib.free() the string after usage.

MT safe. Grabs and releases the Gst.Object's LOCK for all objects in the hierarchy.

Return type:

str

Generates a string describing the path of self in the object hierarchy. Only useful (or used) for debugging.

Free-function: GLib.free

get_value(property_name, timestamp)[source]
Parameters:
  • property_name (str) – the name of the property to get

  • timestamp (int) – the time the control-change should be read from

Returns:

the GObject.Value of the property at the given time, or None if the property isn’t controlled.

Return type:

GObject.Value or None

Gets the value for the given controlled property at the requested time.

has_active_control_bindings()[source]
Returns:

True if the object has active controlled properties

Return type:

bool

Check if the self has active controlled properties.

has_ancestor(ancestor)[source]
Parameters:

ancestor (Gst.Object) – a Gst.Object to check as ancestor

Returns:

True if ancestor is an ancestor of self.

Return type:

bool

Check if self has an ancestor ancestor somewhere up in the hierarchy. One can e.g. check if a Gst.Element is inside a Gst.Pipeline.

Deprecated since version ???: Use Gst.Object.has_as_ancestor() instead. MT safe. Grabs and releases object's locks.

has_as_ancestor(ancestor)[source]
Parameters:

ancestor (Gst.Object) – a Gst.Object to check as ancestor

Returns:

True if ancestor is an ancestor of self.

MT safe. Grabs and releases self's locks.

Return type:

bool

Check if self has an ancestor ancestor somewhere up in the hierarchy. One can e.g. check if a Gst.Element is inside a Gst.Pipeline.

has_as_parent(parent)[source]
Parameters:

parent (Gst.Object) – a Gst.Object to check as parent

Returns:

False if either self or parent is None. True if parent is the parent of self. Otherwise False.

MT safe. Grabs and releases self's locks.

Return type:

bool

Check if parent is the parent of self. E.g. a Gst.Element can check if it owns a given Gst.Pad.

New in version 1.6.

ref()[source]
Returns:

A pointer to self

Return type:

Gst.Object

Increments the reference count on self. This function does not take the lock on self because it relies on atomic refcounting.

This object returns the input parameter to ease writing constructs like : result = Gst.Object.ref (object->parent);

remove_control_binding(binding)[source]
Parameters:

binding (Gst.ControlBinding) – the binding

Returns:

True if the binding could be removed.

Return type:

bool

Removes the corresponding Gst.ControlBinding. If it was the last ref of the binding, it will be disposed.

set_control_binding_disabled(property_name, disabled)[source]
Parameters:
  • property_name (str) – property to disable

  • disabled (bool) – boolean that specifies whether to disable the controller or not.

This function is used to disable the control bindings on a property for some time, i.e. Gst.Object.sync_values() will do nothing for the property.

set_control_bindings_disabled(disabled)[source]
Parameters:

disabled (bool) – boolean that specifies whether to disable the controller or not.

This function is used to disable all controlled properties of the self for some time, i.e. Gst.Object.sync_values() will do nothing.

set_control_rate(control_rate)[source]
Parameters:

control_rate (int) – the new control-rate in nanoseconds.

Change the control-rate for this self. Audio processing Gst.Element objects will use this rate to sub-divide their processing loop and call Gst.Object.sync_values() in between. The length of the processing segment should be up to control-rate nanoseconds.

The control-rate should not change if the element is in Gst.State.PAUSED or Gst.State.PLAYING.

set_name(name)[source]
Parameters:

name (str or None) – new name of object

Returns:

True if the name could be set. Since Objects that have a parent cannot be renamed, this function returns False in those cases.

MT safe. This function grabs and releases self's LOCK.

Return type:

bool

Sets the name of self, or gives self a guaranteed unique name (if name is None). This function makes a copy of the provided name, so the caller retains ownership of the name it sent.

set_parent(parent)[source]
Parameters:

parent (Gst.Object) – new parent of object

Returns:

True if parent could be set or False when self already had a parent or self and parent are the same.

MT safe. Grabs and releases self's LOCK.

Return type:

bool

Sets the parent of self to parent. The object’s reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink()).

suggest_next_sync()[source]
Returns:

Returns the suggested timestamp or Gst.CLOCK_TIME_NONE if no control-rate was set.

Return type:

int

Returns a suggestion for timestamps where buffers should be split to get best controller results.

sync_values(timestamp)[source]
Parameters:

timestamp (int) – the time that should be processed

Returns:

True if the controller values could be applied to the object properties, False otherwise

Return type:

bool

Sets the properties of the object, according to the Gst.ControlSources that (maybe) handle them and for the given timestamp.

If this function fails, it is most likely the application developers fault. Most probably the control sources are not setup correctly.

unparent()[source]

Clear the parent of self, removing the associated reference. This function decreases the refcount of self.

MT safe. Grabs and releases self's lock.

unref()[source]

Decrements the reference count on self. If reference count hits zero, destroy self. This function does not take the lock on self as it relies on atomic refcounting.

The unref method should never be called with the LOCK held since this might deadlock the dispose function.

do_deep_notify(orig, pspec) virtual
Parameters:

default signal handler

Signal Details

Gst.Object.signals.deep_notify(object, prop_object, prop)
Signal Name:

deep-notify

Flags:

RUN_FIRST, NO_RECURSE, DETAILED, NO_HOOKS

Parameters:

The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.

Property Details

Gst.Object.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The name of the object

Gst.Object.props.parent
Name:

parent

Type:

Gst.Object

Default Value:

None

Flags:

READABLE, WRITABLE

The parent of the object. Please note, that when changing the ‘parent’ property, we don’t emit GObject.Object ::notify and Gst.Object ::deep-notify signals due to locking issues. In some cases one can use Gst.Bin ::element-added or Gst.Bin ::element-removed signals on the parent to achieve a similar effect.