remove old autoplug support

Original commit message from CVS:
remove old autoplug support
This commit is contained in:
David Schleef 2003-11-29 05:30:56 +00:00
parent 57fcf33e5e
commit 97383fdaee
9 changed files with 0 additions and 3086 deletions

View file

@ -1,123 +0,0 @@
#include <gst/gst.h>
#include <stdlib.h>
#include <string.h>
GstElement *pipeline, *src, *autobin, *cache, *typefind, *decoder, *sink;
/* callback for when we have the type of the file
* we set up a playing pipeline based on the mime type
*/
void
have_type (GstElement *element, GstCaps *caps, GstCaps **private_caps)
{
gchar *mime = g_strdup_printf (gst_caps_get_mime (caps));
fprintf (stderr, "have caps, mime type is %s\n", mime);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
/* unlink the typefind from the pipeline and remove it,
* since we now know what the type is */
gst_element_unlink (cache, typefind);
gst_bin_remove (GST_BIN (autobin), typefind);
gst_scheduler_show (GST_ELEMENT_SCHED (pipeline));
/* now based on the mime type set up the pipeline properly */
if (strstr (mime, "mp3")) {
decoder = gst_element_factory_make ("mad", "decoder");
}
else if (strstr (mime, "x-ogg")) {
decoder = gst_element_factory_make ("vorbisfile", "decoder");
}
else if (strstr (mime, "x-wav")) {
decoder = gst_element_factory_make ("wavparse", "decoder");
}
else if (strstr (mime, "x-flac")) {
decoder = gst_element_factory_make ("flacdec", "decoder");
}
else {
g_print ("mime type %s not handled in this program, exiting.\n", mime);
g_free (mime);
exit (-1);
}
g_free (mime);
/* handle playback */
sink = gst_element_factory_make ("osssink", "sink");
gst_bin_add (GST_BIN (autobin), decoder);
gst_bin_add (GST_BIN (autobin), sink);
gst_element_link (decoder, sink);
g_object_set (G_OBJECT (cache), "reset", TRUE, NULL);
gst_element_link (cache, decoder);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
fprintf (stderr, "done with have_type signal, playing\n");
}
void cache_empty (GstElement *element, gpointer private) {
fprintf(stderr,"have cache empty\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_element_unlink_pads (src,"src",cache,"sink");
gst_scheduler_show (GST_ELEMENT_SCHED(pipeline));
gst_element_unlink_pads (cache,"src",decoder,"sink");
gst_scheduler_show (GST_ELEMENT_SCHED(pipeline));
gst_bin_remove (GST_BIN(autobin), cache);
gst_scheduler_show (GST_ELEMENT_SCHED(pipeline));
gst_element_link_pads (src,"src",decoder,"sink");
gst_scheduler_show (GST_ELEMENT_SCHED(pipeline));
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gst_scheduler_show (GST_ELEMENT_SCHED(pipeline));
fprintf(stderr,"done with cache_empty\n");
}
int main (int argc,char *argv[]) {
GstCaps *caps;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("filesrc","src");
if (argc < 2) {
g_print ("Please give a file to test the autoplugger on.\n");
return -1;
}
g_object_set (G_OBJECT (src), "location", argv[1], NULL);
gst_bin_add (GST_BIN (pipeline), src);
/* the autobin will be used to do the autoplugging in */
autobin = gst_bin_new ("autobin");
/* a cache is used to make autoplugging quicker */
cache = gst_element_factory_make ("autoplugcache", "cache");
g_signal_connect (G_OBJECT (cache), "cache_empty",
G_CALLBACK (cache_empty), NULL);
/* typefind does the type detection */
typefind = gst_element_factory_make ("typefind", "typefind");
/* execute the callback when we find the type */
g_signal_connect (G_OBJECT (typefind), "have_type",
G_CALLBACK (have_type), &caps);
gst_bin_add (GST_BIN (autobin), cache);
gst_bin_add (GST_BIN (autobin), typefind);
gst_element_link (cache, typefind);
gst_element_add_ghost_pad (autobin,
gst_element_get_pad (cache, "sink") ,"sink");
gst_bin_add (GST_BIN (pipeline), autobin);
gst_element_link (src, autobin);
/* pipeline is now src ! autobin
* with autobin: cache ! typefind
*/
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
return 0;
}

View file

@ -1,367 +0,0 @@
/* GStreamer
* Copyright (C) 2001 RidgeRun, Inc. (www.ridgerun.com)
*
* gstautoplugcache.c: Data cache for the dynamic autoplugger
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gst/gst.h>
GST_DEBUG_CATEGORY_STATIC(debug_category);
#define GST_CAT_DEFAULT debug_category
GstElementDetails gst_autoplugcache_details = GST_ELEMENT_DETAILS (
"AutoplugCache",
"Generic",
"Data cache for the dynamic autoplugger",
"Erik Walthinsen <omega@temple-baptist.com>"
);
#define GST_TYPE_AUTOPLUGCACHE \
(gst_autoplugcache_get_type())
#define GST_AUTOPLUGCACHE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUTOPLUGCACHE,GstAutoplugCache))
#define GST_AUTOPLUGCACHE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUTOPLUGCACHE,GstAutoplugCacheClass))
#define GST_IS_AUTOPLUGCACHE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUTOPLUGCACHE))
#define GST_IS_AUTOPLUGCACHE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUTOPLUGCACHE))
typedef struct _GstAutoplugCache GstAutoplugCache;
typedef struct _GstAutoplugCacheClass GstAutoplugCacheClass;
struct _GstAutoplugCache {
GstElement element;
GstPad *sinkpad, *srcpad;
gboolean caps_proxy;
GList *cache;
GList *cache_start;
gint buffer_count;
GList *current_playout;
gboolean fire_empty;
gboolean fire_first;
};
struct _GstAutoplugCacheClass {
GstElementClass parent_class;
void (*first_buffer) (GstElement *element, GstBuffer *buf);
void (*cache_empty) (GstElement *element);
};
/* Cache signals and args */
enum {
FIRST_BUFFER,
CACHE_EMPTY,
LAST_SIGNAL
};
enum {
ARG_0,
ARG_BUFFER_COUNT,
ARG_CAPS_PROXY,
ARG_RESET
};
static void gst_autoplugcache_class_init (GstAutoplugCacheClass *klass);
static void gst_autoplugcache_init (GstAutoplugCache *cache);
static void gst_autoplugcache_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void gst_autoplugcache_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static void gst_autoplugcache_loop (GstElement *element);
static GstElementStateReturn gst_autoplugcache_change_state (GstElement *element);
static GstElementClass *parent_class = NULL;
static guint gst_autoplugcache_signals[LAST_SIGNAL] = { 0 };
GType
gst_autoplugcache_get_type(void) {
static GType autoplugcache_type = 0;
if (!autoplugcache_type) {
static const GTypeInfo autoplugcache_info = {
sizeof(GstAutoplugCacheClass),
NULL,
NULL,
(GClassInitFunc)gst_autoplugcache_class_init,
NULL,
NULL,
sizeof(GstAutoplugCache),
0,
(GInstanceInitFunc)gst_autoplugcache_init,
};
autoplugcache_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAutoplugCache", &autoplugcache_info, 0);
}
return autoplugcache_type;
}
static void
gst_autoplugcache_class_init (GstAutoplugCacheClass *klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFFER_COUNT,
g_param_spec_int("buffer_count","buffer_count","buffer_count",
0,G_MAXINT,0,G_PARAM_READABLE)); /* CHECKME! */
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CAPS_PROXY,
g_param_spec_boolean("caps_proxy","caps_proxy","caps_proxy",
FALSE,G_PARAM_READWRITE)); /* CHECKME! */
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_RESET,
g_param_spec_boolean("reset","reset","reset",
FALSE,G_PARAM_WRITABLE)); /* CHECKME! */
gst_autoplugcache_signals[FIRST_BUFFER] =
g_signal_new ("first_buffer", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstAutoplugCacheClass, first_buffer), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
gst_autoplugcache_signals[CACHE_EMPTY] =
g_signal_new ("cache_empty", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstAutoplugCacheClass, cache_empty), NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_autoplugcache_set_property;
gobject_class->get_property = gst_autoplugcache_get_property;
gstelement_class->change_state = gst_autoplugcache_change_state;
gst_element_class_set_details (gstelement_class, &gst_autoplugcache_details);
}
static void
gst_autoplugcache_init (GstAutoplugCache *cache)
{
gst_element_set_loop_function(GST_ELEMENT(cache), GST_DEBUG_FUNCPTR(gst_autoplugcache_loop));
cache->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
/* gst_pad_set_negotiate_function (cache->sinkpad, gst_autoplugcache_nego_sink); */
gst_element_add_pad (GST_ELEMENT(cache), cache->sinkpad);
cache->srcpad = gst_pad_new ("src", GST_PAD_SRC);
/* gst_pad_set_negotiate_function (cache->srcpad, gst_autoplugcache_nego_src); */
gst_element_add_pad (GST_ELEMENT(cache), cache->srcpad);
cache->caps_proxy = FALSE;
/* provide a zero basis for the cache */
cache->cache = g_list_prepend(NULL, NULL);
cache->cache_start = cache->cache;
cache->buffer_count = 0;
cache->current_playout = 0;
cache->fire_empty = FALSE;
cache->fire_first = FALSE;
}
static void
gst_autoplugcache_loop (GstElement *element)
{
GstAutoplugCache *cache;
GstBuffer *buf = NULL;
cache = GST_AUTOPLUGCACHE (element);
/* Theory:
* The cache is a doubly-linked list. The front of the list is the most recent
* buffer, the end of the list is the first buffer. The playout pointer always
* points to the latest buffer sent out the end. cache points to the front
* (most reccent) of the list at all times. cache_start points to the first
* buffer, i.e. the end of the list.
* If the playout pointer does not have a prev (towards the most recent) buffer
* (== NULL), a buffer must be pulled from the sink pad and added to the cache.
* When the playout pointer gets reset (as in a set_property), the cache is walked
* without problems, because the playout pointer has a non-NULL next. When
* the playout pointer hits the end of cache again it has to start pulling.
*/
/* the first time through, the current_playout pointer is going to be NULL */
if (cache->current_playout == NULL) {
/* get a buffer */
buf = GST_BUFFER (gst_pad_pull (cache->sinkpad));
if (GST_IS_EVENT (buf)) {
gst_pad_event_default (cache->sinkpad, GST_EVENT (buf));
return;
}
/* add it to the cache, though cache == NULL */
gst_buffer_ref (buf);
cache->cache = g_list_prepend (cache->cache, buf);
cache->buffer_count++;
/* set the current_playout pointer */
cache->current_playout = cache->cache;
g_signal_emit (G_OBJECT(cache), gst_autoplugcache_signals[FIRST_BUFFER], 0, buf);
/* send the buffer on its way */
gst_pad_push (cache->srcpad, GST_DATA (buf));
}
/* the steady state is where the playout is at the front of the cache */
else if (g_list_previous(cache->current_playout) == NULL) {
/* if we've been told to fire an empty signal (after a reset) */
if (cache->fire_empty) {
int oldstate = GST_STATE(cache);
GST_DEBUG ("at front of cache, about to pull, but firing signal");
gst_object_ref (GST_OBJECT (cache));
g_signal_emit (G_OBJECT(cache), gst_autoplugcache_signals[CACHE_EMPTY], 0, NULL);
if (GST_STATE(cache) != oldstate) {
gst_object_unref (GST_OBJECT (cache));
GST_DEBUG ("state changed during signal, aborting");
return;
}
gst_object_unref (GST_OBJECT (cache));
}
/* get a buffer */
buf = GST_BUFFER (gst_pad_pull (cache->sinkpad));
if (GST_IS_EVENT (buf)) {
gst_pad_event_default (cache->sinkpad, GST_EVENT (buf));
return;
}
/* add it to the front of the cache */
gst_buffer_ref (buf);
cache->cache = g_list_prepend (cache->cache, buf);
cache->buffer_count++;
/* set the current_playout pointer */
cache->current_playout = cache->cache;
/* send the buffer on its way */
gst_pad_push (cache->srcpad, GST_DATA (buf));
}
/* otherwise we're trundling through existing cached buffers */
else {
/* move the current_playout pointer */
cache->current_playout = g_list_previous (cache->current_playout);
if (cache->fire_first) {
g_signal_emit (G_OBJECT(cache), gst_autoplugcache_signals[FIRST_BUFFER], 0, buf);
cache->fire_first = FALSE;
}
/* push that buffer */
gst_pad_push (cache->srcpad, GST_DATA (GST_BUFFER(cache->current_playout->data)));
}
}
static GstElementStateReturn
gst_autoplugcache_change_state (GstElement *element)
{
/* FIXME this should do something like free the cache on ->NULL */
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
static void
gst_autoplugcache_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GstAutoplugCache *cache;
cache = GST_AUTOPLUGCACHE (object);
switch (prop_id) {
case ARG_CAPS_PROXY:
cache->caps_proxy = g_value_get_boolean (value);
GST_DEBUG ("caps_proxy is %d",cache->caps_proxy);
if (cache->caps_proxy) {
} else {
}
break;
case ARG_RESET:
/* no idea why anyone would set this to FALSE, but just in case ;-) */
if (g_value_get_boolean (value)) {
GST_DEBUG ("resetting playout pointer");
/* reset the playout pointer to the begining again */
cache->current_playout = cache->cache_start;
/* now we can fire a signal when the cache runs dry */
cache->fire_empty = TRUE;
/* also set it up to fire the first_buffer signal again */
cache->fire_first = TRUE;
}
break;
default:
break;
}
}
static void
gst_autoplugcache_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GstAutoplugCache *cache;
cache = GST_AUTOPLUGCACHE (object);
switch (prop_id) {
case ARG_BUFFER_COUNT:
g_value_set_int (value, cache->buffer_count);
break;
case ARG_CAPS_PROXY:
g_value_set_boolean (value, cache->caps_proxy);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
plugin_init (GstPlugin *plugin)
{
GST_DEBUG_CATEGORY_INIT (debug_category, "AUTOPLUGCACHE", 0, "autoplugcache element");
if (!gst_element_register (plugin, "autoplugcache", GST_RANK_NONE, GST_TYPE_AUTOPLUGCACHE))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"autoplugcache",
"an autoplug cache",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)

View file

@ -1,617 +0,0 @@
/* GStreamer
* Copyright (C) 2001 RidgeRun, Inc. (www.ridgerun.com)
*
* gstautoplugger.c: Data for the dynamic autopluggerger
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gst/gst.h>
GstElementDetails gst_autoplugger_details = GST_ELEMENT_DETAILS (
"Dynamic autoplugger",
"Generic",
"Magic element that converts from any type to any other",
"Erik Walthinsen <omega@temple-baptist.com>"
);
#define GST_TYPE_AUTOPLUGGER \
(gst_autoplugger_get_type())
#define GST_AUTOPLUGGER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUTOPLUGGER,GstAutoplugger))
#define GST_AUTOPLUGGER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUTOPLUGGER,GstAutopluggerClass))
#define GST_IS_AUTOPLUGGER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUTOPLUGGER))
#define GST_IS_AUTOPLUGGER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUTOPLUGGER))
typedef struct _GstAutoplugger GstAutoplugger;
typedef struct _GstAutopluggerClass GstAutopluggerClass;
struct _GstAutoplugger {
GstBin bin;
gint paused;
GstElement *cache;
gboolean cache_first_buffer;
GstPad *cache_sinkpad, *cache_srcpad;
GstElement *typefind;
GstPad *typefind_sinkpad;
GstPad *sinkpadpeer, *srcpadpeer;
GstCaps *sinkcaps, *srccaps;
GstCaps *sinktemplatecaps;
GstAutoplug *autoplug;
GstElement *autobin;
gboolean disable_nocaps;
};
struct _GstAutopluggerClass {
GstBinClass parent_class;
};
/* signals and args */
enum {
LAST_SIGNAL
};
enum {
ARG_0,
};
static void gst_autoplugger_class_init (GstAutopluggerClass *klass);
static void gst_autoplugger_init (GstAutoplugger *queue);
static void gst_autoplugger_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_autoplugger_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
/*static GstElementStateReturn gst_autoplugger_change_state (GstElement *element);*/
/*
static void gst_autoplugger_external_sink_caps_changed (GstPad *pad, GstCaps *caps, GstAutoplugger *autoplugger);
static void gst_autoplugger_external_src_caps_changed (GstPad *pad, GstCaps *caps, GstAutoplugger *autoplugger);
*/
static void gst_autoplugger_external_sink_caps_nego_failed (GstPad *pad, gboolean *result, GstAutoplugger *autoplugger);
static void gst_autoplugger_external_src_caps_nego_failed (GstPad *pad, gboolean *result, GstAutoplugger *autoplugger);
/* defined but not used
static void gst_autoplugger_external_sink_linked (GstPad *pad, GstPad *peerpad, GstAutoplugger *autoplugger);
static void gst_autoplugger_external_src_linked (GstPad *pad, GstPad *peerpad, GstAutoplugger *autoplugger);
*/
static void gst_autoplugger_cache_first_buffer (GstElement *element,GstBuffer *buf,GstAutoplugger *autoplugger);
static void gst_autoplugger_cache_empty (GstElement *element, GstAutoplugger *autoplugger);
static void gst_autoplugger_type_find_have_type (GstElement *element, GstCaps *caps, GstAutoplugger *autoplugger);
static GstElementClass *parent_class = NULL;
/*static guint gst_autoplugger_signals[LAST_SIGNAL] = { 0 };*/
GType
gst_autoplugger_get_type(void) {
static GType autoplugger_type = 0;
if (!autoplugger_type) {
static const GTypeInfo autoplugger_info = {
sizeof(GstAutopluggerClass),
NULL,
NULL,
(GClassInitFunc)gst_autoplugger_class_init,
NULL,
NULL,
sizeof(GstAutoplugger),
0,
(GInstanceInitFunc)gst_autoplugger_init,
};
autoplugger_type = g_type_register_static (GST_TYPE_BIN, "GstAutoplugger", &autoplugger_info, 0);
}
return autoplugger_type;
}
static void
gst_autoplugger_class_init (GstAutopluggerClass *klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
/*
gst_autoplugger_signals[_EMPTY] =
g_signal_new ("_empty", G_OBJECT_TYPE(gobject_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstAutopluggerClass, _empty), NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
*/
/*
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFFER_COUNT,
g_param_spec_int("buffer_count","buffer_count","buffer_count",
0,G_MAXINT,0,G_PARAM_READABLE)); * CHECKME! *
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_RESET,
g_param_spec_boolean("reset","reset","reset",
FALSE,G_PARAM_WRITABLE)); * CHECKME! *
*/
gobject_class->set_property = gst_autoplugger_set_property;
gobject_class->get_property = gst_autoplugger_get_property;
/* gstelement_class->change_state = gst_autoplugger_change_state; */
gst_element_class_set_details (gstelement_class, &gst_autoplugger_details);
}
static void
gst_autoplugger_init (GstAutoplugger *autoplugger)
{
/* create the autoplugger cache, which is the fundamental unit of the autopluggerger */
/* FIXME we need to find a way to set element's name before _init */
/* FIXME ... so we can name the subelements uniquely */
autoplugger->cache = gst_element_factory_make("autoplugcache", "unnamed_autoplugcache");
g_return_if_fail (autoplugger->cache != NULL);
GST_DEBUG ("turning on caps nego proxying in cache");
g_object_set(G_OBJECT(autoplugger->cache),"caps_proxy",TRUE,NULL);
/* attach signals to the cache */
g_signal_connect (G_OBJECT (autoplugger->cache), "first_buffer",
G_CALLBACK (gst_autoplugger_cache_first_buffer), autoplugger);
/* add the cache to self */
gst_bin_add (GST_BIN(autoplugger), autoplugger->cache);
/* get the cache's pads so we can attach stuff to them */
autoplugger->cache_sinkpad = gst_element_get_pad (autoplugger->cache, "sink");
autoplugger->cache_srcpad = gst_element_get_pad (autoplugger->cache, "src");
/* attach handlers to the typefind pads */
/* FIXME "caps_changed" no longer exists
g_signal_connect (G_OBJECT (autoplugger->cache_sinkpad), "caps_changed",
G_CALLBACK (gst_autoplugger_external_sink_caps_changed), autoplugger);
g_signal_connect (G_OBJECT (autoplugger->cache_srcpad), "caps_changed",
G_CALLBACK (gst_autoplugger_external_src_caps_changed), autoplugger);
*/
g_signal_connect (G_OBJECT (autoplugger->cache_sinkpad), "caps_nego_failed",
G_CALLBACK (gst_autoplugger_external_sink_caps_nego_failed), autoplugger);
g_signal_connect (G_OBJECT (autoplugger->cache_srcpad), "caps_nego_failed",
G_CALLBACK (gst_autoplugger_external_src_caps_nego_failed), autoplugger);
/* g_signal_connect (G_OBJECT (autoplugger->cache_sinkpad), "linked", */
/* gst_autoplugger_external_sink_linked, autoplugger);*/
/* g_signal_connect (G_OBJECT (autoplugger->cache_srcpad), "linked", */
/* gst_autoplugger_external_src_linked, autoplugger); */
/* ghost both of these pads to the outside world */
gst_element_add_ghost_pad (GST_ELEMENT(autoplugger), autoplugger->cache_sinkpad, "sink");
gst_element_add_ghost_pad (GST_ELEMENT(autoplugger), autoplugger->cache_srcpad, "src");
}
/* defined but not used
G_GNUC_UNUSED static void
gst_autoplugger_external_sink_linked(GstPad *pad, GstPad *peerpad, GstAutoplugger *autoplugger)
{
GstPadTemplate *peertemplate;
GstCaps *peercaps, *peertemplatecaps;
GST_INFO ("have cache:sink linked");*/
/* autoplugger->sinkpadpeer = peerpad; */
/*
if (autoplugger->sinkpadpeer) {
peercaps = GST_PAD_CAPS(autoplugger->sinkpadpeer);
if (peercaps)
GST_INFO ("there are some caps on this pad's peer: %s",
gst_caps_get_mime(peercaps));
peertemplate = GST_PAD_PAD_TEMPLATE(autoplugger->sinkpadpeer);
if (peertemplate) {
peertemplatecaps = GST_PAD_TEMPLATE_CAPS(peertemplate);
if (peertemplatecaps) {
GST_INFO ("there are some caps on this pad's peer's padtemplate %s",
gst_caps_get_mime(peertemplatecaps));
}
}
}
}
G_GNUC_UNUSED static void
gst_autoplugger_external_src_linked(GstPad *pad, GstPad *peerpad, GstAutoplugger *autoplugger)
{
GstPadTemplate *peertemplate;
GstCaps *peercaps, *peertemplatecaps;
GST_INFO ("have cache:src linked");*/
/* autoplugger->srcpadpeer = peerpad; */
/*
if (autoplugger->srcpadpeer) {
peercaps = GST_PAD_CAPS(autoplugger->srcpadpeer);
if (peercaps)
GST_INFO ("there are some caps on this pad's peer: %s",
gst_caps_get_mime(peercaps));
peertemplate = GST_PAD_PAD_TEMPLATE(autoplugger->srcpadpeer);
if (peertemplate) {
peertemplatecaps = GST_PAD_TEMPLATE_CAPS(peertemplate);
if (peertemplatecaps) {
GST_INFO ("there are some caps on this pad's peer's padtemplate %s",
gst_caps_get_mime(peertemplatecaps));
autoplugger->sinktemplatecaps = peertemplatecaps;*/
/* GST_DEBUG ("turning on caps nego proxying in cache"); */
/* gtk_object_set(G_OBJECT(autoplugger->cache),"caps_proxy",TRUE,NULL);*/
/* }
}
}
}*/
/*
static void
gst_autoplugger_external_sink_caps_changed(GstPad *pad, GstCaps *caps, GstAutoplugger *autoplugger)
{
GST_INFO ("have cache:sink caps of %s\n",gst_caps_get_mime(caps));
autoplugger->sinkcaps = caps;
}
static void
gst_autoplugger_external_src_caps_changed(GstPad *pad, GstCaps *caps, GstAutoplugger *autoplugger)
{
GST_INFO ("have cache:src caps of %s\n",gst_caps_get_mime(caps));
autoplugger->srccaps = caps;
}
*/
static gboolean
gst_autoplugger_autoplug(GstAutoplugger *autoplugger,GstPad *srcpad,GstCaps *srccaps,GstCaps *sinkcaps)
{
GstPad *sinkpad;
sinkpad = GST_PAD(GST_PAD_PEER(srcpad));
GST_DEBUG ("unlinking %s:%s and %s:%s to autoplug between them",
GST_DEBUG_PAD_NAME(srcpad),GST_DEBUG_PAD_NAME(sinkpad));
GST_DEBUG ("srcpadcaps are of type %s",gst_caps_get_mime(srccaps));
GST_DEBUG ("sinkpadcaps are of type %s",gst_caps_get_mime(sinkcaps));
/* unlink the pads */
GST_DEBUG ("unlinking the pads that will be joined by an autobin");
gst_pad_unlink(srcpad,sinkpad);
if (!autoplugger->autoplug) {
autoplugger->autoplug = gst_autoplug_factory_make("static");
g_return_val_if_fail(autoplugger->autoplug != NULL, FALSE);
}
GST_DEBUG ("building autoplugged bin between caps");
autoplugger->autobin = gst_autoplug_to_caps(autoplugger->autoplug,
srccaps,sinkcaps,NULL);
g_return_val_if_fail(autoplugger->autobin != NULL, FALSE);
gst_bin_add(GST_BIN(autoplugger),autoplugger->autobin);
gst_scheduler_show(GST_ELEMENT_SCHED(autoplugger));
/* FIXME this is a hack */
/* GST_DEBUG ("copying failed caps to srcpad %s:%s to ensure renego",GST_DEBUG_PAD_NAME(autoplugger->cache_srcpad)); */
/* gst_pad_set_caps(srcpad,srccaps); */
if (GST_PAD_CAPS(srcpad) == NULL) GST_DEBUG ("no caps on cache:src!");
/* attach the autoplugged bin */
GST_DEBUG ("attaching the autoplugged bin between the two pads");
gst_pad_link(srcpad,gst_element_get_pad(autoplugger->autobin,"sink"));
gst_scheduler_show(GST_ELEMENT_SCHED(autoplugger));
gst_pad_link(gst_element_get_pad(autoplugger->autobin,"src_00"),sinkpad);
gst_scheduler_show(GST_ELEMENT_SCHED(autoplugger));
/* FIXME try to force the renego */
/* GST_DEBUG ("trying to force everyone to nego"); */
/* gst_pad_renegotiate(gst_element_get_pad(autoplugger->autobin,"sink")); */
/* gst_pad_renegotiate(sinkpad); */
return TRUE;
}
static void
gst_autoplugger_external_sink_caps_nego_failed(GstPad *pad, gboolean *result, GstAutoplugger *autoplugger)
{
GstPad *srcpad_peer;
GstPadTemplate *srcpad_peer_template;
GstCaps *srcpad_peer_caps;
GstPad *sinkpad_peer;
GstCaps *sinkpad_peer_caps;
GST_INFO ("have caps nego failure on sinkpad %s:%s!!!",GST_DEBUG_PAD_NAME(pad));
autoplugger->paused++;
if (autoplugger->paused == 1)
/* try to PAUSE the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PAUSED);
srcpad_peer = GST_PAD(GST_PAD_PEER(autoplugger->cache_srcpad));
g_return_if_fail(srcpad_peer != NULL);
srcpad_peer_template = GST_PAD_PAD_TEMPLATE(srcpad_peer);
g_return_if_fail(srcpad_peer_template != NULL);
srcpad_peer_caps = GST_PAD_TEMPLATE_CAPS(srcpad_peer_template);
g_return_if_fail(srcpad_peer_caps != NULL);
sinkpad_peer = GST_PAD(GST_PAD_PEER(pad));
g_return_if_fail(sinkpad_peer != NULL);
sinkpad_peer_caps = GST_PAD_CAPS(sinkpad_peer);
g_return_if_fail(sinkpad_peer_caps != NULL);
if (gst_autoplugger_autoplug(autoplugger,autoplugger->cache_srcpad,sinkpad_peer_caps,srcpad_peer_caps))
*result = TRUE;
autoplugger->paused--;
if (autoplugger->paused == 0)
/* try to PLAY the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PLAYING);
GST_INFO ("done dealing with caps nego failure on sinkpad %s:%s",GST_DEBUG_PAD_NAME(pad));
}
static void
gst_autoplugger_external_src_caps_nego_failed(GstPad *pad, gboolean *result, GstAutoplugger *autoplugger)
{
GstCaps *srcpad_caps;
GstPad *srcpad_peer;
GstPadTemplate *srcpad_peer_template;
GstCaps *srcpad_peer_caps;
GST_INFO ("have caps nego failure on srcpad %s:%s!!!",GST_DEBUG_PAD_NAME(pad));
autoplugger->paused++;
if (autoplugger->paused == 1)
/* try to PAUSE the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PAUSED);
srcpad_caps = GST_PAD_CAPS(autoplugger->cache_srcpad);
srcpad_peer = GST_PAD(GST_PAD_PEER(autoplugger->cache_srcpad));
g_return_if_fail(srcpad_peer != NULL);
srcpad_peer_template = GST_PAD_PAD_TEMPLATE(srcpad_peer);
g_return_if_fail(srcpad_peer_template != NULL);
srcpad_peer_caps = GST_PAD_TEMPLATE_CAPS(srcpad_peer_template);
g_return_if_fail(srcpad_peer_caps != NULL);
if (gst_autoplugger_autoplug(autoplugger,autoplugger->cache_srcpad,srcpad_caps,srcpad_peer_caps))
*result = TRUE;
autoplugger->paused--;
if (autoplugger->paused == 0)
/* try to PLAY the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PLAYING);
autoplugger->disable_nocaps = TRUE;
GST_INFO ("done dealing with caps nego failure on srcpad %s:%s",GST_DEBUG_PAD_NAME(pad));
}
static void
gst_autoplugger_cache_empty(GstElement *element, GstAutoplugger *autoplugger)
{
GstPad *cache_sinkpad_peer,*cache_srcpad_peer;
GST_INFO ("autoplugger cache has hit empty, we can now remove it");
autoplugger->paused++;
if (autoplugger->paused == 1)
/* try to PAUSE the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PAUSED);
/* unlink the cache from its peers */
GST_DEBUG ("unlinking autoplugcache from its peers");
cache_sinkpad_peer = GST_PAD (GST_PAD_PEER(autoplugger->cache_sinkpad));
cache_srcpad_peer = GST_PAD (GST_PAD_PEER(autoplugger->cache_srcpad));
gst_pad_unlink(cache_sinkpad_peer,autoplugger->cache_sinkpad);
gst_pad_unlink(autoplugger->cache_srcpad,cache_srcpad_peer);
/* remove the cache from self */
GST_DEBUG ("removing the cache from the autoplugger");
gst_bin_remove (GST_BIN(autoplugger), autoplugger->cache);
/* link the two pads */
GST_DEBUG ("relinking the autoplugcache's former peers");
gst_pad_link(cache_sinkpad_peer,cache_srcpad_peer);
autoplugger->paused--;
if (autoplugger->paused == 0)
/* try to PLAY the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PLAYING);
/* xmlSaveFile("autoplugger.gst", gst_xml_write(GST_ELEMENT_SCHED(autoplugger)->parent)); */
GST_INFO ("autoplugger_cache_empty finished");
}
static void
gst_autoplugger_type_find_have_type(GstElement *element, GstCaps *caps, GstAutoplugger *autoplugger)
{
GST_INFO ("typefind claims to have a type: %s",gst_caps_get_mime(caps));
gst_scheduler_show(GST_ELEMENT_SCHED(autoplugger));
autoplugger->paused++;
if (autoplugger->paused == 1)
/* try to PAUSE the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PAUSED);
/* first unlink the typefind and shut it down */
GST_DEBUG ("unlinking typefind from the cache");
gst_pad_unlink(autoplugger->cache_srcpad,autoplugger->typefind_sinkpad);
gst_bin_remove(GST_BIN(autoplugger),autoplugger->typefind);
/* FIXME FIXME now we'd compare caps and see if we need to autoplug something in the middle, but for */
/* now we're going to just relink where we left off */
/* FIXME FIXME FIXME!!!: this should really be done in the caps failure!!! */
/*
if (!autoplugger->autoplug) {
autoplugger->autoplug = gst_autoplug_factory_make("static");
}
autoplugger->autobin = gst_autoplug_to_caps(autoplugger->autoplug,
caps,autoplugger->sinktemplatecaps,NULL);
g_return_if_fail(autoplugger->autobin != NULL);
gst_bin_add(GST_BIN(autoplugger),autoplugger->autobin);
* * re-attach the srcpad's original peer to the cache *
* GST_DEBUG ("relinking the cache to the downstream peer"); *
* gst_pad_link(autoplugger->cache_srcpad,autoplugger->srcpadpeer); *
* attach the autoplugged bin *
GST_DEBUG ("attaching the autoplugged bin between cache and downstream peer");
gst_pad_link(autoplugger->cache_srcpad,gst_element_get_pad(autoplugger->autobin,"sink"));
gst_pad_link(gst_element_get_pad(autoplugger->autobin,"src_00"),autoplugger->srcpadpeer);
*/
/* FIXME set the caps on the new link
* GST_DEBUG ("forcing caps on the typefound pad");
* gst_pad_set_caps(autoplugger->cache_srcpad,caps);
* reattach the original outside srcpad
*/
GST_DEBUG ("re-attaching downstream peer to autoplugcache");
gst_pad_link(autoplugger->cache_srcpad,autoplugger->srcpadpeer);
/* now reset the autoplugcache */
GST_DEBUG ("resetting the cache to send first buffer(s) again");
g_object_set(G_OBJECT(autoplugger->cache),"reset",TRUE,NULL);
/* attach the cache_empty handler */
/* FIXME this is the wrong place, it shouldn't be done until we get successful caps nego! */
g_signal_connect (G_OBJECT(autoplugger->cache),"cache_empty",
G_CALLBACK (gst_autoplugger_cache_empty), autoplugger);
autoplugger->paused--;
if (autoplugger->paused == 0)
/* try to PLAY the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PLAYING);
GST_INFO ("typefind_have_type finished");
gst_scheduler_show(GST_ELEMENT_SCHED(autoplugger));
}
static void
gst_autoplugger_cache_first_buffer(GstElement *element,GstBuffer *buf,GstAutoplugger *autoplugger)
{
GST_INFO ("have first buffer through cache");
autoplugger->cache_first_buffer = TRUE;
/* if there are no established caps, worry */
if (!autoplugger->sinkcaps) {
GST_INFO ("have no caps for the buffer, Danger Will Robinson!");
if (autoplugger->disable_nocaps) {
GST_DEBUG ("not dealing with lack of caps this time");
return;
}
gst_scheduler_show(GST_ELEMENT_SCHED(autoplugger));
autoplugger->paused++;
if (autoplugger->paused == 1)
/* try to PAUSE the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PAUSED);
/* detach the srcpad */
GST_DEBUG ("unlinking cache from its downstream peer");
autoplugger->srcpadpeer = GST_PAD(GST_PAD_PEER(autoplugger->cache_srcpad));
gst_pad_unlink(autoplugger->cache_srcpad,autoplugger->srcpadpeer);
/* instantiate the typefind and set up the signal handlers */
if (!autoplugger->typefind) {
GST_DEBUG ("creating typefind and setting signal handler");
autoplugger->typefind = gst_element_factory_make("typefind","unnamed_type_find");
autoplugger->typefind_sinkpad = gst_element_get_pad(autoplugger->typefind,"sink");
g_signal_connect (G_OBJECT(autoplugger->typefind),"have_type",
G_CALLBACK (gst_autoplugger_type_find_have_type), autoplugger);
}
/* add it to self and attach it */
GST_DEBUG ("adding typefind to self and linking to cache");
gst_bin_add(GST_BIN(autoplugger),autoplugger->typefind);
gst_pad_link(autoplugger->cache_srcpad,autoplugger->typefind_sinkpad);
/* bring the typefind into playing state */
GST_DEBUG ("setting typefind state to PLAYING");
gst_element_set_state(autoplugger->cache,GST_STATE_PLAYING);
autoplugger->paused--;
if (autoplugger->paused == 0)
/* try to PLAY the whole thing */
gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PLAYING);
GST_INFO ("here we go into nothingness, hoping the typefind will return us to safety");
gst_scheduler_show(GST_ELEMENT_SCHED(autoplugger));
} else {
/* * attach the cache_empty handler, since the cache simply isn't needed *
* g_signal_connect (G_OBJECT(autoplugger->cache),"cache_empty",
* gst_autoplugger_cache_empty,autoplugger);
*/
}
}
static void
gst_autoplugger_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GstAutoplugger *autoplugger;
autoplugger = GST_AUTOPLUGGER (object);
switch (prop_id) {
default:
break;
}
}
static void
gst_autoplugger_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GstAutoplugger *autoplugger;
autoplugger = GST_AUTOPLUGGER (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
plugin_init (GstPlugin *plugin)
{
if (!gst_element_register (plugin, "autoplugger", GST_RANK_NONE, GST_TYPE_AUTOPLUGGER))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"autoplugger",
"magic element that converts from any type tom any other",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)

View file

@ -1,655 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gststaticautoplug.c: A static Autoplugger of pipelines
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gststaticautoplug.h"
#include <gst/gst.h>
#define GST_AUTOPLUG_MAX_COST 999999
GST_DEBUG_CATEGORY_STATIC(debug_category);
#define GST_CAT_DEFAULT debug_category
typedef guint (*GstAutoplugCostFunction) (gpointer src, gpointer dest, gpointer data);
typedef const GList* (*GstAutoplugListFunction) (gpointer data);
static void gst_static_autoplug_class_init (GstStaticAutoplugClass *klass);
static void gst_static_autoplug_init (GstStaticAutoplug *autoplug);
static GList* gst_autoplug_func (gpointer src, gpointer sink,
GstAutoplugListFunction list_function,
GstAutoplugCostFunction cost_function,
gpointer data);
static GstElement* gst_static_autoplug_to_caps (GstAutoplug *autoplug,
GstCaps *srccaps, GstCaps *sinkcaps, va_list args);
static GstAutoplugClass *parent_class = NULL;
GType gst_static_autoplug_get_type(void)
{
static GType static_autoplug_type = 0;
if (!static_autoplug_type) {
static const GTypeInfo static_autoplug_info = {
sizeof(GstElementClass),
NULL,
NULL,
(GClassInitFunc)gst_static_autoplug_class_init,
NULL,
NULL,
sizeof(GstElement),
0,
(GInstanceInitFunc)gst_static_autoplug_init,
};
static_autoplug_type = g_type_register_static (GST_TYPE_AUTOPLUG, "GstStaticAutoplug", &static_autoplug_info, 0);
}
return static_autoplug_type;
}
static void
gst_static_autoplug_class_init(GstStaticAutoplugClass *klass)
{
GstAutoplugClass *gstautoplug_class;
gstautoplug_class = (GstAutoplugClass*) klass;
parent_class = g_type_class_ref(GST_TYPE_AUTOPLUG);
gstautoplug_class->autoplug_to_caps = gst_static_autoplug_to_caps;
}
static void gst_static_autoplug_init(GstStaticAutoplug *autoplug) {
}
static gboolean
plugin_init (GstPlugin *plugin)
{
GstAutoplugFactory *factory;
GST_DEBUG_CATEGORY_INIT (debug_category, "STATIC_AUTOPLUG", 0, "static autoplugger element");
factory = gst_autoplug_factory_new ("static",
"A static autoplugger, it constructs the complete element before running it",
gst_static_autoplug_get_type ());
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
}
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gststaticautoplug",
"a static autoplugger",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)
static gboolean
gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
{
GList *srctemps, *desttemps;
srctemps = src->padtemplates;
while (srctemps) {
GstPadTemplate *srctemp = (GstPadTemplate *)srctemps->data;
desttemps = dest->padtemplates;
while (desttemps) {
GstPadTemplate *desttemp = (GstPadTemplate *)desttemps->data;
if (srctemp->direction == GST_PAD_SRC &&
desttemp->direction == GST_PAD_SINK) {
if (gst_caps_is_always_compatible (gst_pad_template_get_caps (srctemp),
gst_pad_template_get_caps (desttemp))) {
GST_DEBUG ("factory \"%s\" can link with factory \"%s\"\n", GST_OBJECT_NAME (src),
GST_OBJECT_NAME (dest));
return TRUE;
}
}
desttemps = g_list_next (desttemps);
}
srctemps = g_list_next (srctemps);
}
GST_DEBUG ("factory \"%s\" cannot link with factory \"%s\"\n", GST_OBJECT_NAME (src),
GST_OBJECT_NAME (dest));
return FALSE;
}
static gboolean
gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
{
const GList *sinkpads;
gboolean linked = FALSE;
GST_DEBUG ("gstpipeline: autoplug pad link function for \"%s\" to \"%s\"",
GST_ELEMENT_NAME(src), GST_ELEMENT_NAME(sink));
sinkpads = gst_element_get_pad_list(sink);
while (sinkpads) {
GstPad *sinkpad = (GstPad *)sinkpads->data;
/* if we have a match, link the pads */
if (gst_pad_get_direction(sinkpad) == GST_PAD_SINK &&
!GST_PAD_IS_LINKED(sinkpad))
{
if (gst_caps_is_always_compatible (gst_pad_get_caps(pad), gst_pad_get_caps(sinkpad))) {
gst_pad_link(pad, sinkpad);
GST_DEBUG ("gstpipeline: autolink pad \"%s\" in element %s <-> ", GST_PAD_NAME (pad),
GST_ELEMENT_NAME(src));
GST_DEBUG ("pad \"%s\" in element %s", GST_PAD_NAME (sinkpad),
GST_ELEMENT_NAME(sink));
linked = TRUE;
break;
}
else {
GST_DEBUG ("pads incompatible %s, %s", GST_PAD_NAME (pad), GST_PAD_NAME (sinkpad));
}
}
sinkpads = g_list_next(sinkpads);
}
if (!linked) {
GST_DEBUG ("gstpipeline: no path to sinks for type");
}
return linked;
}
typedef struct {
GstElement *result;
GstCaps *endcap;
gint i;
} dynamic_pad_struct;
static void
autoplug_dynamic_pad (GstElement *element, GstPad *pad, gpointer data)
{
dynamic_pad_struct *info = (dynamic_pad_struct *)data;
const GList *pads = gst_element_get_pad_list (element);
GST_DEBUG ("attempting to dynamically create a ghostpad for %s=%s", GST_ELEMENT_NAME (element),
GST_PAD_NAME (pad));
while (pads) {
GstPad *pad = GST_PAD (pads->data);
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
pads = g_list_next (pads);
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (templ), info->endcap)) {
gchar *name;
name = g_strdup_printf ("src_%02d", info->i);
gst_element_add_ghost_pad (info->result, pad, name);
g_free (name);
GST_DEBUG ("gstpipeline: new dynamic pad %s", GST_PAD_NAME (pad));
break;
}
}
}
static void
gst_autoplug_pads_autoplug (GstElement *src, GstElement *sink)
{
const GList *srcpads;
gboolean linked = FALSE;
srcpads = gst_element_get_pad_list(src);
while (srcpads && !linked) {
GstPad *srcpad = (GstPad *)srcpads->data;
if (gst_pad_get_direction(srcpad) == GST_PAD_SRC)
linked = gst_autoplug_pads_autoplug_func (src, srcpad, sink);
srcpads = g_list_next(srcpads);
}
if (!linked) {
GST_DEBUG ("gstpipeline: delaying pad links for \"%s\" to \"%s\"",
GST_ELEMENT_NAME(src), GST_ELEMENT_NAME(sink));
g_signal_connect (G_OBJECT(src), "new_pad",
G_CALLBACK (gst_autoplug_pads_autoplug_func), sink);
}
}
static const GList*
gst_autoplug_element_factory_get_list (gpointer data)
{
return gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY);
}
typedef struct {
GstCaps *src;
GstCaps *sink;
} caps_struct;
#define IS_CAPS(cap) (((cap) == caps->src) || (cap) == caps->sink)
static guint
gst_autoplug_caps_find_cost (gpointer src, gpointer dest, gpointer data)
{
caps_struct *caps = (caps_struct *)data;
gboolean res;
if (IS_CAPS (src) && IS_CAPS (dest)) {
res = gst_caps_is_always_compatible ((GstCaps *)src, (GstCaps *)dest);
}
else if (IS_CAPS (src)) {
res = gst_element_factory_can_sink_caps ((GstElementFactory *)dest, (GstCaps *)src);
}
else if (IS_CAPS (dest)) {
res = gst_element_factory_can_src_caps ((GstElementFactory *)src, (GstCaps *)dest);
}
else {
res = gst_autoplug_can_match ((GstElementFactory *)src, (GstElementFactory *)dest);
}
if (res)
return 1;
else
return GST_AUTOPLUG_MAX_COST;
}
static GstElement*
gst_static_autoplug_to_caps (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *sinkcaps, va_list args)
{
caps_struct caps;
GstCaps *capslist;
GstElement *result = NULL, *srcelement = NULL;
GList **factories;
GList *chains = NULL;
GList *endcaps = NULL;
guint numsinks = 0, i;
gboolean have_common = FALSE;
capslist = sinkcaps;
/*
* We first create a list of elements that are needed
* to convert the srcpad caps to the different sinkpad caps.
* and add the list of elementfactories to a list (chains).
*/
caps.src = srccaps;
while (capslist) {
GList *elements;
caps.sink = capslist;
GST_INFO ("autoplugging two caps structures");
elements = gst_autoplug_func (caps.src, caps.sink,
gst_autoplug_element_factory_get_list,
gst_autoplug_caps_find_cost,
&caps);
if (elements) {
chains = g_list_append (chains, elements);
endcaps = g_list_append (endcaps, capslist);
numsinks++;
}
else {
}
capslist = va_arg (args, GstCaps *);
}
/*
* If no list could be found the pipeline cannot be autoplugged and
* we return a NULL element
*/
if (numsinks == 0)
return NULL;
/*
* We now have a list of lists. We will turn this into an array
* of lists, this will make it much more easy to manipulate it
* in the next steps.
*/
factories = g_new0 (GList *, numsinks);
for (i = 0; chains; i++) {
GList *elements = (GList *) chains->data;
factories[i] = elements;
chains = g_list_next (chains);
}
/*FIXME, free the list */
result = gst_bin_new ("autoplug_bin");
/*
* We now hav a list of lists that is probably like:
*
* !
* A -> B -> C
* !
* A -> D -> E
*
* we now try to find the common elements (A) and add them to
* the bin. We remove them from both lists too.
*/
while (factories[0]) {
GstElementFactory *factory;
GstElement *element;
gchar *name;
/* fase 3: add common elements */
factory = (GstElementFactory *) (factories[0]->data);
/* check to other paths for matching elements (factories) */
for (i=1; i<numsinks; i++) {
if (factory != (GstElementFactory *) (factories[i]->data)) {
goto differ;
}
}
GST_DEBUG ("common factory \"%s\"", GST_OBJECT_NAME (factory));
/* it is likely that the plugin is not loaded yet. thus when it loads it
* will replace the elementfactory that gst built from the cache, and the
* GST_OBJECT_NAME will no longer be valid. thus we must g_strdup its name.
*
* this might be an implementation problem, i don't know, if a program keeps
* a reference to a cached factory after a factory has been added on plugin
* initialization. i raelly don't know though.
*/
name = g_strdup (GST_OBJECT_NAME (factory));
element = gst_element_factory_create (factory, name);
g_free(name);
gst_bin_add (GST_BIN(result), element);
if (srcelement != NULL) {
gst_autoplug_pads_autoplug (srcelement, element);
}
/* this is the first element, find a good ghostpad */
else {
const GList *pads;
pads = gst_element_get_pad_list (element);
while (pads) {
GstPad *pad = GST_PAD (pads->data);
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
if (gst_caps_is_always_compatible (srccaps, GST_PAD_TEMPLATE_CAPS (templ))) {
gst_element_add_ghost_pad (result, pad, "sink");
break;
}
pads = g_list_next (pads);
}
}
gst_autoplug_signal_new_object (GST_AUTOPLUG (autoplug), GST_OBJECT (element));
srcelement = element;
/* advance the pointer in all lists */
for (i=0; i<numsinks; i++) {
factories[i] = g_list_next (factories[i]);
}
have_common = TRUE;
}
differ:
/* loop over all the sink elements */
for (i = 0; i < numsinks; i++) {
GstElement *thesrcelement = srcelement;
GstElement *thebin = GST_ELEMENT(result);
while (factories[i]) {
/* fase 4: add other elements... */
GstElementFactory *factory;
GstElement *element;
factory = (GstElementFactory *)(factories[i]->data);
GST_DEBUG ("factory \"%s\"", GST_OBJECT_NAME (factory));
element = gst_element_factory_create(factory, GST_OBJECT_NAME (factory));
GST_DEBUG ("adding element %s", GST_ELEMENT_NAME (element));
gst_bin_add(GST_BIN(thebin), element);
gst_autoplug_signal_new_object (GST_AUTOPLUG (autoplug), GST_OBJECT (element));
gst_autoplug_pads_autoplug(thesrcelement, element);
/* this element is now the new source element */
thesrcelement = element;
factories[i] = g_list_next(factories[i]);
}
/*
* we're at the last element in the chain,
* find a suitable pad to turn into a ghostpad
*/
{
GstCaps *endcap = (GstCaps *)(endcaps->data);
const GList *pads = gst_element_get_pad_list (thesrcelement);
gboolean have_pad = FALSE;
endcaps = g_list_next (endcaps);
GST_DEBUG ("attempting to create a ghostpad for %s", GST_ELEMENT_NAME (thesrcelement));
while (pads) {
GstPad *pad = GST_PAD (pads->data);
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
pads = g_list_next (pads);
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (templ), endcap)) {
gchar *name;
name = g_strdup_printf ("src_%02d", i);
gst_element_add_ghost_pad (result, pad, name);
g_free (name);
have_pad = TRUE;
break;
}
}
if (!have_pad) {
dynamic_pad_struct *data = g_new0(dynamic_pad_struct, 1);
data->result = result;
data->endcap = endcap;
data->i = i;
GST_DEBUG ("delaying the creation of a ghostpad for %s", GST_ELEMENT_NAME (thesrcelement));
g_signal_connect (G_OBJECT (thesrcelement), "new_pad",
G_CALLBACK (autoplug_dynamic_pad), data);
}
}
}
return result;
}
/*
* shortest path algorithm
*
*/
struct _gst_autoplug_node
{
gpointer iNode;
gpointer iPrev;
gint iDist;
};
typedef struct _gst_autoplug_node gst_autoplug_node;
static gint
find_factory (gst_autoplug_node *rgnNodes, gpointer factory)
{
gint i=0;
while (rgnNodes[i].iNode) {
if (rgnNodes[i].iNode == factory) return i;
i++;
}
return 0;
}
static GList*
construct_path (gst_autoplug_node *rgnNodes, gpointer factory)
{
GstElementFactory *current;
GList *factories = NULL;
current = rgnNodes[find_factory(rgnNodes, factory)].iPrev;
GST_INFO ("factories found in autoplugging (reversed order)");
while (current != NULL)
{
gpointer next = NULL;
next = rgnNodes[find_factory(rgnNodes, current)].iPrev;
if (next) {
factories = g_list_prepend (factories, current);
GST_INFO ("factory: \"%s\"", GST_OBJECT_NAME (current));
}
current = next;
}
return factories;
}
static GList*
gst_autoplug_enqueue (GList *queue, gpointer iNode, gint iDist, gpointer iPrev)
{
gst_autoplug_node *node = g_malloc (sizeof (gst_autoplug_node));
node->iNode = iNode;
node->iDist = iDist;
node->iPrev = iPrev;
queue = g_list_append (queue, node);
return queue;
}
static GList*
gst_autoplug_dequeue (GList *queue, gpointer *iNode, gint *iDist, gpointer *iPrev)
{
GList *head;
gst_autoplug_node *node;
head = g_list_first (queue);
if (head) {
node = (gst_autoplug_node *)head->data;
*iNode = node->iNode;
*iPrev = node->iPrev;
*iDist = node->iDist;
head = g_list_remove (queue, node);
}
return head;
}
static GList*
gst_autoplug_func (gpointer src, gpointer sink,
GstAutoplugListFunction list_function,
GstAutoplugCostFunction cost_function,
gpointer data)
{
gst_autoplug_node *rgnNodes;
GList *queue = NULL;
gpointer iNode, iPrev;
gint iDist, i, iCost;
GList *elements = g_list_copy ((GList *)list_function(data));
GList *factories;
guint num_factories;
elements = g_list_append (elements, sink);
elements = g_list_append (elements, src);
factories = elements;
num_factories = g_list_length (factories);
rgnNodes = g_new0 (gst_autoplug_node, num_factories+1);
for (i=0; i< num_factories; i++) {
gpointer fact = factories->data;
rgnNodes[i].iNode = fact;
rgnNodes[i].iPrev = NULL;
if (fact == src) {
rgnNodes[i].iDist = 0;
}
else {
rgnNodes[i].iDist = GST_AUTOPLUG_MAX_COST;
}
factories = g_list_next (factories);
}
rgnNodes[num_factories].iNode = NULL;
queue = gst_autoplug_enqueue (queue, src, 0, NULL);
while (g_list_length (queue) > 0) {
GList *factories2 = elements;
queue = gst_autoplug_dequeue (queue, &iNode, &iDist, &iPrev);
for (i=0; i< num_factories; i++) {
gpointer current = factories2->data;
iCost = cost_function (iNode, current, data);
if (iCost != GST_AUTOPLUG_MAX_COST) {
if ((GST_AUTOPLUG_MAX_COST == rgnNodes[i].iDist) ||
(rgnNodes[i].iDist > (iCost + iDist))) {
rgnNodes[i].iDist = iDist + iCost;
rgnNodes[i].iPrev = iNode;
queue = gst_autoplug_enqueue (queue, current, iDist + iCost, iNode);
}
}
factories2 = g_list_next (factories2);
}
}
return construct_path (rgnNodes, sink);
}

View file

@ -1,59 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstautoplug.h: Header for autoplugging functionality
*
* 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.
*/
#ifndef __GST_STATIC_AUTOPLUG_H__
#define __GST_STATIC_AUTOPLUG_H__
#include <gst/gstautoplug.h>
G_BEGIN_DECLS
#define GST_TYPE_STATIC_AUTOPLUG \
(gst_static_autoplug_get_type())
#define GST_STATIC_AUTOPLUG(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_STATIC_AUTOPLUG,GstStaticAutoplug))
#define GST_STATIC_AUTOPLUG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_STATIC_AUTOPLUG,GstStaticAutoplugClass))
#define GST_IS_STATIC_AUTOPLUG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_STATIC_AUTOPLUG))
#define GST_IS_STATIC_AUTOPLUG_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_STATIC_AUTOPLUG))
typedef struct _GstStaticAutoplug GstStaticAutoplug;
typedef struct _GstStaticAutoplugClass GstStaticAutoplugClass;
struct _GstStaticAutoplug {
GstAutoplug object;
};
struct _GstStaticAutoplugClass {
GstAutoplugClass parent_class;
};
GType gst_static_autoplug_get_type (void);
G_END_DECLS
#endif /* __GST_STATIC_AUTOPLUG_H__ */

View file

@ -1,673 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gststaticautoplug.c: A static Autoplugger of pipelines
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gststaticautoplugrender.h"
#include <gst/gst.h>
#define GST_AUTOPLUG_MAX_COST 999999
GST_DEBUG_CATEGORY_STATIC(debug_category);
#define GST_CAT_DEFAULT debug_category
typedef guint (*GstAutoplugCostFunction) (gpointer src, gpointer dest, gpointer data);
typedef GList* (*GstAutoplugListFunction) (gpointer data);
static void gst_static_autoplug_render_class_init (GstStaticAutoplugRenderClass *klass);
static void gst_static_autoplug_render_init (GstStaticAutoplugRender *autoplug);
static GList* gst_autoplug_func (gpointer src, gpointer sink,
GstAutoplugListFunction list_function,
GstAutoplugCostFunction cost_function,
gpointer data);
static GstElement* gst_static_autoplug_to_render (GstAutoplug *autoplug,
GstCaps *srccaps, GstElement *target, va_list args);
static GstAutoplugClass *parent_class = NULL;
GType gst_static_autoplug_render_get_type(void)
{
static GType static_autoplug_type = 0;
if (!static_autoplug_type) {
static const GTypeInfo static_autoplug_info = {
sizeof(GstElementClass),
NULL,
NULL,
(GClassInitFunc)gst_static_autoplug_render_class_init,
NULL,
NULL,
sizeof(GstElement),
0,
(GInstanceInitFunc)gst_static_autoplug_render_init,
};
static_autoplug_type = g_type_register_static (GST_TYPE_AUTOPLUG, "GstStaticAutoplugRender", &static_autoplug_info, 0);
}
return static_autoplug_type;
}
static void
gst_static_autoplug_render_class_init(GstStaticAutoplugRenderClass *klass)
{
GstAutoplugClass *gstautoplug_class;
gstautoplug_class = (GstAutoplugClass*) klass;
parent_class = g_type_class_ref(GST_TYPE_AUTOPLUG);
gstautoplug_class->autoplug_to_renderers = gst_static_autoplug_to_render;
}
static void gst_static_autoplug_render_init(GstStaticAutoplugRender *autoplug) {
}
static gboolean
plugin_init (GstPlugin *plugin)
{
GstAutoplugFactory *factory;
GST_DEBUG_CATEGORY_INIT (debug_category, "STATIC_AUTOPLUG", 0, "static autoplug render element");
factory = gst_autoplug_factory_new ("staticrender",
"A static autoplugger, it constructs the complete element before running it",
gst_static_autoplug_render_get_type ());
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
}
else {
g_warning ("could not register autoplugger: staticrender");
}
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gststaticautoplugrender",
"a static autoplugger",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)
static GstPadTemplate*
gst_autoplug_match_caps (GstElementFactory *factory, GstPadDirection direction, GstCaps *caps)
{
GList *templates;
templates = factory->padtemplates;
while (templates) {
GstPadTemplate *template = (GstPadTemplate *)templates->data;
if (template->direction == direction && direction == GST_PAD_SRC) {
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), caps))
return template;
}
else if (template->direction == direction && direction == GST_PAD_SINK) {
if (gst_caps_is_always_compatible (caps, GST_PAD_TEMPLATE_CAPS (template)))
return template;
}
templates = g_list_next (templates);
}
return NULL;
}
static gboolean
gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
{
GList *srctemps, *desttemps;
srctemps = src->padtemplates;
while (srctemps) {
GstPadTemplate *srctemp = (GstPadTemplate *)srctemps->data;
srctemps = g_list_next (srctemps);
if (srctemp->direction != GST_PAD_SRC)
continue;
desttemps = dest->padtemplates;
while (desttemps) {
GstPadTemplate *desttemp = (GstPadTemplate *)desttemps->data;
desttemps = g_list_next (desttemps);
if (desttemp->direction == GST_PAD_SINK && desttemp->presence != GST_PAD_REQUEST) {
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (srctemp), GST_PAD_TEMPLATE_CAPS (desttemp))) {
GST_DEBUG ("factory \"%s\" can link with factory \"%s\"",
GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
return TRUE;
}
}
}
}
GST_DEBUG ("factory \"%s\" cannot link with factory \"%s\"",
GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
return FALSE;
}
static gboolean
gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
{
const GList *sinkpads;
gboolean linked = FALSE;
GstElementState state = GST_STATE (gst_element_get_parent (src));
GST_DEBUG ("gstpipeline: autoplug pad link function for %s %s:%s to \"%s\"",
GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME(pad), GST_ELEMENT_NAME(sink));
if (state == GST_STATE_PLAYING)
gst_element_set_state (GST_ELEMENT (gst_element_get_parent (src)), GST_STATE_PAUSED);
sinkpads = gst_element_get_pad_list(sink);
while (sinkpads) {
GstPad *sinkpad = (GstPad *)sinkpads->data;
/* if we have a match, link the pads */
if (gst_pad_get_direction(sinkpad) == GST_PAD_SINK &&
!GST_PAD_IS_LINKED (pad) && !GST_PAD_IS_LINKED(sinkpad))
{
if ((linked = gst_pad_link (pad, sinkpad))) {
break;
}
else {
GST_DEBUG ("pads incompatible %s, %s", GST_PAD_NAME (pad), GST_PAD_NAME (sinkpad));
}
}
sinkpads = g_list_next(sinkpads);
}
if (state == GST_STATE_PLAYING)
gst_element_set_state (GST_ELEMENT (gst_element_get_parent (src)), GST_STATE_PLAYING);
if (!linked) {
GST_DEBUG ("gstpipeline: no path to sinks for type");
}
return linked;
}
static void
gst_autoplug_pads_autoplug (GstElement *src, GstElement *sink)
{
const GList *srcpads;
gboolean linked = FALSE;
srcpads = gst_element_get_pad_list(src);
while (srcpads && !linked) {
GstPad *srcpad = (GstPad *)srcpads->data;
if (gst_pad_get_direction(srcpad) == GST_PAD_SRC) {
linked = gst_autoplug_pads_autoplug_func (src, srcpad, sink);
if (linked)
break;
}
srcpads = g_list_next(srcpads);
}
if (!linked) {
GST_DEBUG ("gstpipeline: delaying pad links for \"%s\" to \"%s\"",
GST_ELEMENT_NAME(src), GST_ELEMENT_NAME(sink));
g_signal_connect (G_OBJECT(src),"new_pad",
G_CALLBACK (gst_autoplug_pads_autoplug_func), sink);
}
}
static GList*
gst_autoplug_element_factory_get_list (gpointer data)
{
return (GList *) gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY);
}
typedef struct {
GstCaps *src;
GstCaps *sink;
} caps_struct;
#define IS_CAPS(cap) (((cap) == caps->src) || (cap) == caps->sink)
static guint
gst_autoplug_caps_find_cost (gpointer src, gpointer dest, gpointer data)
{
caps_struct *caps = (caps_struct *)data;
gboolean res;
if (IS_CAPS (src) && IS_CAPS (dest)) {
res = gst_caps_is_always_compatible ((GstCaps *)src, (GstCaps *)dest);
}
else if (IS_CAPS (src)) {
GstPadTemplate *templ;
templ = gst_autoplug_match_caps ((GstElementFactory *)dest, GST_PAD_SINK, (GstCaps *)src);
if (templ && templ->presence != GST_PAD_REQUEST)
res = TRUE;
else
res = FALSE;
}
else if (IS_CAPS (dest)) {
GstPadTemplate *templ;
templ = gst_autoplug_match_caps ((GstElementFactory *)src, GST_PAD_SRC, (GstCaps *)dest);
if (templ && templ->presence != GST_PAD_REQUEST)
res = TRUE;
else
res = FALSE;
}
else {
res = gst_autoplug_can_match ((GstElementFactory *)src, (GstElementFactory *)dest);
GST_INFO ("factory %s to factory %s %d", GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest), res);
}
if (res)
return 1;
else
return GST_AUTOPLUG_MAX_COST;
}
static GstElement*
gst_static_autoplug_to_render (GstAutoplug *autoplug, GstCaps *srccaps, GstElement *target, va_list args)
{
caps_struct caps;
GstElement *targetelement;
GstElement *result = NULL, *srcelement = NULL;
GList **factories;
GList *chains = NULL;
GList *endelements = NULL;
guint numsinks = 0, i;
gboolean have_common = FALSE;
targetelement = target;
/*
* We first create a list of elements that are needed
* to convert the srcpad caps to the different sinkpad caps.
* and add the list of elementfactories to a list (chains).
*/
caps.src = srccaps;
while (targetelement) {
GList *elements;
GstRealPad *pad;
GstPadTemplate *templ;
pad = GST_PAD_REALIZE (gst_element_get_pad_list (targetelement)->data);
templ = GST_PAD_PAD_TEMPLATE (pad);
if (templ)
caps.sink = GST_PAD_TEMPLATE_CAPS (templ);
else
goto next;
GST_INFO ("autoplugging two caps structures");
elements = gst_autoplug_func (caps.src, caps.sink,
gst_autoplug_element_factory_get_list,
gst_autoplug_caps_find_cost,
&caps);
if (elements) {
chains = g_list_append (chains, elements);
endelements = g_list_append (endelements, targetelement);
numsinks++;
}
else {
}
next:
targetelement = va_arg (args, GstElement *);
}
/*
* If no list could be found the pipeline cannot be autoplugged and
* we return a NULL element
*/
if (numsinks == 0)
return NULL;
/*
* We now have a list of lists. We will turn this into an array
* of lists, this will make it much more easy to manipulate it
* in the next steps.
*/
factories = g_new0 (GList *, numsinks);
for (i = 0; chains; i++) {
GList *elements = (GList *) chains->data;
factories[i] = elements;
chains = g_list_next (chains);
}
/*FIXME, free the list */
result = gst_bin_new ("autoplug_bin");
/*
* We now hav a list of lists that is probably like:
*
* !
* A -> B -> C
* !
* A -> D -> E
*
* we now try to find the common elements (A) and add them to
* the bin. We remove them from both lists too.
*/
while (factories[0]) {
GstElementFactory *factory;
GstElement *element;
/* fase 3: add common elements */
factory = (GstElementFactory *) (factories[0]->data);
/* check to other paths for matching elements (factories) */
for (i=1; i<numsinks; i++) {
if (factory != (GstElementFactory *) (factories[i]->data)) {
goto differ;
}
}
GST_DEBUG ("common factory \"%s\"", GST_OBJECT_NAME (factory));
element = gst_element_factory_create (factory, g_strdup (GST_OBJECT_NAME (factory)));
gst_bin_add (GST_BIN(result), element);
if (srcelement != NULL) {
gst_autoplug_pads_autoplug (srcelement, element);
}
/* this is the first element, find a good ghostpad */
else {
const GList *pads;
pads = gst_element_get_pad_list (element);
while (pads) {
GstPad *pad = GST_PAD (pads->data);
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
if (gst_caps_is_always_compatible (srccaps, GST_PAD_TEMPLATE_CAPS (templ))) {
gst_element_add_ghost_pad (result, pad, "sink");
break;
}
pads = g_list_next (pads);
}
}
gst_autoplug_signal_new_object (GST_AUTOPLUG (autoplug), GST_OBJECT (element));
srcelement = element;
/* advance the pointer in all lists */
for (i=0; i<numsinks; i++) {
factories[i] = g_list_next (factories[i]);
}
have_common = TRUE;
}
differ:
/* loop over all the sink elements */
for (i = 0; i < numsinks; i++) {
GstElement *thesrcelement = srcelement;
GstElement *thebin = GST_ELEMENT(result);
GstElement *sinkelement;
gboolean use_thread;
sinkelement = GST_ELEMENT (endelements->data);
endelements = g_list_next (endelements);
use_thread = have_common;
while (factories[i] || sinkelement) {
/* fase 4: add other elements... */
GstElementFactory *factory;
GstElement *element;
if (factories[i]) {
factory = (GstElementFactory *)(factories[i]->data);
GST_DEBUG ("factory \"%s\"", GST_OBJECT_NAME (factory));
element = gst_element_factory_create(factory, g_strdup (GST_OBJECT_NAME (factory)));
}
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) || use_thread) {
GstElement *queue;
GstPad *srcpad;
GstElement *current_bin = thebin;
use_thread = FALSE;
GST_DEBUG ("sugest new thread for \"%s\" %08x", GST_ELEMENT_NAME (element), GST_FLAGS(element));
/* create a new queue and add to the previous bin */
queue = gst_element_factory_make("queue", g_strconcat("queue_", GST_ELEMENT_NAME(element), NULL));
GST_DEBUG ("adding element \"%s\"", GST_ELEMENT_NAME (element));
/* this will be the new bin for all following elements */
thebin = gst_element_factory_make("thread", g_strconcat("thread_", GST_ELEMENT_NAME(element), NULL));
gst_bin_add(GST_BIN(thebin), queue);
gst_autoplug_signal_new_object (GST_AUTOPLUG (autoplug), GST_OBJECT (queue));
srcpad = gst_element_get_pad(queue, "src");
gst_autoplug_pads_autoplug(thesrcelement, queue);
GST_DEBUG ("adding element %s", GST_ELEMENT_NAME (element));
gst_bin_add(GST_BIN(thebin), element);
gst_autoplug_signal_new_object (GST_AUTOPLUG (autoplug), GST_OBJECT (element));
GST_DEBUG ("adding element %s", GST_ELEMENT_NAME (thebin));
gst_bin_add(GST_BIN(current_bin), thebin);
gst_autoplug_signal_new_object (GST_AUTOPLUG (autoplug), GST_OBJECT (thebin));
thesrcelement = queue;
}
/* no thread needed, easy case */
else {
GST_DEBUG ("adding element %s", GST_ELEMENT_NAME (element));
gst_bin_add(GST_BIN(thebin), element);
gst_autoplug_signal_new_object (GST_AUTOPLUG (autoplug), GST_OBJECT (element));
}
gst_autoplug_pads_autoplug(thesrcelement, element);
/* this element is now the new source element */
thesrcelement = element;
factories[i] = g_list_next(factories[i]);
}
}
return result;
}
/*
* shortest path algorithm
*
*/
struct _gst_autoplug_node
{
gpointer iNode;
gpointer iPrev;
gint iDist;
};
typedef struct _gst_autoplug_node gst_autoplug_node;
static gint
find_factory (gst_autoplug_node *rgnNodes, gpointer factory)
{
gint i=0;
while (rgnNodes[i].iNode) {
if (rgnNodes[i].iNode == factory) return i;
i++;
}
return 0;
}
static GList*
construct_path (gst_autoplug_node *rgnNodes, gpointer factory)
{
GstElementFactory *current;
GList *factories = NULL;
current = rgnNodes[find_factory(rgnNodes, factory)].iPrev;
GST_INFO ("factories found in autoplugging (reversed order)");
while (current != NULL)
{
gpointer next = NULL;
next = rgnNodes[find_factory(rgnNodes, current)].iPrev;
if (next) {
factories = g_list_prepend (factories, current);
GST_INFO ("factory: \"%s\"", GST_OBJECT_NAME (current));
}
current = next;
}
return factories;
}
static GList*
gst_autoplug_enqueue (GList *queue, gpointer iNode, gint iDist, gpointer iPrev)
{
gst_autoplug_node *node = g_malloc (sizeof (gst_autoplug_node));
node->iNode = iNode;
node->iDist = iDist;
node->iPrev = iPrev;
queue = g_list_append (queue, node);
return queue;
}
static GList*
gst_autoplug_dequeue (GList *queue, gpointer *iNode, gint *iDist, gpointer *iPrev)
{
GList *head;
gst_autoplug_node *node;
head = g_list_first (queue);
if (head) {
node = (gst_autoplug_node *)head->data;
*iNode = node->iNode;
*iPrev = node->iPrev;
*iDist = node->iDist;
head = g_list_remove (queue, node);
}
return head;
}
static GList*
gst_autoplug_func (gpointer src, gpointer sink,
GstAutoplugListFunction list_function,
GstAutoplugCostFunction cost_function,
gpointer data)
{
gst_autoplug_node *rgnNodes;
GList *queue = NULL;
gpointer iNode, iPrev;
gint iDist, i, iCost;
GList *elements = g_list_copy (list_function(data));
GList *factories;
guint num_factories;
elements = g_list_append (elements, sink);
elements = g_list_append (elements, src);
factories = elements;
num_factories = g_list_length (factories);
rgnNodes = g_new0 (gst_autoplug_node, num_factories+1);
for (i=0; i< num_factories; i++) {
gpointer fact = factories->data;
rgnNodes[i].iNode = fact;
rgnNodes[i].iPrev = NULL;
if (fact == src) {
rgnNodes[i].iDist = 0;
}
else {
rgnNodes[i].iDist = GST_AUTOPLUG_MAX_COST;
}
factories = g_list_next (factories);
}
rgnNodes[num_factories].iNode = NULL;
queue = gst_autoplug_enqueue (queue, src, 0, NULL);
while (g_list_length (queue) > 0) {
GList *factories2 = elements;
queue = gst_autoplug_dequeue (queue, &iNode, &iDist, &iPrev);
for (i=0; i< num_factories; i++) {
gpointer current = factories2->data;
iCost = cost_function (iNode, current, data);
if (iCost != GST_AUTOPLUG_MAX_COST) {
if ((GST_AUTOPLUG_MAX_COST == rgnNodes[i].iDist) ||
(rgnNodes[i].iDist > (iCost + iDist))) {
rgnNodes[i].iDist = iDist + iCost;
rgnNodes[i].iPrev = iNode;
queue = gst_autoplug_enqueue (queue, current, iDist + iCost, iNode);
}
}
factories2 = g_list_next (factories2);
}
}
return construct_path (rgnNodes, sink);
}

View file

@ -1,59 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstautoplug.h: Header for autoplugging functionality
*
* 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.
*/
#ifndef __GST_STATIC_AUTOPLUG_RENDER_H__
#define __GST_STATIC_AUTOPLUG_RENDER_H__
#include <gst/gstautoplug.h>
G_BEGIN_DECLS
#define GST_TYPE_STATIC_AUTOPLUG_RENDER \
(gst_static_autoplug_render_get_type())
#define GST_STATIC_AUTOPLUG_RENDER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_STATIC_AUTOPLUG_RENDER,GstStaticAutoplugRender))
#define GST_STATIC_AUTOPLUG_RENDER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_STATIC_AUTOPLUG_RENDER,GstStaticAutoplugRenderClass))
#define GST_IS_STATIC_AUTOPLUG_RENDER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_STATIC_AUTOPLUG_RENDER))
#define GST_IS_STATIC_AUTOPLUG_RENDER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_STATIC_AUTOPLUG_RENDER))
typedef struct _GstStaticAutoplugRender GstStaticAutoplugRender;
typedef struct _GstStaticAutoplugRenderClass GstStaticAutoplugRenderClass;
struct _GstStaticAutoplugRender {
GstAutoplug object;
};
struct _GstStaticAutoplugRenderClass {
GstAutoplugClass parent_class;
};
GType gst_static_autoplug_render_get_type (void);
G_END_DECLS
#endif /* __GST_STATIC_AUTOPLUG_H__ */

View file

@ -1,385 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstautoplug.c: Autoplugging of pipelines
*
* 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_private.h"
#include <gst/gstconfig.h>
#include "gstautoplug.h"
#include "gstregistrypool.h"
#include "gstinfo.h"
enum {
NEW_OBJECT,
LAST_SIGNAL
};
enum {
ARG_0,
/* FILL ME */
};
static void gst_autoplug_class_init (GstAutoplugClass *klass);
static void gst_autoplug_init (GstAutoplug *autoplug);
static GstObjectClass *parent_class = NULL;
static guint gst_autoplug_signals[LAST_SIGNAL] = { 0 };
GType gst_autoplug_get_type(void)
{
static GType autoplug_type = 0;
if (!autoplug_type) {
static const GTypeInfo autoplug_info = {
sizeof(GstAutoplugClass),
NULL,
NULL,
(GClassInitFunc)gst_autoplug_class_init,
NULL,
NULL,
sizeof(GstAutoplug),
4,
(GInstanceInitFunc)gst_autoplug_init,
NULL
};
autoplug_type = g_type_register_static (GST_TYPE_OBJECT, "GstAutoplug", &autoplug_info, G_TYPE_FLAG_ABSTRACT);
}
return autoplug_type;
}
static void
gst_autoplug_class_init(GstAutoplugClass *klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
gobject_class = (GObjectClass*) klass;
gstobject_class = (GstObjectClass*) klass;
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
gst_autoplug_signals[NEW_OBJECT] =
g_signal_new ("new_object", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstAutoplugClass, new_object), NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_OBJECT);
}
static void gst_autoplug_init(GstAutoplug *autoplug)
{
}
/**
* gst_autoplug_signal_new_object:
* @autoplug: The autoplugger to emit the signal
* @object: The object that is passed to the signal
*
* Emit a new_object signal. autopluggers are supposed to
* emit this signal whenever a new object has been added to
* the autoplugged pipeline.
*
*/
void
gst_autoplug_signal_new_object (GstAutoplug *autoplug, GstObject *object)
{
g_signal_emit (G_OBJECT (autoplug), gst_autoplug_signals[NEW_OBJECT], 0, object);
}
/**
* gst_autoplug_to_caps:
* @autoplug: The autoplugger performing the autoplugging.
* @srccaps: The source capabilities.
* @sinkcaps: The target capabilities.
* @...: more target capabilities.
*
* Perform the autoplugging procedure on the given autoplugger.
* The src caps will be connected to the sink caps.
*
* Returns: A new #GstElement that connects the src caps to the sink caps.
*/
GstElement*
gst_autoplug_to_caps (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *sinkcaps, ...)
{
GstAutoplugClass *oclass;
GstElement *element = NULL;
va_list args;
va_start (args, sinkcaps);
oclass = GST_AUTOPLUG_CLASS (G_OBJECT_GET_CLASS(autoplug));
if (oclass->autoplug_to_caps)
element = (oclass->autoplug_to_caps) (autoplug, srccaps, sinkcaps, args);
va_end (args);
return element;
}
/**
* gst_autoplug_to_caps_valist:
* @autoplug: The autoplugger performing the autoplugging.
* @srccaps: The source capabilities.
* @sinkcaps: The target capabilities.
* @va_list: more target capabilities.
*
* Perform the autoplugging procedure on the given autoplugger.
* The src caps will be connected to the sink caps.
*
* Returns: A new #GstElement that connects the src caps to the sink caps.
*/
GstElement*
gst_autoplug_to_caps_valist (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *sinkcaps, va_list args)
{
GstAutoplugClass *oclass;
GstElement *element = NULL;
oclass = GST_AUTOPLUG_CLASS (G_OBJECT_GET_CLASS(autoplug));
if (oclass->autoplug_to_caps)
element = (oclass->autoplug_to_caps) (autoplug, srccaps, sinkcaps, args);
return element;
}
/**
* gst_autoplug_to_renderers:
* @autoplug: The autoplugger performing the autoplugging.
* @srccaps: The source capabilities.
* @target: The target element.
* @...: more target elements.
*
* Perform the autoplugging procedure on the given autoplugger.
* The src caps will be connected to the target elements.
*
* Returns: A new #GstElement that connects the src caps to the target elements.
*/
GstElement*
gst_autoplug_to_renderers (GstAutoplug *autoplug, GstCaps *srccaps, GstElement *target, ...)
{
GstAutoplugClass *oclass;
GstElement *element = NULL;
va_list args;
va_start (args, target);
oclass = GST_AUTOPLUG_CLASS (G_OBJECT_GET_CLASS(autoplug));
if (oclass->autoplug_to_renderers)
element = (oclass->autoplug_to_renderers) (autoplug, srccaps, target, args);
va_end (args);
return element;
}
/**
* gst_autoplug_to_renderers_valist:
* @autoplug: The autoplugger performing the autoplugging.
* @srccaps: The source capabilities.
* @target: The target element.
* @va_list: more target elements.
*
* Perform the autoplugging procedure on the given autoplugger.
* The src caps will be connected to the target elements.
*
* Returns: A new #GstElement that connects the src caps to the target elements.
*/
GstElement*
gst_autoplug_to_renderers_valist (GstAutoplug *autoplug, GstCaps *srccaps, GstElement *target, va_list args)
{
GstAutoplugClass *oclass;
GstElement *element = NULL;
oclass = GST_AUTOPLUG_CLASS (G_OBJECT_GET_CLASS(autoplug));
if (oclass->autoplug_to_renderers)
element = (oclass->autoplug_to_renderers) (autoplug, srccaps, target, args);
return element;
}
static void gst_autoplug_factory_class_init (GstAutoplugFactoryClass *klass);
static void gst_autoplug_factory_init (GstAutoplugFactory *factory);
static GstPluginFeatureClass *factory_parent_class = NULL;
/* static guint gst_autoplug_factory_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_autoplug_factory_get_type (void)
{
static GType autoplugfactory_type = 0;
if (!autoplugfactory_type) {
static const GTypeInfo autoplugfactory_info = {
sizeof (GstAutoplugFactoryClass),
NULL,
NULL,
(GClassInitFunc) gst_autoplug_factory_class_init,
NULL,
NULL,
sizeof(GstAutoplugFactory),
0,
(GInstanceInitFunc) gst_autoplug_factory_init,
NULL
};
autoplugfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstAutoplugFactory", &autoplugfactory_info, 0);
}
return autoplugfactory_type;
}
static void
gst_autoplug_factory_class_init (GstAutoplugFactoryClass *klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstPluginFeatureClass *gstpluginfeature_class;
gobject_class = (GObjectClass*)klass;
gstobject_class = (GstObjectClass*)klass;
gstpluginfeature_class = (GstPluginFeatureClass*) klass;
factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE);
}
static void
gst_autoplug_factory_init (GstAutoplugFactory *factory)
{
}
/**
* gst_autoplug_factory_new:
* @name: name of autoplugfactory to create
* @longdesc: long description of autoplugfactory to create
* @type: the gtk type of the GstAutoplug element of this factory
*
* Create a new autoplugfactory with the given parameters
*
* Returns: a new #GstAutoplugFactory.
*/
GstAutoplugFactory*
gst_autoplug_factory_new (const gchar *name, const gchar *longdesc, GType type)
{
GstAutoplugFactory *factory;
g_return_val_if_fail(name != NULL, NULL);
factory = gst_autoplug_factory_find (name);
if (!factory) {
factory = GST_AUTOPLUG_FACTORY (g_object_new (GST_TYPE_AUTOPLUG_FACTORY, NULL));
}
GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
if (factory->longdesc)
g_free (factory->longdesc);
factory->longdesc = g_strdup (longdesc);
factory->type = type;
return factory;
}
/**
* gst_autoplug_factory_destroy:
* @factory: factory to destroy
*
* Removes the autoplug from the global list.
*/
void
gst_autoplug_factory_destroy (GstAutoplugFactory *factory)
{
g_return_if_fail (factory != NULL);
/* we don't free the struct bacause someone might have a handle to it.. */
}
/**
* gst_autoplug_factory_find:
* @name: name of autoplugfactory to find
*
* Search for an autoplugfactory of the given name.
*
* Returns: #GstAutoplugFactory if found, NULL otherwise
*/
GstAutoplugFactory*
gst_autoplug_factory_find (const gchar *name)
{
GstPluginFeature *feature;
g_return_val_if_fail (name != NULL, NULL);
GST_DEBUG ("gstautoplug: find \"%s\"", name);
feature = gst_registry_pool_find_feature (name, GST_TYPE_AUTOPLUG_FACTORY);
if (feature)
return GST_AUTOPLUG_FACTORY (feature);
return NULL;
}
/**
* gst_autoplug_factory_create:
* @factory: the factory used to create the instance
*
* Create a new #GstAutoplug instance from the
* given autoplugfactory.
*
* Returns: A new #GstAutoplug instance.
*/
GstAutoplug*
gst_autoplug_factory_create (GstAutoplugFactory *factory)
{
GstAutoplug *new = NULL;
g_return_val_if_fail (factory != NULL, NULL);
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
g_return_val_if_fail (factory->type != 0, NULL);
new = GST_AUTOPLUG (g_object_new(factory->type,NULL));
}
return new;
}
/**
* gst_autoplug_factory_make:
* @name: the name of the factory used to create the instance
*
* Create a new #GstAutoplug instance from the
* autoplugfactory with the given name.
*
* Returns: A new #GstAutoplug instance.
*/
GstAutoplug*
gst_autoplug_factory_make (const gchar *name)
{
GstAutoplugFactory *factory;
g_return_val_if_fail (name != NULL, NULL);
factory = gst_autoplug_factory_find (name);
if (factory == NULL)
return NULL;
return gst_autoplug_factory_create (factory);
}

View file

@ -1,148 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstautoplug.h: Header for autoplugging functionality
*
* 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.
*/
#ifndef __GST_AUTOPLUG_H__
#define __GST_AUTOPLUG_H__
#ifndef GST_DISABLE_AUTOPLUG
#include <gst/gstelement.h>
G_BEGIN_DECLS
#define GST_TYPE_AUTOPLUG \
(gst_autoplug_get_type())
#define GST_AUTOPLUG(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUTOPLUG,GstAutoplug))
#define GST_AUTOPLUG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUTOPLUG,GstAutoplugClass))
#define GST_IS_AUTOPLUG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUTOPLUG))
#define GST_IS_AUTOPLUG_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUTOPLUG))
typedef struct _GstAutoplug GstAutoplug;
typedef struct _GstAutoplugClass GstAutoplugClass;
typedef enum {
GST_AUTOPLUG_TO_CAPS = GST_OBJECT_FLAG_LAST,
GST_AUTOPLUG_TO_RENDERER,
GST_AUTOPLUG_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8
} GstAutoplugFlags;
struct _GstAutoplug {
GstObject object;
GST_OBJECT_PADDING
};
struct _GstAutoplugClass {
GstObjectClass parent_class;
/* signal callbacks */
void (*new_object) (GstAutoplug *autoplug, GstObject *object);
/* perform the autoplugging */
GstElement* (*autoplug_to_caps) (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *sinkcaps, va_list args);
GstElement* (*autoplug_to_renderers) (GstAutoplug *autoplug, GstCaps *srccaps, GstElement *target, va_list args);
GST_CLASS_PADDING
};
GType gst_autoplug_get_type (void);
void gst_autoplug_signal_new_object (GstAutoplug *autoplug, GstObject *object);
GstElement* gst_autoplug_to_caps (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *sinkcaps, ...);
GstElement* gst_autoplug_to_caps_valist (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *sinkcaps, va_list args);
GstElement* gst_autoplug_to_renderers (GstAutoplug *autoplug, GstCaps *srccaps,
GstElement *target, ...);
GstElement* gst_autoplug_to_renderers_valist (GstAutoplug *autoplug, GstCaps *srccaps,
GstElement *target, va_list args);
/*
* creating autopluggers
*
*/
#define GST_TYPE_AUTOPLUG_FACTORY \
(gst_autoplug_factory_get_type())
#define GST_AUTOPLUG_FACTORY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUTOPLUG_FACTORY,GstAutoplugFactory))
#define GST_AUTOPLUG_FACTORY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUTOPLUG_FACTORY,GstAutoplugFactoryClass))
#define GST_IS_AUTOPLUG_FACTORY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUTOPLUG_FACTORY))
#define GST_IS_AUTOPLUG_FACTORY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUTOPLUG_FACTORY))
typedef struct _GstAutoplugFactory GstAutoplugFactory;
typedef struct _GstAutoplugFactoryClass GstAutoplugFactoryClass;
struct _GstAutoplugFactory {
GstPluginFeature feature;
gchar *longdesc; /* long description of the autoplugger (well, don't overdo it..) */
GType type; /* unique GType of the autoplugger */
};
struct _GstAutoplugFactoryClass {
GstPluginFeatureClass parent;
};
GType gst_autoplug_factory_get_type (void);
GstAutoplugFactory* gst_autoplug_factory_new (const gchar *name, const gchar *longdesc, GType type);
void gst_autoplug_factory_destroy (GstAutoplugFactory *factory);
GstAutoplugFactory* gst_autoplug_factory_find (const gchar *name);
GstAutoplug* gst_autoplug_factory_create (GstAutoplugFactory *factory);
GstAutoplug* gst_autoplug_factory_make (const gchar *name);
G_END_DECLS
#else /* GST_DISABLE_AUTOPLUG */
#pragma GCC poison gst_autoplug_get_type
#pragma GCC poison gst_autoplug_signal_new_object
#pragma GCC poison gst_autoplug_to_caps
#pragma GCC poison gst_autoplug_to_renderers
#pragma GCC poison gst_autoplug_factory_get_type
#pragma GCC poison gst_autoplug_factory_new
#pragma GCC poison gst_autoplug_factory_destroy
#pragma GCC poison gst_autoplug_factory_find
#pragma GCC poison gst_autoplug_factory_get_list
#pragma GCC poison gst_autoplug_factory_create
#pragma GCC poison gst_autoplug_factory_make
#endif /* GST_DISABLE_AUTOPLUG */
#endif /* __GST_AUTOPLUG_H__ */