diff --git a/girs/GstValidate-1.0.gir b/girs/GstValidate-1.0.gir index 312ad090ed..bc3a7774e9 100644 --- a/girs/GstValidate-1.0.gir +++ b/girs/GstValidate-1.0.gir @@ -1726,6 +1726,16 @@ target is in. + + + The property is optional, if it +is not found on the object, nothing happens. + + + Do not check that after +setting the property, the value is the one we set. + + @@ -4092,6 +4102,34 @@ function. + + + + + + + + The #GstValidateReporter to use to report errors + + + + The #GObject to set the property on + + + + The name of the property to set + + + + The value to set the property to + + + + The #GstValidateObjectSetPropertyFlags to use + + + + diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-enums.h b/subprojects/gst-devtools/validate/gst/validate/gst-validate-enums.h index 3dbf994818..3b8c98162a 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-enums.h +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-enums.h @@ -113,4 +113,19 @@ typedef enum { GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_NO_EXPRESSION = 1 << 1, } GstValidateStructureResolveVariablesFlags; + +/** + * GstValidateObjectSetPropertyFlags: + * @GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_OPTIONAL: The property is optional, if it + * is not found on the object, nothing happens. + * @GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_NO_VALUE_CHECK: Do not check that after + * setting the property, the value is the one we set. + * + * Since: 1.24 + */ +typedef enum { + GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_OPTIONAL = (1 << 0), + GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_NO_VALUE_CHECK = (1 << 1), +} GstValidateObjectSetPropertyFlags; + #endif /* __GST_VALIDATE_ENUMS_H__ */ diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c b/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c index 7a1c01e714..9da44c33ff 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c @@ -1418,9 +1418,11 @@ _set_or_check_properties (GQuark field_id, const GValue * value, GstValidateAction *action; GstObject *obj = NULL; GParamSpec *paramspec = NULL; + gboolean no_value_check = FALSE; + GstValidateObjectSetPropertyFlags flags = 0; const gchar *field = g_quark_to_string (field_id); const gchar *unused_fields[] = { "__scenario__", "__action__", "__res__", - "playback-time", "repeat", NULL + "playback-time", "repeat", "no-value-check", NULL }; if (g_strv_contains (unused_fields, field)) @@ -1429,14 +1431,23 @@ _set_or_check_properties (GQuark field_id, const GValue * value, gst_structure_get (structure, "__scenario__", G_TYPE_POINTER, &scenario, "__action__", G_TYPE_POINTER, &action, NULL); + gst_structure_get_boolean (structure, "no-value-check", &no_value_check); + + if (no_value_check) { + flags |= GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_NO_VALUE_CHECK; + } + if (action->priv->optional) + flags |= GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_OPTIONAL; + obj = _get_target_object_property (scenario, action, field, ¶mspec); if (!obj || !paramspec) { res = GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED; goto done; } if (gst_structure_has_name (action->structure, "set-properties")) - res = gst_validate_object_set_property (GST_VALIDATE_REPORTER (scenario), - G_OBJECT (obj), paramspec->name, value, action->priv->optional); + res = + gst_validate_object_set_property_full (GST_VALIDATE_REPORTER (scenario), + G_OBJECT (obj), paramspec->name, value, flags); else res = _check_property (scenario, action, obj, paramspec->name, value); diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.c b/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.c index 18b15599c6..8ecc9faaae 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.c +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.c @@ -1032,10 +1032,20 @@ gst_validate_utils_get_clocktime (GstStructure * structure, const gchar * name, return TRUE; } +/** + * gst_validate_object_set_property_full: + * @reporter: The #GstValidateReporter to use to report errors + * @object: The #GObject to set the property on + * @property: The name of the property to set + * @value: The value to set the property to + * @flags: The #GstValidateObjectSetPropertyFlags to use + * + * Since: 1.24 + */ GstValidateActionReturn -gst_validate_object_set_property (GstValidateReporter * reporter, +gst_validate_object_set_property_full (GstValidateReporter * reporter, GObject * object, const gchar * property, - const GValue * value, gboolean optional) + const GValue * value, GstValidateObjectSetPropertyFlags flags) { GParamSpec *paramspec; GObjectClass *klass = G_OBJECT_GET_CLASS (object); @@ -1044,7 +1054,7 @@ gst_validate_object_set_property (GstValidateReporter * reporter, paramspec = g_object_class_find_property (klass, property); if (paramspec == NULL) { - if (optional) + if (!!(flags & GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_OPTIONAL)) return TRUE; GST_ERROR ("Target doesn't have property %s", property); return FALSE; @@ -1078,16 +1088,18 @@ gst_validate_object_set_property (GstValidateReporter * reporter, 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 (reporter, SCENARIO_ACTION_EXECUTION_ERROR, - "Setting value %" GST_PTR_FORMAT "::%s failed, expected value: %s" - " value after setting %s", object, property, cvalstr, nvalstr); + if (!(flags & GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_NO_VALUE_CHECK)) { + if (gst_value_compare (&cvalue, &nvalue) != GST_VALUE_EQUAL) { + gchar *nvalstr = gst_value_serialize (&nvalue); + gchar *cvalstr = gst_value_serialize (&cvalue); + GST_VALIDATE_REPORT (reporter, 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); + res = GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED; + g_free (nvalstr); + g_free (cvalstr); + } } g_value_reset (&cvalue); @@ -1593,3 +1605,12 @@ gst_validate_fail_on_missing_plugin (void) } return FALSE; } + +GstValidateActionReturn +gst_validate_object_set_property (GstValidateReporter * reporter, + GObject * object, + const gchar * property, const GValue * value, gboolean optional) +{ + return gst_validate_object_set_property_full (reporter, object, property, + value, optional ? GST_VALIDATE_OBJECT_SET_PROPERTY_FLAGS_OPTIONAL : 0); +} diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.h b/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.h index 2589f18f15..3ae12ba317 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.h +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-utils.h @@ -74,6 +74,14 @@ GstValidateActionReturn gst_validate_object_set_property (GstValidateReporter * const GValue * value, gboolean optional); +GST_VALIDATE_API +GstValidateActionReturn gst_validate_object_set_property_full(GstValidateReporter * reporter, + GObject * object, + const gchar * property, + const GValue * value, + GstValidateObjectSetPropertyFlags flags); + + GST_VALIDATE_API void gst_validate_spin_on_fault_signals (void);