display: add display types.

Move display types from gstvaapipluginutil.* to gstvaapidisplay.* so that
we could simplify characterization of a GstVaapiDisplay. Also rename "auto"
type to "any", and add a "display-type" attribute.
This commit is contained in:
Gwenole Beauchesne 2012-07-25 09:16:02 +02:00
parent 411b970f8a
commit 437bc925f6
9 changed files with 93 additions and 46 deletions

View file

@ -49,6 +49,7 @@ enum {
PROP_0, PROP_0,
PROP_DISPLAY, PROP_DISPLAY,
PROP_DISPLAY_TYPE,
PROP_WIDTH, PROP_WIDTH,
PROP_HEIGHT PROP_HEIGHT
}; };
@ -80,6 +81,29 @@ free_display_cache(void)
g_display_cache = NULL; g_display_cache = NULL;
} }
/* GstVaapiDisplayType enumerations */
GType
gst_vaapi_display_type_get_type(void)
{
static GType g_type = 0;
static const GEnumValue display_types[] = {
{ GST_VAAPI_DISPLAY_TYPE_ANY,
"Auto detection", "any" },
{ GST_VAAPI_DISPLAY_TYPE_X11,
"VA/X11 display", "x11" },
#if USE_GLX
{ GST_VAAPI_DISPLAY_TYPE_GLX,
"VA/GLX display", "glx" },
#endif
{ 0, NULL, NULL },
};
if (!g_type)
g_type = g_enum_register_static("GstVaapiDisplayType", display_types);
return g_type;
}
/* Append GstVaapiImageFormat to formats array */ /* Append GstVaapiImageFormat to formats array */
static inline void static inline void
append_format(GArray *formats, GstVaapiImageFormat format) append_format(GArray *formats, GstVaapiImageFormat format)
@ -378,6 +402,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
info.display = display; info.display = display;
info.display_type = priv->display_type;
if (priv->display) if (priv->display)
info.va_display = priv->display; info.va_display = priv->display;
@ -388,6 +413,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
if (!klass->get_display || !klass->get_display(display, &info)) if (!klass->get_display || !klass->get_display(display, &info))
return FALSE; return FALSE;
priv->display = info.va_display; priv->display = info.va_display;
priv->display_type = info.display_type;
if (klass->get_size) if (klass->get_size)
klass->get_size(display, &priv->width, &priv->height); klass->get_size(display, &priv->width, &priv->height);
if (klass->get_size_mm) if (klass->get_size_mm)
@ -407,6 +433,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
if (cached_info) { if (cached_info) {
g_clear_object(&priv->parent); g_clear_object(&priv->parent);
priv->parent = g_object_ref(cached_info->display); priv->parent = g_object_ref(cached_info->display);
priv->display_type = cached_info->display_type;
} }
if (!priv->parent) { if (!priv->parent) {
@ -567,6 +594,9 @@ gst_vaapi_display_set_property(
case PROP_DISPLAY: case PROP_DISPLAY:
display->priv->display = g_value_get_pointer(value); display->priv->display = g_value_get_pointer(value);
break; break;
case PROP_DISPLAY_TYPE:
display->priv->display_type = 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;
@ -587,6 +617,9 @@ gst_vaapi_display_get_property(
case PROP_DISPLAY: case PROP_DISPLAY:
g_value_set_pointer(value, gst_vaapi_display_get_display(display)); g_value_set_pointer(value, gst_vaapi_display_get_display(display));
break; break;
case PROP_DISPLAY_TYPE:
g_value_set_enum(value, gst_vaapi_display_get_display_type(display));
break;
case PROP_WIDTH: case PROP_WIDTH:
g_value_set_uint(value, gst_vaapi_display_get_width(display)); g_value_set_uint(value, gst_vaapi_display_get_width(display));
break; break;
@ -640,6 +673,16 @@ gst_vaapi_display_class_init(GstVaapiDisplayClass *klass)
"VA display", "VA display",
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class,
PROP_DISPLAY_TYPE,
g_param_spec_enum("display-type",
"VA display type",
"VA display type",
GST_VAAPI_TYPE_DISPLAY_TYPE,
GST_VAAPI_DISPLAY_TYPE_ANY,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property g_object_class_install_property
(object_class, (object_class,
PROP_WIDTH, PROP_WIDTH,
@ -666,6 +709,7 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
display->priv = priv; display->priv = priv;
priv->parent = NULL; priv->parent = NULL;
priv->display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
priv->display = NULL; priv->display = NULL;
priv->width = 0; priv->width = 0;
priv->height = 0; priv->height = 0;
@ -795,6 +839,23 @@ gst_vaapi_display_flush(GstVaapiDisplay *display)
klass->flush(display); klass->flush(display);
} }
/**
* gst_vaapi_display_get_display:
* @display: a #GstVaapiDisplay
*
* Returns the #GstVaapiDisplayType bound to @display.
*
* Return value: the #GstVaapiDisplayType
*/
GstVaapiDisplayType
gst_vaapi_display_get_display_type(GstVaapiDisplay *display)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display),
GST_VAAPI_DISPLAY_TYPE_ANY);
return display->priv->display_type;
}
/** /**
* gst_vaapi_display_get_display: * gst_vaapi_display_get_display:
* @display: a #GstVaapiDisplay * @display: a #GstVaapiDisplay

View file

@ -54,11 +54,30 @@ G_BEGIN_DECLS
GST_VAAPI_TYPE_DISPLAY, \ GST_VAAPI_TYPE_DISPLAY, \
GstVaapiDisplayClass)) GstVaapiDisplayClass))
typedef enum _GstVaapiDisplayType GstVaapiDisplayType;
typedef struct _GstVaapiDisplayInfo GstVaapiDisplayInfo; typedef struct _GstVaapiDisplayInfo GstVaapiDisplayInfo;
typedef struct _GstVaapiDisplay GstVaapiDisplay; typedef struct _GstVaapiDisplay GstVaapiDisplay;
typedef struct _GstVaapiDisplayPrivate GstVaapiDisplayPrivate; typedef struct _GstVaapiDisplayPrivate GstVaapiDisplayPrivate;
typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass; typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
/**
* GstVaapiDisplayType:
* @GST_VAAPI_DISPLAY_TYPE_ANY: Automatic detection of the display type.
* @GST_VAAPI_DISPLAY_TYPE_X11: VA/X11 display.
* @GST_VAAPI_DISPLAY_TYPE_GLX: VA/GLX display.
*/
enum _GstVaapiDisplayType {
GST_VAAPI_DISPLAY_TYPE_ANY = 0,
GST_VAAPI_DISPLAY_TYPE_X11,
GST_VAAPI_DISPLAY_TYPE_GLX,
};
#define GST_VAAPI_TYPE_DISPLAY_TYPE \
(gst_vaapi_display_type_get_type())
GType
gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
/** /**
* GstVaapiDisplayInfo: * GstVaapiDisplayInfo:
* *
@ -66,6 +85,7 @@ typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
*/ */
struct _GstVaapiDisplayInfo { struct _GstVaapiDisplayInfo {
GstVaapiDisplay *display; GstVaapiDisplay *display;
GstVaapiDisplayType display_type;
gchar *display_name; gchar *display_name;
VADisplay va_display; VADisplay va_display;
gpointer native_display; gpointer native_display;
@ -134,6 +154,9 @@ gst_vaapi_display_sync(GstVaapiDisplay *display);
void void
gst_vaapi_display_flush(GstVaapiDisplay *display); gst_vaapi_display_flush(GstVaapiDisplay *display);
GstVaapiDisplayType
gst_vaapi_display_get_display_type(GstVaapiDisplay *display);
VADisplay VADisplay
gst_vaapi_display_get_display(GstVaapiDisplay *display); gst_vaapi_display_get_display(GstVaapiDisplay *display);

View file

@ -59,6 +59,7 @@ gst_vaapi_display_glx_get_display_info(
info->va_display = vaGetDisplayGLX(GST_VAAPI_DISPLAY_XDISPLAY(display)); info->va_display = vaGetDisplayGLX(GST_VAAPI_DISPLAY_XDISPLAY(display));
if (!info->va_display) if (!info->va_display)
return FALSE; return FALSE;
info->display_type = GST_VAAPI_DISPLAY_TYPE_GLX;
return dpy_class->get_display(display, info); return dpy_class->get_display(display, info);
} }

View file

@ -74,6 +74,7 @@ G_BEGIN_DECLS
struct _GstVaapiDisplayPrivate { struct _GstVaapiDisplayPrivate {
GstVaapiDisplay *parent; GstVaapiDisplay *parent;
GStaticRecMutex mutex; GStaticRecMutex mutex;
GstVaapiDisplayType display_type;
VADisplay display; VADisplay display;
guint width; guint width;
guint height; guint height;

View file

@ -341,6 +341,7 @@ gst_vaapi_display_x11_get_display_info(
info->va_display = vaGetDisplay(priv->x11_display); info->va_display = vaGetDisplay(priv->x11_display);
if (!info->va_display) if (!info->va_display)
return FALSE; return FALSE;
info->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
} }
return TRUE; return TRUE;
} }

View file

@ -68,6 +68,7 @@ cache_entry_new(const GstVaapiDisplayInfo *di)
info->display = di->display; info->display = di->display;
info->va_display = di->va_display; info->va_display = di->va_display;
info->native_display = di->native_display; info->native_display = di->native_display;
info->display_type = di->display_type;
info->display_name = NULL; info->display_name = NULL;
if (di->display_name) { if (di->display_name) {

View file

@ -71,7 +71,7 @@ gst_vaapi_ensure_display(
) )
{ {
GstVaapiDisplayType display_type = GstVaapiDisplayType display_type =
display_type_ptr ? *display_type_ptr : GST_VAAPI_DISPLAY_TYPE_AUTO; display_type_ptr ? *display_type_ptr : GST_VAAPI_DISPLAY_TYPE_ANY;
GstVaapiDisplay *display; GstVaapiDisplay *display;
GstVideoContext *context; GstVideoContext *context;
const DisplayMap *m; const DisplayMap *m;
@ -89,7 +89,7 @@ gst_vaapi_ensure_display(
/* If no neighboor, or application not interested, use system default */ /* If no neighboor, or application not interested, use system default */
for (m = g_display_map; m->type_str != NULL; m++) { for (m = g_display_map; m->type_str != NULL; m++) {
if (display_type != GST_VAAPI_DISPLAY_TYPE_AUTO && if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY &&
display_type != m->type) display_type != m->type)
continue; continue;
@ -104,7 +104,7 @@ gst_vaapi_ensure_display(
display = NULL; display = NULL;
} }
if (display_type != GST_VAAPI_DISPLAY_TYPE_AUTO) if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY)
break; break;
} }
@ -232,25 +232,3 @@ gst_vaapi_append_surface_caps(GstCaps *out_caps, GstCaps *in_caps)
} }
return TRUE; return TRUE;
} }
GType
gst_vaapi_display_type_get_type(void)
{
static GType g_type = 0;
static const GEnumValue display_types[] = {
{ GST_VAAPI_DISPLAY_TYPE_AUTO,
"Auto detection", "auto" },
{ GST_VAAPI_DISPLAY_TYPE_X11,
"VA/X11 display", "x11" },
#if USE_GLX
{ GST_VAAPI_DISPLAY_TYPE_GLX,
"VA/GLX display", "glx" },
#endif
{ 0, NULL, NULL },
};
if (!g_type)
g_type = g_enum_register_static("GstVaapiDisplayType", display_types);
return g_type;
}

View file

@ -26,25 +26,6 @@
#include <gst/vaapi/gstvaapidisplay.h> #include <gst/vaapi/gstvaapidisplay.h>
/**
* GstVaapiDisplayType:
* @GST_VAAPI_DISPLAY_TYPE_AUTO: Automatic detection of the display type.
* @GST_VAAPI_DISPLAY_TYPE_X11: VA/X11 display.
* @GST_VAAPI_DISPLAY_TYPE_GLX: VA/GLX display.
*/
typedef enum _GstVaapiDisplayType GstVaapiDisplayType;
enum _GstVaapiDisplayType {
GST_VAAPI_DISPLAY_TYPE_AUTO = 0,
GST_VAAPI_DISPLAY_TYPE_X11,
GST_VAAPI_DISPLAY_TYPE_GLX,
};
#define GST_VAAPI_TYPE_DISPLAY_TYPE \
gst_vaapi_display_type_get_type()
GType
gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
G_GNUC_INTERNAL G_GNUC_INTERNAL
gboolean gboolean
gst_vaapi_ensure_display( gst_vaapi_ensure_display(

View file

@ -99,7 +99,7 @@ enum {
PROP_USE_REFLECTION PROP_USE_REFLECTION
}; };
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_AUTO #define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
/* GstImplementsInterface interface */ /* GstImplementsInterface interface */
@ -818,7 +818,7 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
"display type", "display type",
"display type to use", "display type to use",
GST_VAAPI_TYPE_DISPLAY_TYPE, GST_VAAPI_TYPE_DISPLAY_TYPE,
GST_VAAPI_DISPLAY_TYPE_AUTO, GST_VAAPI_DISPLAY_TYPE_ANY,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#if USE_GLX #if USE_GLX