2000-01-30 09:03:00 +00:00
|
|
|
/* Gnome-Streamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gstpipeline.h>
|
2000-10-08 22:17:11 +00:00
|
|
|
#include <gst/gstthread.h>
|
2000-08-21 21:20:38 +00:00
|
|
|
#include <gst/gstsink.h>
|
|
|
|
#include <gst/gstutils.h>
|
|
|
|
#include <gst/gsttype.h>
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-08-18 20:35:48 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void gst_pipeline_class_init(GstPipelineClass *klass);
|
|
|
|
static void gst_pipeline_init(GstPipeline *pipeline);
|
|
|
|
|
2000-07-17 17:14:15 +00:00
|
|
|
static GstElementStateReturn gst_pipeline_change_state(GstElement *element);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
static void gst_pipeline_prepare(GstPipeline *pipeline);
|
|
|
|
|
2000-08-21 21:20:38 +00:00
|
|
|
static void gst_pipeline_have_type(GstSink *sink, GstSink *sink2, gpointer data);
|
2000-08-22 21:18:18 +00:00
|
|
|
static void gst_pipeline_pads_autoplug(GstElement *src, GstElement *sink);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
static GstBin *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
|
|
|
|
gst_pipeline_get_type(void) {
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
pipeline_type = gtk_type_unique(gst_bin_get_type(),&pipeline_info);
|
|
|
|
}
|
|
|
|
return pipeline_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_pipeline_class_init(GstPipelineClass *klass) {
|
|
|
|
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-09-24 22:45:48 +00:00
|
|
|
gstelement_class->elementfactory = gst_elementfactory_find("pipeline");
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gst_pipeline_init(GstPipeline *pipeline) {
|
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-09-09 16:36:10 +00:00
|
|
|
GstElement *gst_pipeline_new(guchar *name) {
|
2000-01-30 09:03:00 +00:00
|
|
|
GstPipeline *pipeline;
|
|
|
|
|
|
|
|
pipeline = gtk_type_new(gst_pipeline_get_type());
|
|
|
|
gst_element_set_name(GST_ELEMENT(pipeline),name);
|
2000-09-09 16:36:10 +00:00
|
|
|
return GST_ELEMENT(pipeline);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gst_pipeline_prepare(GstPipeline *pipeline) {
|
2000-09-17 22:08:09 +00:00
|
|
|
g_print("GstPipeline: preparing pipeline \"%s\" for playing\n",
|
|
|
|
gst_element_get_name(GST_ELEMENT(pipeline)));
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-08-21 21:20:38 +00:00
|
|
|
static void gst_pipeline_have_type(GstSink *sink, GstSink *sink2, gpointer data) {
|
|
|
|
g_print("GstPipeline: pipeline have type %p\n", (gboolean *)data);
|
|
|
|
|
|
|
|
*(gboolean *)data = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint16 gst_pipeline_typefind(GstPipeline *pipeline, GstElement *element) {
|
|
|
|
gboolean found = FALSE;
|
|
|
|
GstElement *typefind;
|
|
|
|
guint16 type_id = 0;
|
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
g_print("GstPipeline: typefind for element \"%s\" %p\n",
|
|
|
|
gst_element_get_name(element), &found);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
|
|
|
typefind = gst_elementfactory_make("typefind","typefind");
|
|
|
|
g_return_val_if_fail(typefind != NULL, FALSE);
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(typefind),"have_type",
|
|
|
|
GTK_SIGNAL_FUNC(gst_pipeline_have_type), &found);
|
|
|
|
|
|
|
|
gst_pad_connect(gst_element_get_pad(element,"src"),
|
|
|
|
gst_element_get_pad(typefind,"sink"));
|
|
|
|
|
|
|
|
gst_bin_add(GST_BIN(pipeline), typefind);
|
|
|
|
|
|
|
|
gst_bin_create_plan(GST_BIN(pipeline));
|
|
|
|
gst_element_set_state(GST_ELEMENT(element),GST_STATE_READY);
|
|
|
|
gst_element_set_state(GST_ELEMENT(element),GST_STATE_PLAYING);
|
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
// keep pushing buffers... the have_type signal handler will set the found flag
|
2000-08-21 21:20:38 +00:00
|
|
|
while (!found) {
|
|
|
|
gst_src_push(GST_SRC(element));
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state(GST_ELEMENT(element),GST_STATE_NULL);
|
|
|
|
|
|
|
|
if (found) {
|
|
|
|
type_id = gst_util_get_int_arg(GTK_OBJECT(typefind),"type");
|
2000-09-17 22:08:09 +00:00
|
|
|
gst_pad_set_type_id(gst_element_get_pad(element, "src"), type_id);
|
2000-08-21 21:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_pad_disconnect(gst_element_get_pad(element,"src"),
|
|
|
|
gst_element_get_pad(typefind,"sink"));
|
|
|
|
gst_bin_remove(GST_BIN(pipeline), typefind);
|
2000-09-09 16:36:10 +00:00
|
|
|
gst_object_unref(GST_OBJECT(typefind));
|
2000-08-21 21:20:38 +00:00
|
|
|
|
|
|
|
return type_id;
|
|
|
|
}
|
|
|
|
|
2000-08-22 21:18:18 +00:00
|
|
|
static void gst_pipeline_pads_autoplug_func(GstElement *src, GstPad *pad, GstElement *sink) {
|
|
|
|
GList *sinkpads;
|
|
|
|
GstPad *sinkpad;
|
2000-09-17 22:08:09 +00:00
|
|
|
gboolean connected = FALSE;
|
2000-08-22 21:18:18 +00:00
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
g_print("gstpipeline: autoplug pad connect function type %d for \"%s\" to \"%s\"\n", pad->type,
|
|
|
|
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) {
|
|
|
|
sinkpad = (GstPad *)sinkpads->data;
|
|
|
|
|
|
|
|
// if we have a match, connect the pads
|
2000-09-17 22:08:09 +00:00
|
|
|
if (sinkpad->type == pad->type &&
|
|
|
|
sinkpad->direction == GST_PAD_SINK &&
|
|
|
|
!GST_PAD_CONNECTED(sinkpad))
|
|
|
|
{
|
2000-08-22 21:18:18 +00:00
|
|
|
gst_pad_connect(pad, sinkpad);
|
2000-09-17 22:08:09 +00:00
|
|
|
g_print("gstpipeline: autoconnect pad \"%s\" (%d) in element %s <-> ", pad->name,
|
|
|
|
pad->type, gst_element_get_name(src));
|
|
|
|
g_print("pad \"%s\" (%d) in element %s\n", sinkpad->name, sinkpad->type,
|
|
|
|
gst_element_get_name(sink));
|
|
|
|
connected = TRUE;
|
2000-08-22 21:18:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sinkpads = g_list_next(sinkpads);
|
|
|
|
}
|
2000-09-17 22:08:09 +00:00
|
|
|
|
|
|
|
if (!connected) {
|
|
|
|
g_print("gstpipeline: no path to sinks for type %d\n", pad->type);
|
|
|
|
}
|
2000-08-22 21:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gst_pipeline_pads_autoplug(GstElement *src, GstElement *sink) {
|
|
|
|
GList *srcpads, *sinkpads;
|
|
|
|
gboolean connected = FALSE;
|
|
|
|
|
|
|
|
srcpads = gst_element_get_pad_list(src);
|
|
|
|
|
|
|
|
while (srcpads) {
|
|
|
|
GstPad *srcpad = (GstPad *)srcpads->data;
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
if (srcpad->direction == GST_PAD_SRC && !GST_PAD_CONNECTED(srcpad)) {
|
|
|
|
|
|
|
|
sinkpads = gst_element_get_pad_list(sink);
|
|
|
|
// FIXME could O(n) if the types were sorted...
|
|
|
|
while (sinkpads) {
|
|
|
|
sinkpad = (GstPad *)sinkpads->data;
|
|
|
|
|
|
|
|
// if we have a match, connect the pads
|
2000-09-17 22:08:09 +00:00
|
|
|
if (sinkpad->type == srcpad->type &&
|
|
|
|
sinkpad->direction == GST_PAD_SINK &&
|
|
|
|
!GST_PAD_CONNECTED(sinkpad)) {
|
2000-08-22 21:18:18 +00:00
|
|
|
gst_pad_connect(srcpad, sinkpad);
|
2000-09-17 22:08:09 +00:00
|
|
|
g_print("gstpipeline: autoconnect pad \"%s\" (%d) in element %s <-> ",
|
|
|
|
srcpad->name, srcpad->type, gst_element_get_name(src));
|
|
|
|
g_print("pad \"%s\" (%d) in element %s\n", sinkpad->name,
|
|
|
|
sinkpad->type, gst_element_get_name(sink));
|
2000-08-22 21:18:18 +00:00
|
|
|
connected = TRUE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
sinkpads = g_list_next(sinkpads);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
srcpads = g_list_next(srcpads);
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
if (!connected) {
|
|
|
|
g_print("gstpipeline: delaying pad connections\n");
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
void gst_pipeline_add_src(GstPipeline *pipeline, GstElement *src)
|
|
|
|
{
|
|
|
|
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));
|
|
|
|
|
|
|
|
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
|
|
|
|
* will be used as a sink for autoplugging
|
|
|
|
*/
|
|
|
|
void gst_pipeline_add_sink(GstPipeline *pipeline, GstElement *sink)
|
|
|
|
{
|
|
|
|
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));
|
|
|
|
|
|
|
|
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-08-21 21:20:38 +00:00
|
|
|
gboolean gst_pipeline_autoplug(GstPipeline *pipeline) {
|
|
|
|
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-08-21 21:20:38 +00:00
|
|
|
GstElementFactory *factory;
|
2000-09-24 22:45:48 +00:00
|
|
|
GList *src_types;
|
2000-08-21 21:20:38 +00:00
|
|
|
guint16 src_type = 0, sink_type = 0;
|
2000-10-08 22:17:11 +00:00
|
|
|
guint i, numsinks;
|
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);
|
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
g_print("GstPipeline: autopluging pipeline \"%s\"\n",
|
|
|
|
gst_element_get_name(GST_ELEMENT(pipeline)));
|
|
|
|
|
|
|
|
|
|
|
|
// fase 1, run typedetect on the source if needed...
|
|
|
|
if (!pipeline->src) {
|
|
|
|
g_print("GstPipeline: no source detected, can't autoplug pipeline \"%s\"\n",
|
|
|
|
gst_element_get_name(GST_ELEMENT(pipeline)));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
factory = gst_element_get_factory(pipeline->src);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
src_types = factory->src_types;
|
|
|
|
if (src_types == NULL) {
|
|
|
|
g_print("GstPipeline: source \"%s\" has no MIME type, running typefind...\n",
|
|
|
|
gst_element_get_name(pipeline->src));
|
|
|
|
|
|
|
|
src_type = gst_pipeline_typefind(pipeline, pipeline->src);
|
|
|
|
|
|
|
|
if (src_type) {
|
|
|
|
g_print("GstPipeline: source \"%s\" type found %d\n", gst_element_get_name(pipeline->src),
|
|
|
|
src_type);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_print("GstPipeline: source \"%s\" has no type\n", gst_element_get_name(pipeline->src));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (src_types) {
|
|
|
|
// FIXME loop over types and find paths...
|
|
|
|
src_types = g_list_next(src_types);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
srcelement = pipeline->src;
|
|
|
|
|
|
|
|
elements = pipeline->sinks;
|
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
numsinks = g_list_length(elements);
|
|
|
|
factories = g_new0(GList *, numsinks);
|
|
|
|
|
|
|
|
i = 0;
|
2000-09-22 23:35:14 +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
|
|
|
GList *pads;
|
|
|
|
GstPad *pad;
|
|
|
|
|
2000-08-21 21:20:38 +00:00
|
|
|
element = GST_ELEMENT(elements->data);
|
|
|
|
|
2000-09-22 23:35:14 +00:00
|
|
|
pads = gst_element_get_pad_list(element);
|
|
|
|
|
|
|
|
while (pads) {
|
|
|
|
pad = (GstPad *)pads->data;
|
|
|
|
|
|
|
|
if (pad->direction == GST_PAD_SINK) {
|
|
|
|
sink_type = gst_pad_get_type_id(pad);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
2000-10-08 22:17:11 +00:00
|
|
|
|
|
|
|
factories[i] = gst_type_get_sink_to_src(src_type, sink_type);
|
|
|
|
//factories[i] = g_list_append(factories[i], element);
|
|
|
|
i++;
|
|
|
|
|
2000-08-21 21:20:38 +00:00
|
|
|
elements = g_list_next(elements);
|
|
|
|
}
|
|
|
|
|
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++) {
|
|
|
|
if (factory != (GstElementFactory *)(factories[i]->data))
|
|
|
|
goto differ;
|
|
|
|
factories[i] = g_list_next(factories[i]);
|
|
|
|
}
|
|
|
|
factory = (GstElementFactory *)(factories[0]->data);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
g_print("GstPipeline: 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-08-21 21:20:38 +00:00
|
|
|
}
|
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
differ:
|
|
|
|
// loop over all the sink elements
|
|
|
|
elements = pipeline->sinks;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (elements) {
|
|
|
|
GstElement *thesrcelement = srcelement;
|
|
|
|
GstElement *thebin = GST_ELEMENT(pipeline);
|
|
|
|
|
|
|
|
sinkelement = (GstElement *)elements->data;
|
|
|
|
|
|
|
|
while (factories[i] || sinkelement) {
|
|
|
|
// fase 4: add other elements...
|
|
|
|
|
|
|
|
if (factories[i]) {
|
|
|
|
factory = (GstElementFactory *)(factories[i]->data);
|
|
|
|
g_print("GstPipeline: factory \"%s\"\n", factory->name);
|
|
|
|
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...
|
|
|
|
if (GST_ELEMENT_IS_THREAD_SUGGESTED(element)) {
|
|
|
|
GstElement *queue;
|
|
|
|
GList *sinkpads;
|
|
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
g_print("GstPipeline: sugest new thread for \"%s\" %08x\n", element->name, GST_FLAGS(element));
|
|
|
|
|
|
|
|
// create a new queue and add to the previous bin
|
|
|
|
queue = gst_elementfactory_make("queue", g_strconcat("queue_", gst_element_get_name(element), NULL));
|
|
|
|
gst_bin_add(GST_BIN(pipeline), queue);
|
|
|
|
|
|
|
|
// this will be the new bin for all following elements
|
|
|
|
thebin = gst_thread_new("thread");
|
|
|
|
|
|
|
|
srcpad = gst_element_get_pad(queue, "src");
|
|
|
|
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)) {
|
|
|
|
// the queue has the types of the element it connects
|
|
|
|
srcpad->type = sinkpad->type;
|
|
|
|
gst_element_get_pad(queue, "sink")->type = sinkpad->type;
|
|
|
|
gst_pad_connect(srcpad, sinkpad);
|
|
|
|
g_print("gstpipeline: autoconnect pad \"%s\" (%d) in element %s <-> ",
|
|
|
|
srcpad->name, srcpad->type, gst_element_get_name(queue));
|
|
|
|
g_print("pad \"%s\" (%d) in element %s\n", sinkpad->name,
|
|
|
|
sinkpad->type, gst_element_get_name(element));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sinkpads = g_list_next(sinkpads);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_bin_add(GST_BIN(thebin), element);
|
|
|
|
gst_bin_add(GST_BIN(pipeline), thebin);
|
|
|
|
element = queue;
|
|
|
|
}
|
|
|
|
// no thread needed, easy case
|
|
|
|
else {
|
|
|
|
gst_bin_add(GST_BIN(thebin), element);
|
|
|
|
}
|
|
|
|
gst_pipeline_pads_autoplug(thesrcelement, element);
|
|
|
|
|
|
|
|
// this element is now the new source element
|
|
|
|
thesrcelement = element;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2000-09-17 22:08:09 +00:00
|
|
|
g_print("GstPipeline: unable to autoplug pipeline \"%s\"\n",
|
|
|
|
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-07-17 17:14:15 +00:00
|
|
|
static GstElementStateReturn gst_pipeline_change_state(GstElement *element) {
|
2000-01-30 09:03:00 +00:00
|
|
|
GstPipeline *pipeline;
|
|
|
|
|
2000-02-27 23:18:38 +00:00
|
|
|
g_return_val_if_fail(GST_IS_PIPELINE(element), FALSE);
|
2000-01-30 09:03:00 +00:00
|
|
|
pipeline = GST_PIPELINE(element);
|
|
|
|
|
2000-08-14 10:55:35 +00:00
|
|
|
|
|
|
|
switch (GST_STATE_PENDING(pipeline)) {
|
2000-07-17 17:14:15 +00:00
|
|
|
case GST_STATE_READY:
|
|
|
|
// we need to set up internal state
|
2000-01-30 09:03:00 +00:00
|
|
|
gst_pipeline_prepare(pipeline);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
2000-08-14 10:55:35 +00:00
|
|
|
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
|
|
|
return GST_STATE_SUCCESS;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-02 06:26:44 +00:00
|
|
|
/**
|
|
|
|
* gst_pipeline_iterate:
|
|
|
|
* @pipeline: GstPipeline to iterate
|
|
|
|
*
|
|
|
|
* Cause the pipeline's contents to be run through one full 'iteration'.
|
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
void gst_pipeline_iterate(GstPipeline *pipeline) {
|
|
|
|
g_return_if_fail(pipeline != NULL);
|
|
|
|
g_return_if_fail(GST_IS_PIPELINE(pipeline));
|
|
|
|
}
|