display: add display types.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 25 Jul 2012 07:16:02 +0000 (09:16 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 25 Jul 2012 12:37:11 +0000 (14:37 +0200)
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
gst-libs/gst/vaapi/gstvaapidisplay.h
gst-libs/gst/vaapi/gstvaapidisplay_glx.c
gst-libs/gst/vaapi/gstvaapidisplay_priv.h
gst-libs/gst/vaapi/gstvaapidisplay_x11.c
gst-libs/gst/vaapi/gstvaapidisplaycache.c
gst/vaapi/gstvaapipluginutil.c
gst/vaapi/gstvaapipluginutil.h
gst/vaapi/gstvaapisink.c

index e113f71..f4352bd 100644 (file)
@@ -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
index e68e9c3..81410ec 100644 (file)
@@ -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);
 
index ccf126a..87ac84a 100644 (file)
@@ -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);
 }
 
index 80ec99a..d48cc60 100644 (file)
@@ -74,6 +74,7 @@ G_BEGIN_DECLS
 struct _GstVaapiDisplayPrivate {
     GstVaapiDisplay    *parent;
     GStaticRecMutex     mutex;
+    GstVaapiDisplayType display_type;
     VADisplay           display;
     guint               width;
     guint               height;
index 6ad5ed1..1c89d15 100644 (file)
@@ -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;
 }
index 93178f4..0e6ef36 100644 (file)
@@ -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) {
index a092134..ad8ce88 100644 (file)
@@ -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;
-}
index fd53520..64aa8e9 100644 (file)
 
 #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
 gboolean
 gst_vaapi_ensure_display(
index 7a99219..ff43a06 100644 (file)
@@ -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