From f30a12777691e385380aed0c0d4d93b2629f6090 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 24 Apr 2020 17:15:16 -0400 Subject: [PATCH] launch: Add support for testfiles Making it simpler to define a test in a single files, including the configuration etc.. Part-of: --- tools/ges-launcher.c | 29 ++++++++++++++++++++++------- tools/ges-launcher.h | 1 + tools/ges-validate.c | 21 ++++++++++++++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/tools/ges-launcher.c b/tools/ges-launcher.c index 88845db..f99bdfe 100644 --- a/tools/ges-launcher.c +++ b/tools/ges-launcher.c @@ -131,7 +131,7 @@ retry: } } - if (opts->scenario && !load_path) { + if ((opts->scenario || opts->testfile) && !load_path) { if (!has_video && opts->track_types & GES_TRACK_TYPE_VIDEO) { trackv = GES_TRACK (ges_video_track_new ()); @@ -212,7 +212,10 @@ _project_loaded_cb (GESProject * project, GESTimeline * timeline, if (self->priv->parsed_options.load_path && project_uri && ges_validate_activate (GST_PIPELINE (self->priv->pipeline), self, opts) == FALSE) { - g_error ("Could not activate scenario %s", opts->scenario); + if (opts->scenario) + g_error ("Could not activate scenario %s", opts->scenario); + else + g_error ("Could not activate testfile %s", opts->testfile); self->priv->seenerrors = TRUE; g_application_quit (G_APPLICATION (self)); } @@ -239,7 +242,7 @@ _error_loading_asset_cb (GESProject * project, GError * error, static gboolean _create_timeline (GESLauncher * self, const gchar * serialized_timeline, - const gchar * proj_uri, const gchar * scenario) + const gchar * proj_uri, gboolean validate) { GESProject *project; @@ -247,7 +250,7 @@ _create_timeline (GESLauncher * self, const gchar * serialized_timeline, if (proj_uri != NULL) { project = ges_project_new (proj_uri); - } else if (scenario == NULL) { + } else if (!validate) { GST_INFO ("serialized timeline is %s", serialized_timeline); project = ges_project_new (serialized_timeline); } else { @@ -560,7 +563,8 @@ _create_pipeline (GESLauncher * self, const gchar * serialized_timeline) self->priv->pipeline = ges_pipeline_new (); - if (!_create_timeline (self, serialized_timeline, uri, opts->scenario)) { + if (!_create_timeline (self, serialized_timeline, uri, opts->scenario + || opts->testfile)) { GST_ERROR ("Could not create the timeline"); goto failure; } @@ -773,6 +777,16 @@ ges_launcher_parse_options (GESLauncher * self, } , #ifdef HAVE_GST_VALIDATE + {"set-test-file", 0, 0, G_OPTION_ARG_STRING, &opts->testfile, + "ges-launch-1.0 exposes gst-validate functionalities, such as test files and scenarios." + " Scenarios describe actions to execute, such as seeks or setting of " + "properties. " + "GES implements editing-specific actions such as adding or removing " + "clips. " + "See gst-validate-1.0 --help for more info about validate and " + "scenarios, " "and --inspect-action-type.", + ""} + , {"set-scenario", 0, 0, G_OPTION_ARG_STRING, &opts->scenario, "ges-launch-1.0 exposes gst-validate functionalities, such as scenarios." " Scenarios describe actions to execute, such as seeks or setting of " @@ -890,8 +904,8 @@ _local_command_line (GApplication * application, gchar ** arguments[], goto done; } - if (!opts->load_path && !opts->scenario && !opts->list_transitions - && (argc <= 1)) { + if (!opts->load_path && !opts->scenario && !opts->testfile + && !opts->list_transitions && (argc <= 1)) { g_printf ("%s", g_option_context_get_help (ctx, TRUE, NULL)); g_option_context_free (ctx); *exit_status = 1; @@ -1003,6 +1017,7 @@ _finalize (GObject * object) g_free (opts->video_track_caps); g_free (opts->audio_track_caps); g_free (opts->scenario); + g_free (opts->testfile); G_OBJECT_CLASS (ges_launcher_parent_class)->finalize (object); } diff --git a/tools/ges-launcher.h b/tools/ges-launcher.h index d9372b9..5c9f06d 100644 --- a/tools/ges-launcher.h +++ b/tools/ges-launcher.h @@ -39,6 +39,7 @@ typedef struct gboolean needs_set_state; gboolean smartrender; gchar *scenario; + gchar *testfile; gchar *format; gchar *outputuri; gchar *encoding_profile; diff --git a/tools/ges-validate.c b/tools/ges-validate.c index 2e185e8..d6e1d77 100644 --- a/tools/ges-validate.c +++ b/tools/ges-validate.c @@ -115,10 +115,13 @@ ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher, return TRUE; } - ges_validate_register_action_types (); - ges_validate_register_issues (); + gst_validate_init_debug (); - if (opts->scenario) { + if (opts->testfile) { + if (opts->scenario) + g_error ("Can not specify scenario and testfile at the same time"); + gst_validate_setup_test_file (opts->testfile, opts->mute); + } else if (opts->scenario) { if (g_strcmp0 (opts->scenario, "none")) { gchar *scenario_name = g_strconcat (opts->scenario, "->gespipeline*", NULL); @@ -127,6 +130,9 @@ ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher, } } + ges_validate_register_action_types (); + ges_validate_register_issues (); + runner = gst_validate_runner_new (); gst_tracing_register_hook (GST_TRACER (runner), "bin-add-post", G_CALLBACK (bin_element_added)); @@ -141,6 +147,8 @@ ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher, if (metas) { gchar **ges_options = gst_validate_utils_get_strv (metas, "ges-options"); + if (!ges_options) + ges_options = gst_validate_utils_get_strv (metas, "args"); if (ges_options) { gint i; @@ -242,6 +250,13 @@ gboolean ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher, GESLauncherParsedOptions * opts) { + if (opts->testfile) { + GST_WARNING ("Trying to run testfile %s, but gst-validate not supported", + opts->testfile); + + return FALSE; + } + if (opts->scenario) { GST_WARNING ("Trying to run scenario %s, but gst-validate not supported", opts->scenario); -- 2.7.4