mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
scenario: Make it possible to define mandatory fields
And give a descrpition for actions
This commit is contained in:
parent
ccc3f8d696
commit
b4a711c568
2 changed files with 58 additions and 14 deletions
|
@ -56,6 +56,13 @@ static void gst_validate_scenario_finalize (GObject * object);
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstValidateScenario, gst_validate_scenario,
|
G_DEFINE_TYPE_WITH_CODE (GstValidateScenario, gst_validate_scenario,
|
||||||
G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, NULL));
|
G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, NULL));
|
||||||
|
|
||||||
|
typedef struct _GstValidateActionType
|
||||||
|
{
|
||||||
|
GstValidateExecuteAction execute;
|
||||||
|
gchar ** mandatory_fields;
|
||||||
|
gchar *description;
|
||||||
|
} GstValidateActionType;
|
||||||
|
|
||||||
struct _GstValidateScenarioPrivate
|
struct _GstValidateScenarioPrivate
|
||||||
{
|
{
|
||||||
GstElement *pipeline;
|
GstElement *pipeline;
|
||||||
|
@ -468,15 +475,15 @@ get_position (GstValidateScenario * scenario)
|
||||||
GST_LOG ("Current position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
|
GST_LOG ("Current position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
|
||||||
if ((rate > 0 && (GstClockTime) position >= act->playback_time) ||
|
if ((rate > 0 && (GstClockTime) position >= act->playback_time) ||
|
||||||
(rate < 0 && (GstClockTime) position <= act->playback_time)) {
|
(rate < 0 && (GstClockTime) position <= act->playback_time)) {
|
||||||
GstValidateExecuteAction func;
|
GstValidateActionType *type;
|
||||||
|
|
||||||
/* TODO what about non flushing seeks? */
|
/* TODO what about non flushing seeks? */
|
||||||
/* TODO why is this inside the action time if ? */
|
/* TODO why is this inside the action time if ? */
|
||||||
if (GST_CLOCK_TIME_IS_VALID (priv->seeked_position))
|
if (GST_CLOCK_TIME_IS_VALID (priv->seeked_position))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
func = g_hash_table_lookup (action_types_table, act->type);
|
type = g_hash_table_lookup (action_types_table, act->type);
|
||||||
if (!func (scenario, act))
|
if (!type->execute (scenario, act))
|
||||||
GST_WARNING_OBJECT (scenario, "Could not execute %" GST_PTR_FORMAT,
|
GST_WARNING_OBJECT (scenario, "Could not execute %" GST_PTR_FORMAT,
|
||||||
act->structure);
|
act->structure);
|
||||||
|
|
||||||
|
@ -570,6 +577,7 @@ _load_scenario_file (GstValidateScenario * scenario,
|
||||||
type = gst_structure_get_name (structure);
|
type = gst_structure_get_name (structure);
|
||||||
if (!g_hash_table_lookup (action_types_table, type)) {
|
if (!g_hash_table_lookup (action_types_table, type)) {
|
||||||
GST_WARNING_OBJECT (scenario, "We do not handle action types %s", type);
|
GST_WARNING_OBJECT (scenario, "We do not handle action types %s", type);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
action = g_slice_new0 (GstValidateAction);
|
action = g_slice_new0 (GstValidateAction);
|
||||||
|
@ -830,21 +838,57 @@ gst_validate_list_scenarios (void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
gst_validate_add_action_type (const gchar *type_name, GstValidateExecuteAction function)
|
_free_action_type (GstValidateActionType *type)
|
||||||
{
|
{
|
||||||
|
g_free (type->description);
|
||||||
|
|
||||||
|
if (type->mandatory_fields)
|
||||||
|
g_strfreev (type->mandatory_fields);
|
||||||
|
g_free (type->description);
|
||||||
|
|
||||||
|
g_slice_free (GstValidateActionType, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_validate_add_action_type (const gchar *type_name, GstValidateExecuteAction function,
|
||||||
|
const gchar * const * mandatory_fields, const gchar *description)
|
||||||
|
{
|
||||||
|
GstValidateActionType *type = g_slice_new0 (GstValidateActionType);
|
||||||
|
|
||||||
if (action_types_table == NULL)
|
if (action_types_table == NULL)
|
||||||
action_types_table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
action_types_table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
(GDestroyNotify) g_free, NULL);
|
(GDestroyNotify) _free_action_type, NULL);
|
||||||
g_hash_table_insert (action_types_table, g_strdup (type_name), function);
|
|
||||||
|
type->execute = function;
|
||||||
|
type->mandatory_fields = g_strdupv ( (gchar **) mandatory_fields);
|
||||||
|
type->description = g_strdup (description);
|
||||||
|
|
||||||
|
g_hash_table_insert (action_types_table, g_strdup (type_name), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init_scenarios (void)
|
init_scenarios (void)
|
||||||
{
|
{
|
||||||
gst_validate_add_action_type ("seek", _execute_seek);
|
const gchar * seek_mandatory_fields[] = { "start", NULL };
|
||||||
gst_validate_add_action_type ("pause",_execute_pause);
|
|
||||||
gst_validate_add_action_type ("play",_execute_play);
|
gst_validate_add_action_type ("seek", _execute_seek, seek_mandatory_fields,
|
||||||
gst_validate_add_action_type ("eos",_execute_eos);
|
"Allows to seek into the files");
|
||||||
gst_validate_add_action_type ("switch-track", _execute_switch_track);
|
gst_validate_add_action_type ("pause",_execute_pause, NULL,
|
||||||
|
"Make it possible to set pipeline to PAUSED, you can add a duration"
|
||||||
|
" parametter so the pipeline goaes back to playing after that duration"
|
||||||
|
" (in second)");
|
||||||
|
gst_validate_add_action_type ("play",_execute_play, NULL,
|
||||||
|
"Make it possible to set the pipeline state to PLAYING");
|
||||||
|
gst_validate_add_action_type ("eos",_execute_eos, NULL,
|
||||||
|
"Make it possible to send an EOS to the pipeline");
|
||||||
|
gst_validate_add_action_type ("switch-track", _execute_switch_track, NULL,
|
||||||
|
"The 'switch-track' command can be used to switch tracks.\n"
|
||||||
|
"The 'type' argument selects which track type to change (can be 'audio', 'video',"
|
||||||
|
" or 'text'). The 'index' argument selects which track of this type"
|
||||||
|
" to use: it can be either a number, which will be the Nth track of"
|
||||||
|
" the given type, or a number with a '+' or '-' prefix, which means"
|
||||||
|
" a relative change (eg, '+1' means 'next track', '-1' means 'previous"
|
||||||
|
" track'), note that you need to state that it is a string in the scenario file"
|
||||||
|
" prefixing it with (string).");
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ GstValidateScenario * gst_validate_scenario_factory_create (GstValidateRunner *r
|
||||||
GstElement *pipeline,
|
GstElement *pipeline,
|
||||||
const gchar *scenario_name);
|
const gchar *scenario_name);
|
||||||
void gst_validate_list_scenarios (void);
|
void gst_validate_list_scenarios (void);
|
||||||
void gst_validate_add_action_type (const gchar *type_name,
|
void gst_validate_add_action_type (const gchar *type_name, GstValidateExecuteAction function,
|
||||||
GstValidateExecuteAction function);
|
const gchar * const * mandatory_fields, const gchar *description);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue