From 4467b27b9f7290d3f3fb9bc3dc7e64d01fae5d46 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 12 Feb 2014 00:28:18 +0100 Subject: [PATCH] validate: Add a way to save details about avalaible scenarios in a file --- validate/gst/validate/gst-validate-scenario.c | 24 ++++++++++++++++--- validate/gst/validate/gst-validate-scenario.h | 2 +- validate/tools/gst-validate-transcoding.c | 11 ++++++--- validate/tools/gst-validate.c | 10 ++++++-- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index e15c0bc02d..45add85444 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -1215,9 +1215,13 @@ _list_scenarios_in_dir (GFile * dir, GKeyFile *kf) } } -void -gst_validate_list_scenarios (void) +gboolean +gst_validate_list_scenarios (gchar *output_file) { + gchar *result; + + gsize datalength; + GError *err = NULL; GKeyFile *kf = NULL; const gchar *env_scenariodir = g_getenv ("GST_VALIDATE_SCENARIOS_PATH"); gchar *tldir = g_build_filename (g_get_user_data_dir (), @@ -1248,7 +1252,21 @@ gst_validate_list_scenarios (void) _list_scenarios_in_dir (dir, kf); g_object_unref (dir); - g_print ("Full file:\n%s", g_key_file_to_data (kf, NULL, NULL)); + result = g_key_file_to_data (kf, &datalength, &err); + g_print ("All scenarios avalaible:\n%s", result); + + + if (output_file && !err) + g_file_set_contents (output_file, result, datalength, &err); + + if (err) { + GST_WARNING ("Got error '%s' listing scenarios", err->message); + g_clear_error (&err); + + return FALSE; + } + + return TRUE; } static void diff --git a/validate/gst/validate/gst-validate-scenario.h b/validate/gst/validate/gst-validate-scenario.h index 473bce885f..3b4ce8800b 100644 --- a/validate/gst/validate/gst-validate-scenario.h +++ b/validate/gst/validate/gst-validate-scenario.h @@ -71,7 +71,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); +gboolean gst_validate_list_scenarios (gchar *output_file); void gst_validate_add_action_type (const gchar *type_name, GstValidateExecuteAction function, const gchar * const * mandatory_fields, const gchar *description, gboolean is_config); diff --git a/validate/tools/gst-validate-transcoding.c b/validate/tools/gst-validate-transcoding.c index e22b751d83..c21092c4f9 100644 --- a/validate/tools/gst-validate-transcoding.c +++ b/validate/tools/gst-validate-transcoding.c @@ -745,6 +745,7 @@ main (int argc, gchar ** argv) GOptionContext *ctx; int rep_err; GstStateChangeReturn sret; + gchar *output_file = NULL; #ifdef G_OS_UNIX guint signal_watch_id; @@ -780,6 +781,10 @@ main (int argc, gchar ** argv) "exiting.", NULL}, {"list-scenarios", 'l', 0, G_OPTION_ARG_NONE, &list_scenarios, "List the avalaible scenarios that can be run", NULL}, + {"scenarios-defs-output-file", '\0', 0, G_OPTION_ARG_FILENAME, + &output_file, "The output file to store scenarios details. " + "Implies --list-scenario", + NULL}, {"force-reencoding", 'r', 0, G_OPTION_ARG_NONE, &force_reencoding, "Whether to try to force reencoding, meaning trying to only remux " "if possible(default: TRUE)", NULL}, @@ -830,9 +835,9 @@ main (int argc, gchar ** argv) gst_validate_init (); - if (list_scenarios) { - gst_validate_list_scenarios (); - + if (list_scenarios || output_file) { + if (gst_validate_list_scenarios (output_file)) + return 1; return 0; } diff --git a/validate/tools/gst-validate.c b/validate/tools/gst-validate.c index dfb9812eaa..fb3322a070 100644 --- a/validate/tools/gst-validate.c +++ b/validate/tools/gst-validate.c @@ -173,6 +173,7 @@ main (int argc, gchar ** argv) const gchar *scenario = NULL, *configs = NULL; gboolean list_scenarios = FALSE; GstStateChangeReturn sret; + gchar *output_file = NULL; #ifdef G_OS_UNIX guint signal_watch_id; @@ -185,6 +186,10 @@ main (int argc, gchar ** argv) "environment variable", NULL}, {"list-scenarios", 'l', 0, G_OPTION_ARG_NONE, &list_scenarios, "List the avalaible scenarios that can be run", NULL}, + {"scenarios-defs-output-file", '\0', 0, G_OPTION_ARG_FILENAME, + &output_file, "The output file to store scenarios details. " + "Implies --list-scenario", + NULL}, {"set-configs", '\0', 0, G_OPTION_ARG_STRING, &configs, "Let you set a config scenario, the scenario needs to be set as 'config" "' you can specify a list of scenario separated by ':'" @@ -233,8 +238,9 @@ main (int argc, gchar ** argv) gst_init (&argc, &argv); gst_validate_init (); - if (list_scenarios) { - gst_validate_list_scenarios (); + if (list_scenarios || output_file) { + if (gst_validate_list_scenarios (output_file)) + return 1; return 0; }