validate: Implement the notion of implementer namespace to the action types

This allows users to know who implements an action type.

+ Enhance the printing of all action making it readable.
This commit is contained in:
Thibault Saunier 2014-09-05 23:03:58 +02:00
parent 15f52d4fa3
commit 69165a9f04
6 changed files with 77 additions and 50 deletions

View file

@ -27,6 +27,9 @@
GST_DEBUG_CATEGORY_EXTERN (gstvalidate_debug); GST_DEBUG_CATEGORY_EXTERN (gstvalidate_debug);
#define GST_CAT_DEFAULT gstvalidate_debug #define GST_CAT_DEFAULT gstvalidate_debug
extern GRegex *newline_regex;
typedef struct _GstValidateScenario GstValidateScenario; typedef struct _GstValidateScenario GstValidateScenario;
typedef struct _GstValidateAction GstValidateAction; typedef struct _GstValidateAction GstValidateAction;
typedef struct _GstValidateActionParameter GstValidateActionParameter; typedef struct _GstValidateActionParameter GstValidateActionParameter;
@ -38,6 +41,7 @@ struct _GstValidateActionType
GstMiniObject mini_object; GstMiniObject mini_object;
gchar *name; gchar *name;
gchar *implementer_namespace;
GstValidateExecuteAction execute; GstValidateExecuteAction execute;

View file

@ -43,9 +43,8 @@ static GstValidateDebugFlags _gst_validate_flags = 0;
static GHashTable *_gst_validate_issues = NULL; static GHashTable *_gst_validate_issues = NULL;
static FILE **log_files = NULL; static FILE **log_files = NULL;
#ifndef GST_DISABLE_GST_DEBUG
static GRegex *newline_regex = NULL; GRegex *newline_regex = NULL;
#endif
GST_DEBUG_CATEGORY_STATIC (gst_validate_report_debug); GST_DEBUG_CATEGORY_STATIC (gst_validate_report_debug);
#undef GST_CAT_DEFAULT #undef GST_CAT_DEFAULT
@ -481,6 +480,8 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
g_string_printf (string, "\nAction type:"); g_string_printf (string, "\nAction type:");
g_string_append_printf (string, "\n Name: %s", type->name); g_string_append_printf (string, "\n Name: %s", type->name);
g_string_append_printf (string, "\n Implementer namespace: %s",
type->implementer_namespace);
if (type->is_config) if (type->is_config)
g_string_append_printf (string, g_string_append_printf (string,
@ -572,14 +573,14 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
g_string_append_vprintf (string, format, args); g_string_append_vprintf (string, format, args);
#ifndef GST_DISABLE_GST_DEBUG
{
gchar *str;
if (!newline_regex) if (!newline_regex)
newline_regex = newline_regex =
g_regex_new ("\n", G_REGEX_OPTIMIZE | G_REGEX_MULTILINE, 0, NULL); g_regex_new ("\n", G_REGEX_OPTIMIZE | G_REGEX_MULTILINE, 0, NULL);
#ifndef GST_DISABLE_GST_DEBUG
{
gchar *str;
str = g_regex_replace (newline_regex, string->str, string->len, 0, str = g_regex_replace (newline_regex, string->str, string->len, 0,
"", 0, NULL); "", 0, NULL);

View file

@ -58,6 +58,10 @@ GST_DEBUG_CATEGORY_STATIC (gst_validate_scenario_debug);
#undef GST_CAT_DEFAULT #undef GST_CAT_DEFAULT
#define GST_CAT_DEFAULT gst_validate_scenario_debug #define GST_CAT_DEFAULT gst_validate_scenario_debug
#define ADD_ACTION_TYPE(_tname, _function, _params, _desc, _is_config) G_STMT_START { \
gst_validate_add_action_type ((_tname), "core", (_function), (_params), (_desc), (_is_config)); \
} G_STMT_END
enum enum
{ {
PROP_0, PROP_0,
@ -196,6 +200,7 @@ _action_type_free (GstValidateActionType * type)
g_free (type->parameters); g_free (type->parameters);
g_free (type->description); g_free (type->description);
g_free (type->name); g_free (type->name);
g_free (type->implementer_namespace);
} }
static void static void
@ -1898,6 +1903,7 @@ done:
/** /**
* gst_validate_add_action_type: * gst_validate_add_action_type:
* @type_name: The name of the new action type to add * @type_name: The name of the new action type to add
* @implementer_namespace: The namespace of the implementer of the action type
* @function: (scope notified): The function to be called to execute the action * @function: (scope notified): The function to be called to execute the action
* @parameters: The #GstValidateActionParameter usable as parameter of the type * @parameters: The #GstValidateActionParameter usable as parameter of the type
* @description: A description of the new type * @description: A description of the new type
@ -1909,6 +1915,7 @@ done:
*/ */
void void
gst_validate_add_action_type (const gchar * type_name, gst_validate_add_action_type (const gchar * type_name,
const gchar * implementer_namespace,
GstValidateExecuteAction function, GstValidateExecuteAction function,
GstValidateActionParameter * parameters, GstValidateActionParameter * parameters,
const gchar * description, gboolean is_config) const gchar * description, gboolean is_config)
@ -1946,6 +1953,7 @@ gst_validate_add_action_type (const gchar * type_name,
type->execute = function; type->execute = function;
type->name = g_strdup (type_name); type->name = g_strdup (type_name);
type->implementer_namespace = g_strdup (implementer_namespace);
type->description = g_strdup (description); type->description = g_strdup (description);
type->is_config = is_config; type->is_config = is_config;
@ -1979,14 +1987,15 @@ gst_validate_print_action_types (gchar ** wanted_types, gint num_wanted_types)
gint nfound = 0; gint nfound = 0;
for (tmp = gst_validate_list_action_types (); tmp; tmp = tmp->next) { for (tmp = gst_validate_list_action_types (); tmp; tmp = tmp->next) {
GstValidateActionType *atype = tmp->data;
gboolean print = FALSE; gboolean print = FALSE;
if (num_wanted_types) { if (num_wanted_types) {
gint n; gint n;
for (n = 0; n < num_wanted_types; n++) { for (n = 0; n < num_wanted_types; n++) {
if (g_strcmp0 (((GstValidateActionType *) tmp->data)->name, if (g_strcmp0 (atype->name, wanted_types[n]) == 0 ||
wanted_types[n]) == 0) { g_strcmp0 (atype->implementer_namespace, wanted_types[n]) == 0) {
nfound++; nfound++;
print = TRUE; print = TRUE;
@ -1997,11 +2006,21 @@ gst_validate_print_action_types (gchar ** wanted_types, gint num_wanted_types)
print = TRUE; print = TRUE;
} }
if (print) if (print && num_wanted_types) {
gst_validate_printf (tmp->data, "\n"); gst_validate_printf (tmp->data, "\n");
} else if (print) {
gchar *desc =
g_regex_replace (newline_regex, atype->description, -1, 0, "\n ",
0,
NULL);
gst_validate_printf (NULL, "\n%s: %s:\n %s\n",
atype->implementer_namespace, atype->name, desc);
g_free (desc);
}
} }
if (num_wanted_types && num_wanted_types != nfound) { if (num_wanted_types && num_wanted_types > nfound) {
return FALSE; return FALSE;
} }
@ -2020,8 +2039,8 @@ init_scenarios (void)
clean_action_str = g_regex_new ("\\\\\n|#.*\n", G_REGEX_CASELESS, 0, NULL); clean_action_str = g_regex_new ("\\\\\n|#.*\n", G_REGEX_CASELESS, 0, NULL);
/* *INDENT-OFF* */ /* *INDENT-OFF* */
gst_validate_add_action_type ("description", _execute_seek, ADD_ACTION_TYPE ("description", _execute_seek,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "summary", .name = "summary",
.description = "Whether the scenario is a config only scenario (ie. explain what it does)", .description = "Whether the scenario is a config only scenario (ie. explain what it does)",
@ -2107,12 +2126,12 @@ init_scenarios (void)
.def = "infinite (GST_CLOCK_TIME_NONE)" .def = "infinite (GST_CLOCK_TIME_NONE)"
}, },
{NULL} {NULL}
}, }),
"Allows to describe the scenario in various ways", "Allows to describe the scenario in various ways",
TRUE); TRUE);
gst_validate_add_action_type ("seek", _execute_seek, ADD_ACTION_TYPE ("seek", _execute_seek,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "start", .name = "start",
.description = "The starting value of the seek", .description = "The starting value of the seek",
@ -2154,15 +2173,15 @@ init_scenarios (void)
"GST_CLOCK_TIME_NONE", "GST_CLOCK_TIME_NONE",
}, },
{NULL} {NULL}
}, }),
"Seeks into the stream, example of a seek happening when the stream reaches 5 seconds\n" "Seeks into the stream, example of a seek happening when the stream reaches 5 seconds\n"
"or 1 eighth of its duration and seeks at 10sec or 2 eighth of its duration:\n" "or 1 eighth of its duration and seeks at 10sec or 2 eighth of its duration:\n"
" seek, playback_time=\"min(5.0, (duration/8))\", start=\"min(10, 2*(duration/8))\", flags=accurate+flush", " seek, playback_time=\"min(5.0, (duration/8))\", start=\"min(10, 2*(duration/8))\", flags=accurate+flush",
FALSE FALSE
); );
gst_validate_add_action_type ("pause", _execute_pause, ADD_ACTION_TYPE ("pause", _execute_pause,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "duration", .name = "duration",
.description = "The duration during which the stream will be paused", .description = "The duration during which the stream will be paused",
@ -2172,22 +2191,22 @@ init_scenarios (void)
.def = "0.0", .def = "0.0",
}, },
{NULL} {NULL}
}, }),
"Sets pipeline to PAUSED. You can add a 'duration'\n" "Sets pipeline to PAUSED. You can add a 'duration'\n"
"parametter so the pipeline goes back to playing after that duration\n" "parametter so the pipeline goes back to playing after that duration\n"
"(in second)", FALSE); "(in second)", FALSE);
gst_validate_add_action_type ("play", _execute_play, NULL, ADD_ACTION_TYPE ("play", _execute_play, NULL,
"Sets the pipeline state to PLAYING", FALSE); "Sets the pipeline state to PLAYING", FALSE);
gst_validate_add_action_type ("stop", _execute_stop, NULL, ADD_ACTION_TYPE ("stop", _execute_stop, NULL,
"Sets the pipeline state to NULL", FALSE); "Sets the pipeline state to NULL", FALSE);
gst_validate_add_action_type ("eos", _execute_eos, NULL, ADD_ACTION_TYPE ("eos", _execute_eos, NULL,
"Sends an EOS event to the pipeline", FALSE); "Sends an EOS event to the pipeline", FALSE);
gst_validate_add_action_type ("switch-track", _execute_switch_track, ADD_ACTION_TYPE ("switch-track", _execute_switch_track,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "type", .name = "type",
.description = "Selects which track type to change (can be 'audio', 'video'," .description = "Selects which track type to change (can be 'audio', 'video',"
@ -2210,29 +2229,29 @@ init_scenarios (void)
.def = "+1", .def = "+1",
}, },
{NULL} {NULL}
}, }),
"The 'switch-track' command can be used to switch tracks.\n" "The 'switch-track' command can be used to switch tracks.\n"
, FALSE); , FALSE);
gst_validate_add_action_type ("wait", _execute_wait, ADD_ACTION_TYPE ("wait", _execute_wait,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "duration", .name = "duration",
.description = "the duration while no other action will be executed", .description = "the duration while no other action will be executed",
.mandatory = TRUE, .mandatory = TRUE,
NULL}, NULL},
{NULL} {NULL}
}, }),
"Waits during 'duration' seconds", FALSE); "Waits during 'duration' seconds", FALSE);
gst_validate_add_action_type ("dot-pipeline", _execute_dot_pipeline, NULL, ADD_ACTION_TYPE ("dot-pipeline", _execute_dot_pipeline, NULL,
"Dots the pipeline (the 'name' property will be used in the dot filename).\n" "Dots the pipeline (the 'name' property will be used in the dot filename).\n"
"For more information have a look at the GST_DEBUG_BIN_TO_DOT_FILE documentation.\n" "For more information have a look at the GST_DEBUG_BIN_TO_DOT_FILE documentation.\n"
"Note that the GST_DEBUG_DUMP_DOT_DIR env variable needs to be set\n", "Note that the GST_DEBUG_DUMP_DOT_DIR env variable needs to be set\n",
FALSE); FALSE);
gst_validate_add_action_type ("set-feature-rank", _set_rank, ADD_ACTION_TYPE ("set-feature-rank", _set_rank,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "feature-name", .name = "feature-name",
.description = "The name of a GstFeature", .description = "The name of a GstFeature",
@ -2246,11 +2265,11 @@ init_scenarios (void)
.types = "string, int", .types = "string, int",
NULL}, NULL},
{NULL} {NULL}
}, }),
"Changes the ranking of a particular plugin feature", TRUE); "Changes the ranking of a particular plugin feature", TRUE);
gst_validate_add_action_type ("set-state", _execute_set_state, ADD_ACTION_TYPE ("set-state", _execute_set_state,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "state", .name = "state",
.description = "A GstState as a string, should be in: \n" .description = "A GstState as a string, should be in: \n"
@ -2259,11 +2278,11 @@ init_scenarios (void)
.types = "string", .types = "string",
}, },
{NULL} {NULL}
}, }),
"Changes the state of the pipeline to any GstState", FALSE); "Changes the state of the pipeline to any GstState", FALSE);
gst_validate_add_action_type ("set-property", _execute_set_property, ADD_ACTION_TYPE ("set-property", _execute_set_property,
(GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "target-element-name", .name = "target-element-name",
.description = "The name of the GstElement to set a property on", .description = "The name of the GstElement to set a property on",
@ -2285,12 +2304,12 @@ init_scenarios (void)
NULL NULL
}, },
{NULL} {NULL}
}, }),
"Sets a property of any element in the pipeline", FALSE); "Sets a property of any element in the pipeline", FALSE);
gst_validate_add_action_type ("set-debug-threshold", ADD_ACTION_TYPE ("set-debug-threshold",
_execute_set_debug_threshold, _execute_set_debug_threshold,
(GstValidateActionParameter []) ((GstValidateActionParameter [])
{ {
{ {
.name = "debug-threshold", .name = "debug-threshold",
@ -2299,12 +2318,12 @@ init_scenarios (void)
.mandatory = TRUE, .mandatory = TRUE,
.types = "string"}, .types = "string"},
{NULL} {NULL}
}, }),
"Sets the debug level to be used, same format as\n" "Sets the debug level to be used, same format as\n"
"setting the GST_DEBUG env variable", FALSE); "setting the GST_DEBUG env variable", FALSE);
gst_validate_add_action_type ("emit-signal", _execute_emit_signal, ADD_ACTION_TYPE ("emit-signal", _execute_emit_signal,
(GstValidateActionParameter []) ((GstValidateActionParameter [])
{ {
{ {
.name = "target-element-name", .name = "target-element-name",
@ -2320,7 +2339,7 @@ init_scenarios (void)
NULL NULL
}, },
{NULL} {NULL}
}, }),
"Emits a signal to an element in the pipeline", FALSE); "Emits a signal to an element in the pipeline", FALSE);
/* *INDENT-ON* */ /* *INDENT-ON* */

View file

@ -162,7 +162,9 @@ gst_validate_list_scenarios (gchar **scenarios,
gint num_scenarios, gint num_scenarios,
gchar * output_file); gchar * output_file);
void gst_validate_add_action_type (const gchar *type_name, GstValidateExecuteAction function, void gst_validate_add_action_type (const gchar *type_name,
const gchar *implementer_namespace,
GstValidateExecuteAction function,
GstValidateActionParameter * parameters, GstValidateActionParameter * parameters,
const gchar *description, gboolean is_config); const gchar *description, gboolean is_config);

View file

@ -702,7 +702,7 @@ static void
_register_actions (void) _register_actions (void)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
gst_validate_add_action_type ("set-restriction", _execute_set_restriction, gst_validate_add_action_type ("set-restriction", "validate-transcoding", _execute_set_restriction,
(GstValidateActionParameter []) { (GstValidateActionParameter []) {
{ {
.name = "restriction-caps", .name = "restriction-caps",
@ -715,7 +715,8 @@ _register_actions (void)
}, },
"Change the restriction caps on the fly", "Change the restriction caps on the fly",
FALSE); FALSE);
gst_validate_add_action_type ("video-request-key-unit",
gst_validate_add_action_type ("video-request-key-unit", "validate-transcoding",
_execute_request_key_unit, _execute_request_key_unit,
(GstValidateActionParameter []) { (GstValidateActionParameter []) {
{ {

View file

@ -304,7 +304,7 @@ static void
_register_playbin_actions (void) _register_playbin_actions (void)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
gst_validate_add_action_type ("set-subtitle", _execute_set_subtitles, gst_validate_add_action_type ("set-subtitle", "validate-launcher", _execute_set_subtitles,
(GstValidateActionParameter []) { (GstValidateActionParameter []) {
{ {
.name = "subtitle-file", .name = "subtitle-file",
@ -325,7 +325,7 @@ _register_playbin_actions (void)
FALSE); FALSE);
/* Overriding default implementation */ /* Overriding default implementation */
gst_validate_add_action_type ("switch-track", _execute_switch_track, gst_validate_add_action_type ("switch-track", "validate-launcher", _execute_switch_track,
(GstValidateActionParameter []) { (GstValidateActionParameter []) {
{ {
.name = "type", .name = "type",