From bc4619a44bd57ef222a8605914c088ad0dc8c609 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 31 Dec 2000 16:12:48 +0000 Subject: [PATCH] Added multiple caps to the pads Original commit message from CVS: Added multiple caps to the pads Extended the padfactory for the multiple caps GstCaps now have a name so that future manipulations on them can be done by name Updated the plugins for the new caps list --- examples/autoplug/autoplug.c | 2 +- gst/elements/gstaudiosink.c | 17 +++-- gst/gst.h | 1 + gst/gstautoplug.c | 55 +++++++++++---- gst/gstautoplug.h | 2 + gst/gstcaps.c | 74 +++++++++++++++++++-- gst/gstcaps.h | 22 +++--- gst/gstelement.h | 4 ++ gst/gstelementfactory.c | 92 ++++++++++++++++++++------ gst/gstinfo.c | 3 +- gst/gstpad.c | 52 ++++++++++----- gst/gstpad.h | 15 +++-- gst/gstpipeline.c | 14 ++-- gst/gstplugin.c | 1 + gst/gstprops.c | 31 ++++++++- gst/gstprops.h | 3 + plugins/elements/gstaudiosink.c | 17 +++-- tests/Makefile.am | 2 +- tests/autoplug.c | 12 ++-- tests/caps.c | 12 ++-- tests/case4.c | 3 +- tests/init.c | 2 + tests/old/examples/autoplug/autoplug.c | 2 +- tests/queue.c | 8 ++- tests/simplefake.c | 4 +- tests/states.c | 4 ++ 26 files changed, 338 insertions(+), 116 deletions(-) diff --git a/examples/autoplug/autoplug.c b/examples/autoplug/autoplug.c index 4bc26cf48e..b5e2866a5c 100644 --- a/examples/autoplug/autoplug.c +++ b/examples/autoplug/autoplug.c @@ -4,7 +4,7 @@ static gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstSrc *src) +void eos(GstElement *src) { g_print("have eos, quitting\n"); diff --git a/gst/elements/gstaudiosink.c b/gst/elements/gstaudiosink.c index c2ac249952..0249a3e126 100644 --- a/gst/elements/gstaudiosink.c +++ b/gst/elements/gstaudiosink.c @@ -74,14 +74,17 @@ static GstPadFactory audiosink_sink_factory = { "sink", GST_PAD_FACTORY_SINK, GST_PAD_FACTORY_ALWAYS, - "audio/raw", - "format", GST_PROPS_INT (AFMT_S16_LE), - "depth", GST_PROPS_LIST ( - GST_PROPS_INT (8), + GST_PAD_FACTORY_CAPS ( + "audiosink_sink", + "audio/raw", + "format", GST_PROPS_INT (AFMT_S16_LE), + "depth", GST_PROPS_LIST ( + GST_PROPS_INT (8), GST_PROPS_INT (16) - ), - "rate", GST_PROPS_INT_RANGE (8000, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2), + ), + "rate", GST_PROPS_INT_RANGE (8000, 48000), + "channels", GST_PROPS_INT_RANGE (1, 2) + ), NULL }; diff --git a/gst/gst.h b/gst/gst.h index 8d3005958a..d39cdecbb3 100644 --- a/gst/gst.h +++ b/gst/gst.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/gst/gstautoplug.c b/gst/gstautoplug.c index 505c13f83b..20b38dfdac 100644 --- a/gst/gstautoplug.c +++ b/gst/gstautoplug.c @@ -88,7 +88,7 @@ gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest) if (srctemp->direction == GST_PAD_SRC && desttemp->direction == GST_PAD_SINK) { - if (gst_caps_check_compatibility (srctemp->caps, desttemp->caps)) { + if (gst_caps_list_check_compatibility (srctemp->caps, desttemp->caps)) { INFO(0,"factory \"%s\" can connect with factory \"%s\"", src->name, dest->name); return TRUE; } @@ -109,8 +109,8 @@ gst_autoplug_elementfactory_get_list (gpointer data) } typedef struct { - GstCaps *src; - GstCaps *sink; + GList *src; + GList *sink; } caps_struct; #define IS_CAPS(cap) (((cap) == caps->src) || (cap) == caps->sink) @@ -122,16 +122,16 @@ gst_autoplug_caps_find_cost (gpointer src, gpointer dest, gpointer data) gboolean res; if (IS_CAPS (src) && IS_CAPS (dest)) { - res = gst_caps_check_compatibility ((GstCaps *)src, (GstCaps *)dest); - INFO (0,"caps %d to caps %d %d", ((GstCaps *)src)->id, ((GstCaps *)dest)->id, res); + res = gst_caps_list_check_compatibility ((GList *)src, (GList *)dest); + //INFO (0,"caps %d to caps %d %d", ((GstCaps *)src)->id, ((GstCaps *)dest)->id, res); } else if (IS_CAPS (src)) { - res = gst_elementfactory_can_sink_caps ((GstElementFactory *)dest, src); - INFO (0,"factory %s to src caps %d %d", ((GstElementFactory *)dest)->name, ((GstCaps *)src)->id, res); + res = gst_elementfactory_can_sink_caps_list ((GstElementFactory *)dest, (GList *)src); + //INFO (0,"factory %s to src caps %d %d", ((GstElementFactory *)dest)->name, ((GstCaps *)src)->id, res); } else if (IS_CAPS (dest)) { - res = gst_elementfactory_can_src_caps ((GstElementFactory *)src, dest); - INFO (0,"factory %s to sink caps %d %d", ((GstElementFactory *)src)->name, ((GstCaps *)dest)->id, res); + res = gst_elementfactory_can_src_caps_list ((GstElementFactory *)src, (GList *)dest); + //INFO (0,"factory %s to sink caps %d %d", ((GstElementFactory *)src)->name, ((GstCaps *)dest)->id, res); } else { res = gst_autoplug_can_match ((GstElementFactory *)src, (GstElementFactory *)dest); @@ -148,17 +148,48 @@ gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps) { caps_struct caps; - caps.src = srccaps; - caps.sink = sinkcaps; + caps.src = g_list_prepend (NULL,srccaps); + caps.sink = g_list_prepend (NULL,sinkcaps); INFO (0,"autoplugging two caps structures"); - return gst_autoplug_func (srccaps, sinkcaps, + return gst_autoplug_func (caps.src, caps.sink, gst_autoplug_elementfactory_get_list, gst_autoplug_caps_find_cost, &caps); } +GList* +gst_autoplug_caps_list (GList *srccaps, GList *sinkcaps) +{ + caps_struct caps; + + caps.src = srccaps; + caps.sink = sinkcaps; + + INFO (0,"autoplugging two caps list structures"); + + return gst_autoplug_func (caps.src, caps.sink, + gst_autoplug_elementfactory_get_list, + gst_autoplug_caps_find_cost, + &caps); +} + +GList* +gst_autoplug_pads (GstPad *srcpad, GstPad *sinkpad) +{ + caps_struct caps; + + caps.src = srcpad->caps; + caps.sink = sinkpad->caps; + + INFO (0,"autoplugging two caps structures"); + + return gst_autoplug_func (caps.src, caps.sink, + gst_autoplug_elementfactory_get_list, + gst_autoplug_caps_find_cost, + &caps); +} static gint find_factory (gst_autoplug_node *rgnNodes, gpointer factory) { diff --git a/gst/gstautoplug.h b/gst/gstautoplug.h index b895dfe861..c646c24d61 100644 --- a/gst/gstautoplug.h +++ b/gst/gstautoplug.h @@ -60,6 +60,8 @@ struct _GstAutoplugClass { GtkType gst_autoplug_get_type (void); GList* gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps); +GList* gst_autoplug_caps_list (GList *srccaps, GList *sinkcaps); +GList* gst_autoplug_pads (GstPad *srcpad, GstPad *sinkpad); #ifdef __cplusplus diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 319a1f462d..0a9c88f311 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#define GST_DEBUG_ENABLED +//#define GST_DEBUG_ENABLED #include "gst_private.h" #include "gstcaps.h" @@ -54,6 +54,7 @@ get_type_for_mime (gchar *mime) /** * gst_caps_new: + * @name: the name of this capability * @mime: the mime type to attach to the capability * * create a new capability with the given mime type @@ -61,13 +62,14 @@ get_type_for_mime (gchar *mime) * Returns: a new capability */ GstCaps* -gst_caps_new (gchar *mime) +gst_caps_new (gchar *name, gchar *mime) { GstCaps *caps; g_return_val_if_fail (mime != NULL, NULL); caps = g_new0 (GstCaps, 1); + caps->name = g_strdup (name); caps->id = get_type_for_mime (mime); caps->properties = NULL; @@ -76,6 +78,7 @@ gst_caps_new (gchar *mime) /** * gst_caps_new_with_props: + * @name: the name of this capability * @mime: the mime type to attach to the capability * @props: the properties for this capability * @@ -85,11 +88,11 @@ gst_caps_new (gchar *mime) * Returns: a new capability */ GstCaps* -gst_caps_new_with_props (gchar *mime, GstProps *props) +gst_caps_new_with_props (gchar *name, gchar *mime, GstProps *props) { GstCaps *caps; - caps = gst_caps_new (mime); + caps = gst_caps_new (name, mime); caps->properties = props; return caps; @@ -105,16 +108,38 @@ gst_caps_new_with_props (gchar *mime, GstProps *props) */ GstCaps* gst_caps_register (GstCapsFactory *factory) +{ + guint dummy; + + return gst_caps_register_count (factory, &dummy); +} + +/** + * gst_caps_register_count: + * @factory: the factory to register + * @counter: count how many entries were consumed + * + * Register the factory. + * + * Returns: The registered capability + */ +GstCaps* +gst_caps_register_count (GstCapsFactory *factory, guint *counter) { GstCapsFactoryEntry tag; gint i = 0; guint16 typeid; + gchar *name; GstCaps *caps; - + g_return_val_if_fail (factory != NULL, NULL); tag = (*factory)[i++]; + g_return_val_if_fail (tag != NULL, NULL); + name = tag; + + tag = (*factory)[i++]; g_return_val_if_fail (tag != NULL, NULL); typeid = get_type_for_mime ((gchar *)tag); @@ -122,8 +147,11 @@ gst_caps_register (GstCapsFactory *factory) caps = g_new0 (GstCaps, 1); g_return_val_if_fail (caps != NULL, NULL); + caps->name = g_strdup (name); caps->id = typeid; - caps->properties = gst_props_register (&(*factory)[i]); + caps->properties = gst_props_register_count (&(*factory)[i], counter); + + *counter += 2; return caps; } @@ -160,7 +188,7 @@ gst_caps_set_props (GstCaps *caps, GstProps *props) GstProps* gst_caps_get_props (GstCaps *caps) { - g_return_val_if_fail (caps != NULL, caps); + g_return_val_if_fail (caps != NULL, NULL); return caps->properties; } @@ -201,6 +229,34 @@ gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps) } } +/** + * gst_caps_list_check_compatibility: + * @fromcaps: a capabilty + * @tocaps: a capabilty + * + * Checks whether two capability lists are compatible + * + * Returns: true if compatible, false otherwise + */ +gboolean +gst_caps_list_check_compatibility (GList *fromcaps, GList *tocaps) +{ + while (fromcaps) { + GstCaps *fromcap = (GstCaps *)fromcaps->data; + GList *destcaps = tocaps; + + while (destcaps) { + GstCaps *destcap = (GstCaps *)destcaps->data; + + if (gst_caps_check_compatibility (fromcap, destcap)) + return TRUE; + + destcaps = g_list_next (destcaps); + } + fromcaps = g_list_next (fromcaps); + } + return FALSE; +} /** * gst_caps_save_thyself: @@ -218,6 +274,7 @@ gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent) g_return_val_if_fail (caps != NULL, NULL); + xmlNewChild (parent, NULL, "name", caps->name); xmlNewChild (parent, NULL, "type", gst_type_find_by_id (caps->id)->mime); if (caps->properties) { subtree = xmlNewChild (parent, NULL, "properties", NULL); @@ -243,6 +300,9 @@ gst_caps_load_thyself (xmlNodePtr parent) xmlNodePtr field = parent->childs; while (field) { + if (!strcmp (field->name, "name")) { + caps->name = g_strdup (xmlNodeGetContent (field)); + } if (!strcmp (field->name, "type")) { caps->id = get_type_for_mime (xmlNodeGetContent (field)); } diff --git a/gst/gstcaps.h b/gst/gstcaps.h index f32014404b..8952844879 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -32,24 +32,28 @@ typedef gpointer GstCapsFactoryEntry; typedef GstCapsFactoryEntry GstCapsFactory[]; struct _GstCaps { + gchar *name; /* the name of this caps */ + guint16 id; /* type id (major type) */ GstProps *properties; /* properties for this capability */ }; /* initialize the subsystem */ -void _gst_caps_initialize (void); +void _gst_caps_initialize (void); -GstCaps* gst_caps_new (gchar *mime); -GstCaps* gst_caps_new_with_props (gchar *mime, GstProps *props); -GstCaps* gst_caps_register (GstCapsFactory *factory); +GstCaps* gst_caps_new (gchar *name, gchar *mime); +GstCaps* gst_caps_new_with_props (gchar *name, gchar *mime, GstProps *props); +GstCaps* gst_caps_register (GstCapsFactory *factory); +GstCaps* gst_caps_register_count (GstCapsFactory *factory, guint *count); -GstCaps* gst_caps_set_props (GstCaps *caps, GstProps *props); -GstProps* gst_caps_get_props (GstCaps *caps); +GstCaps* gst_caps_set_props (GstCaps *caps, GstProps *props); +GstProps* gst_caps_get_props (GstCaps *caps); -gboolean gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps); +gboolean gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps); +gboolean gst_caps_list_check_compatibility (GList *fromcaps, GList *tocaps); -xmlNodePtr gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent); -GstCaps* gst_caps_load_thyself (xmlNodePtr parent); +xmlNodePtr gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent); +GstCaps* gst_caps_load_thyself (xmlNodePtr parent); #endif /* __GST_CAPS_H__ */ diff --git a/gst/gstelement.h b/gst/gstelement.h index e65ff98cf9..d492926d76 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -231,6 +231,10 @@ gboolean gst_elementfactory_can_src_caps (GstElementFactory *factory, GstCaps *caps); gboolean gst_elementfactory_can_sink_caps (GstElementFactory *factory, GstCaps *caps); +gboolean gst_elementfactory_can_src_caps_list (GstElementFactory *factory, + GList *caps); +gboolean gst_elementfactory_can_sink_caps_list (GstElementFactory *factory, + GList *caps); GstElement* gst_elementfactory_create (GstElementFactory *factory, gchar *name); diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index a6542eda7c..ba6142d2d3 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -218,17 +218,17 @@ gst_elementfactory_add_padtemplate (GstElementFactory *factory, } /** - * gst_elementfactory_can_src_caps : + * gst_elementfactory_can_src_caps_list : * @factory: factory to query - * @caps: the caps to check + * @caps: the caps list to check * - * Checks if the factory can source the given capability + * Checks if the factory can source the given capability list * - * Returns: true if it can src the capability + * Returns: true if it can src the capabilities */ gboolean -gst_elementfactory_can_src_caps (GstElementFactory *factory, - GstCaps *caps) +gst_elementfactory_can_src_caps_list (GstElementFactory *factory, + GList *caps) { GList *templates; @@ -241,7 +241,7 @@ gst_elementfactory_can_src_caps (GstElementFactory *factory, GstPadTemplate *template = (GstPadTemplate *)templates->data; if (template->direction == GST_PAD_SRC) { - if (gst_caps_check_compatibility (template->caps, caps)) + if (gst_caps_list_check_compatibility (template->caps, caps)) return TRUE; } templates = g_list_next (templates); @@ -250,6 +250,64 @@ gst_elementfactory_can_src_caps (GstElementFactory *factory, return FALSE; } +/** + * gst_elementfactory_can_sink_caps_list : + * @factory: factory to query + * @caps: the caps list to check + * + * Checks if the factory can sink the given capability list + * + * Returns: true if it can sink the capabilities + */ +gboolean +gst_elementfactory_can_sink_caps_list (GstElementFactory *factory, + GList *caps) +{ + GList *templates; + + g_return_val_if_fail(factory != NULL, FALSE); + g_return_val_if_fail(caps != NULL, FALSE); + + templates = factory->padtemplates; + + while (templates) { + GstPadTemplate *template = (GstPadTemplate *)templates->data; + + if (template->direction == GST_PAD_SINK) { + if (gst_caps_list_check_compatibility (caps, template->caps)) + return TRUE; + } + templates = g_list_next (templates); + } + + return FALSE; +} + +/** + * gst_elementfactory_can_src_caps : + * @factory: factory to query + * @caps: the caps to check + * + * Checks if the factory can src the given capability + * + * Returns: true if it can sink the capability + */ +gboolean +gst_elementfactory_can_src_caps (GstElementFactory *factory, + GstCaps *caps) +{ + GList *dummy; + gboolean ret; + + dummy = g_list_prepend (NULL, caps); + + ret = gst_elementfactory_can_src_caps_list (factory, dummy); + + g_list_free (dummy); + + return ret; +} + /** * gst_elementfactory_can_sink_caps : * @factory: factory to query @@ -263,24 +321,16 @@ gboolean gst_elementfactory_can_sink_caps (GstElementFactory *factory, GstCaps *caps) { - GList *templates; + GList *dummy; + gboolean ret; - g_return_val_if_fail(factory != NULL, FALSE); - g_return_val_if_fail(caps != NULL, FALSE); + dummy = g_list_prepend (NULL, caps); - templates = factory->padtemplates; + ret = gst_elementfactory_can_sink_caps_list (factory, dummy); - while (templates) { - GstPadTemplate *template = (GstPadTemplate *)templates->data; + g_list_free (dummy); - if (template->direction == GST_PAD_SINK) { - if (gst_caps_check_compatibility (caps, template->caps)) - return TRUE; - } - templates = g_list_next (templates); - } - - return FALSE; + return ret; } /** diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 5c2125ee11..685091dd79 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -33,7 +33,8 @@ GHashTable *__gst_function_pointers = NULL; /***** INFO system *****/ GstInfoHandler _gst_info_handler = gst_default_info_handler; -guint32 _gst_info_categories = 0xffffffff; +//guint32 _gst_info_categories = 0xffffffff; +guint32 _gst_info_categories = 0x00000000; static gchar *_gst_info_category_strings[] = { "GST_INIT", diff --git a/gst/gstpad.c b/gst/gstpad.c index 1c6d0b04c3..42f3957dfa 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -471,16 +471,19 @@ gst_pad_connect (GstPad *srcpad, /* chack pad compatibility */ if (srcpad->caps && sinkpad->caps) { - if (!gst_caps_check_compatibility (srcpad->caps, sinkpad->caps)) + if (!gst_caps_check_compatibility (srcpad->caps, sinkpad->caps)) { g_warning ("gstpad: connecting incompatible pads (%s:%s) and (%s:%s)\n", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); - else + } + else { DEBUG ("gstpad: connecting compatible pads (%s:%s) and (%s:%s)\n", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + } } - else + else { DEBUG ("gstpad: could not check capabilities of pads (%s:%s) and (%s:%s)\n", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + } /* first set peers */ srcpad->peer = sinkpad; @@ -592,15 +595,15 @@ gst_pad_get_ghost_parents (GstPad *pad) } /** - * gst_pad_set_caps: + * gst_pad_set_caps_list: * @pad: the pad to set the caps to - * @caps: the caps to attach to this pad + * @caps: the capslist to attach to this pad * * set the capabilities of this pad */ void -gst_pad_set_caps (GstPad *pad, - GstCaps *caps) +gst_pad_set_caps_list (GstPad *pad, + GList *caps) { g_return_if_fail (pad != NULL); g_return_if_fail (GST_IS_PAD (pad)); @@ -608,15 +611,15 @@ gst_pad_set_caps (GstPad *pad, pad->caps = caps; } /** - * gst_pad_get_caps: + * gst_pad_get_caps_list: * @pad: the pad to get the capabilities from * * get the capabilities of this pad * - * Returns: the capabilities of this pad + * Returns: a list of capabilities of this pad */ -GstCaps * -gst_pad_get_caps (GstPad *pad) +GList * +gst_pad_get_caps_list (GstPad *pad) { g_return_val_if_fail (pad != NULL, NULL); g_return_val_if_fail (GST_IS_PAD (pad), NULL); @@ -821,6 +824,7 @@ gst_padtemplate_new (GstPadFactory *factory) GstPadTemplate *new; GstPadFactoryEntry tag; gint i = 0; + guint counter = 0; g_return_val_if_fail (factory != NULL, NULL); @@ -836,7 +840,13 @@ gst_padtemplate_new (GstPadFactory *factory) tag = (*factory)[i++]; new->presence = GPOINTER_TO_UINT (tag); - new->caps = gst_caps_register ((GstCapsFactory *)&(*factory)[i]); + tag = (*factory)[i++]; + + while (GPOINTER_TO_INT (tag) == 1) { + new->caps = g_list_append (new->caps, gst_caps_register_count ((GstCapsFactory *)&(*factory)[i], &counter)); + i+=counter; + tag = (*factory)[i++]; + } return new; } @@ -846,7 +856,7 @@ gst_padtemplate_new (GstPadFactory *factory) * @name_template: the name template * @direction: the direction for the template * @presence: the presence of the pad - * @caps: the capabilities for the template + * @caps: a list of capabilities for the template * * creates a new padtemplate from the given arguments * @@ -855,7 +865,7 @@ gst_padtemplate_new (GstPadFactory *factory) GstPadTemplate* gst_padtemplate_create (gchar *name_template, GstPadDirection direction, GstPadPresence presence, - GstCaps *caps) + GList *caps) { GstPadTemplate *new; @@ -883,13 +893,21 @@ xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent) { xmlNodePtr subtree; + GList *caps; xmlNewChild(parent,NULL,"nametemplate", pad->name_template); xmlNewChild(parent,NULL,"direction", (pad->direction == GST_PAD_SINK? "sink":"src")); xmlNewChild(parent,NULL,"presence", (pad->presence == GST_PAD_ALWAYS? "always":"sometimes")); - subtree = xmlNewChild(parent,NULL,"caps", NULL); - gst_caps_save_thyself (pad->caps, subtree); + caps = pad->caps; + while (caps) { + GstCaps *cap = (GstCaps *)caps->data; + + subtree = xmlNewChild(parent,NULL,"caps", NULL); + gst_caps_save_thyself (cap, subtree); + + caps = g_list_next (caps); + } return parent; } @@ -934,7 +952,7 @@ gst_padtemplate_load_thyself (xmlNodePtr parent) } } else if (!strcmp(field->name, "caps")) { - factory->caps = gst_caps_load_thyself (field); + factory->caps = g_list_append(factory->caps, gst_caps_load_thyself (field)); } field = field->next; } diff --git a/gst/gstpad.h b/gst/gstpad.h index d404ffef10..6220115f8f 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -82,7 +82,7 @@ struct _GstPad { GstObject object; gchar *name; - GstCaps *caps; + GList *caps; cothread_state *threadstate; @@ -134,7 +134,7 @@ struct _GstPadTemplate { gchar *name_template; GstPadDirection direction; GstPadPresence presence; - GstCaps *caps; + GList *caps; }; struct _GstPadTemplateClass { @@ -148,12 +148,15 @@ struct _GstPadTemplateClass { /* factory */ typedef gpointer GstPadFactoryEntry; typedef GstPadFactoryEntry GstPadFactory[]; + #define GST_PAD_FACTORY_ALWAYS GINT_TO_POINTER(GST_PAD_ALWAYS) #define GST_PAD_FACTORY_SOMETIMES GINT_TO_POINTER(GST_PAD_SOMETIMES) #define GST_PAD_FACTORY_SRC GINT_TO_POINTER(GST_PAD_SRC) #define GST_PAD_FACTORY_SINK GINT_TO_POINTER(GST_PAD_SINK) +#define GST_PAD_FACTORY_CAPS(a...) GINT_TO_POINTER(1),##a,NULL + GtkType gst_pad_get_type (void); GstPad* gst_pad_new (gchar *name, GstPadDirection direction); @@ -167,8 +170,10 @@ void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get); void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion); void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos); -void gst_pad_set_caps (GstPad *pad, GstCaps *caps); -GstCaps* gst_pad_get_caps (GstPad *pad); +void gst_pad_set_caps_list (GstPad *pad, GList *caps); +GList* gst_pad_get_caps_list (GstPad *pad); +GstCaps* gst_pad_get_caps_by_name (GstPad *pad, gchar *name); +gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad); void gst_pad_set_name (GstPad *pad, const gchar *name); const gchar* gst_pad_get_name (GstPad *pad); @@ -213,7 +218,7 @@ GtkType gst_padtemplate_get_type (void); GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory); GstPadTemplate* gst_padtemplate_create (gchar *name_template, GstPadDirection direction, GstPadPresence presence, - GstCaps *caps); + GList *caps); xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent); GstPadTemplate* gst_padtemplate_load_thyself (xmlNodePtr parent); diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index 55d9e1e526..bb2bffc164 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -172,7 +172,7 @@ gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element) if (found) { caps = gst_util_get_pointer_arg (GTK_OBJECT (typefind), "caps"); - gst_pad_set_caps (gst_element_get_pad (element, "src"), caps); + gst_pad_set_caps_list (gst_element_get_pad (element, "src"), g_list_prepend (NULL, caps)); } gst_pad_disconnect (gst_element_get_pad (element, "src"), @@ -200,7 +200,7 @@ gst_pipeline_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink) if (sinkpad->direction == GST_PAD_SINK && !GST_PAD_CONNECTED(sinkpad)) { - if (gst_caps_check_compatibility (pad->caps, sinkpad->caps)) { + if (gst_caps_list_check_compatibility (pad->caps, sinkpad->caps)) { gst_pad_connect(pad, sinkpad); DEBUG("gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name, gst_element_get_name(src)); @@ -308,7 +308,6 @@ gst_pipeline_autoplug (GstPipeline *pipeline) GList **factories; GList **base_factories; GstElementFactory *factory; - GList *src_pads; GstCaps *src_caps = 0; guint i, numsinks; gboolean use_thread = FALSE, have_common = FALSE; @@ -352,14 +351,13 @@ gst_pipeline_autoplug (GstPipeline *pipeline) i = 0; // fase 2, loop over all the sinks.. while (elements) { - GList *pads; GstPad *pad; element = GST_ELEMENT(elements->data); pad = (GstPad *)gst_element_get_pad_list (element)->data; - base_factories[i] = factories[i] = gst_autoplug_caps (src_caps, pad->caps); + base_factories[i] = factories[i] = gst_autoplug_caps_list (g_list_append(NULL,src_caps), pad->caps); // if we have a succesfull connection, proceed if (factories[i] != NULL) i++; @@ -451,11 +449,11 @@ differ: // FIXME connect matching pads, not just the first one... if (sinkpad->direction == GST_PAD_SINK && !GST_PAD_CONNECTED(sinkpad)) { - GstCaps *caps = gst_pad_get_caps (sinkpad); + GList *caps = gst_pad_get_caps_list (sinkpad); // the queue has the type of the elements it connects - gst_pad_set_caps (srcpad, caps); - gst_pad_set_caps (gst_element_get_pad(queue, "sink"), caps); + gst_pad_set_caps_list (srcpad, caps); + gst_pad_set_caps_list (gst_element_get_pad(queue, "sink"), caps); break; } sinkpads = g_list_next(sinkpads); diff --git a/gst/gstplugin.c b/gst/gstplugin.c index f5c5009602..4bb90a71cd 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -459,6 +459,7 @@ gst_plugin_load_typefactory (gchar *mime) gchar *pluginname = g_strdup (plugin->name); INFO(GST_INFO_PLUGIN_LOADING,"loading type factory for \"%s\" from plugin %s",mime,plugin->name); + plugin->loaded = TRUE; gst_plugin_remove(plugin); if (!gst_plugin_load_absolute(filename)) { DEBUG("gstplugin: error loading type factory \"%s\" from plugin %s\n", mime, pluginname); diff --git a/gst/gstprops.c b/gst/gstprops.c index 766b0e4315..b4894fc2b1 100644 --- a/gst/gstprops.c +++ b/gst/gstprops.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#define GST_DEBUG_ENABLED +//#define GST_DEBUG_ENABLED #include "gst_private.h" #include "gstprops.h" @@ -107,17 +107,34 @@ props_compare_func (gconstpointer a, */ GstProps * gst_props_register (GstPropsFactory factory) +{ + guint dummy; + + return gst_props_register_count (factory, &dummy); +} + +/** + * gst_props_register_count: + * @factory: the factory to register + * @counter: count how many fields were consumed + * + * Register the factory. + * + * Returns: The new property created from the factory + */ +GstProps * +gst_props_register_count (GstPropsFactory factory, guint *counter) { GstPropsFactoryEntry tag; gint i = 0; - GstProps *props; + GstProps *props = NULL; gint skipped; g_return_val_if_fail (factory != NULL, NULL); tag = factory[i++]; - if (!tag) return NULL; + if (!tag) goto end; props = g_new0 (GstProps, 1); g_return_val_if_fail (props != NULL, NULL); @@ -128,6 +145,11 @@ gst_props_register (GstPropsFactory factory) GQuark quark; GstPropsEntry *entry; + if (tag < GST_PROPS_LAST_ID) { + g_warning ("properties seem to be wrong\n"); + return NULL; + } + quark = g_quark_from_string ((gchar *)tag); tag = factory[i]; @@ -167,6 +189,9 @@ gst_props_register (GstPropsFactory factory) tag = factory[i++]; } +end: + *counter = i; + return props; } diff --git a/gst/gstprops.h b/gst/gstprops.h index c60c7646fb..bdfb20d66c 100644 --- a/gst/gstprops.h +++ b/gst/gstprops.h @@ -40,6 +40,7 @@ typedef enum { GST_PROPS_INT_RANGE_ID_NUM, GST_PROPS_FOURCC_ID_NUM, GST_PROPS_BOOL_ID_NUM, + GST_PROPS_LAST_ID_NUM = GST_PROPS_END_ID_NUM + 16, } GstPropsId; #define GST_PROPS_END_ID GINT_TO_POINTER(GST_PROPS_END_ID_NUM) @@ -48,6 +49,7 @@ typedef enum { #define GST_PROPS_INT_RANGE_ID GINT_TO_POINTER(GST_PROPS_INT_RANGE_ID_NUM) #define GST_PROPS_FOURCC_ID GINT_TO_POINTER(GST_PROPS_FOURCC_ID_NUM) #define GST_PROPS_BOOL_ID GINT_TO_POINTER(GST_PROPS_BOOL_ID_NUM) +#define GST_PROPS_LAST_ID GINT_TO_POINTER(GST_PROPS_LAST_ID_NUM) #define GST_PROPS_LIST(a...) GST_PROPS_LIST_ID,##a,NULL #define GST_PROPS_INT(a) GST_PROPS_INT_ID,(GINT_TO_POINTER(a)) @@ -65,6 +67,7 @@ struct _GstProps { void _gst_props_initialize (void); GstProps* gst_props_register (GstPropsFactory factory); +GstProps* gst_props_register_count (GstPropsFactory factory, guint *counter); GstProps* gst_props_new (GstPropsFactoryEntry entry, ...); diff --git a/plugins/elements/gstaudiosink.c b/plugins/elements/gstaudiosink.c index c2ac249952..0249a3e126 100644 --- a/plugins/elements/gstaudiosink.c +++ b/plugins/elements/gstaudiosink.c @@ -74,14 +74,17 @@ static GstPadFactory audiosink_sink_factory = { "sink", GST_PAD_FACTORY_SINK, GST_PAD_FACTORY_ALWAYS, - "audio/raw", - "format", GST_PROPS_INT (AFMT_S16_LE), - "depth", GST_PROPS_LIST ( - GST_PROPS_INT (8), + GST_PAD_FACTORY_CAPS ( + "audiosink_sink", + "audio/raw", + "format", GST_PROPS_INT (AFMT_S16_LE), + "depth", GST_PROPS_LIST ( + GST_PROPS_INT (8), GST_PROPS_INT (16) - ), - "rate", GST_PROPS_INT_RANGE (8000, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2), + ), + "rate", GST_PROPS_INT_RANGE (8000, 48000), + "channels", GST_PROPS_INT_RANGE (1, 2) + ), NULL }; diff --git a/tests/Makefile.am b/tests/Makefile.am index c217c2ef99..19826ae08f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip mp3encode autoplug props case4 +noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip mp3encode autoplug props case4 padfactory LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la CFLAGS = -Wall diff --git a/tests/autoplug.c b/tests/autoplug.c index e418adb451..f6dcb1be39 100644 --- a/tests/autoplug.c +++ b/tests/autoplug.c @@ -5,8 +5,8 @@ autoplug_caps (gchar *mime1, gchar *mime2) { GstCaps *caps1, *caps2; - caps1 = gst_caps_new (mime1); - caps2 = gst_caps_new (mime2); + caps1 = gst_caps_new ("tescaps1", mime1); + caps2 = gst_caps_new ("tescaps2", mime2); return gst_autoplug_caps (caps1, caps2); } @@ -39,21 +39,25 @@ int main(int argc,char *argv[]) factories = gst_autoplug_caps ( gst_caps_new_with_props( + "testcaps3", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (TRUE), NULL)), - gst_caps_new("audio/raw")); + gst_caps_new("testcaps4","audio/raw")); dump_factories (factories); factories = gst_autoplug_caps ( gst_caps_new_with_props( + "testcaps5", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (FALSE), NULL)), - gst_caps_new("video/raw")); + gst_caps_new("testcaps6", "video/raw")); dump_factories (factories); + + exit (0); } diff --git a/tests/caps.c b/tests/caps.c index 4a8c76bb90..bbd4d1ab0d 100644 --- a/tests/caps.c +++ b/tests/caps.c @@ -1,12 +1,7 @@ #include -static GstTypeFactory mpegfactory = { - "video/mpeg", // major type - ".mpg .mpeg", // extenstions - NULL, // typefind function -}; - static GstCapsFactory mpeg2dec_sink_caps = { + "mpeg2dec_sink", "video/mpeg", "mpegtype", GST_PROPS_LIST ( GST_PROPS_INT(1), @@ -16,6 +11,7 @@ static GstCapsFactory mpeg2dec_sink_caps = { }; static GstCapsFactory mp1parse_src_caps = { + "mp1parse_src", "video/mpeg", "mpegtype", GST_PROPS_LIST ( GST_PROPS_INT(1) @@ -24,6 +20,7 @@ static GstCapsFactory mp1parse_src_caps = { }; static GstCapsFactory mpeg2dec_src_caps = { + "mpeg2dec_src", "video/raw", "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC ('Y','V','1','2'), @@ -35,6 +32,7 @@ static GstCapsFactory mpeg2dec_src_caps = { }; static GstCapsFactory raw_sink_caps = { + "raw_sink_caps", "video/raw", "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC_INT (0x32315659) @@ -44,6 +42,7 @@ static GstCapsFactory raw_sink_caps = { }; static GstCapsFactory raw2_sink_caps = { + "raw2_sink_caps", "video/raw", "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC_INT (0x32315659), @@ -58,7 +57,6 @@ static GstCaps *sinkcaps = NULL, *rawcaps = NULL, *rawcaps2 = NULL, *rawcaps3 = NULL, - *sinkcapslist = NULL, *mp1parsecaps = NULL; int main(int argc,char *argv[]) diff --git a/tests/case4.c b/tests/case4.c index a24c137869..d681d960c1 100644 --- a/tests/case4.c +++ b/tests/case4.c @@ -4,7 +4,6 @@ int main(int argc,char *argv[]) { GstBin *thread; GstElement *src,*identity,*sink; - int i; DEBUG_ENTER("(%d)",argc); @@ -31,4 +30,6 @@ int main(int argc,char *argv[]) { gst_bin_iterate(thread); gst_bin_iterate(thread); + + exit(0); } diff --git a/tests/init.c b/tests/init.c index a66c5e59d1..04984c9ff1 100644 --- a/tests/init.c +++ b/tests/init.c @@ -2,4 +2,6 @@ int main(int argc,char *argv[]) { gst_init(&argc,&argv); + + exit (0); } diff --git a/tests/old/examples/autoplug/autoplug.c b/tests/old/examples/autoplug/autoplug.c index 4bc26cf48e..b5e2866a5c 100644 --- a/tests/old/examples/autoplug/autoplug.c +++ b/tests/old/examples/autoplug/autoplug.c @@ -4,7 +4,7 @@ static gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstSrc *src) +void eos(GstElement *src) { g_print("have eos, quitting\n"); diff --git a/tests/queue.c b/tests/queue.c index 7cda7dc365..980a32318b 100644 --- a/tests/queue.c +++ b/tests/queue.c @@ -13,7 +13,7 @@ int main(int argc,char *argv[]) { // thr1 = gst_bin_new("thr1"); g_return_val_if_fail(2,thr1 != NULL); // thr2 = GST_BIN(gst_thread_new("thr2")); - thr2 = gst_bin_new("thr2"); + thr2 = GST_BIN(gst_bin_new("thr2")); g_return_val_if_fail(3,thr2 != NULL); fprintf(stderr,"QUEUE: fakesrc\n"); src = gst_elementfactory_make("fakesrc","src"); @@ -41,8 +41,8 @@ fprintf(stderr,"QUEUE: fakesink\n"); gst_bin_add(pipeline,GST_ELEMENT(queue)); gst_bin_add(pipeline,GST_ELEMENT(thr2)); fprintf(stderr,"QUEUE: connecting elements\n"); - gst_element_connect(thr1,"src",queue,"sink"); - gst_element_connect(queue,"src",thr2,"sink"); + gst_element_connect(GST_ELEMENT(thr1),"src",queue,"sink"); + gst_element_connect(queue,"src",GST_ELEMENT(thr2),"sink"); // gst_pad_connect(gst_element_get_pad(src,"src"),gst_element_get_pad(queue,"sink")); // gst_pad_connect(gst_element_get_pad(queue,"src"),gst_element_get_pad(sink,"sink")); fprintf(stderr,"QUEUE: constructed outer pipeline\n"); @@ -59,4 +59,6 @@ fprintf(stderr,"QUEUE: fakesink\n"); // fflush(stdout); // fflush(stderr); // gst_bin_iterate(thr2); +// + exit (0); } diff --git a/tests/simplefake.c b/tests/simplefake.c index ff86d3fdb2..9d1a059ec4 100644 --- a/tests/simplefake.c +++ b/tests/simplefake.c @@ -2,7 +2,7 @@ #include int main(int argc,char *argv[]) { - GstPipeline *pipeline; + GstElement *pipeline; GstElement *src,*identity,*sink; int i; @@ -39,4 +39,6 @@ int main(int argc,char *argv[]) { fprintf(stderr,"\n"); gst_bin_iterate(GST_BIN(pipeline)); } + + exit (0); } diff --git a/tests/states.c b/tests/states.c index e5139af9bd..211bec0330 100644 --- a/tests/states.c +++ b/tests/states.c @@ -4,6 +4,8 @@ gboolean state_change(GstElement *element,GstElementState state) { g_print(">STATES: element '%s' state set to %d(%s)\n", gst_element_get_name(element),state,_gst_print_statename(state)); g_print(">STATES: element state is actually %d\n",GST_STATE(element)); + + return TRUE; } int main(int argc,char *argv[]) { @@ -61,4 +63,6 @@ int main(int argc,char *argv[]) { gst_element_set_state (bin, GST_STATE_PLAYING); gst_bin_iterate (GST_BIN (bin)); + + exit (0); }