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.
This commit is contained in:
Wim Taymans 2001-04-14 18:56:37 +00:00
parent 335080574f
commit b38d9a945b
27 changed files with 651 additions and 954 deletions

View file

@ -444,15 +444,6 @@ GST_GPAD_REALPAD
GstGhostPad GstGhostPad
gst_ghost_pad_new 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 GstPadPresence
GstPadTemplate GstPadTemplate
GST_PADTEMPLATE_CAPS GST_PADTEMPLATE_CAPS
@ -460,7 +451,6 @@ GST_PADTEMPLATE_DIRECTION
GST_PADTEMPLATE_NAME_TEMPLATE GST_PADTEMPLATE_NAME_TEMPLATE
GST_PADTEMPLATE_PRESENCE GST_PADTEMPLATE_PRESENCE
gst_padtemplate_new gst_padtemplate_new
gst_padtemplate_create
gst_padtemplate_load_thyself gst_padtemplate_load_thyself
gst_padtemplate_save_thyself gst_padtemplate_save_thyself
gst_padtemplate_get_caps gst_padtemplate_get_caps
@ -498,7 +488,6 @@ GST_PADTEMPLATE_CLASS
GST_IS_PADTEMPLATE GST_IS_PADTEMPLATE
GST_IS_PADTEMPLATE_CLASS GST_IS_PADTEMPLATE_CLASS
gst_padtemplate_get_type gst_padtemplate_get_type
GST_PAD_FACTORY_CAPS_ID
</SECTION> </SECTION>
<SECTION> <SECTION>
@ -627,16 +616,10 @@ GST_CAPS_LOCK
GST_CAPS_TRYLOCK GST_CAPS_TRYLOCK
GST_CAPS_UNLOCK GST_CAPS_UNLOCK
GstCaps GstCaps
GstCapsFactory
GstCapsFactoryEntry
GstCapsFactory[]
gst_caps_new gst_caps_new
gst_caps_new_with_props
gst_caps_destroy gst_caps_destroy
gst_caps_ref gst_caps_ref
gst_caps_unref gst_caps_unref
gst_caps_register
gst_caps_register_count
gst_caps_copy gst_caps_copy
gst_caps_copy_on_write gst_caps_copy_on_write
gst_caps_append gst_caps_append
@ -668,8 +651,6 @@ GST_CAPS
<FILE>gstprops</FILE> <FILE>gstprops</FILE>
<TITLE>GstProps</TITLE> <TITLE>GstProps</TITLE>
GstProps GstProps
GstPropsFactoryEntry
GstPropsFactory[]
GST_MAKE_FOURCC GST_MAKE_FOURCC
GST_PROPS_LIST GST_PROPS_LIST
GST_PROPS_INT GST_PROPS_INT
@ -679,11 +660,8 @@ GST_PROPS_BOOLEAN
GST_PROPS_STRING GST_PROPS_STRING
GST_PROPS_FLOAT GST_PROPS_FLOAT
GST_PROPS_FLOAT_RANGE 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_new
gst_props_newv
gst_props_merge gst_props_merge
gst_props_copy gst_props_copy
gst_props_copy_on_write gst_props_copy_on_write
@ -700,18 +678,7 @@ gst_props_save_thyself
gst_props_load_thyself gst_props_load_thyself
<SUBSECTION Standard> <SUBSECTION Standard>
GstPropsEntry GstPropsEntry
GstPropsListFactory[]
GstPropsId 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
</SECTION> </SECTION>
<SECTION> <SECTION>

View file

@ -51,39 +51,11 @@ Unlock the caps structure
@properties: the properties of the capability @properties: the properties of the capability
@next: a pointer to the next caps. @next: a pointer to the next caps.
<!-- ##### TYPEDEF GstCapsFactory ##### -->
<para>
</para>
<!-- ##### TYPEDEF GstCapsFactoryEntry ##### -->
<para>
</para>
<!-- ##### TYPEDEF GstCapsFactory[] ##### -->
<para>
</para>
<!-- ##### FUNCTION gst_caps_new ##### --> <!-- ##### FUNCTION gst_caps_new ##### -->
<para> <para>
</para> </para>
@name:
@mime:
@Returns:
<!-- ##### FUNCTION gst_caps_new_with_props ##### -->
<para>
</para>
@name: @name:
@mime: @mime:
@props: @props:
@ -114,27 +86,6 @@ Unlock the caps structure
@caps: @caps:
<!-- ##### FUNCTION gst_caps_register ##### -->
<para>
</para>
@factory:
@Returns:
<!-- ##### FUNCTION gst_caps_register_count ##### -->
<para>
</para>
@factory:
@counter:
@Returns:
<!-- # Unused Parameters # -->
@count:
<!-- ##### FUNCTION gst_caps_copy ##### --> <!-- ##### FUNCTION gst_caps_copy ##### -->
<para> <para>

View file

@ -797,64 +797,6 @@ Get the real pad of this ghost pad.
@Returns: @Returns:
<!-- ##### TYPEDEF GstPadFactoryEntry ##### -->
<para>
Defines an entry for a padfactory.
</para>
<!-- ##### TYPEDEF GstPadFactory[] ##### -->
<para>
The padfactory.
</para>
<!-- ##### MACRO GST_PAD_FACTORY_SOMETIMES ##### -->
<para>
Indicate that this pad will become available depending
on the media type. Use this in the factory definition.
</para>
<!-- ##### MACRO GST_PAD_FACTORY_ALWAYS ##### -->
<para>
Indicate that this pad will always be available.
Use this in the factory definition.
</para>
<!-- ##### MACRO GST_PAD_FACTORY_REQUEST ##### -->
<para>
Indicates that this pad will be available on request. Use
this in the factory definition.
</para>
<!-- ##### MACRO GST_PAD_FACTORY_SINK ##### -->
<para>
Indicates a sinkpad for the padfactory.
</para>
<!-- ##### MACRO GST_PAD_FACTORY_SRC ##### -->
<para>
Indicates a srcpad for the padfactory.
</para>
<!-- ##### MACRO GST_PAD_FACTORY_CAPS ##### -->
<para>
Starts the declaration of a the capabilities for this padtemplate.
</para>
@a...: a capability factory
<!-- ##### ENUM GstPadPresence ##### --> <!-- ##### ENUM GstPadPresence ##### -->
<para> <para>
Indicates when this pad will become available. Indicates when this pad will become available.
@ -912,20 +854,14 @@ Indicates when this pad will become available.
</para> </para>
@factory:
@Returns:
<!-- ##### FUNCTION gst_padtemplate_create ##### -->
<para>
</para>
@name_template: @name_template:
@direction: @direction:
@presence: @presence:
@caps: @caps:
@Varargs:
@Returns: @Returns:
<!-- # Unused Parameters # -->
@factory:
<!-- ##### FUNCTION gst_padtemplate_load_thyself ##### --> <!-- ##### FUNCTION gst_padtemplate_load_thyself ##### -->

View file

@ -24,18 +24,6 @@ GstCaps
@lock: @lock:
@properties: the properties @properties: the properties
<!-- ##### TYPEDEF GstPropsFactoryEntry ##### -->
<para>
</para>
<!-- ##### TYPEDEF GstPropsFactory[] ##### -->
<para>
</para>
<!-- ##### MACRO GST_MAKE_FOURCC ##### --> <!-- ##### MACRO GST_MAKE_FOURCC ##### -->
<para> <para>
@ -117,50 +105,26 @@ Create a boolean property.
@b: @b:
<!-- ##### MACRO GST_PROPS_FLOAT_STRING ##### -->
<para>
</para>
@a:
<!-- ##### MACRO GST_PROPS_FLOAT_RANGE_STRING ##### -->
<para>
</para>
@a:
@b:
<!-- ##### FUNCTION gst_props_register ##### -->
<para>
</para>
@factory:
@Returns:
<!-- ##### FUNCTION gst_props_register_count ##### -->
<para>
</para>
@factory:
@counter:
@Returns:
<!-- ##### FUNCTION gst_props_new ##### --> <!-- ##### FUNCTION gst_props_new ##### -->
<para> <para>
</para> </para>
@entry: @firstname:
@Varargs: @Varargs:
@Returns: @Returns:
<!-- # Unused Parameters # -->
@entry:
<!-- ##### FUNCTION gst_props_newv ##### -->
<para>
</para>
@firstname:
@var_args:
@Returns:
<!-- ##### FUNCTION gst_props_merge ##### --> <!-- ##### FUNCTION gst_props_merge ##### -->
@ -235,10 +199,10 @@ Create a boolean property.
@props: @props:
@name: @name:
@entry:
@Varargs: @Varargs:
@Returns: @Returns:
<!-- # Unused Parameters # --> <!-- # Unused Parameters # -->
@entry:
@value: @value:

View file

@ -207,6 +207,12 @@ the stream.
@Returns: @Returns:
<!-- ##### TYPEDEF GstCapsFactoryEntry ##### -->
<para>
</para>
<!-- ##### MACRO GST_IS_DISKSRC_CLASS ##### --> <!-- ##### MACRO GST_IS_DISKSRC_CLASS ##### -->
<para> <para>
@ -226,6 +232,17 @@ the stream.
</para> </para>
<!-- ##### FUNCTION gst_padtemplate_create ##### -->
<para>
</para>
@name_template:
@direction:
@presence:
@caps:
@Returns:
<!-- ##### MACRO GST_IS_ESDSINK_CLASS ##### --> <!-- ##### MACRO GST_IS_ESDSINK_CLASS ##### -->
<para> <para>
@ -610,6 +627,12 @@ Specify the current offset in the file.
@Returns: @Returns:
<!-- ##### TYPEDEF GstCapsFactory[] ##### -->
<para>
</para>
<!-- ##### MACRO GST_PROPS_BOOL_ID ##### --> <!-- ##### MACRO GST_PROPS_BOOL_ID ##### -->
<para> <para>
@ -899,6 +922,12 @@ The fequency.
@obj: @obj:
<!-- ##### TYPEDEF GstPropsFactory[] ##### -->
<para>
</para>
<!-- ##### SIGNAL GstAudioSink::handoff ##### --> <!-- ##### SIGNAL GstAudioSink::handoff ##### -->
<para> <para>
The buffer is sent to the sound card. The buffer is sent to the sound card.
@ -960,6 +989,16 @@ The buffer is sent to the sound card.
</para> </para>
<!-- ##### FUNCTION gst_caps_register_count ##### -->
<para>
</para>
@factory:
@counter:
@Returns:
@count:
<!-- ##### MACRO GST_TYPE_HTTPSRC ##### --> <!-- ##### MACRO GST_TYPE_HTTPSRC ##### -->
<para> <para>
@ -1151,6 +1190,12 @@ Flags for the GstSrc element
GstColorSpace GstColorSpace
<!-- ##### TYPEDEF GstPadFactoryEntry ##### -->
<para>
Defines an entry for a padfactory.
</para>
<!-- ##### ENUM GstAsyncDiskSrcFlags ##### --> <!-- ##### ENUM GstAsyncDiskSrcFlags ##### -->
<para> <para>
<informaltable pgwide=1 frame="none" role="enum"> <informaltable pgwide=1 frame="none" role="enum">
@ -1218,6 +1263,12 @@ GstColorSpace
@Returns: @Returns:
<!-- ##### MACRO GST_PAD_FACTORY_SINK ##### -->
<para>
Indicates a sinkpad for the padfactory.
</para>
<!-- ##### MACRO GST_SRC_CLASS ##### --> <!-- ##### MACRO GST_SRC_CLASS ##### -->
<para> <para>
@ -1376,6 +1427,13 @@ This macro sets the given flags.
</para> </para>
<!-- ##### MACRO GST_PROPS_FLOAT_STRING ##### -->
<para>
</para>
@a:
<!-- ##### FUNCTION gst_filter_get_type ##### --> <!-- ##### FUNCTION gst_filter_get_type ##### -->
<para> <para>
@ -1444,6 +1502,12 @@ The frequency.
</para> </para>
<!-- ##### MACRO GST_PAD_FACTORY_SRC ##### -->
<para>
Indicates a srcpad for the padfactory.
</para>
<!-- ##### MACRO GST_IS_SINK_CLASS ##### --> <!-- ##### MACRO GST_IS_SINK_CLASS ##### -->
<para> <para>
@ -1553,6 +1617,13 @@ The frequency.
@name: @name:
@Returns: @Returns:
<!-- ##### MACRO GST_PAD_FACTORY_CAPS ##### -->
<para>
Starts the declaration of a the capabilities for this padtemplate.
</para>
@a...: a capability factory
<!-- ##### SECTION ./tmpl/gstsrc.sgml:Title ##### --> <!-- ##### SECTION ./tmpl/gstsrc.sgml:Title ##### -->
GstSrc GstSrc
@ -1573,6 +1644,16 @@ GstSrc
@pad: @pad:
@buf: @buf:
<!-- ##### FUNCTION gst_caps_new_with_props ##### -->
<para>
</para>
@name:
@mime:
@props:
@Returns:
<!-- ##### MACRO GST_TYPE_AUDIOSRC ##### --> <!-- ##### MACRO GST_TYPE_AUDIOSRC ##### -->
<para> <para>
@ -1750,6 +1831,14 @@ Query whether this object has multiple input pads.
</para> </para>
<!-- ##### FUNCTION gst_props_register ##### -->
<para>
</para>
@factory:
@Returns:
<!-- ##### STRUCT GstThreadClass ##### --> <!-- ##### STRUCT GstThreadClass ##### -->
<para> <para>
@ -1796,6 +1885,12 @@ Information about video buffers.
@klass: @klass:
<!-- ##### TYPEDEF GstPropsFactoryEntry ##### -->
<para>
</para>
<!-- ##### MACRO GST_IS_FILTER_CLASS ##### --> <!-- ##### MACRO GST_IS_FILTER_CLASS ##### -->
<para> <para>
@ -2051,6 +2146,23 @@ The start point of a filter graph
@src: @src:
<!-- ##### FUNCTION gst_props_register_count ##### -->
<para>
</para>
@factory:
@counter:
@Returns:
<!-- ##### MACRO GST_PROPS_FLOAT_RANGE_STRING ##### -->
<para>
</para>
@a:
@b:
<!-- ##### MACRO GST_FAKESRC_CLASS ##### --> <!-- ##### MACRO GST_FAKESRC_CLASS ##### -->
<para> <para>
@ -2110,6 +2222,13 @@ The start point of a filter graph
@klass: <<<<<<< gstreamer-unused.sgml @klass: <<<<<<< gstreamer-unused.sgml
<!-- ##### MACRO GST_PAD_FACTORY_REQUEST ##### -->
<para>
Indicates that this pad will be available on request. Use
this in the factory definition.
</para>
<!-- ##### FUNCTION gst_audiosink_sync_parms ##### --> <!-- ##### FUNCTION gst_audiosink_sync_parms ##### -->
<para> <para>
@ -2147,6 +2266,13 @@ This macro unsets the given state on the element.
@pad: @pad:
@id: @id:
<!-- ##### MACRO GST_PAD_FACTORY_ALWAYS ##### -->
<para>
Indicate that this pad will always be available.
Use this in the factory definition.
</para>
<!-- ##### FUNCTION gst_pad_add_ghost_parent ##### --> <!-- ##### FUNCTION gst_pad_add_ghost_parent ##### -->
<para> <para>
@ -2396,6 +2522,12 @@ Information about audio buffers.
Take data in and spit data out Take data in and spit data out
<!-- ##### TYPEDEF GstPadFactory[] ##### -->
<para>
The padfactory.
</para>
<!-- ##### MACRO GST_SRC_ASYNC ##### --> <!-- ##### MACRO GST_SRC_ASYNC ##### -->
<para> <para>
This macro checks to see if the GST_SRC_ASYNC flag is set. 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.
</para> </para>
<!-- ##### TYPEDEF GstCapsFactory ##### -->
<para>
</para>
<!-- ##### STRUCT GstFdSrcClass ##### --> <!-- ##### STRUCT GstFdSrcClass ##### -->
<para> <para>
@ -2515,6 +2653,14 @@ Information about audio buffers.
</para> </para>
<!-- ##### FUNCTION gst_caps_register ##### -->
<para>
</para>
@factory:
@Returns:
<!-- ##### FUNCTION plugin_initialize ##### --> <!-- ##### FUNCTION plugin_initialize ##### -->
<para> <para>
@ -2561,6 +2707,13 @@ Specify the location of the file to read.
GstAudioSrc GstAudioSrc
<!-- ##### MACRO GST_PAD_FACTORY_SOMETIMES ##### -->
<para>
Indicate that this pad will become available depending
on the media type. Use this in the factory definition.
</para>
<!-- ##### MACRO INFO ##### --> <!-- ##### MACRO INFO ##### -->
<para> <para>

View file

@ -1,64 +0,0 @@
<!-- ##### SECTION Title ##### -->
videoraw
<!-- ##### SECTION Short_Description ##### -->
Information about video buffers.
<!-- ##### SECTION Long_Description ##### -->
<para>
Information about video buffers.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT MetaVideoRaw ##### -->
<para>
</para>
@meta:
@format:
@visual:
@width:
@height:
@overlay_info:
@dga_info:
<!-- ##### STRUCT MetaDGA ##### -->
<para>
</para>
@base:
@swidth:
@sheight:
@bytes_per_line:
<!-- ##### STRUCT MetaOverlay ##### -->
<para>
</para>
@wx:
@wy:
@overlay_element:
@clip_count:
@overlay_clip:
@width:
@height:
@did_overlay:
@fully_obscured:
<!-- ##### STRUCT OverlayClip ##### -->
<para>
</para>
@x1:
@x2:
@y1:
@y2:

View file

@ -248,16 +248,16 @@ static gchar*
gst_editor_props_show_func (GstPropsEntry *entry) gst_editor_props_show_func (GstPropsEntry *entry)
{ {
switch (entry->propstype) { switch (entry->propstype) {
case GST_PROPS_INT_ID_NUM: case GST_PROPS_INT_ID:
return g_strdup_printf ("%d", entry->data.int_data); return g_strdup_printf ("%d", entry->data.int_data);
break; 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); return g_strdup_printf ("%d-%d", entry->data.int_range_data.min, entry->data.int_range_data.max);
break; break;
case GST_PROPS_FOURCC_ID_NUM: case GST_PROPS_FOURCC_ID:
return g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data); return g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data);
break; break;
case GST_PROPS_BOOL_ID_NUM: case GST_PROPS_BOOL_ID:
return g_strdup_printf ("%s", (entry->data.bool_data ? "TRUE" : "FALSE")); return g_strdup_printf ("%s", (entry->data.bool_data ? "TRUE" : "FALSE"));
break; break;
default: default:
@ -272,7 +272,7 @@ gst_editor_add_caps_to_tree (GstCaps *caps, GtkWidget *tree, GtkCTreeNode *padno
if (caps) { if (caps) {
GstProps *props = gst_caps_get_props (caps); GstProps *props = gst_caps_get_props (caps);
if (props) { if (props) {
GSList *propslist = props->properties; GList *propslist = props->properties;
while (propslist) { while (propslist) {
gchar *data[2]; 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); data[0] = g_quark_to_string (entry->propid);
switch (entry->propstype) { switch (entry->propstype) {
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
{ {
GList *list; GList *list;
guint count = 0; 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, gtk_ctree_insert_node (GTK_CTREE (tree), padnode, NULL, data, 0,
NULL, NULL, NULL, NULL, TRUE, TRUE); 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); pads = gst_element_get_padtemplate_list(realelement);
while (pads) { while (pads) {
GstPadTemplate *templ = (GstPadTemplate *)pads->data; GstPadTemplate *templ = (GstPadTemplate *)pads->data;
GList *caps = templ->caps; GstCaps *caps = templ->caps;
gchar *mime; gchar *mime;
gchar *data[2]; gchar *data[2];
GtkCTreeNode *padnode; GtkCTreeNode *padnode;
if (caps) { if (caps) {
GstType *type; GstType *type;
type = gst_type_find_by_id (((GstCaps *)caps->data)->id); type = gst_type_find_by_id (((GstCaps *)caps)->id);
mime = type->mime; mime = type->mime;
} }
else { else {
@ -377,11 +377,11 @@ gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element)
NULL, NULL, NULL, NULL, FALSE, TRUE); NULL, NULL, NULL, NULL, FALSE, TRUE);
while (caps) { while (caps) {
GstCaps *cap = (GstCaps *)caps->data; GstCaps *cap = (GstCaps *)caps;
gst_editor_add_caps_to_tree (cap, tree, padnode); gst_editor_add_caps_to_tree (cap, tree, padnode);
caps = g_list_next (caps); caps = (caps)->next;
} }
pads = g_list_next (pads); pads = g_list_next (pads);

View file

@ -57,34 +57,41 @@ enum {
* can have. They can be quite complex, but for this example plugin * can have. They can be quite complex, but for this example plugin
* they are rather simple. * they are rather simple.
*/ */
static GstPadFactory sink_factory = { static GstPadTemplate*
"sink", /* The name of the pad */ sink_factory (void)
GST_PAD_FACTORY_SINK, /* Direction of the pad */ {
GST_PAD_FACTORY_ALWAYS, /* The pad exists for every instance */ return
GST_PAD_FACTORY_CAPS( /* This factory has specific capabilities */ gst_padtemplate_new (
"example_sink", /* The name of the caps */ "sink", /* The name of the pad */
"unknown/unknown", /* The overall MIME/type */ GST_PAD_SINK, /* Direction of the pad */
"foo", GST_PROPS_INT (1), /* An integer property */ GST_PAD_ALWAYS, /* The pad exists for every instance */
"bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */ gst_caps_new (
"baz", GST_PROPS_LIST ( /* A list of values for */ "example_sink", /* The name of the caps */
GST_PROPS_INT (1), "unknown/unknown", /* The overall MIME/type */
GST_PROPS_INT (3) gst_props_new (
) "foo", GST_PROPS_INT (1), /* An integer property */
), "bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */
NULL /* All factories must be NULL-terminated */ "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. */ /* This factory is much simpler, and defines the source pad. */
static GstPadFactory src_factory = { static GstPadTemplate*
"src", src_factory (void)
GST_PAD_FACTORY_SRC, {
GST_PAD_FACTORY_ALWAYS, return
GST_PAD_FACTORY_CAPS( gst_padtemplate_new (
"example_src", "src",
"unknown/unknown" GST_PAD_SRC,
), GST_PAD_ALWAYS,
NULL gst_caps_new (
}; "example_src",
"unknown/unknown",
NULL));
}
/* A number of functon prototypes are given so we can refer to them later. */ /* 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 * Note that the generated padtemplates are stored in static global
* variables, for the gst_example_init function to use later on. * 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); 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); gst_elementfactory_add_padtemplate (factory, src_template);
/* The very last thing is to register the elementfactory with the plugin. */ /* The very last thing is to register the elementfactory with the plugin. */

View file

@ -45,13 +45,17 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
static GstPadFactory tee_src_factory = { static GstPadTemplate*
"src%d", tee_src_factory_create (void)
GST_PAD_FACTORY_SRC, {
GST_PAD_FACTORY_REQUEST, return
NULL, /* no caps */ gst_padtemplate_new (
NULL, "src%d",
}; GST_PAD_SRC,
GST_PAD_REQUEST,
NULL /* no caps */
);
}
static void gst_tee_class_init (GstTeeClass *klass); static void gst_tee_class_init (GstTeeClass *klass);
@ -197,7 +201,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf)
gboolean gboolean
gst_tee_factory_init (GstElementFactory *factory) 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); gst_elementfactory_add_padtemplate (factory, gst_tee_src_template);
return TRUE; return TRUE;

View file

@ -62,13 +62,14 @@ get_type_for_mime (const gchar *mime)
* gst_caps_new: * gst_caps_new:
* @name: the name of this capability * @name: the name of this capability
* @mime: the mime type to attach to the 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 * Returns: a new capability
*/ */
GstCaps* GstCaps*
gst_caps_new (const gchar *name, const gchar *mime) gst_caps_new (const gchar *name, const gchar *mime, GstProps *props)
{ {
GstCaps *caps; GstCaps *caps;
@ -80,7 +81,7 @@ gst_caps_new (const gchar *name, const gchar *mime)
caps->name = g_strdup (name); caps->name = g_strdup (name);
caps->id = get_type_for_mime (mime); caps->id = get_type_for_mime (mime);
caps->properties = NULL; caps->properties = props;
caps->next = NULL; caps->next = NULL;
caps->refcount = 1; caps->refcount = 1;
caps->lock = g_mutex_new (); caps->lock = g_mutex_new ();
@ -88,78 +89,6 @@ gst_caps_new (const gchar *name, const gchar *mime)
return caps; 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: * gst_caps_destroy:
* @caps: the caps to destroy * @caps: the caps to destroy
@ -244,7 +173,7 @@ gst_caps_copy (GstCaps *caps)
g_return_val_if_fail (caps != NULL, NULL); g_return_val_if_fail (caps != NULL, NULL);
GST_CAPS_LOCK (caps); GST_CAPS_LOCK (caps);
new = gst_caps_new_with_props ( new = gst_caps_new (
caps->name, caps->name,
(gst_type_find_by_id (caps->id))->mime, (gst_type_find_by_id (caps->id))->mime,
gst_props_copy (caps->properties)); gst_props_copy (caps->properties));

View file

@ -36,12 +36,6 @@
#include <gst/gstprops.h> #include <gst/gstprops.h>
typedef struct _GstCaps GstCaps; 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) \ #define GST_CAPS(caps) \
((GstCaps *)(caps)) ((GstCaps *)(caps))
@ -65,10 +59,7 @@ struct _GstCaps {
/* initialize the subsystem */ /* initialize the subsystem */
void _gst_caps_initialize (void); void _gst_caps_initialize (void);
GstCaps* gst_caps_new (const gchar *name, const gchar *mime); GstCaps* gst_caps_new (const gchar *name, const gchar *mime, GstProps *props);
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);
void gst_caps_unref (GstCaps *caps); void gst_caps_unref (GstCaps *caps);
void gst_caps_ref (GstCaps *caps); void gst_caps_ref (GstCaps *caps);

View file

@ -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: * gst_padtemplate_create:
* @name_template: the name template * @name_template: the name template
@ -1450,11 +1408,13 @@ gst_padtemplate_new (GstPadFactory *factory)
* Returns: the new padtemplate * Returns: the new padtemplate
*/ */
GstPadTemplate* GstPadTemplate*
gst_padtemplate_create (gchar *name_template, gst_padtemplate_new (gchar *name_template,
GstPadDirection direction, GstPadPresence presence, GstPadDirection direction, GstPadPresence presence,
GstCaps *caps) GstCaps *caps, ...)
{ {
GstPadTemplate *new; GstPadTemplate *new;
va_list var_args;
GstCaps *thecaps = NULL;
g_return_val_if_fail (name_template != NULL, 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_NAME_TEMPLATE (new) = name_template;
GST_PADTEMPLATE_DIRECTION (new) = direction; GST_PADTEMPLATE_DIRECTION (new) = direction;
GST_PADTEMPLATE_PRESENCE (new) = presence; 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; return new;
} }
@ -1581,7 +1550,7 @@ gst_padtemplate_load_thyself (xmlNodePtr parent)
field = field->next; field = field->next;
} }
factory = gst_padtemplate_create (name_template, direction, presence, caps); factory = gst_padtemplate_new (name_template, direction, presence, caps, NULL);
return factory; return factory;
} }

View file

@ -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_pad_get_type (void);
GtkType gst_real_pad_get_type (void); GtkType gst_real_pad_get_type (void);
GtkType gst_ghost_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 */ /* templates and factories */
GtkType gst_padtemplate_get_type (void); GtkType gst_padtemplate_get_type (void);
GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory); GstPadTemplate* gst_padtemplate_new (gchar *name_template,
GstPadTemplate* gst_padtemplate_create (gchar *name_template,
GstPadDirection direction, GstPadPresence presence, GstPadDirection direction, GstPadPresence presence,
GstCaps *caps); GstCaps *caps, ...);
GstCaps* gst_padtemplate_get_caps (GstPadTemplate *templ); GstCaps* gst_padtemplate_get_caps (GstPadTemplate *templ);
GstCaps* gst_padtemplate_get_caps_by_name (GstPadTemplate *templ, const gchar *name); GstCaps* gst_padtemplate_get_caps_by_name (GstPadTemplate *templ, const gchar *name);

View file

@ -364,6 +364,8 @@ gst_plugin_load_absolute (const gchar *name)
module = g_module_open(name,G_MODULE_BIND_LAZY); module = g_module_open(name,G_MODULE_BIND_LAZY);
if (module != NULL) { if (module != NULL) {
if (g_module_symbol(module,"plugin_init",(gpointer *)&initfunc)) { if (g_module_symbol(module,"plugin_init",(gpointer *)&initfunc)) {
GST_INFO (GST_CAT_PLUGIN_LOADING,"loading plugin \"%s\"...",
name);
if ((plugin = (initfunc)(module))) { if ((plugin = (initfunc)(module))) {
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" loaded: %d elements, %d types", GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" loaded: %d elements, %d types",
plugin->name,plugin->numelements,plugin->numtypes); plugin->name,plugin->numelements,plugin->numtypes);

View file

@ -34,18 +34,6 @@ static GMutex *_gst_props_chunk_lock;
static gboolean gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry2); 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 void
_gst_props_initialize (void) _gst_props_initialize (void)
{ {
@ -67,16 +55,16 @@ gst_props_debug_entry (GstPropsEntry *entry)
case GST_PROPS_INT_ID: case GST_PROPS_INT_ID:
GST_DEBUG (0, "%d\n", entry->data.int_data); GST_DEBUG (0, "%d\n", entry->data.int_data);
break; break;
case GST_PROPS_FOURCC_ID_NUM: case GST_PROPS_FOURCC_ID:
GST_DEBUG (0, "%4.4s\n", (gchar*)&entry->data.fourcc_data); GST_DEBUG (0, "%4.4s\n", (gchar*)&entry->data.fourcc_data);
break; break;
case GST_PROPS_BOOL_ID_NUM: case GST_PROPS_BOOL_ID:
GST_DEBUG (0, "%d\n", entry->data.bool_data); GST_DEBUG (0, "%d\n", entry->data.bool_data);
break; break;
case GST_PROPS_STRING_ID_NUM: case GST_PROPS_STRING_ID:
GST_DEBUG (0, "%s\n", entry->data.string_data.string); GST_DEBUG (0, "%s\n", entry->data.string_data.string);
break; 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, GST_DEBUG (0, "%d-%d\n", entry->data.int_range_data.min,
entry->data.int_range_data.max); entry->data.int_range_data.max);
break; 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 static gint
props_compare_func (gconstpointer a, props_compare_func (gconstpointer a,
gconstpointer b) gconstpointer b)
@ -166,184 +93,139 @@ props_find_func (gconstpointer a,
return (entry1 - entry2->propid); return (entry1 - entry2->propid);
} }
/** static void
* gst_props_register: gst_props_entry_fill (GstPropsEntry *entry, va_list *var_args)
* @factory: the factory to register
*
* Register the factory.
*
* Returns: the new property created from the factory
*/
GstProps *
gst_props_register (GstPropsFactory factory)
{ {
guint dummy; entry->propstype = va_arg (*var_args, GstPropsId);
return gst_props_register_count (factory, &dummy); switch (entry->propstype) {
} case GST_PROPS_INT_ID:
entry->data.int_data = va_arg (*var_args, gint);
/** break;
* gst_props_register_count: case GST_PROPS_INT_RANGE_ID:
* @factory: the factory to register entry->data.int_range_data.min = va_arg (*var_args, gint);
* @counter: count how many fields were consumed entry->data.int_range_data.max = va_arg (*var_args, gint);
* break;
* Register the factory. case GST_PROPS_FLOAT_ID:
* entry->data.float_data = va_arg (*var_args, gfloat);
* Returns: the new property created from the factory break;
*/ case GST_PROPS_FLOAT_RANGE_ID:
GstProps * entry->data.float_range_data.min = va_arg (*var_args, gfloat);
gst_props_register_count (GstPropsFactory factory, guint *counter) entry->data.float_range_data.max = va_arg (*var_args, gfloat);
{ break;
GstPropsFactoryEntry tag; case GST_PROPS_FOURCC_ID:
gint i = 0; entry->data.fourcc_data = va_arg (*var_args, gulong);
GstProps *props = NULL; break;
gint skipped; case GST_PROPS_BOOL_ID:
entry->data.bool_data = va_arg (*var_args, gboolean);
g_return_val_if_fail (factory != NULL, NULL); break;
case GST_PROPS_STRING_ID:
tag = factory[i++]; entry->data.string_data.string = g_strdup (va_arg (*var_args, gchar*));
break;
if (!tag) goto end; default:
break;
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++];
} }
end:
*counter = i;
return props;
} }
/** /**
* gst_props_new: * gst_props_new:
* @entry: the property entries for the property * @firstname: the first property name
* @...: the property entries for the property * @...: 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. * Create a new property from the list of entries.
* *
* Returns: the new property created from the list of entries * Returns: the new property created from the list of entries
*/ */
GstProps* 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; GstProps *props;
gboolean inlist = FALSE;
const gchar *prop_name;
GstPropsEntry *list_entry = NULL;
#define add_value(value) {\ g_mutex_lock (_gst_props_chunk_lock);
GST_DEBUG (0,"%d %p\n", i, value);\ props = g_mem_chunk_alloc (_gst_props_chunk);
factory[i++] = value; \ g_mutex_unlock (_gst_props_chunk_lock);
if (i >= size) { \
size += 16; \
factory = (GstPropsFactoryEntry *) g_realloc (factory, size*sizeof(GstPropsFactoryEntry));\
}\
}
size = 16; props->properties = NULL;
factory = (GstPropsFactoryEntry *) g_malloc (size*sizeof(GstPropsFactoryEntry)); props->refcount = 1;
prop_name = firstname;
va_start (var_args, entry);
// property name
value = (GstPropsFactoryEntry) entry;
// properties // properties
while (value) { while (prop_name) {
if (!inlist) { GstPropsEntry *entry;
// add name
add_value (value); 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 entry->propid = g_quark_from_string (prop_name);
value = va_arg (var_args, GstPropsFactoryEntry); gst_props_entry_fill (entry, &var_args);
}
switch (GPOINTER_TO_INT (value)) {
case GST_PROPS_END_ID_NUM:
g_assert (inlist == TRUE);
inlist = FALSE; switch (entry->propstype) {
skip = 0; 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; break;
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
{ g_return_val_if_fail (inlist == FALSE, NULL);
g_assert (inlist == FALSE);
skip = 0;
inlist = TRUE; inlist = TRUE;
list_entry = entry;
list_entry->data.list_data.entries = NULL;
break; 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: default:
skip = _arg_len[GPOINTER_TO_INT (value)]; g_mutex_lock (_gst_props_entries_chunk_lock);
break; 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; return props;
} }
@ -352,7 +234,6 @@ gst_props_new (GstPropsFactoryEntry entry, ...)
* gst_props_set: * gst_props_set:
* @props: the props to modify * @props: the props to modify
* @name: the name of the entry to modify * @name: the name of the entry to modify
* @entry: The new value of the property entry
* @...: More property entries. * @...: More property entries.
* *
* Modifies the value of the given entry in the props struct. * 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. * Returns: the new modified property structure.
*/ */
GstProps* GstProps*
gst_props_set (GstProps *props, const gchar *name, GstPropsFactoryEntry entry, ...) gst_props_set (GstProps *props, const gchar *name, ...)
{ {
GQuark quark; GQuark quark;
GList *lentry; 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); lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
if (lentry) { if (lentry) {
GstPropsEntry *thisentry; GstPropsEntry *entry;
GstPropsFactoryEntry value;
thisentry = (GstPropsEntry *)lentry->data; entry = (GstPropsEntry *)lentry->data;
va_start (var_args, entry); va_start (var_args, name);
// property name
value = (GstPropsFactoryEntry) entry;
switch (GPOINTER_TO_INT (value)) { gst_props_entry_fill (entry, &var_args);
case GST_PROPS_INT_ID:
thisentry->propstype = GST_PROPS_INT_ID_NUM; va_end (var_args);
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;
}
} }
else { else {
g_print("gstprops: no property '%s' to change\n", name); 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), GST_DEBUG (0,"compare: %s %s\n", g_quark_to_string (entry1->propid),
g_quark_to_string (entry2->propid)); g_quark_to_string (entry2->propid));
switch (entry1->propstype) { switch (entry1->propstype) {
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
{ {
GList *entrylist = entry1->data.list_data.entries; GList *entrylist = entry1->data.list_data.entries;
gboolean valid = TRUE; // innocent until proven guilty gboolean valid = TRUE; // innocent until proven guilty
@ -751,90 +602,90 @@ gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry
return valid; return valid;
} }
case GST_PROPS_INT_RANGE_ID_NUM: case GST_PROPS_INT_RANGE_ID:
switch (entry2->propstype) { switch (entry2->propstype) {
// a - b <---> a - c // 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 && 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); 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); return gst_props_entry_check_list_compatibility (entry1, entry2);
default: default:
return FALSE; return FALSE;
} }
break; break;
case GST_PROPS_FLOAT_RANGE_ID_NUM: case GST_PROPS_FLOAT_RANGE_ID:
switch (entry2->propstype) { switch (entry2->propstype) {
// a - b <---> a - c // 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 && 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); 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); return gst_props_entry_check_list_compatibility (entry1, entry2);
default: default:
return FALSE; return FALSE;
} }
break; break;
case GST_PROPS_FOURCC_ID_NUM: case GST_PROPS_FOURCC_ID:
switch (entry2->propstype) { switch (entry2->propstype) {
// b <---> a // b <---> a
case GST_PROPS_FOURCC_ID_NUM: case GST_PROPS_FOURCC_ID:
return (entry2->data.fourcc_data == entry1->data.fourcc_data); return (entry2->data.fourcc_data == entry1->data.fourcc_data);
// b <---> a,b,c // b <---> a,b,c
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
return gst_props_entry_check_list_compatibility (entry1, entry2); return gst_props_entry_check_list_compatibility (entry1, entry2);
default: default:
return FALSE; return FALSE;
} }
break; break;
case GST_PROPS_INT_ID_NUM: case GST_PROPS_INT_ID:
switch (entry2->propstype) { switch (entry2->propstype) {
// b <---> a - d // 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 && return (entry2->data.int_range_data.min <= entry1->data.int_data &&
entry2->data.int_range_data.max >= entry1->data.int_data); entry2->data.int_range_data.max >= entry1->data.int_data);
// b <---> a // b <---> a
case GST_PROPS_INT_ID_NUM: case GST_PROPS_INT_ID:
return (entry2->data.int_data == entry1->data.int_data); return (entry2->data.int_data == entry1->data.int_data);
// b <---> a,b,c // b <---> a,b,c
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
return gst_props_entry_check_list_compatibility (entry1, entry2); return gst_props_entry_check_list_compatibility (entry1, entry2);
default: default:
return FALSE; return FALSE;
} }
break; break;
case GST_PROPS_FLOAT_ID_NUM: case GST_PROPS_FLOAT_ID:
switch (entry2->propstype) { switch (entry2->propstype) {
// b <---> a - d // 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 && return (entry2->data.float_range_data.min <= entry1->data.float_data &&
entry2->data.float_range_data.max >= entry1->data.float_data); entry2->data.float_range_data.max >= entry1->data.float_data);
// b <---> a // b <---> a
case GST_PROPS_FLOAT_ID_NUM: case GST_PROPS_FLOAT_ID:
return (entry2->data.float_data == entry1->data.float_data); return (entry2->data.float_data == entry1->data.float_data);
// b <---> a,b,c // b <---> a,b,c
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
return gst_props_entry_check_list_compatibility (entry1, entry2); return gst_props_entry_check_list_compatibility (entry1, entry2);
default: default:
return FALSE; return FALSE;
} }
break; break;
case GST_PROPS_BOOL_ID_NUM: case GST_PROPS_BOOL_ID:
switch (entry2->propstype) { switch (entry2->propstype) {
// t <---> t // t <---> t
case GST_PROPS_BOOL_ID_NUM: case GST_PROPS_BOOL_ID:
return (entry2->data.bool_data == entry1->data.bool_data); 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); return gst_props_entry_check_list_compatibility (entry1, entry2);
default: default:
return FALSE; return FALSE;
} }
case GST_PROPS_STRING_ID_NUM: case GST_PROPS_STRING_ID:
switch (entry2->propstype) { switch (entry2->propstype) {
// t <---> t // 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)); 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); return gst_props_entry_check_list_compatibility (entry1, entry2);
default: default:
return FALSE; return FALSE;
@ -924,14 +775,14 @@ gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent)
gchar *str; gchar *str;
switch (entry->propstype) { switch (entry->propstype) {
case GST_PROPS_INT_ID_NUM: case GST_PROPS_INT_ID:
subtree = xmlNewChild (parent, NULL, "int", NULL); subtree = xmlNewChild (parent, NULL, "int", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
str = g_strdup_printf ("%d", entry->data.int_data); str = g_strdup_printf ("%d", entry->data.int_data);
xmlNewProp (subtree, "value", str); xmlNewProp (subtree, "value", str);
g_free(str); g_free(str);
break; break;
case GST_PROPS_INT_RANGE_ID_NUM: case GST_PROPS_INT_RANGE_ID:
subtree = xmlNewChild (parent, NULL, "range", NULL); subtree = xmlNewChild (parent, NULL, "range", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
str = g_strdup_printf ("%d", entry->data.int_range_data.min); 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); xmlNewProp (subtree, "max", str);
g_free(str); g_free(str);
break; break;
case GST_PROPS_FLOAT_ID_NUM: case GST_PROPS_FLOAT_ID:
subtree = xmlNewChild (parent, NULL, "float", NULL); subtree = xmlNewChild (parent, NULL, "float", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
str = g_strdup_printf ("%f", entry->data.float_data); str = g_strdup_printf ("%f", entry->data.float_data);
xmlNewProp (subtree, "value", str); xmlNewProp (subtree, "value", str);
g_free(str); g_free(str);
break; break;
case GST_PROPS_FLOAT_RANGE_ID_NUM: case GST_PROPS_FLOAT_RANGE_ID:
subtree = xmlNewChild (parent, NULL, "floatrange", NULL); subtree = xmlNewChild (parent, NULL, "floatrange", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
str = g_strdup_printf ("%f", entry->data.float_range_data.min); 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); xmlNewProp (subtree, "max", str);
g_free(str); g_free(str);
break; break;
case GST_PROPS_FOURCC_ID_NUM: case GST_PROPS_FOURCC_ID:
str = g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data); str = g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data);
xmlAddChild (parent, xmlNewComment (str)); xmlAddChild (parent, xmlNewComment (str));
g_free(str); g_free(str);
@ -968,12 +819,12 @@ gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent)
xmlNewProp (subtree, "hexvalue", str); xmlNewProp (subtree, "hexvalue", str);
g_free(str); g_free(str);
break; break;
case GST_PROPS_BOOL_ID_NUM: case GST_PROPS_BOOL_ID:
subtree = xmlNewChild (parent, NULL, "boolean", NULL); subtree = xmlNewChild (parent, NULL, "boolean", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
xmlNewProp (subtree, "value", (entry->data.bool_data ? "true" : "false")); xmlNewProp (subtree, "value", (entry->data.bool_data ? "true" : "false"));
break; break;
case GST_PROPS_STRING_ID_NUM: case GST_PROPS_STRING_ID:
subtree = xmlNewChild (parent, NULL, "string", NULL); subtree = xmlNewChild (parent, NULL, "string", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
xmlNewProp (subtree, "value", entry->data.string_data.string); 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; GstPropsEntry *entry = (GstPropsEntry *) proplist->data;
switch (entry->propstype) { switch (entry->propstype) {
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
subtree = xmlNewChild (parent, NULL, "list", NULL); subtree = xmlNewChild (parent, NULL, "list", NULL);
xmlNewProp (subtree, "name", g_quark_to_string (entry->propid)); xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
g_list_foreach (entry->data.list_data.entries, (GFunc) gst_props_save_thyself_func, subtree); 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); g_mutex_unlock (_gst_props_entries_chunk_lock);
if (!strcmp(field->name, "int")) { if (!strcmp(field->name, "int")) {
entry->propstype = GST_PROPS_INT_ID_NUM; entry->propstype = GST_PROPS_INT_ID;
prop = xmlGetProp(field, "name"); prop = xmlGetProp(field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
g_free (prop); g_free (prop);
@ -1042,7 +893,7 @@ gst_props_load_thyself_func (xmlNodePtr field)
g_free (prop); g_free (prop);
} }
else if (!strcmp(field->name, "range")) { 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"); prop = xmlGetProp(field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
g_free (prop); g_free (prop);
@ -1054,7 +905,7 @@ gst_props_load_thyself_func (xmlNodePtr field)
g_free (prop); g_free (prop);
} }
else if (!strcmp(field->name, "float")) { else if (!strcmp(field->name, "float")) {
entry->propstype = GST_PROPS_FLOAT_ID_NUM; entry->propstype = GST_PROPS_FLOAT_ID;
prop = xmlGetProp(field, "name"); prop = xmlGetProp(field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
g_free (prop); g_free (prop);
@ -1063,7 +914,7 @@ gst_props_load_thyself_func (xmlNodePtr field)
g_free (prop); g_free (prop);
} }
else if (!strcmp(field->name, "floatrange")) { 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"); prop = xmlGetProp(field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
g_free (prop); g_free (prop);
@ -1075,7 +926,7 @@ gst_props_load_thyself_func (xmlNodePtr field)
g_free (prop); g_free (prop);
} }
else if (!strcmp(field->name, "boolean")) { else if (!strcmp(field->name, "boolean")) {
entry->propstype = GST_PROPS_BOOL_ID_NUM; entry->propstype = GST_PROPS_BOOL_ID;
prop = xmlGetProp(field, "name"); prop = xmlGetProp(field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
g_free (prop); g_free (prop);
@ -1085,7 +936,7 @@ gst_props_load_thyself_func (xmlNodePtr field)
g_free (prop); g_free (prop);
} }
else if (!strcmp(field->name, "fourcc")) { else if (!strcmp(field->name, "fourcc")) {
entry->propstype = GST_PROPS_FOURCC_ID_NUM; entry->propstype = GST_PROPS_FOURCC_ID;
prop = xmlGetProp(field, "name"); prop = xmlGetProp(field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
g_free (prop); g_free (prop);
@ -1094,7 +945,7 @@ gst_props_load_thyself_func (xmlNodePtr field)
g_free (prop); g_free (prop);
} }
else if (!strcmp(field->name, "string")) { else if (!strcmp(field->name, "string")) {
entry->propstype = GST_PROPS_STRING_ID_NUM; entry->propstype = GST_PROPS_STRING_ID;
prop = xmlGetProp(field, "name"); prop = xmlGetProp(field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
g_free (prop); g_free (prop);
@ -1141,7 +992,7 @@ gst_props_load_thyself (xmlNodePtr parent)
entry = g_mem_chunk_alloc (_gst_props_entries_chunk); entry = g_mem_chunk_alloc (_gst_props_entries_chunk);
g_mutex_unlock (_gst_props_entries_chunk_lock); 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; entry->data.list_data.entries = NULL;
prop = xmlGetProp (field, "name"); prop = xmlGetProp (field, "name");
entry->propid = g_quark_from_string (prop); entry->propid = g_quark_from_string (prop);
@ -1171,8 +1022,3 @@ gst_props_load_thyself (xmlNodePtr parent)
return props; return props;
} }
gfloat* _gst_props_floatpointer (gfloat f)
{
return &f;
}

View file

@ -36,45 +36,29 @@
typedef struct _GstProps GstProps; typedef struct _GstProps GstProps;
typedef gpointer GstPropsFactoryEntry;
typedef GstPropsFactoryEntry GstPropsFactory[];
typedef GstPropsFactory *GstPropsListFactory[];
typedef enum { typedef enum {
GST_PROPS_END_ID_NUM = 0, GST_PROPS_END_ID = 0,
GST_PROPS_LIST_ID_NUM, GST_PROPS_LIST_ID,
GST_PROPS_INT_ID_NUM, GST_PROPS_INT_ID,
GST_PROPS_INT_RANGE_ID_NUM, GST_PROPS_INT_RANGE_ID,
GST_PROPS_FLOAT_ID_NUM, GST_PROPS_FLOAT_ID,
GST_PROPS_FLOAT_RANGE_ID_NUM, GST_PROPS_FLOAT_RANGE_ID,
GST_PROPS_FOURCC_ID_NUM, GST_PROPS_FOURCC_ID,
GST_PROPS_BOOL_ID_NUM, GST_PROPS_BOOL_ID,
GST_PROPS_STRING_ID_NUM, GST_PROPS_STRING_ID,
GST_PROPS_LAST_ID_NUM = GST_PROPS_END_ID_NUM + 16, GST_PROPS_LAST_ID = GST_PROPS_END_ID + 16,
} GstPropsId; } 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_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_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(a) GST_PROPS_INT_ID,(a)
#define GST_PROPS_INT_RANGE(a,b) GST_PROPS_INT_RANGE_ID,(GINT_TO_POINTER(a)),(GINT_TO_POINTER(b)) #define GST_PROPS_INT_RANGE(a,b) GST_PROPS_INT_RANGE_ID,(a),(b)
#define GST_PROPS_FLOAT_STRING(a) GST_PROPS_FLOAT_ID,(a) #define GST_PROPS_FLOAT(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_RANGE(a,b) GST_PROPS_FLOAT_RANGE_ID,(a),(b)
#define GST_PROPS_FLOAT(a) GST_PROPS_FLOAT_ID,(&(a)) #define GST_PROPS_FOURCC(a) GST_PROPS_FOURCC_ID,(a)
#define GST_PROPS_FLOAT_RANGE(a,b) GST_PROPS_FLOAT_RANGE_ID,(&(a)),(&(b)) #define GST_PROPS_BOOLEAN(a) GST_PROPS_BOOL_ID,(a)
#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_STRING(a) GST_PROPS_STRING_ID,(a) #define GST_PROPS_STRING(a) GST_PROPS_STRING_ID,(a)
@ -88,10 +72,8 @@ struct _GstProps {
/* initialize the subsystem */ /* initialize the subsystem */
void _gst_props_initialize (void); void _gst_props_initialize (void);
GstProps* gst_props_register (GstPropsFactory factory); GstProps* gst_props_new (const gchar *firstname, ...);
GstProps* gst_props_register_count (GstPropsFactory factory, guint *counter); GstProps* gst_props_newv (const gchar *firstname, va_list var_args);
GstProps* gst_props_new (GstPropsFactoryEntry entry, ...);
void gst_props_unref (GstProps *props); void gst_props_unref (GstProps *props);
void gst_props_ref (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); 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); gint gst_props_get_int (GstProps *props, const gchar *name);
gulong gst_props_get_fourcc_int (GstProps *props, const gchar *name); gulong gst_props_get_fourcc_int (GstProps *props, const gchar *name);

View file

@ -1,3 +1,3 @@
metaincludedir = $(includedir)/gst/meta metaincludedir = $(includedir)/gst/meta
metainclude_HEADERS = \ metainclude_HEADERS = \
videoraw.h.old spectrum.h

View file

@ -25,11 +25,14 @@ libgstmediaplay_la_SOURCES = \
gstmediaplay_SOURCES = \ gstmediaplay_SOURCES = \
main.c main.c
libgstmediaplayincludedir = $(includedir)/gstplay
libgstmediaplayinclude_HEADERS = \
gstplay.h
noinst_HEADERS = \ noinst_HEADERS = \
gstmediaplay.h \ gstmediaplay.h \
gststatusarea.h \ gststatusarea.h \
callbacks.h \ callbacks.h \
gstplay.h \
gstplayprivate.h gstplayprivate.h

View file

@ -423,6 +423,8 @@ gst_play_realize (GtkWidget *widget)
g_return_if_fail (GST_IS_PLAY (widget)); g_return_if_fail (GST_IS_PLAY (widget));
//g_print ("realize\n");
play = GST_PLAY (widget); play = GST_PLAY (widget);
priv = (GstPlayPrivate *)play->priv; priv = (GstPlayPrivate *)play->priv;

View file

@ -45,13 +45,17 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
static GstPadFactory tee_src_factory = { static GstPadTemplate*
"src%d", tee_src_factory_create (void)
GST_PAD_FACTORY_SRC, {
GST_PAD_FACTORY_REQUEST, return
NULL, /* no caps */ gst_padtemplate_new (
NULL, "src%d",
}; GST_PAD_SRC,
GST_PAD_REQUEST,
NULL /* no caps */
);
}
static void gst_tee_class_init (GstTeeClass *klass); static void gst_tee_class_init (GstTeeClass *klass);
@ -197,7 +201,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf)
gboolean gboolean
gst_tee_factory_init (GstElementFactory *factory) 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); gst_elementfactory_add_padtemplate (factory, gst_tee_src_template);
return TRUE; return TRUE;

View file

@ -22,7 +22,7 @@ main (int argc, char *argv[])
g_assert (videosink != NULL); g_assert (videosink != NULL);
testcaps = g_list_append (NULL, testcaps = g_list_append (NULL,
gst_caps_new_with_props ("test_caps", gst_caps_new ("test_caps",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),

View file

@ -3,10 +3,10 @@
static GstElement* static GstElement*
autoplug_caps (GstAutoplug *autoplug, gchar *mime1, gchar *mime2) autoplug_caps (GstAutoplug *autoplug, gchar *mime1, gchar *mime2)
{ {
GList *caps1, *caps2; GstCaps *caps1, *caps2;
caps1 = g_list_append (NULL, gst_caps_new ("tescaps1", mime1)); caps1 = gst_caps_new ("tescaps1", mime1, NULL);
caps2 = g_list_append (NULL, gst_caps_new ("tescaps2", mime2)); caps2 = gst_caps_new ("tescaps2", mime2, NULL);
return gst_autoplug_to_caps (autoplug, caps1, caps2, 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)); xmlSaveFile ("autoplug2_2.gst", gst_xml_write (element));
element = gst_autoplug_to_caps (autoplug, element = gst_autoplug_to_caps (autoplug,
g_list_append (NULL, gst_caps_new_with_props( gst_caps_new(
"testcaps3", "testcaps3",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (TRUE), "systemstream", GST_PROPS_BOOLEAN (TRUE),
NULL))), NULL)),
g_list_append (NULL, gst_caps_new("testcaps4","audio/raw")), gst_caps_new("testcaps4","audio/raw", NULL),
NULL); NULL);
xmlSaveFile ("autoplug2_3.gst", gst_xml_write (element)); xmlSaveFile ("autoplug2_3.gst", gst_xml_write (element));
element = gst_autoplug_to_caps (autoplug, element = gst_autoplug_to_caps (autoplug,
g_list_append (NULL, gst_caps_new_with_props( gst_caps_new(
"testcaps5", "testcaps5",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE), "systemstream", GST_PROPS_BOOLEAN (FALSE),
NULL))), NULL)),
g_list_append (NULL, gst_caps_new("testcaps6", "video/raw")), gst_caps_new("testcaps6", "video/raw", NULL),
NULL); NULL);
xmlSaveFile ("autoplug2_4.gst", gst_xml_write (element)); xmlSaveFile ("autoplug2_4.gst", gst_xml_write (element));
element = gst_autoplug_to_caps (autoplug, element = gst_autoplug_to_caps (autoplug,
g_list_append (NULL, gst_caps_new( gst_caps_new(
"testcaps7", "testcaps7",
"video/avi")), "video/avi", NULL),
g_list_append (NULL, gst_caps_new("testcaps8", "video/raw")), gst_caps_new("testcaps8", "video/raw", NULL),
g_list_append (NULL, gst_caps_new("testcaps9", "audio/raw")), gst_caps_new("testcaps9", "audio/raw", NULL),
NULL); NULL);
xmlSaveFile ("autoplug2_5.gst", gst_xml_write (element)); xmlSaveFile ("autoplug2_5.gst", gst_xml_write (element));
element = gst_autoplug_to_caps (autoplug, element = gst_autoplug_to_caps (autoplug,
g_list_append (NULL, gst_caps_new_with_props( gst_caps_new(
"testcaps10", "testcaps10",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (TRUE), "systemstream", GST_PROPS_BOOLEAN (TRUE),
NULL))), NULL)),
g_list_append (NULL, gst_caps_new("testcaps10", "video/raw")), gst_caps_new("testcaps10", "video/raw", NULL),
g_list_append (NULL, gst_caps_new("testcaps11", "audio/raw")), gst_caps_new("testcaps11", "audio/raw", NULL),
NULL); NULL);
xmlSaveFile ("autoplug2_6.gst", gst_xml_write (element)); xmlSaveFile ("autoplug2_6.gst", gst_xml_write (element));

View file

@ -17,64 +17,64 @@ main (int argc, char *argv[])
autoplug2 = gst_autoplugfactory_make ("static"); autoplug2 = gst_autoplugfactory_make ("static");
element = gst_autoplug_to_renderers (autoplug, 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)); xmlSaveFile ("autoplug3_1.gst", gst_xml_write (element));
element = gst_autoplug_to_renderers (autoplug, 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) { if (element) {
xmlSaveFile ("autoplug3_2.gst", gst_xml_write (element)); xmlSaveFile ("autoplug3_2.gst", gst_xml_write (element));
} }
element = gst_autoplug_to_caps (autoplug2, element = gst_autoplug_to_caps (autoplug2,
g_list_append (NULL, gst_caps_new_with_props( gst_caps_new(
"testcaps3", "testcaps3",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (TRUE), "systemstream", GST_PROPS_BOOLEAN (TRUE),
NULL))), NULL)),
g_list_append (NULL, gst_caps_new("testcaps4","audio/raw")), gst_caps_new("testcaps4","audio/raw", NULL),
NULL); NULL);
if (element) { if (element) {
xmlSaveFile ("autoplug3_3.gst", gst_xml_write (element)); xmlSaveFile ("autoplug3_3.gst", gst_xml_write (element));
} }
element = gst_autoplug_to_caps (autoplug2, element = gst_autoplug_to_caps (autoplug2,
g_list_append (NULL, gst_caps_new_with_props( gst_caps_new(
"testcaps5", "testcaps5",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE), "systemstream", GST_PROPS_BOOLEAN (FALSE),
NULL))), NULL)),
g_list_append (NULL, gst_caps_new("testcaps6", "video/raw")), gst_caps_new("testcaps6", "video/raw", NULL),
NULL); NULL);
if (element) { if (element) {
xmlSaveFile ("autoplug3_4.gst", gst_xml_write (element)); xmlSaveFile ("autoplug3_4.gst", gst_xml_write (element));
} }
element = gst_autoplug_to_caps (autoplug2, element = gst_autoplug_to_caps (autoplug2,
g_list_append (NULL, gst_caps_new( gst_caps_new(
"testcaps7", "testcaps7",
"video/avi")), "video/avi", NULL),
g_list_append (NULL, gst_caps_new("testcaps8", "video/raw")), gst_caps_new("testcaps8", "video/raw", NULL),
g_list_append (NULL, gst_caps_new("testcaps9", "audio/raw")), gst_caps_new("testcaps9", "audio/raw", NULL),
NULL); NULL);
if (element) { if (element) {
xmlSaveFile ("autoplug3_5.gst", gst_xml_write (element)); xmlSaveFile ("autoplug3_5.gst", gst_xml_write (element));
} }
element = gst_autoplug_to_caps (autoplug2, element = gst_autoplug_to_caps (autoplug2,
g_list_append (NULL, gst_caps_new_with_props( gst_caps_new(
"testcaps10", "testcaps10",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (TRUE), "systemstream", GST_PROPS_BOOLEAN (TRUE),
NULL))), NULL)),
g_list_append (NULL, gst_caps_new("testcaps10", "video/raw")), gst_caps_new("testcaps10", "video/raw", NULL),
g_list_append (NULL, gst_caps_new("testcaps11", "audio/raw")), gst_caps_new("testcaps11", "audio/raw", NULL),
NULL); NULL);
if (element) { if (element) {
xmlSaveFile ("autoplug3_6.gst", gst_xml_write (element)); xmlSaveFile ("autoplug3_6.gst", gst_xml_write (element));
@ -84,13 +84,13 @@ main (int argc, char *argv[])
sink2 = gst_elementfactory_make ("osssink", "osssink"); sink2 = gst_elementfactory_make ("osssink", "osssink");
element = gst_autoplug_to_renderers (autoplug, element = gst_autoplug_to_renderers (autoplug,
g_list_append (NULL, gst_caps_new_with_props( gst_caps_new(
"testcaps10", "testcaps10",
"video/mpeg", "video/mpeg",
gst_props_new ( gst_props_new (
"mpegversion", GST_PROPS_INT (1), "mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (TRUE), "systemstream", GST_PROPS_BOOLEAN (TRUE),
NULL))), NULL)),
sink1, sink1,
sink2, sink2,
NULL); NULL);

View file

@ -1,65 +1,119 @@
#include <gst/gst.h> #include <gst/gst.h>
static GstCapsFactory mpeg2dec_sink_caps = { static GstCaps*
"mpeg2dec_sink", mpeg2dec_sink_caps (void)
"video/mpeg", {
"mpegtype", GST_PROPS_LIST ( return
GST_PROPS_INT(1), gst_caps_new (
GST_PROPS_INT(2) "mpeg2dec_sink",
), "video/mpeg",
NULL gst_props_new (
}; "mpegtype", GST_PROPS_LIST (
GST_PROPS_INT(1),
GST_PROPS_INT(2)
),
NULL
)
);
}
static GstCapsFactory mp1parse_src_caps = { static GstCaps*
"mp1parse_src", mp1parse_src_caps (void)
"video/mpeg", {
"mpegtype", GST_PROPS_LIST ( return
GST_PROPS_INT(1) gst_caps_new (
), "mp1parse_src",
NULL "video/mpeg",
}; gst_props_new (
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT(1)
),
NULL
)
);
}
static GstCapsFactory mpeg2dec_src_caps = { static GstCaps*
"mpeg2dec_src", mpeg2dec_src_caps (void)
"video/raw", {
"fourcc", GST_PROPS_LIST ( return
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), gst_caps_new (
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')) "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), "width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096),
NULL NULL
}; )
);
}
static GstCapsFactory raw_sink_caps = { static GstCaps*
"raw_sink_caps", raw_sink_caps (void)
"video/raw", {
"fourcc", GST_PROPS_LIST ( return
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')) gst_caps_new (
), "raw_sink_caps",
"height", GST_PROPS_INT_RANGE (16, 256), "video/raw",
NULL 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 = { static GstCaps*
"raw2_sink_caps", raw2_sink_caps (void)
"video/raw", {
"fourcc", GST_PROPS_LIST ( 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','V','1','2')),
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')) GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2'))
), ),
"height", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096),
NULL 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, static GstCaps *sinkcaps = NULL,
*rawcaps = NULL, *rawcaps = NULL,
*rawcaps2 = NULL, *rawcaps2 = NULL,
*rawcaps3 = NULL, *rawcaps3 = NULL,
*mp1parsecaps = NULL; *mp1parsecaps = NULL;
int main(int argc,char *argv[]) int
main (int argc, char *argv[])
{ {
gboolean testret; gboolean testret;
xmlDocPtr doc; xmlDocPtr doc;
@ -68,25 +122,28 @@ int main(int argc,char *argv[])
doc = xmlNewDoc ("1.0"); doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL); doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
g_thread_init (NULL);
_gst_type_initialize (); _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); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (sinkcaps, parent); gst_caps_save_thyself (sinkcaps, parent);
rawcaps = gst_caps_register (&mpeg2dec_src_caps); rawcaps = mpeg2dec_src_caps ();
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL);
gst_caps_save_thyself (rawcaps, parent); gst_caps_save_thyself (rawcaps, parent);
rawcaps2 = gst_caps_register (&raw_sink_caps); rawcaps2 = raw_sink_caps ();
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities3", NULL); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities3", NULL);
gst_caps_save_thyself (rawcaps2, parent); gst_caps_save_thyself (rawcaps2, parent);
mp1parsecaps = gst_caps_register (&mp1parse_src_caps); mp1parsecaps = mp1parse_src_caps ();
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities4", NULL); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities4", NULL);
gst_caps_save_thyself (mp1parsecaps, parent); gst_caps_save_thyself (mp1parsecaps, parent);
rawcaps3 = gst_caps_register (&raw2_sink_caps); rawcaps3 = raw2_sink_caps ();
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL);
gst_caps_save_thyself (rawcaps3, parent); gst_caps_save_thyself (rawcaps3, parent);

View file

@ -57,34 +57,41 @@ enum {
* can have. They can be quite complex, but for this example plugin * can have. They can be quite complex, but for this example plugin
* they are rather simple. * they are rather simple.
*/ */
static GstPadFactory sink_factory = { static GstPadTemplate*
"sink", /* The name of the pad */ sink_factory (void)
GST_PAD_FACTORY_SINK, /* Direction of the pad */ {
GST_PAD_FACTORY_ALWAYS, /* The pad exists for every instance */ return
GST_PAD_FACTORY_CAPS( /* This factory has specific capabilities */ gst_padtemplate_new (
"example_sink", /* The name of the caps */ "sink", /* The name of the pad */
"unknown/unknown", /* The overall MIME/type */ GST_PAD_SINK, /* Direction of the pad */
"foo", GST_PROPS_INT (1), /* An integer property */ GST_PAD_ALWAYS, /* The pad exists for every instance */
"bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */ gst_caps_new (
"baz", GST_PROPS_LIST ( /* A list of values for */ "example_sink", /* The name of the caps */
GST_PROPS_INT (1), "unknown/unknown", /* The overall MIME/type */
GST_PROPS_INT (3) gst_props_new (
) "foo", GST_PROPS_INT (1), /* An integer property */
), "bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */
NULL /* All factories must be NULL-terminated */ "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. */ /* This factory is much simpler, and defines the source pad. */
static GstPadFactory src_factory = { static GstPadTemplate*
"src", src_factory (void)
GST_PAD_FACTORY_SRC, {
GST_PAD_FACTORY_ALWAYS, return
GST_PAD_FACTORY_CAPS( gst_padtemplate_new (
"example_src", "src",
"unknown/unknown" GST_PAD_SRC,
), GST_PAD_ALWAYS,
NULL gst_caps_new (
}; "example_src",
"unknown/unknown",
NULL));
}
/* A number of functon prototypes are given so we can refer to them later. */ /* 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 * Note that the generated padtemplates are stored in static global
* variables, for the gst_example_init function to use later on. * 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); 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); gst_elementfactory_add_padtemplate (factory, src_template);
/* The very last thing is to register the elementfactory with the plugin. */ /* The very last thing is to register the elementfactory with the plugin. */

View file

@ -1,22 +1,24 @@
#include <gst/gst.h> #include <gst/gst.h>
static GstPropsFactory mpeg2dec_sink_props = { static GstProps* mpeg2dec_sink_props_register (void) {
"mpegtype", GST_PROPS_LIST ( return gst_props_new (
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT(1), GST_PROPS_INT(1),
GST_PROPS_INT(2) GST_PROPS_INT(2)
), ),
NULL NULL);
}; }
static GstPropsFactory mpeg2dec_src_props = { static GstProps* mpeg2dec_src_props_register (void) {
"fourcc", GST_PROPS_LIST ( 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','V','1','2')),
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')) GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2'))
), ),
"width", GST_PROPS_INT_RANGE (16, 4096), "width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096),
NULL NULL);
}; }
static GstProps *sinkprops = NULL, static GstProps *sinkprops = NULL,
*rawprops = NULL, *rawprops = NULL,
@ -31,13 +33,14 @@ int main(int argc,char *argv[])
doc = xmlNewDoc ("1.0"); doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Properties", NULL); 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); parent = xmlNewChild (doc->xmlRootNode, NULL, "Props1", NULL);
gst_props_save_thyself (sinkprops, parent); 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); parent = xmlNewChild (doc->xmlRootNode, NULL, "Props2", NULL);
gst_props_save_thyself (rawprops, parent); gst_props_save_thyself (rawprops, parent);

View file

@ -15,25 +15,25 @@ void print_prop(GstPropsEntry *prop,gboolean showname,gchar *pfx) {
printf(pfx); printf(pfx);
switch (prop->propstype) { switch (prop->propstype) {
case GST_PROPS_INT_ID_NUM: case GST_PROPS_INT_ID:
printf("Integer: %d\n",prop->data.int_data); printf("Integer: %d\n",prop->data.int_data);
break; 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, printf("Integer range: %d - %d\n",prop->data.int_range_data.min,
prop->data.int_range_data.max); prop->data.int_range_data.max);
break; break;
case GST_PROPS_BOOL_ID_NUM: case GST_PROPS_BOOL_ID:
printf("Boolean: %s\n",prop->data.bool_data ? "TRUE" : "FALSE"); printf("Boolean: %s\n",prop->data.bool_data ? "TRUE" : "FALSE");
break; break;
case GST_PROPS_STRING_ID_NUM: case GST_PROPS_STRING_ID:
printf("String: %s\n",prop->data.string_data.string); printf("String: %s\n",prop->data.string_data.string);
break; break;
case GST_PROPS_FOURCC_ID_NUM: case GST_PROPS_FOURCC_ID:
printf("FourCC: %c%c%c%c\n", printf("FourCC: %c%c%c%c\n",
prop->data.fourcc_data & 0xff,prop->data.fourcc_data>>8 & 0xff, prop->data.fourcc_data & 0xff,prop->data.fourcc_data>>8 & 0xff,
prop->data.fourcc_data>>16 & 0xff,prop->data.fourcc_data>>24 & 0xff); prop->data.fourcc_data>>16 & 0xff,prop->data.fourcc_data>>24 & 0xff);
break; break;
case GST_PROPS_LIST_ID_NUM: case GST_PROPS_LIST_ID:
printf("List:\n"); printf("List:\n");
longprefix = g_strdup_printf("%s ",pfx); longprefix = g_strdup_printf("%s ",pfx);
list = prop->data.list_data.entries; list = prop->data.list_data.entries;