2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GstObject.html
44 * - gst_object_save_thyself
45 * - gst_object_restore_thyself
46 * - gst_class_signal_emit_by_name
47 * - gst_class_signal_connect
56 * - GObject* -> ObjectG
57 * - GstObject* -> ObjectGst
62 module gstreamer
.ObjectGst
;
64 private import gstreamerc
.gstreamertypes
;
66 private import gstreamerc
.gstreamer
;
68 private import glib
.Str
;
69 private import gobject
.ObjectG
;
70 private import glib
.ErrorG
;
71 private import glib
.ListG
;
77 * GstObject provides a root for the object hierarchy tree filed in by the
78 * GStreamer library. It is currently a thin wrapper on top of
79 * GObject. It is an abstract class that is not very usable on its own.
80 * GstObject gives us basic refcounting, parenting functionality and locking.
81 * Most of the function are just extended for special GStreamer needs and can be
82 * found under the same name in the base class of GstObject which is GObject
83 * (e.g. g_object_ref() becomes gst_object_ref()).
84 * The most interesting difference between GstObject and GObject is the
85 * "floating" reference count. A GObject is created with a reference count of
86 * 1, owned by the creator of the GObject. (The owner of a reference is the
87 * code section that has the right to call gst_object_unref() in order to
88 * remove that reference.) A GstObject is created with a reference count of 1
89 * also, but it isn't owned by anyone; Instead, the initial reference count
90 * of a GstObject is "floating". The floating reference can be removed by
91 * anyone at any time, by calling gst_object_sink(). gst_object_sink() does
92 * nothing if an object is already sunk (has no floating reference).
93 * When you add a GstElement to its parent container, the parent container will
95 * gst_object_ref (GST_OBJECT (child_element));
96 * gst_object_sink (GST_OBJECT (child_element));
97 * This means that the container now owns a reference to the child element
98 * (since it called gst_object_ref()), and the child element has no floating
100 * The purpose of the floating reference is to keep the child element alive
101 * until you add it to a parent container, which then manages the lifetime of
103 * element = gst_element_factory_make (factoryname, name);
104 * // element has one floating reference to keep it alive
105 * gst_bin_add (GST_BIN (bin), element);
106 * // element has one non-floating reference owned by the container
107 * Another effect of this is, that calling gst_object_unref() on a bin object,
108 * will also destoy all the GstElement objects in it. The same is true for
109 * calling gst_bin_remove().
110 * Special care has to be taken for all methods that gst_object_sink() an object
111 * since if the caller of those functions had a floating reference to the object,
112 * the object reference is now invalid.
113 * In contrast to GObject instances, GstObject adds a name property. The functions
114 * gst_object_set_name() and gst_object_get_name() are used to set/get the name
116 * Last reviewed on 2005-11-09 (0.9.4)
118 private import gobject
.ObjectG
;
119 public class ObjectGst
: ObjectG
122 /** the main Gtk struct */
123 protected GstObject
* gstObject
;
126 public GstObject
* getObjectGstStruct()
132 /** the main Gtk struct as a void* */
133 protected void* getStruct()
135 return cast(void*)gstObject
;
139 * Sets our main struct and passes it to the parent class
141 public this (GstObject
* gstObject
)
143 super(cast(GObject
*)gstObject
);
144 this.gstObject
= gstObject
;
150 // imports for the signal processing
151 private import gobject
.Signals
;
152 private import gtkc
.gdktypes
;
153 int[char[]] connectedSignals
;
155 void delegate(ObjectG
, GParamSpec
*, ObjectGst
)[] onDeepNotifyListeners
;
156 void addOnDeepNotify(void delegate(ObjectG
, GParamSpec
*, ObjectGst
) dlg
)
158 if ( !("deep-notify" in connectedSignals
) )
163 cast(GCallback
)&callBackDeepNotify
,
166 cast(ConnectFlags
)0);
167 connectedSignals
["deep-notify"] = 1;
169 onDeepNotifyListeners
~= dlg
;
171 extern(C
) static void callBackDeepNotify(GstObject
* gstobjectStruct
, GObject
* propObject
, GParamSpec
* prop
, ObjectGst objectGst
)
173 bit consumed
= false;
175 foreach ( void delegate(ObjectG
, GParamSpec
*, ObjectGst
) dlg
; objectGst
.onDeepNotifyListeners
)
177 dlg(new ObjectG(propObject
), prop
, objectGst
);
183 void delegate(gpointer
, ObjectGst
)[] onObjectSavedListeners
;
184 void addOnObjectSaved(void delegate(gpointer
, ObjectGst
) dlg
)
186 if ( !("object-saved" in connectedSignals
) )
191 cast(GCallback
)&callBackObjectSaved
,
194 cast(ConnectFlags
)0);
195 connectedSignals
["object-saved"] = 1;
197 onObjectSavedListeners
~= dlg
;
199 extern(C
) static void callBackObjectSaved(GstObject
* gstobjectStruct
, gpointer xmlNode
, ObjectGst objectGst
)
201 bit consumed
= false;
203 foreach ( void delegate(gpointer
, ObjectGst
) dlg
; objectGst
.onObjectSavedListeners
)
205 dlg(xmlNode
, objectGst
);
211 void delegate(ObjectG
, ObjectGst
)[] onParentSetListeners
;
212 void addOnParentSet(void delegate(ObjectG
, ObjectGst
) dlg
)
214 if ( !("parent-set" in connectedSignals
) )
219 cast(GCallback
)&callBackParentSet
,
222 cast(ConnectFlags
)0);
223 connectedSignals
["parent-set"] = 1;
225 onParentSetListeners
~= dlg
;
227 extern(C
) static void callBackParentSet(GstObject
* gstobjectStruct
, GObject
* parent
, ObjectGst objectGst
)
229 bit consumed
= false;
231 foreach ( void delegate(ObjectG
, ObjectGst
) dlg
; objectGst
.onParentSetListeners
)
233 dlg(new ObjectG(parent
), objectGst
);
239 void delegate(ObjectG
, ObjectGst
)[] onParentUnsetListeners
;
240 void addOnParentUnset(void delegate(ObjectG
, ObjectGst
) dlg
)
242 if ( !("parent-unset" in connectedSignals
) )
247 cast(GCallback
)&callBackParentUnset
,
250 cast(ConnectFlags
)0);
251 connectedSignals
["parent-unset"] = 1;
253 onParentUnsetListeners
~= dlg
;
255 extern(C
) static void callBackParentUnset(GstObject
* gstobjectStruct
, GObject
* parent
, ObjectGst objectGst
)
257 bit consumed
= false;
259 foreach ( void delegate(ObjectG
, ObjectGst
) dlg
; objectGst
.onParentUnsetListeners
)
261 dlg(new ObjectG(parent
), objectGst
);
289 * Sets the name of object, or gives object a guaranteed unique
290 * name (if name is NULL).
291 * This function makes a copy of the provided name, so the caller
292 * retains ownership of the name it sent.
298 * TRUE if the name could be set. Since Objects that have
299 * a parent cannot be renamed, this function returns FALSE in those
301 * MT safe. This function grabs and releases object's LOCK.
303 public int setName(char[] name
)
305 // gboolean gst_object_set_name (GstObject *object, const gchar *name);
306 return gst_object_set_name(gstObject
, Str
.toStringz(name
));
310 * Returns a copy of the name of object.
311 * Caller should g_free() the return value after usage.
312 * For a nameless object, this returns NULL, which you can safely g_free()
317 * the name of object. g_free() after usage.
318 * MT safe. This function grabs and releases object's LOCK.
320 public char[] getName()
322 // gchar* gst_object_get_name (GstObject *object);
323 return Str
.toString(gst_object_get_name(gstObject
) );
327 * Sets the parent of object to parent. The object's reference count will
328 * be incremented, and any floating reference will be removed (see gst_object_sink()).
329 * This function causes the parent-set signal to be emitted when the parent
330 * was successfully set.
334 * new parent of object
336 * TRUE if parent could be set or FALSE when object
337 * already had a parent or object and parent are the same.
338 * MT safe. Grabs and releases object's LOCK.
340 public int setParent(ObjectGst parent
)
342 // gboolean gst_object_set_parent (GstObject *object, GstObject *parent);
343 return gst_object_set_parent(gstObject
, (parent
is null) ?
null : parent
.getObjectGstStruct());
347 * Returns the parent of object. This function increases the refcount
348 * of the parent object so you should gst_object_unref() it after usage.
352 * parent of object, this can be NULL if object has no
353 * parent. unref after usage.
354 * MT safe. Grabs and releases object's LOCK.
356 public ObjectGst
getParent()
358 // GstObject* gst_object_get_parent (GstObject *object);
359 return new ObjectGst( gst_object_get_parent(gstObject
) );
363 * Clear the parent of object, removing the associated reference.
364 * This function decreases the refcount of object.
365 * MT safe. Grabs and releases object's lock.
367 * a GstObject to unparent
369 public void unparent()
371 // void gst_object_unparent (GstObject *object);
372 gst_object_unparent(gstObject
);
376 * Returns a copy of the name prefix of object.
377 * Caller should g_free() the return value after usage.
378 * For a prefixless object, this returns NULL, which you can safely g_free()
383 * the name prefix of object. g_free() after usage.
384 * MT safe. This function grabs and releases object's LOCK.
386 public char[] getNamePrefix()
388 // gchar* gst_object_get_name_prefix (GstObject *object);
389 return Str
.toString(gst_object_get_name_prefix(gstObject
) );
393 * Sets the name prefix of object to name_prefix.
394 * This function makes a copy of the provided name prefix, so the caller
395 * retains ownership of the name prefix it sent.
396 * MT safe. This function grabs and releases object's LOCK.
400 * new name prefix of object
402 public void setNamePrefix(char[] namePrefix
)
404 // void gst_object_set_name_prefix (GstObject *object, const gchar *name_prefix);
405 gst_object_set_name_prefix(gstObject
, Str
.toStringz(namePrefix
));
409 * A default deep_notify signal callback for an object. The user data
410 * should contain a pointer to an array of strings that should be excluded
411 * from the notify. The default handler will print the new value of the property
413 * MT safe. This function grabs and releases object's LOCK for getting its
416 * the GObject that signalled the notify.
418 * a GstObject that initiated the notify.
420 * a GParamSpec of the property.
422 * a set of user-specified properties to exclude or
423 * NULL to show all changes.
425 public static void defaultDeepNotify(ObjectG object
, ObjectGst orig
, GParamSpec
* pspec
, char** excludedProps
)
427 // void gst_object_default_deep_notify (GObject *object, GstObject *orig, GParamSpec *pspec, gchar **excluded_props);
428 gst_object_default_deep_notify((object
is null) ?
null : object
.getObjectGStruct(), (orig
is null) ?
null : orig
.getObjectGstStruct(), pspec
, excludedProps
);
432 * A default error function.
433 * The default handler will simply print the error string using g_print.
435 * the GstObject that initiated the error.
439 * an additional debug information string, or NULL.
441 public void defaultError(ErrorG error
, char[] dbug
)
443 // void gst_object_default_error (GstObject *source, GError *error, gchar *debug);
444 gst_object_default_error(gstObject
, (error
is null) ?
null : error
.getErrorGStruct(), Str
.toStringz(dbug
));
448 * Checks to see if there is any object named name in list. This function
449 * does not do any locking of any kind. You might want to protect the
450 * provided list with the lock of the owner of the list. This function
451 * will lock each GstObject in the list to compare the name, so be
452 * carefull when passing a list with a locked object.
454 * a list of GstObject to check through
456 * the name to search for
458 * TRUE if a GstObject named name does not appear in list,
460 * MT safe. Grabs and releases the LOCK of each object in the list.
462 public static int checkUniqueness(ListG list
, char[] name
)
464 // gboolean gst_object_check_uniqueness (GList *list, const gchar *name);
465 return gst_object_check_uniqueness((list
is null) ?
null : list
.getListGStruct(), Str
.toStringz(name
));
469 * Check if object has an ancestor ancestor somewhere up in
472 * a GstObject to check
474 * a GstObject to check as ancestor
476 * TRUE if ancestor is an ancestor of object.
477 * MT safe. Grabs and releases object's locks.
479 public int hasAncestor(ObjectGst ancestor
)
481 // gboolean gst_object_has_ancestor (GstObject *object, GstObject *ancestor);
482 return gst_object_has_ancestor(gstObject
, (ancestor
is null) ?
null : ancestor
.getObjectGstStruct());
488 * Increments the refence count on object. This function
489 * does not take the lock on object because it relies on
490 * atomic refcounting.
491 * This object returns the input parameter to ease writing
493 * result = gst_object_ref (object->parent);
495 * a GstObject to reference
497 * A pointer to object
499 public static void* doref(void* object
)
501 // gpointer gst_object_ref (gpointer object);
502 return gst_object_ref(object
);
506 * Decrements the refence count on object. If reference count hits
507 * zero, destroy object. This function does not take the lock
508 * on object as it relies on atomic refcounting.
509 * The unref method should never be called with the LOCK held since
510 * this might deadlock the dispose function.
512 * a GstObject to unreference
514 public static void unref(void* object
)
516 // void gst_object_unref (gpointer object);
517 gst_object_unref(object
);
521 * If object was floating, the GST_OBJECT_FLOATING flag is removed
522 * and object is unreffed. When object was not floating,
523 * this function does nothing.
524 * Any newly created object has a refcount of 1 and is floating.
525 * This function should be used when creating a new object to
526 * symbolically 'take ownership' of object. This done by first doing a
527 * gst_object_ref() to keep a reference to object and then gst_object_sink()
528 * to remove and unref any floating references to object.
529 * Use gst_object_set_parent() to have this done for you.
530 * MT safe. This function grabs and releases object lock.
532 * a GstObject to sink
534 public static void sink(void* object
)
536 // void gst_object_sink (gpointer object);
537 gst_object_sink(object
);
541 * Unrefs the GstObject pointed to by oldobj, refs newobj and
542 * puts newobj in *oldobj. Be carefull when calling this
543 * function, it does not take any locks. You might want to lock
544 * the object owning oldobj pointer before calling this
546 * Make sure not to LOCK oldobj because it might be unreffed
547 * which could cause a deadlock when it is disposed.
549 * pointer to a place of a GstObject to replace
553 public static void replace(GstObject
** oldobj
, ObjectGst newobj
)
555 // void gst_object_replace (GstObject **oldobj, GstObject *newobj);
556 gst_object_replace(oldobj
, (newobj
is null) ?
null : newobj
.getObjectGstStruct());
560 * Generates a string describing the path of object in
561 * the object hierarchy. Only useful (or used) for debugging.
565 * a string describing the path of object. You must
566 * g_free() the string after usage.
567 * MT safe. Grabs and releases the GstObject's LOCK for all objects
570 public char[] getPathString()
572 // gchar* gst_object_get_path_string (GstObject *object);
573 return Str
.toString(gst_object_get_path_string(gstObject
) );