validate: Add a GstValidateActionTypeFlag flag

Allowing us to define action types more in detail.
Keep backward compatibility, at least with the C API

https://bugzilla.gnome.org/show_bug.cgi?id=739854
This commit is contained in:
Thibault Saunier 2014-11-07 23:19:59 +01:00
parent fcb0f20828
commit 4cbcb97258
4 changed files with 40 additions and 20 deletions

View file

@ -33,6 +33,8 @@ extern GRegex *newline_regex;
typedef struct _GstValidateActionType GstValidateActionType; typedef struct _GstValidateActionType GstValidateActionType;
#define IS_CONFIG_ACTION_TYPE(type) (((type) & GST_VALIDATE_ACTION_TYPE_CONFIG) || ((type) == TRUE))
struct _GstValidateActionType struct _GstValidateActionType
{ {
GstMiniObject mini_object; GstMiniObject mini_object;
@ -45,7 +47,7 @@ struct _GstValidateActionType
GstValidateActionParameter *parameters; GstValidateActionParameter *parameters;
gchar *description; gchar *description;
gboolean is_config; GstValidateActionTypeFlags flags;
gpointer _gst_reserved[GST_PADDING_LARGE]; gpointer _gst_reserved[GST_PADDING_LARGE];
}; };

View file

@ -531,7 +531,7 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
g_string_append_printf (string, "\n Implementer namespace: %s", g_string_append_printf (string, "\n Implementer namespace: %s",
type->implementer_namespace); type->implementer_namespace);
if (type->is_config) if (IS_CONFIG_ACTION_TYPE (type->flags))
g_string_append_printf (string, g_string_append_printf (string,
"\n Is config action (meaning it will be executing right " "\n Is config action (meaning it will be executing right "
"at the begining of the execution of the pipeline)"); "at the begining of the execution of the pipeline)");

View file

@ -1358,7 +1358,7 @@ _load_scenario_file (GstValidateScenario * scenario,
action->structure = structure; action->structure = structure;
if (action_type->is_config) { if (IS_CONFIG_ACTION_TYPE (action_type->flags)) {
ret = action_type->execute (scenario, action); ret = action_type->execute (scenario, action);
gst_mini_object_unref (GST_MINI_OBJECT (action)); gst_mini_object_unref (GST_MINI_OBJECT (action));
@ -1894,10 +1894,11 @@ gst_validate_register_action_type (const gchar * type_name,
const gchar * implementer_namespace, const gchar * implementer_namespace,
GstValidateExecuteAction function, GstValidateExecuteAction function,
GstValidateActionParameter * parameters, GstValidateActionParameter * parameters,
const gchar * description, gboolean is_config) const gchar * description, GstValidateActionTypeFlags flags)
{ {
GstValidateActionType *tmptype; GstValidateActionType *tmptype;
GstValidateActionType *type = gst_validate_action_type_new (); GstValidateActionType *type = gst_validate_action_type_new ();
gboolean is_config = IS_CONFIG_ACTION_TYPE (flags);
gint n_params = is_config ? 0 : 2; gint n_params = is_config ? 0 : 2;
if (parameters) { if (parameters) {
@ -1932,7 +1933,7 @@ gst_validate_register_action_type (const gchar * type_name,
type->name = g_strdup (type_name); type->name = g_strdup (type_name);
type->implementer_namespace = g_strdup (implementer_namespace); type->implementer_namespace = g_strdup (implementer_namespace);
type->description = g_strdup (description); type->description = g_strdup (description);
type->is_config = is_config; type->flags = flags;
if ((tmptype = _find_action_type (type_name))) { if ((tmptype = _find_action_type (type_name))) {
action_types = g_list_remove (action_types, tmptype); action_types = g_list_remove (action_types, tmptype);
@ -2104,7 +2105,7 @@ init_scenarios (void)
{NULL} {NULL}
}), }),
"Allows to describe the scenario in various ways", "Allows to describe the scenario in various ways",
TRUE); GST_VALIDATE_ACTION_TYPE_CONFIG);
REGISTER_ACTION_TYPE ("seek", _execute_seek, REGISTER_ACTION_TYPE ("seek", _execute_seek,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -2160,7 +2161,7 @@ init_scenarios (void)
"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 GST_VALIDATE_ACTION_TYPE_NONE
); );
REGISTER_ACTION_TYPE ("pause", _execute_pause, REGISTER_ACTION_TYPE ("pause", _execute_pause,
@ -2177,16 +2178,16 @@ init_scenarios (void)
}), }),
"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)", GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("play", _execute_play, NULL, REGISTER_ACTION_TYPE ("play", _execute_play, NULL,
"Sets the pipeline state to PLAYING", FALSE); "Sets the pipeline state to PLAYING", GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("stop", _execute_stop, NULL, REGISTER_ACTION_TYPE ("stop", _execute_stop, NULL,
"Sets the pipeline state to NULL", FALSE); "Sets the pipeline state to NULL", GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("eos", _execute_eos, NULL, REGISTER_ACTION_TYPE ("eos", _execute_eos, NULL,
"Sends an EOS event to the pipeline", FALSE); "Sends an EOS event to the pipeline", GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("switch-track", _execute_switch_track, REGISTER_ACTION_TYPE ("switch-track", _execute_switch_track,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -2214,7 +2215,7 @@ init_scenarios (void)
{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); , GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("wait", _execute_wait, REGISTER_ACTION_TYPE ("wait", _execute_wait,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -2225,13 +2226,13 @@ init_scenarios (void)
NULL}, NULL},
{NULL} {NULL}
}), }),
"Waits during 'duration' seconds", FALSE); "Waits during 'duration' seconds", GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("dot-pipeline", _execute_dot_pipeline, NULL, REGISTER_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); GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("set-feature-rank", _set_rank, REGISTER_ACTION_TYPE ("set-feature-rank", _set_rank,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -2249,7 +2250,8 @@ init_scenarios (void)
NULL}, NULL},
{NULL} {NULL}
}), }),
"Changes the ranking of a particular plugin feature", TRUE); "Changes the ranking of a particular plugin feature",
GST_VALIDATE_ACTION_TYPE_CONFIG);
REGISTER_ACTION_TYPE ("set-state", _execute_set_state, REGISTER_ACTION_TYPE ("set-state", _execute_set_state,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -2262,7 +2264,8 @@ init_scenarios (void)
}, },
{NULL} {NULL}
}), }),
"Changes the state of the pipeline to any GstState", FALSE); "Changes the state of the pipeline to any GstState",
GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("set-property", _execute_set_property, REGISTER_ACTION_TYPE ("set-property", _execute_set_property,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -2288,7 +2291,8 @@ init_scenarios (void)
}, },
{NULL} {NULL}
}), }),
"Sets a property of any element in the pipeline", FALSE); "Sets a property of any element in the pipeline",
GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("set-debug-threshold", REGISTER_ACTION_TYPE ("set-debug-threshold",
_execute_set_debug_threshold, _execute_set_debug_threshold,
@ -2303,7 +2307,8 @@ init_scenarios (void)
{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",
GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("emit-signal", _execute_emit_signal, REGISTER_ACTION_TYPE ("emit-signal", _execute_emit_signal,
((GstValidateActionParameter []) ((GstValidateActionParameter [])
@ -2323,7 +2328,8 @@ init_scenarios (void)
}, },
{NULL} {NULL}
}), }),
"Emits a signal to an element in the pipeline", FALSE); "Emits a signal to an element in the pipeline",
GST_VALIDATE_ACTION_TYPE_NONE);
/* *INDENT-ON* */ /* *INDENT-ON* */
} }

View file

@ -152,6 +152,17 @@ struct _GstValidateScenario
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];
}; };
/**
* GstValidateActionTypeFlags:
* @GST_VALIDATE_ACTION_TYPE_NONE: No special flag
*/
typedef enum
{
GST_VALIDATE_ACTION_TYPE_NONE = 0,
GST_VALIDATE_ACTION_TYPE_CONFIG = 1 << 1,
GST_VALIDATE_ACTION_TYPE_ASYNC = 1 << 2,
} GstValidateActionTypeFlags;
GType gst_validate_scenario_get_type (void); GType gst_validate_scenario_get_type (void);
GstValidateScenario * gst_validate_scenario_factory_create (GstValidateRunner *runner, GstValidateScenario * gst_validate_scenario_factory_create (GstValidateRunner *runner,
@ -166,7 +177,8 @@ void gst_validate_register_action_type (const gchar *type_name,
const gchar *implementer_namespace, const gchar *implementer_namespace,
GstValidateExecuteAction function, GstValidateExecuteAction function,
GstValidateActionParameter * parameters, GstValidateActionParameter * parameters,
const gchar *description, gboolean is_config); const gchar *description,
GstValidateActionTypeFlags flags);
gboolean gst_validate_action_get_clocktime (GstValidateScenario * scenario, gboolean gst_validate_action_get_clocktime (GstValidateScenario * scenario,