display: expose display attributes as GObject properties.

Expose VA display "render-mode" and "rotation" attributes as standard
GObject properties.
This commit is contained in:
Gwenole Beauchesne 2012-08-28 10:55:59 +02:00
parent fe4ad408dc
commit 9c714cf7a0
2 changed files with 57 additions and 5 deletions

View file

@ -28,6 +28,7 @@
#include "sysdeps.h" #include "sysdeps.h"
#include <string.h> #include <string.h>
#include "gstvaapiutils.h" #include "gstvaapiutils.h"
#include "gstvaapivalue.h"
#include "gstvaapidisplay.h" #include "gstvaapidisplay.h"
#include "gstvaapidisplay_priv.h" #include "gstvaapidisplay_priv.h"
#include "gstvaapiworkarounds.h" #include "gstvaapiworkarounds.h"
@ -51,9 +52,8 @@ struct _GstVaapiProperty {
VADisplayAttribute attribute; VADisplayAttribute attribute;
}; };
/* XXX: export property names when the API is stable enough */ #define DEFAULT_RENDER_MODE GST_VAAPI_RENDER_MODE_TEXTURE
#define GST_VAAPI_DISPLAY_PROP_RENDER_MODE "render-mode" #define DEFAULT_ROTATION GST_VAAPI_ROTATION_0
#define GST_VAAPI_DISPLAY_PROP_ROTATION "rotation"
enum { enum {
PROP_0, PROP_0,
@ -62,6 +62,8 @@ enum {
PROP_DISPLAY_TYPE, PROP_DISPLAY_TYPE,
PROP_WIDTH, PROP_WIDTH,
PROP_HEIGHT, PROP_HEIGHT,
PROP_RENDER_MODE,
PROP_ROTATION,
N_PROPERTIES N_PROPERTIES
}; };
@ -713,6 +715,12 @@ gst_vaapi_display_set_property(
case PROP_DISPLAY_TYPE: case PROP_DISPLAY_TYPE:
display->priv->display_type = g_value_get_enum(value); display->priv->display_type = g_value_get_enum(value);
break; break;
case PROP_RENDER_MODE:
gst_vaapi_display_set_render_mode(display, g_value_get_enum(value));
break;
case PROP_ROTATION:
gst_vaapi_display_set_rotation(display, g_value_get_enum(value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break; break;
@ -742,6 +750,16 @@ gst_vaapi_display_get_property(
case PROP_HEIGHT: case PROP_HEIGHT:
g_value_set_uint(value, gst_vaapi_display_get_height(display)); g_value_set_uint(value, gst_vaapi_display_get_height(display));
break; break;
case PROP_RENDER_MODE: {
GstVaapiRenderMode mode;
if (!gst_vaapi_display_get_render_mode(display, &mode))
mode = DEFAULT_RENDER_MODE;
g_value_set_enum(value, mode);
break;
}
case PROP_ROTATION:
g_value_set_enum(value, gst_vaapi_display_get_rotation(display));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break; break;
@ -809,6 +827,32 @@ gst_vaapi_display_class_init(GstVaapiDisplayClass *klass)
1, G_MAXUINT32, 1, 1, G_MAXUINT32, 1,
G_PARAM_READABLE); G_PARAM_READABLE);
/**
* GstVaapiDisplay:render-mode:
*
* The VA display rendering mode, expressed as a #GstVaapiRenderMode.
*/
g_properties[PROP_RENDER_MODE] =
g_param_spec_enum(GST_VAAPI_DISPLAY_PROP_RENDER_MODE,
"render mode",
"The display rendering mode",
GST_VAAPI_TYPE_RENDER_MODE,
DEFAULT_RENDER_MODE,
G_PARAM_READWRITE);
/**
* GstVaapiDisplay:rotation:
*
* The VA display rotation mode, expressed as a #GstVaapiRotation.
*/
g_properties[PROP_ROTATION] =
g_param_spec_enum(GST_VAAPI_DISPLAY_PROP_ROTATION,
"rotation",
"The display rotation mode",
GST_VAAPI_TYPE_ROTATION,
DEFAULT_ROTATION,
G_PARAM_READWRITE);
g_object_class_install_properties(object_class, N_PROPERTIES, g_properties); g_object_class_install_properties(object_class, N_PROPERTIES, g_properties);
} }
@ -1348,7 +1392,7 @@ get_render_mode_default(
#endif #endif
default: default:
/* This includes VA/X11 and VA/GLX modes */ /* This includes VA/X11 and VA/GLX modes */
*pmode = GST_VAAPI_RENDER_MODE_TEXTURE; *pmode = DEFAULT_RENDER_MODE;
break; break;
} }
return TRUE; return TRUE;
@ -1445,7 +1489,7 @@ gst_vaapi_display_get_rotation(GstVaapiDisplay *display)
{ {
gint value; gint value;
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), GST_VAAPI_ROTATION_0); g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), DEFAULT_ROTATION);
if (!get_attribute(display, VADisplayAttribRotation, &value)) if (!get_attribute(display, VADisplayAttribRotation, &value))
value = VA_ROTATION_NONE; value = VA_ROTATION_NONE;

View file

@ -96,6 +96,14 @@ struct _GstVaapiDisplayInfo {
gpointer native_display; gpointer native_display;
}; };
/**
* GstVaapiDisplayProperties:
* @GST_VAAPI_DISPLAY_PROP_RENDER_MODE: rendering mode (#GstVaapiRenderMode).
* @GST_VAAPI_DISPLAY_PROP_ROTATION: rotation angle (#GstVaapiRotation).
*/
#define GST_VAAPI_DISPLAY_PROP_RENDER_MODE "render-mode"
#define GST_VAAPI_DISPLAY_PROP_ROTATION "rotation"
/** /**
* GstVaapiDisplay: * GstVaapiDisplay:
* *