mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-17 04:45:47 +00:00
validate:scenario: Enhance the set_property action to handle enum props
User needs to specify the enum value as a string, to be used as with gst_util_set_object_arg. Also enhance reporting and verify that the set value has actually been taken into account.
This commit is contained in:
parent
dbc598b378
commit
f2fc6a4550
1 changed files with 54 additions and 9 deletions
|
@ -2328,12 +2328,15 @@ _get_target_elements_by_klass (GstValidateScenario * scenario,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static GstValidateActionReturn
|
||||||
_object_set_property (GObject * object, const gchar * property,
|
_object_set_property (GstValidateScenario * scenario,
|
||||||
|
GObject * object, const gchar * property,
|
||||||
const GValue * value, gboolean optional)
|
const GValue * value, gboolean optional)
|
||||||
{
|
{
|
||||||
GObjectClass *klass = G_OBJECT_GET_CLASS (object);
|
|
||||||
GParamSpec *paramspec;
|
GParamSpec *paramspec;
|
||||||
|
GObjectClass *klass = G_OBJECT_GET_CLASS (object);
|
||||||
|
GstValidateExecuteActionReturn res = GST_VALIDATE_EXECUTE_ACTION_OK;
|
||||||
|
GValue cvalue = G_VALUE_INIT, nvalue = G_VALUE_INIT;
|
||||||
|
|
||||||
paramspec = g_object_class_find_property (klass, property);
|
paramspec = g_object_class_find_property (klass, property);
|
||||||
if (paramspec == NULL) {
|
if (paramspec == NULL) {
|
||||||
|
@ -2343,9 +2346,49 @@ _object_set_property (GObject * object, const gchar * property,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set_property (object, property, value);
|
g_value_init (&cvalue, paramspec->value_type);
|
||||||
|
if (paramspec->value_type != G_VALUE_TYPE (value) &&
|
||||||
|
(G_VALUE_TYPE (value) == G_TYPE_STRING)) {
|
||||||
|
if (!gst_value_deserialize (&cvalue, g_value_get_string (value))) {
|
||||||
|
GST_VALIDATE_REPORT (scenario, SCENARIO_ACTION_EXECUTION_ERROR,
|
||||||
|
"Could not set %" GST_PTR_FORMAT "::%s as value %s"
|
||||||
|
" could not be deserialize to %s", object, property,
|
||||||
|
g_value_get_string (value), G_PARAM_SPEC_TYPE_NAME (paramspec));
|
||||||
|
|
||||||
return TRUE;
|
return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!g_value_transform (value, &cvalue)) {
|
||||||
|
GST_VALIDATE_REPORT (scenario, SCENARIO_ACTION_EXECUTION_ERROR,
|
||||||
|
"Could not set %" GST_PTR_FORMAT " property %s to type %s"
|
||||||
|
" (wanted type %s)", object, property, G_VALUE_TYPE_NAME (value),
|
||||||
|
G_PARAM_SPEC_TYPE_NAME (paramspec));
|
||||||
|
|
||||||
|
return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_set_property (object, property, &cvalue);
|
||||||
|
|
||||||
|
g_value_init (&nvalue, paramspec->value_type);
|
||||||
|
g_object_get_property (object, property, &nvalue);
|
||||||
|
|
||||||
|
if (gst_value_compare (&cvalue, &nvalue) != GST_VALUE_EQUAL) {
|
||||||
|
gchar *nvalstr = gst_value_serialize (&nvalue);
|
||||||
|
gchar *cvalstr = gst_value_serialize (&cvalue);
|
||||||
|
GST_VALIDATE_REPORT (scenario, SCENARIO_ACTION_EXECUTION_ERROR,
|
||||||
|
"Setting value %" GST_PTR_FORMAT "::%s failed, expected value: %s"
|
||||||
|
" value after setting %s", object, property, cvalstr, nvalstr);
|
||||||
|
|
||||||
|
res = GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
|
||||||
|
g_free (nvalstr);
|
||||||
|
g_free (cvalstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_value_reset (&cvalue);
|
||||||
|
g_value_reset (&nvalue);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -2380,9 +2423,11 @@ _execute_set_property (GstValidateScenario * scenario,
|
||||||
"property-value");
|
"property-value");
|
||||||
|
|
||||||
for (l = targets; l != NULL; l = g_list_next (l)) {
|
for (l = targets; l != NULL; l = g_list_next (l)) {
|
||||||
if (!_object_set_property (G_OBJECT (l->data), property, property_value,
|
GstValidateActionReturn tmpres = _object_set_property (scenario,
|
||||||
action->priv->optional))
|
G_OBJECT (l->data), property, property_value, action->priv->optional);
|
||||||
ret = FALSE;
|
|
||||||
|
if (!tmpres)
|
||||||
|
ret = tmpres;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free_full (targets, gst_object_unref);
|
g_list_free_full (targets, gst_object_unref);
|
||||||
|
@ -3234,7 +3279,7 @@ _element_added_cb (GstBin * bin, GstElement * element,
|
||||||
GstValidateActionType *action_type;
|
GstValidateActionType *action_type;
|
||||||
action_type = _find_action_type (action->type);
|
action_type = _find_action_type (action->type);
|
||||||
GST_DEBUG_OBJECT (element, "Executing set-property action");
|
GST_DEBUG_OBJECT (element, "Executing set-property action");
|
||||||
if (action_type->execute (scenario, action)) {
|
if (gst_validate_execute_action (action_type, action)) {
|
||||||
priv->on_addition_actions =
|
priv->on_addition_actions =
|
||||||
g_list_remove_link (priv->on_addition_actions, tmp);
|
g_list_remove_link (priv->on_addition_actions, tmp);
|
||||||
gst_mini_object_unref (GST_MINI_OBJECT (action));
|
gst_mini_object_unref (GST_MINI_OBJECT (action));
|
||||||
|
|
Loading…
Reference in a new issue