mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
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
This commit is contained in:
parent
b063511c05
commit
7d74176395
1 changed files with 12 additions and 74 deletions
|
@ -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
|
static void
|
||||||
dump_properties (GstVaapiDisplay * display)
|
dump_properties (GstVaapiDisplay * display)
|
||||||
{
|
{
|
||||||
GstVaapiDisplayProperty *prop;
|
GParamSpec **properties;
|
||||||
GPtrArray *properties;
|
guint i, n_properties;
|
||||||
guint i;
|
|
||||||
|
|
||||||
static const gchar *g_properties[] = {
|
properties =
|
||||||
GST_VAAPI_DISPLAY_PROP_RENDER_MODE,
|
g_object_class_list_properties (G_OBJECT_GET_CLASS (display),
|
||||||
GST_VAAPI_DISPLAY_PROP_ROTATION,
|
&n_properties);
|
||||||
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 ();
|
for (i = 0; i < n_properties; i++) {
|
||||||
if (!properties)
|
const gchar *const name = g_param_spec_get_nick (properties[i]);
|
||||||
return;
|
GValue value = G_VALUE_INIT;
|
||||||
|
|
||||||
for (i = 0; g_properties[i] != NULL; i++) {
|
|
||||||
const gchar *const name = g_properties[i];
|
|
||||||
|
|
||||||
if (!gst_vaapi_display_has_property (display, name))
|
if (!gst_vaapi_display_has_property (display, name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
prop = gst_vaapi_display_property_new (name);
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (properties[i]));
|
||||||
if (!prop) {
|
g_object_get_property (G_OBJECT (display), name, &value);
|
||||||
GST_ERROR ("failed to allocate GstVaapiDisplayProperty");
|
print_value (&value, name);
|
||||||
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_print ("%u properties\n", properties->len);
|
g_free (properties);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue