MiniObject

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

Subclasses will include gstreamer.MiniObject as the first member in their structure and then call MiniObject.init to initialize the gstreamer.MiniObject fields.

MiniObject.ref and MiniObject.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 MiniObject.copy.

MiniObject.isWritable 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. MiniObject.makeWritable 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 gstreamer.MiniObject with MiniObject.setQdata and MiniObject.getQdata. The data is meant to be specific to the particular object and is not automatically copied with MiniObject.copy or similar methods.

A weak reference can be added and remove with MiniObject.weakRef and MiniObject.weakUnref respectively.

Constructors

this
this(GstMiniObject* gstMiniObject, bool ownedRef)

Sets our main struct and passes it to the parent class.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

addParent
void addParent(MiniObject parent)

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

copy
MiniObject copy()

Creates a copy of the mini-object.

getMiniObjectStruct
GstMiniObject* getMiniObjectStruct(bool transferOwnership)

Get the main Gtk struct

getQdata
void* getQdata(GQuark quark)

This function gets back user data pointers stored via MiniObject.setQdata.

getStruct
void* getStruct()

the main Gtk struct as a void*

init
void init(uint flags, GType type, GstMiniObjectCopyFunction copyFunc, GstMiniObjectDisposeFunction disposeFunc, GstMiniObjectFreeFunction freeFunc)

Initializes a mini-object with the desired type and copy/dispose/free functions.

isWritable
bool isWritable()

If mini_object 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.

lock
bool lock(GstLockFlags flags)

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

makeWritable
MiniObject makeWritable()

Checks if a mini-object is writable. If not, a writable copy is made and returned. This gives away the reference to the original mini object, and returns a reference to the new object.

ref_
MiniObject ref_()

Increase the reference count of the mini-object.

removeParent
void removeParent(MiniObject parent)

This removes parent as a parent for object. See MiniObject.addParent.

setQdata
void setQdata(GQuark quark, void* data, GDestroyNotify destroy)

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

stealQdata
void* stealQdata(GQuark quark)

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

unlock
void unlock(GstLockFlags flags)

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

unref
void unref()

Decreases the reference count of the mini-object, possibly freeing the mini-object.

weakRef
void weakRef(GstMiniObjectNotify notify, void* data)

Adds a weak reference callback to a mini object. Weak references are used for notification when a mini object is finalized. They are called "weak references" because they allow you to safely hold a pointer to the mini object without calling MiniObject.ref (MiniObject.ref adds a strong reference, that is, forces the object to stay alive).

weakUnref
void weakUnref(GstMiniObjectNotify notify, void* data)

Removes a weak reference callback from a mini object.

Static functions

replace
bool replace(MiniObject olddata, MiniObject newdata)

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.

steal
MiniObject steal(MiniObject olddata)

Replace the current gstreamer.MiniObject pointer to by olddata with NULL and return the old value.

take
bool take(MiniObject olddata, MiniObject newdata)

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

Variables

gstMiniObject
GstMiniObject* gstMiniObject;

the main Gtk struct