summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-09-22 19:35:04 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-09-22 20:06:42 +0200
commit7d74176395b17e2a5d694c8b17b0cb23469605e9 (patch)
treefd739d6a7500ab4ff08941ddb8343e5e5963f2b6 /tests
parentb063511c0512f7cb09a6c94c9b3b0df4dab8d581 (diff)
tests: display: use GObject getter
Instead of using the gst_vaapi_display_get_property(), this patch replaces it with g_object_get_property() to dump the available VA display properties. https://bugzilla.gnome.org/show_bug.cgi?id=788058
Diffstat (limited to 'tests')
-rw-r--r--tests/test-display.c86
1 files changed, 12 insertions, 74 deletions
diff --git a/tests/test-display.c b/tests/test-display.c
index 154ca404..d81e9030 100644
--- a/tests/test-display.c
+++ b/tests/test-display.c
@@ -140,91 +140,29 @@ print_formats (GArray * formats, const gchar * name)
}
}
-typedef struct _GstVaapiDisplayProperty GstVaapiDisplayProperty;
-struct _GstVaapiDisplayProperty
-{
- const gchar *name;
- GValue value;
-};
-
-static void
-gst_vaapi_display_property_free (GstVaapiDisplayProperty * prop)
-{
- if (!prop)
- return;
- g_value_unset (&prop->value);
- g_slice_free (GstVaapiDisplayProperty, prop);
-}
-
-static GstVaapiDisplayProperty *
-gst_vaapi_display_property_new (const gchar * name)
-{
- GstVaapiDisplayProperty *prop;
-
- prop = g_slice_new0 (GstVaapiDisplayProperty);
- if (!prop)
- return NULL;
- prop->name = name;
- return prop;
-}
-
-static void
-free_property_cb (gpointer data, gpointer user_data)
-{
- gst_vaapi_display_property_free (data);
-}
-
static void
dump_properties (GstVaapiDisplay * display)
{
- GstVaapiDisplayProperty *prop;
- GPtrArray *properties;
- guint i;
+ GParamSpec **properties;
+ guint i, n_properties;
- static const gchar *g_properties[] = {
- GST_VAAPI_DISPLAY_PROP_RENDER_MODE,
- GST_VAAPI_DISPLAY_PROP_ROTATION,
- GST_VAAPI_DISPLAY_PROP_HUE,
- GST_VAAPI_DISPLAY_PROP_SATURATION,
- GST_VAAPI_DISPLAY_PROP_BRIGHTNESS,
- GST_VAAPI_DISPLAY_PROP_CONTRAST,
- NULL
- };
-
- properties = g_ptr_array_new ();
- if (!properties)
- return;
+ properties =
+ g_object_class_list_properties (G_OBJECT_GET_CLASS (display),
+ &n_properties);
- for (i = 0; g_properties[i] != NULL; i++) {
- const gchar *const name = g_properties[i];
+ for (i = 0; i < n_properties; i++) {
+ const gchar *const name = g_param_spec_get_nick (properties[i]);
+ GValue value = G_VALUE_INIT;
if (!gst_vaapi_display_has_property (display, name))
continue;
- prop = gst_vaapi_display_property_new (name);
- if (!prop) {
- GST_ERROR ("failed to allocate GstVaapiDisplayProperty");
- goto end;
- }
-
- if (!gst_vaapi_display_get_property (display, name, &prop->value)) {
- GST_ERROR ("failed to get property '%s'", name);
- goto end;
- }
- g_ptr_array_add (properties, prop);
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (properties[i]));
+ g_object_get_property (G_OBJECT (display), name, &value);
+ print_value (&value, name);
}
- g_print ("%u properties\n", properties->len);
- for (i = 0; i < properties->len; i++) {
- prop = g_ptr_array_index (properties, i);
- print_value (&prop->value, prop->name);
- }
-
-end:
- if (properties) {
- g_ptr_array_foreach (properties, free_property_cb, NULL);
- g_ptr_array_free (properties, TRUE);
- }
+ g_free (properties);
}
static void