merge from EVENTS1 on 20011016
[platform/upstream/gstreamer.git] / gst / gstbin.c
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstbin.c: GstBin container object and support code
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 //#define GST_DEBUG_ENABLED
24 #include "gst_private.h"
25
26 #include "gstbin.h"
27
28 #include "gstscheduler.h"
29
30 GstElementDetails gst_bin_details = {
31   "Generic bin",
32   "Bin",
33   "Simple container object",
34   VERSION,
35   "Erik Walthinsen <omega@cse.ogi.edu>",
36   "(C) 1999",
37 };
38
39
40 static void                     gst_bin_dispose         (GObject *object);
41
42 static GstElementStateReturn    gst_bin_change_state            (GstElement *element);
43 static GstElementStateReturn    gst_bin_change_state_norecurse  (GstBin *bin);
44 static gboolean                 gst_bin_change_state_type       (GstBin *bin,
45                                                                  GstElementState state,
46                                                                  GType type);
47
48 static gboolean                 gst_bin_iterate_func            (GstBin *bin);
49
50 #ifndef GST_DISABLE_LOADSAVE
51 static xmlNodePtr               gst_bin_save_thyself            (GstObject *object, xmlNodePtr parent);
52 static void                     gst_bin_restore_thyself         (GstObject *object, xmlNodePtr self);
53 #endif
54
55 /* Bin signals and args */
56 enum {
57   OBJECT_ADDED,
58   LAST_SIGNAL
59 };
60
61 enum {
62   ARG_0,
63   /* FILL ME */
64 };
65
66
67 static void gst_bin_class_init  (GstBinClass *klass);
68 static void gst_bin_init        (GstBin *bin);
69
70
71 static GstElementClass *parent_class = NULL;
72 static guint gst_bin_signals[LAST_SIGNAL] = { 0 };
73
74 GType
75 gst_bin_get_type (void)
76 {
77   static GType bin_type = 0;
78
79   if (!bin_type) {
80     static const GTypeInfo bin_info = {
81       sizeof(GstBinClass),
82       NULL,
83       NULL,
84       (GClassInitFunc)gst_bin_class_init,
85       NULL,
86       NULL,
87       sizeof(GstBin),
88       8,
89       (GInstanceInitFunc)gst_bin_init,
90       NULL
91     };
92     bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
93   }
94   return bin_type;
95 }
96
97 static void
98 gst_bin_class_init (GstBinClass *klass)
99 {
100   GObjectClass *gobject_class;
101   GstObjectClass *gstobject_class;
102   GstElementClass *gstelement_class;
103
104   gobject_class = (GObjectClass*)klass;
105   gstobject_class = (GstObjectClass*)klass;
106   gstelement_class = (GstElementClass*)klass;
107
108   parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
109
110   gst_bin_signals[OBJECT_ADDED] =
111     g_signal_new ("object_added", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_FIRST,
112                     G_STRUCT_OFFSET (GstBinClass, object_added), NULL, NULL,
113                     gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
114                     GST_TYPE_ELEMENT);
115
116   klass->change_state_type =            GST_DEBUG_FUNCPTR (gst_bin_change_state_type);
117   klass->iterate =                      GST_DEBUG_FUNCPTR (gst_bin_iterate_func);
118
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);
122 #endif
123
124   gstelement_class->change_state =      GST_DEBUG_FUNCPTR (gst_bin_change_state);
125
126   gobject_class->dispose =              GST_DEBUG_FUNCPTR (gst_bin_dispose);
127 }
128
129 static void
130 gst_bin_init (GstBin *bin)
131 {
132   // in general, we prefer to use cothreads for most things
133   GST_FLAG_SET (bin, GST_BIN_FLAG_PREFER_COTHREADS);
134
135   bin->numchildren = 0;
136   bin->children = NULL;
137   bin->eos_providers = NULL;
138   bin->num_eos_providers = 0;
139   bin->chains = NULL;
140   bin->eoscond = g_cond_new ();
141 }
142
143 /**
144  * gst_bin_new:
145  * @name: name of new bin
146  *
147  * Create a new bin with given name.
148  *
149  * Returns: new bin
150  */
151 GstElement*
152 gst_bin_new (const gchar *name)
153 {
154   return gst_elementfactory_make ("bin", name);
155 }
156
157 static inline void
158 gst_bin_reset_element_sched (GstElement *element, GstSchedule *sched)
159 {
160   GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "resetting element's scheduler");
161
162   // first remove the element from its current schedule, if any
163 //  if (GST_ELEMENT_SCHED(element))
164 //    GST_SCHEDULE_REMOVE_ELEMENT (GST_ELEMENT_SCHED(element), element);
165   // then set the new manager
166   gst_element_set_sched (element,sched);
167
168   // and add it to the new scheduler
169 //  if (sched)
170 //    GST_SCHEDULE_ADD_ELEMENT (sched, element);
171 }
172
173 static void
174 gst_bin_set_element_sched (GstElement *element,GstSchedule *sched)
175 {
176   GList *children;
177   GstElement *child;
178
179   g_return_if_fail (element != NULL);
180   g_return_if_fail (GST_IS_ELEMENT(element));
181   g_return_if_fail (sched != NULL);
182   g_return_if_fail (GST_IS_SCHEDULE(sched));
183
184   GST_INFO (GST_CAT_SCHEDULING, "setting element \"%s\" sched to %p",GST_ELEMENT_NAME(element),
185             sched);
186
187   // if it's actually a Bin
188   if (GST_IS_BIN(element)) {
189
190     if (GST_FLAG_IS_SET(element,GST_BIN_FLAG_MANAGER)) {
191       GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "child is already a manager, not resetting");
192       return;
193     }
194
195     GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "setting children's schedule to parent's");
196     GST_SCHEDULE_ADD_ELEMENT (sched, element);
197
198     // set the children's schedule
199     children = GST_BIN(element)->children;
200     while (children) {
201       child = GST_ELEMENT (children->data);
202       children = g_list_next(children);
203
204       gst_bin_set_element_sched (child, sched);
205     }
206
207   // otherwise, if it's just a regular old element
208   } else {
209     GST_SCHEDULE_ADD_ELEMENT (sched, element);
210   }
211 }
212
213
214 static void
215 gst_bin_unset_element_sched (GstElement *element)
216 {
217   GList *children;
218   GstElement *child;
219
220   g_return_if_fail (element != NULL);
221   g_return_if_fail (GST_IS_ELEMENT(element));
222
223   GST_INFO (GST_CAT_SCHEDULING, "removing element \"%s\" from it sched %p",
224             GST_ELEMENT_NAME(element),GST_ELEMENT_SCHED(element));
225
226   // if it's actually a Bin
227   if (GST_IS_BIN(element)) {
228
229     if (GST_FLAG_IS_SET(element,GST_BIN_FLAG_MANAGER)) {
230       GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "child is already a manager, not unsetting sched");
231       return;
232     }
233
234     // FIXME this check should be irrelevant
235     if (GST_ELEMENT_SCHED (element))
236       GST_SCHEDULE_REMOVE_ELEMENT (GST_ELEMENT_SCHED(element), element);
237
238     // for each child, remove them from their schedule
239     children = GST_BIN(element)->children;
240     while (children) {
241       child = GST_ELEMENT (children->data);
242       children = g_list_next(children);
243
244       gst_bin_unset_element_sched (child);
245     }
246
247   // otherwise, if it's just a regular old element
248   } else {
249     // FIXME this check should be irrelevant
250     if (GST_ELEMENT_SCHED (element))
251       GST_SCHEDULE_REMOVE_ELEMENT (GST_ELEMENT_SCHED(element), element);
252   }
253 }
254
255
256 /**
257  * gst_bin_add:
258  * @bin: #GstBin to add element to
259  * @element: #GstElement to add to bin
260  *
261  * Add the given element to the bin.  Set the elements parent, and thus
262  * add a reference.
263  */
264 void
265 gst_bin_add (GstBin *bin,
266              GstElement *element)
267 {
268   g_return_if_fail (bin != NULL);
269   g_return_if_fail (GST_IS_BIN (bin));
270   g_return_if_fail (element != NULL);
271   g_return_if_fail (GST_IS_ELEMENT (element));
272
273   GST_DEBUG (GST_CAT_PARENTAGE, "adding element \"%s\" to bin \"%s\"\n",
274              GST_ELEMENT_NAME(element),GST_ELEMENT_NAME(bin));
275
276   // must be not be in PLAYING state in order to modify bin
277 //  g_return_if_fail (GST_STATE (bin) != GST_STATE_PLAYING);
278
279   // the element must not already have a parent
280   g_return_if_fail (GST_ELEMENT_PARENT(element) == NULL);
281
282   // then check to see if the element's name is already taken in the bin
283   g_return_if_fail (gst_object_check_uniqueness (bin->children, GST_ELEMENT_NAME(element)) == TRUE);
284
285   // set the element's parent and add the element to the bin's list of children
286   gst_object_set_parent (GST_OBJECT (element), GST_OBJECT (bin));
287   bin->children = g_list_append (bin->children, element);
288   bin->numchildren++;
289
290   ///// now we have to deal with manager stuff
291   // we can only do this if there's a scheduler:
292   // if we're not a manager, and aren't attached to anything, we have no sched (yet)
293   if (GST_ELEMENT_SCHED(bin) != NULL)
294     gst_bin_set_element_sched (element, GST_ELEMENT_SCHED(bin));
295
296   GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "added child \"%s\"", GST_ELEMENT_NAME (element));
297
298   g_signal_emit (G_OBJECT (bin), gst_bin_signals[OBJECT_ADDED], 0, element);
299 }
300
301 /**
302  * gst_bin_remove:
303  * @bin: #GstBin to remove element from
304  * @element: #GstElement to remove
305  *
306  * Remove the element from its associated bin, unparenting as well.
307  */
308 void
309 gst_bin_remove (GstBin *bin,
310                 GstElement *element)
311 {
312   g_return_if_fail (bin != NULL);
313   g_return_if_fail (GST_IS_BIN (bin));
314   g_return_if_fail (element != NULL);
315   g_return_if_fail (GST_IS_ELEMENT (element));
316   g_return_if_fail (bin->children != NULL);
317
318   // must not be in PLAYING state in order to modify bin
319   g_return_if_fail (GST_STATE (bin) != GST_STATE_PLAYING);
320
321   // the element must have its parent set to the current bin
322   g_return_if_fail (GST_ELEMENT_PARENT(element) == (GstObject *)bin);
323
324   // the element must be in the bin's list of children
325   if (g_list_find(bin->children, element) == NULL) {
326     // FIXME this should be a warning!!!
327     GST_ERROR_OBJECT(bin,element,"no such element in bin");
328     return;
329   }
330
331   // remove this element from the list of managed elements
332   gst_bin_unset_element_sched (element);
333
334   // now remove the element from the list of elements
335   bin->children = g_list_remove (bin->children, element);
336   bin->numchildren--;
337
338   GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "removed child %s", GST_ELEMENT_NAME (element));
339
340   gst_object_unparent (GST_OBJECT (element));
341
342   /* if we're down to zero children, force state to NULL */
343   if (bin->numchildren == 0 && GST_ELEMENT_SCHED (bin) != NULL)
344     gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
345 }
346
347
348 static GstElementStateReturn
349 gst_bin_change_state (GstElement *element)
350 {
351   GstBin *bin;
352   GList *children;
353   GstElement *child;
354   GstElementStateReturn ret;
355
356 //  GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME  (element));
357
358   g_return_val_if_fail (GST_IS_BIN (element), GST_STATE_FAILURE);
359
360   bin = GST_BIN (element);
361
362 //  GST_DEBUG (GST_CAT_STATES,"currently %d(%s), %d(%s) pending\n",GST_STATE (element),
363 //          gst_element_statename (GST_STATE (element)), GST_STATE_PENDING (element),
364 //          gst_element_statename (GST_STATE_PENDING (element)));
365
366   GST_INFO_ELEMENT (GST_CAT_STATES, element, "changing childrens' state from %s to %s",
367                 gst_element_statename (GST_STATE (element)),
368                 gst_element_statename (GST_STATE_PENDING (element)));
369
370 //  g_return_val_if_fail(bin->numchildren != 0, GST_STATE_FAILURE);
371
372
373 //  g_print("-->\n");
374   children = bin->children;
375   while (children) {
376     child = GST_ELEMENT (children->data);
377 //    GST_DEBUG (GST_CAT_STATES,"setting state on '%s'\n",GST_ELEMENT_NAME  (child));
378     switch (gst_element_set_state (child, GST_STATE_PENDING (element))) {
379       case GST_STATE_FAILURE:
380         GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING;
381         GST_DEBUG (GST_CAT_STATES,"child '%s' failed to go to state %d(%s)\n", GST_ELEMENT_NAME (child),
382               GST_STATE_PENDING (element), gst_element_statename (GST_STATE_PENDING (element)));
383         return GST_STATE_FAILURE;
384         break;
385       case GST_STATE_ASYNC:
386         GST_DEBUG (GST_CAT_STATES,"child '%s' is changing state asynchronously\n", GST_ELEMENT_NAME (child));
387         break;
388     }
389 //    g_print("\n");
390     children = g_list_next (children);
391   }
392 //  g_print("<-- \"%s\"\n",GST_OBJECT_NAME(bin));
393
394   GST_INFO_ELEMENT (GST_CAT_STATES, element, "done changing bin's state from %s to %s",
395                 gst_element_statename (GST_STATE (element)),
396                 gst_element_statename (GST_STATE_PENDING (element)));
397   ret =  gst_bin_change_state_norecurse (bin);
398
399   return ret;
400 }
401
402
403 static GstElementStateReturn
404 gst_bin_change_state_norecurse (GstBin *bin)
405 {
406   if (GST_ELEMENT_CLASS (parent_class)->change_state) {
407     GST_DEBUG_ELEMENT (GST_CAT_STATES, bin, "setting bin's own state\n");
408     return GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT (bin));
409   } else
410     return GST_STATE_FAILURE;
411 }
412
413 static gboolean
414 gst_bin_change_state_type(GstBin *bin,
415                           GstElementState state,
416                           GType type)
417 {
418   GList *children;
419   GstElement *child;
420
421 //  g_print("gst_bin_change_state_type(\"%s\",%d,%d);\n",
422 //          GST_OBJECT_NAME(bin))),state,type);
423
424   g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
425   g_return_val_if_fail (bin->numchildren != 0, FALSE);
426
427 //  g_print("-->\n");
428   children = bin->children;
429   while (children) {
430     child = GST_ELEMENT (children->data);
431     if (GST_IS_BIN (child)) {
432       if (!gst_bin_set_state_type (GST_BIN (child), state,type))
433         return FALSE;
434     } else if (G_TYPE_CHECK_INSTANCE_TYPE (child,type)) {
435       if (!gst_element_set_state (child,state))
436         return FALSE;
437     }
438 //    g_print("\n");
439     children = g_list_next (children);
440   }
441   if (type == GST_TYPE_BIN)
442     gst_element_set_state (GST_ELEMENT (bin),state);
443
444   return TRUE;
445 }
446
447 /**
448  * gst_bin_set_state_type:
449  * @bin: #GstBin to set the state
450  * @state: the new state to set the elements to
451  * @type: the type of elements to change
452  *
453  * Sets the state of only those objects of the given type.
454  *
455  * Returns: indication if the state change was successfull
456  */
457 gboolean
458 gst_bin_set_state_type (GstBin *bin,
459                         GstElementState state,
460                         GType type)
461 {
462   GstBinClass *oclass;
463
464   GST_DEBUG (GST_CAT_STATES,"gst_bin_set_state_type(\"%s\",%d,%d)\n",
465           GST_ELEMENT_NAME (bin), state,type);
466
467   g_return_val_if_fail (bin != NULL, FALSE);
468   g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
469
470   oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS(bin));
471
472   if (oclass->change_state_type)
473     (oclass->change_state_type) (bin,state,type);
474   return TRUE;
475 }
476
477 static void
478 gst_bin_dispose (GObject *object)
479 {
480   GstBin *bin = GST_BIN (object);
481   GList *children, *orig;
482   GstElement *child;
483
484   GST_DEBUG (GST_CAT_REFCOUNTING,"dispose\n");
485
486   if (bin->children) {
487     orig = children = g_list_copy (bin->children);
488     while (children) {
489       child = GST_ELEMENT (children->data);
490       //gst_object_unref (GST_OBJECT (child));
491       //gst_object_unparent (GST_OBJECT (child));
492       gst_bin_remove (bin, child);
493       children = g_list_next (children);
494     }
495     g_list_free (orig);
496     g_list_free (bin->children);
497   }
498   bin->children = NULL;
499   bin->numchildren = 0;
500
501   g_cond_free (bin->eoscond);
502
503   G_OBJECT_CLASS (parent_class)->dispose (object);
504 }
505
506 /**
507  * gst_bin_get_by_name:
508  * @bin: #Gstbin to search
509  * @name: the element name to search for
510  *
511  * Get the element with the given name from this bin.
512  *
513  * Returns: the element with the given name
514  */
515 GstElement*
516 gst_bin_get_by_name (GstBin *bin,
517                      const gchar *name)
518 {
519   GList *children;
520   GstElement *child;
521
522   g_return_val_if_fail (bin != NULL, NULL);
523   g_return_val_if_fail (GST_IS_BIN (bin), NULL);
524   g_return_val_if_fail (name != NULL, NULL);
525
526   GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "looking up child element %s", name);
527
528   children = bin->children;
529   while (children) {
530     child = GST_ELEMENT (children->data);
531     if (!strcmp (GST_OBJECT_NAME(child),name))
532       return child;
533     if (GST_IS_BIN (child)) {
534       GstElement *res = gst_bin_get_by_name (GST_BIN (child), name);
535       if (res)
536         return res;
537     }
538     children = g_list_next (children);
539   }
540
541   return NULL;
542 }
543
544 /**
545  * gst_bin_get_by_name_recurse_up:
546  * @bin: #Gstbin to search
547  * @name: the element name to search for
548  *
549  * Get the element with the given name from this bin. If the
550  * element is not found, a recursion is performed on the parent bin.
551  *
552  * Returns: the element with the given name
553  */
554 GstElement*
555 gst_bin_get_by_name_recurse_up (GstBin *bin,
556                                 const gchar *name)
557 {
558   GstElement *result = NULL;
559   GstObject *parent;
560
561   g_return_val_if_fail (bin != NULL, NULL);
562   g_return_val_if_fail (GST_IS_BIN (bin), NULL);
563   g_return_val_if_fail (name != NULL, NULL);
564
565   result = gst_bin_get_by_name (bin, name);
566
567   if (result)
568     return result;
569
570   parent = gst_object_get_parent (GST_OBJECT (bin));
571
572   if (parent && GST_IS_BIN (parent)) {
573     result = gst_bin_get_by_name_recurse_up (GST_BIN (parent), name);
574   }
575
576   return result;
577 }
578
579 /**
580  * gst_bin_get_list:
581  * @bin: #Gstbin to get the list from
582  *
583  * Get the list of elements in this bin.
584  *
585  * Returns: a GList of elements
586  */
587 GList*
588 gst_bin_get_list (GstBin *bin)
589 {
590   g_return_val_if_fail (bin != NULL, NULL);
591   g_return_val_if_fail (GST_IS_BIN (bin), NULL);
592
593   return bin->children;
594 }
595
596 #ifndef GST_DISABLE_LOADSAVE
597 static xmlNodePtr
598 gst_bin_save_thyself (GstObject *object,
599                       xmlNodePtr parent)
600 {
601   GstBin *bin = GST_BIN (object);
602   xmlNodePtr childlist, elementnode;
603   GList *children;
604   GstElement *child;
605
606   if (GST_OBJECT_CLASS (parent_class)->save_thyself)
607     GST_OBJECT_CLASS (parent_class)->save_thyself (GST_OBJECT (bin), parent);
608
609   childlist = xmlNewChild (parent, NULL, "children", NULL);
610
611   GST_INFO_ELEMENT (GST_CAT_XML, bin, "saving %d children", bin->numchildren);
612
613   children = bin->children;
614   while (children) {
615     child = GST_ELEMENT (children->data);
616     elementnode = xmlNewChild (childlist, NULL, "element", NULL);
617     gst_object_save_thyself (GST_OBJECT (child), elementnode);
618     children = g_list_next (children);
619   }
620   return childlist;
621 }
622
623 static void
624 gst_bin_restore_thyself (GstObject *object,
625                          xmlNodePtr self)
626 {
627   GstBin *bin = GST_BIN (object);
628   xmlNodePtr field = self->xmlChildrenNode;
629   xmlNodePtr childlist;
630
631   while (field) {
632     if (!strcmp (field->name, "children")) {
633       GST_INFO_ELEMENT (GST_CAT_XML, GST_ELEMENT (object), "loading children");
634       childlist = field->xmlChildrenNode;
635       while (childlist) {
636         if (!strcmp (childlist->name, "element")) {
637           GstElement *element = gst_element_restore_thyself (childlist, GST_OBJECT (bin));
638
639           gst_bin_add (bin, element);
640         }
641         childlist = childlist->next;
642       }
643     }
644
645     field = field->next;
646   }
647 }
648 #endif /* GST_DISABLE_LOADSAVE */
649
650
651 /**
652  * gst_bin_iterate:
653  * @bin: #Gstbin to iterate
654  *
655  * Iterates over the elements in this bin.
656  *
657  * Returns: TRUE if the bin did something usefull. This value
658  *          can be used to determine it the bin is in EOS.
659  */
660 gboolean
661 gst_bin_iterate (GstBin *bin)
662 {
663   GstBinClass *oclass;
664   gboolean eos = TRUE;
665
666   GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME (bin));
667
668   oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS(bin));
669
670   if (oclass->iterate)
671     eos = (oclass->iterate) (bin);
672
673   GST_DEBUG_LEAVE("(\"%s\")",GST_ELEMENT_NAME (bin));
674
675   return eos;
676 }
677
678 /* out internal element fired EOS, we decrement the number of pending EOS childs */
679 G_GNUC_UNUSED static void
680 gst_bin_received_eos (GstElement *element, GstBin *bin)
681 {
682   GST_INFO_ELEMENT (GST_CAT_PLANNING, bin, "child %s fired eos, pending %d", GST_ELEMENT_NAME (element),
683                   bin->num_eos_providers);
684
685   GST_LOCK (bin);
686   if (bin->num_eos_providers) {
687     bin->num_eos_providers--;
688     g_cond_signal (bin->eoscond);
689   }
690   GST_UNLOCK (bin);
691 }
692
693 typedef struct {
694   gulong offset;
695   gulong size;
696 } region_struct;
697
698
699 static gboolean
700 gst_bin_iterate_func (GstBin *bin)
701 {
702   // only iterate if this is the manager bin
703   if (GST_ELEMENT_SCHED(bin)->parent == GST_ELEMENT (bin)) {
704     return GST_SCHEDULE_ITERATE(GST_ELEMENT_SCHED(bin));
705   } else {
706     GST_DEBUG (GST_CAT_SCHEDULING, "this bin can't be iterated on!\n");
707   }
708
709   return FALSE;
710 }
711