mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-13 23:22:54 +00:00
validate: Factor out a method to set properties on elements in utils
Make sure to use it where appropriate and add some logging when setting an object property from an action. And use the valgrind.conf to set all the properties instead of having a mixture of a config scenario and the config file (making sure the max-lateness is set on any sink)
This commit is contained in:
parent
1d568ff11f
commit
1a28e7b043
7 changed files with 82 additions and 74 deletions
|
@ -1,3 +0,0 @@
|
|||
description, is-config=true
|
||||
set-property, target-element-klass=Sink/Video, property-name=max-lateness, property-value=600, optional=true
|
||||
set-property, target-element-klass=Sink/Audio, property-name=max-lateness, property-value=600, optional=true
|
|
@ -1 +1,2 @@
|
|||
core, action=set-property, target-element-klass=Filter, property-name=qos, property-value=false
|
||||
core, action=set-property, target-element-klass=Sink, property-name=max-lateness, property-value=-1, optional=true
|
||||
|
|
|
@ -219,6 +219,7 @@ set_config_properties (GstValidateMonitor * monitor, GstElement * element)
|
|||
for (l = config; l != NULL; l = g_list_next (l)) {
|
||||
GstStructure *s = l->data;
|
||||
const gchar *klass;
|
||||
gchar *tmp;
|
||||
const gchar *prop_name;
|
||||
const GValue *prop_value;
|
||||
|
||||
|
@ -239,7 +240,11 @@ set_config_properties (GstValidateMonitor * monitor, GstElement * element)
|
|||
if (!prop_value)
|
||||
continue;
|
||||
|
||||
g_object_set_property (G_OBJECT (element), prop_name, prop_value);
|
||||
tmp = gst_value_serialize (prop_value);
|
||||
gst_validate_printf (monitor, "Setting %s to %s", prop_name, tmp);
|
||||
g_free (tmp);
|
||||
gst_validate_object_set_property (GST_VALIDATE_REPORTER (monitor),
|
||||
G_OBJECT (element), prop_name, prop_value, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2337,69 +2337,6 @@ _get_target_elements_by_klass_or_factory_name (GstValidateScenario * scenario,
|
|||
return result;
|
||||
}
|
||||
|
||||
static GstValidateActionReturn
|
||||
_object_set_property (GstValidateScenario * scenario,
|
||||
GObject * object, const gchar * property,
|
||||
const GValue * value, gboolean optional)
|
||||
{
|
||||
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);
|
||||
if (paramspec == NULL) {
|
||||
if (optional)
|
||||
return TRUE;
|
||||
GST_ERROR ("Target doesn't have property %s", property);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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 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
|
||||
_execute_set_property (GstValidateScenario * scenario,
|
||||
GstValidateAction * action)
|
||||
|
@ -2434,8 +2371,10 @@ _execute_set_property (GstValidateScenario * scenario,
|
|||
"property-value");
|
||||
|
||||
for (l = targets; l != NULL; l = g_list_next (l)) {
|
||||
GstValidateActionReturn tmpres = _object_set_property (scenario,
|
||||
G_OBJECT (l->data), property, property_value, action->priv->optional);
|
||||
GstValidateActionReturn tmpres =
|
||||
gst_validate_object_set_property (GST_VALIDATE_REPORTER (scenario),
|
||||
G_OBJECT (l->data), property,
|
||||
property_value, action->priv->optional);
|
||||
|
||||
if (!tmpres)
|
||||
ret = tmpres;
|
||||
|
|
|
@ -758,3 +758,66 @@ gst_validate_utils_get_clocktime (GstStructure * structure, const gchar * name,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstValidateActionReturn
|
||||
gst_validate_object_set_property (GstValidateReporter * reporter,
|
||||
GObject * object, const gchar * property,
|
||||
const GValue * value, gboolean optional)
|
||||
{
|
||||
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);
|
||||
if (paramspec == NULL) {
|
||||
if (optional)
|
||||
return TRUE;
|
||||
GST_ERROR ("Target doesn't have property %s", property);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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 (reporter, 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 GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
|
||||
}
|
||||
} else {
|
||||
if (!g_value_transform (value, &cvalue)) {
|
||||
GST_VALIDATE_REPORT (reporter, 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 (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);
|
||||
}
|
||||
|
||||
g_value_reset (&cvalue);
|
||||
g_value_reset (&nvalue);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include<glib.h>
|
||||
#include<gio/gio.h>
|
||||
#include <gst/gst.h>
|
||||
#include "gst-validate-scenario.h"
|
||||
#include "gst-validate-reporter.h"
|
||||
|
||||
typedef int (*GstValidateParseVariableFunc) (const gchar *name,
|
||||
double *value, gpointer user_data);
|
||||
|
@ -48,4 +50,10 @@ gboolean gst_validate_element_has_klass (GstElement * element, const gchar * kla
|
|||
gboolean gst_validate_utils_get_clocktime (GstStructure *structure, const gchar * name,
|
||||
GstClockTime * retval);
|
||||
|
||||
GstValidateActionReturn gst_validate_object_set_property (GstValidateReporter * reporter,
|
||||
GObject * object,
|
||||
const gchar * property,
|
||||
const GValue * value,
|
||||
gboolean optional);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -716,11 +716,6 @@ class GstValidateTest(Test):
|
|||
|
||||
if self.scenario is not None:
|
||||
scenario = self.scenario.get_execution_name()
|
||||
if self.options.valgrind:
|
||||
# Increase sink's max-lateness property when running inside
|
||||
# Valgrind as it slows down everything quiet a lot.
|
||||
scenario = "setup_sink_props_max_lateness:%s" % scenario
|
||||
|
||||
subproc_env["GST_VALIDATE_SCENARIO"] = scenario
|
||||
self.add_env_variable("GST_VALIDATE_SCENARIO",
|
||||
subproc_env["GST_VALIDATE_SCENARIO"])
|
||||
|
|
Loading…
Reference in a new issue