| GStreamer 0.10 Core Reference Manual | ||||
|---|---|---|---|---|
#include <gst/gst.h>
GstObject;
enum GstObjectFlags;
#define GST_OBJECT_FLAGS (obj)
#define GST_OBJECT_FLAG_IS_SET (obj,flag)
#define GST_OBJECT_FLAG_SET (obj,flag)
#define GST_OBJECT_FLAG_UNSET (obj,flag)
#define GST_OBJECT_NAME (obj)
#define GST_OBJECT_PARENT (obj)
#define GST_OBJECT_IS_DISPOSING (obj)
#define GST_OBJECT_IS_FLOATING (obj)
#define GST_OBJECT_REFCOUNT (obj)
#define GST_OBJECT_REFCOUNT_VALUE (obj)
#define GST_CLASS_GET_LOCK (obj)
#define GST_CLASS_LOCK (obj)
#define GST_CLASS_TRYLOCK (obj)
#define GST_CLASS_UNLOCK (obj)
#define GST_OBJECT_LOCK (obj)
#define GST_OBJECT_TRYLOCK (obj)
#define GST_OBJECT_UNLOCK (obj)
#define GST_OBJECT_GET_LOCK (obj)
gboolean gst_object_set_name (GstObject *object,
const gchar *name);
gchar* gst_object_get_name (GstObject *object);
gboolean gst_object_set_parent (GstObject *object,
GstObject *parent);
GstObject* gst_object_get_parent (GstObject *object);
void gst_object_unparent (GstObject *object);
gchar* gst_object_get_name_prefix (GstObject *object);
void gst_object_set_name_prefix (GstObject *object,
const gchar *name_prefix);
void gst_object_default_deep_notify (GObject *object,
GstObject *orig,
GParamSpec *pspec,
gchar **excluded_props);
void gst_object_default_error (GstObject *source,
GError *error,
gchar *debug);
gboolean gst_object_check_uniqueness (GList *list,
const gchar *name);
gboolean gst_object_has_ancestor (GstObject *object,
GstObject *ancestor);
GstXmlNodePtr gst_object_save_thyself (GstObject *object,
GstXmlNodePtr parent);
void gst_object_restore_thyself (GstObject *object,
GstXmlNodePtr self);
gpointer gst_object_ref (gpointer object);
void gst_object_unref (gpointer object);
void gst_object_sink (gpointer object);
void gst_object_replace (GstObject **oldobj,
GstObject *newobj);
gchar* gst_object_get_path_string (GstObject *object);
guint gst_class_signal_connect (GstObjectClass *klass,
const gchar *name,
gpointer func,
gpointer func_data);
void gst_class_signal_emit_by_name (GstObject *object,
const gchar *name,
GstXmlNodePtr self);
GObject
+----GstObject
+----GstPad
+----GstPluginFeature
+----GstElement
+----GstPlugin
+----GstRegistry
+----GstBus
+----GstClock
+----GstIndex
+----GstPadTemplate
+----GstTask
+----GstXML
"deep-notify" void user_function (GstObject *gstobject, GObject *prop_object, GParamSpec *prop, gpointer user_data) : Run first / No recursion / Has details / No hooks "object-saved" void user_function (GstObject *gstobject, gpointer xml_node, gpointer user_data) : Run last "parent-set" void user_function (GstObject *gstobject, GObject *parent, gpointer user_data) : Run last "parent-unset" void user_function (GstObject *gstobject, GObject *parent, gpointer user_data) : Run last
GstObject provides a root for the object hierarchy tree filed in by the GStreamer library. It is currently a thin wrapper on top of GObject. It is an abstract class that is not very usable on its own.
GstObject gives us basic refcounting, parenting functionality and locking.
Most of the function are just extended for special GStreamer needs and can be
found under the same name in the base class of GstObject which is GObject
(e.g. g_object_ref() becomes gst_object_ref()).
The most interesting difference between GstObject and GObject is the
"floating" reference count. A GObject is created with a reference count of
1, owned by the creator of the GObject. (The owner of a reference is the
code section that has the right to call gst_object_unref() in order to
remove that reference.) A GstObject is created with a reference count of 1
also, but it isn't owned by anyone; Instead, the initial reference count
of a GstObject is "floating". The floating reference can be removed by
anyone at any time, by calling gst_object_sink(). gst_object_sink() does
nothing if an object is already sunk (has no floating reference).
When you add a GstElement to its parent container, the parent container will do this:
gst_object_ref (GST_OBJECT (child_element)); gst_object_sink (GST_OBJECT (child_element));
This means that the container now owns a reference to the child element
(since it called gst_object_ref()), and the child element has no floating
reference.
The purpose of the floating reference is to keep the child element alive until you add it to a parent container, which then manages the lifetime of the object itself:
element = gst_element_factory_make (factoryname, name); // element has one floating reference to keep it alive gst_bin_add (GST_BIN (bin), element); // element has one non-floating reference owned by the container
Another effect of this is, that calling gst_object_unref() on a bin object,
will also destoy all the GstElement objects in it. The same is true for
calling gst_bin_remove().
Special care has to be taken for all methods that gst_object_sink() an object
since if the caller of those functions had a floating reference to the object,
the object reference is now invalid.
In contrast to GObject instances, GstObject 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.
Last reviewed on 2005-11-09 (0.9.4)
typedef struct {
gint refcount;
GMutex *lock; /* object LOCK */
gchar *name; /* object name */
gchar *name_prefix; /* used for debugging */
GstObject *parent; /* this object's parent, weak ref */
guint32 flags;
} GstObject;
GStreamer base object class.
refcount;gintrefcount unused
unused
GMutex *lock;GMutexlock object LOCK
object LOCK
gchar *name;gcharname The name of the object
The name of the object
gchar *name_prefix;gcharname_prefix used for debugging
used for debugging
GstObject *parent;GstObjectparent this object's parent, weak ref
this object's parent, weak ref
guint32 flags;guint32flags use GST_OBJECT_IS_XXX macros to access the flags
use GST_OBJECT_IS_XXX macros to access the flags
gint refcount; |
unused |
GMutex *lock; |
object LOCK |
gchar *name; |
The name of the object |
gchar *name_prefix; |
used for debugging |
GstObject *parent; |
this object's parent, weak ref |
guint32 flags; |
use GST_OBJECT_IS_XXX macros to access the flags |
typedef enum
{
GST_OBJECT_DISPOSING = (1<<0),
GST_OBJECT_FLOATING = (1<<1),
/* padding */
GST_OBJECT_FLAG_LAST = (1<<4)
} GstObjectFlags;
The standard flags that an gstobject may have.
GST_OBJECT_DISPOSINGGST_OBJECT_DISPOSING the object is been destroyed, do use it anymore
the object is been destroyed, do use it anymore
GST_OBJECT_FLOATINGGST_OBJECT_FLOATING the object has a floating reference count (e.g. its
not assigned to a bin)
the object has a floating reference count (e.g. its
not assigned to a bin)
GST_OBJECT_FLAG_LASTGST_OBJECT_FLAG_LAST subclasses can add additional flags starting from this flag
subclasses can add additional flags starting from this flag
#define GST_OBJECT_FLAGS(obj) (GST_OBJECT_CAST (obj)->flags)
This macro returns the entire set of flags for the object.
#define GST_OBJECT_FLAG_IS_SET(obj,flag) ((GST_OBJECT_FLAGS (obj) & (flag)) == (flag))
This macro checks to see if the given flag is set.
#define GST_OBJECT_FLAG_SET(obj,flag) (GST_OBJECT_FLAGS (obj) |= (flag))
This macro sets the given bits.
#define GST_OBJECT_FLAG_UNSET(obj,flag) (GST_OBJECT_FLAGS (obj) &= ~(flag))
This macro usets the given bits.
#define GST_OBJECT_NAME(obj) (GST_OBJECT_CAST(obj)->name)
Get the name of this object
#define GST_OBJECT_PARENT(obj) (GST_OBJECT_CAST(obj)->parent)
Get the parent of this object
#define GST_OBJECT_IS_DISPOSING(obj) (GST_OBJECT_FLAG_IS_SET (obj, GST_OBJECT_DISPOSING))
Check if the given object is beeing destroyed.
#define GST_OBJECT_IS_FLOATING(obj) (GST_OBJECT_FLAG_IS_SET (obj, GST_OBJECT_FLOATING))
Check if the given object is floating (has no owner).
#define GST_OBJECT_REFCOUNT(obj) (((GObject*)(obj))->ref_count)
Get access to the reference count field of the object.
#define GST_OBJECT_REFCOUNT_VALUE(obj) g_atomic_int_get ((gint *) &GST_OBJECT_REFCOUNT(obj))
Get the reference count value of the object.
#define GST_CLASS_GET_LOCK(obj) (GST_OBJECT_CLASS_CAST(obj)->lock)
This macro will return the class lock used to protect deep_notify signal emission on thread-unsafe glib versions (glib < 2.8).
obj :obj a GstObjectClass
a GstObjectClass
GstObjectClassGstObjectClass
obj : |
a GstObjectClass |
#define GST_CLASS_LOCK(obj) (g_static_rec_mutex_lock(GST_CLASS_GET_LOCK(obj)))
Lock the class.
obj :obj a GstObjectClass
a GstObjectClass
GstObjectClassGstObjectClass
obj : |
a GstObjectClass |
#define GST_CLASS_TRYLOCK(obj) (g_static_rec_mutex_trylock(GST_CLASS_GET_LOCK(obj)))
Try to lock the class, returns TRUE if class could be locked.
obj :obj a GstObjectClass
a GstObjectClass
GstObjectClassGstObjectClass
obj : |
a GstObjectClass |
#define GST_CLASS_UNLOCK(obj) (g_static_rec_mutex_unlock(GST_CLASS_GET_LOCK(obj)))
Unlock the class.
obj :obj a GstObjectClass
a GstObjectClass
GstObjectClassGstObjectClass
obj : |
a GstObjectClass |
#define GST_OBJECT_LOCK(obj) g_mutex_lock(GST_OBJECT_GET_LOCK(obj))
This macro will obtain a lock on the object, making serialization possible. It blocks until the lock can be obtained.
#define GST_OBJECT_TRYLOCK(obj) g_mutex_trylock(GST_OBJECT_GET_LOCK(obj))
This macro will try to obtain a lock on the object, but will return with FALSE if it can't get it immediately.
obj :obj a Object.
a Object.
ObjectObject
obj : |
a Object. |
#define GST_OBJECT_UNLOCK(obj) g_mutex_unlock(GST_OBJECT_GET_LOCK(obj))
This macro releases a lock on the object.
#define GST_OBJECT_GET_LOCK(obj) (GST_OBJECT_CAST(obj)->lock)
Acquire a reference to the mutex of this object.
gboolean gst_object_set_name (GstObject *object, const gchar *name);
Sets the name of object, or gives object a guaranteed unique
name (if name is NULL).
This function makes a copy of the provided name, so the caller
retains ownership of the name it sent.
object :object a GstObject
a GstObject
GstObjectGstObjectname :name new name of object
new name of object
Returns :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 object's LOCK.
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 object's LOCK.
object
object : |
a GstObject |
name : |
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 object's LOCK.
|
gchar* gst_object_get_name (GstObject *object);
Returns a copy of the name of object.
Caller should g_free() the return value after usage.
For a nameless object, this returns NULL, which you can safely g_free()
as well.
object :object a GstObject
a GstObject
GstObjectGstObjectReturns :Returns the name of object. g_free() after usage.
MT safe. This function grabs and releases object's LOCK.
the name of object. g_free() after usage.
MT safe. This function grabs and releases object's LOCK.
objectg_free()g_free()object
object : |
a GstObject |
| Returns : | the name of object. g_free() after usage.
MT safe. This function grabs and releases object's LOCK.
|
gboolean gst_object_set_parent (GstObject *object, GstObject *parent);
Sets the parent of object to parent. The object's reference count will
be incremented, and any floating reference will be removed (see gst_object_sink()).
This function causes the parent-set signal to be emitted when the parent was successfully set.
object :object a GstObject
a GstObject
GstObjectGstObjectparent :parent new parent of object
new parent of object
Returns :Returns TRUE if parent could be set or FALSE when object
already had a parent or object and parent are the same.
MT safe. Grabs and releases object's LOCK.
TRUE if parent could be set or FALSE when object
already had a parent or object and parent are the same.
MT safe. Grabs and releases object's LOCK.
parentobjectobjectparentobject
object : |
a GstObject |
parent : |
new parent of object |
| Returns : | TRUE if parent could be set or FALSE when object
already had a parent or object and parent are the same.
MT safe. Grabs and releases object's LOCK.
|
GstObject* gst_object_get_parent (GstObject *object);
Returns the parent of object. This function increases the refcount
of the parent object so you should gst_object_unref() it after usage.
object :object a GstObject
a GstObject
GstObjectGstObjectReturns :Returns parent of object, this can be NULL if object has no
parent. unref after usage.
MT safe. Grabs and releases object's LOCK.
parent of object, this can be NULL if object has no
parent. unref after usage.
MT safe. Grabs and releases object's LOCK.
objectobjectobject
object : |
a GstObject |
| Returns : | parent of object, this can be NULL if object has no
parent. unref after usage.
MT safe. Grabs and releases object's LOCK.
|
void gst_object_unparent (GstObject *object);
Clear the parent of object, removing the associated reference.
This function decreases the refcount of object.
MT safe. Grabs and releases object's lock.
gchar* gst_object_get_name_prefix (GstObject *object);
Returns a copy of the name prefix of object.
Caller should g_free() the return value after usage.
For a prefixless object, this returns NULL, which you can safely g_free()
as well.
object :object a GstObject
a GstObject
GstObjectGstObjectReturns :Returns the name prefix of object. g_free() after usage.
MT safe. This function grabs and releases object's LOCK.
the name prefix of object. g_free() after usage.
MT safe. This function grabs and releases object's LOCK.
objectg_free()g_free()object
object : |
a GstObject |
| Returns : | the name prefix of object. g_free() after usage.
MT safe. This function grabs and releases object's LOCK.
|
void gst_object_set_name_prefix (GstObject *object, const gchar *name_prefix);
Sets the name prefix of object to name_prefix.
This function makes a copy of the provided name prefix, so the caller
retains ownership of the name prefix it sent.
MT safe. This function grabs and releases object's LOCK.
void gst_object_default_deep_notify (GObject *object,
GstObject *orig,
GParamSpec *pspec,
gchar **excluded_props);
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.
object :object the GObject that signalled the notify.
the GObject that signalled the notify.
GObjectGObjectorig :orig a GstObject that initiated the notify.
a GstObject that initiated the notify.
GstObjectGstObjectpspec :pspec a GParamSpec of the property.
a GParamSpec of the property.
GParamSpecGParamSpecexcluded_props :excluded_props a set of user-specified properties to exclude or
NULL to show all changes.
a set of user-specified properties to exclude or
NULL to show all changes.
object : |
the GObject that signalled the notify. |
orig : |
a GstObject that initiated the notify. |
pspec : |
a GParamSpec of the property. |
excluded_props : |
a set of user-specified properties to exclude or NULL to show all changes. |
void gst_object_default_error (GstObject *source, GError *error, gchar *debug);
A default error function.
The default handler will simply print the error string using g_print.
source :source the GstObject that initiated the error.
the GstObject that initiated the error.
GstObjectGstObjecterror :error the GError.
the GError.
debug :debug an additional debug information string, or NULL.
an additional debug information string, or NULL.
source : |
the GstObject that initiated the error. |
error : |
the GError. |
debug : |
an additional debug information string, or NULL. |
gboolean gst_object_check_uniqueness (GList *list,
const gchar *name);
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 GstObject in the list to compare the name, so be
carefull when passing a list with a locked object.
list :list a list of GstObject to check through
a list of GstObject to check through
GstObjectGstObjectname :name the name to search for
the name to search for
Returns :Returns TRUE if a GstObject named name does not appear in list,
FALSE if it does.
MT safe. Grabs and releases the LOCK of each object in the list.
TRUE if a GstObject named name does not appear in list,
FALSE if it does.
MT safe. Grabs and releases the LOCK of each object in the list.
GstObjectGstObjectnamelist
list : |
a list of GstObject to check through |
name : |
the name to search for |
| Returns : | TRUE if a GstObject named name does not appear in list,
FALSE if it does.
MT safe. Grabs and releases the LOCK of each object in the list.
|
gboolean gst_object_has_ancestor (GstObject *object, GstObject *ancestor);
Check if object has an ancestor ancestor somewhere up in
the hierarchy.
object :object a GstObject to check
a GstObject to check
GstObjectGstObjectancestor :ancestor a GstObject to check as ancestor
a GstObject to check as ancestor
GstObjectGstObjectReturns :Returns TRUE if ancestor is an ancestor of object.
MT safe. Grabs and releases object's locks.
TRUE if ancestor is an ancestor of object.
MT safe. Grabs and releases object's locks.
ancestorobjectobject
object : |
a GstObject to check |
ancestor : |
a GstObject to check as ancestor |
| Returns : | TRUE if ancestor is an ancestor of object.
MT safe. Grabs and releases object's locks.
|
GstXmlNodePtr gst_object_save_thyself (GstObject *object, GstXmlNodePtr parent);
Saves object into the parent XML node.
object :object a GstObject to save
a GstObject to save
GstObjectGstObjectparent :parent The parent XML node to save object into
The parent XML node to save object into
objectReturns :Returns the new xmlNodePtr with the saved object
the new xmlNodePtr with the saved object
object : |
a GstObject to save |
parent : |
The parent XML node to save object into
|
| Returns : | the new xmlNodePtr with the saved object |
void gst_object_restore_thyself (GstObject *object, GstXmlNodePtr self);
Restores object with the data from the parent XML node.
gpointer gst_object_ref (gpointer object);
Increments the refence count on object. This function
does not take the lock on object because it relies on
atomic refcounting.
This object returns the input parameter to ease writing constructs like : result = gst_object_ref (object->parent);
void gst_object_unref (gpointer object);
Decrements the refence count on object. If reference count hits
zero, destroy object. This function does not take the lock
on object as it relies on atomic refcounting.
The unref method should never be called with the LOCK held since this might deadlock the dispose function.
void gst_object_sink (gpointer object);
If object was floating, the GST_OBJECT_FLOATING flag is removed
and object is unreffed. When object was not floating,
this function does nothing.
Any newly created object has a refcount of 1 and is floating.
This function should be used when creating a new object to
symbolically 'take ownership' of object. This done by first doing a
gst_object_ref() to keep a reference to object and then gst_object_sink()
to remove and unref any floating references to object.
Use gst_object_set_parent() to have this done for you.
MT safe. This function grabs and releases object lock.
void gst_object_replace (GstObject **oldobj, GstObject *newobj);
Unrefs the GstObject pointed to by oldobj, refs newobj and
puts newobj in *oldobj. Be carefull when calling this
function, it does not take any locks. You might want to lock
the object owning oldobj pointer before calling this
function.
Make sure not to LOCK oldobj because it might be unreffed
which could cause a deadlock when it is disposed.
gchar* gst_object_get_path_string (GstObject *object);
Generates a string describing the path of object in
the object hierarchy. Only useful (or used) for debugging.
object :object a GstObject
a GstObject
GstObjectGstObjectReturns :Returns a string describing the path of object. You must
g_free() the string after usage.
MT safe. Grabs and releases the GstObject's LOCK for all objects
in the hierarchy.
a string describing the path of object. You must
g_free() the string after usage.
MT safe. Grabs and releases the GstObject's LOCK for all objects
in the hierarchy.
objectg_free()g_free()GstObjectGstObject
object : |
a GstObject |
| Returns : | a string describing the path of object. You must
g_free() the string after usage.
MT safe. Grabs and releases the GstObject's LOCK for all objects
in the hierarchy.
|
guint gst_class_signal_connect (GstObjectClass *klass,
const gchar *name,
gpointer func,
gpointer func_data);
Connect to a class signal.
klass :klass a GstObjectClass to attach the signal to
a GstObjectClass to attach the signal to
GstObjectClassGstObjectClassname :name the name of the signal to attach to
the name of the signal to attach to
func :func the signal function
the signal function
func_data :func_data a pointer to user data
a pointer to user data
Returns :Returns the signal id.
the signal id.
klass : |
a GstObjectClass to attach the signal to |
name : |
the name of the signal to attach to |
func : |
the signal function |
func_data : |
a pointer to user data |
| Returns : | the signal id. |
void gst_class_signal_emit_by_name (GstObject *object, const gchar *name, GstXmlNodePtr self);
emits the named class signal.
object :object a GstObject that emits the signal
a GstObject that emits the signal
GstObjectGstObjectname :name the name of the signal to emit
the name of the signal to emit
self :self data for the signal
data for the signal
object : |
a GstObject that emits the signal |
name : |
the name of the signal to emit |
self : |
data for the signal |
void user_function (GstObject *gstobject, GObject *prop_object, GParamSpec *prop, gpointer user_data) : Run first / No recursion / Has details / No hooks
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.
gstobject :gstobject a GstObject
a GstObject
GstObjectGstObjectprop_object :prop_object the object that originated the signal
the object that originated the signal
prop :prop the property that changed
the property that changed
user_data :user_datauser data set when the signal handler was connected.user data set when the signal handler was connected.
gstobject : |
a GstObject |
prop_object : |
the object that originated the signal |
prop : |
the property that changed |
user_data : |
user data set when the signal handler was connected. |
void user_function (GstObject *gstobject, gpointer xml_node, gpointer user_data) : Run last
Trigered whenever a new object is saved to XML. You can connect to this signal to insert custom XML tags into the core XML.
gstobject :gstobject a GstObject
a GstObject
GstObjectGstObjectxml_node :xml_node the xmlNodePtr of the parent node
the xmlNodePtr of the parent node
user_data :user_datauser data set when the signal handler was connected.user data set when the signal handler was connected.
gstobject : |
a GstObject |
xml_node : |
the xmlNodePtr of the parent node |
user_data : |
user data set when the signal handler was connected. |
void user_function (GstObject *gstobject, GObject *parent, gpointer user_data) : Run last
Emitted when the parent of an object is set.
gstobject :gstobject a GstObject
a GstObject
GstObjectGstObjectparent :parent the new parent
the new parent
user_data :user_datauser data set when the signal handler was connected.user data set when the signal handler was connected.
gstobject : |
a GstObject |
parent : |
the new parent |
user_data : |
user data set when the signal handler was connected. |
void user_function (GstObject *gstobject, GObject *parent, gpointer user_data) : Run last
Emitted when the parent of an object is unset.
gstobject :gstobject a GstObject
a GstObject
GstObjectGstObjectparent :parent the old parent
the old parent
user_data :user_datauser data set when the signal handler was connected.user data set when the signal handler was connected.
gstobject : |
a GstObject |
parent : |
the old parent |
user_data : |
user data set when the signal handler was connected. |