launch: Add support for testfiles

Making it simpler to define a test in a single files, including the
configuration etc..

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/166>
This commit is contained in:
Thibault Saunier 2020-04-24 17:15:16 -04:00
parent a71b4984f6
commit f30a127776
3 changed files with 41 additions and 10 deletions

View file

@ -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) { if (!has_video && opts->track_types & GES_TRACK_TYPE_VIDEO) {
trackv = GES_TRACK (ges_video_track_new ()); 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 if (self->priv->parsed_options.load_path && project_uri
&& ges_validate_activate (GST_PIPELINE (self->priv->pipeline), && ges_validate_activate (GST_PIPELINE (self->priv->pipeline),
self, opts) == FALSE) { self, opts) == FALSE) {
if (opts->scenario)
g_error ("Could not activate scenario %s", 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; self->priv->seenerrors = TRUE;
g_application_quit (G_APPLICATION (self)); g_application_quit (G_APPLICATION (self));
} }
@ -239,7 +242,7 @@ _error_loading_asset_cb (GESProject * project, GError * error,
static gboolean static gboolean
_create_timeline (GESLauncher * self, const gchar * serialized_timeline, _create_timeline (GESLauncher * self, const gchar * serialized_timeline,
const gchar * proj_uri, const gchar * scenario) const gchar * proj_uri, gboolean validate)
{ {
GESProject *project; GESProject *project;
@ -247,7 +250,7 @@ _create_timeline (GESLauncher * self, const gchar * serialized_timeline,
if (proj_uri != NULL) { if (proj_uri != NULL) {
project = ges_project_new (proj_uri); project = ges_project_new (proj_uri);
} else if (scenario == NULL) { } else if (!validate) {
GST_INFO ("serialized timeline is %s", serialized_timeline); GST_INFO ("serialized timeline is %s", serialized_timeline);
project = ges_project_new (serialized_timeline); project = ges_project_new (serialized_timeline);
} else { } else {
@ -560,7 +563,8 @@ _create_pipeline (GESLauncher * self, const gchar * serialized_timeline)
self->priv->pipeline = ges_pipeline_new (); 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"); GST_ERROR ("Could not create the timeline");
goto failure; goto failure;
} }
@ -773,6 +777,16 @@ ges_launcher_parse_options (GESLauncher * self,
} }
, ,
#ifdef HAVE_GST_VALIDATE #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.",
"</test/file/path>"}
,
{"set-scenario", 0, 0, G_OPTION_ARG_STRING, &opts->scenario, {"set-scenario", 0, 0, G_OPTION_ARG_STRING, &opts->scenario,
"ges-launch-1.0 exposes gst-validate functionalities, such as scenarios." "ges-launch-1.0 exposes gst-validate functionalities, such as scenarios."
" Scenarios describe actions to execute, such as seeks or setting of " " Scenarios describe actions to execute, such as seeks or setting of "
@ -890,8 +904,8 @@ _local_command_line (GApplication * application, gchar ** arguments[],
goto done; goto done;
} }
if (!opts->load_path && !opts->scenario && !opts->list_transitions if (!opts->load_path && !opts->scenario && !opts->testfile
&& (argc <= 1)) { && !opts->list_transitions && (argc <= 1)) {
g_printf ("%s", g_option_context_get_help (ctx, TRUE, NULL)); g_printf ("%s", g_option_context_get_help (ctx, TRUE, NULL));
g_option_context_free (ctx); g_option_context_free (ctx);
*exit_status = 1; *exit_status = 1;
@ -1003,6 +1017,7 @@ _finalize (GObject * object)
g_free (opts->video_track_caps); g_free (opts->video_track_caps);
g_free (opts->audio_track_caps); g_free (opts->audio_track_caps);
g_free (opts->scenario); g_free (opts->scenario);
g_free (opts->testfile);
G_OBJECT_CLASS (ges_launcher_parent_class)->finalize (object); G_OBJECT_CLASS (ges_launcher_parent_class)->finalize (object);
} }

View file

@ -39,6 +39,7 @@ typedef struct
gboolean needs_set_state; gboolean needs_set_state;
gboolean smartrender; gboolean smartrender;
gchar *scenario; gchar *scenario;
gchar *testfile;
gchar *format; gchar *format;
gchar *outputuri; gchar *outputuri;
gchar *encoding_profile; gchar *encoding_profile;

View file

@ -115,10 +115,13 @@ ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher,
return TRUE; return TRUE;
} }
ges_validate_register_action_types (); gst_validate_init_debug ();
ges_validate_register_issues ();
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")) { if (g_strcmp0 (opts->scenario, "none")) {
gchar *scenario_name = gchar *scenario_name =
g_strconcat (opts->scenario, "->gespipeline*", NULL); 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 (); runner = gst_validate_runner_new ();
gst_tracing_register_hook (GST_TRACER (runner), "bin-add-post", gst_tracing_register_hook (GST_TRACER (runner), "bin-add-post",
G_CALLBACK (bin_element_added)); G_CALLBACK (bin_element_added));
@ -141,6 +147,8 @@ ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher,
if (metas) { if (metas) {
gchar **ges_options = gst_validate_utils_get_strv (metas, "ges-options"); 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) { if (ges_options) {
gint i; gint i;
@ -242,6 +250,13 @@ gboolean
ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher, ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher,
GESLauncherParsedOptions * opts) GESLauncherParsedOptions * opts)
{ {
if (opts->testfile) {
GST_WARNING ("Trying to run testfile %s, but gst-validate not supported",
opts->testfile);
return FALSE;
}
if (opts->scenario) { if (opts->scenario) {
GST_WARNING ("Trying to run scenario %s, but gst-validate not supported", GST_WARNING ("Trying to run scenario %s, but gst-validate not supported",
opts->scenario); opts->scenario);