+2003-12-31 David Schleef <ds@schleef.org>
+
+ * gst/gstcaps.c: (gst_caps_intersect),
+ (_gst_caps_normalize_foreach), (gst_caps_normalize):
+ Implement gst_caps_normalize().
+ * testsuite/caps/normalisation.c: (main):
+ Add an additional test
+
2003-12-31 Ronald Bultje <rbultje@ronald.bitfreak.net>
* gst/gstqueue.c: (gst_queue_init):
GstStructure *struct1;
GstStructure *struct2;
GstCaps *dest;
+ //GstCaps *caps;
g_return_val_if_fail (caps1 != NULL, NULL);
g_return_val_if_fail (caps2 != NULL, NULL);
}
}
- /* FIXME: need a simplify function */
+#if 0
+ caps = gst_caps_simplify (dest);
+ gst_caps_free (dest);
+ return caps;
+#else
return dest;
+#endif
}
GstCaps *gst_caps_union (const GstCaps *caps1, const GstCaps *caps2)
return dest1;
}
+typedef struct _NormalizeForeach {
+ GstCaps *caps;
+ GstStructure *structure;
+} NormalizeForeach;
+
+static gboolean
+_gst_caps_normalize_foreach (GQuark field_id, GValue *value, gpointer ptr)
+{
+ NormalizeForeach *nf = (NormalizeForeach *) ptr;
+ GValue val = { 0 };
+ int i;
+
+ if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
+ for (i=1; i<gst_value_list_get_size (value); i++) {
+ const GValue *v = gst_value_list_get_value (value, i);
+ GstStructure *structure = gst_structure_copy (nf->structure);
+
+ gst_structure_id_set_value (structure, field_id, v);
+ gst_caps_append_structure (nf->caps, structure);
+ }
+
+ gst_value_init_and_copy (&val, gst_value_list_get_value (value, 0));
+ gst_structure_id_set_value (nf->structure, field_id, &val);
+ g_value_unset (&val);
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
GstCaps *gst_caps_normalize (const GstCaps *caps)
{
- g_critical ("unimplemented");
+ NormalizeForeach nf;
+ GstCaps *newcaps;
+ int i;
- return NULL;
+ g_return_val_if_fail(caps != NULL, NULL);
+
+ newcaps = gst_caps_copy (caps);
+ nf.caps = newcaps;
+
+ for(i=0;i<newcaps->structs->len;i++){
+ nf.structure = gst_caps_get_structure (newcaps, i);
+
+ while (!gst_structure_foreach (nf.structure, _gst_caps_normalize_foreach,
+ &nf));
+ }
+
+ return newcaps;
}
static gboolean
"height=(int)[16,4096]"
);
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
+ "x, "
+ "y=(int){1,2}, "
+ "z=(int){3,4}; "
+ "a, "
+ "b=(int){5,6}, "
+ "c=(int){7,8}"
+);
+
/* defined, not used
GST_CAPS_FACTORY (rawcaps4,
GST_CAPS_NEW (
int
main (int argc, char *argv[])
{
- xmlDocPtr doc;
- xmlNodePtr parent;
GstCaps *caps;
gst_init (&argc, &argv);
- doc = xmlNewDoc ("1.0");
- doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
-
caps = gst_caps_normalize (gst_static_caps_get (&sinkcaps));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&mp1parsecaps));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps2));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps3));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
- xmlDocDump(stdout, doc);
+ caps = gst_caps_normalize (gst_static_caps_get (&rawcaps4));
+ g_assert (gst_caps_get_size (caps) == 8);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
return 0;
}
"height=(int)[16,4096]"
);
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
+ "x, "
+ "y=(int){1,2}, "
+ "z=(int){3,4}; "
+ "a, "
+ "b=(int){5,6}, "
+ "c=(int){7,8}"
+);
+
/* defined, not used
GST_CAPS_FACTORY (rawcaps4,
GST_CAPS_NEW (
int
main (int argc, char *argv[])
{
- xmlDocPtr doc;
- xmlNodePtr parent;
GstCaps *caps;
gst_init (&argc, &argv);
- doc = xmlNewDoc ("1.0");
- doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
-
caps = gst_caps_normalize (gst_static_caps_get (&sinkcaps));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&mp1parsecaps));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps2));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps3));
- parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
- gst_caps_save_thyself (caps, parent);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
- xmlDocDump(stdout, doc);
+ caps = gst_caps_normalize (gst_static_caps_get (&rawcaps4));
+ g_assert (gst_caps_get_size (caps) == 8);
+ g_print ("\n%s\n", gst_caps_to_string (caps));
return 0;
}