alternative to assert
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Bin.d
blob5166bd9ba1991a9500e6b8d4300a166fe03e86c9
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 = GstBin.html
26 * outPack = gstreamer
27 * outFile = Bin
28 * strct = GstBin
29 * realStrct=
30 * ctorStrct=
31 * clss = Bin
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gst_bin_
40 * - gst_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gst_bin_new
45 * imports:
46 * - glib.Str
47 * - gstreamer.Element
48 * - gstreamer.Iterator
49 * structWrap:
50 * - GstBin* -> Bin
51 * - GstElement* -> Element
52 * - GstIterator* -> Iterator
53 * module aliases:
54 * local aliases:
57 module gstreamer.Bin;
59 private import gstreamerc.gstreamertypes;
61 private import gstreamerc.gstreamer;
63 private import glib.Str;
64 private import gstreamer.Element;
65 private import gstreamer.Iterator;
69 /**
70 * Description
71 * GstBin is an element that can contain other GstElement, allowing them to be
72 * managed as a group.
73 * Pads from the child elements can be ghosted to the bin, see GstGhostPad.
74 * This makes the bin look like any other elements and enables creation of
75 * higher-level abstraction elements.
76 * A new GstBin is created with gst_bin_new(). Use a GstPipeline instead if you
77 * want to create a toplevel bin because a normal bin doesn't have a bus or
78 * handle clock distribution of its own.
79 * After the bin has been created you will typically add elements to it with
80 * gst_bin_add(). You can remove elements with gst_bin_remove().
81 * An element can be retrieved from a bin with gst_bin_get_by_name(), using the
82 * elements name. gst_bin_get_by_name_recurse_up() is mainly used for internal
83 * purposes and will query the parent bins when the element is not found in the
84 * current bin.
85 * An iterator of elements in a bin can be retrieved with
86 * gst_bin_iterate_elements(). Various other iterators exist to retrieve the
87 * elements in a bin.
88 * gst_object_unref() is used to drop your reference to the bin.
89 * The element-added signal is
90 * fired whenever a new element is added to the bin. Likewise the element-removed signal is fired
91 * whenever an element is removed from the bin.
92 * Notes
93 * A GstBin internally intercepts every GstMessage posted by its children and
94 * implements the following default behaviour for each of them:
95 * GST_MESSAGE_EOS
96 * This message is only posted by sinks in the PLAYING
97 * state. If all sinks posted the EOS message, this bin will post and EOS
98 * message upwards.
99 * GST_MESSAGE_SEGMENT_START
100 * just collected and never forwarded upwards.
101 * The messages are used to decide when all elements have completed playback
102 * of their segment.
103 * GST_MESSAGE_SEGMENT_DONE
104 * Is posted by GstBin when all elements that posted
105 * a SEGMENT_START have posted a SEGMENT_DONE.
106 * GST_MESSAGE_DURATION
107 * Is posted by an element that detected a change
108 * in the stream duration. The default bin behaviour is to clear any
109 * cached duration values so that the next duration query will perform
110 * a full duration recalculation. The duration change is posted to the
111 * application so that it can refetch the new duration with a duration
112 * query.
113 * GST_MESSAGE_CLOCK_LOST
114 * This message is posted by an element when it
115 * can no longer provide a clock. The default bin behaviour is to
116 * check if the lost clock was the one provided by the bin. If so and
117 * the bin is currently in the PLAYING state, the message is forwarded to
118 * the bin parent.
119 * This message is also generated when a clock provider is removed from
120 * the bin. If this message is received by the application, it should
121 * PAUSE the pipeline and set it back to PLAYING to force a new clock
122 * distribution.
123 * GST_MESSAGE_CLOCK_PROVIDE
124 * This message is generated when an element
125 * can provide a clock. This mostly happens when a new clock
126 * provider is added to the bin. The default behaviour of the bin is to
127 * mark the currently selected clock as dirty, which will perform a clock
128 * recalculation the next time the bin is asked to provide a clock.
129 * This message is never sent tot the application but is forwarded to
130 * the parent of the bin.
131 * OTHERS
132 * posted upwards.
133 * A GstBin implements the following default behaviour for answering to a
134 * GstQuery:
135 * GST_QUERY_DURATION
136 * If the query has been asked before with the same format
137 * and the bin is a toplevel bin (ie. has no parent),
138 * use the cached previous value. If no previous value was cached, the
139 * query is sent to all sink elements in the bin and the MAXIMUM of all
140 * values is returned. If the bin is a toplevel bin the value is cached.
141 * If no sinks are available in the bin, the query fails.
142 * GST_QUERY_POSITION
143 * The query is sent to all sink elements in the bin and the
144 * MAXIMUM of all values is returned. If no sinks are available in the bin,
145 * the query fails.
146 * OTHERS
147 * the query is forwarded to all sink elements, the result
148 * of the first sink that answers the query successfully is returned. If no
149 * sink is in the bin, the query fails.
150 * A GstBin will by default forward any event sent to it to all sink elements.
151 * If all the sinks return TRUE, the bin will also return TRUE, else FALSE is
152 * returned. If no sinks are in the bin, the event handler will return TRUE.
153 * Last reviewed on 2006-04-28 (0.10.6)
155 private import gstreamer.Element;
156 public class Bin : Element
159 /** the main Gtk struct */
160 protected GstBin* gstBin;
163 public GstBin* getBinStruct()
165 return gstBin;
169 /** the main Gtk struct as a void* */
170 protected void* getStruct()
172 return cast(void*)gstBin;
176 * Sets our main struct and passes it to the parent class
178 public this (GstBin* gstBin)
180 super(cast(GstElement*)gstBin);
181 this.gstBin = gstBin;
185 * Creates a new bin with the given name.
186 * name:
187 * the name of the new bin
188 * Returns:
189 * a new GstBin
191 public this(char[] name)
193 // GstElement* gst_bin_new (const gchar *name);
194 this( cast(GstBin*) gst_bin_new(Str.toStringz(name)) );
197 public this(Element elem)
199 super( elem.getElementStruct() );
200 this.gstBin = cast(GstBin*)elem.getElementStruct();
206 // imports for the signal processing
207 private import gobject.Signals;
208 private import gtkc.gdktypes;
209 int[char[]] connectedSignals;
211 void delegate(Element, Bin)[] onElementAddedListeners;
212 void addOnElementAdded(void delegate(Element, Bin) dlg)
214 if ( !("element-added" in connectedSignals) )
216 Signals.connectData(
217 getStruct(),
218 "element-added",
219 cast(GCallback)&callBackElementAdded,
220 cast(void*)this,
221 null,
222 cast(ConnectFlags)0);
223 connectedSignals["element-added"] = 1;
225 onElementAddedListeners ~= dlg;
227 extern(C) static void callBackElementAdded(GstBin* binStruct, GstElement* element, Bin bin)
229 bit consumed = false;
231 foreach ( void delegate(Element, Bin) dlg ; bin.onElementAddedListeners )
233 dlg(new Element(element), bin);
236 return consumed;
239 void delegate(Element, Bin)[] onElementRemovedListeners;
240 void addOnElementRemoved(void delegate(Element, Bin) dlg)
242 if ( !("element-removed" in connectedSignals) )
244 Signals.connectData(
245 getStruct(),
246 "element-removed",
247 cast(GCallback)&callBackElementRemoved,
248 cast(void*)this,
249 null,
250 cast(ConnectFlags)0);
251 connectedSignals["element-removed"] = 1;
253 onElementRemovedListeners ~= dlg;
255 extern(C) static void callBackElementRemoved(GstBin* binStruct, GstElement* element, Bin bin)
257 bit consumed = false;
259 foreach ( void delegate(Element, Bin) dlg ; bin.onElementRemovedListeners )
261 dlg(new Element(element), bin);
264 return consumed;
272 * Adds the given element to the bin. Sets the element's parent, and thus
273 * takes ownership of the element. An element can only be added to one bin.
274 * If the element's pads are linked to other pads, the pads will be unlinked
275 * before the element is added to the bin.
276 * MT safe.
277 * bin:
278 * a GstBin
279 * element:
280 * the GstElement to add
281 * Returns:
282 * TRUE if the element could be added, FALSE if
283 * the bin does not want to accept the element.
285 public int add(Element element)
287 // gboolean gst_bin_add (GstBin *bin, GstElement *element);
288 return gst_bin_add(gstBin, (element is null) ? null : element.getElementStruct());
292 * Removes the element from the bin, unparenting it as well.
293 * Unparenting the element means that the element will be dereferenced,
294 * so if the bin holds the only reference to the element, the element
295 * will be freed in the process of removing it from the bin. If you
296 * want the element to still exist after removing, you need to call
297 * gst_object_ref() before removing it from the bin.
298 * If the element's pads are linked to other pads, the pads will be unlinked
299 * before the element is removed from the bin.
300 * MT safe.
301 * bin:
302 * a GstBin
303 * element:
304 * the GstElement to remove
305 * Returns:
306 * TRUE if the element could be removed, FALSE if
307 * the bin does not want to remove the element.
309 public int remove(Element element)
311 // gboolean gst_bin_remove (GstBin *bin, GstElement *element);
312 return gst_bin_remove(gstBin, (element is null) ? null : element.getElementStruct());
316 * Gets the element with the given name from a bin. This
317 * function recurses into child bins.
318 * Returns NULL if no element with the given name is found in the bin.
319 * MT safe. Caller owns returned reference.
320 * bin:
321 * a GstBin
322 * name:
323 * the element name to search for
324 * Returns:
325 * the GstElement with the given name, or NULL
327 public Element getByName(char[] name)
329 // GstElement* gst_bin_get_by_name (GstBin *bin, const gchar *name);
330 return new Element( gst_bin_get_by_name(gstBin, Str.toStringz(name)) );
334 * Gets the element with the given name from this bin. If the
335 * element is not found, a recursion is performed on the parent bin.
336 * Returns NULL if:
337 * - no element with the given name is found in the bin
338 * MT safe. Caller owns returned reference.
339 * bin:
340 * a GstBin
341 * name:
342 * the element name to search for
343 * Returns:
344 * the GstElement with the given name, or NULL
346 public Element getByNameRecurseUp(char[] name)
348 // GstElement* gst_bin_get_by_name_recurse_up (GstBin *bin, const gchar *name);
349 return new Element( gst_bin_get_by_name_recurse_up(gstBin, Str.toStringz(name)) );
353 * Looks for an element inside the bin that implements the given
354 * interface. If such an element is found, it returns the element.
355 * You can cast this element to the given interface afterwards. If you want
356 * all elements that implement the interface, use
357 * gst_bin_iterate_all_by_interface(). This function recurses into child bins.
358 * MT safe. Caller owns returned reference.
359 * bin:
360 * a GstBin
361 * iface:
362 * the GType of an interface
363 * Returns:
364 * A GstElement inside the bin implementing the interface
366 public Element getByInterface(GType iface)
368 // GstElement* gst_bin_get_by_interface (GstBin *bin, GType iface);
369 return new Element( gst_bin_get_by_interface(gstBin, iface) );
373 * Gets an iterator for the elements in this bin.
374 * Each element yielded by the iterator will have its refcount increased, so
375 * unref after use.
376 * MT safe. Caller owns returned value.
377 * bin:
378 * a GstBin
379 * Returns:
380 * a GstIterator of GstElement, or NULL
382 public Iterator iterateElements()
384 // GstIterator* gst_bin_iterate_elements (GstBin *bin);
385 return new Iterator( gst_bin_iterate_elements(gstBin) );
389 * Gets an iterator for the elements in this bin.
390 * This iterator recurses into GstBin children.
391 * Each element yielded by the iterator will have its refcount increased, so
392 * unref after use.
393 * MT safe. Caller owns returned value.
394 * bin:
395 * a GstBin
396 * Returns:
397 * a GstIterator of GstElement, or NULL
399 public Iterator iterateRecurse()
401 // GstIterator* gst_bin_iterate_recurse (GstBin *bin);
402 return new Iterator( gst_bin_iterate_recurse(gstBin) );
406 * Gets an iterator for all elements in the bin that have the
407 * GST_ELEMENT_IS_SINK flag set.
408 * Each element yielded by the iterator will have its refcount increased, so
409 * unref after use.
410 * MT safe. Caller owns returned value.
411 * bin:
412 * a GstBin
413 * Returns:
414 * a GstIterator of GstElement, or NULL
416 public Iterator iterateSinks()
418 // GstIterator* gst_bin_iterate_sinks (GstBin *bin);
419 return new Iterator( gst_bin_iterate_sinks(gstBin) );
423 * Gets an iterator for the elements in this bin in topologically
424 * sorted order. This means that the elements are returned from
425 * the most downstream elements (sinks) to the sources.
426 * This function is used internally to perform the state changes
427 * of the bin elements.
428 * Each element yielded by the iterator will have its refcount increased, so
429 * unref after use.
430 * MT safe. Caller owns returned value.
431 * bin:
432 * a GstBin
433 * Returns:
434 * a GstIterator of GstElement, or NULL
436 public Iterator iterateSorted()
438 // GstIterator* gst_bin_iterate_sorted (GstBin *bin);
439 return new Iterator( gst_bin_iterate_sorted(gstBin) );
443 * Gets an iterator for all elements in the bin that have no sinkpads and have
444 * the GST_ELEMENT_IS_SINK flag unset.
445 * Each element yielded by the iterator will have its refcount increased, so
446 * unref after use.
447 * MT safe. Caller owns returned value.
448 * bin:
449 * a GstBin
450 * Returns:
451 * a GstIterator of GstElement, or NULL
453 public Iterator iterateSources()
455 // GstIterator* gst_bin_iterate_sources (GstBin *bin);
456 return new Iterator( gst_bin_iterate_sources(gstBin) );
460 * Looks for all elements inside the bin that implements the given
461 * interface. You can safely cast all returned elements to the given interface.
462 * The function recurses inside child bins. The iterator will yield a series
463 * of GstElement that should be unreffed after use.
464 * Each element yielded by the iterator will have its refcount increased, so
465 * unref after use.
466 * MT safe. Caller owns returned value.
467 * bin:
468 * a GstBin
469 * iface:
470 * the GType of an interface
471 * Returns:
472 * a GstIterator of GstElement for all elements in the bin
473 * implementing the given interface, or NULL
475 public Iterator iterateAllByInterface(GType iface)
477 // GstIterator* gst_bin_iterate_all_by_interface (GstBin *bin, GType iface);
478 return new Iterator( gst_bin_iterate_all_by_interface(gstBin, iface) );
482 * Adds a NULL-terminated list of elements to a bin. This function is
483 * equivalent to calling gst_bin_add() for each member of the list.
484 * bin:
485 * a GstBin
486 * element_1:
487 * the GstElement element to add to the bin
488 * ...:
489 * additional elements to add to the bin
491 public void addMany(Element element1, ... )
493 // void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...);
494 gst_bin_add_many(gstBin, (element1 is null) ? null : element1.getElementStruct());
498 * Remove a list of elements from a bin. This function is equivalent
499 * to calling gst_bin_remove() with each member of the list.
500 * bin:
501 * a GstBin
502 * element_1:
503 * the first GstElement to remove from the bin
504 * ...:
505 * NULL-terminated list of elements to remove from the bin
507 public void removeMany(Element element1, ... )
509 // void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...);
510 gst_bin_remove_many(gstBin, (element1 is null) ? null : element1.getElementStruct());
514 * Recursively looks for elements with an unconnected pad of the given
515 * direction within the specified bin and returns an unconnected pad
516 * if one is found, or NULL otherwise. If a pad is found, the caller
517 * owns a reference to it and should use gst_object_unref() on the
518 * pad when it is not needed any longer.
519 * bin:
520 * bin in which to look for elements with unconnected pads
521 * direction:
522 * whether to look for an unconnected source or sink pad
523 * Returns:
524 * unconnected pad of the given direction, or NULL.
525 * Since 0.10.3
527 public GstPad* findUnconnectedPad(GstPadDirection direction)
529 // GstPad* gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction);
530 return gst_bin_find_unconnected_pad(gstBin, direction);