plugins: use new display types more.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 25 Jul 2012 12:51:28 +0000 (14:51 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 25 Jul 2012 13:03:48 +0000 (15:03 +0200)
In particular, simplify gst_vaapi_reply_to_query() with display types.
Likewise for creating new video buffers.

gst/vaapi/gstvaapipluginbuffer.c
gst/vaapi/gstvaapipluginutil.c

index 225318e..7005a2b 100644 (file)
 #endif
 #include "gstvaapipluginbuffer.h"
 
-static inline GType
+static GType
 get_type(GstVaapiDisplay *display)
 {
+    GType type;
+
+    switch (gst_vaapi_display_get_display_type(display)) {
 #if USE_GLX
-    if (GST_VAAPI_IS_DISPLAY_GLX(display))
-        return GST_VAAPI_TYPE_VIDEO_BUFFER_GLX;
+    case GST_VAAPI_DISPLAY_TYPE_GLX:
+        type = GST_VAAPI_TYPE_VIDEO_BUFFER_GLX;
+        break;
 #endif
-    return GST_VAAPI_TYPE_VIDEO_BUFFER;
+    default:
+        type = GST_VAAPI_TYPE_VIDEO_BUFFER;
+        break;
+    }
+    return type;
 }
 
 GstBuffer *
index 6c731a6..3ae3d23 100644 (file)
@@ -161,6 +161,7 @@ gst_vaapi_set_display(
 gboolean
 gst_vaapi_reply_to_query(GstQuery *query, GstVaapiDisplay *display)
 {
+    GstVaapiDisplayType display_type;
     const gchar **types;
     const gchar *type;
     gint i;
@@ -174,9 +175,11 @@ gst_vaapi_reply_to_query(GstQuery *query, GstVaapiDisplay *display)
     if (!types)
         return FALSE;
 
-    for (i = 0; types[i]; i++) {
+    display_type = gst_vaapi_display_get_display_type(display);
+    for (i = 0; types[i] && !res; i++) {
         type = types[i];
 
+        res = TRUE;
         if (!strcmp(type, "gst-vaapi-display")) {
             gst_video_context_query_set_object(query, type, G_OBJECT(display));
         }
@@ -184,25 +187,30 @@ gst_vaapi_reply_to_query(GstQuery *query, GstVaapiDisplay *display)
             VADisplay vadpy = gst_vaapi_display_get_display(display);
             gst_video_context_query_set_pointer(query, type, vadpy);
         }
-        else if (!strcmp(type, "x11-display") &&
-                 GST_VAAPI_IS_DISPLAY_X11(display)) {
-            GstVaapiDisplayX11 *xvadpy = GST_VAAPI_DISPLAY_X11(display);
-            Display *x11dpy = gst_vaapi_display_x11_get_display(xvadpy);
-            gst_video_context_query_set_pointer(query, type, x11dpy);
-            
-        }
-        else if (!strcmp(type, "x11-display-name") &&
-                 GST_VAAPI_IS_DISPLAY_X11(display)) {
-            GstVaapiDisplayX11 *xvadpy = GST_VAAPI_DISPLAY_X11(display);
-            Display *x11dpy = gst_vaapi_display_x11_get_display(xvadpy);
-            gst_video_context_query_set_string(query, type, DisplayString(x11dpy));
-        }
         else {
-            continue;
+            switch (display_type) {
+#if USE_GLX
+            case GST_VAAPI_DISPLAY_TYPE_GLX:
+#endif
+            case GST_VAAPI_DISPLAY_TYPE_X11: {
+                GstVaapiDisplayX11 * const xvadpy =
+                    GST_VAAPI_DISPLAY_X11(display);
+                Display * const x11dpy =
+                    gst_vaapi_display_x11_get_display(xvadpy);
+                if (!strcmp(type, "x11-display"))
+                    gst_video_context_query_set_pointer(query, type, x11dpy);
+                else if (!strcmp(type, "x11-display-name"))
+                    gst_video_context_query_set_string(query, type,
+                        DisplayString(x11dpy));
+                else
+                    res = FALSE;
+                break;
+            }
+            default:
+                res = FALSE;
+                break;
+            }
         }
-
-        res = TRUE;
-        break;
     }
     return res;
 }