From 7d74176395b17e2a5d694c8b17b0cb23469605e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 22 Sep 2017 19:35:04 +0200 Subject: [PATCH] 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 --- tests/test-display.c | 86 ++++++++-------------------------------------------- 1 file changed, 12 insertions(+), 74 deletions(-) diff --git a/tests/test-display.c b/tests/test-display.c index 154ca40..d81e903 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 -- 2.7.4