mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
value: add (de)serialisation function for uchar
.. since we sadly have a plugin in -good that has a uchar property (cmmlenc) https://bugzilla.gnome.org/show_bug.cgi?id=642522
This commit is contained in:
parent
cc5edeefcd
commit
3a744ca442
2 changed files with 54 additions and 0 deletions
|
@ -2017,6 +2017,12 @@ CREATE_USERIALIZATION (uint, UINT);
|
||||||
CREATE_USERIALIZATION (uint64, UINT64);
|
CREATE_USERIALIZATION (uint64, UINT64);
|
||||||
CREATE_USERIALIZATION (ulong, ULONG);
|
CREATE_USERIALIZATION (ulong, ULONG);
|
||||||
|
|
||||||
|
/* FIXME 0.11: remove this again, plugins shouldn't have uchar properties */
|
||||||
|
#ifndef G_MAXUCHAR
|
||||||
|
#define G_MAXUCHAR 255
|
||||||
|
#endif
|
||||||
|
CREATE_USERIALIZATION (uchar, UCHAR);
|
||||||
|
|
||||||
/**********
|
/**********
|
||||||
* double *
|
* double *
|
||||||
**********/
|
**********/
|
||||||
|
@ -4931,6 +4937,8 @@ _gst_value_initialize (void)
|
||||||
REGISTER_SERIALIZATION (G_TYPE_UINT64, uint64);
|
REGISTER_SERIALIZATION (G_TYPE_UINT64, uint64);
|
||||||
REGISTER_SERIALIZATION (G_TYPE_ULONG, ulong);
|
REGISTER_SERIALIZATION (G_TYPE_ULONG, ulong);
|
||||||
|
|
||||||
|
REGISTER_SERIALIZATION (G_TYPE_UCHAR, uchar);
|
||||||
|
|
||||||
g_value_register_transform_func (GST_TYPE_FOURCC, G_TYPE_STRING,
|
g_value_register_transform_func (GST_TYPE_FOURCC, G_TYPE_STRING,
|
||||||
gst_value_transform_fourcc_string);
|
gst_value_transform_fourcc_string);
|
||||||
g_value_register_transform_func (GST_TYPE_INT_RANGE, G_TYPE_STRING,
|
g_value_register_transform_func (GST_TYPE_INT_RANGE, G_TYPE_STRING,
|
||||||
|
|
|
@ -245,6 +245,51 @@ GST_START_TEST (test_deserialize_guint64)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_deserialize_guchar)
|
||||||
|
{
|
||||||
|
GValue value = { 0 };
|
||||||
|
const char *strings[] = {
|
||||||
|
"0xff",
|
||||||
|
"255",
|
||||||
|
"-1",
|
||||||
|
"1",
|
||||||
|
"-0",
|
||||||
|
};
|
||||||
|
guchar results[] = {
|
||||||
|
0xff,
|
||||||
|
255,
|
||||||
|
(guchar) - 1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
|
||||||
|
g_value_init (&value, G_TYPE_UCHAR);
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (strings); ++i) {
|
||||||
|
fail_unless (gst_value_deserialize (&value, strings[i]),
|
||||||
|
"could not deserialize %s (%d)", strings[i], i);
|
||||||
|
fail_unless (g_value_get_uchar (&value) == results[i],
|
||||||
|
"resulting value is %u not %u, for string %s (%d)",
|
||||||
|
g_value_get_uchar (&value), results[i], strings[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test serialisation as well while we're at it */
|
||||||
|
{
|
||||||
|
gchar *str;
|
||||||
|
GValue value = { 0 };
|
||||||
|
g_value_init (&value, G_TYPE_UCHAR);
|
||||||
|
|
||||||
|
g_value_set_uchar (&value, 255);
|
||||||
|
str = gst_value_serialize (&value);
|
||||||
|
|
||||||
|
fail_unless_equals_string (str, "255");
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_deserialize_gstfraction)
|
GST_START_TEST (test_deserialize_gstfraction)
|
||||||
{
|
{
|
||||||
GValue value = { 0 };
|
GValue value = { 0 };
|
||||||
|
@ -2565,6 +2610,7 @@ gst_value_suite (void)
|
||||||
tcase_add_test (tc_chain, test_deserialize_guint_failures);
|
tcase_add_test (tc_chain, test_deserialize_guint_failures);
|
||||||
tcase_add_test (tc_chain, test_deserialize_gint64);
|
tcase_add_test (tc_chain, test_deserialize_gint64);
|
||||||
tcase_add_test (tc_chain, test_deserialize_guint64);
|
tcase_add_test (tc_chain, test_deserialize_guint64);
|
||||||
|
tcase_add_test (tc_chain, test_deserialize_guchar);
|
||||||
tcase_add_test (tc_chain, test_deserialize_gstfraction);
|
tcase_add_test (tc_chain, test_deserialize_gstfraction);
|
||||||
tcase_add_test (tc_chain, test_serialize_flags);
|
tcase_add_test (tc_chain, test_serialize_flags);
|
||||||
tcase_add_test (tc_chain, test_deserialize_flags);
|
tcase_add_test (tc_chain, test_deserialize_flags);
|
||||||
|
|
Loading…
Reference in a new issue