validate: Add a way to use config actions in GST_VALIDATE_CONFIG files

The synthax is:

core, action=action-name, param1=1, param2=param2
This commit is contained in:
Thibault Saunier 2017-06-06 12:42:57 -04:00
parent 8d251f12d9
commit 237a976d07
2 changed files with 53 additions and 4 deletions

View file

@ -1737,8 +1737,8 @@ _fill_action (GstValidateScenario * scenario, GstValidateAction * action,
(gst_structure_get_boolean (action->structure, "as-config",
&is_config) && is_config == TRUE)) {
gst_validate_print_action (action, NULL);
res = action_type->execute (scenario, action);
gst_validate_print_action (action, NULL);
return res;
}
@ -2449,6 +2449,7 @@ _execute_disable_plugin (GstValidateScenario * scenario,
return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
}
gst_validate_printf (action, "Disabling plugin \"%s\"\n", plugin_name);
gst_registry_remove_plugin (gst_registry_get (), plugin);
return GST_VALIDATE_EXECUTE_ACTION_OK;
@ -2785,6 +2786,22 @@ done:
return TRUE;
}
static gboolean
_action_type_has_parameter (GstValidateActionType * atype,
const gchar * paramname)
{
gint i;
if (!atype->parameters)
return FALSE;
for (i = 0; atype->parameters[i].name; i++)
if (g_strcmp0 (atype->parameters[i].name, paramname) == 0)
return TRUE;
return FALSE;
}
static gboolean
_load_scenario_file (GstValidateScenario * scenario,
const gchar * scenario_file, gboolean * is_config)
@ -3830,6 +3847,7 @@ gst_validate_scenario_get_target_state (GstValidateScenario * scenario)
void
init_scenarios (void)
{
GList *tmp;
GST_DEBUG_CATEGORY_INIT (gst_validate_scenario_debug, "gstvalidatescenario",
GST_DEBUG_FG_YELLOW, "Gst validate scenarios");
@ -4222,6 +4240,33 @@ init_scenarios (void)
GST_VALIDATE_ACTION_TYPE_NONE);
/* *INDENT-ON* */
for (tmp = gst_validate_plugin_get_config (NULL); tmp; tmp = tmp->next) {
const gchar *action_typename;
if ((action_typename = gst_structure_get_string (tmp->data, "action"))) {
GstValidateAction *action;
GstValidateActionType *atype = _find_action_type (action_typename);
if (!atype) {
g_error ("[CONFIG ERROR] Action type %s not found", action_typename);
continue;
}
if (!(atype->flags & GST_VALIDATE_ACTION_TYPE_CONFIG) &&
!(_action_type_has_parameter (atype, "as-config"))) {
g_error ("[CONFIG ERROR] Action is not a config action");
continue;
}
gst_structure_set (tmp->data, "as-config", G_TYPE_BOOLEAN, TRUE, NULL);
gst_structure_set_name (tmp->data, action_typename);
action = gst_validate_action_new (NULL, tmp->data);
_fill_action (NULL, action, tmp->data, FALSE);
}
}
}
void

View file

@ -194,9 +194,13 @@ gst_validate_plugin_get_config (GstPlugin * plugin)
if (confs) {
gint i;
for (i = 0; i < gst_caps_get_size (confs); i++)
plugin_conf = g_list_append (plugin_conf,
gst_structure_copy (gst_caps_get_structure (confs, i)));
for (i = 0; i < gst_caps_get_size (confs); i++) {
GstStructure *structure = gst_caps_get_structure (confs, i);
if (gst_structure_has_name (structure, suffix))
plugin_conf =
g_list_append (plugin_conf, gst_structure_copy (structure));
}
gst_caps_unref (confs);
}