2012-11-19 16:24:03 +00:00
|
|
|
/* Gstreamer Editing Services
|
|
|
|
*
|
|
|
|
* Copyright (C) <2012> Thibault Saunier <thibault.saunier@collabora.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#undef VERSION
|
|
|
|
#endif
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* TODO Determine error codes numbers */
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
#include <string.h>
|
2012-11-19 16:24:03 +00:00
|
|
|
#include <errno.h>
|
2013-08-31 22:46:45 +00:00
|
|
|
#include <locale.h>
|
|
|
|
|
|
|
|
#include "ges.h"
|
2019-07-08 00:55:53 +00:00
|
|
|
#include <glib/gstdio.h>
|
2012-11-19 16:24:03 +00:00
|
|
|
#include "ges-internal.h"
|
|
|
|
|
|
|
|
#define parent_class ges_xml_formatter_parent_class
|
|
|
|
#define API_VERSION 0
|
2021-07-09 14:15:01 +00:00
|
|
|
#define MINOR_VERSION 8
|
|
|
|
#define VERSION 0.8
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
#define COLLECT_STR_OPT (G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL)
|
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
#define _GET_PRIV(o) (((GESXmlFormatter*)o)->priv)
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar *id;
|
|
|
|
gint start_line;
|
|
|
|
gint start_char;
|
|
|
|
gint fd;
|
|
|
|
gchar *filename;
|
|
|
|
GError *error;
|
|
|
|
GMainLoop *ml;
|
|
|
|
} SubprojectData;
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
struct _GESXmlFormatterPrivate
|
|
|
|
{
|
|
|
|
gboolean ges_opened;
|
|
|
|
gboolean project_opened;
|
|
|
|
|
|
|
|
GString *str;
|
2014-10-27 15:51:42 +00:00
|
|
|
|
|
|
|
GHashTable *element_id;
|
2019-07-08 00:55:53 +00:00
|
|
|
GHashTable *subprojects_map;
|
|
|
|
SubprojectData *subproject;
|
|
|
|
gint subproject_depth;
|
2014-10-27 15:51:42 +00:00
|
|
|
|
|
|
|
guint nbelements;
|
2015-05-18 19:24:25 +00:00
|
|
|
|
|
|
|
guint min_version;
|
2012-11-19 16:24:03 +00:00
|
|
|
};
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
G_LOCK_DEFINE_STATIC (uri_subprojects_map_lock);
|
|
|
|
/* { project_uri: { subproject_uri: new_suproject_uri}} */
|
|
|
|
static GHashTable *uri_subprojects_map = NULL;
|
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GESXmlFormatter, ges_xml_formatter,
|
|
|
|
GES_TYPE_BASE_XML_FORMATTER);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
static GString *_save_project (GESFormatter * formatter, GString * str,
|
|
|
|
GESProject * project, GESTimeline * timeline, GError ** error, guint depth);
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
static inline void
|
|
|
|
_parse_ges_element (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
2015-05-18 19:24:25 +00:00
|
|
|
guint api_version;
|
2012-11-19 16:24:03 +00:00
|
|
|
const gchar *version, *properties;
|
|
|
|
|
|
|
|
gchar **split_version = NULL;
|
|
|
|
|
|
|
|
if (g_strcmp0 (element_name, "ges")) {
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
2019-07-08 00:55:53 +00:00
|
|
|
"Found element '%s', Missing '<ges>' element'", element_name);
|
2012-11-19 16:24:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error, G_MARKUP_COLLECT_STRING, "version", &version,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
|
|
|
G_MARKUP_COLLECT_INVALID)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
split_version = g_strsplit (version, ".", 2);
|
|
|
|
if (split_version[1] == NULL)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
api_version = g_ascii_strtoull (split_version[0], NULL, 10);
|
|
|
|
if (errno || api_version != API_VERSION)
|
|
|
|
goto stroull_failed;
|
|
|
|
|
2015-05-18 19:24:25 +00:00
|
|
|
self->priv->min_version = g_ascii_strtoull (split_version[1], NULL, 10);
|
|
|
|
if (self->priv->min_version > MINOR_VERSION)
|
2012-11-19 16:24:03 +00:00
|
|
|
goto failed;
|
|
|
|
|
|
|
|
_GET_PRIV (self)->ges_opened = TRUE;
|
|
|
|
g_strfreev (split_version);
|
|
|
|
return;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', %s wrong version'", element_name, version);
|
|
|
|
if (split_version)
|
|
|
|
g_strfreev (split_version);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
stroull_failed:
|
|
|
|
GST_WARNING_OBJECT (self, "Error while strtoull: %s", g_strerror (errno));
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_project (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
const gchar *metadatas = NULL, *properties;
|
|
|
|
GESXmlFormatterPrivate *priv = _GET_PRIV (self);
|
|
|
|
|
|
|
|
if (g_strcmp0 (element_name, "project")) {
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
2019-01-18 20:12:42 +00:00
|
|
|
"Found element '%s', Missing '<project>' element'", element_name);
|
2012-11-19 16:24:03 +00:00
|
|
|
} else {
|
|
|
|
priv->project_opened = TRUE;
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas, G_MARKUP_COLLECT_INVALID))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (GES_FORMATTER (self)->project && metadatas)
|
|
|
|
ges_meta_container_add_metas_from_string (GES_META_CONTAINER
|
|
|
|
(GES_FORMATTER (self)->project), metadatas);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_encoding_profile (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name, const gchar ** attribute_names,
|
|
|
|
const gchar ** attribute_values, GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
GstCaps *capsformat = NULL;
|
2017-08-22 14:23:45 +00:00
|
|
|
GstStructure *preset_properties = NULL;
|
|
|
|
const gchar *name, *description, *type, *preset = NULL,
|
|
|
|
*str_preset_properties = NULL, *preset_name = NULL, *format;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "name", &name,
|
|
|
|
G_MARKUP_COLLECT_STRING, "description", &description,
|
|
|
|
G_MARKUP_COLLECT_STRING, "type", &type,
|
|
|
|
COLLECT_STR_OPT, "preset", &preset,
|
2017-08-22 14:23:45 +00:00
|
|
|
COLLECT_STR_OPT, "preset-properties", &str_preset_properties,
|
2012-11-19 16:24:03 +00:00
|
|
|
COLLECT_STR_OPT, "preset-name", &preset_name,
|
|
|
|
COLLECT_STR_OPT, "format", &format, G_MARKUP_COLLECT_INVALID))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (format)
|
|
|
|
capsformat = gst_caps_from_string (format);
|
|
|
|
|
2017-08-22 14:23:45 +00:00
|
|
|
if (str_preset_properties) {
|
|
|
|
preset_properties = gst_structure_from_string (str_preset_properties, NULL);
|
|
|
|
if (preset_properties == NULL) {
|
2019-06-16 15:09:46 +00:00
|
|
|
gst_caps_unref (capsformat);
|
2017-08-22 14:23:45 +00:00
|
|
|
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Wrong preset-properties format.", element_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
ges_base_xml_formatter_add_encoding_profile (GES_BASE_XML_FORMATTER (self),
|
2017-08-22 14:23:45 +00:00
|
|
|
type, NULL, name, description, capsformat, preset, preset_properties,
|
|
|
|
preset_name, 0, 0, NULL, 0, FALSE, NULL, TRUE, error);
|
2019-11-20 06:52:56 +00:00
|
|
|
|
|
|
|
if (preset_properties)
|
|
|
|
gst_structure_free (preset_properties);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_stream_profile (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name, const gchar ** attribute_names,
|
|
|
|
const gchar ** attribute_values, GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
2015-05-07 08:52:18 +00:00
|
|
|
gboolean variableframerate = FALSE, enabled = TRUE;
|
2012-11-19 16:24:03 +00:00
|
|
|
guint id = 0, presence = 0, pass = 0;
|
|
|
|
GstCaps *format_caps = NULL, *restriction_caps = NULL;
|
2017-08-22 14:23:45 +00:00
|
|
|
GstStructure *preset_properties = NULL;
|
2012-11-19 16:24:03 +00:00
|
|
|
const gchar *parent, *strid, *type, *strpresence, *format = NULL,
|
2017-08-22 14:23:45 +00:00
|
|
|
*name = NULL, *description = NULL, *preset,
|
|
|
|
*str_preset_properties = NULL, *preset_name = NULL, *restriction = NULL,
|
|
|
|
*strpass = NULL, *strvariableframerate = NULL, *strenabled = NULL;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
/* FIXME Looks like there is a bug in that function, if we put the parent
|
|
|
|
* at the beginning it set %NULL and not the real value... :/ */
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "id", &strid,
|
|
|
|
G_MARKUP_COLLECT_STRING, "type", &type,
|
|
|
|
G_MARKUP_COLLECT_STRING, "presence", &strpresence,
|
|
|
|
COLLECT_STR_OPT, "format", &format,
|
|
|
|
COLLECT_STR_OPT, "name", &name,
|
|
|
|
COLLECT_STR_OPT, "description", &description,
|
|
|
|
COLLECT_STR_OPT, "preset", &preset,
|
2017-08-22 14:23:45 +00:00
|
|
|
COLLECT_STR_OPT, "preset-properties", &str_preset_properties,
|
2012-11-19 16:24:03 +00:00
|
|
|
COLLECT_STR_OPT, "preset-name", &preset_name,
|
|
|
|
COLLECT_STR_OPT, "restriction", &restriction,
|
2014-04-10 16:01:03 +00:00
|
|
|
COLLECT_STR_OPT, "pass", &strpass,
|
2012-11-19 16:24:03 +00:00
|
|
|
COLLECT_STR_OPT, "variableframerate", &strvariableframerate,
|
2015-05-07 08:52:18 +00:00
|
|
|
COLLECT_STR_OPT, "enabled", &strenabled,
|
2012-11-19 16:24:03 +00:00
|
|
|
G_MARKUP_COLLECT_STRING, "parent", &parent, G_MARKUP_COLLECT_INVALID))
|
|
|
|
return;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
id = g_ascii_strtoll (strid, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
|
|
|
|
if (strpresence) {
|
|
|
|
presence = g_ascii_strtoll (strpresence, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
}
|
|
|
|
|
2017-08-22 14:23:45 +00:00
|
|
|
if (str_preset_properties) {
|
|
|
|
preset_properties = gst_structure_from_string (str_preset_properties, NULL);
|
|
|
|
if (preset_properties == NULL)
|
|
|
|
goto convertion_failed;
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
if (strpass) {
|
|
|
|
pass = g_ascii_strtoll (strpass, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strvariableframerate) {
|
|
|
|
variableframerate = g_ascii_strtoll (strvariableframerate, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
}
|
|
|
|
|
2015-05-07 08:52:18 +00:00
|
|
|
if (strenabled) {
|
|
|
|
enabled = g_ascii_strtoll (strenabled, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
if (format)
|
|
|
|
format_caps = gst_caps_from_string (format);
|
|
|
|
|
|
|
|
if (restriction)
|
|
|
|
restriction_caps = gst_caps_from_string (restriction);
|
|
|
|
|
|
|
|
ges_base_xml_formatter_add_encoding_profile (GES_BASE_XML_FORMATTER (self),
|
2017-08-22 14:23:45 +00:00
|
|
|
type, parent, name, description, format_caps, preset, preset_properties,
|
|
|
|
preset_name, id, presence, restriction_caps, pass, variableframerate,
|
|
|
|
NULL, enabled, error);
|
|
|
|
|
|
|
|
if (preset_properties)
|
|
|
|
gst_structure_free (preset_properties);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
convertion_failed:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Wrong property type, error: %s'", element_name,
|
|
|
|
g_strerror (errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_timeline (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
const gchar *metadatas = NULL, *properties = NULL;
|
|
|
|
GESTimeline *timeline = GES_FORMATTER (self)->timeline;
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas, G_MARKUP_COLLECT_INVALID))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (timeline == NULL)
|
|
|
|
return;
|
|
|
|
|
2013-08-07 17:37:49 +00:00
|
|
|
ges_base_xml_formatter_set_timeline_properties (GES_BASE_XML_FORMATTER (self),
|
|
|
|
timeline, properties, metadatas);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_asset (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
GType extractable_type;
|
|
|
|
const gchar *id, *extractable_type_name, *metadatas = NULL, *properties =
|
2015-11-20 22:33:12 +00:00
|
|
|
NULL, *proxy_id = NULL;
|
2019-07-08 00:55:53 +00:00
|
|
|
GESXmlFormatterPrivate *priv = _GET_PRIV (self);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error, G_MARKUP_COLLECT_STRING, "id", &id,
|
|
|
|
G_MARKUP_COLLECT_STRING, "extractable-type-name",
|
|
|
|
&extractable_type_name,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
2015-11-20 22:33:12 +00:00
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas,
|
|
|
|
COLLECT_STR_OPT, "proxy-id", &proxy_id, G_MARKUP_COLLECT_INVALID))
|
2012-11-19 16:24:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
extractable_type = g_type_from_name (extractable_type_name);
|
2019-07-08 00:55:53 +00:00
|
|
|
if (extractable_type == GES_TYPE_TIMELINE) {
|
|
|
|
SubprojectData *subproj_data = g_malloc0 (sizeof (SubprojectData));
|
|
|
|
const gchar *nid;
|
|
|
|
|
|
|
|
priv->subproject = subproj_data;
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
nid = g_hash_table_lookup (priv->subprojects_map, id);
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
|
|
|
|
if (!nid) {
|
|
|
|
subproj_data->id = id;
|
|
|
|
subproj_data->fd =
|
|
|
|
g_file_open_tmp ("XXXXXX.xges", &subproj_data->filename, error);
|
|
|
|
if (subproj_data->fd == -1) {
|
|
|
|
GST_ERROR_OBJECT (self, "Could not create subproject file for %s", id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_markup_parse_context_get_position (context, &subproj_data->start_line,
|
|
|
|
&subproj_data->start_char);
|
2019-08-12 14:17:53 +00:00
|
|
|
id = g_filename_to_uri (subproj_data->filename, NULL, NULL);
|
2019-07-08 00:55:53 +00:00
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
g_hash_table_insert (priv->subprojects_map, g_strdup (subproj_data->id),
|
|
|
|
(gchar *) id);
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
GST_INFO_OBJECT (self, "Serialized subproject %sis now at: %s",
|
|
|
|
subproj_data->id, id);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (self, "Subproject already exists: %s -> %s", id, nid);
|
|
|
|
id = nid;
|
|
|
|
subproj_data->start_line = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
if (extractable_type == G_TYPE_NONE)
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s' invalid extractable_type %s'",
|
|
|
|
element_name, extractable_type_name);
|
|
|
|
else if (!g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE))
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', %s not an extractable_type'",
|
|
|
|
element_name, extractable_type_name);
|
|
|
|
else {
|
|
|
|
GstStructure *props = NULL;
|
|
|
|
if (properties)
|
|
|
|
props = gst_structure_from_string (properties, NULL);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
if (extractable_type == GES_TYPE_URI_CLIP) {
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
if (g_hash_table_contains (priv->subprojects_map, id)) {
|
|
|
|
id = g_hash_table_lookup (priv->subprojects_map, id);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "Using subproject %s", id);
|
|
|
|
}
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
ges_base_xml_formatter_add_asset (GES_BASE_XML_FORMATTER (self), id,
|
2015-11-20 22:33:12 +00:00
|
|
|
extractable_type, props, metadatas, proxy_id, error);
|
2012-11-19 16:24:03 +00:00
|
|
|
if (props)
|
|
|
|
gst_structure_free (props);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_track (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
GESTrackType track_type;
|
2013-09-25 17:48:45 +00:00
|
|
|
GstStructure *props = NULL;
|
2012-11-19 16:24:03 +00:00
|
|
|
const gchar *strtrack_type, *strcaps, *strtrack_id, *metadatas =
|
|
|
|
NULL, *properties = NULL;
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "track-type", &strtrack_type,
|
|
|
|
G_MARKUP_COLLECT_STRING, "track-id", &strtrack_id,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas,
|
|
|
|
G_MARKUP_COLLECT_STRING, "caps", &strcaps, G_MARKUP_COLLECT_INVALID))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((caps = gst_caps_from_string (strcaps)) == NULL)
|
|
|
|
goto wrong_caps;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
track_type = g_ascii_strtoll (strtrack_type, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
|
2013-09-25 17:48:45 +00:00
|
|
|
if (properties) {
|
|
|
|
props = gst_structure_from_string (properties, NULL);
|
2021-01-19 13:29:09 +00:00
|
|
|
if (!props)
|
|
|
|
goto wrong_properties;
|
2013-09-25 17:48:45 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
ges_base_xml_formatter_add_track (GES_BASE_XML_FORMATTER (self), track_type,
|
2013-09-25 17:48:45 +00:00
|
|
|
caps, strtrack_id, props, metadatas, error);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2014-05-10 20:45:34 +00:00
|
|
|
if (props)
|
|
|
|
gst_structure_free (props);
|
|
|
|
|
2015-10-01 09:28:38 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
wrong_caps:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Can not create caps: %s'", element_name, strcaps);
|
|
|
|
return;
|
|
|
|
|
|
|
|
convertion_failed:
|
2012-12-29 22:34:29 +00:00
|
|
|
gst_caps_unref (caps);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Wrong property type, error: %s'", element_name,
|
|
|
|
g_strerror (errno));
|
|
|
|
return;
|
|
|
|
|
2021-01-19 13:29:09 +00:00
|
|
|
wrong_properties:
|
|
|
|
gst_clear_caps (&caps);
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Can not create properties: %s'", element_name, properties);
|
|
|
|
return;
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_layer (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
GstStructure *props = NULL;
|
|
|
|
guint priority;
|
|
|
|
GType extractable_type = G_TYPE_NONE;
|
|
|
|
const gchar *metadatas = NULL, *properties = NULL, *strprio = NULL,
|
2020-03-06 21:56:52 +00:00
|
|
|
*extractable_type_name, *deactivated_tracks_str;
|
|
|
|
|
|
|
|
gchar **deactivated_tracks = NULL;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "priority", &strprio,
|
|
|
|
COLLECT_STR_OPT, "extractable-type-name", &extractable_type_name,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
2020-03-06 21:56:52 +00:00
|
|
|
COLLECT_STR_OPT, "deactivated-tracks", &deactivated_tracks_str,
|
2012-11-19 16:24:03 +00:00
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas, G_MARKUP_COLLECT_INVALID))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (extractable_type_name) {
|
|
|
|
extractable_type = g_type_from_name (extractable_type_name);
|
|
|
|
if (extractable_type == G_TYPE_NONE) {
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s' invalid extractable_type %s'",
|
|
|
|
element_name, extractable_type_name);
|
|
|
|
|
|
|
|
return;
|
|
|
|
} else if (!g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE)) {
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', %s not an extractable_type'",
|
|
|
|
element_name, extractable_type_name);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (properties) {
|
|
|
|
props = gst_structure_from_string (properties, NULL);
|
|
|
|
if (props == NULL)
|
|
|
|
goto wrong_properties;
|
|
|
|
}
|
|
|
|
|
2014-07-18 16:27:20 +00:00
|
|
|
errno = 0;
|
2012-11-19 16:24:03 +00:00
|
|
|
priority = g_ascii_strtoll (strprio, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
if (deactivated_tracks_str)
|
|
|
|
deactivated_tracks = g_strsplit (deactivated_tracks_str, " ", -1);
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
ges_base_xml_formatter_add_layer (GES_BASE_XML_FORMATTER (self),
|
2020-03-06 21:56:52 +00:00
|
|
|
extractable_type, priority, props, metadatas, deactivated_tracks, error);
|
|
|
|
|
|
|
|
g_strfreev (deactivated_tracks);
|
2014-05-10 20:41:23 +00:00
|
|
|
|
|
|
|
done:
|
2012-11-19 16:24:03 +00:00
|
|
|
if (props)
|
|
|
|
gst_structure_free (props);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
convertion_failed:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Wrong property type, error: %s'", element_name,
|
|
|
|
g_strerror (errno));
|
2014-05-10 20:41:23 +00:00
|
|
|
goto done;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
wrong_properties:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', wrong layer properties '%s', could no be deserialized",
|
|
|
|
element_name, properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2013-01-20 15:42:29 +00:00
|
|
|
_parse_clip (GMarkupParseContext * context,
|
2012-11-19 16:24:03 +00:00
|
|
|
const gchar * element_name, const gchar ** attribute_names,
|
|
|
|
const gchar ** attribute_values, GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
GType type;
|
2018-07-28 16:16:36 +00:00
|
|
|
GstStructure *props = NULL, *children_props = NULL;
|
2012-11-19 16:24:03 +00:00
|
|
|
GESTrackType track_types;
|
|
|
|
GstClockTime start, inpoint = 0, duration, layer_prio;
|
2019-07-08 00:55:53 +00:00
|
|
|
GESXmlFormatterPrivate *priv = _GET_PRIV (self);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
const gchar *strid, *asset_id, *strstart, *strin, *strduration, *strrate,
|
|
|
|
*strtrack_types, *strtype, *metadatas = NULL, *properties =
|
2018-07-28 16:16:36 +00:00
|
|
|
NULL, *children_properties = NULL, *strlayer_prio;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "id", &strid,
|
|
|
|
G_MARKUP_COLLECT_STRING, "type-name", &strtype,
|
|
|
|
G_MARKUP_COLLECT_STRING, "start", &strstart,
|
|
|
|
G_MARKUP_COLLECT_STRING, "duration", &strduration,
|
|
|
|
G_MARKUP_COLLECT_STRING, "asset-id", &asset_id,
|
|
|
|
G_MARKUP_COLLECT_STRING, "track-types", &strtrack_types,
|
|
|
|
G_MARKUP_COLLECT_STRING, "layer-priority", &strlayer_prio,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
2018-07-28 16:16:36 +00:00
|
|
|
COLLECT_STR_OPT, "children-properties", &children_properties,
|
2012-11-19 16:24:03 +00:00
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas,
|
|
|
|
COLLECT_STR_OPT, "rate", &strrate,
|
|
|
|
COLLECT_STR_OPT, "inpoint", &strin, G_MARKUP_COLLECT_INVALID)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
type = g_type_from_name (strtype);
|
2013-01-20 15:42:29 +00:00
|
|
|
if (!g_type_is_a (type, GES_TYPE_CLIP))
|
2012-11-19 16:24:03 +00:00
|
|
|
goto wrong_type;
|
|
|
|
|
2014-07-18 16:27:20 +00:00
|
|
|
errno = 0;
|
2012-11-19 16:24:03 +00:00
|
|
|
track_types = g_ascii_strtoll (strtrack_types, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
|
|
|
|
layer_prio = g_ascii_strtoll (strlayer_prio, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
|
|
|
|
if (strin) {
|
|
|
|
inpoint = g_ascii_strtoull (strin, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
start = g_ascii_strtoull (strstart, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
|
|
|
|
duration = g_ascii_strtoull (strduration, NULL, 10);
|
|
|
|
if (errno)
|
|
|
|
goto convertion_failed;
|
|
|
|
|
|
|
|
if (properties) {
|
|
|
|
props = gst_structure_from_string (properties, NULL);
|
|
|
|
if (props == NULL)
|
|
|
|
goto wrong_properties;
|
|
|
|
}
|
|
|
|
|
2018-07-28 16:16:36 +00:00
|
|
|
if (children_properties) {
|
|
|
|
children_props = gst_structure_from_string (children_properties, NULL);
|
|
|
|
if (children_props == NULL)
|
|
|
|
goto wrong_children_properties;
|
|
|
|
}
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
if (g_hash_table_contains (priv->subprojects_map, asset_id)) {
|
|
|
|
asset_id = g_hash_table_lookup (priv->subprojects_map, asset_id);
|
|
|
|
GST_DEBUG_OBJECT (self, "Using subproject %s", asset_id);
|
|
|
|
}
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_base_xml_formatter_add_clip (GES_BASE_XML_FORMATTER (self),
|
layer: Remove the "rate" property of ges_timeline_layer_add_asset
API:
- ges_timeline_layer_add_asset (layer, asset, start, inpoint, duration, rate, track_types);
+ ges_timeline_layer_add_asset (layer, asset, start, inpoint, duration, track_types);
2013-04-23 22:57:44 +00:00
|
|
|
strid, asset_id, type, start, inpoint, duration, layer_prio,
|
2018-07-28 16:16:36 +00:00
|
|
|
track_types, props, children_props, metadatas, error);
|
2012-11-19 16:24:03 +00:00
|
|
|
if (props)
|
|
|
|
gst_structure_free (props);
|
2019-11-20 06:52:56 +00:00
|
|
|
if (children_props)
|
|
|
|
gst_structure_free (children_props);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
wrong_properties:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
2013-01-20 15:42:29 +00:00
|
|
|
"element '%s', Clip %s properties '%s', could no be deserialized",
|
2012-11-19 16:24:03 +00:00
|
|
|
element_name, asset_id, properties);
|
|
|
|
return;
|
|
|
|
|
2018-07-28 16:16:36 +00:00
|
|
|
wrong_children_properties:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Clip %s children properties '%s', could no be deserialized",
|
|
|
|
element_name, asset_id, children_properties);
|
2019-11-20 06:52:56 +00:00
|
|
|
if (props)
|
|
|
|
gst_structure_free (props);
|
2018-07-28 16:16:36 +00:00
|
|
|
return;
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
convertion_failed:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Wrong property type, error: %s'", element_name,
|
|
|
|
g_strerror (errno));
|
|
|
|
return;
|
|
|
|
|
|
|
|
wrong_type:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
2013-01-20 15:42:29 +00:00
|
|
|
"element '%s', %s not a GESClip'", element_name, strtype);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
static inline void
|
|
|
|
_parse_binding (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
const gchar *type = NULL, *source_type = NULL, *timed_values =
|
2013-07-08 22:31:30 +00:00
|
|
|
NULL, *property_name = NULL, *mode = NULL, *track_id = NULL;
|
2013-03-30 17:54:50 +00:00
|
|
|
gchar **pairs, **tmp;
|
|
|
|
gchar *pair;
|
|
|
|
GSList *list = NULL;
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "type", &type,
|
|
|
|
G_MARKUP_COLLECT_STRING, "source_type", &source_type,
|
|
|
|
G_MARKUP_COLLECT_STRING, "property", &property_name,
|
|
|
|
G_MARKUP_COLLECT_STRING, "mode", &mode,
|
2013-07-08 22:31:30 +00:00
|
|
|
G_MARKUP_COLLECT_STRING, "track_id", &track_id,
|
2013-03-30 17:54:50 +00:00
|
|
|
G_MARKUP_COLLECT_STRING, "values", &timed_values,
|
|
|
|
G_MARKUP_COLLECT_INVALID)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pairs = g_strsplit (timed_values, " ", 0);
|
|
|
|
for (tmp = pairs; tmp != NULL; tmp += 1) {
|
|
|
|
gchar **value_pair;
|
|
|
|
|
|
|
|
pair = *tmp;
|
|
|
|
if (pair == NULL)
|
|
|
|
break;
|
|
|
|
if (strlen (pair)) {
|
|
|
|
GstTimedValue *value;
|
|
|
|
|
2019-07-12 20:15:35 +00:00
|
|
|
value = g_new0 (GstTimedValue, 1);
|
2013-03-30 17:54:50 +00:00
|
|
|
value_pair = g_strsplit (pair, ":", 0);
|
|
|
|
value->timestamp = g_ascii_strtoull (value_pair[0], NULL, 10);
|
|
|
|
value->value = g_ascii_strtod (value_pair[1], NULL);
|
|
|
|
list = g_slist_append (list, value);
|
|
|
|
g_strfreev (value_pair);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (pairs);
|
2013-07-08 22:31:30 +00:00
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
ges_base_xml_formatter_add_control_binding (GES_BASE_XML_FORMATTER (self),
|
|
|
|
type,
|
|
|
|
source_type,
|
2013-07-08 22:31:30 +00:00
|
|
|
property_name, (gint) g_ascii_strtoll (mode, NULL, 10), track_id, list);
|
2013-03-30 17:54:50 +00:00
|
|
|
}
|
|
|
|
|
2013-09-13 23:35:55 +00:00
|
|
|
static inline void
|
|
|
|
_parse_source (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
2020-03-13 18:03:17 +00:00
|
|
|
GstStructure *children_props = NULL, *props = NULL;
|
2021-07-09 14:15:01 +00:00
|
|
|
const gchar *track_id = NULL, *children_properties = NULL, *properties =
|
|
|
|
NULL, *metadatas = NULL;
|
2013-09-13 23:35:55 +00:00
|
|
|
|
|
|
|
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,
|
2020-03-13 18:03:17 +00:00
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
2021-07-09 14:15:01 +00:00
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas, G_MARKUP_COLLECT_INVALID)) {
|
2013-09-13 23:35:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (children_properties) {
|
|
|
|
children_props = gst_structure_from_string (children_properties, NULL);
|
|
|
|
if (children_props == NULL)
|
|
|
|
goto wrong_children_properties;
|
|
|
|
}
|
|
|
|
|
2020-03-13 18:03:17 +00:00
|
|
|
if (properties) {
|
|
|
|
props = gst_structure_from_string (properties, NULL);
|
|
|
|
if (props == NULL)
|
|
|
|
goto wrong_properties;
|
|
|
|
}
|
|
|
|
|
2013-09-13 23:35:55 +00:00
|
|
|
ges_base_xml_formatter_add_source (GES_BASE_XML_FORMATTER (self), track_id,
|
2021-07-09 14:15:01 +00:00
|
|
|
children_props, props, metadatas);
|
2013-09-13 23:35:55 +00:00
|
|
|
|
2020-03-13 18:03:17 +00:00
|
|
|
done:
|
2013-09-13 23:35:55 +00:00
|
|
|
if (children_props)
|
|
|
|
gst_structure_free (children_props);
|
|
|
|
|
2020-03-13 18:03:17 +00:00
|
|
|
if (props)
|
|
|
|
gst_structure_free (props);
|
|
|
|
|
2013-09-13 23:35:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
wrong_children_properties:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', children properties '%s', could no be deserialized",
|
|
|
|
element_name, children_properties);
|
2020-03-13 18:03:17 +00:00
|
|
|
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;
|
2013-09-13 23:35:55 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
static inline void
|
|
|
|
_parse_effect (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
GType type;
|
|
|
|
|
|
|
|
GstStructure *children_props = NULL, *props = NULL;
|
|
|
|
const gchar *asset_id = NULL, *strtype = NULL, *track_id =
|
|
|
|
NULL, *metadatas = NULL, *properties = NULL, *track_type = NULL,
|
2013-01-20 15:42:29 +00:00
|
|
|
*children_properties = NULL, *clip_id;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas,
|
|
|
|
G_MARKUP_COLLECT_STRING, "asset-id", &asset_id,
|
2013-01-20 15:42:29 +00:00
|
|
|
G_MARKUP_COLLECT_STRING, "clip-id", &clip_id,
|
2012-11-19 16:24:03 +00:00
|
|
|
G_MARKUP_COLLECT_STRING, "type-name", &strtype,
|
|
|
|
G_MARKUP_COLLECT_STRING, "track-id", &track_id,
|
|
|
|
COLLECT_STR_OPT, "children-properties", &children_properties,
|
|
|
|
COLLECT_STR_OPT, "track-type", &track_type,
|
|
|
|
COLLECT_STR_OPT, "properties", &properties,
|
|
|
|
G_MARKUP_COLLECT_INVALID)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = g_type_from_name (strtype);
|
2013-01-26 15:35:19 +00:00
|
|
|
if (!g_type_is_a (type, GES_TYPE_BASE_EFFECT))
|
2012-11-19 16:24:03 +00:00
|
|
|
goto wrong_type;
|
|
|
|
|
|
|
|
if (children_properties) {
|
|
|
|
children_props = gst_structure_from_string (children_properties, NULL);
|
|
|
|
if (children_props == NULL)
|
|
|
|
goto wrong_children_properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (properties) {
|
|
|
|
props = gst_structure_from_string (properties, NULL);
|
|
|
|
if (props == NULL)
|
|
|
|
goto wrong_properties;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_base_xml_formatter_add_track_element (GES_BASE_XML_FORMATTER (self),
|
2013-01-20 15:42:29 +00:00
|
|
|
type, asset_id, track_id, clip_id, children_props, props, metadatas,
|
2012-11-19 16:24:03 +00:00
|
|
|
error);
|
|
|
|
|
2014-05-09 12:00:32 +00:00
|
|
|
out:
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
if (props)
|
|
|
|
gst_structure_free (props);
|
|
|
|
if (children_props)
|
|
|
|
gst_structure_free (children_props);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
wrong_properties:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Effect %s properties '%s', could no be deserialized",
|
|
|
|
element_name, asset_id, properties);
|
2014-05-13 12:30:39 +00:00
|
|
|
goto out;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
wrong_children_properties:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"element '%s', Effect %s children properties '%s', could no be deserialized",
|
|
|
|
element_name, asset_id, children_properties);
|
2014-05-09 12:00:32 +00:00
|
|
|
goto out;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
wrong_type:
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
2013-01-26 15:35:19 +00:00
|
|
|
"element '%s', %s not a GESBaseEffect'", element_name, strtype);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
2014-10-27 15:51:42 +00:00
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_group (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
2019-01-15 12:38:14 +00:00
|
|
|
const gchar *id, *properties, *metadatas = NULL;
|
2014-10-27 15:51:42 +00:00
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "id", &id,
|
|
|
|
G_MARKUP_COLLECT_STRING, "properties", &properties,
|
2019-01-15 12:38:14 +00:00
|
|
|
COLLECT_STR_OPT, "metadatas", &metadatas, G_MARKUP_COLLECT_INVALID)) {
|
2014-10-27 15:51:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ges_base_xml_formatter_add_group (GES_BASE_XML_FORMATTER (self), id,
|
2019-01-15 12:38:14 +00:00
|
|
|
properties, metadatas);
|
2014-10-27 15:51:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_parse_group_child (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
GESXmlFormatter * self, GError ** error)
|
|
|
|
{
|
|
|
|
const gchar *child_id, *name;
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, attribute_names,
|
|
|
|
attribute_values, error,
|
|
|
|
G_MARKUP_COLLECT_STRING, "id", &child_id,
|
|
|
|
G_MARKUP_COLLECT_STRING, "name", &name, G_MARKUP_COLLECT_INVALID)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ges_base_xml_formatter_last_group_add_child (GES_BASE_XML_FORMATTER (self),
|
|
|
|
child_id, name);
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
static void
|
|
|
|
_parse_element_start (GMarkupParseContext * context, const gchar * element_name,
|
|
|
|
const gchar ** attribute_names, const gchar ** attribute_values,
|
|
|
|
gpointer self, GError ** error)
|
|
|
|
{
|
|
|
|
GESXmlFormatterPrivate *priv = _GET_PRIV (self);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
if (priv->subproject) {
|
|
|
|
if (g_strcmp0 (element_name, "ges") == 0) {
|
|
|
|
priv->subproject_depth += 1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!G_UNLIKELY (priv->ges_opened)) {
|
2012-11-19 16:24:03 +00:00
|
|
|
_parse_ges_element (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
2019-07-08 00:55:53 +00:00
|
|
|
} else if (!G_UNLIKELY (priv->project_opened))
|
2012-11-19 16:24:03 +00:00
|
|
|
_parse_project (context, element_name, attribute_names, attribute_values,
|
|
|
|
self, error);
|
2019-07-08 00:55:53 +00:00
|
|
|
else if (g_strcmp0 (element_name, "ges") == 0) {
|
|
|
|
} else if (g_strcmp0 (element_name, "encoding-profile") == 0)
|
2012-11-19 16:24:03 +00:00
|
|
|
_parse_encoding_profile (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
|
|
|
else if (g_strcmp0 (element_name, "stream-profile") == 0)
|
|
|
|
_parse_stream_profile (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
|
|
|
else if (g_strcmp0 (element_name, "timeline") == 0)
|
|
|
|
_parse_timeline (context, element_name, attribute_names, attribute_values,
|
|
|
|
self, error);
|
|
|
|
else if (g_strcmp0 (element_name, "asset") == 0)
|
|
|
|
_parse_asset (context, element_name, attribute_names, attribute_values,
|
|
|
|
self, error);
|
|
|
|
else if (g_strcmp0 (element_name, "track") == 0)
|
|
|
|
_parse_track (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
|
|
|
else if (g_strcmp0 (element_name, "layer") == 0)
|
|
|
|
_parse_layer (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
2013-01-20 15:42:29 +00:00
|
|
|
else if (g_strcmp0 (element_name, "clip") == 0)
|
|
|
|
_parse_clip (context, element_name, attribute_names,
|
2012-11-19 16:24:03 +00:00
|
|
|
attribute_values, self, error);
|
2013-09-13 23:35:55 +00:00
|
|
|
else if (g_strcmp0 (element_name, "source") == 0)
|
|
|
|
_parse_source (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
2012-11-19 16:24:03 +00:00
|
|
|
else if (g_strcmp0 (element_name, "effect") == 0)
|
|
|
|
_parse_effect (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
2013-03-30 17:54:50 +00:00
|
|
|
else if (g_strcmp0 (element_name, "binding") == 0)
|
|
|
|
_parse_binding (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
2014-10-27 15:51:42 +00:00
|
|
|
else if (g_strcmp0 (element_name, "group") == 0)
|
|
|
|
_parse_group (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
|
|
|
else if (g_strcmp0 (element_name, "child") == 0)
|
|
|
|
_parse_group_child (context, element_name, attribute_names,
|
|
|
|
attribute_values, self, error);
|
2012-11-19 16:24:03 +00:00
|
|
|
else
|
|
|
|
GST_LOG_OBJECT (self, "Element %s not handled", element_name);
|
|
|
|
}
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
static gboolean
|
|
|
|
_save_subproject_data (GESXmlFormatter * self, SubprojectData * subproj_data,
|
|
|
|
gint subproject_end_line, gint subproject_end_char, GError ** error)
|
|
|
|
{
|
|
|
|
gsize size;
|
|
|
|
gint line = 1, i;
|
|
|
|
gboolean res = FALSE;
|
|
|
|
gsize start = 0, end = 0;
|
|
|
|
gchar *xml = GES_BASE_XML_FORMATTER (self)->xmlcontent;
|
|
|
|
|
|
|
|
for (i = 0; xml[i] != '\0'; i++) {
|
|
|
|
if (!start && line == subproj_data->start_line) {
|
|
|
|
i += subproj_data->start_char - 1;
|
|
|
|
start = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line == subproject_end_line) {
|
|
|
|
end = i + subproject_end_char - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xml[i] == '\n')
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
g_assert (start && end);
|
|
|
|
size = (end - start);
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (self, "Saving subproject %s from %d:%d(%" G_GSIZE_FORMAT
|
|
|
|
") to %d:%d(%" G_GSIZE_FORMAT ")",
|
|
|
|
subproj_data->id, subproj_data->start_line, subproj_data->start_char,
|
|
|
|
start, subproject_end_line, subproject_end_char, end);
|
|
|
|
|
2021-05-12 21:43:46 +00:00
|
|
|
res = g_file_set_contents (subproj_data->filename, &xml[start], size, error);
|
2019-07-08 00:55:53 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
static void
|
|
|
|
_parse_element_end (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name, gpointer self, GError ** error)
|
|
|
|
{
|
2019-07-08 00:55:53 +00:00
|
|
|
GESXmlFormatterPrivate *priv = _GET_PRIV (self);
|
|
|
|
SubprojectData *subproj_data = priv->subproject;
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
/*GESXmlFormatterPrivate *priv = _GET_PRIV (self); */
|
2015-05-18 19:24:25 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
if (!g_strcmp0 (element_name, "ges")) {
|
|
|
|
gint subproject_end_line, subproject_end_char;
|
|
|
|
|
|
|
|
if (priv->subproject_depth)
|
|
|
|
priv->subproject_depth -= 1;
|
|
|
|
|
|
|
|
if (!subproj_data) {
|
|
|
|
if (GES_FORMATTER (self)->project) {
|
|
|
|
gchar *version = g_strdup_printf ("%d.%d",
|
|
|
|
API_VERSION, GES_XML_FORMATTER (self)->priv->min_version);
|
|
|
|
|
|
|
|
ges_meta_container_set_string (GES_META_CONTAINER (GES_FORMATTER
|
|
|
|
(self)->project), GES_META_FORMAT_VERSION, version);
|
|
|
|
|
|
|
|
g_free (version);
|
|
|
|
_GET_PRIV (self)->ges_opened = FALSE;
|
|
|
|
}
|
|
|
|
} else if (subproj_data->start_line != -1 && !priv->subproject_depth) {
|
|
|
|
g_markup_parse_context_get_position (context, &subproject_end_line,
|
|
|
|
&subproject_end_char);
|
|
|
|
_save_subproject_data (GES_XML_FORMATTER (self), subproj_data,
|
|
|
|
subproject_end_line, subproject_end_char, error);
|
|
|
|
|
|
|
|
subproj_data->filename = NULL;
|
|
|
|
g_close (subproj_data->fd, error);
|
|
|
|
subproj_data->id = NULL;
|
|
|
|
subproj_data->start_line = 0;
|
|
|
|
subproj_data->start_char = 0;
|
|
|
|
}
|
2015-05-18 19:24:25 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
if (!priv->subproject_depth) {
|
|
|
|
g_clear_pointer (&priv->subproject, g_free);
|
|
|
|
}
|
2020-05-21 21:22:18 +00:00
|
|
|
} else if (!g_strcmp0 (element_name, "clip")) {
|
|
|
|
if (!priv->subproject)
|
|
|
|
ges_base_xml_formatter_end_current_clip (GES_BASE_XML_FORMATTER (self));
|
2015-05-18 19:24:25 +00:00
|
|
|
}
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_error_parsing (GMarkupParseContext * context, GError * error,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2019-01-18 20:25:11 +00:00
|
|
|
GST_WARNING ("Error occurred when parsing %s", error->message);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************
|
|
|
|
* *
|
|
|
|
* Saving implementation *
|
|
|
|
* *
|
|
|
|
***********************************************/
|
|
|
|
|
|
|
|
/* XML writting utils */
|
|
|
|
static inline void
|
2019-07-08 00:55:53 +00:00
|
|
|
string_add_indents (GString * str, guint depth, gboolean prepend)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
for (i = 0; i < depth; i++)
|
|
|
|
prepend ? g_string_prepend (str, " ") : g_string_append (str, " ");
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
string_append_with_depth (GString * str, const gchar * string, guint depth)
|
|
|
|
{
|
|
|
|
string_add_indents (str, depth, FALSE);
|
|
|
|
g_string_append (str, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
append_escaped (GString * str, gchar * tmpstr, guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, tmpstr, depth);
|
2013-04-22 00:11:52 +00:00
|
|
|
g_free (tmpstr);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
2021-01-15 18:21:06 +00:00
|
|
|
gboolean
|
|
|
|
ges_util_can_serialize_spec (GParamSpec * spec)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
2014-09-27 07:59:12 +00:00
|
|
|
if (!(spec->flags & G_PARAM_WRITABLE)) {
|
2019-07-09 04:07:16 +00:00
|
|
|
GST_LOG ("%s from %s is not writable",
|
2014-09-27 07:59:12 +00:00
|
|
|
spec->name, g_type_name (spec->owner_type));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
} else if (spec->flags & G_PARAM_CONSTRUCT_ONLY) {
|
2019-07-09 04:07:16 +00:00
|
|
|
GST_LOG ("%s from %s is construct only",
|
2014-09-27 07:59:12 +00:00
|
|
|
spec->name, g_type_name (spec->owner_type));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
} else if (spec->flags & GES_PARAM_NO_SERIALIZATION &&
|
|
|
|
g_type_is_a (spec->owner_type, GES_TYPE_TIMELINE_ELEMENT)) {
|
2019-07-09 04:07:16 +00:00
|
|
|
GST_LOG ("%s from %s is set as GES_PARAM_NO_SERIALIZATION",
|
2014-09-27 07:59:12 +00:00
|
|
|
spec->name, g_type_name (spec->owner_type));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
} else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (spec), G_TYPE_OBJECT)) {
|
2019-07-09 04:07:16 +00:00
|
|
|
GST_LOG ("%s from %s contains GObject, can't serialize that.",
|
2014-09-27 07:59:12 +00:00
|
|
|
spec->name, g_type_name (spec->owner_type));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
} else if ((g_type_is_a (spec->owner_type, GST_TYPE_OBJECT) &&
|
|
|
|
!g_strcmp0 (spec->name, "name"))) {
|
|
|
|
|
2019-07-09 04:07:16 +00:00
|
|
|
GST_LOG ("We do not want to serialize the name of GstObjects.");
|
2014-09-27 07:59:12 +00:00
|
|
|
return FALSE;
|
|
|
|
} else if (G_PARAM_SPEC_VALUE_TYPE (spec) == G_TYPE_GTYPE) {
|
2019-07-09 04:07:16 +00:00
|
|
|
GST_LOG ("%s from %s contains a GType, can't serialize.",
|
2014-09-27 07:59:12 +00:00
|
|
|
spec->name, g_type_name (spec->owner_type));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_init_value_from_spec_for_serialization (GValue * value, GParamSpec * spec)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (g_type_is_a (spec->value_type, G_TYPE_ENUM) ||
|
|
|
|
g_type_is_a (spec->value_type, G_TYPE_FLAGS))
|
|
|
|
g_value_init (value, G_TYPE_INT);
|
|
|
|
else
|
|
|
|
g_value_init (value, spec->value_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2020-03-06 21:56:52 +00:00
|
|
|
_serialize_properties (GObject * object, gint * ret_n_props,
|
|
|
|
const gchar * fieldname, ...)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
|
|
|
gchar *ret;
|
|
|
|
guint n_props, j;
|
|
|
|
GParamSpec *spec, **pspecs;
|
|
|
|
GObjectClass *class = G_OBJECT_GET_CLASS (object);
|
|
|
|
GstStructure *structure = gst_structure_new_empty ("properties");
|
|
|
|
|
|
|
|
pspecs = g_object_class_list_properties (class, &n_props);
|
|
|
|
for (j = 0; j < n_props; j++) {
|
|
|
|
GValue val = { 0 };
|
|
|
|
|
|
|
|
spec = pspecs[j];
|
2021-01-15 18:21:06 +00:00
|
|
|
if (!ges_util_can_serialize_spec (spec))
|
2020-03-06 21:56:52 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
_init_value_from_spec_for_serialization (&val, spec);
|
|
|
|
g_object_get_property (object, spec->name, &val);
|
|
|
|
if (gst_value_compare (g_param_spec_get_default_value (spec),
|
|
|
|
&val) == GST_VALUE_EQUAL) {
|
|
|
|
GST_INFO ("Ignoring %s as it is using the default value", spec->name);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2013-09-25 17:48:45 +00:00
|
|
|
if (spec->value_type == GST_TYPE_CAPS) {
|
2015-10-01 09:28:38 +00:00
|
|
|
gchar *caps_str;
|
2020-03-06 21:56:52 +00:00
|
|
|
const GstCaps *caps = gst_value_get_caps (&val);
|
2013-09-25 17:48:45 +00:00
|
|
|
|
2015-10-01 09:28:38 +00:00
|
|
|
caps_str = gst_caps_to_string (caps);
|
|
|
|
gst_structure_set (structure, spec->name, G_TYPE_STRING, caps_str, NULL);
|
|
|
|
g_free (caps_str);
|
2020-03-06 21:56:52 +00:00
|
|
|
goto next;
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
2020-03-06 21:56:52 +00:00
|
|
|
|
|
|
|
gst_structure_set_value (structure, spec->name, &val);
|
|
|
|
|
|
|
|
next:
|
|
|
|
g_value_unset (&val);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
g_free (pspecs);
|
|
|
|
|
|
|
|
if (fieldname) {
|
|
|
|
va_list varargs;
|
|
|
|
va_start (varargs, fieldname);
|
|
|
|
gst_structure_remove_fields_valist (structure, fieldname, varargs);
|
|
|
|
va_end (varargs);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = gst_structure_to_string (structure);
|
2020-03-06 21:56:52 +00:00
|
|
|
if (ret_n_props)
|
|
|
|
*ret_n_props = gst_structure_n_fields (structure);
|
2012-11-19 16:24:03 +00:00
|
|
|
gst_structure_free (structure);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
static void
|
|
|
|
project_loaded_cb (GESProject * project, GESTimeline * timeline,
|
|
|
|
SubprojectData * data)
|
|
|
|
{
|
|
|
|
g_main_loop_quit (data->ml);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
error_loading_asset_cb (GESProject * project, GError * err,
|
|
|
|
const gchar * unused_id, GType extractable_type, SubprojectData * data)
|
|
|
|
{
|
|
|
|
data->error = g_error_copy (err);
|
|
|
|
g_main_loop_quit (data->ml);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_save_subproject (GESXmlFormatter * self, GString * str, GESProject * project,
|
|
|
|
GESAsset * subproject, GError ** error, guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
2019-07-08 00:55:53 +00:00
|
|
|
GString *substr;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
gchar *properties, *metas;
|
|
|
|
GESXmlFormatterPrivate *priv = self->priv;
|
|
|
|
GMainContext *context = g_main_context_get_thread_default ();
|
|
|
|
const gchar *id = ges_asset_get_id (subproject);
|
|
|
|
SubprojectData data = { 0, };
|
|
|
|
|
|
|
|
if (!g_strcmp0 (ges_asset_get_id (GES_ASSET (project)), id)) {
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
G_MARKUP_ERROR_INVALID_CONTENT,
|
|
|
|
"Project %s trying to recurse into itself", id);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
g_hash_table_insert (priv->subprojects_map, g_strdup (id), g_strdup (id));
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
timeline = GES_TIMELINE (ges_asset_extract (subproject, error));
|
|
|
|
if (!timeline) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
context = g_main_context_default ();
|
|
|
|
|
|
|
|
data.ml = g_main_loop_new (context, TRUE);
|
|
|
|
g_signal_connect (subproject, "loaded", (GCallback) project_loaded_cb, &data);
|
|
|
|
g_signal_connect (subproject, "error-loading-asset",
|
2019-08-19 15:35:49 +00:00
|
|
|
(GCallback) error_loading_asset_cb, &data);
|
2019-07-08 00:55:53 +00:00
|
|
|
g_main_loop_run (data.ml);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (subproject, project_loaded_cb, &data);
|
|
|
|
g_signal_handlers_disconnect_by_func (subproject, error_loading_asset_cb,
|
|
|
|
&data);
|
|
|
|
if (data.error) {
|
|
|
|
g_propagate_error (error, data.error);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
subproject = ges_extractable_get_asset (GES_EXTRACTABLE (timeline));
|
|
|
|
substr = g_string_new (NULL);
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (G_OBJECT (subproject), NULL, NULL);
|
2019-07-08 00:55:53 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (subproject));
|
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
|
|
|
(" <asset id='%s' extractable-type-name='%s' properties='%s' metadatas='%s'>\n",
|
|
|
|
ges_asset_get_id (subproject),
|
|
|
|
g_type_name (ges_asset_get_extractable_type (subproject)), properties,
|
|
|
|
metas), depth);
|
2019-08-19 13:38:12 +00:00
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 6);
|
2019-07-08 00:55:53 +00:00
|
|
|
|
|
|
|
depth += 4;
|
|
|
|
GST_DEBUG_OBJECT (self, "Saving subproject %s (depth: %d)",
|
|
|
|
ges_asset_get_id (subproject), depth / 4);
|
|
|
|
if (!_save_project (GES_FORMATTER (self), substr, GES_PROJECT (subproject),
|
|
|
|
timeline, error, depth)) {
|
|
|
|
g_string_free (substr, TRUE);
|
|
|
|
g_object_unref (subproject);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (self, "DONE Saving subproject %s",
|
|
|
|
ges_asset_get_id (subproject));
|
|
|
|
depth -= 4;
|
|
|
|
|
|
|
|
g_string_append (str, substr->str);
|
|
|
|
g_string_free (substr, TRUE);
|
|
|
|
string_append_with_depth (str, " </asset>\n", depth);
|
|
|
|
|
|
|
|
err:
|
|
|
|
g_object_unref (subproject);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
sort_assets (GESAsset * a, GESAsset * b)
|
|
|
|
{
|
|
|
|
if (GES_IS_PROJECT (a))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (GES_IS_PROJECT (b))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-07-13 17:25:48 +00:00
|
|
|
static void
|
|
|
|
_serialize_streams (GESXmlFormatter * self, GString * str,
|
|
|
|
GESUriClipAsset * asset, GError ** error, guint depth)
|
|
|
|
{
|
|
|
|
const GList *tmp, *streams = ges_uri_clip_asset_get_stream_assets (asset);
|
|
|
|
|
|
|
|
for (tmp = streams; tmp; tmp = tmp->next) {
|
|
|
|
gchar *properties, *metas, *capsstr;
|
|
|
|
const gchar *id = ges_asset_get_id (tmp->data);
|
|
|
|
GstDiscovererStreamInfo *sinfo =
|
|
|
|
ges_uri_source_asset_get_stream_info (tmp->data);
|
|
|
|
GstCaps *caps = gst_discoverer_stream_info_get_caps (sinfo);
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (tmp->data, NULL, NULL);
|
2019-07-13 17:25:48 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (tmp->data);
|
|
|
|
capsstr = gst_caps_to_string (caps);
|
|
|
|
|
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
|
|
|
(" <stream-info id='%s' extractable-type-name='%s' properties='%s' metadatas='%s' caps='%s'/>\n",
|
|
|
|
id, g_type_name (ges_asset_get_extractable_type (tmp->data)),
|
|
|
|
properties, metas, capsstr), depth);
|
2019-08-19 13:38:12 +00:00
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 6);
|
2019-07-13 17:25:48 +00:00
|
|
|
g_free (metas);
|
|
|
|
g_free (properties);
|
|
|
|
g_free (capsstr);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
static inline gboolean
|
|
|
|
_save_assets (GESXmlFormatter * self, GString * str, GESProject * project,
|
|
|
|
GError ** error, guint depth)
|
|
|
|
{
|
|
|
|
gchar *properties, *metas;
|
2015-11-20 22:33:12 +00:00
|
|
|
GESAsset *asset, *proxy;
|
2012-11-19 16:24:03 +00:00
|
|
|
GList *assets, *tmp;
|
2019-07-08 00:55:53 +00:00
|
|
|
const gchar *id;
|
|
|
|
GESXmlFormatterPrivate *priv = self->priv;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
assets = ges_project_list_assets (project, GES_TYPE_EXTRACTABLE);
|
2019-07-08 00:55:53 +00:00
|
|
|
for (tmp = g_list_sort (assets, (GCompareFunc) sort_assets); tmp;
|
|
|
|
tmp = tmp->next) {
|
2012-11-19 16:24:03 +00:00
|
|
|
asset = GES_ASSET (tmp->data);
|
2019-07-08 00:55:53 +00:00
|
|
|
id = ges_asset_get_id (asset);
|
|
|
|
|
|
|
|
if (GES_IS_PROJECT (asset)) {
|
|
|
|
if (!_save_subproject (self, str, project, asset, error, depth))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ges_asset_get_extractable_type (asset) == GES_TYPE_URI_CLIP) {
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
if (g_hash_table_contains (priv->subprojects_map, id)) {
|
|
|
|
id = g_hash_table_lookup (priv->subprojects_map, id);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "Using subproject %s", id);
|
|
|
|
}
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
}
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (G_OBJECT (asset), NULL, NULL);
|
2012-11-19 16:24:03 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (asset));
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
2015-11-20 22:33:12 +00:00
|
|
|
(" <asset id='%s' extractable-type-name='%s' properties='%s' metadatas='%s' ",
|
2019-07-08 00:55:53 +00:00
|
|
|
id, g_type_name (ges_asset_get_extractable_type (asset)),
|
|
|
|
properties, metas), depth);
|
2015-11-20 22:33:12 +00:00
|
|
|
|
|
|
|
/*TODO Save the whole list of proxies */
|
|
|
|
proxy = ges_asset_get_proxy (asset);
|
|
|
|
if (proxy) {
|
2019-07-08 00:55:53 +00:00
|
|
|
const gchar *proxy_id = ges_asset_get_id (proxy);
|
|
|
|
|
|
|
|
if (ges_asset_get_extractable_type (asset) == GES_TYPE_URI_CLIP) {
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
if (g_hash_table_contains (priv->subprojects_map, proxy_id)) {
|
|
|
|
proxy_id = g_hash_table_lookup (priv->subprojects_map, proxy_id);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "Using subproject %s", id);
|
|
|
|
}
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
}
|
2015-11-20 22:33:12 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped (" proxy-id='%s' ",
|
2019-07-08 00:55:53 +00:00
|
|
|
proxy_id), depth);
|
2015-11-20 22:33:12 +00:00
|
|
|
|
|
|
|
if (!g_list_find (assets, proxy)) {
|
|
|
|
assets = g_list_append (assets, gst_object_ref (proxy));
|
|
|
|
|
|
|
|
if (!tmp->next)
|
|
|
|
tmp->next = g_list_last (assets);
|
|
|
|
}
|
|
|
|
|
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 3);
|
|
|
|
}
|
2019-07-13 17:25:48 +00:00
|
|
|
g_string_append (str, ">\n");
|
|
|
|
|
|
|
|
if (GES_IS_URI_CLIP_ASSET (asset)) {
|
|
|
|
_serialize_streams (self, str, GES_URI_CLIP_ASSET (asset), error, depth);
|
|
|
|
}
|
2019-07-08 00:55:53 +00:00
|
|
|
|
2019-07-13 17:25:48 +00:00
|
|
|
string_append_with_depth (str, " </asset>\n", depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_free (properties);
|
|
|
|
g_free (metas);
|
|
|
|
}
|
2019-07-08 00:55:53 +00:00
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
g_list_free_full (assets, gst_object_unref);
|
2019-07-08 00:55:53 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_tracks (GESXmlFormatter * self, GString * str, GESTimeline * timeline,
|
|
|
|
guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
|
|
|
gchar *strtmp, *metas;
|
|
|
|
GESTrack *track;
|
|
|
|
GList *tmp, *tracks;
|
2013-09-25 17:48:45 +00:00
|
|
|
char *properties;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
guint nb_tracks = 0;
|
|
|
|
|
|
|
|
tracks = ges_timeline_get_tracks (timeline);
|
|
|
|
for (tmp = tracks; tmp; tmp = tmp->next) {
|
|
|
|
track = GES_TRACK (tmp->data);
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (G_OBJECT (track), NULL, "caps", NULL);
|
2012-11-19 16:24:03 +00:00
|
|
|
strtmp = gst_caps_to_string (ges_track_get_caps (track));
|
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (track));
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
2013-09-25 17:48:45 +00:00
|
|
|
(" <track caps='%s' track-type='%i' track-id='%i' properties='%s' metadatas='%s'/>\n",
|
2019-07-08 00:55:53 +00:00
|
|
|
strtmp, track->type, nb_tracks++, properties, metas), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_free (strtmp);
|
|
|
|
g_free (metas);
|
2013-09-25 17:48:45 +00:00
|
|
|
g_free (properties);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
g_list_free_full (tracks, gst_object_unref);
|
|
|
|
}
|
|
|
|
|
2013-09-13 23:35:55 +00:00
|
|
|
static inline void
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_children_properties (GString * str, GESTimelineElement * element,
|
|
|
|
guint depth)
|
2013-09-13 23:35:55 +00:00
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
GParamSpec **pspecs, *spec;
|
|
|
|
guint i, n_props;
|
2015-10-01 09:28:38 +00:00
|
|
|
gchar *struct_str;
|
2013-09-13 23:35:55 +00:00
|
|
|
|
2018-07-28 16:16:36 +00:00
|
|
|
pspecs = ges_timeline_element_list_children_properties (element, &n_props);
|
2013-09-13 23:35:55 +00:00
|
|
|
|
|
|
|
structure = gst_structure_new_empty ("properties");
|
|
|
|
for (i = 0; i < n_props; i++) {
|
|
|
|
GValue val = { 0 };
|
|
|
|
spec = pspecs[i];
|
|
|
|
|
2021-01-15 18:21:06 +00:00
|
|
|
if (ges_util_can_serialize_spec (spec)) {
|
2016-05-06 18:44:28 +00:00
|
|
|
gchar *spec_name =
|
|
|
|
g_strdup_printf ("%s::%s", g_type_name (spec->owner_type),
|
|
|
|
spec->name);
|
|
|
|
|
2013-09-13 23:35:55 +00:00
|
|
|
_init_value_from_spec_for_serialization (&val, spec);
|
2018-07-28 16:16:36 +00:00
|
|
|
ges_timeline_element_get_child_property_by_pspec (element, spec, &val);
|
2016-05-06 18:44:28 +00:00
|
|
|
gst_structure_set_value (structure, spec_name, &val);
|
|
|
|
|
|
|
|
g_free (spec_name);
|
2013-09-13 23:35:55 +00:00
|
|
|
g_value_unset (&val);
|
|
|
|
}
|
|
|
|
g_param_spec_unref (spec);
|
|
|
|
}
|
|
|
|
g_free (pspecs);
|
|
|
|
|
2015-10-01 09:28:38 +00:00
|
|
|
struct_str = gst_structure_to_string (structure);
|
2013-09-13 23:35:55 +00:00
|
|
|
append_escaped (str,
|
2019-07-08 00:55:53 +00:00
|
|
|
g_markup_printf_escaped (" children-properties='%s'", struct_str), 0);
|
2013-09-13 23:35:55 +00:00
|
|
|
gst_structure_free (structure);
|
2015-10-01 09:28:38 +00:00
|
|
|
g_free (struct_str);
|
2013-09-13 23:35:55 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
/* TODO : Use this function for every track element with controllable properties */
|
|
|
|
static inline void
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_keyframes (GString * str, GESTrackElement * trackelement, gint index,
|
|
|
|
guint depth)
|
2013-03-30 17:54:50 +00:00
|
|
|
{
|
|
|
|
GHashTable *bindings_hashtable;
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key, value;
|
|
|
|
|
2014-10-01 07:53:44 +00:00
|
|
|
bindings_hashtable =
|
|
|
|
ges_track_element_get_all_control_bindings (trackelement);
|
2013-03-30 17:54:50 +00:00
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, bindings_hashtable);
|
|
|
|
|
|
|
|
/* We iterate over the bindings, and save the timed values */
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
|
|
|
if (GST_IS_DIRECT_CONTROL_BINDING ((GstControlBinding *) value)) {
|
|
|
|
GstControlSource *source;
|
2015-06-16 11:25:32 +00:00
|
|
|
gboolean absolute = FALSE;
|
2013-03-30 17:54:50 +00:00
|
|
|
GstDirectControlBinding *binding;
|
|
|
|
|
|
|
|
binding = (GstDirectControlBinding *) value;
|
|
|
|
|
2015-06-16 11:25:32 +00:00
|
|
|
g_object_get (binding, "control-source", &source,
|
|
|
|
"absolute", &absolute, NULL);
|
2013-03-30 17:54:50 +00:00
|
|
|
|
|
|
|
if (GST_IS_INTERPOLATION_CONTROL_SOURCE (source)) {
|
|
|
|
GList *timed_values, *tmp;
|
|
|
|
GstInterpolationMode mode;
|
|
|
|
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
2015-06-16 11:25:32 +00:00
|
|
|
(" <binding type='%s' source_type='interpolation' property='%s'",
|
2019-07-08 00:55:53 +00:00
|
|
|
absolute ? "direct-absolute" : "direct", (gchar *) key), depth);
|
2015-06-16 11:25:32 +00:00
|
|
|
|
2013-03-30 17:54:50 +00:00
|
|
|
g_object_get (source, "mode", &mode, NULL);
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped (" mode='%d'", mode),
|
|
|
|
depth);
|
|
|
|
append_escaped (str, g_markup_printf_escaped (" track_id='%d'", index),
|
|
|
|
depth);
|
|
|
|
append_escaped (str, g_markup_printf_escaped (" values ='"), depth);
|
2013-03-30 17:54:50 +00:00
|
|
|
timed_values =
|
|
|
|
gst_timed_value_control_source_get_all
|
|
|
|
(GST_TIMED_VALUE_CONTROL_SOURCE (source));
|
|
|
|
for (tmp = timed_values; tmp; tmp = tmp->next) {
|
2013-09-01 23:19:30 +00:00
|
|
|
gchar strbuf[G_ASCII_DTOSTR_BUF_SIZE];
|
2013-03-30 17:54:50 +00:00
|
|
|
GstTimedValue *value;
|
|
|
|
|
|
|
|
value = (GstTimedValue *) tmp->data;
|
2013-04-22 00:29:29 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped (" %" G_GUINT64_FORMAT
|
2013-09-01 23:19:30 +00:00
|
|
|
":%s ", value->timestamp, g_ascii_dtostr (strbuf,
|
2019-07-08 00:55:53 +00:00
|
|
|
G_ASCII_DTOSTR_BUF_SIZE, value->value)), depth);
|
2013-03-30 17:54:50 +00:00
|
|
|
}
|
2019-07-12 20:15:35 +00:00
|
|
|
g_list_free (timed_values);
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("'/>\n"), depth);
|
2013-03-30 17:54:50 +00:00
|
|
|
} else
|
|
|
|
GST_DEBUG ("control source not in [interpolation]");
|
2020-05-20 20:20:10 +00:00
|
|
|
|
|
|
|
gst_object_unref (source);
|
2013-03-30 17:54:50 +00:00
|
|
|
} else
|
2015-06-16 11:25:32 +00:00
|
|
|
GST_DEBUG ("Binding type not in [direct, direct-absolute]");
|
2013-03-30 17:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
static inline void
|
2013-01-26 15:31:33 +00:00
|
|
|
_save_effect (GString * str, guint clip_id, GESTrackElement * trackelement,
|
2019-07-08 00:55:53 +00:00
|
|
|
GESTimeline * timeline, guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
|
|
|
GESTrack *tck;
|
|
|
|
GList *tmp, *tracks;
|
|
|
|
gchar *properties, *metas;
|
2013-09-13 23:35:55 +00:00
|
|
|
guint track_id = 0;
|
2014-11-10 15:20:29 +00:00
|
|
|
gboolean serialize;
|
2015-10-01 09:28:38 +00:00
|
|
|
gchar *extractable_id;
|
2014-11-10 15:20:29 +00:00
|
|
|
|
|
|
|
g_object_get (trackelement, "serialize", &serialize, NULL);
|
|
|
|
if (!serialize) {
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (trackelement, "Should not be serialized");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
tck = ges_track_element_get_track (trackelement);
|
2012-11-19 16:24:03 +00:00
|
|
|
if (tck == NULL) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_WARNING_OBJECT (trackelement, " Not in any track, can not save it");
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tracks = ges_timeline_get_tracks (timeline);
|
|
|
|
for (tmp = tracks; tmp; tmp = tmp->next) {
|
|
|
|
if (tmp->data == tck)
|
|
|
|
break;
|
|
|
|
track_id++;
|
|
|
|
}
|
|
|
|
g_list_free_full (tracks, gst_object_unref);
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (G_OBJECT (trackelement), NULL, "start",
|
2020-05-21 21:22:18 +00:00
|
|
|
"duration", "locked", "name", "priority", NULL);
|
2013-01-26 15:31:33 +00:00
|
|
|
metas =
|
|
|
|
ges_meta_container_metas_to_string (GES_META_CONTAINER (trackelement));
|
2015-10-01 09:28:38 +00:00
|
|
|
extractable_id = ges_extractable_get_id (GES_EXTRACTABLE (trackelement));
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
2013-07-08 02:40:55 +00:00
|
|
|
g_markup_printf_escaped (" <effect asset-id='%s' clip-id='%u'"
|
2013-04-22 00:11:52 +00:00
|
|
|
" type-name='%s' track-type='%i' track-id='%i' properties='%s' metadatas='%s'",
|
2015-10-01 09:28:38 +00:00
|
|
|
extractable_id, clip_id,
|
2013-04-22 00:11:52 +00:00
|
|
|
g_type_name (G_OBJECT_TYPE (trackelement)), tck->type, track_id,
|
2019-07-08 00:55:53 +00:00
|
|
|
properties, metas), depth);
|
2015-10-01 09:28:38 +00:00
|
|
|
g_free (extractable_id);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_free (properties);
|
|
|
|
g_free (metas);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_children_properties (str, GES_TIMELINE_ELEMENT (trackelement), depth);
|
|
|
|
append_escaped (str, g_markup_printf_escaped (">\n"), depth);
|
2013-03-30 17:54:50 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_keyframes (str, trackelement, -1, depth);
|
2013-03-30 17:54:50 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped (" </effect>\n"),
|
|
|
|
depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
static inline void
|
|
|
|
_save_layer_track_activness (GESXmlFormatter * self, GESLayer * layer,
|
|
|
|
GString * str, GESTimeline * timeline, guint depth)
|
|
|
|
{
|
|
|
|
guint nb_tracks = 0, i;
|
|
|
|
GList *tmp, *tracks = ges_timeline_get_tracks (timeline);
|
|
|
|
GArray *deactivated_tracks = g_array_new (TRUE, FALSE, sizeof (gint32));
|
|
|
|
|
|
|
|
for (tmp = tracks; tmp; tmp = tmp->next, nb_tracks++) {
|
|
|
|
if (!ges_layer_get_active_for_track (layer, tmp->data))
|
|
|
|
g_array_append_val (deactivated_tracks, nb_tracks);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!deactivated_tracks->len) {
|
|
|
|
g_string_append (str, ">\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 7);
|
|
|
|
g_string_append (str, " deactivated-tracks='");
|
|
|
|
for (i = 0; i < deactivated_tracks->len; i++)
|
|
|
|
g_string_append_printf (str, "%d ", g_array_index (deactivated_tracks, gint,
|
|
|
|
i));
|
|
|
|
g_string_append (str, "'>\n");
|
|
|
|
|
|
|
|
done:
|
|
|
|
g_array_free (deactivated_tracks, TRUE);
|
|
|
|
g_list_free_full (tracks, gst_object_unref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_save_source (GESXmlFormatter * self, GString * str,
|
|
|
|
GESTimelineElement * element, GESTimeline * timeline, GList * tracks,
|
|
|
|
guint depth)
|
|
|
|
{
|
|
|
|
gint index, n_props;
|
|
|
|
gboolean serialize;
|
2021-07-09 14:15:01 +00:00
|
|
|
gchar *properties, *metas;
|
2020-03-06 21:56:52 +00:00
|
|
|
|
|
|
|
if (!GES_IS_SOURCE (element))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_object_get (element, "serialize", &serialize, NULL);
|
|
|
|
if (!serialize) {
|
|
|
|
GST_DEBUG_OBJECT (element, "Should not be serialized");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
index =
|
|
|
|
g_list_index (tracks,
|
|
|
|
ges_track_element_get_track (GES_TRACK_ELEMENT (element)));
|
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
|
|
|
(" <source track-id='%i' ", index), depth);
|
|
|
|
|
|
|
|
properties = _serialize_properties (G_OBJECT (element), &n_props,
|
|
|
|
"in-point", "priority", "start", "duration", "track", "track-type"
|
|
|
|
"uri", "name", "max-duration", NULL);
|
|
|
|
|
|
|
|
/* Try as possible to allow older versions of GES to load the files */
|
|
|
|
if (n_props) {
|
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 7);
|
|
|
|
g_string_append_printf (str, "properties='%s' ", properties);
|
|
|
|
}
|
|
|
|
g_free (properties);
|
|
|
|
|
2021-07-09 14:15:01 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (element));
|
|
|
|
g_string_append_printf (str, "metadatas='%s' ", metas);
|
|
|
|
g_free (metas);
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
_save_children_properties (str, element, depth);
|
|
|
|
append_escaped (str, g_markup_printf_escaped (">\n"), depth);
|
|
|
|
_save_keyframes (str, GES_TRACK_ELEMENT (element), index, depth);
|
|
|
|
append_escaped (str, g_markup_printf_escaped (" </source>\n"),
|
|
|
|
depth);
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
static inline void
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_layers (GESXmlFormatter * self, GString * str, GESTimeline * timeline,
|
|
|
|
guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
|
|
|
gchar *properties, *metas;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *clip;
|
|
|
|
GList *tmplayer, *tmpclip, *clips;
|
2014-10-27 15:51:42 +00:00
|
|
|
GESXmlFormatterPrivate *priv = self->priv;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
for (tmplayer = timeline->layers; tmplayer; tmplayer = tmplayer->next) {
|
|
|
|
guint priority;
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = GES_LAYER (tmplayer->data);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
priority = ges_layer_get_priority (layer);
|
2020-03-06 21:56:52 +00:00
|
|
|
properties =
|
|
|
|
_serialize_properties (G_OBJECT (layer), NULL, "priority", NULL);
|
2012-11-19 16:24:03 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (layer));
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
2020-03-06 21:56:52 +00:00
|
|
|
(" <layer priority='%i' properties='%s' metadatas='%s'",
|
2019-07-08 00:55:53 +00:00
|
|
|
priority, properties, metas), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_free (properties);
|
|
|
|
g_free (metas);
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
_save_layer_track_activness (self, layer, str, timeline, depth);
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
clips = ges_layer_get_clips (layer);
|
2013-01-20 15:42:29 +00:00
|
|
|
for (tmpclip = clips; tmpclip; tmpclip = tmpclip->next) {
|
2012-11-19 16:24:03 +00:00
|
|
|
GList *effects, *tmpeffect;
|
2013-07-08 22:31:30 +00:00
|
|
|
GList *tmptrackelement;
|
|
|
|
GList *tracks;
|
2014-11-10 15:20:29 +00:00
|
|
|
gboolean serialize;
|
2015-10-01 09:28:38 +00:00
|
|
|
gchar *extractable_id;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
clip = GES_CLIP (tmpclip->data);
|
2014-11-10 15:20:29 +00:00
|
|
|
|
|
|
|
g_object_get (clip, "serialize", &serialize, NULL);
|
|
|
|
if (!serialize) {
|
|
|
|
GST_DEBUG_OBJECT (clip, "Should not be serialized");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
/* We escape all mandatrorry properties that are handled sparetely
|
|
|
|
* and vtype for StandarTransition as it is the asset ID */
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (G_OBJECT (clip), NULL,
|
2012-11-19 16:24:03 +00:00
|
|
|
"supported-formats", "rate", "in-point", "start", "duration",
|
|
|
|
"max-duration", "priority", "vtype", "uri", NULL);
|
2015-10-01 09:28:38 +00:00
|
|
|
extractable_id = ges_extractable_get_id (GES_EXTRACTABLE (clip));
|
2019-07-08 00:55:53 +00:00
|
|
|
if (GES_IS_URI_CLIP (clip)) {
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
if (g_hash_table_contains (priv->subprojects_map, extractable_id))
|
|
|
|
extractable_id =
|
|
|
|
g_strdup (g_hash_table_lookup (priv->subprojects_map,
|
|
|
|
extractable_id));
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
}
|
2019-01-15 12:59:59 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (clip));
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
2013-07-08 02:40:55 +00:00
|
|
|
g_markup_printf_escaped (" <clip id='%i' asset-id='%s'"
|
2013-04-22 00:11:52 +00:00
|
|
|
" type-name='%s' layer-priority='%i' track-types='%i' start='%"
|
|
|
|
G_GUINT64_FORMAT "' duration='%" G_GUINT64_FORMAT "' inpoint='%"
|
2019-01-15 12:59:59 +00:00
|
|
|
G_GUINT64_FORMAT "' rate='%d' properties='%s' metadatas='%s'",
|
2015-10-01 09:28:38 +00:00
|
|
|
priv->nbelements, extractable_id,
|
2013-04-22 00:11:52 +00:00
|
|
|
g_type_name (G_OBJECT_TYPE (clip)), priority,
|
|
|
|
ges_clip_get_supported_formats (clip), _START (clip),
|
2019-07-08 00:55:53 +00:00
|
|
|
_DURATION (clip), _INPOINT (clip), 0, properties, metas), depth);
|
2019-04-09 12:56:08 +00:00
|
|
|
g_free (metas);
|
2018-07-28 16:16:36 +00:00
|
|
|
|
2018-07-29 20:20:50 +00:00
|
|
|
if (GES_IS_TRANSITION_CLIP (clip)) {
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_children_properties (str, GES_TIMELINE_ELEMENT (clip), depth);
|
2018-07-29 20:20:50 +00:00
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 4);
|
|
|
|
}
|
2018-07-28 16:16:36 +00:00
|
|
|
g_string_append (str, ">\n");
|
|
|
|
|
2015-10-01 09:28:38 +00:00
|
|
|
g_free (extractable_id);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_free (properties);
|
|
|
|
|
2014-10-27 15:51:42 +00:00
|
|
|
g_hash_table_insert (self->priv->element_id, clip,
|
|
|
|
GINT_TO_POINTER (priv->nbelements));
|
|
|
|
|
2018-07-28 16:16:36 +00:00
|
|
|
|
2015-11-04 19:20:10 +00:00
|
|
|
/* Effects must always be serialized in the right priority order.
|
|
|
|
* List order is guaranteed by the fact that ges_clip_get_top_effects
|
|
|
|
* sorts the effects. */
|
|
|
|
effects = ges_clip_get_top_effects (clip);
|
|
|
|
for (tmpeffect = effects; tmpeffect; tmpeffect = tmpeffect->next) {
|
2014-10-27 15:51:42 +00:00
|
|
|
_save_effect (str, priv->nbelements,
|
2019-07-08 00:55:53 +00:00
|
|
|
GES_TRACK_ELEMENT (tmpeffect->data), timeline, depth);
|
2015-11-04 19:20:10 +00:00
|
|
|
}
|
2019-04-09 12:56:08 +00:00
|
|
|
g_list_free (effects);
|
2013-07-08 22:31:30 +00:00
|
|
|
tracks = ges_timeline_get_tracks (timeline);
|
|
|
|
|
|
|
|
for (tmptrackelement = GES_CONTAINER_CHILDREN (clip); tmptrackelement;
|
|
|
|
tmptrackelement = tmptrackelement->next) {
|
2020-03-06 21:56:52 +00:00
|
|
|
_save_source (self, str, tmptrackelement->data, timeline, tracks,
|
2019-07-08 00:55:53 +00:00
|
|
|
depth);
|
2013-07-08 22:31:30 +00:00
|
|
|
}
|
|
|
|
g_list_free_full (tracks, gst_object_unref);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " </clip>\n", depth);
|
2013-07-08 02:40:55 +00:00
|
|
|
|
2014-10-27 15:51:42 +00:00
|
|
|
priv->nbelements++;
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
2017-11-27 10:49:04 +00:00
|
|
|
g_list_free_full (clips, (GDestroyNotify) gst_object_unref);
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " </layer>\n", depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-27 15:51:42 +00:00
|
|
|
static void
|
|
|
|
_save_group (GESXmlFormatter * self, GString * str, GList ** seen_groups,
|
2019-07-08 00:55:53 +00:00
|
|
|
GESGroup * group, guint depth)
|
2014-10-27 15:51:42 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
2014-11-10 15:20:29 +00:00
|
|
|
gboolean serialize;
|
2019-01-15 12:38:14 +00:00
|
|
|
gchar *properties, *metadatas;
|
2014-10-27 15:51:42 +00:00
|
|
|
|
2014-11-10 15:20:29 +00:00
|
|
|
g_object_get (group, "serialize", &serialize, NULL);
|
|
|
|
if (!serialize) {
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (group, "Should not be serialized");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-27 15:51:42 +00:00
|
|
|
if (g_list_find (*seen_groups, group)) {
|
|
|
|
GST_DEBUG_OBJECT (group, "Already serialized");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*seen_groups = g_list_prepend (*seen_groups, group);
|
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (group); tmp; tmp = tmp->next) {
|
|
|
|
if (GES_IS_GROUP (tmp->data)) {
|
|
|
|
_save_group (self, str, seen_groups,
|
2019-07-08 00:55:53 +00:00
|
|
|
GES_GROUP (GES_TIMELINE_ELEMENT (tmp->data)), depth);
|
2014-10-27 15:51:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (G_OBJECT (group), NULL, NULL);
|
2019-01-15 12:38:14 +00:00
|
|
|
|
|
|
|
metadatas = ges_meta_container_metas_to_string (GES_META_CONTAINER (group));
|
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 5);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
string_add_indents (str, depth, FALSE);
|
2019-01-15 12:38:14 +00:00
|
|
|
g_string_append_printf (str,
|
|
|
|
" <group id='%d' properties='%s' metadatas='%s'>\n",
|
|
|
|
self->priv->nbelements, properties, metadatas);
|
2014-10-27 15:51:42 +00:00
|
|
|
g_free (properties);
|
2019-01-15 12:38:14 +00:00
|
|
|
g_free (metadatas);
|
2014-10-27 15:51:42 +00:00
|
|
|
g_hash_table_insert (self->priv->element_id, group,
|
|
|
|
GINT_TO_POINTER (self->priv->nbelements));
|
|
|
|
self->priv->nbelements++;
|
|
|
|
|
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (group); tmp; tmp = tmp->next) {
|
|
|
|
gint id = GPOINTER_TO_INT (g_hash_table_lookup (self->priv->element_id,
|
|
|
|
tmp->data));
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
string_add_indents (str, depth, FALSE);
|
2014-10-27 15:51:42 +00:00
|
|
|
g_string_append_printf (str, " <child id='%d' name='%s'/>\n", id,
|
|
|
|
GES_TIMELINE_ELEMENT_NAME (tmp->data));
|
|
|
|
}
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " </group>\n", depth);
|
2014-10-27 15:51:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_groups (GESXmlFormatter * self, GString * str, GESTimeline * timeline,
|
|
|
|
guint depth)
|
2014-10-27 15:51:42 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GList *seen_groups = NULL;
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " <groups>\n", depth);
|
2016-09-06 12:27:38 +00:00
|
|
|
for (tmp = ges_timeline_get_groups (timeline); tmp; tmp = tmp->next) {
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_group (self, str, &seen_groups, tmp->data, depth);
|
2014-10-27 15:51:42 +00:00
|
|
|
}
|
2017-11-27 10:49:04 +00:00
|
|
|
g_list_free (seen_groups);
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " </groups>\n", depth);
|
2014-10-27 15:51:42 +00:00
|
|
|
}
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
static inline void
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_timeline (GESXmlFormatter * self, GString * str, GESTimeline * timeline,
|
|
|
|
guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
|
|
|
gchar *properties = NULL, *metas = NULL;
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
properties =
|
|
|
|
_serialize_properties (G_OBJECT (timeline), NULL, "update", "name",
|
2012-11-19 16:24:03 +00:00
|
|
|
"async-handling", "message-forward", NULL);
|
|
|
|
|
2013-09-13 23:37:58 +00:00
|
|
|
ges_meta_container_set_uint64 (GES_META_CONTAINER (timeline), "duration",
|
|
|
|
ges_timeline_get_duration (timeline));
|
2012-11-19 16:24:03 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (timeline));
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
2013-07-08 02:40:55 +00:00
|
|
|
g_markup_printf_escaped
|
2019-07-08 00:55:53 +00:00
|
|
|
(" <timeline properties='%s' metadatas='%s'>\n", properties, metas),
|
|
|
|
depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_tracks (self, str, timeline, depth);
|
|
|
|
_save_layers (self, str, timeline, depth);
|
|
|
|
_save_groups (self, str, timeline, depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " </timeline>\n", depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
g_free (properties);
|
|
|
|
g_free (metas);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-05-18 19:24:25 +00:00
|
|
|
_save_stream_profiles (GESXmlFormatter * self, GString * str,
|
2019-07-08 00:55:53 +00:00
|
|
|
GstEncodingProfile * sprof, const gchar * profilename, guint id,
|
|
|
|
guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
|
|
|
gchar *tmpc;
|
|
|
|
GstCaps *tmpcaps;
|
2021-01-15 11:47:10 +00:00
|
|
|
GstStructure *properties;
|
2012-11-19 16:24:03 +00:00
|
|
|
const gchar *preset, *preset_name, *name, *description;
|
|
|
|
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
2013-07-08 02:40:55 +00:00
|
|
|
g_markup_printf_escaped
|
|
|
|
(" <stream-profile parent='%s' id='%d' type='%s' "
|
2015-05-18 19:24:25 +00:00
|
|
|
"presence='%d' ", profilename, id,
|
2013-04-22 00:11:52 +00:00
|
|
|
gst_encoding_profile_get_type_nick (sprof),
|
2019-07-08 00:55:53 +00:00
|
|
|
gst_encoding_profile_get_presence (sprof)), depth);
|
2015-05-18 19:24:25 +00:00
|
|
|
|
|
|
|
if (!gst_encoding_profile_is_enabled (sprof)) {
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_strdup ("enabled='0' "), depth);
|
2015-05-18 19:24:25 +00:00
|
|
|
|
|
|
|
self->priv->min_version = MAX (self->priv->min_version, 2);
|
|
|
|
}
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
tmpcaps = gst_encoding_profile_get_format (sprof);
|
|
|
|
if (tmpcaps) {
|
|
|
|
tmpc = gst_caps_to_string (tmpcaps);
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("format='%s' ", tmpc), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
gst_caps_unref (tmpcaps);
|
|
|
|
g_free (tmpc);
|
|
|
|
}
|
|
|
|
|
|
|
|
name = gst_encoding_profile_get_name (sprof);
|
|
|
|
if (name)
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("name='%s' ", name), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
description = gst_encoding_profile_get_description (sprof);
|
|
|
|
if (description)
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("description='%s' ",
|
2019-07-08 00:55:53 +00:00
|
|
|
description), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
preset = gst_encoding_profile_get_preset (sprof);
|
2017-08-22 14:23:45 +00:00
|
|
|
if (preset) {
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("preset='%s' ", preset),
|
|
|
|
depth);
|
2021-01-15 11:47:10 +00:00
|
|
|
}
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2021-01-15 11:47:10 +00:00
|
|
|
properties = gst_encoding_profile_get_element_properties (sprof);
|
|
|
|
if (properties) {
|
|
|
|
gchar *props_str = gst_structure_to_string (properties);
|
|
|
|
|
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped ("preset-properties='%s' ", props_str), depth);
|
|
|
|
g_free (props_str);
|
|
|
|
gst_structure_free (properties);
|
2017-08-22 14:23:45 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
preset_name = gst_encoding_profile_get_preset_name (sprof);
|
|
|
|
if (preset_name)
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("preset-name='%s' ",
|
2019-07-08 00:55:53 +00:00
|
|
|
preset_name), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
tmpcaps = gst_encoding_profile_get_restriction (sprof);
|
|
|
|
if (tmpcaps) {
|
|
|
|
tmpc = gst_caps_to_string (tmpcaps);
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("restriction='%s' ", tmpc),
|
|
|
|
depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
gst_caps_unref (tmpcaps);
|
|
|
|
g_free (tmpc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_IS_ENCODING_VIDEO_PROFILE (sprof)) {
|
|
|
|
GstEncodingVideoProfile *vp = (GstEncodingVideoProfile *) sprof;
|
|
|
|
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped ("pass='%d' variableframerate='%i' ",
|
|
|
|
gst_encoding_video_profile_get_pass (vp),
|
2019-07-08 00:55:53 +00:00
|
|
|
gst_encoding_video_profile_get_variableframerate (vp)), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_string_append (str, "/>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2015-05-18 19:24:25 +00:00
|
|
|
_save_encoding_profiles (GESXmlFormatter * self, GString * str,
|
2019-07-08 00:55:53 +00:00
|
|
|
GESProject * project, guint depth)
|
2012-11-19 16:24:03 +00:00
|
|
|
{
|
|
|
|
GstCaps *profformat;
|
2021-01-15 11:47:10 +00:00
|
|
|
GstStructure *properties;
|
2012-11-19 16:24:03 +00:00
|
|
|
const gchar *profname, *profdesc, *profpreset, *proftype, *profpresetname;
|
|
|
|
|
|
|
|
const GList *tmp;
|
2017-07-21 20:41:26 +00:00
|
|
|
GList *profiles = g_list_reverse (g_list_copy ((GList *)
|
|
|
|
ges_project_list_encoding_profiles (project)));
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2017-07-21 20:41:26 +00:00
|
|
|
for (tmp = profiles; tmp; tmp = tmp->next) {
|
2012-11-19 16:24:03 +00:00
|
|
|
GstEncodingProfile *prof = GST_ENCODING_PROFILE (tmp->data);
|
|
|
|
|
|
|
|
profname = gst_encoding_profile_get_name (prof);
|
|
|
|
profdesc = gst_encoding_profile_get_description (prof);
|
|
|
|
profpreset = gst_encoding_profile_get_preset (prof);
|
|
|
|
profpresetname = gst_encoding_profile_get_preset_name (prof);
|
|
|
|
proftype = gst_encoding_profile_get_type_nick (prof);
|
|
|
|
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped
|
2013-07-08 02:40:55 +00:00
|
|
|
(" <encoding-profile name='%s' description='%s' type='%s' ",
|
2019-07-08 00:55:53 +00:00
|
|
|
profname, profdesc, proftype), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2017-08-22 14:23:45 +00:00
|
|
|
if (profpreset) {
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("preset='%s' ",
|
2019-07-08 00:55:53 +00:00
|
|
|
profpreset), depth);
|
2021-01-15 11:47:10 +00:00
|
|
|
}
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2021-01-15 11:47:10 +00:00
|
|
|
properties = gst_encoding_profile_get_element_properties (prof);
|
|
|
|
if (properties) {
|
|
|
|
gchar *props_str = gst_structure_to_string (properties);
|
2017-08-22 14:23:45 +00:00
|
|
|
|
2021-01-15 11:47:10 +00:00
|
|
|
append_escaped (str,
|
|
|
|
g_markup_printf_escaped ("preset-properties='%s' ", props_str),
|
|
|
|
depth);
|
|
|
|
g_free (props_str);
|
|
|
|
gst_structure_free (properties);
|
2017-08-22 14:23:45 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
if (profpresetname)
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("preset-name='%s' ",
|
2019-07-08 00:55:53 +00:00
|
|
|
profpresetname), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
profformat = gst_encoding_profile_get_format (prof);
|
|
|
|
if (profformat) {
|
|
|
|
gchar *format = gst_caps_to_string (profformat);
|
2019-07-08 00:55:53 +00:00
|
|
|
append_escaped (str, g_markup_printf_escaped ("format='%s' ", format),
|
|
|
|
depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_free (format);
|
|
|
|
gst_caps_unref (profformat);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_string_append (str, ">\n");
|
|
|
|
|
|
|
|
if (GST_IS_ENCODING_CONTAINER_PROFILE (prof)) {
|
|
|
|
guint i = 0;
|
|
|
|
const GList *tmp2;
|
|
|
|
GstEncodingContainerProfile *container_prof;
|
|
|
|
|
|
|
|
container_prof = GST_ENCODING_CONTAINER_PROFILE (prof);
|
|
|
|
for (tmp2 = gst_encoding_container_profile_get_profiles (container_prof);
|
|
|
|
tmp2; tmp2 = tmp2->next, i++) {
|
|
|
|
GstEncodingProfile *sprof = (GstEncodingProfile *) tmp2->data;
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_stream_profiles (self, str, sprof, profname, i, depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-08 02:40:55 +00:00
|
|
|
append_escaped (str,
|
2019-07-08 00:55:53 +00:00
|
|
|
g_markup_printf_escaped (" </encoding-profile>\n"), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
2017-07-21 20:41:26 +00:00
|
|
|
g_list_free (profiles);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GString *
|
|
|
|
_save (GESFormatter * formatter, GESTimeline * timeline, GError ** error)
|
|
|
|
{
|
|
|
|
GString *str;
|
|
|
|
GESProject *project;
|
2019-07-08 00:55:53 +00:00
|
|
|
GESXmlFormatterPrivate *priv = _GET_PRIV (formatter);
|
2015-05-18 19:24:25 +00:00
|
|
|
|
|
|
|
priv->min_version = 1;
|
2012-11-19 16:24:03 +00:00
|
|
|
project = formatter->project;
|
|
|
|
str = priv->str = g_string_new (NULL);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
return _save_project (formatter, str, project, timeline, error, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GString *
|
|
|
|
_save_project (GESFormatter * formatter, GString * str, GESProject * project,
|
|
|
|
GESTimeline * timeline, GError ** error, guint depth)
|
|
|
|
{
|
|
|
|
gchar *projstr = NULL, *version;
|
|
|
|
gchar *properties = NULL, *metas = NULL;
|
|
|
|
GESXmlFormatter *self = GES_XML_FORMATTER (formatter);
|
|
|
|
GESXmlFormatterPrivate *priv = _GET_PRIV (formatter);
|
|
|
|
|
2020-03-06 21:56:52 +00:00
|
|
|
properties = _serialize_properties (G_OBJECT (project), NULL, NULL);
|
2012-11-19 16:24:03 +00:00
|
|
|
metas = ges_meta_container_metas_to_string (GES_META_CONTAINER (project));
|
2013-04-22 00:11:52 +00:00
|
|
|
append_escaped (str,
|
2013-07-08 02:40:55 +00:00
|
|
|
g_markup_printf_escaped (" <project properties='%s' metadatas='%s'>\n",
|
2019-07-08 00:55:53 +00:00
|
|
|
properties, metas), depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
g_free (properties);
|
|
|
|
g_free (metas);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " <encoding-profiles>\n", depth);
|
|
|
|
_save_encoding_profiles (GES_XML_FORMATTER (formatter), str, project, depth);
|
|
|
|
string_append_with_depth (str, " </encoding-profiles>\n", depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
string_append_with_depth (str, " <ressources>\n", depth);
|
|
|
|
if (!_save_assets (self, str, project, error, depth)) {
|
|
|
|
g_string_free (str, TRUE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
string_append_with_depth (str, " </ressources>\n", depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
_save_timeline (self, str, timeline, depth);
|
|
|
|
string_append_with_depth (str, " </project>\n", depth);
|
|
|
|
string_append_with_depth (str, "</ges>\n", depth);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
2015-05-18 19:24:25 +00:00
|
|
|
projstr = g_strdup_printf ("<ges version='%i.%i'>\n", API_VERSION,
|
|
|
|
priv->min_version);
|
|
|
|
g_string_prepend (str, projstr);
|
2019-07-08 00:55:53 +00:00
|
|
|
string_add_indents (str, depth, TRUE);
|
2015-05-18 19:24:25 +00:00
|
|
|
g_free (projstr);
|
|
|
|
|
|
|
|
ges_meta_container_set_int (GES_META_CONTAINER (project),
|
|
|
|
GES_META_FORMAT_VERSION, priv->min_version);
|
|
|
|
|
|
|
|
version = g_strdup_printf ("%d.%d", API_VERSION,
|
|
|
|
GES_XML_FORMATTER (formatter)->priv->min_version);
|
|
|
|
|
|
|
|
ges_meta_container_set_string (GES_META_CONTAINER (project),
|
|
|
|
GES_META_FORMAT_VERSION, version);
|
|
|
|
|
|
|
|
g_free (version);
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
priv->str = NULL;
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
static void
|
|
|
|
_setup_subprojects_map (GESXmlFormatterPrivate * priv, const gchar * uri)
|
|
|
|
{
|
|
|
|
GHashTable *subprojects_map;
|
|
|
|
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
if (!uri_subprojects_map)
|
|
|
|
uri_subprojects_map =
|
|
|
|
g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
|
|
|
(GDestroyNotify) g_hash_table_unref);
|
|
|
|
|
|
|
|
subprojects_map = g_hash_table_lookup (uri_subprojects_map, uri);
|
|
|
|
if (!subprojects_map) {
|
|
|
|
subprojects_map =
|
|
|
|
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
|
|
|
g_hash_table_insert (uri_subprojects_map, g_strdup (uri), subprojects_map);
|
|
|
|
}
|
|
|
|
priv->subprojects_map = subprojects_map;
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ges_xml_formatter_deinit (void)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("Deinit");
|
|
|
|
G_LOCK (uri_subprojects_map_lock);
|
|
|
|
if (uri_subprojects_map) {
|
|
|
|
g_hash_table_unref (uri_subprojects_map);
|
|
|
|
uri_subprojects_map = NULL;
|
|
|
|
}
|
|
|
|
G_UNLOCK (uri_subprojects_map_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_save_to_uri (GESFormatter * formatter, GESTimeline * timeline,
|
|
|
|
const gchar * uri, gboolean overwrite, GError ** error)
|
|
|
|
{
|
|
|
|
_setup_subprojects_map (_GET_PRIV (formatter), uri);
|
|
|
|
return GES_FORMATTER_CLASS (parent_class)->save_to_uri (formatter, timeline,
|
|
|
|
uri, overwrite, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_can_load_uri (GESFormatter * formatter, const gchar * uri, GError ** error)
|
|
|
|
{
|
|
|
|
_setup_subprojects_map (_GET_PRIV (formatter), uri);
|
|
|
|
return GES_FORMATTER_CLASS (parent_class)->can_load_uri (formatter, uri,
|
|
|
|
error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_load_from_uri (GESFormatter * formatter, GESTimeline * timeline,
|
|
|
|
const gchar * uri, GError ** error)
|
|
|
|
{
|
|
|
|
_setup_subprojects_map (_GET_PRIV (formatter), uri);
|
|
|
|
return GES_FORMATTER_CLASS (parent_class)->load_from_uri (formatter, timeline,
|
|
|
|
uri, error);
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
/***********************************************
|
|
|
|
* *
|
|
|
|
* GObject virtual methods implementation *
|
|
|
|
* *
|
|
|
|
***********************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
_get_property (GObject * object, guint property_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_xml_formatter_init (GESXmlFormatter * self)
|
|
|
|
{
|
2018-09-06 01:55:02 +00:00
|
|
|
GESXmlFormatterPrivate *priv = ges_xml_formatter_get_instance_private (self);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
priv->project_opened = FALSE;
|
2014-10-27 15:51:42 +00:00
|
|
|
priv->element_id = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
|
|
|
self->priv = priv;
|
2015-05-18 19:24:25 +00:00
|
|
|
self->priv->min_version = 1;
|
2014-10-27 15:51:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
g_clear_pointer (&GES_XML_FORMATTER (object)->priv->element_id,
|
2018-10-22 07:13:07 +00:00
|
|
|
g_hash_table_unref);
|
2015-10-01 14:26:05 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2012-11-19 16:24:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_xml_formatter_class_init (GESXmlFormatterClass * self_class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (self_class);
|
|
|
|
GESBaseXmlFormatterClass *basexmlformatter_class;
|
2019-07-08 00:55:53 +00:00
|
|
|
GESFormatterClass *formatter_klass = GES_FORMATTER_CLASS (self_class);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
basexmlformatter_class = GES_BASE_XML_FORMATTER_CLASS (self_class);
|
|
|
|
|
2019-07-08 00:55:53 +00:00
|
|
|
formatter_klass->save_to_uri = _save_to_uri;
|
|
|
|
formatter_klass->can_load_uri = _can_load_uri;
|
|
|
|
formatter_klass->load_from_uri = _load_from_uri;
|
|
|
|
|
2012-11-19 16:24:03 +00:00
|
|
|
object_class->get_property = _get_property;
|
|
|
|
object_class->set_property = _set_property;
|
2014-10-27 15:51:42 +00:00
|
|
|
object_class->dispose = _dispose;
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
basexmlformatter_class->content_parser.start_element = _parse_element_start;
|
|
|
|
basexmlformatter_class->content_parser.end_element = _parse_element_end;
|
|
|
|
basexmlformatter_class->content_parser.text = NULL;
|
|
|
|
basexmlformatter_class->content_parser.passthrough = NULL;
|
|
|
|
basexmlformatter_class->content_parser.error = _error_parsing;
|
|
|
|
|
|
|
|
ges_formatter_class_register_metas (GES_FORMATTER_CLASS (self_class),
|
2012-12-28 22:10:17 +00:00
|
|
|
"ges", "GStreamer Editing Services project files",
|
2019-07-05 13:40:57 +00:00
|
|
|
"xges", "application/xges", VERSION, GST_RANK_PRIMARY);
|
2012-11-19 16:24:03 +00:00
|
|
|
|
|
|
|
basexmlformatter_class->save = _save;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef COLLECT_STR_OPT
|