- Fixed up a bunch of warnings.

Original commit message from CVS:
- Fixed up a bunch of warnings.
- Fixed buffer_copy (alloc correct size)
- Added start of autoplugger meta-element
This commit is contained in:
Erik Walthinsen 2001-05-10 08:16:36 +00:00
parent a4ef247132
commit 89aa4a3810
16 changed files with 275 additions and 37 deletions

View file

@ -1,7 +1,7 @@
filterdir = $(libdir)/gst
filter_LTLIBRARIES = libgststaticautoplug.la libgststaticautoplugrender.la \
libgstautoplugcache.la
libgstautoplugcache.la libgstautoplugger.la
libgststaticautoplug_la_SOURCES = \
gststaticautoplug.c
@ -10,6 +10,7 @@ libgststaticautoplugrender_la_SOURCES = \
gststaticautoplugrender.c
libgstautoplugcache_la_SOURCES = gstautoplugcache.c
libgstautoplugger_la_SOURCES = gstautoplugger.c
libgststaticautoplug_la_LDFLAGS = -version-info $(GST_LIBVERSION)
libgststaticautoplugrender_la_LDFLAGS = -version-info $(GST_LIBVERSION)

View file

@ -1,4 +1,5 @@
#include <gst/gst.h>
#include <string.h>
GstElement *pipeline, *src, *autobin, *cache, *typefind, *decoder, *sink;

View file

@ -77,13 +77,15 @@ enum {
static void gst_autoplugcache_class_init (GstAutoplugCacheClass *klass);
static void gst_autoplugcache_init (GstAutoplugCache *queue);
static void gst_autoplugcache_init (GstAutoplugCache *cache);
static void gst_autoplugcache_set_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_autoplugcache_get_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_autoplugcache_loop (GstElement *element);
static GstPadNegotiateReturn gst_autoplugcache_nego_src (GstPad *pad, GstCaps **caps, gpointer *data);
static GstPadNegotiateReturn gst_autoplugcache_nego_sink (GstPad *pad, GstCaps **caps, gpointer *data);
static GstElementStateReturn gst_autoplugcache_change_state (GstElement *element);
@ -144,9 +146,11 @@ 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->sinkpad, gst_autoplugcache_nego_src);
gst_element_add_pad (GST_ELEMENT(cache), cache->srcpad);
// provide a zero basis for the cache
@ -236,11 +240,27 @@ gst_autoplugcache_loop (GstElement *element)
} while (!GST_FLAG_IS_SET (element, GST_ELEMENT_COTHREAD_STOPPING));
}
static GstPadNegotiateReturn
gst_autoplugcache_nego_src (GstPad *pad, GstCaps **caps, gpointer *data)
{
GstAutoplugCache *cache = GST_AUTOPLUGCACHE (GST_PAD_PARENT (pad));
return gst_pad_negotiate_proxy (pad, cache->sinkpad, caps);
}
static GstPadNegotiateReturn
gst_autoplugcache_nego_sink (GstPad *pad, GstCaps **caps, gpointer *data)
{
GstAutoplugCache *cache = GST_AUTOPLUGCACHE (GST_PAD_PARENT (pad));
return gst_pad_negotiate_proxy (pad, cache->srcpad, caps);
}
static GstElementStateReturn
gst_autoplugcache_change_state (GstElement *element)
{
GstAutoplugCache *cache;
// 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);

View file

@ -0,0 +1,226 @@
/* 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.
*/
#include <gst/gst.h>
GstElementDetails gst_autoplugger_details = {
"Dynamic autoplugger",
"Autoplugger",
"Magic element that converts from any type to any other",
VERSION,
"Erik Walthinsen <omega@temple-baptist.com>",
"(C) 2001 RidgeRun, Inc. (www.ridgerun.com)",
};
#define GST_TYPE_AUTOPLUGGER \
(gst_autoplugger_get_type())
#define GST_AUTOPLUGGER(obj) \
(GTK_CHECK_CAST((obj),GST_TYPE_AUTOPLUGGER,GstAutoplugger))
#define GST_AUTOPLUGGER_CLASS(klass) \
(GTK_CHECK_CLASS_CAST((klass),GST_TYPE_AUTOPLUGGER,GstAutopluggerClass))
#define GST_IS_AUTOPLUGGER(obj) \
(GTK_CHECK_TYPE((obj),GST_TYPE_AUTOPLUGGER))
#define GST_IS_AUTOPLUGGER_CLASS(obj) \
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUTOPLUGGER))
typedef struct _GstAutoplugger GstAutoplugger;
typedef struct _GstAutopluggerClass GstAutopluggerClass;
struct _GstAutoplugger {
GstBin bin;
GstGhostPad *srcghost, *sinkghost;
GstElement *cache, *typefind;
};
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_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_autoplugger_get_arg (GtkObject *object, GtkArg *arg, guint id);
//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 GstElementClass *parent_class = NULL;
//static guint gst_autoplugger_signals[LAST_SIGNAL] = { 0 };
GtkType
gst_autoplugger_get_type(void) {
static GtkType autoplugger_type = 0;
if (!autoplugger_type) {
static const GtkTypeInfo autoplugger_info = {
"GstAutoplugger",
sizeof(GstAutoplugger),
sizeof(GstAutopluggerClass),
(GtkClassInitFunc)gst_autoplugger_class_init,
(GtkObjectInitFunc)gst_autoplugger_init,
(GtkArgSetFunc)gst_autoplugger_set_arg,
(GtkArgGetFunc)gst_autoplugger_get_arg,
(GtkClassInitFunc)NULL,
};
autoplugger_type = gtk_type_unique (GST_TYPE_BIN, &autoplugger_info);
}
return autoplugger_type;
}
static void
gst_autoplugger_class_init (GstAutopluggerClass *klass)
{
GtkObjectClass *gtkobject_class;
GstElementClass *gstelement_class;
gtkobject_class = (GtkObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = gtk_type_class (GST_TYPE_ELEMENT);
/*
gst_autoplugger_signals[_EMPTY] =
gtk_signal_new ("_empty", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstAutopluggerClass, _empty),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (gtkobject_class, gst_autoplugger_signals, LAST_SIGNAL);
*/
/*
gtk_object_add_arg_type ("GstAutoplugger::buffer_count", GTK_TYPE_INT,
GTK_ARG_READABLE, ARG_BUFFER_COUNT);
gtk_object_add_arg_type ("GstAutoplugger::reset", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_RESET);
*/
gtkobject_class->set_arg = gst_autoplugger_set_arg;
gtkobject_class->get_arg = gst_autoplugger_get_arg;
// gstelement_class->change_state = gst_autoplugger_change_state;
}
static void
gst_autoplugger_init (GstAutoplugger *autoplugger)
{
GstPad *srcpad, *sinkpad;
// 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_elementfactory_make("autoplugcache", "unnamed_autoplugcache");
g_return_if_fail (autoplugger->cache != NULL);
// 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
sinkpad = gst_element_get_pad (autoplugger->cache, "sink");
srcpad = gst_element_get_pad (autoplugger->cache, "src");
// attach handlers to the typefind pads
gtk_signal_connect (GTK_OBJECT (sinkpad), "caps_changed",
GTK_SIGNAL_FUNC (gst_autoplugger_external_sink_caps_changed), autoplugger);
gtk_signal_connect (GTK_OBJECT (srcpad), "caps_changed",
GTK_SIGNAL_FUNC (gst_autoplugger_external_src_caps_changed), autoplugger);
// ghost both of these pads to the outside world
gst_element_add_ghost_pad (GST_ELEMENT(autoplugger), sinkpad, "sink");
gst_element_add_ghost_pad (GST_ELEMENT(autoplugger), srcpad, "src");
}
static void
gst_autoplugger_external_sink_caps_changed(GstPad *pad, GstCaps *caps, GstAutoplugger *autoplugger)
{
GST_INFO(GST_CAT_AUTOPLUG, "have cache:sink caps of %s\n",gst_caps_get_mime(caps));
}
static void
gst_autoplugger_external_src_caps_changed(GstPad *pad, GstCaps *caps, GstAutoplugger *autoplugger)
{
GST_INFO(GST_CAT_AUTOPLUG, "have cache:src caps of %s\n",gst_caps_get_mime(caps));
}
static void
gst_autoplugger_set_arg (GtkObject *object, GtkArg *arg, guint id)
{
GstAutoplugger *autoplugger;
autoplugger = GST_AUTOPLUGGER (object);
switch (id) {
default:
break;
}
}
static void
gst_autoplugger_get_arg (GtkObject *object, GtkArg *arg, guint id)
{
GstAutoplugger *autoplugger;
autoplugger = GST_AUTOPLUGGER (object);
switch (id) {
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
factory = gst_elementfactory_new ("autoplugger", GST_TYPE_AUTOPLUGGER,
&gst_autoplugger_details);
g_return_val_if_fail (factory != NULL, FALSE);
gst_plugin_add_factory (plugin, factory);
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"autoplugger",
plugin_init
};

View file

@ -345,7 +345,7 @@ gst_fakesrc_loop(GstElement *element)
if (src->eos) {
GST_INFO (0, "fakesrc is setting eos on pad");
gst_pad_set_eos (pad);
return NULL;
return;
}
buf = gst_buffer_new();

View file

@ -48,6 +48,7 @@
#include <gst/gsttrace.h>
#include <gst/gstxml.h>
#include <gst/cothreads.h>
#include <gst/gstscheduler.h>
#include <gst/gstparse.h>

View file

@ -320,7 +320,7 @@ gst_bin_remove (GstBin *bin,
g_return_if_fail (GST_STATE (bin) != GST_STATE_PLAYING);
// the element must have its parent set to the current bin
g_return_if_fail (GST_ELEMENT_PARENT(element) == (GstElement *)bin);
g_return_if_fail (GST_ELEMENT_PARENT(element) == (GstObject *)bin);
// the element must be in the bin's list of children
if (g_list_find(bin->children, element) == NULL) {
@ -351,7 +351,6 @@ gst_bin_change_state (GstElement *element)
GstBin *bin;
GList *children;
GstElement *child;
GstElementStateReturn ret;
GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME (element));
@ -643,7 +642,7 @@ gst_bin_restore_thyself (GstObject *object,
childlist = field->xmlChildrenNode;
while (childlist) {
if (!strcmp (childlist->name, "element")) {
GstElement *element = gst_element_load_thyself (childlist, GST_OBJECT (bin));
GstElement *element = gst_element_restore_thyself (childlist, GST_OBJECT (bin));
gst_bin_add (bin, element);
}
@ -916,7 +915,7 @@ static gboolean
gst_bin_iterate_func (GstBin *bin)
{
// only iterate if this is the manager bin
if (GST_ELEMENT_SCHED(bin)->parent == bin) {
if (GST_ELEMENT_SCHED(bin)->parent == (GstElement *)bin) {
return GST_SCHEDULE_ITERATE(GST_ELEMENT_SCHED(bin));
} else {
GST_DEBUG (GST_CAT_SCHEDULING, "this bin can't be iterated on!\n");

View file

@ -448,7 +448,7 @@ gst_buffer_copy (GstBuffer *buffer)
// copy the absolute size
newbuf->size = buffer->size;
// allocate space for the copy
newbuf->data = (guchar *)g_malloc (buffer->data);
newbuf->data = (guchar *)g_malloc (buffer->size);
// copy the data straight across
memcpy(newbuf,buffer->data,buffer->size);
// the new maxsize is the same as the size, since we just malloc'd it

View file

@ -119,13 +119,14 @@ gst_element_class_init (GstElementClass *klass)
gtk_object_class_add_signals (gtkobject_class, gst_element_signals, LAST_SIGNAL);
gtkobject_class->set_arg = gst_element_set_arg;
gtkobject_class->get_arg = gst_element_get_arg;
gtkobject_class->destroy = gst_element_real_destroy;
gtkobject_class->set_arg = GST_DEBUG_FUNCPTR(gst_element_set_arg);
gtkobject_class->get_arg = GST_DEBUG_FUNCPTR(gst_element_get_arg);
gtkobject_class->destroy = GST_DEBUG_FUNCPTR(gst_element_real_destroy);
gstobject_class->save_thyself = gst_element_save_thyself;
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR(gst_element_save_thyself);
gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR(gst_element_restore_thyself);
klass->change_state = gst_element_change_state;
klass->change_state = GST_DEBUG_FUNCPTR(gst_element_change_state);
klass->elementfactory = NULL;
}
@ -988,7 +989,7 @@ gst_element_save_thyself (GstObject *object,
}
/**
* gst_element_load_thyself:
* gst_element_restore_thyself:
* @self: the xml node
* @parent: the parent of this object when it's loaded
*
@ -997,7 +998,7 @@ gst_element_save_thyself (GstObject *object,
* Returns: the new element
*/
GstElement*
gst_element_load_thyself (xmlNodePtr self, GstObject *parent)
gst_element_restore_thyself (xmlNodePtr self, GstObject *parent)
{
xmlNodePtr children = self->xmlChildrenNode;
GstElement *element;

View file

@ -248,7 +248,7 @@ void gst_element_error (GstElement *element, const gchar *error);
GstElementFactory* gst_element_get_factory (GstElement *element);
/* XML write and read */
GstElement* gst_element_load_thyself (xmlNodePtr self, GstObject *parent);
GstElement* gst_element_restore_thyself (xmlNodePtr self, GstObject *parent);
/*
@ -280,6 +280,7 @@ GstElement* gst_elementfactory_create (GstElementFactory *factory,
/* FIXME this name is wrong, probably so is the one above it */
GstElement* gst_elementfactory_make (const gchar *factoryname, const gchar *name);
xmlNodePtr gst_elementfactory_save_thyself (GstElementFactory *factory, xmlNodePtr parent);
GstElementFactory* gst_elementfactory_load_thyself (xmlNodePtr parent);

View file

@ -434,10 +434,6 @@ gst_default_error_handler (gchar *file, gchar *function,
#ifdef __USE_GNU
#warning __USE_GNU is defined
#endif
/***** DEBUG system *****/
GHashTable *__gst_function_pointers = NULL;
@ -447,11 +443,12 @@ _gst_debug_nameof_funcptr (void *ptr)
gchar *ptrname;
Dl_info dlinfo;
if (__gst_function_pointers) {
if (ptrname = g_hash_table_lookup(__gst_function_pointers,ptr))
if ((ptrname = g_hash_table_lookup(__gst_function_pointers,ptr)))
return g_strdup(ptrname);
} else if (dladdr(ptr,&dlinfo)) {
return g_strdup(dlinfo.dli_sname);
} else {
return g_strdup_printf("%p",ptr);
}
return NULL;
}

View file

@ -290,7 +290,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf)
/* put the buffer on the tail of the list */
queue->queue = g_slist_append (queue->queue, buf);
GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad));
GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)+\n",GST_DEBUG_PAD_NAME(pad));
/* if we were empty, but aren't any more, signal a condition */
queue->level_buffers++;

View file

@ -69,7 +69,6 @@ static xmlNodePtr gst_thread_save_thyself (GstObject *object, xmlNodePtr paren
static void gst_thread_restore_thyself (GstObject *object, xmlNodePtr self);
static void gst_thread_signal_thread (GstThread *thread, gboolean spinning);
static void gst_thread_schedule_dummy (GstBin *bin);
static void* gst_thread_main_loop (void *arg);
@ -148,14 +147,6 @@ gst_thread_init (GstThread *thread)
// gst_element_set_manager(GST_ELEMENT(thread),GST_ELEMENT(thread));
}
static void
gst_thread_schedule_dummy (GstBin *bin)
{
g_return_if_fail (GST_IS_THREAD (bin));
if (!GST_FLAG_IS_SET (GST_THREAD (bin), GST_THREAD_STATE_SPINNING))
GST_INFO (GST_CAT_THREAD,"scheduling delayed until thread starts");
}
static void
gst_thread_set_arg (GtkObject *object,
@ -228,7 +219,7 @@ gst_thread_change_state (GstElement *element)
GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME(element));
thread = GST_THREAD (element);
GST_DEBUG (GST_CAT_THREAD, "**** THREAD %d changing THREAD %d ****\n",self,thread->thread_id);
GST_DEBUG (GST_CAT_THREAD, "**** THREAD %ld changing THREAD %ld ****\n",self,thread->thread_id);
GST_DEBUG (GST_CAT_THREAD, "**** current pid=%d\n",getpid());
transition = GST_STATE_TRANSITION (element);

View file

@ -167,7 +167,7 @@ gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root)
if (!strcmp(field->name, "element") && (field->ns == xml->ns)) {
GstElement *element;
element = gst_element_load_thyself(field, NULL);
element = gst_element_restore_thyself(field, NULL);
xml->topelements = g_list_prepend (xml->topelements, element);
}

View file

@ -345,7 +345,7 @@ gst_fakesrc_loop(GstElement *element)
if (src->eos) {
GST_INFO (0, "fakesrc is setting eos on pad");
gst_pad_set_eos (pad);
return NULL;
return;
}
buf = gst_buffer_new();

View file

@ -290,7 +290,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf)
/* put the buffer on the tail of the list */
queue->queue = g_slist_append (queue->queue, buf);
GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad));
GST_DEBUG (GST_CAT_DATAFLOW,"(%s:%s)+\n",GST_DEBUG_PAD_NAME(pad));
/* if we were empty, but aren't any more, signal a condition */
queue->level_buffers++;