diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2021-01-15 15:03:20 -0300 |
---|---|---|
committer | Thibault Saunier <tsaunier@igalia.com> | 2021-02-10 16:14:47 -0300 |
commit | 70e3b8ae2a8d13b50f52305b71cfa4b590bb63f6 (patch) | |
tree | c519e5f9cbf0128841f2ce912cec2720d5fbc5ac /tools | |
parent | 7499d412135bdadeaf1cadadf180e6cc9a46e442 (diff) |
ges: Use a `ges:` uri to define timeline from description
This way the command line formatter actually uses an URI and not
an ugly hack where were passing a random string instead of an URI.
This also allows the `gessrc` element to handle timelines described
in its URI meaning that you can now use, for example:
gst-play-1.0 "ges:+test-clip blue d=4.0
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/227>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/ges-launcher.c | 35 | ||||
-rw-r--r-- | tools/ges-launcher.h | 31 | ||||
-rw-r--r-- | tools/utils.c | 40 | ||||
-rw-r--r-- | tools/utils.h | 33 |
4 files changed, 74 insertions, 65 deletions
diff --git a/tools/ges-launcher.c b/tools/ges-launcher.c index be33bd0e..72dda86c 100644 --- a/tools/ges-launcher.c +++ b/tools/ges-launcher.c @@ -716,7 +716,6 @@ static gboolean _create_timeline (GESLauncher * self, const gchar * serialized_timeline, const gchar * proj_uri, gboolean validate) { - GESLauncherParsedOptions *opts = &self->priv->parsed_options; GESProject *project; GError *error = NULL; @@ -724,37 +723,7 @@ _create_timeline (GESLauncher * self, const gchar * serialized_timeline, if (proj_uri != NULL) { project = ges_project_new (proj_uri); } else if (!validate) { - GString *timeline_str = g_string_new (serialized_timeline); - - if (!strstr (serialized_timeline, "+track")) { - GString *track_def; - - if (opts->track_types & GES_TRACK_TYPE_VIDEO) { - track_def = g_string_new (" +track video "); - - if (opts->video_track_caps) - g_string_append_printf (track_def, " restrictions=[%s] ", - opts->video_track_caps); - - g_string_prepend (timeline_str, track_def->str); - g_string_free (track_def, TRUE); - } - - if (opts->track_types & GES_TRACK_TYPE_AUDIO) { - track_def = g_string_new (" +track audio "); - - if (opts->audio_track_caps) - g_string_append_printf (track_def, " restrictions=[%s] ", - opts->audio_track_caps); - - g_string_prepend (timeline_str, track_def->str); - g_string_free (track_def, TRUE); - } - } - - GST_INFO ("Launching timeline: `%s`", timeline_str->str); - project = ges_project_new (timeline_str->str); - g_string_free (timeline_str, TRUE); + project = ges_project_new (serialized_timeline); } else { project = ges_project_new (NULL); } @@ -1366,7 +1335,7 @@ _local_command_line (GApplication * application, gchar ** arguments[], g_option_context_free (ctx); - opts->sanitized_timeline = sanitize_timeline_description (*arguments); + opts->sanitized_timeline = sanitize_timeline_description (*arguments, opts); if (!g_application_register (application, NULL, &error)) { *exit_status = 1; diff --git a/tools/ges-launcher.h b/tools/ges-launcher.h index 4021b142..108ca844 100644 --- a/tools/ges-launcher.h +++ b/tools/ges-launcher.h @@ -21,6 +21,8 @@ #include <ges/ges.h> +#include "utils.h" + G_BEGIN_DECLS #define GES_TYPE_LAUNCHER ges_launcher_get_type() @@ -28,35 +30,6 @@ G_BEGIN_DECLS typedef struct _GESLauncherPrivate GESLauncherPrivate; G_DECLARE_FINAL_TYPE(GESLauncher, ges_launcher, GES, LAUNCHER, GApplication); -typedef struct -{ - gboolean mute; - gboolean disable_mixing; - gchar *save_path; - gchar *save_only_path; - gchar *load_path; - GESTrackType track_types; - gboolean needs_set_state; - gboolean smartrender; - gchar *scenario; - gchar *testfile; - gchar *format; - gchar *outputuri; - gchar *encoding_profile; - gchar *videosink; - gchar *audiosink; - gboolean list_transitions; - gboolean inspect_action_type; - gchar *sanitized_timeline; - gchar *video_track_caps; - gchar *audio_track_caps; - gboolean embed_nesteds; - gboolean disable_validate; - - gboolean ignore_eos; - gboolean interactive; -} GESLauncherParsedOptions; - struct _GESLauncher { GApplication parent; diff --git a/tools/utils.c b/tools/utils.c index 78015cdf..2815ad23 100644 --- a/tools/utils.c +++ b/tools/utils.c @@ -89,10 +89,12 @@ _sanitize_argument (gchar * arg, const gchar * prev_arg) } gchar * -sanitize_timeline_description (gchar ** args) +sanitize_timeline_description (gchar ** args, GESLauncherParsedOptions * opts) { gint i; gchar *prev_arg = NULL; + GString *track_def; + GString *timeline_str; gchar *string = g_strdup (" "); @@ -108,7 +110,41 @@ sanitize_timeline_description (gchar ** args) prev_arg = args[i]; } - return string; + if (strstr (string, "+track")) { + gchar *res = g_strconcat ("ges:", string, NULL); + g_free (string); + + return res; + } + + timeline_str = g_string_new (string); + g_free (string); + + if (opts->track_types & GES_TRACK_TYPE_VIDEO) { + track_def = g_string_new (" +track video "); + + if (opts->video_track_caps) + g_string_append_printf (track_def, " restrictions=[%s] ", + opts->video_track_caps); + + g_string_prepend (timeline_str, track_def->str); + g_string_free (track_def, TRUE); + } + + if (opts->track_types & GES_TRACK_TYPE_AUDIO) { + track_def = g_string_new (" +track audio "); + + if (opts->audio_track_caps) + g_string_append_printf (track_def, " restrictions=[%s] ", + opts->audio_track_caps); + + g_string_prepend (timeline_str, track_def->str); + g_string_free (track_def, TRUE); + } + + g_string_prepend (timeline_str, "ges:"); + + return g_string_free (timeline_str, FALSE); } gboolean diff --git a/tools/utils.h b/tools/utils.h index 63e21011..afd5ab26 100644 --- a/tools/utils.h +++ b/tools/utils.h @@ -21,7 +21,38 @@ #include <gst/pbutils/pbutils.h> #include <gst/pbutils/encoding-profile.h> -gchar * sanitize_timeline_description (gchar **args); +#pragma once + +typedef struct +{ + gboolean mute; + gboolean disable_mixing; + gchar *save_path; + gchar *save_only_path; + gchar *load_path; + GESTrackType track_types; + gboolean needs_set_state; + gboolean smartrender; + gchar *scenario; + gchar *testfile; + gchar *format; + gchar *outputuri; + gchar *encoding_profile; + gchar *videosink; + gchar *audiosink; + gboolean list_transitions; + gboolean inspect_action_type; + gchar *sanitized_timeline; + gchar *video_track_caps; + gchar *audio_track_caps; + gboolean embed_nesteds; + gboolean disable_validate; + + gboolean ignore_eos; + gboolean interactive; +} GESLauncherParsedOptions; + +gchar * sanitize_timeline_description (gchar **args, GESLauncherParsedOptions *opts); gboolean get_flags_from_string (GType type, const gchar * str_flags, guint *val); gchar * ensure_uri (const gchar * location); GstEncodingProfile * parse_encoding_profile (const gchar * format); |