Gst.MiniObject

Fields

Name

Type

Access

Description

copy

Gst.MiniObjectCopyFunction

r/w

a copy function

dispose

Gst.MiniObjectDisposeFunction

r/w

a dispose function

flags

int

r/w

extra flags.

free

Gst.MiniObjectFreeFunction

r/w

the free function

lockstate

int

r/w

atomic state of the locks

priv_pointer

object

r

priv_uint

int

r

refcount

int

r/w

atomic refcount

type

GObject.GType

r/w

the GObject.GType of the object

Methods

class

replace (olddata, newdata)

class

take (olddata, newdata)

add_parent (parent)

get_qdata (quark)

is_writable ()

lock (flags)

remove_parent (parent)

set_qdata (quark, data, destroy)

steal_qdata (quark)

unlock (flags)

Details

class Gst.MiniObject

Gst.MiniObject is a simple structure that can be used to implement refcounted types.

Subclasses will include Gst.MiniObject as the first member in their structure and then call gst_mini_object_init() to initialize the Gst.MiniObject fields.

gst_mini_object_ref() and gst_mini_object_unref() increment and decrement the refcount respectively. When the refcount of a mini-object reaches 0, the dispose function is called first and when this returns True, the free function of the miniobject is called.

A copy can be made with Gst.MiniObject.copy().

Gst.MiniObject.is_writable() will return True when the refcount of the object is exactly 1 and there is no parent or a single parent exists and is writable itself, meaning the current caller has the only reference to the object. gst_mini_object_make_writable() will return a writable version of the object, which might be a new copy when the refcount was not 1.

Opaque data can be associated with a Gst.MiniObject with Gst.MiniObject.set_qdata() and Gst.MiniObject.get_qdata(). The data is meant to be specific to the particular object and is not automatically copied with Gst.MiniObject.copy() or similar methods.

A weak reference can be added and remove with gst_mini_object_weak_ref() and gst_mini_object_weak_unref() respectively.

classmethod replace(olddata, newdata)[source]
Parameters:
Returns:

True if newdata was different from olddata

olddata:

pointer to a pointer to a mini-object to be replaced

Return type:

(bool, olddata: Gst.MiniObject or None)

Atomically modifies a pointer to point to a new mini-object. The reference count of olddata is decreased and the reference count of newdata is increased.

Either newdata and the value pointed to by olddata may be None.

classmethod take(olddata, newdata)[source]
Parameters:
Returns:

True if newdata was different from olddata

olddata:

pointer to a pointer to a mini-object to be replaced

Return type:

(bool, olddata: Gst.MiniObject)

Modifies a pointer to point to a new mini-object. The modification is done atomically. This version is similar to Gst.MiniObject.replace() except that it does not increase the refcount of newdata and thus takes ownership of newdata.

Either newdata and the value pointed to by olddata may be None.

add_parent(parent)[source]
Parameters:

parent (Gst.MiniObject) – a parent Gst.MiniObject

This adds parent as a parent for self. Having one ore more parents affects the writability of self: if a parent is not writable, self is also not writable, regardless of its refcount. self is only writable if all the parents are writable and its own refcount is exactly 1.

Note: This function does not take ownership of parent and also does not take an additional reference. It is the responsibility of the caller to remove the parent again at a later time.

New in version 1.16.

get_qdata(quark)[source]
Parameters:

quark (int) – A #GQuark, naming the user data pointer

Returns:

The user data pointer set, or None

Return type:

object or None

This function gets back user data pointers stored via Gst.MiniObject.set_qdata().

is_writable()[source]
Returns:

True if the object is writable.

Return type:

bool

If self has the LOCKABLE flag set, check if the current EXCLUSIVE lock on object is the only one, this means that changes to the object will not be visible to any other object.

If the LOCKABLE flag is not set, check if the refcount of self is exactly 1, meaning that no other reference exists to the object and that the object is therefore writable.

Modification of a mini-object should only be done after verifying that it is writable.

lock(flags)[source]
Parameters:

flags (Gst.LockFlags) – Gst.LockFlags

Returns:

True if self could be locked.

Return type:

bool

Lock the mini-object with the specified access mode in flags.

remove_parent(parent)[source]
Parameters:

parent (Gst.MiniObject) – a parent Gst.MiniObject

This removes parent as a parent for self. See Gst.MiniObject.add_parent().

New in version 1.16.

set_qdata(quark, data, destroy)[source]
Parameters:
  • quark (int) – A #GQuark, naming the user data pointer

  • data (object or None) – An opaque user data pointer

  • destroy (GLib.DestroyNotify) – Function to invoke with data as argument, when data needs to be freed

This sets an opaque, named pointer on a miniobject. The name is specified through a #GQuark (retrieved e.g. via GLib.quark_from_static_string()), and the pointer can be gotten back from the self with Gst.MiniObject.get_qdata() until the self is disposed. Setting a previously set user data pointer, overrides (frees) the old pointer set, using None as pointer essentially removes the data stored.

destroy may be specified which is called with data as argument when the self is disposed, or the data is being overwritten by a call to Gst.MiniObject.set_qdata() with the same quark.

steal_qdata(quark)[source]
Parameters:

quark (int) – A #GQuark, naming the user data pointer

Returns:

The user data pointer set, or None

Return type:

object or None

This function gets back user data pointers stored via Gst.MiniObject.set_qdata() and removes the data from self without invoking its destroy() function (if any was set).

unlock(flags)[source]
Parameters:

flags (Gst.LockFlags) – Gst.LockFlags

Unlock the mini-object with the specified access mode in flags.