mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
gst/: make sure some essential types used by events are registered as part of gst_init()
Original commit message from CVS: * gst/gstevent.c: (_gst_event_initialize): * gst/gstformat.c: (_gst_format_initialize): make sure some essential types used by events are registered as part of gst_init() * gst/gstvalue.c: (gst_value_serialize_flags): if no flags are set, serialize them to a value that represents NONE so that deserializing them works * tests/check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite): add tests for serialization and deserialization of flags
This commit is contained in:
parent
7a18ca0a76
commit
b4e05d624b
5 changed files with 90 additions and 0 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2006-05-10 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gstevent.c: (_gst_event_initialize):
|
||||
* gst/gstformat.c: (_gst_format_initialize):
|
||||
make sure some essential types used by events are registered
|
||||
as part of gst_init()
|
||||
* gst/gstvalue.c: (gst_value_serialize_flags):
|
||||
if no flags are set, serialize them to a value that represents NONE
|
||||
so that deserializing them works
|
||||
* tests/check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
|
||||
add tests for serialization and deserialization of flags
|
||||
|
||||
2006-05-10 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_collect),
|
||||
|
|
|
@ -93,6 +93,8 @@ void
|
|||
_gst_event_initialize (void)
|
||||
{
|
||||
gst_event_get_type ();
|
||||
gst_seek_flags_get_type ();
|
||||
gst_seek_type_get_type ();
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "gst_private.h"
|
||||
#include <string.h>
|
||||
#include "gstformat.h"
|
||||
#include "gstenumtypes.h"
|
||||
|
||||
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
||||
static GList *_gst_formats = NULL;
|
||||
|
@ -72,6 +73,8 @@ _gst_format_initialize (void)
|
|||
standards++;
|
||||
_n_values++;
|
||||
}
|
||||
/* getting the type registers the enum */
|
||||
gst_format_get_type ();
|
||||
g_static_mutex_unlock (&mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -1921,6 +1921,14 @@ gst_value_serialize_flags (const GValue * value)
|
|||
|
||||
result = g_strdup ("");
|
||||
flags = g_value_get_flags (value);
|
||||
|
||||
/* if no flags are set, try to serialize to the _NONE string */
|
||||
if (!flags) {
|
||||
fl = gst_flags_get_first_value (klass, flags);
|
||||
return g_strdup (fl->value_name);
|
||||
}
|
||||
|
||||
/* some flags are set, so serialize one by one */
|
||||
while (flags) {
|
||||
fl = gst_flags_get_first_value (klass, flags);
|
||||
if (fl != NULL) {
|
||||
|
|
|
@ -319,6 +319,69 @@ GST_START_TEST (test_deserialize_guint_failures)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_serialize_flags)
|
||||
{
|
||||
GValue value = { 0 };
|
||||
gchar *string;
|
||||
GstSeekFlags flags[] = {
|
||||
0,
|
||||
GST_SEEK_FLAG_NONE,
|
||||
GST_SEEK_FLAG_FLUSH,
|
||||
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
|
||||
};
|
||||
const char *results[] = {
|
||||
"GST_SEEK_FLAG_NONE",
|
||||
"GST_SEEK_FLAG_NONE",
|
||||
"GST_SEEK_FLAG_FLUSH",
|
||||
"GST_SEEK_FLAG_FLUSH+GST_SEEK_FLAG_ACCURATE",
|
||||
};
|
||||
int i;
|
||||
|
||||
g_value_init (&value, GST_TYPE_SEEK_FLAGS);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (flags); ++i) {
|
||||
g_value_set_flags (&value, flags[i]);
|
||||
string = gst_value_serialize (&value);
|
||||
fail_if (string == NULL, "could not serialize flags %d", i);
|
||||
fail_unless (strcmp (string, results[i]) == 0,
|
||||
"resulting value is %s, not %s, for flags #%d", string, results[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
GST_START_TEST (test_deserialize_flags)
|
||||
{
|
||||
GValue value = { 0 };
|
||||
const char *strings[] = {
|
||||
"",
|
||||
"0",
|
||||
"GST_SEEK_FLAG_NONE",
|
||||
"GST_SEEK_FLAG_FLUSH",
|
||||
"GST_SEEK_FLAG_FLUSH+GST_SEEK_FLAG_ACCURATE",
|
||||
};
|
||||
GstSeekFlags results[] = {
|
||||
GST_SEEK_FLAG_NONE,
|
||||
GST_SEEK_FLAG_NONE,
|
||||
GST_SEEK_FLAG_NONE,
|
||||
GST_SEEK_FLAG_FLUSH,
|
||||
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
|
||||
};
|
||||
int i;
|
||||
|
||||
g_value_init (&value, GST_TYPE_SEEK_FLAGS);
|
||||
|
||||
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_flags (&value) == results[i],
|
||||
"resulting value is %d, not %d, for string %s (%d)",
|
||||
g_value_get_flags (&value), results[i], strings[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_string)
|
||||
{
|
||||
|
@ -1431,6 +1494,8 @@ gst_value_suite (void)
|
|||
tcase_add_test (tc_chain, test_deserialize_guint_failures);
|
||||
tcase_add_test (tc_chain, test_deserialize_gint64);
|
||||
tcase_add_test (tc_chain, test_deserialize_gstfraction);
|
||||
tcase_add_test (tc_chain, test_serialize_flags);
|
||||
tcase_add_test (tc_chain, test_deserialize_flags);
|
||||
tcase_add_test (tc_chain, test_string);
|
||||
tcase_add_test (tc_chain, test_deserialize_string);
|
||||
tcase_add_test (tc_chain, test_value_compare);
|
||||
|
|
Loading…
Reference in a new issue