2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
2002-06-11 21:03:48 +00:00
|
|
|
*
|
2000-12-28 22:12:02 +00:00
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstbin.c: GstBin container object and support code
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* #define GST_DEBUG_ENABLED */
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
2000-12-08 18:24:16 +00:00
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
#include "gstevent.h"
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstbin.h"
|
2002-02-03 20:07:09 +00:00
|
|
|
#include "gstxml.h"
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-12-26 23:51:04 +00:00
|
|
|
#include "gstscheduler.h"
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
GstElementDetails gst_bin_details = {
|
2000-01-30 09:03:00 +00:00
|
|
|
"Generic bin",
|
2002-04-20 21:42:53 +00:00
|
|
|
"Generic/Bin",
|
2000-01-30 09:03:00 +00:00
|
|
|
"Simple container object",
|
|
|
|
VERSION,
|
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>",
|
|
|
|
"(C) 1999",
|
|
|
|
};
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
GType _gst_bin_type = 0;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
static void gst_bin_dispose (GObject * object);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
static GstElementStateReturn gst_bin_change_state (GstElement *element);
|
|
|
|
static GstElementStateReturn gst_bin_change_state_norecurse (GstBin *bin);
|
|
|
|
static gboolean gst_bin_change_state_type (GstBin *bin,
|
|
|
|
GstElementState state,
|
|
|
|
GType type);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
static gboolean gst_bin_iterate_func (GstBin * bin);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 06:45:56 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2001-12-15 22:37:35 +00:00
|
|
|
static xmlNodePtr gst_bin_save_thyself (GstObject * object, xmlNodePtr parent);
|
|
|
|
static void gst_bin_restore_thyself (GstObject * object, xmlNodePtr self);
|
2001-06-24 21:18:28 +00:00
|
|
|
#endif
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* Bin signals and args */
|
2001-12-15 22:37:35 +00:00
|
|
|
enum
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
OBJECT_ADDED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
enum
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
ARG_0,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
static void gst_bin_class_init (GstBinClass * klass);
|
|
|
|
static void gst_bin_init (GstBin * bin);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
static guint gst_bin_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
GType
|
2001-01-20 03:10:44 +00:00
|
|
|
gst_bin_get_type (void)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2001-10-21 18:00:31 +00:00
|
|
|
if (!_gst_bin_type) {
|
2001-06-25 01:20:11 +00:00
|
|
|
static const GTypeInfo bin_info = {
|
2001-12-15 22:37:35 +00:00
|
|
|
sizeof (GstBinClass),
|
2001-06-25 01:20:11 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2001-12-15 22:37:35 +00:00
|
|
|
(GClassInitFunc) gst_bin_class_init,
|
2001-06-25 01:20:11 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2001-12-15 22:37:35 +00:00
|
|
|
sizeof (GstBin),
|
2001-06-25 01:20:11 +00:00
|
|
|
8,
|
2001-12-15 22:37:35 +00:00
|
|
|
(GInstanceInitFunc) gst_bin_init,
|
2001-09-14 22:16:47 +00:00
|
|
|
NULL
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
2001-12-15 22:37:35 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
_gst_bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-10-21 18:00:31 +00:00
|
|
|
return _gst_bin_type;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_class_init (GstBinClass * klass)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
GObjectClass *gobject_class;
|
2001-01-29 00:06:02 +00:00
|
|
|
GstObjectClass *gstobject_class;
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstobject_class = (GstObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
gst_bin_signals[OBJECT_ADDED] =
|
2001-12-15 22:37:35 +00:00
|
|
|
g_signal_new ("object_added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstBinClass, object_added), NULL, NULL,
|
2001-12-18 19:03:07 +00:00
|
|
|
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_bin_dispose);
|
2002-01-18 22:44:19 +00:00
|
|
|
|
2001-06-25 06:45:56 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2001-12-15 22:37:35 +00:00
|
|
|
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_bin_save_thyself);
|
|
|
|
gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_bin_restore_thyself);
|
2001-06-24 21:18:28 +00:00
|
|
|
#endif
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_bin_change_state);
|
2001-10-17 10:21:27 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
klass->change_state_type = GST_DEBUG_FUNCPTR (gst_bin_change_state_type);
|
|
|
|
klass->iterate = GST_DEBUG_FUNCPTR (gst_bin_iterate_func);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static void
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_init (GstBin * bin)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2001-12-14 22:59:21 +00:00
|
|
|
/* in general, we prefer to use cothreads for most things */
|
2000-12-20 09:39:43 +00:00
|
|
|
GST_FLAG_SET (bin, GST_BIN_FLAG_PREFER_COTHREADS);
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
bin->numchildren = 0;
|
|
|
|
bin->children = NULL;
|
2002-06-10 16:48:47 +00:00
|
|
|
|
|
|
|
bin->pre_iterate_func = NULL;
|
|
|
|
bin->post_iterate_func = NULL;
|
|
|
|
bin->pre_iterate_private = NULL;
|
|
|
|
bin->post_iterate_private = NULL;
|
2002-06-03 19:50:41 +00:00
|
|
|
|
|
|
|
bin->iterate_mutex = g_mutex_new ();
|
|
|
|
bin->iterate_cond = g_cond_new ();
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bin_new:
|
|
|
|
* @name: name of new bin
|
|
|
|
*
|
|
|
|
* Create a new bin with given name.
|
|
|
|
*
|
|
|
|
* Returns: new bin
|
|
|
|
*/
|
2001-12-15 22:37:35 +00:00
|
|
|
GstElement *
|
|
|
|
gst_bin_new (const gchar * name)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2002-04-11 20:35:18 +00:00
|
|
|
return gst_element_factory_make ("bin", name);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_get_clock:
|
2002-04-23 15:02:35 +00:00
|
|
|
* @bin: a #GstBin to get the clock of
|
2002-03-31 14:04:50 +00:00
|
|
|
*
|
2002-04-23 15:02:35 +00:00
|
|
|
* Gets the current clock of the (scheduler of the) bin.
|
2002-03-31 14:04:50 +00:00
|
|
|
*
|
2002-04-23 15:02:35 +00:00
|
|
|
* Returns: the #GstClock of the bin
|
2002-03-31 14:04:50 +00:00
|
|
|
*/
|
2002-02-03 20:07:09 +00:00
|
|
|
GstClock*
|
|
|
|
gst_bin_get_clock (GstBin *bin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (bin != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
if (GST_ELEMENT_SCHED (bin))
|
|
|
|
return gst_scheduler_get_clock (GST_ELEMENT_SCHED (bin));
|
|
|
|
|
|
|
|
return NULL;
|
2002-02-03 20:07:09 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_use_clock:
|
|
|
|
* @bin: the bin to set the clock for
|
|
|
|
* @clock: the clock to use.
|
|
|
|
*
|
|
|
|
* Force the bin to use the given clock. Use NULL to
|
|
|
|
* force it to use no clock at all.
|
|
|
|
*/
|
2002-02-03 20:07:09 +00:00
|
|
|
void
|
|
|
|
gst_bin_use_clock (GstBin *bin, GstClock *clock)
|
|
|
|
{
|
|
|
|
g_return_if_fail (bin != NULL);
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
if (GST_ELEMENT_SCHED (bin))
|
|
|
|
gst_scheduler_use_clock (GST_ELEMENT_SCHED (bin), clock);
|
2002-02-03 20:07:09 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_auto_clock:
|
|
|
|
* @bin: the bin to autoclock
|
|
|
|
*
|
|
|
|
* Let the bin select a clock automatically.
|
|
|
|
*/
|
2002-02-03 20:07:09 +00:00
|
|
|
void
|
|
|
|
gst_bin_auto_clock (GstBin *bin)
|
|
|
|
{
|
|
|
|
g_return_if_fail (bin != NULL);
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
if (GST_ELEMENT_SCHED (bin))
|
|
|
|
gst_scheduler_auto_clock (GST_ELEMENT_SCHED (bin));
|
2002-02-03 20:07:09 +00:00
|
|
|
}
|
|
|
|
|
2001-09-14 22:16:47 +00:00
|
|
|
static void
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_bin_set_element_sched (GstElement *element, GstScheduler *sched)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
|
|
|
GList *children;
|
|
|
|
GstElement *child;
|
|
|
|
|
|
|
|
g_return_if_fail (element != NULL);
|
2001-12-15 22:37:35 +00:00
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
g_return_if_fail (sched != NULL);
|
2001-12-15 22:37:35 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_INFO (GST_CAT_SCHEDULING, "setting element \"%s\" sched to %p", GST_ELEMENT_NAME (element),
|
|
|
|
sched);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* if it's actually a Bin */
|
2001-12-15 22:37:35 +00:00
|
|
|
if (GST_IS_BIN (element)) {
|
2001-12-04 22:12:50 +00:00
|
|
|
if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "child is already a manager, not resetting");
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "setting children's schedule to parent's");
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_scheduler_add_element (sched, element);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* set the children's schedule */
|
2001-12-15 22:37:35 +00:00
|
|
|
children = GST_BIN (element)->children;
|
2001-05-25 21:00:07 +00:00
|
|
|
while (children) {
|
|
|
|
child = GST_ELEMENT (children->data);
|
2001-12-15 22:37:35 +00:00
|
|
|
children = g_list_next (children);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
gst_bin_set_element_sched (child, sched);
|
|
|
|
}
|
2001-12-15 22:37:35 +00:00
|
|
|
}
|
2001-12-14 22:59:21 +00:00
|
|
|
/* otherwise, if it's just a regular old element */
|
2001-12-15 22:37:35 +00:00
|
|
|
else {
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_scheduler_add_element (sched, element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-14 22:16:47 +00:00
|
|
|
static void
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_bin_unset_element_sched (GstElement *element, GstScheduler *sched)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
|
|
|
GList *children;
|
|
|
|
GstElement *child;
|
|
|
|
|
|
|
|
g_return_if_fail (element != NULL);
|
2001-12-15 22:37:35 +00:00
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-19 19:22:53 +00:00
|
|
|
if (GST_ELEMENT_SCHED (element) == NULL) {
|
|
|
|
GST_INFO (GST_CAT_SCHEDULING, "element \"%s\" has no scheduler",
|
|
|
|
GST_ELEMENT_NAME (element));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
GST_INFO (GST_CAT_SCHEDULING, "removing element \"%s\" from its sched %p",
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_ELEMENT_NAME (element), GST_ELEMENT_SCHED (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* if it's actually a Bin */
|
2001-12-15 22:37:35 +00:00
|
|
|
if (GST_IS_BIN (element)) {
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
|
|
|
|
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element,
|
|
|
|
"child is already a manager, not unsetting sched");
|
2002-03-30 17:05:03 +00:00
|
|
|
if (sched) {
|
|
|
|
gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element));
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-12-14 22:59:21 +00:00
|
|
|
/* for each child, remove them from their schedule */
|
2001-12-15 22:37:35 +00:00
|
|
|
children = GST_BIN (element)->children;
|
2001-05-25 21:00:07 +00:00
|
|
|
while (children) {
|
|
|
|
child = GST_ELEMENT (children->data);
|
2001-12-15 22:37:35 +00:00
|
|
|
children = g_list_next (children);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_bin_unset_element_sched (child, sched);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
|
2001-12-15 22:37:35 +00:00
|
|
|
}
|
2001-12-14 22:59:21 +00:00
|
|
|
/* otherwise, if it's just a regular old element */
|
2001-12-15 22:37:35 +00:00
|
|
|
else {
|
|
|
|
gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-21 14:44:27 +00:00
|
|
|
/**
|
2002-03-31 14:04:50 +00:00
|
|
|
* gst_bin_add_many:
|
|
|
|
* @bin: the bin to add the elements to
|
2002-02-21 14:44:27 +00:00
|
|
|
* @element_1: the first element to add to the bin
|
|
|
|
* @...: NULL-terminated list of elements to add to the bin
|
|
|
|
*
|
|
|
|
* Add a list of elements to a bin. Uses #gst_bin_add.
|
2002-03-31 14:04:50 +00:00
|
|
|
*/
|
2002-02-21 14:44:27 +00:00
|
|
|
void
|
|
|
|
gst_bin_add_many (GstBin *bin, GstElement *element_1, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
g_return_if_fail (bin != NULL);
|
|
|
|
g_return_if_fail (element_1 != NULL);
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element_1));
|
|
|
|
|
|
|
|
va_start (args, element_1);
|
|
|
|
|
|
|
|
while (element_1) {
|
|
|
|
gst_bin_add (bin, element_1);
|
|
|
|
|
|
|
|
element_1 = va_arg (args, GstElement*);
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_add:
|
|
|
|
* @bin: #GstBin to add element to
|
|
|
|
* @element: #GstElement to add to bin
|
|
|
|
*
|
|
|
|
* Add the given element to the bin. Set the elements parent, and thus
|
|
|
|
* add a reference.
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_bin_add (GstBin *bin, GstElement *element)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2001-12-10 18:08:35 +00:00
|
|
|
gint state_idx = 0;
|
|
|
|
GstElementState state;
|
2002-03-30 17:05:03 +00:00
|
|
|
GstScheduler *sched;
|
2001-12-10 18:08:35 +00:00
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
g_return_if_fail (bin != NULL);
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (GST_CAT_PARENTAGE, "adding element \"%s\" to bin \"%s\"",
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin));
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* must be not be in PLAYING state in order to modify bin */
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_if_fail (GST_STATE (bin) != GST_STATE_PLAYING);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* the element must not already have a parent */
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_if_fail (GST_ELEMENT_PARENT (element) == NULL);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* then check to see if the element's name is already taken in the bin */
|
2002-04-21 14:16:36 +00:00
|
|
|
if (gst_object_check_uniqueness (bin->children,
|
|
|
|
GST_ELEMENT_NAME (element)) == FALSE)
|
|
|
|
{
|
|
|
|
g_warning ("Name %s is not unique in bin %s, not adding\n",
|
|
|
|
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin));
|
|
|
|
return;
|
|
|
|
}
|
2000-07-17 17:14:15 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* set the element's parent and add the element to the bin's list of children */
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_set_parent (GST_OBJECT (element), GST_OBJECT (bin));
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
bin->children = g_list_append (bin->children, element);
|
2000-01-30 09:03:00 +00:00
|
|
|
bin->numchildren++;
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* bump our internal state counter */
|
2001-12-10 18:08:35 +00:00
|
|
|
state = GST_STATE (element);
|
2001-12-15 22:37:35 +00:00
|
|
|
while (state >>= 1) state_idx++;
|
2001-12-10 18:08:35 +00:00
|
|
|
bin->child_states[state_idx]++;
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
/* now we have to deal with manager stuff
|
|
|
|
* we can only do this if there's a scheduler:
|
|
|
|
* if we're not a manager, and aren't attached to anything, we have no sched (yet) */
|
2002-03-30 17:05:03 +00:00
|
|
|
sched = GST_ELEMENT_SCHED (bin);
|
|
|
|
if (sched) {
|
|
|
|
gst_bin_set_element_sched (element, sched);
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
2000-12-30 02:41:15 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "added child \"%s\"", GST_ELEMENT_NAME (element));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
g_signal_emit (G_OBJECT (bin), gst_bin_signals[OBJECT_ADDED], 0, element);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bin_remove:
|
2000-07-17 17:14:15 +00:00
|
|
|
* @bin: #GstBin to remove element from
|
2000-01-30 09:03:00 +00:00
|
|
|
* @element: #GstElement to remove
|
|
|
|
*
|
|
|
|
* Remove the element from its associated bin, unparenting as well.
|
2002-06-11 21:03:48 +00:00
|
|
|
* The element will also be unreferenced so there's no need to call
|
|
|
|
* gst_object_unref on it.
|
|
|
|
* If you want the element to still exist after removing, you need to call
|
|
|
|
* #gst_object_ref before removing it from the bin.
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_bin_remove (GstBin *bin, GstElement *element)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2001-12-10 18:08:35 +00:00
|
|
|
gint state_idx = 0;
|
|
|
|
GstElementState state;
|
|
|
|
|
2002-04-03 18:26:03 +00:00
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_PARENTAGE, bin, "trying to remove child %s", GST_ELEMENT_NAME (element));
|
2002-02-24 19:08:30 +00:00
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
g_return_if_fail (bin != NULL);
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (bin->children != NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* must not be in PLAYING state in order to modify bin */
|
2001-05-25 21:00:07 +00:00
|
|
|
g_return_if_fail (GST_STATE (bin) != GST_STATE_PLAYING);
|
2000-07-17 17:14:15 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* the element must have its parent set to the current bin */
|
2001-12-15 22:37:35 +00:00
|
|
|
g_return_if_fail (GST_ELEMENT_PARENT (element) == (GstObject *) bin);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* the element must be in the bin's list of children */
|
2001-12-15 22:37:35 +00:00
|
|
|
if (g_list_find (bin->children, element) == NULL) {
|
|
|
|
g_warning ("no element \"%s\" in bin \"%s\"\n", GST_ELEMENT_NAME (element),
|
|
|
|
GST_ELEMENT_NAME (bin));
|
2000-12-30 02:41:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* remove this element from the list of managed elements */
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_bin_unset_element_sched (element, GST_ELEMENT_SCHED (bin));
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* now remove the element from the list of elements */
|
2000-11-04 18:54:07 +00:00
|
|
|
bin->children = g_list_remove (bin->children, element);
|
2000-01-30 09:03:00 +00:00
|
|
|
bin->numchildren--;
|
2000-07-17 17:14:15 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* bump our internal state counter */
|
2001-12-10 18:08:35 +00:00
|
|
|
state = GST_STATE (element);
|
2001-12-15 22:37:35 +00:00
|
|
|
while (state >>= 1) state_idx++;
|
2001-12-10 18:08:35 +00:00
|
|
|
bin->child_states[state_idx]--;
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "removed child %s", GST_ELEMENT_NAME (element));
|
2000-12-30 02:41:15 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unparent (GST_OBJECT (element));
|
|
|
|
|
2000-07-17 17:14:15 +00:00
|
|
|
/* if we're down to zero children, force state to NULL */
|
2001-12-20 20:03:10 +00:00
|
|
|
if (bin->numchildren == 0 && GST_ELEMENT_SCHED (bin) != NULL) {
|
|
|
|
GST_STATE_PENDING (bin) = GST_STATE_NULL;
|
|
|
|
gst_bin_change_state_norecurse (bin);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2002-01-01 15:58:51 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_child_state_change:
|
|
|
|
* @bin: #GstBin with the child
|
|
|
|
* @oldstate: The old child state
|
|
|
|
* @newstate: The new child state
|
|
|
|
* @child: #GstElement that signaled an changed state
|
|
|
|
*
|
|
|
|
* An internal function to inform the parent bin about a state change
|
|
|
|
* of a child.
|
|
|
|
*/
|
2001-12-20 20:03:10 +00:00
|
|
|
void
|
2002-01-01 15:58:51 +00:00
|
|
|
gst_bin_child_state_change (GstBin *bin, GstElementState oldstate, GstElementState newstate,
|
2001-12-22 21:18:17 +00:00
|
|
|
GstElement *child)
|
2001-12-04 22:12:50 +00:00
|
|
|
{
|
|
|
|
gint old_idx = 0, new_idx = 0, i;
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_INFO (GST_CAT_STATES, "child %s changed state in bin %s from %s to %s",
|
|
|
|
GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin),
|
2002-04-23 11:15:18 +00:00
|
|
|
gst_element_state_get_name (oldstate), gst_element_state_get_name (newstate));
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2002-01-01 16:01:00 +00:00
|
|
|
while (oldstate >>= 1) old_idx++;
|
|
|
|
while (newstate >>= 1) new_idx++;
|
2001-12-04 22:12:50 +00:00
|
|
|
|
|
|
|
GST_LOCK (bin);
|
|
|
|
bin->child_states[old_idx]--;
|
|
|
|
bin->child_states[new_idx]++;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
for (i = GST_NUM_STATES - 1; i >= 0; i--) {
|
2001-12-04 22:12:50 +00:00
|
|
|
if (bin->child_states[i] != 0) {
|
2002-01-01 13:51:04 +00:00
|
|
|
gint state = (1 << i);
|
|
|
|
if (GST_STATE (bin) != state) {
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_INFO (GST_CAT_STATES, "bin %s need state change to %s",
|
2002-04-23 11:15:18 +00:00
|
|
|
GST_ELEMENT_NAME (bin), gst_element_state_get_name (state));
|
2002-01-01 13:51:04 +00:00
|
|
|
GST_STATE_PENDING (bin) = state;
|
2002-03-30 17:05:03 +00:00
|
|
|
GST_UNLOCK (bin);
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_bin_change_state_norecurse (bin);
|
2002-03-30 17:05:03 +00:00
|
|
|
return;
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GST_UNLOCK (bin);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static GstElementStateReturn
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_change_state (GstElement * element)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstBin *bin;
|
|
|
|
GList *children;
|
|
|
|
GstElement *child;
|
2001-03-07 21:52:56 +00:00
|
|
|
GstElementStateReturn ret;
|
2001-12-04 22:12:50 +00:00
|
|
|
GstElementState old_state, pending;
|
2002-02-03 20:07:09 +00:00
|
|
|
gint transition;
|
2001-12-04 22:12:50 +00:00
|
|
|
gboolean have_async = FALSE;
|
2000-12-20 09:39:43 +00:00
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BIN (element), GST_STATE_FAILURE);
|
Changed the way things are scheduled, especially sources. A Src used to have a push() function, and optionally a pus...
Original commit message from CVS:
Changed the way things are scheduled, especially sources. A Src used to
have a push() function, and optionally a pushregion() to deal with async
reads, etc. That whole thing has gone away, in favor of providing a
pull() function for the output (Src) pad instead, ala chain functions.
This makes constructing cothreaded schedules out of non-loop elements
somewhat easier. Basically there was always a question as to which pad
was being dealt with. In the pullregion case, cothread-specific data was
used to try to pass the region struct to the right place, which is a slow
hack. And in general, the push function severely limited the kind of
tricks that could be played when there's more than one output pad, such as
a multi-out file reader with async capabilities on each pad independently.
This changes the way cothread scheduling occurs. Instead of the hack to
deal with Src's by calling their push() function (or optionally the
pushregion(), in certain cases), we now are working towards a general
mechanism where pads are the only thing that are dealt with directly.
An optimization was made in the process of doing this: the loopfunction
actually run as the outer [stack] frame of the cothread is now set more
intelligently in create_plan() based on what kind of element it is. We
now have:
loopfunc_wrapper: used for loop-based elements, it simply calls the
loopfunc in a loop, paying attention to COTHREAD_STOPPING (see
below). It currently does other, soon to be depracated, stuff.
pullsrc_wrapper: wraps a Src that's not loop-based (since your options
are now loop- or pull-based)
There will be a couple more to deal with other cases, such as Connections
and chain-based elements. The general idea is that it's a lot more
efficient to make the decisions once in create_plan than to keep doing
this huge if/else chain in the wrapper. Just choose the right wrapper up
front. It'll be most apparent performance-wise in the case of whichever
element context is switched to first for each iteration, since the whole
wrapper setup is done for every iteration.
The tricky part is that there is now a bit of overloading of the function
pointers in a pad. The current meanings (possibly to change a bit more
soon) are:
chainfunc: as always, chainfunc pointer is mirrored between peer pads
(this may change, and the chain func may end up in pushfunc)
pushfunc: SrcPad: gst_pad_pushfunc_proxy, cothread_switch to peer
SinkPad: none (may take over chainfunc, see below) pullfunc:
SrcPad: Src or Connection's function to construct buffers
SinkPad: gst_pad_pullfunc_proxy, cothread_switch to peer
There are a number of issues remaining with the scheduling, not the least
of which is the fact that Connections are still dealt with the old way,
with _push() functions and such. I'm trying to figure out a way to unify
the system so it makes sense. Following the scheduling system is hard
enough, trying to change it is murder.
Another useful scheduling addition, mentioned above, is COTHREAD_STOPPING.
It's an element flag that's used to signal whatever code is running in
cothread context that it should be finishing up and exiting soon. An
example of this is in plugins/cobin/spindentity.c. All the loops should
now be composed of do/while loops, rather than while(1) loops:
do {
buf = gst_pad_pull(spindentity->sinkpad);
gst_pad_push(spindentity->srcpad,buf);
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
The reason for this is that COTHREAD_STOPPING may be set before the above
loop ever gets started. It wouldn't do for the body of the loop to never
once get called, that would simply stall the pipeline. Note that only the
core library code is ever responsible for setting and unsetting this flag.
All elements have to do is respond to it by cleanly exiting the loop and
the function holding it.
This is needed primarily to allow iterations to occur properly.
Basically, there's a single entry point in the cothread scheduling loop,
gst_bin_iterate_func() simply switches to this cothread. If the element
in this context is allowed to loop infinitely, nothing would even switch
back to the context from which the iterate() was originally called. This
is a bit of a problem. The solution is for there to be an implicit switch
back to the originating context. Now, even I'm not sure exactly how this
works, but if the cothread that's switched to actually returns, execution
returns back to the calling context, i.e. iterate_func().
COTHREAD_STOPPING is therefore set just before switching into this
(currently randomly chosen) context, on the assumption that it will return
promptly after finishing its duties. The burden of clearing the flag
falls to the various wrapper functions provided by the Bin code, thus
element writers don't have to worry about doing that at all (and simply
shouldn't).
Related changes:
All the sources in elements/ have been changed to reflect the new system.
FIXMEs:
1) gstpipeline.c calls gst_src_push at some point, dunno why, it's
commented out now.
2) any other sources, including vcdsrc, dvdsrc, and v4lsrc will break
badly and need to be modified to work as pull-based sources.
2000-12-04 10:52:30 +00:00
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
bin = GST_BIN (element);
|
2000-07-17 17:14:15 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
old_state = GST_STATE (element);
|
|
|
|
pending = GST_STATE_PENDING (element);
|
2002-02-03 20:07:09 +00:00
|
|
|
transition = GST_STATE_TRANSITION (element);
|
2000-12-30 02:41:15 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_STATES, element, "changing childrens' state from %s to %s",
|
2002-04-23 11:15:18 +00:00
|
|
|
gst_element_state_get_name (old_state), gst_element_state_get_name (pending));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
if (pending == GST_STATE_VOID_PENDING)
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
children = bin->children;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
while (children) {
|
2002-06-17 16:00:10 +00:00
|
|
|
GstElementState old_child_state;
|
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
child = GST_ELEMENT (children->data);
|
2001-12-04 22:12:50 +00:00
|
|
|
children = g_list_next (children);
|
|
|
|
|
2002-06-17 16:00:10 +00:00
|
|
|
old_child_state = GST_STATE (child);
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
switch (gst_element_set_state (child, pending)) {
|
2000-07-17 17:14:15 +00:00
|
|
|
case GST_STATE_FAILURE:
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING;
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (GST_CAT_STATES, "child '%s' failed to go to state %d(%s)",
|
2002-04-23 11:15:18 +00:00
|
|
|
GST_ELEMENT_NAME (child), pending, gst_element_state_get_name (pending));
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2002-06-17 16:00:10 +00:00
|
|
|
gst_element_set_state (child, old_child_state);
|
2001-12-04 22:12:50 +00:00
|
|
|
if (GST_ELEMENT_SCHED (child) == GST_ELEMENT_SCHED (element)) {
|
2001-12-22 21:18:17 +00:00
|
|
|
/* reset to what is was */
|
|
|
|
GST_STATE_PENDING (element) = old_state;
|
2002-06-17 16:00:10 +00:00
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
gst_bin_change_state (element);
|
2002-06-17 16:00:10 +00:00
|
|
|
/* see if the old state was set */
|
|
|
|
if (GST_STATE (element) == old_state)
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
|
|
|
|
/* something wacky happened, we can't even go back */
|
2001-12-15 22:37:35 +00:00
|
|
|
return GST_STATE_FAILURE;
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
2001-12-15 22:37:35 +00:00
|
|
|
break;
|
2000-07-17 17:14:15 +00:00
|
|
|
case GST_STATE_ASYNC:
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (GST_CAT_STATES, "child '%s' is changing state asynchronously",
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_ELEMENT_NAME (child));
|
2001-12-04 22:12:50 +00:00
|
|
|
have_async = TRUE;
|
2001-12-15 22:37:35 +00:00
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_STATES, element, "done changing bin's state from %s to %s, now in %s",
|
2002-04-23 11:15:18 +00:00
|
|
|
gst_element_state_get_name (old_state),
|
|
|
|
gst_element_state_get_name (pending),
|
|
|
|
gst_element_state_get_name (GST_STATE (element)));
|
2001-12-04 22:12:50 +00:00
|
|
|
|
|
|
|
if (have_async)
|
|
|
|
ret = GST_STATE_ASYNC;
|
|
|
|
else
|
|
|
|
ret = GST_STATE_SUCCESS;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
return ret;
|
2000-07-17 17:14:15 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static GstElementStateReturn
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_change_state_norecurse (GstBin * bin)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2002-02-03 20:07:09 +00:00
|
|
|
GstElementStateReturn ret;
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state) {
|
2002-04-03 18:26:03 +00:00
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_STATES, bin, "setting bin's own state");
|
2002-02-03 20:07:09 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT (bin));
|
|
|
|
|
|
|
|
return ret;
|
2001-12-15 22:37:35 +00:00
|
|
|
}
|
|
|
|
else
|
2000-07-17 17:14:15 +00:00
|
|
|
return GST_STATE_FAILURE;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static gboolean
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_change_state_type (GstBin * bin, GstElementState state, GType type)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *children;
|
|
|
|
GstElement *child;
|
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
|
|
|
|
g_return_val_if_fail (bin->numchildren != 0, FALSE);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
children = bin->children;
|
|
|
|
while (children) {
|
2000-11-04 18:54:07 +00:00
|
|
|
child = GST_ELEMENT (children->data);
|
|
|
|
if (GST_IS_BIN (child)) {
|
2001-12-15 22:37:35 +00:00
|
|
|
if (!gst_bin_set_state_type (GST_BIN (child), state, type))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (G_TYPE_CHECK_INSTANCE_TYPE (child, type)) {
|
|
|
|
if (!gst_element_set_state (child, state))
|
|
|
|
return FALSE;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2000-11-04 18:54:07 +00:00
|
|
|
children = g_list_next (children);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
if (type == GST_TYPE_BIN)
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (bin), state);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_set_state_type:
|
|
|
|
* @bin: #GstBin to set the state
|
|
|
|
* @state: the new state to set the elements to
|
|
|
|
* @type: the type of elements to change
|
|
|
|
*
|
|
|
|
* Sets the state of only those objects of the given type.
|
|
|
|
*
|
|
|
|
* Returns: indication if the state change was successfull
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
gboolean
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_set_state_type (GstBin * bin, GstElementState state, GType type)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstBinClass *oclass;
|
|
|
|
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (GST_CAT_STATES, "gst_bin_set_state_type(\"%s\",%d,%s)",
|
2002-02-20 21:31:16 +00:00
|
|
|
GST_ELEMENT_NAME (bin), state, G_OBJECT_TYPE_NAME (type));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
g_return_val_if_fail (bin != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS (bin));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
if (oclass->change_state_type)
|
2001-12-15 22:37:35 +00:00
|
|
|
(oclass->change_state_type) (bin, state, type);
|
2000-09-24 14:29:49 +00:00
|
|
|
return TRUE;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static void
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_dispose (GObject * object)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
|
|
|
GstBin *bin = GST_BIN (object);
|
2001-05-25 21:00:07 +00:00
|
|
|
GList *children, *orig;
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElement *child;
|
|
|
|
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-02-17 19:58:29 +00:00
|
|
|
if (gst_element_get_state (GST_ELEMENT (object)) == GST_STATE_PLAYING)
|
|
|
|
gst_element_set_state (GST_ELEMENT (object), GST_STATE_PAUSED);
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
if (bin->children) {
|
|
|
|
orig = children = g_list_copy (bin->children);
|
|
|
|
while (children) {
|
|
|
|
child = GST_ELEMENT (children->data);
|
|
|
|
gst_bin_remove (bin, child);
|
|
|
|
children = g_list_next (children);
|
|
|
|
}
|
|
|
|
g_list_free (bin->children);
|
2001-12-15 22:37:35 +00:00
|
|
|
g_list_free (orig);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
bin->children = NULL;
|
|
|
|
bin->numchildren = 0;
|
|
|
|
|
2001-09-28 19:16:02 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_get_by_name:
|
|
|
|
* @bin: #Gstbin to search
|
|
|
|
* @name: the element name to search for
|
|
|
|
*
|
2001-01-06 22:05:15 +00:00
|
|
|
* Get the element with the given name from this bin.
|
2000-03-27 19:53:43 +00:00
|
|
|
*
|
|
|
|
* Returns: the element with the given name
|
|
|
|
*/
|
2001-12-15 22:37:35 +00:00
|
|
|
GstElement *
|
|
|
|
gst_bin_get_by_name (GstBin * bin, const gchar * name)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *children;
|
|
|
|
GstElement *child;
|
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
g_return_val_if_fail (bin != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "looking up child element %s", name);
|
2000-12-30 02:41:15 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
children = bin->children;
|
|
|
|
while (children) {
|
2000-11-04 18:54:07 +00:00
|
|
|
child = GST_ELEMENT (children->data);
|
2001-12-15 22:37:35 +00:00
|
|
|
if (!strcmp (GST_OBJECT_NAME (child), name))
|
2000-01-30 09:03:00 +00:00
|
|
|
return child;
|
2000-11-04 18:54:07 +00:00
|
|
|
if (GST_IS_BIN (child)) {
|
|
|
|
GstElement *res = gst_bin_get_by_name (GST_BIN (child), name);
|
2001-12-15 22:37:35 +00:00
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
if (res)
|
2001-12-15 22:37:35 +00:00
|
|
|
return res;
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
2000-11-04 18:54:07 +00:00
|
|
|
children = g_list_next (children);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_get_by_name_recurse_up:
|
|
|
|
* @bin: #Gstbin to search
|
|
|
|
* @name: the element name to search for
|
|
|
|
*
|
|
|
|
* Get the element with the given name from this bin. If the
|
|
|
|
* element is not found, a recursion is performed on the parent bin.
|
|
|
|
*
|
|
|
|
* Returns: the element with the given name
|
|
|
|
*/
|
2001-12-15 22:37:35 +00:00
|
|
|
GstElement *
|
|
|
|
gst_bin_get_by_name_recurse_up (GstBin * bin, const gchar * name)
|
2001-01-29 00:06:02 +00:00
|
|
|
{
|
|
|
|
GstElement *result = NULL;
|
|
|
|
GstObject *parent;
|
|
|
|
|
|
|
|
g_return_val_if_fail (bin != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
result = gst_bin_get_by_name (bin, name);
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
if (!result) {
|
|
|
|
parent = gst_object_get_parent (GST_OBJECT (bin));
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
if (parent && GST_IS_BIN (parent)) {
|
|
|
|
result = gst_bin_get_by_name_recurse_up (GST_BIN (parent), name);
|
|
|
|
}
|
2001-01-29 00:06:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_get_list:
|
|
|
|
* @bin: #Gstbin to get the list from
|
|
|
|
*
|
2001-01-06 22:05:15 +00:00
|
|
|
* Get the list of elements in this bin.
|
2000-03-27 19:53:43 +00:00
|
|
|
*
|
|
|
|
* Returns: a GList of elements
|
|
|
|
*/
|
2002-04-19 19:49:41 +00:00
|
|
|
const GList *
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_get_list (GstBin * bin)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (bin != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return bin->children;
|
|
|
|
}
|
|
|
|
|
2001-06-25 06:45:56 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2001-01-20 03:10:44 +00:00
|
|
|
static xmlNodePtr
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_save_thyself (GstObject * object, xmlNodePtr parent)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
GstBin *bin = GST_BIN (object);
|
|
|
|
xmlNodePtr childlist, elementnode;
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *children;
|
|
|
|
GstElement *child;
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
if (GST_OBJECT_CLASS (parent_class)->save_thyself)
|
|
|
|
GST_OBJECT_CLASS (parent_class)->save_thyself (GST_OBJECT (bin), parent);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
childlist = xmlNewChild (parent, NULL, "children", NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_XML, bin, "saving %d children", bin->numchildren);
|
2000-12-30 02:41:15 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
children = bin->children;
|
|
|
|
while (children) {
|
2000-11-04 18:54:07 +00:00
|
|
|
child = GST_ELEMENT (children->data);
|
2001-01-29 00:06:02 +00:00
|
|
|
elementnode = xmlNewChild (childlist, NULL, "element", NULL);
|
|
|
|
gst_object_save_thyself (GST_OBJECT (child), elementnode);
|
2000-11-04 18:54:07 +00:00
|
|
|
children = g_list_next (children);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2000-09-27 19:33:10 +00:00
|
|
|
return childlist;
|
|
|
|
}
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static void
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_restore_thyself (GstObject * object, xmlNodePtr self)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
GstBin *bin = GST_BIN (object);
|
|
|
|
xmlNodePtr field = self->xmlChildrenNode;
|
2000-09-27 19:33:10 +00:00
|
|
|
xmlNodePtr childlist;
|
|
|
|
|
|
|
|
while (field) {
|
2000-11-04 18:54:07 +00:00
|
|
|
if (!strcmp (field->name, "children")) {
|
2001-01-29 00:06:02 +00:00
|
|
|
GST_INFO_ELEMENT (GST_CAT_XML, GST_ELEMENT (object), "loading children");
|
2001-01-18 11:16:53 +00:00
|
|
|
childlist = field->xmlChildrenNode;
|
2000-09-27 19:33:10 +00:00
|
|
|
while (childlist) {
|
2001-12-15 22:37:35 +00:00
|
|
|
if (!strcmp (childlist->name, "element")) {
|
2002-01-11 15:49:47 +00:00
|
|
|
GstElement *element = gst_xml_make_element (childlist, GST_OBJECT (bin));
|
|
|
|
|
|
|
|
/* it had to be parented to find the pads, now we ref and unparent so
|
|
|
|
* we can add it to the bin */
|
|
|
|
gst_object_ref (GST_OBJECT (element));
|
|
|
|
gst_object_unparent (GST_OBJECT (element));
|
|
|
|
|
2000-11-04 18:54:07 +00:00
|
|
|
gst_bin_add (bin, element);
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
2001-12-15 22:37:35 +00:00
|
|
|
childlist = childlist->next;
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
field = field->next;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-10-17 10:21:27 +00:00
|
|
|
#endif /* GST_DISABLE_LOADSAVE */
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static gboolean
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_iterate_func (GstBin * bin)
|
2001-12-04 22:12:50 +00:00
|
|
|
{
|
2001-12-14 22:59:21 +00:00
|
|
|
/* only iterate if this is the manager bin */
|
2002-01-18 22:44:19 +00:00
|
|
|
if (GST_ELEMENT_SCHED (bin) &&
|
|
|
|
GST_ELEMENT_SCHED (bin)->parent == GST_ELEMENT (bin)) {
|
2001-12-24 15:14:03 +00:00
|
|
|
GstSchedulerState state;
|
|
|
|
|
|
|
|
state = gst_scheduler_iterate (GST_ELEMENT_SCHED (bin));
|
|
|
|
|
|
|
|
if (state == GST_SCHEDULER_STATE_RUNNING) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (state == GST_SCHEDULER_STATE_ERROR) {
|
|
|
|
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
|
|
|
}
|
2001-12-15 22:37:35 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-01-19 06:29:40 +00:00
|
|
|
g_warning ("bin \"%s\" can't be iterated on!\n", GST_ELEMENT_NAME (bin));
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-08-14 10:55:35 +00:00
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_bin_iterate:
|
|
|
|
* @bin: #Gstbin to iterate
|
|
|
|
*
|
2001-01-06 22:05:15 +00:00
|
|
|
* Iterates over the elements in this bin.
|
2001-01-21 23:20:46 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the bin did something usefull. This value
|
|
|
|
* can be used to determine it the bin is in EOS.
|
2000-03-27 19:53:43 +00:00
|
|
|
*/
|
2001-01-20 17:59:25 +00:00
|
|
|
gboolean
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_bin_iterate (GstBin * bin)
|
2000-11-04 18:54:07 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstBinClass *oclass;
|
2001-11-14 21:06:15 +00:00
|
|
|
gboolean running = TRUE;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_DEBUG_ENTER ("(\"%s\")", GST_ELEMENT_NAME (bin));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-03-18 04:41:37 +00:00
|
|
|
g_return_val_if_fail (bin != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS (bin));
|
2001-01-20 03:10:44 +00:00
|
|
|
|
2002-06-10 16:48:47 +00:00
|
|
|
if (bin->pre_iterate_func)
|
|
|
|
(bin->pre_iterate_func) (bin, bin->pre_iterate_private);
|
2002-06-07 19:34:52 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
if (oclass->iterate)
|
2001-11-14 21:06:15 +00:00
|
|
|
running = (oclass->iterate) (bin);
|
Changed the way things are scheduled, especially sources. A Src used to have a push() function, and optionally a pus...
Original commit message from CVS:
Changed the way things are scheduled, especially sources. A Src used to
have a push() function, and optionally a pushregion() to deal with async
reads, etc. That whole thing has gone away, in favor of providing a
pull() function for the output (Src) pad instead, ala chain functions.
This makes constructing cothreaded schedules out of non-loop elements
somewhat easier. Basically there was always a question as to which pad
was being dealt with. In the pullregion case, cothread-specific data was
used to try to pass the region struct to the right place, which is a slow
hack. And in general, the push function severely limited the kind of
tricks that could be played when there's more than one output pad, such as
a multi-out file reader with async capabilities on each pad independently.
This changes the way cothread scheduling occurs. Instead of the hack to
deal with Src's by calling their push() function (or optionally the
pushregion(), in certain cases), we now are working towards a general
mechanism where pads are the only thing that are dealt with directly.
An optimization was made in the process of doing this: the loopfunction
actually run as the outer [stack] frame of the cothread is now set more
intelligently in create_plan() based on what kind of element it is. We
now have:
loopfunc_wrapper: used for loop-based elements, it simply calls the
loopfunc in a loop, paying attention to COTHREAD_STOPPING (see
below). It currently does other, soon to be depracated, stuff.
pullsrc_wrapper: wraps a Src that's not loop-based (since your options
are now loop- or pull-based)
There will be a couple more to deal with other cases, such as Connections
and chain-based elements. The general idea is that it's a lot more
efficient to make the decisions once in create_plan than to keep doing
this huge if/else chain in the wrapper. Just choose the right wrapper up
front. It'll be most apparent performance-wise in the case of whichever
element context is switched to first for each iteration, since the whole
wrapper setup is done for every iteration.
The tricky part is that there is now a bit of overloading of the function
pointers in a pad. The current meanings (possibly to change a bit more
soon) are:
chainfunc: as always, chainfunc pointer is mirrored between peer pads
(this may change, and the chain func may end up in pushfunc)
pushfunc: SrcPad: gst_pad_pushfunc_proxy, cothread_switch to peer
SinkPad: none (may take over chainfunc, see below) pullfunc:
SrcPad: Src or Connection's function to construct buffers
SinkPad: gst_pad_pullfunc_proxy, cothread_switch to peer
There are a number of issues remaining with the scheduling, not the least
of which is the fact that Connections are still dealt with the old way,
with _push() functions and such. I'm trying to figure out a way to unify
the system so it makes sense. Following the scheduling system is hard
enough, trying to change it is murder.
Another useful scheduling addition, mentioned above, is COTHREAD_STOPPING.
It's an element flag that's used to signal whatever code is running in
cothread context that it should be finishing up and exiting soon. An
example of this is in plugins/cobin/spindentity.c. All the loops should
now be composed of do/while loops, rather than while(1) loops:
do {
buf = gst_pad_pull(spindentity->sinkpad);
gst_pad_push(spindentity->srcpad,buf);
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
The reason for this is that COTHREAD_STOPPING may be set before the above
loop ever gets started. It wouldn't do for the body of the loop to never
once get called, that would simply stall the pipeline. Note that only the
core library code is ever responsible for setting and unsetting this flag.
All elements have to do is respond to it by cleanly exiting the loop and
the function holding it.
This is needed primarily to allow iterations to occur properly.
Basically, there's a single entry point in the cothread scheduling loop,
gst_bin_iterate_func() simply switches to this cothread. If the element
in this context is allowed to loop infinitely, nothing would even switch
back to the context from which the iterate() was originally called. This
is a bit of a problem. The solution is for there to be an implicit switch
back to the originating context. Now, even I'm not sure exactly how this
works, but if the cothread that's switched to actually returns, execution
returns back to the calling context, i.e. iterate_func().
COTHREAD_STOPPING is therefore set just before switching into this
(currently randomly chosen) context, on the assumption that it will return
promptly after finishing its duties. The burden of clearing the flag
falls to the various wrapper functions provided by the Bin code, thus
element writers don't have to worry about doing that at all (and simply
shouldn't).
Related changes:
All the sources in elements/ have been changed to reflect the new system.
FIXMEs:
1) gstpipeline.c calls gst_src_push at some point, dunno why, it's
commented out now.
2) any other sources, including vcdsrc, dvdsrc, and v4lsrc will break
badly and need to be modified to work as pull-based sources.
2000-12-04 10:52:30 +00:00
|
|
|
|
2002-06-10 16:48:47 +00:00
|
|
|
if (bin->post_iterate_func)
|
|
|
|
(bin->post_iterate_func) (bin, bin->post_iterate_private);
|
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_DEBUG_LEAVE ("(\"%s\") %d", GST_ELEMENT_NAME (bin), running);
|
2001-01-20 17:59:25 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!running) {
|
|
|
|
if (GST_STATE (bin) == GST_STATE_PLAYING && GST_STATE_PENDING (bin) == GST_STATE_VOID_PENDING) {
|
2001-12-15 22:37:35 +00:00
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, bin,
|
2002-06-03 19:50:41 +00:00
|
|
|
"polling for child shutdown after useless iteration");
|
|
|
|
usleep (1);
|
|
|
|
//gst_element_wait_state_change (GST_ELEMENT (bin));
|
|
|
|
running = TRUE;
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-14 21:06:15 +00:00
|
|
|
|
|
|
|
return running;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2002-06-10 16:48:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bin_set_pre_iterate_function:
|
|
|
|
* @bin: #Gstbin to attach to
|
|
|
|
* @func: callback function to call
|
|
|
|
* @func_data: private data to put in the function call
|
|
|
|
*
|
|
|
|
* Attaches a callback which will be run before every iteration of the bin
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_bin_set_pre_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
bin->pre_iterate_func = func;
|
|
|
|
bin->pre_iterate_private = func_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_bin_set_post_iterate_function:
|
|
|
|
* @bin: #Gstbin to attach to
|
|
|
|
* @func: callback function to call
|
|
|
|
* @func_data: private data to put in the function call
|
|
|
|
*
|
|
|
|
* Attaches a callback which will be run after every iteration of the bin
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_bin_set_post_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
bin->post_iterate_func = func;
|
|
|
|
bin->post_iterate_private = func_data;
|
|
|
|
}
|
|
|
|
|