From b38d9a945b327aee08cbafe95c3d7c72d7d5e024 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 14 Apr 2001 18:56:37 +0000 Subject: [PATCH] A rather large patch: Original commit message from CVS: A rather large patch: - changed the API for the padtemplates: - remove the factories (array of pointers) for the padtemplates, properties and caps. The static array was a nice idea but converting all the property values to a gpointer was not a good idea. float properties were not possible, and casting a gint to a pointer is not very portable. The new API just uses the _padtemplate_new, _caps_new and _props_new functions to create the templates. This has the added benefit that the API is now uniform for static and dynamic templates and that the code can be made cleaner. - lots of cleanups in the way the capabilities are constructed (va_list) - lots of updates for all the plugins (new API) - docs updates (new API) - removed the videoraw docs. --- docs/gst/gstreamer-sections.txt | 35 +- docs/gst/tmpl/gstcaps.sgml | 49 --- docs/gst/tmpl/gstpad.sgml | 70 +--- docs/gst/tmpl/gstprops.sgml | 64 +--- docs/gst/tmpl/gstreamer-unused.sgml | 153 +++++++++ docs/gst/tmpl/videoraw.sgml | 64 ---- editor/gsteditorproperty.c | 22 +- examples/plugins/example.c | 63 ++-- gst/elements/gsttee.c | 20 +- gst/gstcaps.c | 81 +---- gst/gstcaps.h | 11 +- gst/gstpad.c | 63 +--- gst/gstpad.h | 20 +- gst/gstplugin.c | 2 + gst/gstprops.c | 468 +++++++++------------------ gst/gstprops.h | 56 ++-- gst/meta/Makefile.am | 2 +- gstplay/Makefile.am | 5 +- gstplay/gstplay.c | 2 + plugins/elements/gsttee.c | 20 +- tests/autoplug.c | 2 +- tests/autoplug2.c | 34 +- tests/autoplug3.c | 36 +-- tests/caps.c | 159 ++++++--- tests/old/examples/plugins/example.c | 63 ++-- tests/props.c | 29 +- tools/gstreamer-inspect.c | 12 +- 27 files changed, 651 insertions(+), 954 deletions(-) delete mode 100644 docs/gst/tmpl/videoraw.sgml diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index ce1b13225e..ca9923f14c 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -444,15 +444,6 @@ GST_GPAD_REALPAD GstGhostPad gst_ghost_pad_new -GstPadFactoryEntry -GstPadFactory[] -GST_PAD_FACTORY_SOMETIMES -GST_PAD_FACTORY_ALWAYS -GST_PAD_FACTORY_REQUEST -GST_PAD_FACTORY_SINK -GST_PAD_FACTORY_SRC -GST_PAD_FACTORY_CAPS - GstPadPresence GstPadTemplate GST_PADTEMPLATE_CAPS @@ -460,7 +451,6 @@ GST_PADTEMPLATE_DIRECTION GST_PADTEMPLATE_NAME_TEMPLATE GST_PADTEMPLATE_PRESENCE gst_padtemplate_new -gst_padtemplate_create gst_padtemplate_load_thyself gst_padtemplate_save_thyself gst_padtemplate_get_caps @@ -498,7 +488,6 @@ GST_PADTEMPLATE_CLASS GST_IS_PADTEMPLATE GST_IS_PADTEMPLATE_CLASS gst_padtemplate_get_type -GST_PAD_FACTORY_CAPS_ID
@@ -627,16 +616,10 @@ GST_CAPS_LOCK GST_CAPS_TRYLOCK GST_CAPS_UNLOCK GstCaps -GstCapsFactory -GstCapsFactoryEntry -GstCapsFactory[] gst_caps_new -gst_caps_new_with_props gst_caps_destroy gst_caps_ref gst_caps_unref -gst_caps_register -gst_caps_register_count gst_caps_copy gst_caps_copy_on_write gst_caps_append @@ -668,8 +651,6 @@ GST_CAPS gstprops GstProps GstProps -GstPropsFactoryEntry -GstPropsFactory[] GST_MAKE_FOURCC GST_PROPS_LIST GST_PROPS_INT @@ -679,11 +660,8 @@ GST_PROPS_BOOLEAN GST_PROPS_STRING GST_PROPS_FLOAT GST_PROPS_FLOAT_RANGE -GST_PROPS_FLOAT_STRING -GST_PROPS_FLOAT_RANGE_STRING -gst_props_register -gst_props_register_count gst_props_new +gst_props_newv gst_props_merge gst_props_copy gst_props_copy_on_write @@ -700,18 +678,7 @@ gst_props_save_thyself gst_props_load_thyself GstPropsEntry -GstPropsListFactory[] GstPropsId -GST_PROPS_END_ID -GST_PROPS_LIST_ID -GST_PROPS_INT_ID -GST_PROPS_INT_RANGE_ID -GST_PROPS_FOURCC_ID -GST_PROPS_BOOL_ID -GST_PROPS_STRING_ID -GST_PROPS_LAST_ID -GST_PROPS_FLOAT_ID -GST_PROPS_FLOAT_RANGE_ID
diff --git a/docs/gst/tmpl/gstcaps.sgml b/docs/gst/tmpl/gstcaps.sgml index a5064dfade..9f1e9f3fc4 100644 --- a/docs/gst/tmpl/gstcaps.sgml +++ b/docs/gst/tmpl/gstcaps.sgml @@ -51,39 +51,11 @@ Unlock the caps structure @properties: the properties of the capability @next: a pointer to the next caps. - - - - - - - - - - - - - - - - - - -@name: -@mime: -@Returns: - - - - - - - @name: @mime: @props: @@ -114,27 +86,6 @@ Unlock the caps structure @caps: - - - - - -@factory: -@Returns: - - - - - - - -@factory: -@counter: -@Returns: - -@count: - - diff --git a/docs/gst/tmpl/gstpad.sgml b/docs/gst/tmpl/gstpad.sgml index cccdb1ab38..bc51b8eb22 100644 --- a/docs/gst/tmpl/gstpad.sgml +++ b/docs/gst/tmpl/gstpad.sgml @@ -797,64 +797,6 @@ Get the real pad of this ghost pad. @Returns: - - -Defines an entry for a padfactory. - - - - - -The padfactory. - - - - - -Indicate that this pad will become available depending -on the media type. Use this in the factory definition. - - - - - - -Indicate that this pad will always be available. -Use this in the factory definition. - - - - - - -Indicates that this pad will be available on request. Use -this in the factory definition. - - - - - - -Indicates a sinkpad for the padfactory. - - - - - - -Indicates a srcpad for the padfactory. - - - - - - -Starts the declaration of a the capabilities for this padtemplate. - - -@a...: a capability factory - - Indicates when this pad will become available. @@ -912,20 +854,14 @@ Indicates when this pad will become available. -@factory: -@Returns: - - - - - - - @name_template: @direction: @presence: @caps: +@Varargs: @Returns: + +@factory: diff --git a/docs/gst/tmpl/gstprops.sgml b/docs/gst/tmpl/gstprops.sgml index f3899645e1..2c5f0eaf16 100644 --- a/docs/gst/tmpl/gstprops.sgml +++ b/docs/gst/tmpl/gstprops.sgml @@ -24,18 +24,6 @@ GstCaps @lock: @properties: the properties - - - - - - - - - - - - @@ -117,50 +105,26 @@ Create a boolean property. @b: - - - - - -@a: - - - - - - - -@a: -@b: - - - - - - - -@factory: -@Returns: - - - - - - - -@factory: -@counter: -@Returns: - - -@entry: +@firstname: @Varargs: @Returns: + +@entry: + + + + + + + +@firstname: +@var_args: +@Returns: @@ -235,10 +199,10 @@ Create a boolean property. @props: @name: -@entry: @Varargs: @Returns: +@entry: @value: diff --git a/docs/gst/tmpl/gstreamer-unused.sgml b/docs/gst/tmpl/gstreamer-unused.sgml index 80ebffdaab..c750b5e1da 100644 --- a/docs/gst/tmpl/gstreamer-unused.sgml +++ b/docs/gst/tmpl/gstreamer-unused.sgml @@ -207,6 +207,12 @@ the stream. @Returns: + + + + + + @@ -226,6 +232,17 @@ the stream. + + + + + +@name_template: +@direction: +@presence: +@caps: +@Returns: + @@ -610,6 +627,12 @@ Specify the current offset in the file. @Returns: + + + + + + @@ -899,6 +922,12 @@ The fequency. @obj: + + + + + + The buffer is sent to the sound card. @@ -960,6 +989,16 @@ The buffer is sent to the sound card. + + + + + +@factory: +@counter: +@Returns: +@count: + @@ -1151,6 +1190,12 @@ Flags for the GstSrc element GstColorSpace + + +Defines an entry for a padfactory. + + + @@ -1218,6 +1263,12 @@ GstColorSpace @Returns: + + +Indicates a sinkpad for the padfactory. + + + @@ -1376,6 +1427,13 @@ This macro sets the given flags. + + + + + +@a: + @@ -1444,6 +1502,12 @@ The frequency. + + +Indicates a srcpad for the padfactory. + + + @@ -1553,6 +1617,13 @@ The frequency. @name: @Returns: + + +Starts the declaration of a the capabilities for this padtemplate. + + +@a...: a capability factory + GstSrc @@ -1573,6 +1644,16 @@ GstSrc @pad: @buf: + + + + + +@name: +@mime: +@props: +@Returns: + @@ -1750,6 +1831,14 @@ Query whether this object has multiple input pads. + + + + + +@factory: +@Returns: + @@ -1796,6 +1885,12 @@ Information about video buffers. @klass: + + + + + + @@ -2051,6 +2146,23 @@ The start point of a filter graph @src: + + + + + +@factory: +@counter: +@Returns: + + + + + + +@a: +@b: + @@ -2110,6 +2222,13 @@ The start point of a filter graph @klass: <<<<<<< gstreamer-unused.sgml + + +Indicates that this pad will be available on request. Use +this in the factory definition. + + + @@ -2147,6 +2266,13 @@ This macro unsets the given state on the element. @pad: @id: + + +Indicate that this pad will always be available. +Use this in the factory definition. + + + @@ -2396,6 +2522,12 @@ Information about audio buffers. Take data in and spit data out + + +The padfactory. + + + This macro checks to see if the GST_SRC_ASYNC flag is set. @@ -2409,6 +2541,12 @@ This macro checks to see if the GST_SRC_ASYNC flag is set. + + + + + + @@ -2515,6 +2653,14 @@ Information about audio buffers. + + + + + +@factory: +@Returns: + @@ -2561,6 +2707,13 @@ Specify the location of the file to read. GstAudioSrc + + +Indicate that this pad will become available depending +on the media type. Use this in the factory definition. + + + diff --git a/docs/gst/tmpl/videoraw.sgml b/docs/gst/tmpl/videoraw.sgml deleted file mode 100644 index fda469c05b..0000000000 --- a/docs/gst/tmpl/videoraw.sgml +++ /dev/null @@ -1,64 +0,0 @@ - -videoraw - - -Information about video buffers. - - - -Information about video buffers. - - - - - - - - - - - - -@meta: -@format: -@visual: -@width: -@height: -@overlay_info: -@dga_info: - - - - - - -@base: -@swidth: -@sheight: -@bytes_per_line: - - - - - - -@wx: -@wy: -@overlay_element: -@clip_count: -@overlay_clip: -@width: -@height: -@did_overlay: -@fully_obscured: - - - - - - -@x1: -@x2: -@y1: -@y2: - diff --git a/editor/gsteditorproperty.c b/editor/gsteditorproperty.c index ca77aeda58..9a787ce7e8 100644 --- a/editor/gsteditorproperty.c +++ b/editor/gsteditorproperty.c @@ -248,16 +248,16 @@ static gchar* gst_editor_props_show_func (GstPropsEntry *entry) { switch (entry->propstype) { - case GST_PROPS_INT_ID_NUM: + case GST_PROPS_INT_ID: return g_strdup_printf ("%d", entry->data.int_data); break; - case GST_PROPS_INT_RANGE_ID_NUM: + case GST_PROPS_INT_RANGE_ID: return g_strdup_printf ("%d-%d", entry->data.int_range_data.min, entry->data.int_range_data.max); break; - case GST_PROPS_FOURCC_ID_NUM: + case GST_PROPS_FOURCC_ID: return g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data); break; - case GST_PROPS_BOOL_ID_NUM: + case GST_PROPS_BOOL_ID: return g_strdup_printf ("%s", (entry->data.bool_data ? "TRUE" : "FALSE")); break; default: @@ -272,7 +272,7 @@ gst_editor_add_caps_to_tree (GstCaps *caps, GtkWidget *tree, GtkCTreeNode *padno if (caps) { GstProps *props = gst_caps_get_props (caps); if (props) { - GSList *propslist = props->properties; + GList *propslist = props->properties; while (propslist) { gchar *data[2]; @@ -281,7 +281,7 @@ gst_editor_add_caps_to_tree (GstCaps *caps, GtkWidget *tree, GtkCTreeNode *padno data[0] = g_quark_to_string (entry->propid); switch (entry->propstype) { - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: { GList *list; guint count = 0; @@ -303,7 +303,7 @@ gst_editor_add_caps_to_tree (GstCaps *caps, GtkWidget *tree, GtkCTreeNode *padno gtk_ctree_insert_node (GTK_CTREE (tree), padnode, NULL, data, 0, NULL, NULL, NULL, NULL, TRUE, TRUE); - propslist = g_slist_next (propslist); + propslist = g_list_next (propslist); } } } @@ -357,14 +357,14 @@ gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element) pads = gst_element_get_padtemplate_list(realelement); while (pads) { GstPadTemplate *templ = (GstPadTemplate *)pads->data; - GList *caps = templ->caps; + GstCaps *caps = templ->caps; gchar *mime; gchar *data[2]; GtkCTreeNode *padnode; if (caps) { GstType *type; - type = gst_type_find_by_id (((GstCaps *)caps->data)->id); + type = gst_type_find_by_id (((GstCaps *)caps)->id); mime = type->mime; } else { @@ -377,11 +377,11 @@ gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element) NULL, NULL, NULL, NULL, FALSE, TRUE); while (caps) { - GstCaps *cap = (GstCaps *)caps->data; + GstCaps *cap = (GstCaps *)caps; gst_editor_add_caps_to_tree (cap, tree, padnode); - caps = g_list_next (caps); + caps = (caps)->next; } pads = g_list_next (pads); diff --git a/examples/plugins/example.c b/examples/plugins/example.c index dbe5b28794..75e5c78ce6 100644 --- a/examples/plugins/example.c +++ b/examples/plugins/example.c @@ -57,34 +57,41 @@ enum { * can have. They can be quite complex, but for this example plugin * they are rather simple. */ -static GstPadFactory sink_factory = { - "sink", /* The name of the pad */ - GST_PAD_FACTORY_SINK, /* Direction of the pad */ - GST_PAD_FACTORY_ALWAYS, /* The pad exists for every instance */ - GST_PAD_FACTORY_CAPS( /* This factory has specific capabilities */ - "example_sink", /* The name of the caps */ - "unknown/unknown", /* The overall MIME/type */ - "foo", GST_PROPS_INT (1), /* An integer property */ - "bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */ - "baz", GST_PROPS_LIST ( /* A list of values for */ - GST_PROPS_INT (1), - GST_PROPS_INT (3) - ) - ), - NULL /* All factories must be NULL-terminated */ -}; +static GstPadTemplate* +sink_factory (void) +{ + return + gst_padtemplate_new ( + "sink", /* The name of the pad */ + GST_PAD_SINK, /* Direction of the pad */ + GST_PAD_ALWAYS, /* The pad exists for every instance */ + gst_caps_new ( + "example_sink", /* The name of the caps */ + "unknown/unknown", /* The overall MIME/type */ + gst_props_new ( + "foo", GST_PROPS_INT (1), /* An integer property */ + "bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */ + "baz", GST_PROPS_LIST ( /* A list of values for */ + GST_PROPS_INT (1), + GST_PROPS_INT (3) + ), + NULL))); +} /* This factory is much simpler, and defines the source pad. */ -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "example_src", - "unknown/unknown" - ), - NULL -}; +static GstPadTemplate* +src_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "example_src", + "unknown/unknown", + NULL)); +} /* A number of functon prototypes are given so we can refer to them later. */ @@ -351,10 +358,10 @@ plugin_init (GModule *module) * Note that the generated padtemplates are stored in static global * variables, for the gst_example_init function to use later on. */ - sink_template = gst_padtemplate_new (&sink_factory); + sink_template = sink_factory (); gst_elementfactory_add_padtemplate (factory, sink_template); - src_template = gst_padtemplate_new (&src_factory); + src_template = src_factory (); gst_elementfactory_add_padtemplate (factory, src_template); /* The very last thing is to register the elementfactory with the plugin. */ diff --git a/gst/elements/gsttee.c b/gst/elements/gsttee.c index d444217367..67ab4b1541 100644 --- a/gst/elements/gsttee.c +++ b/gst/elements/gsttee.c @@ -45,13 +45,17 @@ enum { /* FILL ME */ }; -static GstPadFactory tee_src_factory = { - "src%d", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_REQUEST, - NULL, /* no caps */ - NULL, -}; +static GstPadTemplate* +tee_src_factory_create (void) +{ + return + gst_padtemplate_new ( + "src%d", + GST_PAD_SRC, + GST_PAD_REQUEST, + NULL /* no caps */ + ); +} static void gst_tee_class_init (GstTeeClass *klass); @@ -197,7 +201,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf) gboolean gst_tee_factory_init (GstElementFactory *factory) { - gst_tee_src_template = gst_padtemplate_new (&tee_src_factory); + gst_tee_src_template = tee_src_factory_create (); gst_elementfactory_add_padtemplate (factory, gst_tee_src_template); return TRUE; diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 31e7b5ef04..c77d9bdafb 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -62,13 +62,14 @@ get_type_for_mime (const gchar *mime) * gst_caps_new: * @name: the name of this capability * @mime: the mime type to attach to the capability + * @props: the properties to add to this capability * - * Create a new capability with the given mime type. + * Create a new capability with the given mime typei and properties. * * Returns: a new capability */ GstCaps* -gst_caps_new (const gchar *name, const gchar *mime) +gst_caps_new (const gchar *name, const gchar *mime, GstProps *props) { GstCaps *caps; @@ -80,7 +81,7 @@ gst_caps_new (const gchar *name, const gchar *mime) caps->name = g_strdup (name); caps->id = get_type_for_mime (mime); - caps->properties = NULL; + caps->properties = props; caps->next = NULL; caps->refcount = 1; caps->lock = g_mutex_new (); @@ -88,78 +89,6 @@ gst_caps_new (const gchar *name, const gchar *mime) return caps; } -/** - * 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 - * - * Create a new capability with the given mime type and the given properties. - * - * Returns: a new capability - */ -GstCaps* -gst_caps_new_with_props (const gchar *name, const gchar *mime, GstProps *props) -{ - GstCaps *caps; - - caps = gst_caps_new (name, mime); - caps->properties = props; - - return caps; -} - -/** - * gst_caps_register: - * @factory: the factory to register - * - * Register the factory. - * - * Returns: the registered capability - */ -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; - 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); - - caps = gst_caps_new_with_props (name, (gchar *)tag, - gst_props_register_count (&(*factory)[i], counter)); - - *counter += 2; - - return caps; -} - /** * gst_caps_destroy: * @caps: the caps to destroy @@ -244,7 +173,7 @@ gst_caps_copy (GstCaps *caps) g_return_val_if_fail (caps != NULL, NULL); GST_CAPS_LOCK (caps); - new = gst_caps_new_with_props ( + new = gst_caps_new ( caps->name, (gst_type_find_by_id (caps->id))->mime, gst_props_copy (caps->properties)); diff --git a/gst/gstcaps.h b/gst/gstcaps.h index ff7ab84a67..c3c619ec9d 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -36,12 +36,6 @@ #include typedef struct _GstCaps GstCaps; -typedef gpointer GstCapsFactoryEntry; -#ifdef __cplusplus -typedef GstCapsFactoryEntry * GstCapsFactory; -#else // C++ was unable to compile with this -typedef GstCapsFactoryEntry GstCapsFactory[]; -#endif #define GST_CAPS(caps) \ ((GstCaps *)(caps)) @@ -65,10 +59,7 @@ struct _GstCaps { /* initialize the subsystem */ void _gst_caps_initialize (void); -GstCaps* gst_caps_new (const gchar *name, const gchar *mime); -GstCaps* gst_caps_new_with_props (const gchar *name, const gchar *mime, GstProps *props); -GstCaps* gst_caps_register (GstCapsFactory *factory); -GstCaps* gst_caps_register_count (GstCapsFactory *factory, guint *counter); +GstCaps* gst_caps_new (const gchar *name, const gchar *mime, GstProps *props); void gst_caps_unref (GstCaps *caps); void gst_caps_ref (GstCaps *caps); diff --git a/gst/gstpad.c b/gst/gstpad.c index eca7d5fe2f..c71757cf09 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1396,48 +1396,6 @@ gst_padtemplate_init (GstPadTemplate *templ) { } -/** - * gst_padtemplate_new: - * @factory: the padfactory to use - * - * Creates a new padtemplate from the factory. - * - * Returns: the new padtemplate - */ -GstPadTemplate* -gst_padtemplate_new (GstPadFactory *factory) -{ - GstPadTemplate *new; - GstPadFactoryEntry tag; - gint i = 0; - guint counter = 0; - - g_return_val_if_fail (factory != NULL, NULL); - - new = gtk_type_new (gst_padtemplate_get_type ()); - - tag = (*factory)[i++]; - g_return_val_if_fail (tag != NULL, new); - new->name_template = g_strdup ((gchar *)tag); - - tag = (*factory)[i++]; - new->direction = GPOINTER_TO_UINT (tag); - - tag = (*factory)[i++]; - new->presence = GPOINTER_TO_UINT (tag); - - tag = (*factory)[i++]; - - while (GPOINTER_TO_INT (tag) == GST_PAD_FACTORY_CAPS_ID) { - GST_PADTEMPLATE_CAPS (new) = gst_caps_append (GST_PADTEMPLATE_CAPS (new), - gst_caps_register_count ((GstCapsFactory *)&(*factory)[i], &counter)); - i+=counter; - tag = (*factory)[i++]; - } - - return new; -} - /** * gst_padtemplate_create: * @name_template: the name template @@ -1450,11 +1408,13 @@ gst_padtemplate_new (GstPadFactory *factory) * Returns: the new padtemplate */ GstPadTemplate* -gst_padtemplate_create (gchar *name_template, - GstPadDirection direction, GstPadPresence presence, - GstCaps *caps) +gst_padtemplate_new (gchar *name_template, + GstPadDirection direction, GstPadPresence presence, + GstCaps *caps, ...) { GstPadTemplate *new; + va_list var_args; + GstCaps *thecaps = NULL; g_return_val_if_fail (name_template != NULL, NULL); @@ -1463,7 +1423,16 @@ gst_padtemplate_create (gchar *name_template, GST_PADTEMPLATE_NAME_TEMPLATE (new) = name_template; GST_PADTEMPLATE_DIRECTION (new) = direction; GST_PADTEMPLATE_PRESENCE (new) = presence; - GST_PADTEMPLATE_CAPS (new) = caps; + + va_start (var_args, caps); + + while (caps) { + thecaps = gst_caps_append (thecaps, caps); + caps = va_arg (var_args, GstCaps*); + } + va_end (var_args); + + GST_PADTEMPLATE_CAPS (new) = thecaps; return new; } @@ -1581,7 +1550,7 @@ gst_padtemplate_load_thyself (xmlNodePtr parent) field = field->next; } - factory = gst_padtemplate_create (name_template, direction, presence, caps); + factory = gst_padtemplate_new (name_template, direction, presence, caps, NULL); return factory; } diff --git a/gst/gstpad.h b/gst/gstpad.h index 2b915ac8fa..a1332df37f 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -253,21 +253,6 @@ 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_REQUEST GINT_TO_POINTER(GST_PAD_REQUEST) - -#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_ID 1 -#define GST_PAD_FACTORY_CAPS(a...) GINT_TO_POINTER(GST_PAD_FACTORY_CAPS_ID),##a,NULL - - GtkType gst_pad_get_type (void); GtkType gst_real_pad_get_type (void); GtkType gst_ghost_pad_get_type (void); @@ -348,10 +333,9 @@ GstPad * gst_ghost_pad_new (gchar *name,GstPad *pad); /* templates and factories */ GtkType gst_padtemplate_get_type (void); -GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory); -GstPadTemplate* gst_padtemplate_create (gchar *name_template, +GstPadTemplate* gst_padtemplate_new (gchar *name_template, GstPadDirection direction, GstPadPresence presence, - GstCaps *caps); + GstCaps *caps, ...); GstCaps* gst_padtemplate_get_caps (GstPadTemplate *templ); GstCaps* gst_padtemplate_get_caps_by_name (GstPadTemplate *templ, const gchar *name); diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 6aa4c1b674..2e5362a2ae 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -364,6 +364,8 @@ gst_plugin_load_absolute (const gchar *name) module = g_module_open(name,G_MODULE_BIND_LAZY); if (module != NULL) { if (g_module_symbol(module,"plugin_init",(gpointer *)&initfunc)) { + GST_INFO (GST_CAT_PLUGIN_LOADING,"loading plugin \"%s\"...", + name); if ((plugin = (initfunc)(module))) { GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" loaded: %d elements, %d types", plugin->name,plugin->numelements,plugin->numtypes); diff --git a/gst/gstprops.c b/gst/gstprops.c index 5ba3eeec43..94a823bd82 100644 --- a/gst/gstprops.c +++ b/gst/gstprops.c @@ -34,18 +34,6 @@ static GMutex *_gst_props_chunk_lock; static gboolean gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry2); -static guint _arg_len[] = { - 0, // GST_PROPS_END_ID_NUM = 0, - 0, // GST_PROPS_LIST_ID_NUM, - 1, // GST_PROPS_INT_ID_NUM, - 2, // GST_PROPS_INT_RANGE_ID_NUM, - 1, // GST_PROPS_FLOAT_ID_NUM, - 2, // GST_PROPS_FLOAT_RANGE_ID_NUM, - 1, // GST_PROPS_FOURCC_ID_NUM, - 1, // GST_PROPS_BOOL_ID_NUM, - 1, // GST_PROPS_STRING_ID_NUM, -}; - void _gst_props_initialize (void) { @@ -67,16 +55,16 @@ gst_props_debug_entry (GstPropsEntry *entry) case GST_PROPS_INT_ID: GST_DEBUG (0, "%d\n", entry->data.int_data); break; - case GST_PROPS_FOURCC_ID_NUM: + case GST_PROPS_FOURCC_ID: GST_DEBUG (0, "%4.4s\n", (gchar*)&entry->data.fourcc_data); break; - case GST_PROPS_BOOL_ID_NUM: + case GST_PROPS_BOOL_ID: GST_DEBUG (0, "%d\n", entry->data.bool_data); break; - case GST_PROPS_STRING_ID_NUM: + case GST_PROPS_STRING_ID: GST_DEBUG (0, "%s\n", entry->data.string_data.string); break; - case GST_PROPS_INT_RANGE_ID_NUM: + case GST_PROPS_INT_RANGE_ID: GST_DEBUG (0, "%d-%d\n", entry->data.int_range_data.min, entry->data.int_range_data.max); break; @@ -85,67 +73,6 @@ gst_props_debug_entry (GstPropsEntry *entry) } } -static GstPropsEntry* -gst_props_create_entry (GstPropsFactory factory, gint *skipped) -{ - GstPropsFactoryEntry tag; - GstPropsEntry *entry; - guint i=0; - - g_mutex_lock (_gst_props_entries_chunk_lock); - entry = g_mem_chunk_alloc (_gst_props_entries_chunk); - g_mutex_unlock (_gst_props_entries_chunk_lock); - - tag = factory[i++]; - switch (GPOINTER_TO_INT (tag)) { - case GST_PROPS_INT_ID_NUM: - entry->propstype = GST_PROPS_INT_ID_NUM; - entry->data.int_data = GPOINTER_TO_INT (factory[i++]); - break; - case GST_PROPS_INT_RANGE_ID_NUM: - entry->propstype = GST_PROPS_INT_RANGE_ID_NUM; - entry->data.int_range_data.min = GPOINTER_TO_INT (factory[i++]); - entry->data.int_range_data.max = GPOINTER_TO_INT (factory[i++]); - break; - case GST_PROPS_FLOAT_ID_NUM: - entry->propstype = GST_PROPS_FLOAT_ID_NUM; - entry->data.float_data = *(gfloat*)factory[i++]; - break; - case GST_PROPS_FLOAT_RANGE_ID_NUM: - entry->propstype = GST_PROPS_FLOAT_RANGE_ID_NUM; - entry->data.float_range_data.min = *(gfloat*)factory[i++]; - entry->data.float_range_data.max = *(gfloat*)factory[i++]; - break; - case GST_PROPS_FOURCC_ID_NUM: - entry->propstype = GST_PROPS_FOURCC_ID_NUM; - entry->data.fourcc_data = GPOINTER_TO_INT (factory[i++]); - break; - case GST_PROPS_LIST_ID_NUM: - g_warning ("gstprops: list not allowed in list\n"); - break; - case GST_PROPS_BOOL_ID_NUM: - entry->propstype = GST_PROPS_BOOL_ID_NUM; - entry->data.bool_data = GPOINTER_TO_INT (factory[i++]); - break; - case GST_PROPS_STRING_ID_NUM: - entry->propstype = GST_PROPS_STRING_ID_NUM; - entry->data.string_data.string = g_strdup (factory[i++]); - break; - default: - g_warning ("gstprops: unknown props id found\n"); - g_mutex_lock (_gst_props_entries_chunk_lock); - g_mem_chunk_free (_gst_props_entries_chunk, entry); - g_mutex_unlock (_gst_props_entries_chunk_lock); - entry = NULL; - break; - } - - *skipped = i; - - return entry; -} - - static gint props_compare_func (gconstpointer a, gconstpointer b) @@ -166,184 +93,139 @@ props_find_func (gconstpointer a, return (entry1 - entry2->propid); } -/** - * gst_props_register: - * @factory: the factory to register - * - * Register the factory. - * - * Returns: the new property created from the factory - */ -GstProps * -gst_props_register (GstPropsFactory factory) +static void +gst_props_entry_fill (GstPropsEntry *entry, va_list *var_args) { - guint dummy; + entry->propstype = va_arg (*var_args, GstPropsId); - 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 = NULL; - gint skipped; - - g_return_val_if_fail (factory != NULL, NULL); - - tag = factory[i++]; - - if (!tag) goto end; - - g_mutex_lock (_gst_props_chunk_lock); - props = g_mem_chunk_alloc (_gst_props_chunk); - g_mutex_unlock (_gst_props_chunk_lock); - - g_return_val_if_fail (props != NULL, NULL); - - props->properties = NULL; - props->refcount = 1; - - while (tag) { - 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]; - switch (GPOINTER_TO_INT (tag)) { - case GST_PROPS_LIST_ID_NUM: - { - GstPropsEntry *list_entry; - - g_mutex_lock (_gst_props_entries_chunk_lock); - entry = g_mem_chunk_alloc (_gst_props_entries_chunk); - g_mutex_unlock (_gst_props_entries_chunk_lock); - - entry->propid = quark; - entry->propstype = GST_PROPS_LIST_ID_NUM; - entry->data.list_data.entries = NULL; - - i++; // skip list tag - tag = factory[i]; - while (tag) { - list_entry = gst_props_create_entry (&factory[i], &skipped); - list_entry->propid = quark; - i += skipped; - tag = factory[i]; - entry->data.list_data.entries = g_list_prepend (entry->data.list_data.entries, list_entry); - } - entry->data.list_data.entries = g_list_reverse (entry->data.list_data.entries); - i++; //skip NULL (list end) - break; - } - default: - { - entry = gst_props_create_entry (&factory[i], &skipped); - entry->propid = quark; - i += skipped; - break; - } - } - props->properties = g_list_insert_sorted (props->properties, entry, props_compare_func); - - tag = factory[i++]; + switch (entry->propstype) { + case GST_PROPS_INT_ID: + entry->data.int_data = va_arg (*var_args, gint); + break; + case GST_PROPS_INT_RANGE_ID: + entry->data.int_range_data.min = va_arg (*var_args, gint); + entry->data.int_range_data.max = va_arg (*var_args, gint); + break; + case GST_PROPS_FLOAT_ID: + entry->data.float_data = va_arg (*var_args, gfloat); + break; + case GST_PROPS_FLOAT_RANGE_ID: + entry->data.float_range_data.min = va_arg (*var_args, gfloat); + entry->data.float_range_data.max = va_arg (*var_args, gfloat); + break; + case GST_PROPS_FOURCC_ID: + entry->data.fourcc_data = va_arg (*var_args, gulong); + break; + case GST_PROPS_BOOL_ID: + entry->data.bool_data = va_arg (*var_args, gboolean); + break; + case GST_PROPS_STRING_ID: + entry->data.string_data.string = g_strdup (va_arg (*var_args, gchar*)); + break; + default: + break; } - -end: - *counter = i; - - return props; } /** * gst_props_new: - * @entry: the property entries for the property - * @...: the property entries for the property + * @firstname: the first property name + * @...: the property values + * + * Create a new property from the given key/value pairs + * + * Returns: the new property + */ +GstProps* +gst_props_new (const gchar *firstname, ...) +{ + GstProps *props; + va_list var_args; + + va_start (var_args, firstname); + + props = gst_props_newv (firstname, var_args); + + va_end (var_args); + + return props; +} + +/** + * gst_props_newv: + * @firstname: the first property name + * @var_args: the property values * * Create a new property from the list of entries. * * Returns: the new property created from the list of entries */ GstProps* -gst_props_new (GstPropsFactoryEntry entry, ...) +gst_props_newv (const gchar *firstname, va_list var_args) { - va_list var_args; - GstPropsFactoryEntry value; - gint i = 0; - gint size, skip; - GstPropsFactoryEntry *factory; - gboolean inlist = FALSE; GstProps *props; + gboolean inlist = FALSE; + const gchar *prop_name; + GstPropsEntry *list_entry = NULL; -#define add_value(value) {\ - GST_DEBUG (0,"%d %p\n", i, value);\ - factory[i++] = value; \ - if (i >= size) { \ - size += 16; \ - factory = (GstPropsFactoryEntry *) g_realloc (factory, size*sizeof(GstPropsFactoryEntry));\ - }\ -} + g_mutex_lock (_gst_props_chunk_lock); + props = g_mem_chunk_alloc (_gst_props_chunk); + g_mutex_unlock (_gst_props_chunk_lock); - size = 16; - factory = (GstPropsFactoryEntry *) g_malloc (size*sizeof(GstPropsFactoryEntry)); + props->properties = NULL; + props->refcount = 1; + + prop_name = firstname; - va_start (var_args, entry); - // property name - value = (GstPropsFactoryEntry) entry; - // properties - while (value) { - if (!inlist) { - // add name - add_value (value); + while (prop_name) { + GstPropsEntry *entry; + + g_mutex_lock (_gst_props_entries_chunk_lock); + entry = g_mem_chunk_alloc (_gst_props_entries_chunk); + g_mutex_unlock (_gst_props_entries_chunk_lock); - // get value - value = va_arg (var_args, GstPropsFactoryEntry); - } - switch (GPOINTER_TO_INT (value)) { - case GST_PROPS_END_ID_NUM: - g_assert (inlist == TRUE); + entry->propid = g_quark_from_string (prop_name); + gst_props_entry_fill (entry, &var_args); - inlist = FALSE; - skip = 0; + switch (entry->propstype) { + case GST_PROPS_INT_ID: + case GST_PROPS_INT_RANGE_ID: + case GST_PROPS_FLOAT_ID: + case GST_PROPS_FLOAT_RANGE_ID: + case GST_PROPS_FOURCC_ID: + case GST_PROPS_BOOL_ID: + case GST_PROPS_STRING_ID: break; - case GST_PROPS_LIST_ID_NUM: - { - g_assert (inlist == FALSE); - - skip = 0; + case GST_PROPS_LIST_ID: + g_return_val_if_fail (inlist == FALSE, NULL); inlist = TRUE; + list_entry = entry; + list_entry->data.list_data.entries = NULL; break; - } + case GST_PROPS_END_ID: + g_return_val_if_fail (inlist == TRUE, NULL); + inlist = FALSE; + list_entry = NULL; + prop_name = va_arg (var_args, gchar*); + continue; default: - skip = _arg_len[GPOINTER_TO_INT (value)]; - break; + g_mutex_lock (_gst_props_entries_chunk_lock); + g_mem_chunk_free (_gst_props_entries_chunk, entry); + g_mutex_unlock (_gst_props_entries_chunk_lock); + g_assert_not_reached (); + break; } - do { - add_value (value); - value = va_arg (var_args, GstPropsFactoryEntry); - } - while (skip--); - } - factory[i++] = NULL; - props = gst_props_register (factory); + if (inlist && (list_entry != entry)) { + list_entry->data.list_data.entries = g_list_prepend (list_entry->data.list_data.entries, entry); + } + else { + props->properties = g_list_insert_sorted (props->properties, entry, props_compare_func); + } + if (!inlist) + prop_name = va_arg (var_args, gchar*); + } return props; } @@ -352,7 +234,6 @@ gst_props_new (GstPropsFactoryEntry entry, ...) * gst_props_set: * @props: the props to modify * @name: the name of the entry to modify - * @entry: The new value of the property entry * @...: More property entries. * * Modifies the value of the given entry in the props struct. @@ -360,7 +241,7 @@ gst_props_new (GstPropsFactoryEntry entry, ...) * Returns: the new modified property structure. */ GstProps* -gst_props_set (GstProps *props, const gchar *name, GstPropsFactoryEntry entry, ...) +gst_props_set (GstProps *props, const gchar *name, ...) { GQuark quark; GList *lentry; @@ -371,45 +252,15 @@ gst_props_set (GstProps *props, const gchar *name, GstPropsFactoryEntry entry, . lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func); if (lentry) { - GstPropsEntry *thisentry; - GstPropsFactoryEntry value; + GstPropsEntry *entry; - thisentry = (GstPropsEntry *)lentry->data; + entry = (GstPropsEntry *)lentry->data; - va_start (var_args, entry); - // property name - value = (GstPropsFactoryEntry) entry; + va_start (var_args, name); - switch (GPOINTER_TO_INT (value)) { - case GST_PROPS_INT_ID: - thisentry->propstype = GST_PROPS_INT_ID_NUM; - value = va_arg (var_args, GstPropsFactoryEntry); - thisentry->data.int_data = GPOINTER_TO_INT (value); - break; - case GST_PROPS_FLOAT_ID: - thisentry->propstype = GST_PROPS_FLOAT_ID_NUM; - value = va_arg (var_args, GstPropsFactoryEntry); - thisentry->data.float_data = *(gfloat*)value; - break; - case GST_PROPS_FOURCC_ID_NUM: - thisentry->propstype = GST_PROPS_FOURCC_ID_NUM; - value = va_arg (var_args, GstPropsFactoryEntry); - thisentry->data.fourcc_data = GPOINTER_TO_INT (value); - break; - case GST_PROPS_BOOL_ID_NUM: - thisentry->propstype = GST_PROPS_BOOL_ID_NUM; - value = va_arg (var_args, GstPropsFactoryEntry); - thisentry->data.bool_data = GPOINTER_TO_INT (value); - break; - case GST_PROPS_STRING_ID_NUM: - thisentry->propstype = GST_PROPS_STRING_ID_NUM; - value = va_arg (var_args, GstPropsFactoryEntry); - thisentry->data.string_data.string = g_strdup (value); - break; - default: - g_print("gstprops: type not allowed\n"); - break; - } + gst_props_entry_fill (entry, &var_args); + + va_end (var_args); } else { g_print("gstprops: no property '%s' to change\n", name); @@ -736,7 +587,7 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry GST_DEBUG (0,"compare: %s %s\n", g_quark_to_string (entry1->propid), g_quark_to_string (entry2->propid)); switch (entry1->propstype) { - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: { GList *entrylist = entry1->data.list_data.entries; gboolean valid = TRUE; // innocent until proven guilty @@ -751,90 +602,90 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry return valid; } - case GST_PROPS_INT_RANGE_ID_NUM: + case GST_PROPS_INT_RANGE_ID: switch (entry2->propstype) { // a - b <---> a - c - case GST_PROPS_INT_RANGE_ID_NUM: + case GST_PROPS_INT_RANGE_ID: return (entry2->data.int_range_data.min <= entry1->data.int_range_data.min && entry2->data.int_range_data.max >= entry1->data.int_range_data.max); - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: return gst_props_entry_check_list_compatibility (entry1, entry2); default: return FALSE; } break; - case GST_PROPS_FLOAT_RANGE_ID_NUM: + case GST_PROPS_FLOAT_RANGE_ID: switch (entry2->propstype) { // a - b <---> a - c - case GST_PROPS_FLOAT_RANGE_ID_NUM: + case GST_PROPS_FLOAT_RANGE_ID: return (entry2->data.float_range_data.min <= entry1->data.float_range_data.min && entry2->data.float_range_data.max >= entry1->data.float_range_data.max); - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: return gst_props_entry_check_list_compatibility (entry1, entry2); default: return FALSE; } break; - case GST_PROPS_FOURCC_ID_NUM: + case GST_PROPS_FOURCC_ID: switch (entry2->propstype) { // b <---> a - case GST_PROPS_FOURCC_ID_NUM: + case GST_PROPS_FOURCC_ID: return (entry2->data.fourcc_data == entry1->data.fourcc_data); // b <---> a,b,c - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: return gst_props_entry_check_list_compatibility (entry1, entry2); default: return FALSE; } break; - case GST_PROPS_INT_ID_NUM: + case GST_PROPS_INT_ID: switch (entry2->propstype) { // b <---> a - d - case GST_PROPS_INT_RANGE_ID_NUM: + case GST_PROPS_INT_RANGE_ID: return (entry2->data.int_range_data.min <= entry1->data.int_data && entry2->data.int_range_data.max >= entry1->data.int_data); // b <---> a - case GST_PROPS_INT_ID_NUM: + case GST_PROPS_INT_ID: return (entry2->data.int_data == entry1->data.int_data); // b <---> a,b,c - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: return gst_props_entry_check_list_compatibility (entry1, entry2); default: return FALSE; } break; - case GST_PROPS_FLOAT_ID_NUM: + case GST_PROPS_FLOAT_ID: switch (entry2->propstype) { // b <---> a - d - case GST_PROPS_FLOAT_RANGE_ID_NUM: + case GST_PROPS_FLOAT_RANGE_ID: return (entry2->data.float_range_data.min <= entry1->data.float_data && entry2->data.float_range_data.max >= entry1->data.float_data); // b <---> a - case GST_PROPS_FLOAT_ID_NUM: + case GST_PROPS_FLOAT_ID: return (entry2->data.float_data == entry1->data.float_data); // b <---> a,b,c - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: return gst_props_entry_check_list_compatibility (entry1, entry2); default: return FALSE; } break; - case GST_PROPS_BOOL_ID_NUM: + case GST_PROPS_BOOL_ID: switch (entry2->propstype) { // t <---> t - case GST_PROPS_BOOL_ID_NUM: + case GST_PROPS_BOOL_ID: return (entry2->data.bool_data == entry1->data.bool_data); - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: return gst_props_entry_check_list_compatibility (entry1, entry2); default: return FALSE; } - case GST_PROPS_STRING_ID_NUM: + case GST_PROPS_STRING_ID: switch (entry2->propstype) { // t <---> t - case GST_PROPS_STRING_ID_NUM: + case GST_PROPS_STRING_ID: return (!strcmp (entry2->data.string_data.string, entry1->data.string_data.string)); - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: return gst_props_entry_check_list_compatibility (entry1, entry2); default: return FALSE; @@ -924,14 +775,14 @@ gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent) gchar *str; switch (entry->propstype) { - case GST_PROPS_INT_ID_NUM: + case GST_PROPS_INT_ID: subtree = xmlNewChild (parent, NULL, "int", NULL); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); str = g_strdup_printf ("%d", entry->data.int_data); xmlNewProp (subtree, "value", str); g_free(str); break; - case GST_PROPS_INT_RANGE_ID_NUM: + case GST_PROPS_INT_RANGE_ID: subtree = xmlNewChild (parent, NULL, "range", NULL); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); str = g_strdup_printf ("%d", entry->data.int_range_data.min); @@ -941,14 +792,14 @@ gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent) xmlNewProp (subtree, "max", str); g_free(str); break; - case GST_PROPS_FLOAT_ID_NUM: + case GST_PROPS_FLOAT_ID: subtree = xmlNewChild (parent, NULL, "float", NULL); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); str = g_strdup_printf ("%f", entry->data.float_data); xmlNewProp (subtree, "value", str); g_free(str); break; - case GST_PROPS_FLOAT_RANGE_ID_NUM: + case GST_PROPS_FLOAT_RANGE_ID: subtree = xmlNewChild (parent, NULL, "floatrange", NULL); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); str = g_strdup_printf ("%f", entry->data.float_range_data.min); @@ -958,7 +809,7 @@ gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent) xmlNewProp (subtree, "max", str); g_free(str); break; - case GST_PROPS_FOURCC_ID_NUM: + case GST_PROPS_FOURCC_ID: str = g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data); xmlAddChild (parent, xmlNewComment (str)); g_free(str); @@ -968,12 +819,12 @@ gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent) xmlNewProp (subtree, "hexvalue", str); g_free(str); break; - case GST_PROPS_BOOL_ID_NUM: + case GST_PROPS_BOOL_ID: subtree = xmlNewChild (parent, NULL, "boolean", NULL); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "value", (entry->data.bool_data ? "true" : "false")); break; - case GST_PROPS_STRING_ID_NUM: + case GST_PROPS_STRING_ID: subtree = xmlNewChild (parent, NULL, "string", NULL); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "value", entry->data.string_data.string); @@ -1008,7 +859,7 @@ gst_props_save_thyself (GstProps *props, xmlNodePtr parent) GstPropsEntry *entry = (GstPropsEntry *) proplist->data; switch (entry->propstype) { - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: subtree = xmlNewChild (parent, NULL, "list", NULL); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); g_list_foreach (entry->data.list_data.entries, (GFunc) gst_props_save_thyself_func, subtree); @@ -1033,7 +884,7 @@ gst_props_load_thyself_func (xmlNodePtr field) g_mutex_unlock (_gst_props_entries_chunk_lock); if (!strcmp(field->name, "int")) { - entry->propstype = GST_PROPS_INT_ID_NUM; + entry->propstype = GST_PROPS_INT_ID; prop = xmlGetProp(field, "name"); entry->propid = g_quark_from_string (prop); g_free (prop); @@ -1042,7 +893,7 @@ gst_props_load_thyself_func (xmlNodePtr field) g_free (prop); } else if (!strcmp(field->name, "range")) { - entry->propstype = GST_PROPS_INT_RANGE_ID_NUM; + entry->propstype = GST_PROPS_INT_RANGE_ID; prop = xmlGetProp(field, "name"); entry->propid = g_quark_from_string (prop); g_free (prop); @@ -1054,7 +905,7 @@ gst_props_load_thyself_func (xmlNodePtr field) g_free (prop); } else if (!strcmp(field->name, "float")) { - entry->propstype = GST_PROPS_FLOAT_ID_NUM; + entry->propstype = GST_PROPS_FLOAT_ID; prop = xmlGetProp(field, "name"); entry->propid = g_quark_from_string (prop); g_free (prop); @@ -1063,7 +914,7 @@ gst_props_load_thyself_func (xmlNodePtr field) g_free (prop); } else if (!strcmp(field->name, "floatrange")) { - entry->propstype = GST_PROPS_FLOAT_RANGE_ID_NUM; + entry->propstype = GST_PROPS_FLOAT_RANGE_ID; prop = xmlGetProp(field, "name"); entry->propid = g_quark_from_string (prop); g_free (prop); @@ -1075,7 +926,7 @@ gst_props_load_thyself_func (xmlNodePtr field) g_free (prop); } else if (!strcmp(field->name, "boolean")) { - entry->propstype = GST_PROPS_BOOL_ID_NUM; + entry->propstype = GST_PROPS_BOOL_ID; prop = xmlGetProp(field, "name"); entry->propid = g_quark_from_string (prop); g_free (prop); @@ -1085,7 +936,7 @@ gst_props_load_thyself_func (xmlNodePtr field) g_free (prop); } else if (!strcmp(field->name, "fourcc")) { - entry->propstype = GST_PROPS_FOURCC_ID_NUM; + entry->propstype = GST_PROPS_FOURCC_ID; prop = xmlGetProp(field, "name"); entry->propid = g_quark_from_string (prop); g_free (prop); @@ -1094,7 +945,7 @@ gst_props_load_thyself_func (xmlNodePtr field) g_free (prop); } else if (!strcmp(field->name, "string")) { - entry->propstype = GST_PROPS_STRING_ID_NUM; + entry->propstype = GST_PROPS_STRING_ID; prop = xmlGetProp(field, "name"); entry->propid = g_quark_from_string (prop); g_free (prop); @@ -1141,7 +992,7 @@ gst_props_load_thyself (xmlNodePtr parent) entry = g_mem_chunk_alloc (_gst_props_entries_chunk); g_mutex_unlock (_gst_props_entries_chunk_lock); - entry->propstype = GST_PROPS_LIST_ID_NUM; + entry->propstype = GST_PROPS_LIST_ID; entry->data.list_data.entries = NULL; prop = xmlGetProp (field, "name"); entry->propid = g_quark_from_string (prop); @@ -1171,8 +1022,3 @@ gst_props_load_thyself (xmlNodePtr parent) return props; } - -gfloat* _gst_props_floatpointer (gfloat f) -{ - return &f; -} diff --git a/gst/gstprops.h b/gst/gstprops.h index 93ee078d91..a67acf8aea 100644 --- a/gst/gstprops.h +++ b/gst/gstprops.h @@ -36,45 +36,29 @@ typedef struct _GstProps GstProps; -typedef gpointer GstPropsFactoryEntry; -typedef GstPropsFactoryEntry GstPropsFactory[]; -typedef GstPropsFactory *GstPropsListFactory[]; typedef enum { - GST_PROPS_END_ID_NUM = 0, - GST_PROPS_LIST_ID_NUM, - GST_PROPS_INT_ID_NUM, - GST_PROPS_INT_RANGE_ID_NUM, - GST_PROPS_FLOAT_ID_NUM, - GST_PROPS_FLOAT_RANGE_ID_NUM, - GST_PROPS_FOURCC_ID_NUM, - GST_PROPS_BOOL_ID_NUM, - GST_PROPS_STRING_ID_NUM, - GST_PROPS_LAST_ID_NUM = GST_PROPS_END_ID_NUM + 16, + GST_PROPS_END_ID = 0, + GST_PROPS_LIST_ID, + GST_PROPS_INT_ID, + GST_PROPS_INT_RANGE_ID, + GST_PROPS_FLOAT_ID, + GST_PROPS_FLOAT_RANGE_ID, + GST_PROPS_FOURCC_ID, + GST_PROPS_BOOL_ID, + GST_PROPS_STRING_ID, + GST_PROPS_LAST_ID = GST_PROPS_END_ID + 16, } GstPropsId; -#define GST_PROPS_END_ID GINT_TO_POINTER(GST_PROPS_END_ID_NUM) -#define GST_PROPS_LIST_ID GINT_TO_POINTER(GST_PROPS_LIST_ID_NUM) -#define GST_PROPS_INT_ID GINT_TO_POINTER(GST_PROPS_INT_ID_NUM) -#define GST_PROPS_INT_RANGE_ID GINT_TO_POINTER(GST_PROPS_INT_RANGE_ID_NUM) -#define GST_PROPS_FLOAT_ID GINT_TO_POINTER(GST_PROPS_FLOAT_ID_NUM) -#define GST_PROPS_FLOAT_RANGE_ID GINT_TO_POINTER(GST_PROPS_FLOAT_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_STRING_ID GINT_TO_POINTER(GST_PROPS_STRING_ID_NUM) -#define GST_PROPS_LAST_ID GINT_TO_POINTER(GST_PROPS_LAST_ID_NUM) - #define GST_MAKE_FOURCC(a,b,c,d) ((a)|(b)<<8|(c)<<16|(d)<<24) #define GST_PROPS_LIST(a...) GST_PROPS_LIST_ID,##a,NULL -#define GST_PROPS_INT(a) GST_PROPS_INT_ID,(GINT_TO_POINTER(a)) -#define GST_PROPS_INT_RANGE(a,b) GST_PROPS_INT_RANGE_ID,(GINT_TO_POINTER(a)),(GINT_TO_POINTER(b)) -#define GST_PROPS_FLOAT_STRING(a) GST_PROPS_FLOAT_ID,(a) -#define GST_PROPS_FLOAT_RANGE_STRING(a,b) GST_PROPS_FLOAT_RANGE_ID,(a),(b) -#define GST_PROPS_FLOAT(a) GST_PROPS_FLOAT_ID,(&(a)) -#define GST_PROPS_FLOAT_RANGE(a,b) GST_PROPS_FLOAT_RANGE_ID,(&(a)),(&(b)) -#define GST_PROPS_FOURCC(a) GST_PROPS_FOURCC_ID,(GINT_TO_POINTER(a)) -#define GST_PROPS_BOOLEAN(a) GST_PROPS_BOOL_ID,(GINT_TO_POINTER(a)) +#define GST_PROPS_INT(a) GST_PROPS_INT_ID,(a) +#define GST_PROPS_INT_RANGE(a,b) GST_PROPS_INT_RANGE_ID,(a),(b) +#define GST_PROPS_FLOAT(a) GST_PROPS_FLOAT_ID,(a) +#define GST_PROPS_FLOAT_RANGE(a,b) GST_PROPS_FLOAT_RANGE_ID,(a),(b) +#define GST_PROPS_FOURCC(a) GST_PROPS_FOURCC_ID,(a) +#define GST_PROPS_BOOLEAN(a) GST_PROPS_BOOL_ID,(a) #define GST_PROPS_STRING(a) GST_PROPS_STRING_ID,(a) @@ -88,10 +72,8 @@ struct _GstProps { /* initialize the subsystem */ 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, ...); +GstProps* gst_props_new (const gchar *firstname, ...); +GstProps* gst_props_newv (const gchar *firstname, va_list var_args); void gst_props_unref (GstProps *props); void gst_props_ref (GstProps *props); @@ -104,7 +86,7 @@ GstProps* gst_props_merge (GstProps *props, GstProps *tomerge); gboolean gst_props_check_compatibility (GstProps *fromprops, GstProps *toprops); -GstProps* gst_props_set (GstProps *props, const gchar *name, GstPropsFactoryEntry entry, ...); +GstProps* gst_props_set (GstProps *props, const gchar *name, ...); gint gst_props_get_int (GstProps *props, const gchar *name); gulong gst_props_get_fourcc_int (GstProps *props, const gchar *name); diff --git a/gst/meta/Makefile.am b/gst/meta/Makefile.am index fe7553eee3..388fd45da0 100644 --- a/gst/meta/Makefile.am +++ b/gst/meta/Makefile.am @@ -1,3 +1,3 @@ metaincludedir = $(includedir)/gst/meta metainclude_HEADERS = \ - videoraw.h.old + spectrum.h diff --git a/gstplay/Makefile.am b/gstplay/Makefile.am index 1dcc03c2fd..943960095b 100644 --- a/gstplay/Makefile.am +++ b/gstplay/Makefile.am @@ -25,11 +25,14 @@ libgstmediaplay_la_SOURCES = \ gstmediaplay_SOURCES = \ main.c +libgstmediaplayincludedir = $(includedir)/gstplay +libgstmediaplayinclude_HEADERS = \ + gstplay.h + noinst_HEADERS = \ gstmediaplay.h \ gststatusarea.h \ callbacks.h \ - gstplay.h \ gstplayprivate.h diff --git a/gstplay/gstplay.c b/gstplay/gstplay.c index 09f12127e0..e8898ef32d 100644 --- a/gstplay/gstplay.c +++ b/gstplay/gstplay.c @@ -423,6 +423,8 @@ gst_play_realize (GtkWidget *widget) g_return_if_fail (GST_IS_PLAY (widget)); + //g_print ("realize\n"); + play = GST_PLAY (widget); priv = (GstPlayPrivate *)play->priv; diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index d444217367..67ab4b1541 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -45,13 +45,17 @@ enum { /* FILL ME */ }; -static GstPadFactory tee_src_factory = { - "src%d", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_REQUEST, - NULL, /* no caps */ - NULL, -}; +static GstPadTemplate* +tee_src_factory_create (void) +{ + return + gst_padtemplate_new ( + "src%d", + GST_PAD_SRC, + GST_PAD_REQUEST, + NULL /* no caps */ + ); +} static void gst_tee_class_init (GstTeeClass *klass); @@ -197,7 +201,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf) gboolean gst_tee_factory_init (GstElementFactory *factory) { - gst_tee_src_template = gst_padtemplate_new (&tee_src_factory); + gst_tee_src_template = tee_src_factory_create (); gst_elementfactory_add_padtemplate (factory, gst_tee_src_template); return TRUE; diff --git a/tests/autoplug.c b/tests/autoplug.c index 70de69b636..2898e64828 100644 --- a/tests/autoplug.c +++ b/tests/autoplug.c @@ -22,7 +22,7 @@ main (int argc, char *argv[]) g_assert (videosink != NULL); testcaps = g_list_append (NULL, - gst_caps_new_with_props ("test_caps", + gst_caps_new ("test_caps", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), diff --git a/tests/autoplug2.c b/tests/autoplug2.c index 64f0a9f58d..8076fa2dea 100644 --- a/tests/autoplug2.c +++ b/tests/autoplug2.c @@ -3,10 +3,10 @@ static GstElement* autoplug_caps (GstAutoplug *autoplug, gchar *mime1, gchar *mime2) { - GList *caps1, *caps2; + GstCaps *caps1, *caps2; - caps1 = g_list_append (NULL, gst_caps_new ("tescaps1", mime1)); - caps2 = g_list_append (NULL, gst_caps_new ("tescaps2", mime2)); + caps1 = gst_caps_new ("tescaps1", mime1, NULL); + caps2 = gst_caps_new ("tescaps2", mime2, NULL); return gst_autoplug_to_caps (autoplug, caps1, caps2, NULL); } @@ -28,48 +28,48 @@ main (int argc, char *argv[]) xmlSaveFile ("autoplug2_2.gst", gst_xml_write (element)); element = gst_autoplug_to_caps (autoplug, - g_list_append (NULL, gst_caps_new_with_props( + gst_caps_new( "testcaps3", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (TRUE), - NULL))), - g_list_append (NULL, gst_caps_new("testcaps4","audio/raw")), + NULL)), + gst_caps_new("testcaps4","audio/raw", NULL), NULL); xmlSaveFile ("autoplug2_3.gst", gst_xml_write (element)); element = gst_autoplug_to_caps (autoplug, - g_list_append (NULL, gst_caps_new_with_props( + gst_caps_new( "testcaps5", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (FALSE), - NULL))), - g_list_append (NULL, gst_caps_new("testcaps6", "video/raw")), + NULL)), + gst_caps_new("testcaps6", "video/raw", NULL), NULL); xmlSaveFile ("autoplug2_4.gst", gst_xml_write (element)); element = gst_autoplug_to_caps (autoplug, - g_list_append (NULL, gst_caps_new( + gst_caps_new( "testcaps7", - "video/avi")), - g_list_append (NULL, gst_caps_new("testcaps8", "video/raw")), - g_list_append (NULL, gst_caps_new("testcaps9", "audio/raw")), + "video/avi", NULL), + gst_caps_new("testcaps8", "video/raw", NULL), + gst_caps_new("testcaps9", "audio/raw", NULL), NULL); xmlSaveFile ("autoplug2_5.gst", gst_xml_write (element)); element = gst_autoplug_to_caps (autoplug, - g_list_append (NULL, gst_caps_new_with_props( + gst_caps_new( "testcaps10", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (TRUE), - NULL))), - g_list_append (NULL, gst_caps_new("testcaps10", "video/raw")), - g_list_append (NULL, gst_caps_new("testcaps11", "audio/raw")), + NULL)), + gst_caps_new("testcaps10", "video/raw", NULL), + gst_caps_new("testcaps11", "audio/raw", NULL), NULL); xmlSaveFile ("autoplug2_6.gst", gst_xml_write (element)); diff --git a/tests/autoplug3.c b/tests/autoplug3.c index 9f6a150648..34927edad2 100644 --- a/tests/autoplug3.c +++ b/tests/autoplug3.c @@ -17,64 +17,64 @@ main (int argc, char *argv[]) autoplug2 = gst_autoplugfactory_make ("static"); element = gst_autoplug_to_renderers (autoplug, - g_list_append (NULL, gst_caps_new ("mp3caps", "audio/mp3")), sink2, NULL); + gst_caps_new ("mp3caps", "audio/mp3", NULL), sink2, NULL); xmlSaveFile ("autoplug3_1.gst", gst_xml_write (element)); element = gst_autoplug_to_renderers (autoplug, - g_list_append (NULL, gst_caps_new ("mpeg1caps", "video/mpeg")), sink1, NULL); + gst_caps_new ("mpeg1caps", "video/mpeg", NULL), sink1, NULL); if (element) { xmlSaveFile ("autoplug3_2.gst", gst_xml_write (element)); } element = gst_autoplug_to_caps (autoplug2, - g_list_append (NULL, gst_caps_new_with_props( + gst_caps_new( "testcaps3", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (TRUE), - NULL))), - g_list_append (NULL, gst_caps_new("testcaps4","audio/raw")), + NULL)), + gst_caps_new("testcaps4","audio/raw", NULL), NULL); if (element) { xmlSaveFile ("autoplug3_3.gst", gst_xml_write (element)); } element = gst_autoplug_to_caps (autoplug2, - g_list_append (NULL, gst_caps_new_with_props( + gst_caps_new( "testcaps5", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (FALSE), - NULL))), - g_list_append (NULL, gst_caps_new("testcaps6", "video/raw")), + NULL)), + gst_caps_new("testcaps6", "video/raw", NULL), NULL); if (element) { xmlSaveFile ("autoplug3_4.gst", gst_xml_write (element)); } element = gst_autoplug_to_caps (autoplug2, - g_list_append (NULL, gst_caps_new( + gst_caps_new( "testcaps7", - "video/avi")), - g_list_append (NULL, gst_caps_new("testcaps8", "video/raw")), - g_list_append (NULL, gst_caps_new("testcaps9", "audio/raw")), + "video/avi", NULL), + gst_caps_new("testcaps8", "video/raw", NULL), + gst_caps_new("testcaps9", "audio/raw", NULL), NULL); if (element) { xmlSaveFile ("autoplug3_5.gst", gst_xml_write (element)); } element = gst_autoplug_to_caps (autoplug2, - g_list_append (NULL, gst_caps_new_with_props( + gst_caps_new( "testcaps10", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (TRUE), - NULL))), - g_list_append (NULL, gst_caps_new("testcaps10", "video/raw")), - g_list_append (NULL, gst_caps_new("testcaps11", "audio/raw")), + NULL)), + gst_caps_new("testcaps10", "video/raw", NULL), + gst_caps_new("testcaps11", "audio/raw", NULL), NULL); if (element) { xmlSaveFile ("autoplug3_6.gst", gst_xml_write (element)); @@ -84,13 +84,13 @@ main (int argc, char *argv[]) sink2 = gst_elementfactory_make ("osssink", "osssink"); element = gst_autoplug_to_renderers (autoplug, - g_list_append (NULL, gst_caps_new_with_props( + gst_caps_new( "testcaps10", "video/mpeg", gst_props_new ( "mpegversion", GST_PROPS_INT (1), "systemstream", GST_PROPS_BOOLEAN (TRUE), - NULL))), + NULL)), sink1, sink2, NULL); diff --git a/tests/caps.c b/tests/caps.c index 047b4ba675..97dc963817 100644 --- a/tests/caps.c +++ b/tests/caps.c @@ -1,65 +1,119 @@ #include -static GstCapsFactory mpeg2dec_sink_caps = { - "mpeg2dec_sink", - "video/mpeg", - "mpegtype", GST_PROPS_LIST ( - GST_PROPS_INT(1), - GST_PROPS_INT(2) - ), - NULL -}; +static GstCaps* +mpeg2dec_sink_caps (void) +{ + return + gst_caps_new ( + "mpeg2dec_sink", + "video/mpeg", + gst_props_new ( + "mpegtype", GST_PROPS_LIST ( + GST_PROPS_INT(1), + GST_PROPS_INT(2) + ), + NULL + ) + ); +} -static GstCapsFactory mp1parse_src_caps = { - "mp1parse_src", - "video/mpeg", - "mpegtype", GST_PROPS_LIST ( - GST_PROPS_INT(1) - ), - NULL -}; +static GstCaps* +mp1parse_src_caps (void) +{ + return + gst_caps_new ( + "mp1parse_src", + "video/mpeg", + gst_props_new ( + "mpegtype", GST_PROPS_LIST ( + GST_PROPS_INT(1) + ), + NULL + ) + ); +} -static GstCapsFactory mpeg2dec_src_caps = { - "mpeg2dec_src", - "video/raw", - "fourcc", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')) +static GstCaps* +mpeg2dec_src_caps (void) +{ + return + gst_caps_new ( + "mpeg2dec_src", + "video/raw", + gst_props_new ( + "fourcc", GST_PROPS_LIST ( + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')) ), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - NULL -}; + "width", GST_PROPS_INT_RANGE (16, 4096), + "height", GST_PROPS_INT_RANGE (16, 4096), + NULL + ) + ); +} -static GstCapsFactory raw_sink_caps = { - "raw_sink_caps", - "video/raw", - "fourcc", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')) - ), - "height", GST_PROPS_INT_RANGE (16, 256), - NULL -}; +static GstCaps* +raw_sink_caps (void) +{ + return + gst_caps_new ( + "raw_sink_caps", + "video/raw", + gst_props_new ( + "fourcc", GST_PROPS_LIST ( + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')) + ), + "height", GST_PROPS_INT_RANGE (16, 256), + NULL + ) + ); +} -static GstCapsFactory raw2_sink_caps = { - "raw2_sink_caps", - "video/raw", - "fourcc", GST_PROPS_LIST ( +static GstCaps* +raw2_sink_caps (void) +{ + return + gst_caps_new ( + "raw2_sink_caps", + "video/raw", + gst_props_new ( + "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')) - ), - "height", GST_PROPS_INT_RANGE (16, 4096), - NULL -}; + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')) + ), + "height", GST_PROPS_INT_RANGE (16, 4096), + NULL + ) + ); +} +static GstCaps* +get_testcaps (void) +{ + return + gst_caps_new ( + "raw2_sink_caps", + "video/raw", + gst_props_new ( + "fourcc", GST_PROPS_LIST ( + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')) + ), + "height", GST_PROPS_INT_RANGE (16, 4096), + NULL + ) + ); +} + static GstCaps *sinkcaps = NULL, *rawcaps = NULL, *rawcaps2 = NULL, *rawcaps3 = NULL, *mp1parsecaps = NULL; -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { gboolean testret; xmlDocPtr doc; @@ -68,25 +122,28 @@ int main(int argc,char *argv[]) doc = xmlNewDoc ("1.0"); doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL); + g_thread_init (NULL); _gst_type_initialize (); + _gst_props_initialize (); + _gst_caps_initialize (); - sinkcaps = gst_caps_register (&mpeg2dec_sink_caps); + sinkcaps = mpeg2dec_sink_caps (); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL); gst_caps_save_thyself (sinkcaps, parent); - rawcaps = gst_caps_register (&mpeg2dec_src_caps); + rawcaps = mpeg2dec_src_caps (); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL); gst_caps_save_thyself (rawcaps, parent); - rawcaps2 = gst_caps_register (&raw_sink_caps); + rawcaps2 = raw_sink_caps (); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities3", NULL); gst_caps_save_thyself (rawcaps2, parent); - mp1parsecaps = gst_caps_register (&mp1parse_src_caps); + mp1parsecaps = mp1parse_src_caps (); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities4", NULL); gst_caps_save_thyself (mp1parsecaps, parent); - rawcaps3 = gst_caps_register (&raw2_sink_caps); + rawcaps3 = raw2_sink_caps (); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL); gst_caps_save_thyself (rawcaps3, parent); diff --git a/tests/old/examples/plugins/example.c b/tests/old/examples/plugins/example.c index dbe5b28794..75e5c78ce6 100644 --- a/tests/old/examples/plugins/example.c +++ b/tests/old/examples/plugins/example.c @@ -57,34 +57,41 @@ enum { * can have. They can be quite complex, but for this example plugin * they are rather simple. */ -static GstPadFactory sink_factory = { - "sink", /* The name of the pad */ - GST_PAD_FACTORY_SINK, /* Direction of the pad */ - GST_PAD_FACTORY_ALWAYS, /* The pad exists for every instance */ - GST_PAD_FACTORY_CAPS( /* This factory has specific capabilities */ - "example_sink", /* The name of the caps */ - "unknown/unknown", /* The overall MIME/type */ - "foo", GST_PROPS_INT (1), /* An integer property */ - "bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */ - "baz", GST_PROPS_LIST ( /* A list of values for */ - GST_PROPS_INT (1), - GST_PROPS_INT (3) - ) - ), - NULL /* All factories must be NULL-terminated */ -}; +static GstPadTemplate* +sink_factory (void) +{ + return + gst_padtemplate_new ( + "sink", /* The name of the pad */ + GST_PAD_SINK, /* Direction of the pad */ + GST_PAD_ALWAYS, /* The pad exists for every instance */ + gst_caps_new ( + "example_sink", /* The name of the caps */ + "unknown/unknown", /* The overall MIME/type */ + gst_props_new ( + "foo", GST_PROPS_INT (1), /* An integer property */ + "bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */ + "baz", GST_PROPS_LIST ( /* A list of values for */ + GST_PROPS_INT (1), + GST_PROPS_INT (3) + ), + NULL))); +} /* This factory is much simpler, and defines the source pad. */ -static GstPadFactory src_factory = { - "src", - GST_PAD_FACTORY_SRC, - GST_PAD_FACTORY_ALWAYS, - GST_PAD_FACTORY_CAPS( - "example_src", - "unknown/unknown" - ), - NULL -}; +static GstPadTemplate* +src_factory (void) +{ + return + gst_padtemplate_new ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + gst_caps_new ( + "example_src", + "unknown/unknown", + NULL)); +} /* A number of functon prototypes are given so we can refer to them later. */ @@ -351,10 +358,10 @@ plugin_init (GModule *module) * Note that the generated padtemplates are stored in static global * variables, for the gst_example_init function to use later on. */ - sink_template = gst_padtemplate_new (&sink_factory); + sink_template = sink_factory (); gst_elementfactory_add_padtemplate (factory, sink_template); - src_template = gst_padtemplate_new (&src_factory); + src_template = src_factory (); gst_elementfactory_add_padtemplate (factory, src_template); /* The very last thing is to register the elementfactory with the plugin. */ diff --git a/tests/props.c b/tests/props.c index 8a9d3bb2b5..572af7a7be 100644 --- a/tests/props.c +++ b/tests/props.c @@ -1,22 +1,24 @@ #include -static GstPropsFactory mpeg2dec_sink_props = { - "mpegtype", GST_PROPS_LIST ( +static GstProps* mpeg2dec_sink_props_register (void) { + return gst_props_new ( + "mpegtype", GST_PROPS_LIST ( GST_PROPS_INT(1), GST_PROPS_INT(2) ), - NULL -}; + NULL); +} -static GstPropsFactory mpeg2dec_src_props = { - "fourcc", GST_PROPS_LIST ( +static GstProps* mpeg2dec_src_props_register (void) { + return gst_props_new ( + "fourcc", GST_PROPS_LIST ( GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')) ), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096), - NULL -}; + "width", GST_PROPS_INT_RANGE (16, 4096), + "height", GST_PROPS_INT_RANGE (16, 4096), + NULL); +} static GstProps *sinkprops = NULL, *rawprops = NULL, @@ -31,13 +33,14 @@ int main(int argc,char *argv[]) doc = xmlNewDoc ("1.0"); doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Properties", NULL); - _gst_type_initialize (); + g_thread_init (NULL); + _gst_props_initialize (); - sinkprops = gst_props_register (mpeg2dec_sink_props); + sinkprops = mpeg2dec_sink_props_register (); parent = xmlNewChild (doc->xmlRootNode, NULL, "Props1", NULL); gst_props_save_thyself (sinkprops, parent); - rawprops = gst_props_register (mpeg2dec_src_props); + rawprops = mpeg2dec_src_props_register (); parent = xmlNewChild (doc->xmlRootNode, NULL, "Props2", NULL); gst_props_save_thyself (rawprops, parent); diff --git a/tools/gstreamer-inspect.c b/tools/gstreamer-inspect.c index 86e4f07968..e18c5f4dcb 100644 --- a/tools/gstreamer-inspect.c +++ b/tools/gstreamer-inspect.c @@ -15,25 +15,25 @@ void print_prop(GstPropsEntry *prop,gboolean showname,gchar *pfx) { printf(pfx); switch (prop->propstype) { - case GST_PROPS_INT_ID_NUM: + case GST_PROPS_INT_ID: printf("Integer: %d\n",prop->data.int_data); break; - case GST_PROPS_INT_RANGE_ID_NUM: + case GST_PROPS_INT_RANGE_ID: printf("Integer range: %d - %d\n",prop->data.int_range_data.min, prop->data.int_range_data.max); break; - case GST_PROPS_BOOL_ID_NUM: + case GST_PROPS_BOOL_ID: printf("Boolean: %s\n",prop->data.bool_data ? "TRUE" : "FALSE"); break; - case GST_PROPS_STRING_ID_NUM: + case GST_PROPS_STRING_ID: printf("String: %s\n",prop->data.string_data.string); break; - case GST_PROPS_FOURCC_ID_NUM: + case GST_PROPS_FOURCC_ID: printf("FourCC: %c%c%c%c\n", prop->data.fourcc_data & 0xff,prop->data.fourcc_data>>8 & 0xff, prop->data.fourcc_data>>16 & 0xff,prop->data.fourcc_data>>24 & 0xff); break; - case GST_PROPS_LIST_ID_NUM: + case GST_PROPS_LIST_ID: printf("List:\n"); longprefix = g_strdup_printf("%s ",pfx); list = prop->data.list_data.entries;