Next: GstPadTemplate, Previous: GstMiniObject, Up: Top
Base class for the GStreamer object hierarchy
<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>
. 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 function 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>
(e.g. g-object-ref
becomes gst-object-ref
).
The most interesting difference between <gst-object>
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
<gst-object>
is created with a reference count of 1 also, but it isn't
owned by anyone; Instead, the initial reference count of a <gst-object>
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 <gst-element>
to its parent container, the parent
container will do this: 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.
gst_object_ref (GST_OBJECT (child_element)); gst_object_sink (GST_OBJECT (child_element));
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 <gst-element>
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, <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.
Last reviewed on 2005-11-09 (0.9.4)
This
<gobject>
class defines the following properties:
name
- The name of the object
<gobject>
)Emitted when the parent of an object is unset.
<gpointer>
)Trigered whenever a new object is saved to XML. You can connect to this signal to insert custom XML tags into the core XML.
<gst-object>
) (arg1 <gparam>
)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.
<gst-object>
) (name mchars
) (ret bool
)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
- a
<gst-object>
- name
- new name of object
- ret
- 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.
<gst-object>
) (ret mchars
)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 safelyg-free
as well.
- object
- a
<gst-object>
- ret
- the name of object.
g-free
after usage. MT safe. This function grabs and releases object's LOCK.
<gst-object>
) (parent <gst-object>
) (ret bool
)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
- a
<gst-object>
- parent
- new parent of object
- ret
- 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.
<gst-object>
) (ret <gst-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
- a
<gst-object>
- ret
- parent of object, this can be NULL if object has no parent. unref after usage. MT safe. Grabs and releases object's LOCK.
<gst-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.
- object
- a
<gst-object>
to unparent
<gst-object>
) (ret mchars
)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 safelyg-free
as well.
- object
- a
<gst-object>
- ret
- the name prefix of object.
g-free
after usage. MT safe. This function grabs and releases object's LOCK.
<gst-object>
) (name_prefix mchars
)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.
- object
- a
<gst-object>
- name-prefix
- new name prefix of object
<gst-object>
) (error <g-error*>
) (debug mchars
)A default error function.
The default handler will simply print the error string using g_print.
- source
- the
<gst-object>
that initiated the error.- error
- the GError.
- debug
- an additional debug information string, or NULL.
glist-of
) (name mchars
) (ret 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 carefull when passing a list with a locked object.
- list
- a list of
<gst-object>
to check through- name
- the name to search for
- ret
- 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.
<gst-object>
) (ancestor <gst-object>
) (ret bool
)Check if object has an ancestor ancestor somewhere up in the hierarchy.
- object
- a
<gst-object>
to check- ancestor
- a
<gst-object>
to check as ancestor- ret
- TRUE if ancestor is an ancestor of object. MT safe. Grabs and releases object's locks.
<gst-object>
) (parent <xml-node-ptr>
) (ret <xml-node-ptr>
)Saves object into the parent XML node.
- object
- a
<gst-object>
to save- parent
- The parent XML node to save object into
- ret
- the new xmlNodePtr with the saved object
<gst-object>
) (self <xml-node-ptr>
)Restores object with the data from the parent XML node.
- object
- a
<gst-object>
to load into- self
- The XML node to load object from
<gst-object>
) (ret mchars
)Generates a string describing the path of object in the object hierarchy. Only useful (or used) for debugging.
- object
- a
<gst-object>
- ret
- a string describing the path of object. You must
g-free
the string after usage. MT safe. Grabs and releases the<gst-object>
's LOCK for all objects in the hierarchy.