2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstbin.c: GstBin container object and support code
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* #define GST_DEBUG_ENABLED */
24 #include "gst_private.h"
30 #include "gstscheduler.h"
32 GstElementDetails gst_bin_details = {
35 "Simple container object",
37 "Erik Walthinsen <omega@cse.ogi.edu>",
41 GType _gst_bin_type = 0;
43 static void gst_bin_dispose (GObject * object);
45 static GstElementStateReturn gst_bin_change_state (GstElement *element);
46 static GstElementStateReturn gst_bin_change_state_norecurse (GstBin *bin);
47 static gboolean gst_bin_change_state_type (GstBin *bin,
48 GstElementState state,
51 static gboolean gst_bin_iterate_func (GstBin * bin);
53 #ifndef GST_DISABLE_LOADSAVE
54 static xmlNodePtr gst_bin_save_thyself (GstObject * object, xmlNodePtr parent);
55 static void gst_bin_restore_thyself (GstObject * object, xmlNodePtr self);
58 /* Bin signals and args */
71 static void gst_bin_class_init (GstBinClass * klass);
72 static void gst_bin_init (GstBin * bin);
74 static GstElementClass *parent_class = NULL;
75 static guint gst_bin_signals[LAST_SIGNAL] = { 0 };
78 gst_bin_get_type (void)
81 static const GTypeInfo bin_info = {
85 (GClassInitFunc) gst_bin_class_init,
90 (GInstanceInitFunc) gst_bin_init,
94 _gst_bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
100 gst_bin_class_init (GstBinClass * klass)
102 GObjectClass *gobject_class;
103 GstObjectClass *gstobject_class;
104 GstElementClass *gstelement_class;
106 gobject_class = (GObjectClass *) klass;
107 gstobject_class = (GstObjectClass *) klass;
108 gstelement_class = (GstElementClass *) klass;
110 parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
112 gst_bin_signals[OBJECT_ADDED] =
113 g_signal_new ("object_added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
114 G_STRUCT_OFFSET (GstBinClass, object_added), NULL, NULL,
115 gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
117 gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_bin_dispose);
119 #ifndef GST_DISABLE_LOADSAVE
120 gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_bin_save_thyself);
121 gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_bin_restore_thyself);
124 gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_bin_change_state);
126 klass->change_state_type = GST_DEBUG_FUNCPTR (gst_bin_change_state_type);
127 klass->iterate = GST_DEBUG_FUNCPTR (gst_bin_iterate_func);
131 gst_bin_init (GstBin * bin)
133 /* in general, we prefer to use cothreads for most things */
134 GST_FLAG_SET (bin, GST_BIN_FLAG_PREFER_COTHREADS);
136 bin->numchildren = 0;
137 bin->children = NULL;
142 * @name: name of new bin
144 * Create a new bin with given name.
149 gst_bin_new (const gchar * name)
151 return gst_element_factory_make ("bin", name);
156 * @bin: the bin to get the clock of
158 * Get the current clock of the bin
160 * Returns: the clock of the bin
163 gst_bin_get_clock (GstBin *bin)
165 g_return_val_if_fail (bin != NULL, NULL);
166 g_return_val_if_fail (GST_IS_BIN (bin), NULL);
168 if (GST_ELEMENT_SCHED (bin))
169 return gst_scheduler_get_clock (GST_ELEMENT_SCHED (bin));
176 * @bin: the bin to set the clock for
177 * @clock: the clock to use.
179 * Force the bin to use the given clock. Use NULL to
180 * force it to use no clock at all.
183 gst_bin_use_clock (GstBin *bin, GstClock *clock)
185 g_return_if_fail (bin != NULL);
186 g_return_if_fail (GST_IS_BIN (bin));
188 if (GST_ELEMENT_SCHED (bin))
189 gst_scheduler_use_clock (GST_ELEMENT_SCHED (bin), clock);
193 * gst_bin_auto_clock:
194 * @bin: the bin to autoclock
196 * Let the bin select a clock automatically.
199 gst_bin_auto_clock (GstBin *bin)
201 g_return_if_fail (bin != NULL);
202 g_return_if_fail (GST_IS_BIN (bin));
204 if (GST_ELEMENT_SCHED (bin))
205 gst_scheduler_auto_clock (GST_ELEMENT_SCHED (bin));
209 gst_bin_set_element_sched (GstElement *element, GstScheduler *sched)
214 g_return_if_fail (element != NULL);
215 g_return_if_fail (GST_IS_ELEMENT (element));
216 g_return_if_fail (sched != NULL);
217 g_return_if_fail (GST_IS_SCHEDULER (sched));
219 GST_INFO (GST_CAT_SCHEDULING, "setting element \"%s\" sched to %p", GST_ELEMENT_NAME (element),
222 /* if it's actually a Bin */
223 if (GST_IS_BIN (element)) {
224 if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
225 GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "child is already a manager, not resetting");
226 gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element));
230 GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "setting children's schedule to parent's");
231 gst_scheduler_add_element (sched, element);
233 /* set the children's schedule */
234 children = GST_BIN (element)->children;
236 child = GST_ELEMENT (children->data);
237 children = g_list_next (children);
239 gst_bin_set_element_sched (child, sched);
242 /* otherwise, if it's just a regular old element */
244 gst_scheduler_add_element (sched, element);
250 gst_bin_unset_element_sched (GstElement *element, GstScheduler *sched)
255 g_return_if_fail (element != NULL);
256 g_return_if_fail (GST_IS_ELEMENT (element));
258 if (GST_ELEMENT_SCHED (element) == NULL) {
259 GST_INFO (GST_CAT_SCHEDULING, "element \"%s\" has no scheduler",
260 GST_ELEMENT_NAME (element));
264 GST_INFO (GST_CAT_SCHEDULING, "removing element \"%s\" from its sched %p",
265 GST_ELEMENT_NAME (element), GST_ELEMENT_SCHED (element));
267 /* if it's actually a Bin */
268 if (GST_IS_BIN (element)) {
270 if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
271 GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element,
272 "child is already a manager, not unsetting sched");
274 gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element));
278 /* for each child, remove them from their schedule */
279 children = GST_BIN (element)->children;
281 child = GST_ELEMENT (children->data);
282 children = g_list_next (children);
284 gst_bin_unset_element_sched (child, sched);
287 gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
289 /* otherwise, if it's just a regular old element */
291 gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
298 * @bin: the bin to add the elements to
299 * @element_1: the first element to add to the bin
300 * @...: NULL-terminated list of elements to add to the bin
302 * Add a list of elements to a bin. Uses #gst_bin_add.
305 gst_bin_add_many (GstBin *bin, GstElement *element_1, ...)
309 g_return_if_fail (bin != NULL);
310 g_return_if_fail (element_1 != NULL);
311 g_return_if_fail (GST_IS_BIN (bin));
312 g_return_if_fail (GST_IS_ELEMENT (element_1));
314 va_start (args, element_1);
317 gst_bin_add (bin, element_1);
319 element_1 = va_arg (args, GstElement*);
327 * @bin: #GstBin to add element to
328 * @element: #GstElement to add to bin
330 * Add the given element to the bin. Set the elements parent, and thus
334 gst_bin_add (GstBin *bin, GstElement *element)
337 GstElementState state;
340 g_return_if_fail (bin != NULL);
341 g_return_if_fail (GST_IS_BIN (bin));
342 g_return_if_fail (element != NULL);
343 g_return_if_fail (GST_IS_ELEMENT (element));
345 GST_DEBUG (GST_CAT_PARENTAGE, "adding element \"%s\" to bin \"%s\"",
346 GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin));
348 /* must be not be in PLAYING state in order to modify bin */
349 g_return_if_fail (GST_STATE (bin) != GST_STATE_PLAYING);
351 /* the element must not already have a parent */
352 g_return_if_fail (GST_ELEMENT_PARENT (element) == NULL);
354 /* then check to see if the element's name is already taken in the bin */
355 if (gst_object_check_uniqueness (bin->children,
356 GST_ELEMENT_NAME (element)) == FALSE)
358 g_warning ("Name %s is not unique in bin %s, not adding\n",
359 GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin));
363 /* set the element's parent and add the element to the bin's list of children */
364 gst_object_set_parent (GST_OBJECT (element), GST_OBJECT (bin));
366 bin->children = g_list_append (bin->children, element);
369 /* bump our internal state counter */
370 state = GST_STATE (element);
371 while (state >>= 1) state_idx++;
372 bin->child_states[state_idx]++;
374 /* now we have to deal with manager stuff
375 * we can only do this if there's a scheduler:
376 * if we're not a manager, and aren't attached to anything, we have no sched (yet) */
377 sched = GST_ELEMENT_SCHED (bin);
379 gst_bin_set_element_sched (element, sched);
382 GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "added child \"%s\"", GST_ELEMENT_NAME (element));
384 g_signal_emit (G_OBJECT (bin), gst_bin_signals[OBJECT_ADDED], 0, element);
389 * @bin: #GstBin to remove element from
390 * @element: #GstElement to remove
392 * Remove the element from its associated bin, unparenting as well.
395 gst_bin_remove (GstBin *bin, GstElement *element)
398 GstElementState state;
400 GST_DEBUG_ELEMENT (GST_CAT_PARENTAGE, bin, "trying to remove child %s", GST_ELEMENT_NAME (element));
402 g_return_if_fail (bin != NULL);
403 g_return_if_fail (GST_IS_BIN (bin));
404 g_return_if_fail (element != NULL);
405 g_return_if_fail (GST_IS_ELEMENT (element));
406 g_return_if_fail (bin->children != NULL);
408 /* must not be in PLAYING state in order to modify bin */
409 g_return_if_fail (GST_STATE (bin) != GST_STATE_PLAYING);
411 /* the element must have its parent set to the current bin */
412 g_return_if_fail (GST_ELEMENT_PARENT (element) == (GstObject *) bin);
414 /* the element must be in the bin's list of children */
415 if (g_list_find (bin->children, element) == NULL) {
416 g_warning ("no element \"%s\" in bin \"%s\"\n", GST_ELEMENT_NAME (element),
417 GST_ELEMENT_NAME (bin));
421 /* remove this element from the list of managed elements */
422 gst_bin_unset_element_sched (element, GST_ELEMENT_SCHED (bin));
424 /* now remove the element from the list of elements */
425 bin->children = g_list_remove (bin->children, element);
428 /* bump our internal state counter */
429 state = GST_STATE (element);
430 while (state >>= 1) state_idx++;
431 bin->child_states[state_idx]--;
433 GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "removed child %s", GST_ELEMENT_NAME (element));
435 gst_object_unparent (GST_OBJECT (element));
437 /* if we're down to zero children, force state to NULL */
438 if (bin->numchildren == 0 && GST_ELEMENT_SCHED (bin) != NULL) {
439 GST_STATE_PENDING (bin) = GST_STATE_NULL;
440 gst_bin_change_state_norecurse (bin);
445 * gst_bin_child_state_change:
446 * @bin: #GstBin with the child
447 * @oldstate: The old child state
448 * @newstate: The new child state
449 * @child: #GstElement that signaled an changed state
451 * An internal function to inform the parent bin about a state change
455 gst_bin_child_state_change (GstBin *bin, GstElementState oldstate, GstElementState newstate,
458 gint old_idx = 0, new_idx = 0, i;
460 GST_INFO (GST_CAT_STATES, "child %s changed state in bin %s from %s to %s",
461 GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin),
462 gst_element_state_get_name (oldstate), gst_element_state_get_name (newstate));
464 while (oldstate >>= 1) old_idx++;
465 while (newstate >>= 1) new_idx++;
468 bin->child_states[old_idx]--;
469 bin->child_states[new_idx]++;
471 for (i = GST_NUM_STATES - 1; i >= 0; i--) {
472 if (bin->child_states[i] != 0) {
473 gint state = (1 << i);
474 if (GST_STATE (bin) != state) {
475 GST_INFO (GST_CAT_STATES, "bin %s need state change to %s",
476 GST_ELEMENT_NAME (bin), gst_element_state_get_name (state));
477 GST_STATE_PENDING (bin) = state;
479 gst_bin_change_state_norecurse (bin);
488 static GstElementStateReturn
489 gst_bin_change_state (GstElement * element)
494 GstElementStateReturn ret;
495 GstElementState old_state, pending;
497 gboolean have_async = FALSE;
499 g_return_val_if_fail (GST_IS_BIN (element), GST_STATE_FAILURE);
501 bin = GST_BIN (element);
503 old_state = GST_STATE (element);
504 pending = GST_STATE_PENDING (element);
505 transition = GST_STATE_TRANSITION (element);
507 GST_INFO_ELEMENT (GST_CAT_STATES, element, "changing childrens' state from %s to %s",
508 gst_element_state_get_name (old_state), gst_element_state_get_name (pending));
510 if (pending == GST_STATE_VOID_PENDING)
511 return GST_STATE_SUCCESS;
513 children = bin->children;
516 child = GST_ELEMENT (children->data);
517 children = g_list_next (children);
519 switch (gst_element_set_state (child, pending)) {
520 case GST_STATE_FAILURE:
521 GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING;
522 GST_DEBUG (GST_CAT_STATES, "child '%s' failed to go to state %d(%s)",
523 GST_ELEMENT_NAME (child), pending, gst_element_state_get_name (pending));
525 gst_element_set_state (child, old_state);
526 if (GST_ELEMENT_SCHED (child) == GST_ELEMENT_SCHED (element)) {
527 /* reset to what is was */
528 GST_STATE_PENDING (element) = old_state;
529 gst_bin_change_state (element);
530 return GST_STATE_FAILURE;
533 case GST_STATE_ASYNC:
534 GST_DEBUG (GST_CAT_STATES, "child '%s' is changing state asynchronously",
535 GST_ELEMENT_NAME (child));
541 GST_INFO_ELEMENT (GST_CAT_STATES, element, "done changing bin's state from %s to %s, now in %s",
542 gst_element_state_get_name (old_state),
543 gst_element_state_get_name (pending),
544 gst_element_state_get_name (GST_STATE (element)));
547 ret = GST_STATE_ASYNC;
549 ret = GST_STATE_SUCCESS;
555 static GstElementStateReturn
556 gst_bin_change_state_norecurse (GstBin * bin)
558 GstElementStateReturn ret;
560 if (GST_ELEMENT_CLASS (parent_class)->change_state) {
561 GST_DEBUG_ELEMENT (GST_CAT_STATES, bin, "setting bin's own state");
562 ret = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT (bin));
567 return GST_STATE_FAILURE;
571 gst_bin_change_state_type (GstBin * bin, GstElementState state, GType type)
576 g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
577 g_return_val_if_fail (bin->numchildren != 0, FALSE);
579 children = bin->children;
581 child = GST_ELEMENT (children->data);
582 if (GST_IS_BIN (child)) {
583 if (!gst_bin_set_state_type (GST_BIN (child), state, type))
586 else if (G_TYPE_CHECK_INSTANCE_TYPE (child, type)) {
587 if (!gst_element_set_state (child, state))
590 children = g_list_next (children);
592 if (type == GST_TYPE_BIN)
593 gst_element_set_state (GST_ELEMENT (bin), state);
599 * gst_bin_set_state_type:
600 * @bin: #GstBin to set the state
601 * @state: the new state to set the elements to
602 * @type: the type of elements to change
604 * Sets the state of only those objects of the given type.
606 * Returns: indication if the state change was successfull
609 gst_bin_set_state_type (GstBin * bin, GstElementState state, GType type)
613 GST_DEBUG (GST_CAT_STATES, "gst_bin_set_state_type(\"%s\",%d,%s)",
614 GST_ELEMENT_NAME (bin), state, G_OBJECT_TYPE_NAME (type));
616 g_return_val_if_fail (bin != NULL, FALSE);
617 g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
619 oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS (bin));
621 if (oclass->change_state_type)
622 (oclass->change_state_type) (bin, state, type);
627 gst_bin_dispose (GObject * object)
629 GstBin *bin = GST_BIN (object);
630 GList *children, *orig;
633 GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
635 if (gst_element_get_state (GST_ELEMENT (object)) == GST_STATE_PLAYING)
636 gst_element_set_state (GST_ELEMENT (object), GST_STATE_PAUSED);
639 orig = children = g_list_copy (bin->children);
641 child = GST_ELEMENT (children->data);
642 gst_bin_remove (bin, child);
643 children = g_list_next (children);
645 g_list_free (bin->children);
648 bin->children = NULL;
649 bin->numchildren = 0;
651 G_OBJECT_CLASS (parent_class)->dispose (object);
655 * gst_bin_get_by_name:
656 * @bin: #Gstbin to search
657 * @name: the element name to search for
659 * Get the element with the given name from this bin.
661 * Returns: the element with the given name
664 gst_bin_get_by_name (GstBin * bin, const gchar * name)
669 g_return_val_if_fail (bin != NULL, NULL);
670 g_return_val_if_fail (GST_IS_BIN (bin), NULL);
671 g_return_val_if_fail (name != NULL, NULL);
673 GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "looking up child element %s", name);
675 children = bin->children;
677 child = GST_ELEMENT (children->data);
678 if (!strcmp (GST_OBJECT_NAME (child), name))
680 if (GST_IS_BIN (child)) {
681 GstElement *res = gst_bin_get_by_name (GST_BIN (child), name);
686 children = g_list_next (children);
693 * gst_bin_get_by_name_recurse_up:
694 * @bin: #Gstbin to search
695 * @name: the element name to search for
697 * Get the element with the given name from this bin. If the
698 * element is not found, a recursion is performed on the parent bin.
700 * Returns: the element with the given name
703 gst_bin_get_by_name_recurse_up (GstBin * bin, const gchar * name)
705 GstElement *result = NULL;
708 g_return_val_if_fail (bin != NULL, NULL);
709 g_return_val_if_fail (GST_IS_BIN (bin), NULL);
710 g_return_val_if_fail (name != NULL, NULL);
712 result = gst_bin_get_by_name (bin, name);
715 parent = gst_object_get_parent (GST_OBJECT (bin));
717 if (parent && GST_IS_BIN (parent)) {
718 result = gst_bin_get_by_name_recurse_up (GST_BIN (parent), name);
727 * @bin: #Gstbin to get the list from
729 * Get the list of elements in this bin.
731 * Returns: a GList of elements
734 gst_bin_get_list (GstBin * bin)
736 g_return_val_if_fail (bin != NULL, NULL);
737 g_return_val_if_fail (GST_IS_BIN (bin), NULL);
739 return bin->children;
742 #ifndef GST_DISABLE_LOADSAVE
744 gst_bin_save_thyself (GstObject * object, xmlNodePtr parent)
746 GstBin *bin = GST_BIN (object);
747 xmlNodePtr childlist, elementnode;
751 if (GST_OBJECT_CLASS (parent_class)->save_thyself)
752 GST_OBJECT_CLASS (parent_class)->save_thyself (GST_OBJECT (bin), parent);
754 childlist = xmlNewChild (parent, NULL, "children", NULL);
756 GST_INFO_ELEMENT (GST_CAT_XML, bin, "saving %d children", bin->numchildren);
758 children = bin->children;
760 child = GST_ELEMENT (children->data);
761 elementnode = xmlNewChild (childlist, NULL, "element", NULL);
762 gst_object_save_thyself (GST_OBJECT (child), elementnode);
763 children = g_list_next (children);
769 gst_bin_restore_thyself (GstObject * object, xmlNodePtr self)
771 GstBin *bin = GST_BIN (object);
772 xmlNodePtr field = self->xmlChildrenNode;
773 xmlNodePtr childlist;
776 if (!strcmp (field->name, "children")) {
777 GST_INFO_ELEMENT (GST_CAT_XML, GST_ELEMENT (object), "loading children");
778 childlist = field->xmlChildrenNode;
780 if (!strcmp (childlist->name, "element")) {
781 GstElement *element = gst_xml_make_element (childlist, GST_OBJECT (bin));
783 /* it had to be parented to find the pads, now we ref and unparent so
784 * we can add it to the bin */
785 gst_object_ref (GST_OBJECT (element));
786 gst_object_unparent (GST_OBJECT (element));
788 gst_bin_add (bin, element);
790 childlist = childlist->next;
797 #endif /* GST_DISABLE_LOADSAVE */
800 gst_bin_iterate_func (GstBin * bin)
802 /* only iterate if this is the manager bin */
803 if (GST_ELEMENT_SCHED (bin) &&
804 GST_ELEMENT_SCHED (bin)->parent == GST_ELEMENT (bin)) {
805 GstSchedulerState state;
807 state = gst_scheduler_iterate (GST_ELEMENT_SCHED (bin));
809 if (state == GST_SCHEDULER_STATE_RUNNING) {
812 else if (state == GST_SCHEDULER_STATE_ERROR) {
813 gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
817 g_warning ("bin \"%s\" can't be iterated on!\n", GST_ELEMENT_NAME (bin));
825 * @bin: #Gstbin to iterate
827 * Iterates over the elements in this bin.
829 * Returns: TRUE if the bin did something usefull. This value
830 * can be used to determine it the bin is in EOS.
833 gst_bin_iterate (GstBin * bin)
836 gboolean running = TRUE;
838 GST_DEBUG_ENTER ("(\"%s\")", GST_ELEMENT_NAME (bin));
840 g_return_val_if_fail (bin != NULL, FALSE);
841 g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
843 oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS (bin));
846 running = (oclass->iterate) (bin);
848 GST_DEBUG_LEAVE ("(\"%s\") %d", GST_ELEMENT_NAME (bin), running);
851 if (GST_STATE (bin) == GST_STATE_PLAYING && GST_STATE_PENDING (bin) == GST_STATE_VOID_PENDING) {
852 GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, bin,
853 "waiting for child shutdown after useless iteration");
854 gst_element_wait_state_change (GST_ELEMENT (bin));
855 GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, bin, "child shutdown");