check/gst/gstcaps.c: Extend caps string tests to check that a caps to string conversion is reversible and produces th...

Original commit message from CVS:
* check/gst/gstcaps.c: (GST_START_TEST):
Extend caps string tests to check that a caps to string
conversion is reversible and produces the same caps.

* gst/gststructure.c: (gst_structure_value_get_generic_type):
Output "fraction" as the generic type fraction range, so caps
serialisation and deserialisation works.
* check/gst/capslist.h:
* gst/gstvalue.c: (gst_value_deserialize_fraction):
Support 'MIN' and 'MAX' for deserialising fractions.
This commit is contained in:
Jan Schmidt 2005-11-22 11:56:01 +00:00
parent 48d1473e3d
commit ba0d715dc8
7 changed files with 52 additions and 0 deletions

View file

@ -1,3 +1,16 @@
2005-11-22 Jan Schmidt <thaytan@mad.scientist.com>
* check/gst/gstcaps.c: (GST_START_TEST):
Extend caps string tests to check that a caps to string
conversion is reversible and produces the same caps.
* gst/gststructure.c: (gst_structure_value_get_generic_type):
Output "fraction" as the generic type fraction range, so caps
serialisation and deserialisation works.
* check/gst/capslist.h:
* gst/gstvalue.c: (gst_value_deserialize_fraction):
Support 'MIN' and 'MAX' for deserialising fractions.
2005-11-22 Andy Wingo <wingo@pobox.com> 2005-11-22 Andy Wingo <wingo@pobox.com>
* gst/gstevent.h (gst_event_new_new_segment) * gst/gstevent.h (gst_event_new_new_segment)

View file

@ -16,7 +16,10 @@ static const gchar *caps_list[] = {
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]", "video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]",
"video/x-raw-rgb,\\ bpp=(int)32", "video/x-raw-rgb,\\ bpp=(int)32",
"test/gst-fraction, fraction = (fraction) 1/8", "test/gst-fraction, fraction = (fraction) 1/8",
"test/gst-fraction, fraction = (fraction) MIN",
"test/gst-fraction, fraction = (fraction) MAX",
"test/gst-fraction-range, fraction = (fraction) [ 1/3, 1/4 ]", "test/gst-fraction-range, fraction = (fraction) [ 1/3, 1/4 ]",
"test/gst-fraction-range, fraction = (fraction) [ MIN, MAX ]",
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], 1/8 }", "test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], 1/8 }",
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], [ 1/8, 2/8 ] }", "test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], [ 1/8, 2/8 ] }",
"ANY", "ANY",

View file

@ -27,13 +27,25 @@
GST_START_TEST (test_from_string) GST_START_TEST (test_from_string)
{ {
GstCaps *caps; GstCaps *caps;
GstCaps *caps2;
gchar *to_str;
int i; int i;
for (i = 0; i < G_N_ELEMENTS (caps_list); i++) { for (i = 0; i < G_N_ELEMENTS (caps_list); i++) {
caps = gst_caps_from_string (caps_list[i]); caps = gst_caps_from_string (caps_list[i]);
fail_if (caps == NULL, fail_if (caps == NULL,
"Could not create caps from string %s\n", caps_list[i]); "Could not create caps from string %s\n", caps_list[i]);
to_str = gst_caps_to_string (caps);
fail_if (to_str == NULL,
"Could not convert caps back to string %s\n", caps_list[i]);
caps2 = gst_caps_from_string (caps_list[i]);
fail_if (caps2 == NULL, "Could not create caps from string %s\n", to_str);
fail_unless (gst_caps_is_equal (caps, caps2));
g_free (caps); g_free (caps);
g_free (caps2);
g_free (to_str);
} }
} }

View file

@ -1286,6 +1286,8 @@ gst_structure_value_get_generic_type (GValue * val)
return G_TYPE_INT; return G_TYPE_INT;
} else if (G_VALUE_TYPE (val) == GST_TYPE_DOUBLE_RANGE) { } else if (G_VALUE_TYPE (val) == GST_TYPE_DOUBLE_RANGE) {
return G_TYPE_DOUBLE; return G_TYPE_DOUBLE;
} else if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION_RANGE) {
return GST_TYPE_FRACTION;
} }
return G_VALUE_TYPE (val); return G_VALUE_TYPE (val);
} }

View file

@ -3344,6 +3344,13 @@ gst_value_deserialize_fraction (GValue * dest, const char *s)
gst_value_set_fraction (dest, num, 1); gst_value_set_fraction (dest, num, 1);
return TRUE; return TRUE;
} }
if (g_ascii_strcasecmp (s, "min") == 0) {
gst_value_set_fraction (dest, -G_MAXINT, 1);
return TRUE;
} else if (g_ascii_strcasecmp (s, "max") == 0) {
gst_value_set_fraction (dest, G_MAXINT, 1);
return TRUE;
}
return FALSE; return FALSE;
} }

View file

@ -16,7 +16,10 @@ static const gchar *caps_list[] = {
"video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]", "video/x-raw-rgb, bpp = (int) 32, depth = (int) 24, endianness = (int) BIG_ENDIAN, red_mask = (int) 0xFF000000, framerate = (double) [ 0, max ]",
"video/x-raw-rgb,\\ bpp=(int)32", "video/x-raw-rgb,\\ bpp=(int)32",
"test/gst-fraction, fraction = (fraction) 1/8", "test/gst-fraction, fraction = (fraction) 1/8",
"test/gst-fraction, fraction = (fraction) MIN",
"test/gst-fraction, fraction = (fraction) MAX",
"test/gst-fraction-range, fraction = (fraction) [ 1/3, 1/4 ]", "test/gst-fraction-range, fraction = (fraction) [ 1/3, 1/4 ]",
"test/gst-fraction-range, fraction = (fraction) [ MIN, MAX ]",
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], 1/8 }", "test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], 1/8 }",
"test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], [ 1/8, 2/8 ] }", "test/gst-fraction-range, fraction = (fraction) { [ 1/3, 1/4 ], [ 1/8, 2/8 ] }",
"ANY", "ANY",

View file

@ -27,13 +27,25 @@
GST_START_TEST (test_from_string) GST_START_TEST (test_from_string)
{ {
GstCaps *caps; GstCaps *caps;
GstCaps *caps2;
gchar *to_str;
int i; int i;
for (i = 0; i < G_N_ELEMENTS (caps_list); i++) { for (i = 0; i < G_N_ELEMENTS (caps_list); i++) {
caps = gst_caps_from_string (caps_list[i]); caps = gst_caps_from_string (caps_list[i]);
fail_if (caps == NULL, fail_if (caps == NULL,
"Could not create caps from string %s\n", caps_list[i]); "Could not create caps from string %s\n", caps_list[i]);
to_str = gst_caps_to_string (caps);
fail_if (to_str == NULL,
"Could not convert caps back to string %s\n", caps_list[i]);
caps2 = gst_caps_from_string (caps_list[i]);
fail_if (caps2 == NULL, "Could not create caps from string %s\n", to_str);
fail_unless (gst_caps_is_equal (caps, caps2));
g_free (caps); g_free (caps);
g_free (caps2);
g_free (to_str);
} }
} }