2001-01-20 20:08:59 +00:00
|
|
|
GstObject
|
|
|
|
=========
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
The base class for the entire GStreamer hierarchy is the GstObject.
|
2001-01-20 20:08:59 +00:00
|
|
|
|
|
|
|
Parentage
|
|
|
|
---------
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
A pointer is available to store the current parent of the object. This is one
|
2007-09-24 11:22:26 +00:00
|
|
|
of the two fundamental requirements for a hierarchical system such as GStreamer
|
2005-03-07 18:27:42 +00:00
|
|
|
(for the other, read up on GstBin). Three functions are provided:
|
|
|
|
_set_parent(), _get_parent(), and _unparent(). The third is required because
|
|
|
|
there is an explicit check in _set_parent(): an object must not already have a
|
|
|
|
parent if you wish to set one. You must unparent the object first. This
|
|
|
|
allows for new additions later.
|
|
|
|
|
|
|
|
- GstObject's that can be parented:
|
|
|
|
GstElement (inside a bin)
|
|
|
|
GstPad (inside an element)
|
2001-01-20 20:08:59 +00:00
|
|
|
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
Naming
|
|
|
|
------
|
|
|
|
- names of objects cannot be changed when they are parented
|
|
|
|
- names of objects should be unique across parent
|
|
|
|
- set_name() can fail because of this
|
|
|
|
- as can gst_element_add_pad()/gst_bin_add_element()
|
|
|
|
- gst_object_set_name() only changes the object's name
|
2001-01-20 20:08:59 +00:00
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
- objects also have a name_prefix that is used to prefix the object name
|
|
|
|
during debugging and identification
|
|
|
|
- there are object-specific set_name's() which also set the name_prefix
|
|
|
|
on the object. This is useful for debugging purposes to give the object
|
|
|
|
a more identifiable name. Typically a parent will call _set_name_prefix
|
|
|
|
on children, taking a lock on them to do so.
|
2001-01-20 20:08:59 +00:00
|
|
|
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
|
2001-01-20 20:08:59 +00:00
|
|
|
Locking
|
|
|
|
-------
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
The GstObject contains the necessary primitives to lock the object in a
|
|
|
|
thread-safe manner. This will be used to provide general thread-safety as
|
|
|
|
needed. However, this lock is generic, i.e. it covers the whole object.
|
|
|
|
|
2005-03-10 12:51:45 +00:00
|
|
|
The object LOCK is a very lowlevel lock that should only be held to access
|
|
|
|
the object properties for short periods of code.
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
All members of the GstObject structure marked as
|
|
|
|
/*< public >*/ /* with LOCK */
|
|
|
|
are protected by this lock. These members can only be accessed for reading
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
or writing while the lock is held. All members should be copied or reffed
|
|
|
|
if they are used after releasing the LOCK.
|
2005-03-07 18:27:42 +00:00
|
|
|
|
|
|
|
Note that this does *not* mean that no other thread can modify the object at
|
|
|
|
the same time that the lock is held. It only means that any two sections of
|
|
|
|
code that obey the lock are guaranteed to not be running simultaneously. "The
|
|
|
|
lock is voluntary and cooperative".
|
2001-01-20 20:08:59 +00:00
|
|
|
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
This lock will ideally be used for parentage, flags and naming, which is
|
2005-03-07 18:27:42 +00:00
|
|
|
reasonable, since they are the only possible things to protect in the
|
|
|
|
GstObject.
|
2001-01-20 20:08:59 +00:00
|
|
|
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
|
2005-03-10 12:51:45 +00:00
|
|
|
Locking order
|
|
|
|
-------------
|
|
|
|
|
|
|
|
In parent-child situations the lock of the parent must always be taken first
|
|
|
|
before taking the lock of the child. It is NOT allowed to hold the child
|
|
|
|
lock before taking the parent lock.
|
|
|
|
|
|
|
|
This policy allows for parents to iterate their children and setting properties
|
|
|
|
on them.
|
|
|
|
|
|
|
|
Whenever a nested lock needs to be taken on objects not involved in a
|
|
|
|
parent-child relation (eg. pads), an explictic locking order has to be defined.
|
|
|
|
|
|
|
|
|
2001-01-20 20:08:59 +00:00
|
|
|
Path Generation
|
|
|
|
---------------
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
Due to the base nature of the GstObject, it becomes the only reasonable place
|
|
|
|
to put this particular function (_get_path_string). It will generate a string
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
describing the parent hierarchy of a given GstObject.
|
|
|
|
|
|
|
|
|
|
|
|
Flags
|
|
|
|
-----
|
|
|
|
|
|
|
|
Each object in the GStreamer object hierarchy can have flags associated with it,
|
|
|
|
which are used to describe a state or a feature of the object.
|
2007-09-24 11:22:26 +00:00
|
|
|
GstObject has flags to mark its lifecycle: FLOATING and DISPOSING.
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
Class signals
|
|
|
|
-------------
|
|
|
|
|
|
|
|
It is possible to know when a new object is loaded by connecting to the
|
|
|
|
GstObjectClass signal. This feature is not very much used and might be removed
|
|
|
|
at some point.
|