scenario: Add an action to remove a feature/plugin from the registry

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/207>
This commit is contained in:
Thibault Saunier 2020-06-12 09:58:24 -04:00 committed by GStreamer Merge Bot
parent dda8e7217c
commit 598ec0a5d4

View file

@ -2044,51 +2044,58 @@ _execute_switch_track (GstValidateScenario * scenario,
} }
static GstValidateExecuteActionReturn static GstValidateExecuteActionReturn
_execute_set_rank (GstValidateScenario * scenario, GstValidateAction * action) _execute_set_rank_or_disable_feature (GstValidateScenario * scenario,
GstValidateAction * action)
{ {
GstValidateExecuteActionReturn res = GST_VALIDATE_EXECUTE_ACTION_OK;
guint rank; guint rank;
GList *features, *origlist; GList *features, *origlist;
GstPlugin *plugin; GstPlugin *plugin;
GstPluginFeature *feature; GstPluginFeature *feature;
const gchar *name; const gchar *name;
gboolean removing_feature =
gst_structure_has_name (action->structure, "remove-plugin-feature");
GstRegistry *registry = gst_registry_get ();
if (!(name = gst_structure_get_string (action->structure, "feature-name")) && REPORT_UNLESS (
!(name = gst_structure_get_string (action->structure, "name"))) { (name = gst_structure_get_string (action->structure, "feature-name")) ||
GST_ERROR ("Could not find the name of the plugin feature(s) to tweak"); (name = gst_structure_get_string (action->structure, "name")), done,
"Could not find the name of the plugin/feature(s) to tweak");
return GST_VALIDATE_EXECUTE_ACTION_ERROR; if (removing_feature)
} REPORT_UNLESS (
(gst_structure_get_uint (action->structure, "rank", &rank)) ||
(gst_structure_get_int (action->structure, "rank", (gint *) & rank)),
done, "Could not get rank to set on %s", name);
if (!(gst_structure_get_uint (action->structure, "rank", &rank) || feature = gst_registry_lookup_feature (registry, name);
gst_structure_get_int (action->structure, "rank", (gint *) & rank))) {
GST_ERROR ("Could not get rank to set on %s", name);
return GST_VALIDATE_EXECUTE_ACTION_ERROR;
}
feature = gst_registry_lookup_feature (gst_registry_get (), name);
if (feature) { if (feature) {
if (removing_feature)
gst_plugin_feature_set_rank (feature, rank); gst_plugin_feature_set_rank (feature, rank);
else
gst_registry_remove_feature (registry, feature);
gst_object_unref (feature); gst_object_unref (feature);
return GST_VALIDATE_EXECUTE_ACTION_OK; goto done;
} }
plugin = gst_registry_find_plugin (gst_registry_get (), name); REPORT_UNLESS ((plugin = gst_registry_find_plugin (registry, name)),
if (!plugin) { done, "Could not find %s", name);
GST_ERROR ("Could not find %s", name);
return GST_VALIDATE_EXECUTE_ACTION_ERROR; if (removing_feature) {
gst_registry_remove_plugin (registry, plugin);
goto done;
} }
origlist = features = origlist = features =
gst_registry_get_feature_list_by_plugin (gst_registry_get (), gst_registry_get_feature_list_by_plugin (registry,
gst_plugin_get_name (plugin)); gst_plugin_get_name (plugin));
for (; features; features = features->next) for (; features; features = features->next)
gst_plugin_feature_set_rank (features->data, rank); gst_plugin_feature_set_rank (features->data, rank);
gst_plugin_feature_list_free (origlist); gst_plugin_feature_list_free (origlist);
return GST_VALIDATE_EXECUTE_ACTION_OK; done:
return res;
} }
static inline gboolean static inline gboolean
@ -6258,7 +6265,7 @@ register_action_types (void)
"Note that the GST_DEBUG_DUMP_DOT_DIR env variable needs to be set", "Note that the GST_DEBUG_DUMP_DOT_DIR env variable needs to be set",
GST_VALIDATE_ACTION_TYPE_NONE); GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE ("set-rank", _execute_set_rank, REGISTER_ACTION_TYPE ("set-rank", _execute_set_rank_or_disable_feature,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "name", .name = "name",
@ -6277,7 +6284,21 @@ register_action_types (void)
"Changes the ranking of a particular plugin feature(s)", "Changes the ranking of a particular plugin feature(s)",
GST_VALIDATE_ACTION_TYPE_CONFIG); GST_VALIDATE_ACTION_TYPE_CONFIG);
REGISTER_ACTION_TYPE ("set-feature-rank", _execute_set_rank, REGISTER_ACTION_TYPE ("remove-feature", _execute_set_rank_or_disable_feature,
((GstValidateActionParameter []) {
{
.name = "name",
.description = "The name of a GstFeature or GstPlugin to remove",
.mandatory = TRUE,
.types = "string",
NULL
},
{NULL}
}),
"Remove a plugin feature(s) or a plugin from the registry",
GST_VALIDATE_ACTION_TYPE_CONFIG);
REGISTER_ACTION_TYPE ("set-feature-rank", _execute_set_rank_or_disable_feature,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
{ {
.name = "feature-name", .name = "feature-name",