mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 19:42:26 +00:00
scenario: Add support for "config" actions, actions executed at parse time
This type of actions is used to change some parametter on GStreamer core and it plugins, it can be fore example, to change the rank of a plugin or things like that.
This commit is contained in:
parent
684eb19267
commit
77bba657d1
4 changed files with 86 additions and 38 deletions
|
@ -94,7 +94,7 @@ gst_validate_bin_monitor_create_scenarios (GstValidateBinMonitor * monitor)
|
||||||
const gchar *scenario_name;
|
const gchar *scenario_name;
|
||||||
|
|
||||||
if ((scenario_name = g_getenv ("GST_VALIDATE_SCENARIO"))) {
|
if ((scenario_name = g_getenv ("GST_VALIDATE_SCENARIO"))) {
|
||||||
gchar **scenario_v = g_strsplit (scenario_name, ":", 2);
|
gchar **scenario_v = g_strsplit (scenario_name, "->", 2);
|
||||||
|
|
||||||
if (scenario_v[1] && GST_VALIDATE_MONITOR_GET_OBJECT (monitor)) {
|
if (scenario_v[1] && GST_VALIDATE_MONITOR_GET_OBJECT (monitor)) {
|
||||||
if (!g_pattern_match_simple (scenario_v[1],
|
if (!g_pattern_match_simple (scenario_v[1],
|
||||||
|
|
|
@ -62,6 +62,7 @@ typedef struct _GstValidateActionType
|
||||||
GstValidateExecuteAction execute;
|
GstValidateExecuteAction execute;
|
||||||
gchar **mandatory_fields;
|
gchar **mandatory_fields;
|
||||||
gchar *description;
|
gchar *description;
|
||||||
|
gboolean is_config;
|
||||||
} GstValidateActionType;
|
} GstValidateActionType;
|
||||||
|
|
||||||
struct _GstValidateScenarioPrivate
|
struct _GstValidateScenarioPrivate
|
||||||
|
@ -702,7 +703,7 @@ _pipeline_freed_cb (GstValidateScenario * scenario,
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_load_scenario_file (GstValidateScenario * scenario,
|
_load_scenario_file (GstValidateScenario * scenario,
|
||||||
const gchar * scenario_file)
|
const gchar * scenario_file, gboolean *is_config)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
gsize xmlsize;
|
gsize xmlsize;
|
||||||
|
@ -727,12 +728,14 @@ _load_scenario_file (GstValidateScenario * scenario,
|
||||||
if (g_strcmp0 (content, "") == 0)
|
if (g_strcmp0 (content, "") == 0)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
|
*is_config = FALSE;
|
||||||
lines = g_strsplit (content, "\n", 0);
|
lines = g_strsplit (content, "\n", 0);
|
||||||
for (i = 0; lines[i]; i++) {
|
for (i = 0; lines[i]; i++) {
|
||||||
const gchar *type, *str_playback_time;
|
const gchar *type, *str_playback_time;
|
||||||
gdouble playback_time;
|
gdouble playback_time;
|
||||||
GstValidateAction *action;
|
GstValidateAction *action;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
GstValidateActionType *action_type;
|
||||||
|
|
||||||
if (g_strcmp0 (lines[i], "") == 0)
|
if (g_strcmp0 (lines[i], "") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -744,7 +747,11 @@ _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_strcmp0 (type, "scenario")) {
|
||||||
|
gst_structure_get_boolean (structure, "is-config", is_config);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
} else if (!(action_type = g_hash_table_lookup (action_types_table, type))) {
|
||||||
GST_ERROR_OBJECT (scenario, "We do not handle action types %s", type);
|
GST_ERROR_OBJECT (scenario, "We do not handle action types %s", type);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -763,8 +770,18 @@ _load_scenario_file (GstValidateScenario * scenario,
|
||||||
if (!(action->name = gst_structure_get_string (structure, "name")))
|
if (!(action->name = gst_structure_get_string (structure, "name")))
|
||||||
action->name = "";
|
action->name = "";
|
||||||
|
|
||||||
action->action_number = priv->num_actions++;
|
|
||||||
action->structure = structure;
|
action->structure = structure;
|
||||||
|
if (action_type->is_config) {
|
||||||
|
ret = action_type->execute (scenario, action);
|
||||||
|
g_slice_free (GstValidateAction, action);
|
||||||
|
|
||||||
|
if (ret == FALSE)
|
||||||
|
goto failed;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
action->action_number = priv->num_actions++;
|
||||||
priv->actions = g_list_append (priv->actions, action);
|
priv->actions = g_list_append (priv->actions, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,26 +813,32 @@ static gboolean
|
||||||
gst_validate_scenario_load (GstValidateScenario * scenario,
|
gst_validate_scenario_load (GstValidateScenario * scenario,
|
||||||
const gchar * scenario_name)
|
const gchar * scenario_name)
|
||||||
{
|
{
|
||||||
gboolean ret = TRUE;
|
gchar **scenarios;
|
||||||
|
guint i;
|
||||||
gchar *lfilename = NULL, *tldir = NULL;
|
gchar *lfilename = NULL, *tldir = NULL;
|
||||||
|
gboolean found_actions = FALSE, is_config, ret = TRUE;
|
||||||
const gchar *env_scenariodir = g_getenv ("GST_VALIDATE_SCENARIOS_PATH");
|
const gchar *env_scenariodir = g_getenv ("GST_VALIDATE_SCENARIOS_PATH");
|
||||||
|
|
||||||
if (!scenario_name)
|
if (!scenario_name)
|
||||||
goto invalid_name;
|
goto invalid_name;
|
||||||
|
|
||||||
|
scenarios = g_strsplit (scenario_name, ":", -1);
|
||||||
|
|
||||||
|
for (i=0; scenarios[i]; i++) {
|
||||||
lfilename =
|
lfilename =
|
||||||
g_strdup_printf ("%s" GST_VALIDATE_SCENARIO_SUFFIX, scenario_name);
|
g_strdup_printf ("%s" GST_VALIDATE_SCENARIO_SUFFIX, scenarios[i]);
|
||||||
|
|
||||||
tldir = g_build_filename ("data/", lfilename, NULL);
|
tldir = g_build_filename ("data/", lfilename, NULL);
|
||||||
|
|
||||||
if ((ret = _load_scenario_file (scenario, tldir)))
|
if ((ret = _load_scenario_file (scenario, tldir, &is_config)))
|
||||||
goto done;
|
goto check_scenario;
|
||||||
|
|
||||||
g_free (tldir);
|
g_free (tldir);
|
||||||
|
|
||||||
if (env_scenariodir) {
|
if (env_scenariodir) {
|
||||||
tldir = g_build_filename (env_scenariodir, lfilename, NULL);
|
tldir = g_build_filename (env_scenariodir, lfilename, NULL);
|
||||||
if ((ret = _load_scenario_file (scenario, tldir)))
|
if ((ret = _load_scenario_file (scenario, tldir, &is_config)))
|
||||||
goto done;
|
goto check_scenario;
|
||||||
g_free (tldir);
|
g_free (tldir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,20 +848,33 @@ gst_validate_scenario_load (GstValidateScenario * scenario,
|
||||||
GST_VALIDATE_SCENARIO_DIRECTORY, lfilename, NULL);
|
GST_VALIDATE_SCENARIO_DIRECTORY, lfilename, NULL);
|
||||||
|
|
||||||
|
|
||||||
if (!(ret = _load_scenario_file (scenario, tldir))) {
|
if (!(ret = _load_scenario_file (scenario, tldir, &is_config))) {
|
||||||
g_free (tldir);
|
g_free (tldir);
|
||||||
/* Try from system-wide profiles */
|
/* Try from system-wide profiles */
|
||||||
tldir = g_build_filename (GST_DATADIR, "gstreamer-" GST_API_VERSION,
|
tldir = g_build_filename (GST_DATADIR, "gstreamer-" GST_API_VERSION,
|
||||||
GST_VALIDATE_SCENARIO_DIRECTORY, lfilename, NULL);
|
GST_VALIDATE_SCENARIO_DIRECTORY, lfilename, NULL);
|
||||||
ret = _load_scenario_file (scenario, tldir);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
if (!(ret = _load_scenario_file (scenario, tldir, &is_config))) {
|
||||||
|
goto invalid_name;
|
||||||
|
}
|
||||||
|
} /* else check scenario */
|
||||||
|
|
||||||
|
check_scenario:
|
||||||
if (tldir)
|
if (tldir)
|
||||||
g_free (tldir);
|
g_free (tldir);
|
||||||
if (lfilename)
|
if (lfilename)
|
||||||
g_free (lfilename);
|
g_free (lfilename);
|
||||||
|
|
||||||
|
if (!is_config) {
|
||||||
|
if (found_actions == TRUE)
|
||||||
|
goto one_actions_scenario_max;
|
||||||
|
else
|
||||||
|
found_actions = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
|
||||||
if (ret == FALSE)
|
if (ret == FALSE)
|
||||||
g_error ("Could not set scenario %s => EXIT\n", scenario_name);
|
g_error ("Could not set scenario %s => EXIT\n", scenario_name);
|
||||||
|
|
||||||
|
@ -850,6 +886,16 @@ invalid_name:
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
one_actions_scenario_max:
|
||||||
|
{
|
||||||
|
GST_ERROR ("You can not set several actions scenario (you can "
|
||||||
|
"have set various confi scenario though, meaning you have to set"
|
||||||
|
" 'scenario, is-config=true' in the scenario file, and all actions"
|
||||||
|
" should be executable at parsing time)");
|
||||||
|
ret = FALSE;
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1040,7 +1086,7 @@ _free_action_type (GstValidateActionType * type)
|
||||||
void
|
void
|
||||||
gst_validate_add_action_type (const gchar * type_name,
|
gst_validate_add_action_type (const gchar * type_name,
|
||||||
GstValidateExecuteAction function, const gchar * const *mandatory_fields,
|
GstValidateExecuteAction function, const gchar * const *mandatory_fields,
|
||||||
const gchar * description)
|
const gchar * description, gboolean is_config)
|
||||||
{
|
{
|
||||||
GstValidateActionType *type = g_slice_new0 (GstValidateActionType);
|
GstValidateActionType *type = g_slice_new0 (GstValidateActionType);
|
||||||
|
|
||||||
|
@ -1051,6 +1097,7 @@ gst_validate_add_action_type (const gchar * type_name,
|
||||||
type->execute = function;
|
type->execute = function;
|
||||||
type->mandatory_fields = g_strdupv ((gchar **) mandatory_fields);
|
type->mandatory_fields = g_strdupv ((gchar **) mandatory_fields);
|
||||||
type->description = g_strdup (description);
|
type->description = g_strdup (description);
|
||||||
|
type->is_config = is_config;
|
||||||
|
|
||||||
g_hash_table_insert (action_types_table, g_strdup (type_name), type);
|
g_hash_table_insert (action_types_table, g_strdup (type_name), type);
|
||||||
}
|
}
|
||||||
|
@ -1061,15 +1108,15 @@ init_scenarios (void)
|
||||||
const gchar *seek_mandatory_fields[] = { "start", NULL };
|
const gchar *seek_mandatory_fields[] = { "start", NULL };
|
||||||
|
|
||||||
gst_validate_add_action_type ("seek", _execute_seek, seek_mandatory_fields,
|
gst_validate_add_action_type ("seek", _execute_seek, seek_mandatory_fields,
|
||||||
"Allows to seek into the files");
|
"Allows to seek into the files", FALSE);
|
||||||
gst_validate_add_action_type ("pause", _execute_pause, NULL,
|
gst_validate_add_action_type ("pause", _execute_pause, NULL,
|
||||||
"Make it possible to set pipeline to PAUSED, you can add a duration"
|
"Make it possible to set pipeline to PAUSED, you can add a duration"
|
||||||
" parametter so the pipeline goaes back to playing after that duration"
|
" parametter so the pipeline goaes back to playing after that duration"
|
||||||
" (in second)");
|
" (in second)", FALSE);
|
||||||
gst_validate_add_action_type ("play", _execute_play, NULL,
|
gst_validate_add_action_type ("play", _execute_play, NULL,
|
||||||
"Make it possible to set the pipeline state to PLAYING");
|
"Make it possible to set the pipeline state to PLAYING", FALSE);
|
||||||
gst_validate_add_action_type ("eos", _execute_eos, NULL,
|
gst_validate_add_action_type ("eos", _execute_eos, NULL,
|
||||||
"Make it possible to send an EOS to the pipeline");
|
"Make it possible to send an EOS to the pipeline", FALSE);
|
||||||
gst_validate_add_action_type ("switch-track", _execute_switch_track, NULL,
|
gst_validate_add_action_type ("switch-track", _execute_switch_track, NULL,
|
||||||
"The 'switch-track' command can be used to switch tracks.\n"
|
"The 'switch-track' command can be used to switch tracks.\n"
|
||||||
"The 'type' argument selects which track type to change (can be 'audio', 'video',"
|
"The 'type' argument selects which track type to change (can be 'audio', 'video',"
|
||||||
|
@ -1078,5 +1125,5 @@ init_scenarios (void)
|
||||||
" the given type, or a number with a '+' or '-' prefix, which means"
|
" the given type, or a number with a '+' or '-' prefix, which means"
|
||||||
" a relative change (eg, '+1' means 'next track', '-1' means 'previous"
|
" 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"
|
" track'), note that you need to state that it is a string in the scenario file"
|
||||||
" prefixing it with (string).");
|
" prefixing it with (string).", FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ GstValidateScenario * gst_validate_scenario_factory_create (GstValidateRunner *r
|
||||||
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, GstValidateExecuteAction function,
|
void gst_validate_add_action_type (const gchar *type_name, GstValidateExecuteAction function,
|
||||||
const gchar * const * mandatory_fields, const gchar *description);
|
const gchar * const * mandatory_fields, const gchar *description,
|
||||||
|
gboolean is_config);
|
||||||
|
|
||||||
gboolean gst_validate_action_get_clocktime (GstValidateScenario * scenario,
|
gboolean gst_validate_action_get_clocktime (GstValidateScenario * scenario,
|
||||||
GstValidateAction *action,
|
GstValidateAction *action,
|
||||||
|
|
|
@ -688,10 +688,10 @@ _register_actions (void)
|
||||||
"running-time", "all-headers", "count", NULL };
|
"running-time", "all-headers", "count", NULL };
|
||||||
|
|
||||||
gst_validate_add_action_type ("set-restriction", _execute_set_restriction,
|
gst_validate_add_action_type ("set-restriction", _execute_set_restriction,
|
||||||
resize_video_mandatory_fields, "Change the restriction caps on the fly");
|
resize_video_mandatory_fields, "Change the restriction caps on the fly", FALSE);
|
||||||
gst_validate_add_action_type ("video-request-key-unit",
|
gst_validate_add_action_type ("video-request-key-unit",
|
||||||
_execute_request_key_unit, force_key_unit_mandatory_fields,
|
_execute_request_key_unit, force_key_unit_mandatory_fields,
|
||||||
"Request a video key unit");
|
"Request a video key unit", FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue