xml-formatter: Serialize groups metadatas

This commit is contained in:
Thibault Saunier 2019-01-15 09:38:14 -03:00 committed by Thibault Saunier
parent c883f98961
commit 1f1b1c8cba
3 changed files with 21 additions and 10 deletions

View file

@ -1389,7 +1389,7 @@ done:
void void
ges_base_xml_formatter_add_group (GESBaseXmlFormatter * self, ges_base_xml_formatter_add_group (GESBaseXmlFormatter * self,
const gchar * id, const gchar * properties) const gchar * id, const gchar * properties, const gchar * metadatas)
{ {
PendingGroup *pgroup; PendingGroup *pgroup;
GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self); GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);
@ -1400,6 +1400,10 @@ ges_base_xml_formatter_add_group (GESBaseXmlFormatter * self,
pgroup = g_slice_new0 (PendingGroup); pgroup = g_slice_new0 (PendingGroup);
pgroup->group = ges_group_new (); pgroup->group = ges_group_new ();
if (metadatas)
ges_meta_container_add_metas_from_string (GES_META_CONTAINER
(pgroup->group), metadatas);
g_hash_table_insert (priv->containers, g_strdup (id), g_hash_table_insert (priv->containers, g_strdup (id),
gst_object_ref (pgroup->group)); gst_object_ref (pgroup->group));
priv->groups = g_list_prepend (priv->groups, pgroup); priv->groups = g_list_prepend (priv->groups, pgroup);

View file

@ -291,7 +291,8 @@ G_GNUC_INTERNAL void ges_base_xml_formatter_add_source (GESBaseXmlForma
G_GNUC_INTERNAL void ges_base_xml_formatter_add_group (GESBaseXmlFormatter *self, G_GNUC_INTERNAL void ges_base_xml_formatter_add_group (GESBaseXmlFormatter *self,
const gchar *name, const gchar *name,
const gchar *properties); const gchar *properties,
const gchar *metadatas);
G_GNUC_INTERNAL void ges_base_xml_formatter_last_group_add_child(GESBaseXmlFormatter *self, G_GNUC_INTERNAL void ges_base_xml_formatter_last_group_add_child(GESBaseXmlFormatter *self,
const gchar * id, const gchar * id,

View file

@ -34,8 +34,8 @@
#define parent_class ges_xml_formatter_parent_class #define parent_class ges_xml_formatter_parent_class
#define API_VERSION 0 #define API_VERSION 0
#define MINOR_VERSION 4 #define MINOR_VERSION 5
#define VERSION 0.4 #define VERSION 0.5
#define COLLECT_STR_OPT (G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL) #define COLLECT_STR_OPT (G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL)
@ -736,18 +736,18 @@ _parse_group (GMarkupParseContext * context, const gchar * element_name,
const gchar ** attribute_names, const gchar ** attribute_values, const gchar ** attribute_names, const gchar ** attribute_values,
GESXmlFormatter * self, GError ** error) GESXmlFormatter * self, GError ** error)
{ {
const gchar *id, *properties; const gchar *id, *properties, *metadatas = NULL;
if (!g_markup_collect_attributes (element_name, attribute_names, if (!g_markup_collect_attributes (element_name, attribute_names,
attribute_values, error, attribute_values, error,
G_MARKUP_COLLECT_STRING, "id", &id, G_MARKUP_COLLECT_STRING, "id", &id,
G_MARKUP_COLLECT_STRING, "properties", &properties, G_MARKUP_COLLECT_STRING, "properties", &properties,
G_MARKUP_COLLECT_INVALID)) { COLLECT_STR_OPT, "metadatas", &metadatas, G_MARKUP_COLLECT_INVALID)) {
return; return;
} }
ges_base_xml_formatter_add_group (GES_BASE_XML_FORMATTER (self), id, ges_base_xml_formatter_add_group (GES_BASE_XML_FORMATTER (self), id,
properties); properties, metadatas);
} }
static inline void static inline void
@ -1295,7 +1295,7 @@ _save_group (GESXmlFormatter * self, GString * str, GList ** seen_groups,
{ {
GList *tmp; GList *tmp;
gboolean serialize; gboolean serialize;
gchar *properties; gchar *properties, *metadatas;
g_object_get (group, "serialize", &serialize, NULL); g_object_get (group, "serialize", &serialize, NULL);
if (!serialize) { if (!serialize) {
@ -1320,9 +1320,15 @@ _save_group (GESXmlFormatter * self, GString * str, GList ** seen_groups,
} }
properties = _serialize_properties (G_OBJECT (group), NULL); properties = _serialize_properties (G_OBJECT (group), NULL);
g_string_append_printf (str, " <group id='%d' properties='%s'>\n",
self->priv->nbelements, properties); metadatas = ges_meta_container_metas_to_string (GES_META_CONTAINER (group));
self->priv->min_version = MAX (self->priv->min_version, 5);
g_string_append_printf (str,
" <group id='%d' properties='%s' metadatas='%s'>\n",
self->priv->nbelements, properties, metadatas);
g_free (properties); g_free (properties);
g_free (metadatas);
g_hash_table_insert (self->priv->element_id, group, g_hash_table_insert (self->priv->element_id, group,
GINT_TO_POINTER (self->priv->nbelements)); GINT_TO_POINTER (self->priv->nbelements));
self->priv->nbelements++; self->priv->nbelements++;