xml-formatter: Add support for metadata on sources
authorPiotrek Brzeziński <thewildtree@outlook.com>
Fri, 9 Jul 2021 14:15:01 +0000 (16:15 +0200)
committerPiotrek Brzeziński <thewildtree@outlook.com>
Fri, 13 Aug 2021 22:10:06 +0000 (00:10 +0200)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/260>

ges/ges-base-xml-formatter.c
ges/ges-internal.h
ges/ges-xml-formatter.c

index a6d1a68..1a1f4e3 100644 (file)
@@ -1109,7 +1109,7 @@ done:
 void
 ges_base_xml_formatter_add_source (GESBaseXmlFormatter * self,
     const gchar * track_id, GstStructure * children_properties,
-    GstStructure * properties)
+    GstStructure * properties, const gchar * metadatas)
 {
   GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);
   GESTrackElement *element = NULL;
@@ -1138,6 +1138,10 @@ ges_base_xml_formatter_add_source (GESBaseXmlFormatter * self,
   if (children_properties)
     gst_structure_foreach (children_properties,
         (GstStructureForeachFunc) _set_child_property, element);
+
+  if (metadatas)
+    ges_meta_container_add_metas_from_string (GES_META_CONTAINER
+        (element), metadatas);
 }
 
 void
index dad6c9c..66b2ba8 100644 (file)
@@ -366,7 +366,8 @@ G_GNUC_INTERNAL void ges_base_xml_formatter_add_track_element   (GESBaseXmlForma
 G_GNUC_INTERNAL void ges_base_xml_formatter_add_source          (GESBaseXmlFormatter *self,
                                                                  const gchar * track_id,
                                                                  GstStructure *children_properties,
-                                                                 GstStructure *properties);
+                                                                 GstStructure *properties,
+                                                                 const gchar *metadatas);
 
 G_GNUC_INTERNAL void ges_base_xml_formatter_add_group           (GESBaseXmlFormatter *self,
                                                                  const gchar *name,
index 0747ccf..63660f1 100644 (file)
@@ -35,8 +35,8 @@
 
 #define parent_class ges_xml_formatter_parent_class
 #define API_VERSION 0
-#define MINOR_VERSION 7
-#define VERSION 0.7
+#define MINOR_VERSION 8
+#define VERSION 0.8
 
 #define COLLECT_STR_OPT (G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL)
 
@@ -722,14 +722,15 @@ _parse_source (GMarkupParseContext * context, const gchar * element_name,
     GESXmlFormatter * self, GError ** error)
 {
   GstStructure *children_props = NULL, *props = NULL;
-  const gchar *track_id = NULL, *children_properties = NULL, *properties = NULL;
+  const gchar *track_id = NULL, *children_properties = NULL, *properties =
+      NULL, *metadatas = NULL;
 
   if (!g_markup_collect_attributes (element_name, attribute_names,
           attribute_values, error,
           G_MARKUP_COLLECT_STRING, "track-id", &track_id,
           COLLECT_STR_OPT, "children-properties", &children_properties,
           COLLECT_STR_OPT, "properties", &properties,
-          G_MARKUP_COLLECT_INVALID)) {
+          COLLECT_STR_OPT, "metadatas", &metadatas, G_MARKUP_COLLECT_INVALID)) {
     return;
   }
 
@@ -746,7 +747,7 @@ _parse_source (GMarkupParseContext * context, const gchar * element_name,
   }
 
   ges_base_xml_formatter_add_source (GES_BASE_XML_FORMATTER (self), track_id,
-      children_props, props);
+      children_props, props, metadatas);
 
 done:
   if (children_props)
@@ -1619,7 +1620,7 @@ _save_source (GESXmlFormatter * self, GString * str,
 {
   gint index, n_props;
   gboolean serialize;
-  gchar *properties;
+  gchar *properties, *metas;
 
   if (!GES_IS_SOURCE (element))
     return;
@@ -1648,6 +1649,10 @@ _save_source (GESXmlFormatter * self, GString * str,
   }
   g_free (properties);
 
+  metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (element));
+  g_string_append_printf (str, "metadatas='%s' ", metas);
+  g_free (metas);
+
   _save_children_properties (str, element, depth);
   append_escaped (str, g_markup_printf_escaped (">\n"), depth);
   _save_keyframes (str, GES_TRACK_ELEMENT (element), index, depth);