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
48 * - gstreamer.Iterator
51 * - GstElement* -> Element
52 * - GstIterator* -> Iterator
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
;
71 * GstBin is an element that can contain other GstElement, allowing them to be
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
85 * An iterator of elements in a bin can be retrieved with
86 * gst_bin_iterate_elements(). Various other iterators exist to retrieve the
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.
93 * A GstBin internally intercepts every GstMessage posted by its children and
94 * implements the following default behaviour for each of them:
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
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
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
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
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
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.
133 * A GstBin implements the following default behaviour for answering to a
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.
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,
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()
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.
187 * the name of the new bin
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
) )
219 cast(GCallback
)&callBackElementAdded
,
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
);
239 void delegate(Element
, Bin
)[] onElementRemovedListeners
;
240 void addOnElementRemoved(void delegate(Element
, Bin
) dlg
)
242 if ( !("element-removed" in connectedSignals
) )
247 cast(GCallback
)&callBackElementRemoved
,
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
);
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.
280 * the GstElement to add
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.
304 * the GstElement to remove
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.
323 * the element name to search for
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.
337 * - no element with the given name is found in the bin
338 * MT safe. Caller owns returned reference.
342 * the element name to search for
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.
362 * the GType of an interface
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
376 * MT safe. Caller owns returned value.
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
393 * MT safe. Caller owns returned value.
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
410 * MT safe. Caller owns returned value.
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
430 * MT safe. Caller owns returned value.
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
447 * MT safe. Caller owns returned value.
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
466 * MT safe. Caller owns returned value.
470 * the GType of an interface
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.
487 * the GstElement element to add to the bin
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.
503 * the first GstElement to remove from the bin
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.
520 * bin in which to look for elements with unconnected pads
522 * whether to look for an unconnected source or sink pad
524 * unconnected pad of the given direction, or NULL.
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
);