From 29f25c6c43178bdba6e8c86fa61a862f8d42a201 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Mon, 23 Sep 2019 16:07:58 -0300 Subject: [PATCH] launch: Add an option to embed nested timelines when saving --- ges/ges-command-line-formatter.c | 12 +++++++++++- ges/ges-structured-interface.c | 3 ++- tools/ges-launcher.c | 28 +++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/ges/ges-command-line-formatter.c b/ges/ges-command-line-formatter.c index afca778..70df258 100644 --- a/ges/ges-command-line-formatter.c +++ b/ges/ges-command-line-formatter.c @@ -312,12 +312,22 @@ static gboolean _ges_command_line_formatter_add_clip (GESTimeline * timeline, GstStructure * structure, GError ** error) { + GESProject *proj; + GESAsset *asset; if (!_cleanup_fields (options[CLIP].properties, structure, error)) return FALSE; gst_structure_set (structure, "type", G_TYPE_STRING, "GESUriClip", NULL); - return _ges_add_clip_from_struct (timeline, structure, error); + if (!_ges_add_clip_from_struct (timeline, structure, error)) + return FALSE; + + proj = GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (timeline))); + asset = _ges_get_asset_from_timeline (timeline, GES_TYPE_URI_CLIP, + gst_structure_get_string (structure, "asset-id"), NULL); + ges_project_add_asset (proj, asset); + + return TRUE; } static gboolean diff --git a/ges/ges-structured-interface.c b/ges/ges-structured-interface.c index b359774..23d8dc9 100644 --- a/ges/ges-structured-interface.c +++ b/ges/ges-structured-interface.c @@ -428,6 +428,7 @@ _ges_add_clip_from_struct (GESTimeline * timeline, GstStructure * structure, asset_id = g_strdup (check_asset_id); } + gst_structure_set (structure, "asset-id", G_TYPE_STRING, asset_id, NULL); asset = _ges_get_asset_from_timeline (timeline, type, asset_id, error); if (!asset) { res = FALSE; @@ -585,7 +586,7 @@ _ges_container_add_child_from_struct (GESTimeline * timeline, } if (!child) { - g_error_new (GES_ERROR, 0, "Wong parametters, could not get a child"); + g_error_new (GES_ERROR, 0, "Wrong parameters, could not get a child"); return FALSE; } diff --git a/tools/ges-launcher.c b/tools/ges-launcher.c index c409f72..c81d2ab 100644 --- a/tools/ges-launcher.c +++ b/tools/ges-launcher.c @@ -53,6 +53,7 @@ typedef struct gchar *sanitized_timeline; const gchar *video_track_caps; const gchar *audio_track_caps; + gboolean embed_nesteds; } ParsedOptions; struct _GESLauncherPrivate @@ -397,7 +398,7 @@ intr_handler (GESLauncher * self) g_print ("interrupt received.\n"); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (self->priv->pipeline), - GST_DEBUG_GRAPH_SHOW_ALL, "ges-launch.interupted"); + GST_DEBUG_GRAPH_SHOW_ALL, "ges-launch.interrupted"); g_application_quit (G_APPLICATION (self)); @@ -411,6 +412,29 @@ _save_timeline (GESLauncher * self) { ParsedOptions *opts = &self->priv->parsed_options; + + if (opts->embed_nesteds) { + GList *tmp, *assets; + GESProject *proj = + GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (self-> + priv->timeline))); + + assets = ges_project_list_assets (proj, GES_TYPE_URI_CLIP); + for (tmp = assets; tmp; tmp = tmp->next) { + gboolean is_nested; + + g_object_get (tmp->data, "is-nested-timeline", &is_nested, NULL); + if (is_nested) { + GESAsset *subproj = + ges_asset_request (GES_TYPE_TIMELINE, ges_asset_get_id (tmp->data), + NULL); + + ges_project_add_asset (proj, subproj); + } + } + g_list_free_full (assets, gst_object_unref); + } + if (opts->save_only_path) { gchar *uri; @@ -750,6 +774,8 @@ _local_command_line (GApplication * application, gchar ** arguments[], "and --inspect-action-type.", ""}, #endif + {"embed-nesteds", 0, 0, G_OPTION_ARG_NONE, &opts->embed_nesteds, + "Embed nested timelines when saving.",}, {NULL} }; -- 2.7.4