mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 13:08:49 +00:00
validate:scenario: Allow setting properties by element factory name
This commit is contained in:
parent
f2fc6a4550
commit
c1f613d8e7
1 changed files with 48 additions and 29 deletions
|
@ -2243,37 +2243,24 @@ _get_target_element (GstValidateScenario * scenario, GstValidateAction * action)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
|
||||||
cmp_klass_name (gconstpointer a, gconstpointer b)
|
|
||||||
{
|
|
||||||
const GValue *v = a;
|
|
||||||
const GValue *param = b;
|
|
||||||
GstElement *element = g_value_get_object (v);
|
|
||||||
const gchar *klass = g_value_get_string (param);
|
|
||||||
|
|
||||||
if (gst_validate_element_has_klass (element, klass))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _get_target_elements_by_klass:
|
* _get_target_elements_by_klass:
|
||||||
* @scenario: a #GstValidateScenario
|
* @scenario: a #GstValidateScenario
|
||||||
* @action: a #GstValidateAction
|
* @action: a #GstValidateAction
|
||||||
*
|
*
|
||||||
* Returns all the elements in the pipeline whose GST_ELEMENT_METADATA_KLASS
|
* Returns all the elements in the pipeline whose GST_ELEMENT_METADATA_KLASS
|
||||||
* matches the 'target-element-klass' of @action.
|
* matches the 'target-element-klass' of @action and the factory name matches
|
||||||
|
* the 'target-element-factory-name'.
|
||||||
*
|
*
|
||||||
* Returns: (transfer full) (element-type GstElement): a list of #GstElement
|
* Returns: (transfer full) (element-type GstElement): a list of #GstElement
|
||||||
*/
|
*/
|
||||||
static GList *
|
static GList *
|
||||||
_get_target_elements_by_klass (GstValidateScenario * scenario,
|
_get_target_elements_by_klass_or_factory_name (GstValidateScenario * scenario,
|
||||||
GstValidateAction * action)
|
GstValidateAction * action)
|
||||||
{
|
{
|
||||||
GList *result = NULL;
|
GList *result = NULL;
|
||||||
GstIterator *it, *filtered;
|
GstIterator *it;
|
||||||
const gchar *klass;
|
const gchar *klass, *fname;
|
||||||
GValue v = G_VALUE_INIT, param = G_VALUE_INIT;
|
GValue v = G_VALUE_INIT, param = G_VALUE_INIT;
|
||||||
gboolean done = FALSE;
|
gboolean done = FALSE;
|
||||||
GstElement *pipeline = gst_validate_scenario_get_pipeline (scenario);
|
GstElement *pipeline = gst_validate_scenario_get_pipeline (scenario);
|
||||||
|
@ -2285,13 +2272,20 @@ _get_target_elements_by_klass (GstValidateScenario * scenario,
|
||||||
}
|
}
|
||||||
|
|
||||||
klass = gst_structure_get_string (action->structure, "target-element-klass");
|
klass = gst_structure_get_string (action->structure, "target-element-klass");
|
||||||
if (klass == NULL) {
|
fname =
|
||||||
|
gst_structure_get_string (action->structure,
|
||||||
|
"target-element-factory-name");
|
||||||
|
if (!klass && !fname) {
|
||||||
gst_object_unref (pipeline);
|
gst_object_unref (pipeline);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gst_validate_element_has_klass (pipeline, klass))
|
if (klass && gst_validate_element_has_klass (pipeline, klass))
|
||||||
|
result = g_list_prepend (result, gst_object_ref (pipeline));
|
||||||
|
|
||||||
|
if (fname && !g_strcmp0 (GST_OBJECT_NAME (gst_element_get_factory (pipeline)),
|
||||||
|
fname))
|
||||||
result = g_list_prepend (result, gst_object_ref (pipeline));
|
result = g_list_prepend (result, gst_object_ref (pipeline));
|
||||||
|
|
||||||
it = gst_bin_iterate_recurse (GST_BIN (pipeline));
|
it = gst_bin_iterate_recurse (GST_BIN (pipeline));
|
||||||
|
@ -2299,15 +2293,24 @@ _get_target_elements_by_klass (GstValidateScenario * scenario,
|
||||||
g_value_init (¶m, G_TYPE_STRING);
|
g_value_init (¶m, G_TYPE_STRING);
|
||||||
g_value_set_string (¶m, klass);
|
g_value_set_string (¶m, klass);
|
||||||
|
|
||||||
filtered = gst_iterator_filter (it, cmp_klass_name, ¶m);
|
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
switch (gst_iterator_next (filtered, &v)) {
|
switch (gst_iterator_next (it, &v)) {
|
||||||
case GST_ITERATOR_OK:{
|
case GST_ITERATOR_OK:{
|
||||||
GstElement *child = g_value_get_object (&v);
|
GstElement *child = g_value_get_object (&v);
|
||||||
|
|
||||||
if (g_list_find (result, child) == NULL)
|
if (g_list_find (result, child))
|
||||||
|
goto next;
|
||||||
|
|
||||||
|
if (klass && gst_validate_element_has_klass (child, klass)) {
|
||||||
result = g_list_prepend (result, gst_object_ref (child));
|
result = g_list_prepend (result, gst_object_ref (child));
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fname
|
||||||
|
&& !g_strcmp0 (GST_OBJECT_NAME (gst_element_get_factory (child)),
|
||||||
|
fname))
|
||||||
|
result = g_list_prepend (result, gst_object_ref (child));
|
||||||
|
next:
|
||||||
g_value_reset (&v);
|
g_value_reset (&v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2322,7 +2325,7 @@ _get_target_elements_by_klass (GstValidateScenario * scenario,
|
||||||
|
|
||||||
g_value_reset (&v);
|
g_value_reset (&v);
|
||||||
g_value_reset (¶m);
|
g_value_reset (¶m);
|
||||||
gst_iterator_free (filtered);
|
gst_iterator_free (it);
|
||||||
gst_object_unref (pipeline);
|
gst_object_unref (pipeline);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -2407,13 +2410,15 @@ _execute_set_property (GstValidateScenario * scenario,
|
||||||
*/
|
*/
|
||||||
if (gst_structure_get_string (action->structure, "target-element-name")) {
|
if (gst_structure_get_string (action->structure, "target-element-name")) {
|
||||||
target = _get_target_element (scenario, action);
|
target = _get_target_element (scenario, action);
|
||||||
if (target == NULL) {
|
if (target == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
targets = g_list_append (targets, target);
|
targets = g_list_append (targets, target);
|
||||||
} else if (gst_structure_get_string (action->structure,
|
} else if (gst_structure_get_string (action->structure,
|
||||||
"target-element-klass")) {
|
"target-element-klass") ||
|
||||||
targets = _get_target_elements_by_klass (scenario, action);
|
gst_structure_get_string (action->structure,
|
||||||
|
"target-element-factory-name")) {
|
||||||
|
targets = _get_target_elements_by_klass_or_factory_name (scenario, action);
|
||||||
} else {
|
} else {
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
@ -3251,6 +3256,13 @@ should_execute_action (GstElement * element, GstValidateAction * action)
|
||||||
if (tmp != NULL && gst_validate_element_has_klass (element, tmp))
|
if (tmp != NULL && gst_validate_element_has_klass (element, tmp))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
tmp =
|
||||||
|
gst_structure_get_string (action->structure,
|
||||||
|
"target-element-factory-name");
|
||||||
|
if (tmp != NULL
|
||||||
|
&& !g_strcmp0 (GST_OBJECT_NAME (gst_element_get_factory (element)), tmp))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4206,6 +4218,13 @@ init_scenarios (void)
|
||||||
.types = "string",
|
.types = "string",
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "target-element-factory-name",
|
||||||
|
.description = "The name factory for which to set a property on built elements",
|
||||||
|
.mandatory = FALSE,
|
||||||
|
.types = "string",
|
||||||
|
NULL
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "target-element-klass",
|
.name = "target-element-klass",
|
||||||
.description = "The klass of the GstElements to set a property on",
|
.description = "The klass of the GstElements to set a property on",
|
||||||
|
|
Loading…
Reference in a new issue