mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
value: add GstTagList serialisation/deserialisation
So we can serialise/deserialise taglists inside structures, which used to work automagically before because GstTagList was just a typedef to GstStructure (same for the GType), but now that it's a separate GType we need to register explicit functions for this. Helps with GDP stuff in pipelines/streamheader tests.
This commit is contained in:
parent
80f94703f9
commit
ffdefd7720
2 changed files with 50 additions and 0 deletions
|
@ -1681,6 +1681,8 @@ gst_structure_get_abbrs (gint * n_abbrs)
|
|||
{"datetime", GST_TYPE_DATE_TIME}
|
||||
,
|
||||
{"bitmask", GST_TYPE_BITMASK}
|
||||
,
|
||||
{"taglist", GST_TYPE_TAG_LIST}
|
||||
};
|
||||
_num = G_N_ELEMENTS (dyn_abbrs);
|
||||
/* permanently allocate and copy the array now */
|
||||
|
|
|
@ -1958,6 +1958,43 @@ gst_value_deserialize_structure (GValue * dest, const gchar * s)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/**************
|
||||
* GstTagList *
|
||||
**************/
|
||||
|
||||
static gboolean
|
||||
gst_value_deserialize_tag_list (GValue * dest, const gchar * s)
|
||||
{
|
||||
GstTagList *taglist;
|
||||
|
||||
if (*s != '"') {
|
||||
taglist = gst_tag_list_new_from_string (s);
|
||||
} else {
|
||||
gchar *str = gst_string_unwrap (s);
|
||||
|
||||
if (G_UNLIKELY (!str))
|
||||
return FALSE;
|
||||
|
||||
taglist = gst_tag_list_new_from_string (str);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
if (G_LIKELY (taglist != NULL)) {
|
||||
g_value_take_boxed (dest, taglist);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gst_value_serialize_tag_list (const GValue * value)
|
||||
{
|
||||
GstTagList *taglist = g_value_get_boxed (value);
|
||||
|
||||
return gst_string_take_and_wrap (gst_tag_list_to_string (taglist));
|
||||
}
|
||||
|
||||
|
||||
/*************
|
||||
* GstBuffer *
|
||||
*************/
|
||||
|
@ -5806,6 +5843,17 @@ _priv_gst_value_initialize (void)
|
|||
gst_value.type = GST_TYPE_STRUCTURE;
|
||||
gst_value_register (&gst_value);
|
||||
}
|
||||
{
|
||||
static GstValueTable gst_value = {
|
||||
0,
|
||||
NULL,
|
||||
gst_value_serialize_tag_list,
|
||||
gst_value_deserialize_tag_list,
|
||||
};
|
||||
|
||||
gst_value.type = GST_TYPE_TAG_LIST;
|
||||
gst_value_register (&gst_value);
|
||||
}
|
||||
{
|
||||
static GstValueTable gst_value = {
|
||||
0,
|
||||
|
|
Loading…
Reference in a new issue