validate: Add a way to list avalaible scenarios

Conflicts:

	gst/validate/gst-validate-transcoding.c
This commit is contained in:
Thibault Saunier 2013-08-16 12:50:51 +02:00 committed by Thiago Santos
parent 123bdea93a
commit de57b1455a
4 changed files with 64 additions and 0 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -17,6 +17,8 @@
#include <glib-unix.h>
#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 ();

View file

@ -11,6 +11,7 @@
#include <gst/gst.h>
#include <gst/validate/validate.h>
#include "gst-validate-scenario.h"
#ifdef G_OS_UNIX
#include <glib-unix.h>
@ -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));