value: add GstTagList serialisation/deserialisation
authorTim-Philipp Müller <tim@centricular.net>
Thu, 19 Jul 2012 23:49:28 +0000 (00:49 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 20 Jul 2012 08:39:53 +0000 (09:39 +0100)
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.

gst/gststructure.c
gst/gstvalue.c

index 4ab57881eb769ca20c274340e1e049f66c0cdb96..56b66bcca54a4805b4070828b179f56b6112644e 100644 (file)
@@ -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 */
index ca229268a754a97fda726667b106810a88d6089a..da46859d031affe235e4e053fbaf99b531d25e4e 100644 (file)
@@ -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,