Problem serializing GstStructure with G_TYPE_DATE_TIME field
Here is a simple repro.
GDateTime* zulu = g_date_time_new_utc(2020, 4, 25, 8, 29, 0.000001);
ASSERT_NE(nullptr, zulu); // It isn't null here
GstStructure* gstruct = gst_structure_new("struct_name",
"zulu", G_TYPE_DATE_TIME, zulu, // Debugging shows that the field was set properly (I think)
nullptr);
gchar* gstring = gst_structure_to_string(gstruct); // struct_name, zulu=(GDateTime)NULL;
The problem is: The gstring
at the end shows that the zulu
field is NULL
. The field is not actually null.
Debugging shows that the problem is related to gst_value_serialize
which returns NULL
.
gchar *
gst_value_serialize (const GValue * value) // <--- A correct-looking value is passed in (wrapping a correct pointer)
{
guint i, len;
GValue s_val = { 0 };
GstValueTable *table, *best;
gchar *s;
GType type;
g_return_val_if_fail (G_IS_VALUE (value), NULL);
type = G_VALUE_TYPE (value);
best = gst_value_hash_lookup_type (type);
if (G_UNLIKELY (!best || !best->serialize)) {
len = gst_value_table->len;
best = NULL;
for (i = 0; i < len; i++) {
table = &g_array_index (gst_value_table, GstValueTable, i);
if (table->serialize && g_type_is_a (type, table->type)) {
if (!best || g_type_is_a (table->type, best->type))
best = table;
}
}
}
if (G_LIKELY (best))
return best->serialize (value);
g_value_init (&s_val, G_TYPE_STRING);
if (g_value_transform (value, &s_val)) {
s = gst_string_wrap (g_value_get_string (&s_val));
} else {
s = NULL; // <-- The function makes it here
}
g_value_unset (&s_val);
return s;
}
Is there some kind of serialization support that gstreamer should be initializing for this to work?
As a side-note, I have seen gst-discoverer-1.0 produce a tag list which contains this datetime=(datetime)1954-04-16T05:59:22-0700
so I'm not sure why my repro above will not work.
I am on Gstreamer 1.16.1-msvc (on windows).