From 437bc925f66b4f6bede4078203a6f8b72449e973 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 25 Jul 2012 09:16:02 +0200 Subject: [PATCH] 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. --- gst-libs/gst/vaapi/gstvaapidisplay.c | 61 +++++++++++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapidisplay.h | 23 ++++++++++++ gst-libs/gst/vaapi/gstvaapidisplay_glx.c | 1 + gst-libs/gst/vaapi/gstvaapidisplay_priv.h | 1 + gst-libs/gst/vaapi/gstvaapidisplay_x11.c | 1 + gst-libs/gst/vaapi/gstvaapidisplaycache.c | 1 + gst/vaapi/gstvaapipluginutil.c | 28 ++------------ gst/vaapi/gstvaapipluginutil.h | 19 ---------- gst/vaapi/gstvaapisink.c | 4 +- 9 files changed, 93 insertions(+), 46 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c index e113f71..f4352bd 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay.c @@ -49,6 +49,7 @@ enum { PROP_0, PROP_DISPLAY, + PROP_DISPLAY_TYPE, PROP_WIDTH, PROP_HEIGHT }; @@ -80,6 +81,29 @@ free_display_cache(void) 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 */ static inline void append_format(GArray *formats, GstVaapiImageFormat format) @@ -378,6 +402,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display) memset(&info, 0, sizeof(info)); info.display = display; + info.display_type = priv->display_type; if (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)) return FALSE; priv->display = info.va_display; + priv->display_type = info.display_type; if (klass->get_size) klass->get_size(display, &priv->width, &priv->height); if (klass->get_size_mm) @@ -407,6 +433,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display) if (cached_info) { g_clear_object(&priv->parent); priv->parent = g_object_ref(cached_info->display); + priv->display_type = cached_info->display_type; } if (!priv->parent) { @@ -567,6 +594,9 @@ gst_vaapi_display_set_property( case PROP_DISPLAY: display->priv->display = g_value_get_pointer(value); break; + case PROP_DISPLAY_TYPE: + display->priv->display_type = g_value_get_enum(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -587,6 +617,9 @@ gst_vaapi_display_get_property( case PROP_DISPLAY: g_value_set_pointer(value, gst_vaapi_display_get_display(display)); break; + case PROP_DISPLAY_TYPE: + g_value_set_enum(value, gst_vaapi_display_get_display_type(display)); + break; case PROP_WIDTH: g_value_set_uint(value, gst_vaapi_display_get_width(display)); break; @@ -642,6 +675,16 @@ gst_vaapi_display_class_init(GstVaapiDisplayClass *klass) 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 + (object_class, PROP_WIDTH, g_param_spec_uint("width", "Width", @@ -666,6 +709,7 @@ gst_vaapi_display_init(GstVaapiDisplay *display) display->priv = priv; priv->parent = NULL; + priv->display_type = GST_VAAPI_DISPLAY_TYPE_ANY; priv->display = NULL; priv->width = 0; priv->height = 0; @@ -799,6 +843,23 @@ gst_vaapi_display_flush(GstVaapiDisplay *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: + * @display: a #GstVaapiDisplay + * * Returns the #VADisplay bound to @display. * * Return value: the #VADisplay diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.h b/gst-libs/gst/vaapi/gstvaapidisplay.h index e68e9c3..81410ec 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay.h @@ -54,18 +54,38 @@ G_BEGIN_DECLS GST_VAAPI_TYPE_DISPLAY, \ GstVaapiDisplayClass)) +typedef enum _GstVaapiDisplayType GstVaapiDisplayType; typedef struct _GstVaapiDisplayInfo GstVaapiDisplayInfo; typedef struct _GstVaapiDisplay GstVaapiDisplay; typedef struct _GstVaapiDisplayPrivate GstVaapiDisplayPrivate; 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: * * Generic class to retrieve VA display info */ struct _GstVaapiDisplayInfo { GstVaapiDisplay *display; + GstVaapiDisplayType display_type; gchar *display_name; VADisplay va_display; gpointer native_display; @@ -134,6 +154,9 @@ gst_vaapi_display_sync(GstVaapiDisplay *display); void gst_vaapi_display_flush(GstVaapiDisplay *display); +GstVaapiDisplayType +gst_vaapi_display_get_display_type(GstVaapiDisplay *display); + VADisplay gst_vaapi_display_get_display(GstVaapiDisplay *display); diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_glx.c b/gst-libs/gst/vaapi/gstvaapidisplay_glx.c index ccf126a..87ac84a 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_glx.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay_glx.c @@ -59,6 +59,7 @@ gst_vaapi_display_glx_get_display_info( info->va_display = vaGetDisplayGLX(GST_VAAPI_DISPLAY_XDISPLAY(display)); if (!info->va_display) return FALSE; + info->display_type = GST_VAAPI_DISPLAY_TYPE_GLX; return dpy_class->get_display(display, info); } diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h index 80ec99a..d48cc60 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h @@ -74,6 +74,7 @@ G_BEGIN_DECLS struct _GstVaapiDisplayPrivate { GstVaapiDisplay *parent; GStaticRecMutex mutex; + GstVaapiDisplayType display_type; VADisplay display; guint width; guint height; diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_x11.c b/gst-libs/gst/vaapi/gstvaapidisplay_x11.c index 6ad5ed1..1c89d15 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_x11.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay_x11.c @@ -341,6 +341,7 @@ gst_vaapi_display_x11_get_display_info( info->va_display = vaGetDisplay(priv->x11_display); if (!info->va_display) return FALSE; + info->display_type = GST_VAAPI_DISPLAY_TYPE_X11; } return TRUE; } diff --git a/gst-libs/gst/vaapi/gstvaapidisplaycache.c b/gst-libs/gst/vaapi/gstvaapidisplaycache.c index 93178f4..0e6ef36 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplaycache.c +++ b/gst-libs/gst/vaapi/gstvaapidisplaycache.c @@ -68,6 +68,7 @@ cache_entry_new(const GstVaapiDisplayInfo *di) info->display = di->display; info->va_display = di->va_display; info->native_display = di->native_display; + info->display_type = di->display_type; info->display_name = NULL; if (di->display_name) { diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index a092134..ad8ce88 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -71,7 +71,7 @@ gst_vaapi_ensure_display( ) { 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; GstVideoContext *context; const DisplayMap *m; @@ -89,7 +89,7 @@ gst_vaapi_ensure_display( /* If no neighboor, or application not interested, use system default */ 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) continue; @@ -104,7 +104,7 @@ gst_vaapi_ensure_display( display = NULL; } - if (display_type != GST_VAAPI_DISPLAY_TYPE_AUTO) + if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY) break; } @@ -232,25 +232,3 @@ gst_vaapi_append_surface_caps(GstCaps *out_caps, GstCaps *in_caps) } 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; -} diff --git a/gst/vaapi/gstvaapipluginutil.h b/gst/vaapi/gstvaapipluginutil.h index fd53520..64aa8e9 100644 --- a/gst/vaapi/gstvaapipluginutil.h +++ b/gst/vaapi/gstvaapipluginutil.h @@ -26,25 +26,6 @@ #include -/** - * 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 gboolean gst_vaapi_ensure_display( diff --git a/gst/vaapi/gstvaapisink.c b/gst/vaapi/gstvaapisink.c index 7a99219..ff43a06 100644 --- a/gst/vaapi/gstvaapisink.c +++ b/gst/vaapi/gstvaapisink.c @@ -99,7 +99,7 @@ enum { PROP_USE_REFLECTION }; -#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_AUTO +#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY /* GstImplementsInterface interface */ @@ -818,7 +818,7 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass) "display type", "display type to use", GST_VAAPI_TYPE_DISPLAY_TYPE, - GST_VAAPI_DISPLAY_TYPE_AUTO, + GST_VAAPI_DISPLAY_TYPE_ANY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); #if USE_GLX -- 2.7.4