diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index 1f65a34c64..74d20b8dd2 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -730,3 +730,50 @@ gst_validate_scenario_factory_create (GstValidateRunner * runner, return scenario; } + +static void +_list_scenarios_in_dir (GFile * dir) +{ + GFileEnumerator *fenum; + GFileInfo *info; + + fenum = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, + G_FILE_QUERY_INFO_NONE, NULL, NULL); + + if (fenum == NULL) + return; + + for (info = g_file_enumerator_next_file (fenum, NULL, NULL); + info; info = g_file_enumerator_next_file (fenum, NULL, NULL)) { + if (g_str_has_suffix (g_file_info_get_name (info), + GST_VALIDATE_SCENARIO_SUFFIX)) { + gchar **name = g_strsplit (g_file_info_get_name (info), + GST_VALIDATE_SCENARIO_SUFFIX, 0); + + g_print ("Scenario %s \n", name[0]); + + g_strfreev (name); + } + } +} + +void +gst_validate_list_scenarios (void) +{ + gchar *tldir = g_build_filename (g_get_user_data_dir (), + "gstreamer-" GST_API_VERSION, GST_VALIDATE_SCENARIO_DIRECTORY, + NULL); + GFile *dir = g_file_new_for_path (tldir); + + g_print ("====================\n" + "Avalaible scenarios:\n" "====================\n"); + _list_scenarios_in_dir (dir); + g_object_unref (dir); + g_free (tldir); + + /* Hack to make it work uninstalled */ + dir = g_file_new_for_path ("data/"); + _list_scenarios_in_dir (dir); + g_object_unref (dir); + +} diff --git a/validate/gst/validate/gst-validate-scenario.h b/validate/gst/validate/gst-validate-scenario.h index 312fec17b0..163cd6a4fb 100644 --- a/validate/gst/validate/gst-validate-scenario.h +++ b/validate/gst/validate/gst-validate-scenario.h @@ -60,6 +60,7 @@ GType gst_validate_scenario_get_type (void); GstValidateScenario * gst_validate_scenario_factory_create (GstValidateRunner *runner, GstElement *pipeline, const gchar *scenario_name); +void gst_validate_list_scenarios (void); G_END_DECLS diff --git a/validate/gst/validate/gst-validate-transcoding.c b/validate/gst/validate/gst-validate-transcoding.c index 7a19bd80cc..57b1b25ef0 100644 --- a/validate/gst/validate/gst-validate-transcoding.c +++ b/validate/gst/validate/gst-validate-transcoding.c @@ -17,6 +17,8 @@ #include #endif +#include "gst-validate-scenario.h" + static GMainLoop *mainloop; static GstElement *pipeline; static GstEncodingProfile *encoding_profile = NULL; @@ -279,6 +281,7 @@ main (int argc, gchar ** argv) GError *err = NULL; const gchar *scenario = NULL; guint count = -1; + gboolean list_scenarios = FALSE; GOptionEntry options[] = { {"output-format", 'o', 0, G_OPTION_ARG_CALLBACK, &_parse_encoding_profile, @@ -298,6 +301,8 @@ main (int argc, gchar ** argv) "received, instead of forcing the pipeline to stop. Sending an EOS " "will allow the transcoding to finish the files properly before " "exiting.", NULL}, + {"list-scenarios", 'l', 0, G_OPTION_ARG_NONE, &list_scenarios, + "List the avalaible scenarios that can be run", NULL}, {NULL} }; @@ -321,6 +326,9 @@ main (int argc, gchar ** argv) if (scenario) g_setenv ("GST_VALIDATE_SCENARIO", scenario, TRUE); + if (list_scenarios) + gst_validate_list_scenarios (); + gst_init (&argc, &argv); gst_validate_init (); diff --git a/validate/gst/validate/gst-validate.c b/validate/gst/validate/gst-validate.c index 912cc6560f..b298b7daac 100644 --- a/validate/gst/validate/gst-validate.c +++ b/validate/gst/validate/gst-validate.c @@ -11,6 +11,7 @@ #include #include +#include "gst-validate-scenario.h" #ifdef G_OS_UNIX #include @@ -63,6 +64,7 @@ main (int argc, gchar ** argv) { GError *err = NULL; const gchar *scenario = NULL; + gboolean list_scenarios = FALSE; guint count = -1; #ifdef G_OS_UNIX guint signal_watch_id; @@ -72,6 +74,8 @@ main (int argc, gchar ** argv) {"set-scenario", '\0', 0, G_OPTION_ARG_STRING, &scenario, "Let you set a scenario, it will override the GST_VALIDATE_SCENARIO " "environment variable", NULL}, + {"list-scenarios", 'l', 0, G_OPTION_ARG_NONE, &list_scenarios, + "List the avalaible scenarios that can be run", NULL}, {NULL} }; GOptionContext *ctx; @@ -106,9 +110,13 @@ main (int argc, gchar ** argv) g_option_context_free (ctx); + if (list_scenarios) + gst_validate_list_scenarios (); + gst_init (&argc, &argv); gst_validate_init (); + /* Create the pipeline */ argvn = g_new0 (char *, argc); memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));