2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstpipeline.c: Overall pipeline management element
|
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.
|
|
|
|
*/
|
|
|
|
|
2000-12-29 19:45:45 +00:00
|
|
|
//#define GST_DEBUG_ENABLED
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
2000-12-28 00:18:26 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstpipeline.h"
|
|
|
|
#include "gstthread.h"
|
|
|
|
#include "gstutils.h"
|
|
|
|
#include "gsttype.h"
|
2000-12-19 13:41:55 +00:00
|
|
|
#include "gstautoplug.h"
|
2000-08-18 20:35:48 +00:00
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElementDetails gst_pipeline_details = {
|
|
|
|
"Pipeline object",
|
|
|
|
"Bin",
|
|
|
|
"Complete pipeline object",
|
|
|
|
VERSION,
|
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>",
|
|
|
|
"(C) 1999",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Pipeline signals and args */
|
|
|
|
enum {
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static void gst_pipeline_class_init (GstPipelineClass *klass);
|
|
|
|
static void gst_pipeline_init (GstPipeline *pipeline);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static GstElementStateReturn gst_pipeline_change_state (GstElement *element);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static void gst_pipeline_prepare (GstPipeline *pipeline);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-29 02:28:04 +00:00
|
|
|
static void gst_pipeline_have_type (GstElement *sink, GstElement *sink2, gpointer data);
|
2000-11-25 14:18:47 +00:00
|
|
|
static void gst_pipeline_pads_autoplug (GstElement *src, GstElement *sink);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
WARNING: Don't grab this updated unless you're really, REALLY sure.
Original commit message from CVS:
WARNING: Don't grab this updated unless you're really, REALLY sure.
WARNING: Wait for the next one.
Whole lotta changes here, including a few random bits:
examples/*/Makefile: updated to use `libtool gcc`, not just `gcc`
gst/
gstbuffer.h: updated to new flag style
gst.c, gstdebug.h: added new debugging for function ptrs
gstpipeline.c: set type of parent_class to the class, not the object
gstthread.c: ditto
plugins/
cdparanoia/cdparanoia.c: added an argument type, updated some defaults
cobin/spindentity.c: updated to new do/while loopfunction style
mp3encode/lame/gstlame.c: argument types, whole lotta lame options
tests/: various changes
Now, for the big changes: Once again, the scheduling system has changed.
And once again, it broke a whole bunch of things. The gist of the change
is that there is now a function pointer for gst_pad_push and gst_pad_pull,
instead of a hard-wired function. Well, currently they are functions, but
that's for debugging purposes only, they just call the function pointer
after spewing lots of DEBUG().
This changed the GstPad structure a bit, and the GstPad API as well.
Where elements used to provide chain() and pull() functions, they provide
chain() and get() functions. gst_pad_set_pull[region]_function has been
changed to get_pad_set_get[region]_function. This means all the elements
out there that used to have pull functions need to be updated. The calls
to that function have been changed in the normal elements, but the names
of the functions passed is still _pull[region](), which is an aesthetic
issue more than anything.
As for what doesn't work yet, just about anything dealing with Connections
is hosed, meaning threaded stuff won't work. This will be fixed about 12
hours from now, after I've slept, etc. The simplefake.c test works in
both cothreaded and chained cases, but not much else will work due to the
Connection problem. Needless to say, don't grab this unless you *need*
these features *now*, else wait to update this stuff until tomorrow.
I'm going to sleep now.
2000-12-16 10:18:09 +00:00
|
|
|
static GstBinClass *parent_class = NULL;
|
2000-02-27 23:18:38 +00:00
|
|
|
//static guint gst_pipeline_signals[LAST_SIGNAL] = { 0 };
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
GtkType
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_pipeline_get_type (void) {
|
2000-01-30 09:03:00 +00:00
|
|
|
static GtkType pipeline_type = 0;
|
|
|
|
|
|
|
|
if (!pipeline_type) {
|
|
|
|
static const GtkTypeInfo pipeline_info = {
|
|
|
|
"GstPipeline",
|
|
|
|
sizeof(GstPipeline),
|
|
|
|
sizeof(GstPipelineClass),
|
|
|
|
(GtkClassInitFunc)gst_pipeline_class_init,
|
|
|
|
(GtkObjectInitFunc)gst_pipeline_init,
|
|
|
|
(GtkArgSetFunc)NULL,
|
|
|
|
(GtkArgGetFunc)NULL,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
2000-11-25 14:18:47 +00:00
|
|
|
pipeline_type = gtk_type_unique (gst_bin_get_type (), &pipeline_info);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
return pipeline_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_pipeline_class_init (GstPipelineClass *klass)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
|
|
gstelement_class = (GstElementClass*)klass;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class(gst_bin_get_type());
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_pipeline_change_state;
|
|
|
|
}
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static void
|
|
|
|
gst_pipeline_init (GstPipeline *pipeline)
|
|
|
|
{
|
2000-12-20 09:39:43 +00:00
|
|
|
// we're a manager by default
|
|
|
|
GST_FLAG_SET (pipeline, GST_BIN_FLAG_MANAGER);
|
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
pipeline->src = NULL;
|
|
|
|
pipeline->sinks = NULL;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 06:26:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_pipeline_new:
|
|
|
|
* @name: name of new pipeline
|
|
|
|
*
|
|
|
|
* Create a new pipeline with the given name.
|
|
|
|
*
|
|
|
|
* Returns: newly created GstPipeline
|
|
|
|
*/
|
2000-11-25 14:18:47 +00:00
|
|
|
GstElement*
|
|
|
|
gst_pipeline_new (guchar *name)
|
|
|
|
{
|
2000-12-27 03:13:20 +00:00
|
|
|
return gst_elementfactory_make ("pipeline", name);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static void
|
|
|
|
gst_pipeline_prepare (GstPipeline *pipeline)
|
|
|
|
{
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: preparing pipeline \"%s\" for playing\n",
|
2000-09-17 22:08:09 +00:00
|
|
|
gst_element_get_name(GST_ELEMENT(pipeline)));
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static void
|
2000-12-29 02:28:04 +00:00
|
|
|
gst_pipeline_have_type (GstElement *sink, GstElement *sink2, gpointer data)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: pipeline have type %p\n", (gboolean *)data);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
|
|
|
*(gboolean *)data = TRUE;
|
|
|
|
}
|
|
|
|
|
2000-12-19 13:41:55 +00:00
|
|
|
static GstCaps*
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
|
|
|
|
{
|
2000-08-21 21:20:38 +00:00
|
|
|
gboolean found = FALSE;
|
|
|
|
GstElement *typefind;
|
2000-12-17 16:24:14 +00:00
|
|
|
GstCaps *caps = NULL;
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: typefind for element \"%s\" %p\n",
|
2000-09-17 22:08:09 +00:00
|
|
|
gst_element_get_name(element), &found);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
typefind = gst_elementfactory_make ("typefind", "typefind");
|
|
|
|
g_return_val_if_fail (typefind != NULL, FALSE);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
gtk_signal_connect (GTK_OBJECT (typefind), "have_type",
|
|
|
|
GTK_SIGNAL_FUNC (gst_pipeline_have_type), &found);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_pad_connect (gst_element_get_pad (element, "src"),
|
|
|
|
gst_element_get_pad (typefind, "sink"));
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), typefind);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-12-22 16:14:33 +00:00
|
|
|
//gst_bin_create_plan (GST_BIN (pipeline));
|
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
|
2000-12-05 18:08:59 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
// keep pushing buffers... the have_type signal handler will set the found flag
|
2000-12-05 18:08:59 +00:00
|
|
|
while (!found) {
|
|
|
|
gst_bin_iterate (GST_BIN (pipeline));
|
|
|
|
}
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-12-05 18:08:59 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
|
|
|
if (found) {
|
2000-12-17 16:24:14 +00:00
|
|
|
caps = gst_util_get_pointer_arg (GTK_OBJECT (typefind), "caps");
|
2000-12-15 16:43:26 +00:00
|
|
|
|
2000-12-31 16:12:48 +00:00
|
|
|
gst_pad_set_caps_list (gst_element_get_pad (element, "src"), g_list_prepend (NULL, caps));
|
2000-08-21 21:20:38 +00:00
|
|
|
}
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_pad_disconnect (gst_element_get_pad (element, "src"),
|
|
|
|
gst_element_get_pad (typefind, "sink"));
|
|
|
|
gst_bin_remove (GST_BIN (pipeline), typefind);
|
|
|
|
gst_object_unref (GST_OBJECT (typefind));
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-12-19 13:41:55 +00:00
|
|
|
return caps;
|
2000-08-21 21:20:38 +00:00
|
|
|
}
|
|
|
|
|
2000-12-11 00:04:25 +00:00
|
|
|
static gboolean
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_pipeline_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
|
|
|
|
{
|
2000-08-22 21:18:18 +00:00
|
|
|
GList *sinkpads;
|
2000-09-17 22:08:09 +00:00
|
|
|
gboolean connected = FALSE;
|
2000-12-03 17:51:29 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"gstpipeline: autoplug pad connect function for \"%s\" to \"%s\"\n",
|
2000-10-08 22:17:11 +00:00
|
|
|
gst_element_get_name(src), gst_element_get_name(sink));
|
2000-08-22 21:18:18 +00:00
|
|
|
|
|
|
|
sinkpads = gst_element_get_pad_list(sink);
|
|
|
|
while (sinkpads) {
|
2000-12-03 17:51:29 +00:00
|
|
|
GstPad *sinkpad = (GstPad *)sinkpads->data;
|
2000-08-22 21:18:18 +00:00
|
|
|
|
|
|
|
// if we have a match, connect the pads
|
2000-12-11 00:04:25 +00:00
|
|
|
if (sinkpad->direction == GST_PAD_SINK &&
|
2000-12-17 16:24:14 +00:00
|
|
|
!GST_PAD_CONNECTED(sinkpad))
|
2000-09-17 22:08:09 +00:00
|
|
|
{
|
2000-12-31 16:12:48 +00:00
|
|
|
if (gst_caps_list_check_compatibility (pad->caps, sinkpad->caps)) {
|
2000-12-17 16:24:14 +00:00
|
|
|
gst_pad_connect(pad, sinkpad);
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name,
|
2000-12-11 00:04:25 +00:00
|
|
|
gst_element_get_name(src));
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"pad \"%s\" in element %s\n", sinkpad->name,
|
2000-09-17 22:08:09 +00:00
|
|
|
gst_element_get_name(sink));
|
2000-12-17 16:24:14 +00:00
|
|
|
connected = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2001-01-01 05:26:34 +00:00
|
|
|
else {
|
|
|
|
GST_DEBUG (0,"pads incompatible %s, %s\n", gst_pad_get_name (pad), gst_pad_get_name (sinkpad));
|
|
|
|
}
|
2000-08-22 21:18:18 +00:00
|
|
|
}
|
|
|
|
sinkpads = g_list_next(sinkpads);
|
|
|
|
}
|
2000-09-17 22:08:09 +00:00
|
|
|
|
|
|
|
if (!connected) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"gstpipeline: no path to sinks for type\n");
|
2000-09-17 22:08:09 +00:00
|
|
|
}
|
2000-12-11 00:04:25 +00:00
|
|
|
return connected;
|
2000-08-22 21:18:18 +00:00
|
|
|
}
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static void
|
|
|
|
gst_pipeline_pads_autoplug (GstElement *src, GstElement *sink)
|
|
|
|
{
|
2000-12-11 00:04:25 +00:00
|
|
|
GList *srcpads;
|
2000-08-22 21:18:18 +00:00
|
|
|
gboolean connected = FALSE;
|
|
|
|
|
|
|
|
srcpads = gst_element_get_pad_list(src);
|
|
|
|
|
2000-12-11 00:04:25 +00:00
|
|
|
while (srcpads && !connected) {
|
2000-08-22 21:18:18 +00:00
|
|
|
GstPad *srcpad = (GstPad *)srcpads->data;
|
2000-12-11 00:04:25 +00:00
|
|
|
|
2000-12-15 16:43:26 +00:00
|
|
|
if (srcpad->direction == GST_PAD_SRC)
|
|
|
|
connected = gst_pipeline_pads_autoplug_func (src, srcpad, sink);
|
2000-12-11 00:04:25 +00:00
|
|
|
|
2000-08-22 21:18:18 +00:00
|
|
|
srcpads = g_list_next(srcpads);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!connected) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"gstpipeline: delaying pad connections for \"%s\" to \"%s\"\n",
|
2000-10-09 20:01:17 +00:00
|
|
|
gst_element_get_name(src), gst_element_get_name(sink));
|
2000-08-22 21:18:18 +00:00
|
|
|
gtk_signal_connect(GTK_OBJECT(src),"new_pad",
|
|
|
|
GTK_SIGNAL_FUNC(gst_pipeline_pads_autoplug_func), sink);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
/**
|
|
|
|
* gst_pipeline_add_src:
|
|
|
|
* @pipeline: the pipeline to add the src to
|
|
|
|
* @src: the src to add to the pipeline
|
|
|
|
*
|
|
|
|
* Adds a src element to the pipeline. This element
|
|
|
|
* will be used as a src for autoplugging. If you add more
|
|
|
|
* than one src element, the previously added element will
|
|
|
|
* be removed.
|
|
|
|
*/
|
2000-11-25 14:18:47 +00:00
|
|
|
void
|
|
|
|
gst_pipeline_add_src (GstPipeline *pipeline, GstElement *src)
|
2000-09-17 22:08:09 +00:00
|
|
|
{
|
2000-11-25 14:18:47 +00:00
|
|
|
g_return_if_fail (pipeline != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PIPELINE (pipeline));
|
|
|
|
g_return_if_fail (src != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (src));
|
2000-09-17 22:08:09 +00:00
|
|
|
|
|
|
|
if (pipeline->src) {
|
|
|
|
printf("gstpipeline: *WARNING* removing previously added element \"%s\"\n",
|
|
|
|
gst_element_get_name(pipeline->src));
|
|
|
|
gst_bin_remove(GST_BIN(pipeline), pipeline->src);
|
|
|
|
}
|
|
|
|
pipeline->src = src;
|
|
|
|
gst_bin_add(GST_BIN(pipeline), src);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_pipeline_add_sink:
|
|
|
|
* @pipeline: the pipeline to add the sink to
|
|
|
|
* @sink: the sink to add to the pipeline
|
|
|
|
*
|
|
|
|
* Adds a sink element to the pipeline. This element
|
2001-01-06 22:05:15 +00:00
|
|
|
* will be used as a sink for autoplugging.
|
2000-09-17 22:08:09 +00:00
|
|
|
*/
|
2000-11-25 14:18:47 +00:00
|
|
|
void
|
|
|
|
gst_pipeline_add_sink (GstPipeline *pipeline, GstElement *sink)
|
2000-09-17 22:08:09 +00:00
|
|
|
{
|
2000-11-25 14:18:47 +00:00
|
|
|
g_return_if_fail (pipeline != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PIPELINE (pipeline));
|
|
|
|
g_return_if_fail (sink != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (sink));
|
2000-09-17 22:08:09 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
pipeline->sinks = g_list_prepend (pipeline->sinks, sink);
|
2000-10-08 22:17:11 +00:00
|
|
|
//gst_bin_add(GST_BIN(pipeline), sink);
|
2000-09-17 22:08:09 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
|
|
|
* gst_pipeline_autoplug:
|
|
|
|
* @pipeline: the pipeline to autoplug
|
|
|
|
*
|
|
|
|
* Constructs a complete pipeline by automatically
|
|
|
|
* detecting the plugins needed.
|
|
|
|
*
|
|
|
|
* Returns: a gboolean indicating success or failure.
|
|
|
|
*/
|
2000-11-25 14:18:47 +00:00
|
|
|
gboolean
|
|
|
|
gst_pipeline_autoplug (GstPipeline *pipeline)
|
|
|
|
{
|
2000-08-21 21:20:38 +00:00
|
|
|
GList *elements;
|
2000-09-09 16:36:10 +00:00
|
|
|
GstElement *element, *srcelement = NULL, *sinkelement= NULL;
|
2000-10-08 22:17:11 +00:00
|
|
|
GList **factories;
|
2000-10-21 12:04:40 +00:00
|
|
|
GList **base_factories;
|
2000-08-21 21:20:38 +00:00
|
|
|
GstElementFactory *factory;
|
2000-12-19 13:41:55 +00:00
|
|
|
GstCaps *src_caps = 0;
|
2000-10-08 22:17:11 +00:00
|
|
|
guint i, numsinks;
|
2000-10-09 20:01:17 +00:00
|
|
|
gboolean use_thread = FALSE, have_common = FALSE;
|
2001-01-01 05:26:34 +00:00
|
|
|
GList *sinkstart;
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
g_return_val_if_fail(pipeline != NULL, FALSE);
|
2000-08-21 21:20:38 +00:00
|
|
|
g_return_val_if_fail(GST_IS_PIPELINE(pipeline), FALSE);
|
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: autopluging pipeline \"%s\"\n",
|
2000-09-17 22:08:09 +00:00
|
|
|
gst_element_get_name(GST_ELEMENT(pipeline)));
|
|
|
|
|
|
|
|
|
|
|
|
// fase 1, run typedetect on the source if needed...
|
|
|
|
if (!pipeline->src) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: no source detected, can't autoplug pipeline \"%s\"\n",
|
2000-09-17 22:08:09 +00:00
|
|
|
gst_element_get_name(GST_ELEMENT(pipeline)));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: source \"%s\" has no MIME type, running typefind...\n",
|
2000-12-19 13:41:55 +00:00
|
|
|
gst_element_get_name(pipeline->src));
|
2000-09-17 22:08:09 +00:00
|
|
|
|
2000-12-19 13:41:55 +00:00
|
|
|
src_caps = gst_pipeline_typefind(pipeline, pipeline->src);
|
2000-09-17 22:08:09 +00:00
|
|
|
|
2000-12-19 13:41:55 +00:00
|
|
|
if (src_caps) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: source \"%s\" type found %d\n", gst_element_get_name(pipeline->src),
|
2000-12-19 13:41:55 +00:00
|
|
|
src_caps->id);
|
2000-09-17 22:08:09 +00:00
|
|
|
}
|
|
|
|
else {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: source \"%s\" has no type\n", gst_element_get_name(pipeline->src));
|
2000-12-19 13:41:55 +00:00
|
|
|
return FALSE;
|
2000-09-17 22:08:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
srcelement = pipeline->src;
|
|
|
|
|
|
|
|
elements = pipeline->sinks;
|
|
|
|
|
2001-01-01 05:26:34 +00:00
|
|
|
sinkstart = g_list_copy (elements);
|
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
numsinks = g_list_length(elements);
|
|
|
|
factories = g_new0(GList *, numsinks);
|
2000-10-21 12:04:40 +00:00
|
|
|
base_factories = g_new0(GList *, numsinks);
|
2000-10-08 22:17:11 +00:00
|
|
|
|
|
|
|
i = 0;
|
2000-12-20 09:39:43 +00:00
|
|
|
// fase 2, loop over all the sinks..
|
2000-08-21 21:20:38 +00:00
|
|
|
while (elements) {
|
2000-09-22 23:35:14 +00:00
|
|
|
GstPad *pad;
|
|
|
|
|
2000-08-21 21:20:38 +00:00
|
|
|
element = GST_ELEMENT(elements->data);
|
|
|
|
|
2000-12-19 13:41:55 +00:00
|
|
|
pad = (GstPad *)gst_element_get_pad_list (element)->data;
|
2000-10-08 22:17:11 +00:00
|
|
|
|
2000-12-31 16:12:48 +00:00
|
|
|
base_factories[i] = factories[i] = gst_autoplug_caps_list (g_list_append(NULL,src_caps), pad->caps);
|
2000-12-29 18:23:41 +00:00
|
|
|
// if we have a succesfull connection, proceed
|
2001-01-01 05:26:34 +00:00
|
|
|
if (factories[i] != NULL) {
|
2000-12-29 18:23:41 +00:00
|
|
|
i++;
|
2001-01-01 05:26:34 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
sinkstart = g_list_remove (sinkstart, element);
|
|
|
|
}
|
2000-10-08 22:17:11 +00:00
|
|
|
|
2000-08-21 21:20:38 +00:00
|
|
|
elements = g_list_next(elements);
|
|
|
|
}
|
2000-12-05 18:08:59 +00:00
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
while (factories[0]) {
|
|
|
|
// fase 3: add common elements
|
|
|
|
factory = (GstElementFactory *)(factories[0]->data);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
// check to other paths for mathing elements (factories)
|
|
|
|
for (i=1; i<numsinks; i++) {
|
2000-12-28 02:51:07 +00:00
|
|
|
if (!factories[i] || (factory != (GstElementFactory *)(factories[i]->data))) {
|
2000-10-08 22:17:11 +00:00
|
|
|
goto differ;
|
2000-10-09 20:01:17 +00:00
|
|
|
}
|
2000-10-08 22:17:11 +00:00
|
|
|
factories[i] = g_list_next(factories[i]);
|
|
|
|
}
|
|
|
|
factory = (GstElementFactory *)(factories[0]->data);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"common factory \"%s\"\n", factory->name);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
|
|
|
element = gst_elementfactory_create(factory, factory->name);
|
|
|
|
gst_bin_add(GST_BIN(pipeline), element);
|
|
|
|
|
2000-08-22 21:18:18 +00:00
|
|
|
gst_pipeline_pads_autoplug(srcelement, element);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
|
|
|
srcelement = element;
|
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
factories[0] = g_list_next(factories[0]);
|
2000-10-09 20:01:17 +00:00
|
|
|
|
|
|
|
have_common = TRUE;
|
2000-08-21 21:20:38 +00:00
|
|
|
}
|
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
differ:
|
|
|
|
// loop over all the sink elements
|
2001-01-01 05:26:34 +00:00
|
|
|
elements = sinkstart;
|
2000-10-08 22:17:11 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (elements) {
|
|
|
|
GstElement *thesrcelement = srcelement;
|
|
|
|
GstElement *thebin = GST_ELEMENT(pipeline);
|
|
|
|
|
2000-10-21 12:04:40 +00:00
|
|
|
if (g_list_length(base_factories[i]) == 0) goto next;
|
2000-10-12 19:41:30 +00:00
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
sinkelement = (GstElement *)elements->data;
|
|
|
|
|
2000-10-09 20:01:17 +00:00
|
|
|
use_thread = have_common;
|
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
while (factories[i] || sinkelement) {
|
|
|
|
// fase 4: add other elements...
|
|
|
|
|
|
|
|
if (factories[i]) {
|
|
|
|
factory = (GstElementFactory *)(factories[i]->data);
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"factory \"%s\"\n", factory->name);
|
2000-10-08 22:17:11 +00:00
|
|
|
element = gst_elementfactory_create(factory, factory->name);
|
|
|
|
factories[i] = g_list_next(factories[i]);
|
|
|
|
}
|
|
|
|
// we have arived to the final sink element
|
|
|
|
else {
|
|
|
|
element = sinkelement;
|
|
|
|
sinkelement = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this element suggests the use of a thread, so we set one up...
|
2000-10-09 20:01:17 +00:00
|
|
|
if (GST_ELEMENT_IS_THREAD_SUGGESTED(element) || use_thread) {
|
2000-10-08 22:17:11 +00:00
|
|
|
GstElement *queue;
|
|
|
|
GList *sinkpads;
|
|
|
|
GstPad *srcpad, *sinkpad;
|
2000-10-09 20:01:17 +00:00
|
|
|
|
|
|
|
use_thread = FALSE;
|
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"sugest new thread for \"%s\" %08x\n", element->name, GST_FLAGS(element));
|
2000-10-08 22:17:11 +00:00
|
|
|
|
|
|
|
// create a new queue and add to the previous bin
|
|
|
|
queue = gst_elementfactory_make("queue", g_strconcat("queue_", gst_element_get_name(element), NULL));
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"adding element \"%s\"\n", element->name);
|
2000-10-09 20:01:17 +00:00
|
|
|
gst_bin_add(GST_BIN(thebin), queue);
|
2000-10-08 22:17:11 +00:00
|
|
|
|
|
|
|
// this will be the new bin for all following elements
|
2000-10-09 20:01:17 +00:00
|
|
|
thebin = gst_elementfactory_make("thread", g_strconcat("thread_", gst_element_get_name(element), NULL));
|
2000-10-08 22:17:11 +00:00
|
|
|
|
|
|
|
srcpad = gst_element_get_pad(queue, "src");
|
2000-10-09 20:01:17 +00:00
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
sinkpads = gst_element_get_pad_list(element);
|
|
|
|
while (sinkpads) {
|
|
|
|
sinkpad = (GstPad *)sinkpads->data;
|
|
|
|
|
|
|
|
// FIXME connect matching pads, not just the first one...
|
|
|
|
if (sinkpad->direction == GST_PAD_SINK &&
|
|
|
|
!GST_PAD_CONNECTED(sinkpad)) {
|
2000-12-31 16:12:48 +00:00
|
|
|
GList *caps = gst_pad_get_caps_list (sinkpad);
|
2000-12-15 16:43:26 +00:00
|
|
|
|
2000-12-03 17:51:29 +00:00
|
|
|
// the queue has the type of the elements it connects
|
2000-12-31 16:12:48 +00:00
|
|
|
gst_pad_set_caps_list (srcpad, caps);
|
|
|
|
gst_pad_set_caps_list (gst_element_get_pad(queue, "sink"), caps);
|
2000-10-08 22:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sinkpads = g_list_next(sinkpads);
|
|
|
|
}
|
2000-10-09 20:01:17 +00:00
|
|
|
gst_pipeline_pads_autoplug(thesrcelement, queue);
|
2000-10-08 22:17:11 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"adding element %s\n", gst_element_get_name (element));
|
2000-10-08 22:17:11 +00:00
|
|
|
gst_bin_add(GST_BIN(thebin), element);
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"adding element %s\n", gst_element_get_name (thebin));
|
2000-10-08 22:17:11 +00:00
|
|
|
gst_bin_add(GST_BIN(pipeline), thebin);
|
2000-10-09 20:01:17 +00:00
|
|
|
thesrcelement = queue;
|
2000-10-08 22:17:11 +00:00
|
|
|
}
|
|
|
|
// no thread needed, easy case
|
|
|
|
else {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"adding element %s\n", gst_element_get_name (element));
|
2000-10-08 22:17:11 +00:00
|
|
|
gst_bin_add(GST_BIN(thebin), element);
|
|
|
|
}
|
|
|
|
gst_pipeline_pads_autoplug(thesrcelement, element);
|
|
|
|
|
|
|
|
// this element is now the new source element
|
|
|
|
thesrcelement = element;
|
|
|
|
}
|
2000-10-12 19:41:30 +00:00
|
|
|
next:
|
2000-10-08 22:17:11 +00:00
|
|
|
elements = g_list_next(elements);
|
|
|
|
i++;
|
2000-08-21 21:20:38 +00:00
|
|
|
}
|
2000-10-08 22:17:11 +00:00
|
|
|
return TRUE;
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: unable to autoplug pipeline \"%s\"\n",
|
2000-09-17 22:08:09 +00:00
|
|
|
gst_element_get_name(GST_ELEMENT(pipeline)));
|
2000-08-21 21:20:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
static GstElementStateReturn
|
|
|
|
gst_pipeline_change_state (GstElement *element)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstPipeline *pipeline;
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PIPELINE (element), FALSE);
|
|
|
|
|
|
|
|
pipeline = GST_PIPELINE (element);
|
2000-08-14 10:55:35 +00:00
|
|
|
|
2000-12-23 03:17:52 +00:00
|
|
|
switch (GST_STATE_TRANSITION (pipeline)) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
2000-07-17 17:14:15 +00:00
|
|
|
// we need to set up internal state
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_pipeline_prepare (pipeline);
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
2000-08-14 10:55:35 +00:00
|
|
|
return GST_STATE_SUCCESS;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-02 06:26:44 +00:00
|
|
|
/**
|
|
|
|
* gst_pipeline_iterate:
|
2001-01-06 22:05:15 +00:00
|
|
|
* @pipeline: #GstPipeline to iterate
|
2000-02-02 06:26:44 +00:00
|
|
|
*
|
|
|
|
* Cause the pipeline's contents to be run through one full 'iteration'.
|
|
|
|
*/
|
2000-11-25 14:18:47 +00:00
|
|
|
void
|
|
|
|
gst_pipeline_iterate (GstPipeline *pipeline)
|
|
|
|
{
|
|
|
|
g_return_if_fail (pipeline != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PIPELINE(pipeline));
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|