gstreamer/tests/props.c
Wim Taymans b38d9a945b 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.
2001-04-14 18:56:37 +00:00

78 lines
2.4 KiB
C

#include <gst/gst.h>
static GstProps* mpeg2dec_sink_props_register (void) {
return gst_props_new (
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT(1),
GST_PROPS_INT(2)
),
NULL);
}
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);
}
static GstProps *sinkprops = NULL,
*rawprops = NULL,
*testprops = NULL;
int main(int argc,char *argv[])
{
xmlDocPtr doc;
xmlNodePtr parent;
gint i;
doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Properties", NULL);
g_thread_init (NULL);
_gst_props_initialize ();
sinkprops = mpeg2dec_sink_props_register ();
parent = xmlNewChild (doc->xmlRootNode, NULL, "Props1", NULL);
gst_props_save_thyself (sinkprops, parent);
rawprops = mpeg2dec_src_props_register ();
parent = xmlNewChild (doc->xmlRootNode, NULL, "Props2", NULL);
gst_props_save_thyself (rawprops, parent);
i=argc;
testprops = gst_props_new ("layer", GST_PROPS_INT (i),
"bitrate", GST_PROPS_INT_RANGE (i*300, i*10000),
NULL);
if (i==3) {
testprops = gst_props_merge (testprops,
gst_props_new ("framed", GST_PROPS_BOOLEAN (TRUE),
"mpegtest", GST_PROPS_BOOLEAN (FALSE),
"hello", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_MAKE_FOURCC (0,0,0x55,0x55)),
GST_PROPS_FOURCC (GST_MAKE_FOURCC (0,0,0x66,0x66))
),
NULL));
}
parent = xmlNewChild (doc->xmlRootNode, NULL, "Props3", NULL);
gst_props_save_thyself (testprops, parent);
sinkprops = gst_props_set (sinkprops, "mpegtype", GST_PROPS_INT (1));
sinkprops = gst_props_set (sinkprops, "foobar", GST_PROPS_FOURCC (GST_MAKE_FOURCC (0x56, 0x56,0x56,0x56)));
g_print ("%08lx\n", gst_props_get_fourcc_int (sinkprops, "foobar"));
g_print ("%d\n", gst_props_get_int (sinkprops, "mpegtype"));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Props4", NULL);
gst_props_save_thyself (sinkprops, parent);
xmlDocDump(stdout, doc);
return 0;
}