formatter: Serialize source properties

This way we ensure that the TrackElement 'active' property is
properly serialized
This commit is contained in:
Thibault Saunier 2020-03-13 15:03:17 -03:00
parent f9f30c4ced
commit 2d810bd7b7
4 changed files with 37 additions and 12 deletions

View file

@ -1106,7 +1106,8 @@ ges_base_xml_formatter_add_control_binding (GESBaseXmlFormatter * self,
void
ges_base_xml_formatter_add_source (GESBaseXmlFormatter * self,
const gchar * track_id, GstStructure * children_properties)
const gchar * track_id, GstStructure * children_properties,
GstStructure * properties)
{
GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);
GESTrackElement *element = NULL;
@ -1128,8 +1129,13 @@ ges_base_xml_formatter_add_source (GESBaseXmlFormatter * self,
return;
}
gst_structure_foreach (children_properties,
(GstStructureForeachFunc) _set_child_property, element);
if (properties)
gst_structure_foreach (properties,
(GstStructureForeachFunc) set_property_foreach, element);
if (children_properties)
gst_structure_foreach (children_properties,
(GstStructureForeachFunc) _set_child_property, element);
}
void

View file

@ -329,7 +329,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 *children_properties,
GstStructure *properties);
G_GNUC_INTERNAL void ges_base_xml_formatter_add_group (GESBaseXmlFormatter *self,
const gchar *name,

View file

@ -122,10 +122,10 @@ GList* ges_layer_get_clips (GESLayer * layer);
GES_API
GstClockTime ges_layer_get_duration (GESLayer *layer);
GES_API
gboolean ges_layer_set_active_for_tracks(GESLayer *layer, gboolean active,
GList *tracks);
gboolean ges_layer_set_active_for_tracks (GESLayer *layer, gboolean active,
GList *tracks);
GES_API gboolean ges_layer_get_active_for_track(GESLayer *layer,
GESTrack *track);
GES_API gboolean ges_layer_get_active_for_track (GESLayer *layer,
GESTrack *track);
G_END_DECLS

View file

@ -712,13 +712,14 @@ _parse_source (GMarkupParseContext * context, const gchar * element_name,
const gchar ** attribute_names, const gchar ** attribute_values,
GESXmlFormatter * self, GError ** error)
{
GstStructure *children_props = NULL;
const gchar *track_id = NULL, *children_properties = NULL;
GstStructure *children_props = NULL, *props = NULL;
const gchar *track_id = NULL, *children_properties = NULL, *properties = 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)) {
return;
}
@ -729,12 +730,22 @@ _parse_source (GMarkupParseContext * context, const gchar * element_name,
goto wrong_children_properties;
}
ges_base_xml_formatter_add_source (GES_BASE_XML_FORMATTER (self), track_id,
children_props);
if (properties) {
props = gst_structure_from_string (properties, NULL);
if (props == NULL)
goto wrong_properties;
}
ges_base_xml_formatter_add_source (GES_BASE_XML_FORMATTER (self), track_id,
children_props, props);
done:
if (children_props)
gst_structure_free (children_props);
if (props)
gst_structure_free (props);
return;
wrong_children_properties:
@ -742,6 +753,13 @@ wrong_children_properties:
G_MARKUP_ERROR_INVALID_CONTENT,
"element '%s', children properties '%s', could no be deserialized",
element_name, children_properties);
goto done;
wrong_properties:
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
"element '%s', properties '%s', could no be deserialized",
element_name, properties);
goto done;
}
static inline void