Trying to bring nack my old modifications.Next is merging with new Tango branch.
[gtkD.git] / gtkD / srcgstreamer / gstreamer / ObjectGst.d
blobbfb419ee27e22236c263e167a22268890fbbcbe6
1 /*
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
26 * outPack = gstreamer
27 * outFile = ObjectGst
28 * strct = GstObject
29 * realStrct=
30 * ctorStrct=
31 * clss = ObjectGst
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gst_object_
40 * - gst_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gst_object_save_thyself
45 * - gst_object_restore_thyself
46 * - gst_class_signal_emit_by_name
47 * - gst_class_signal_connect
48 * - gst_object_ref
49 * imports:
50 * - glib.Str
51 * - gobject.ObjectG
52 * - glib.ErrorG
53 * - glib.ListG
54 * structWrap:
55 * - GError* -> ErrorG
56 * - GList* -> ListG
57 * - GObject* -> ObjectG
58 * - GstObject* -> ObjectGst
59 * module aliases:
60 * local aliases:
63 module gstreamer.ObjectGst;
65 private import gstreamerc.gstreamertypes;
67 private import gstreamerc.gstreamer;
69 private import glib.Str;
70 private import gobject.ObjectG;
71 private import glib.ErrorG;
72 private import glib.ListG;
76 /**
77 * Description
78 * GstObject provides a root for the object hierarchy tree filed in by the
79 * GStreamer library. It is currently a thin wrapper on top of
80 * GObject. It is an abstract class that is not very usable on its own.
81 * GstObject gives us basic refcounting, parenting functionality and locking.
82 * Most of the function are just extended for special GStreamer needs and can be
83 * found under the same name in the base class of GstObject which is GObject
84 * (e.g. g_object_ref() becomes gst_object_ref()).
85 * The most interesting difference between GstObject and GObject is the
86 * "floating" reference count. A GObject is created with a reference count of
87 * 1, owned by the creator of the GObject. (The owner of a reference is the
88 * code section that has the right to call gst_object_unref() in order to
89 * remove that reference.) A GstObject is created with a reference count of 1
90 * also, but it isn't owned by anyone; Instead, the initial reference count
91 * of a GstObject is "floating". The floating reference can be removed by
92 * anyone at any time, by calling gst_object_sink(). gst_object_sink() does
93 * nothing if an object is already sunk (has no floating reference).
94 * When you add a GstElement to its parent container, the parent container will
95 * do this:
96 * gst_object_ref (GST_OBJECT (child_element));
97 * gst_object_sink (GST_OBJECT (child_element));
98 * This means that the container now owns a reference to the child element
99 * (since it called gst_object_ref()), and the child element has no floating
100 * reference.
101 * The purpose of the floating reference is to keep the child element alive
102 * until you add it to a parent container, which then manages the lifetime of
103 * the object itself:
104 * element = gst_element_factory_make (factoryname, name);
105 * // element has one floating reference to keep it alive
106 * gst_bin_add (GST_BIN (bin), element);
107 * // element has one non-floating reference owned by the container
108 * Another effect of this is, that calling gst_object_unref() on a bin object,
109 * will also destoy all the GstElement objects in it. The same is true for
110 * calling gst_bin_remove().
111 * Special care has to be taken for all methods that gst_object_sink() an object
112 * since if the caller of those functions had a floating reference to the object,
113 * the object reference is now invalid.
114 * In contrast to GObject instances, GstObject adds a name property. The functions
115 * gst_object_set_name() and gst_object_get_name() are used to set/get the name
116 * of the object.
117 * Last reviewed on 2005-11-09 (0.9.4)
119 private import gobject.ObjectG;
120 public class ObjectGst : ObjectG
123 /** the main Gtk struct */
124 protected GstObject* gstObject;
127 public GstObject* getObjectGstStruct()
129 return gstObject;
133 /** the main Gtk struct as a void* */
134 protected void* getStruct()
136 return cast(void*)gstObject;
140 * Sets our main struct and passes it to the parent class
142 public this (GstObject* gstObject)
144 super(cast(GObject*)gstObject);
145 this.gstObject = gstObject;
149 * Increments the refence count on object. This function
150 * does not take the lock on object because it relies on
151 * atomic refcounting.
152 * This object returns the input parameter to ease writing
153 * constructs like :
154 * result = gst_object_ref (object->parent);
155 * object:
156 * a GstObject to reference
157 * Returns:
158 * A pointer to object
160 public void* reference()
162 // gpointer gst_object_ref (gpointer object);
163 return gst_object_ref( gstObject );
165 /*public static void* ref(void* object)
167 // gpointer gst_object_ref (gpointer object);
168 return gst_object_ref(object);
174 // imports for the signal processing
175 private import gobject.Signals;
176 private import gtkc.gdktypes;
177 int[char[]] connectedSignals;
179 void delegate(ObjectG, GParamSpec*, ObjectGst)[] onDeepNotifyListeners;
180 void addOnDeepNotify(void delegate(ObjectG, GParamSpec*, ObjectGst) dlg)
182 if ( !("deep-notify" in connectedSignals) )
184 Signals.connectData(
185 getStruct(),
186 "deep-notify",
187 cast(GCallback)&callBackDeepNotify,
188 cast(void*)this,
189 null,
190 cast(ConnectFlags)0);
191 connectedSignals["deep-notify"] = 1;
193 onDeepNotifyListeners ~= dlg;
195 extern(C) static void callBackDeepNotify(GstObject* gstobjectStruct, GObject* propObject, GParamSpec* prop, ObjectGst objectGst)
197 bit consumed = false;
199 foreach ( void delegate(ObjectG, GParamSpec*, ObjectGst) dlg ; objectGst.onDeepNotifyListeners )
201 dlg(new ObjectG(propObject), prop, objectGst);
204 return consumed;
207 void delegate(gpointer, ObjectGst)[] onObjectSavedListeners;
208 void addOnObjectSaved(void delegate(gpointer, ObjectGst) dlg)
210 if ( !("object-saved" in connectedSignals) )
212 Signals.connectData(
213 getStruct(),
214 "object-saved",
215 cast(GCallback)&callBackObjectSaved,
216 cast(void*)this,
217 null,
218 cast(ConnectFlags)0);
219 connectedSignals["object-saved"] = 1;
221 onObjectSavedListeners ~= dlg;
223 extern(C) static void callBackObjectSaved(GstObject* gstobjectStruct, gpointer xmlNode, ObjectGst objectGst)
225 bit consumed = false;
227 foreach ( void delegate(gpointer, ObjectGst) dlg ; objectGst.onObjectSavedListeners )
229 dlg(xmlNode, objectGst);
232 return consumed;
235 void delegate(ObjectG, ObjectGst)[] onParentSetListeners;
236 void addOnParentSet(void delegate(ObjectG, ObjectGst) dlg)
238 if ( !("parent-set" in connectedSignals) )
240 Signals.connectData(
241 getStruct(),
242 "parent-set",
243 cast(GCallback)&callBackParentSet,
244 cast(void*)this,
245 null,
246 cast(ConnectFlags)0);
247 connectedSignals["parent-set"] = 1;
249 onParentSetListeners ~= dlg;
251 extern(C) static void callBackParentSet(GstObject* gstobjectStruct, GObject* parent, ObjectGst objectGst)
253 bit consumed = false;
255 foreach ( void delegate(ObjectG, ObjectGst) dlg ; objectGst.onParentSetListeners )
257 dlg(new ObjectG(parent), objectGst);
260 return consumed;
263 void delegate(ObjectG, ObjectGst)[] onParentUnsetListeners;
264 void addOnParentUnset(void delegate(ObjectG, ObjectGst) dlg)
266 if ( !("parent-unset" in connectedSignals) )
268 Signals.connectData(
269 getStruct(),
270 "parent-unset",
271 cast(GCallback)&callBackParentUnset,
272 cast(void*)this,
273 null,
274 cast(ConnectFlags)0);
275 connectedSignals["parent-unset"] = 1;
277 onParentUnsetListeners ~= dlg;
279 extern(C) static void callBackParentUnset(GstObject* gstobjectStruct, GObject* parent, ObjectGst objectGst)
281 bit consumed = false;
283 foreach ( void delegate(ObjectG, ObjectGst) dlg ; objectGst.onParentUnsetListeners )
285 dlg(new ObjectG(parent), objectGst);
288 return consumed;
313 * Sets the name of object, or gives object a guaranteed unique
314 * name (if name is NULL).
315 * This function makes a copy of the provided name, so the caller
316 * retains ownership of the name it sent.
317 * object:
318 * a GstObject
319 * name:
320 * new name of object
321 * Returns:
322 * TRUE if the name could be set. Since Objects that have
323 * a parent cannot be renamed, this function returns FALSE in those
324 * cases.
325 * MT safe. This function grabs and releases object's LOCK.
327 public int setName(char[] name)
329 // gboolean gst_object_set_name (GstObject *object, const gchar *name);
330 return gst_object_set_name(gstObject, Str.toStringz(name));
334 * Returns a copy of the name of object.
335 * Caller should g_free() the return value after usage.
336 * For a nameless object, this returns NULL, which you can safely g_free()
337 * as well.
338 * object:
339 * a GstObject
340 * Returns:
341 * the name of object. g_free() after usage.
342 * MT safe. This function grabs and releases object's LOCK.
344 public char[] getName()
346 // gchar* gst_object_get_name (GstObject *object);
347 return Str.toString(gst_object_get_name(gstObject) );
351 * Sets the parent of object to parent. The object's reference count will
352 * be incremented, and any floating reference will be removed (see gst_object_sink()).
353 * This function causes the parent-set signal to be emitted when the parent
354 * was successfully set.
355 * object:
356 * a GstObject
357 * parent:
358 * new parent of object
359 * Returns:
360 * TRUE if parent could be set or FALSE when object
361 * already had a parent or object and parent are the same.
362 * MT safe. Grabs and releases object's LOCK.
364 public int setParent(ObjectGst parent)
366 // gboolean gst_object_set_parent (GstObject *object, GstObject *parent);
367 return gst_object_set_parent(gstObject, (parent is null) ? null : parent.getObjectGstStruct());
371 * Returns the parent of object. This function increases the refcount
372 * of the parent object so you should gst_object_unref() it after usage.
373 * object:
374 * a GstObject
375 * Returns:
376 * parent of object, this can be NULL if object has no
377 * parent. unref after usage.
378 * MT safe. Grabs and releases object's LOCK.
380 public ObjectGst getParent()
382 // GstObject* gst_object_get_parent (GstObject *object);
383 return new ObjectGst( gst_object_get_parent(gstObject) );
387 * Clear the parent of object, removing the associated reference.
388 * This function decreases the refcount of object.
389 * MT safe. Grabs and releases object's lock.
390 * object:
391 * a GstObject to unparent
393 public void unparent()
395 // void gst_object_unparent (GstObject *object);
396 gst_object_unparent(gstObject);
400 * Returns a copy of the name prefix of object.
401 * Caller should g_free() the return value after usage.
402 * For a prefixless object, this returns NULL, which you can safely g_free()
403 * as well.
404 * object:
405 * a GstObject
406 * Returns:
407 * the name prefix of object. g_free() after usage.
408 * MT safe. This function grabs and releases object's LOCK.
410 public char[] getNamePrefix()
412 // gchar* gst_object_get_name_prefix (GstObject *object);
413 return Str.toString(gst_object_get_name_prefix(gstObject) );
417 * Sets the name prefix of object to name_prefix.
418 * This function makes a copy of the provided name prefix, so the caller
419 * retains ownership of the name prefix it sent.
420 * MT safe. This function grabs and releases object's LOCK.
421 * object:
422 * a GstObject
423 * name_prefix:
424 * new name prefix of object
426 public void setNamePrefix(char[] namePrefix)
428 // void gst_object_set_name_prefix (GstObject *object, const gchar *name_prefix);
429 gst_object_set_name_prefix(gstObject, Str.toStringz(namePrefix));
433 * A default deep_notify signal callback for an object. The user data
434 * should contain a pointer to an array of strings that should be excluded
435 * from the notify. The default handler will print the new value of the property
436 * using g_print.
437 * MT safe. This function grabs and releases object's LOCK for getting its
438 * path string.
439 * object:
440 * the GObject that signalled the notify.
441 * orig:
442 * a GstObject that initiated the notify.
443 * pspec:
444 * a GParamSpec of the property.
445 * excluded_props:
446 * a set of user-specified properties to exclude or
447 * NULL to show all changes.
449 public static void defaultDeepNotify(ObjectG object, ObjectGst orig, GParamSpec* pspec, char** excludedProps)
451 // void gst_object_default_deep_notify (GObject *object, GstObject *orig, GParamSpec *pspec, gchar **excluded_props);
452 gst_object_default_deep_notify((object is null) ? null : object.getObjectGStruct(), (orig is null) ? null : orig.getObjectGstStruct(), pspec, excludedProps);
456 * A default error function.
457 * The default handler will simply print the error string using g_print.
458 * source:
459 * the GstObject that initiated the error.
460 * error:
461 * the GError.
462 * debug:
463 * an additional debug information string, or NULL.
465 public void defaultError(ErrorG error, char[] dbug)
467 // void gst_object_default_error (GstObject *source, GError *error, gchar *debug);
468 gst_object_default_error(gstObject, (error is null) ? null : error.getErrorGStruct(), Str.toStringz(dbug));
472 * Checks to see if there is any object named name in list. This function
473 * does not do any locking of any kind. You might want to protect the
474 * provided list with the lock of the owner of the list. This function
475 * will lock each GstObject in the list to compare the name, so be
476 * carefull when passing a list with a locked object.
477 * list:
478 * a list of GstObject to check through
479 * name:
480 * the name to search for
481 * Returns:
482 * TRUE if a GstObject named name does not appear in list,
483 * FALSE if it does.
484 * MT safe. Grabs and releases the LOCK of each object in the list.
486 public static int checkUniqueness(ListG list, char[] name)
488 // gboolean gst_object_check_uniqueness (GList *list, const gchar *name);
489 return gst_object_check_uniqueness((list is null) ? null : list.getListGStruct(), Str.toStringz(name));
493 * Check if object has an ancestor ancestor somewhere up in
494 * the hierarchy.
495 * object:
496 * a GstObject to check
497 * ancestor:
498 * a GstObject to check as ancestor
499 * Returns:
500 * TRUE if ancestor is an ancestor of object.
501 * MT safe. Grabs and releases object's locks.
503 public int hasAncestor(ObjectGst ancestor)
505 // gboolean gst_object_has_ancestor (GstObject *object, GstObject *ancestor);
506 return gst_object_has_ancestor(gstObject, (ancestor is null) ? null : ancestor.getObjectGstStruct());
513 * Decrements the refence count on object. If reference count hits
514 * zero, destroy object. This function does not take the lock
515 * on object as it relies on atomic refcounting.
516 * The unref method should never be called with the LOCK held since
517 * this might deadlock the dispose function.
518 * object:
519 * a GstObject to unreference
521 public static void unref(void* object)
523 // void gst_object_unref (gpointer object);
524 gst_object_unref(object);
528 * If object was floating, the GST_OBJECT_FLOATING flag is removed
529 * and object is unreffed. When object was not floating,
530 * this function does nothing.
531 * Any newly created object has a refcount of 1 and is floating.
532 * This function should be used when creating a new object to
533 * symbolically 'take ownership' of object. This done by first doing a
534 * gst_object_ref() to keep a reference to object and then gst_object_sink()
535 * to remove and unref any floating references to object.
536 * Use gst_object_set_parent() to have this done for you.
537 * MT safe. This function grabs and releases object lock.
538 * object:
539 * a GstObject to sink
541 public static void sink(void* object)
543 // void gst_object_sink (gpointer object);
544 gst_object_sink(object);
548 * Unrefs the GstObject pointed to by oldobj, refs newobj and
549 * puts newobj in *oldobj. Be carefull when calling this
550 * function, it does not take any locks. You might want to lock
551 * the object owning oldobj pointer before calling this
552 * function.
553 * Make sure not to LOCK oldobj because it might be unreffed
554 * which could cause a deadlock when it is disposed.
555 * oldobj:
556 * pointer to a place of a GstObject to replace
557 * newobj:
558 * a new GstObject
560 public static void replace(GstObject** oldobj, ObjectGst newobj)
562 // void gst_object_replace (GstObject **oldobj, GstObject *newobj);
563 gst_object_replace(oldobj, (newobj is null) ? null : newobj.getObjectGstStruct());
567 * Generates a string describing the path of object in
568 * the object hierarchy. Only useful (or used) for debugging.
569 * object:
570 * a GstObject
571 * Returns:
572 * a string describing the path of object. You must
573 * g_free() the string after usage.
574 * MT safe. Grabs and releases the GstObject's LOCK for all objects
575 * in the hierarchy.
577 public char[] getPathString()
579 // gchar* gst_object_get_path_string (GstObject *object);
580 return Str.toString(gst_object_get_path_string(gstObject) );