videocontext: support "gst.vaapi.app.Display" context
authorHyunjun Ko <zzoon@igalia.com>
Wed, 5 Jul 2017 06:31:55 +0000 (15:31 +0900)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 18 Jul 2017 16:51:41 +0000 (18:51 +0200)
Through "gst.vaapi.app.Display" context, users can set their own VADisplay
and native display of their backend.

Attributes:
- display : pointer of VADisplay
- x11-display : pointer of X11 display (Display *), if they're using.

This patch creates GstVaapidisplayX11 if information provided through
"gst.vaapi.app.Display"

https://bugzilla.gnome.org/show_bug.cgi?id=766704

gst/vaapi/gstvaapivideocontext.c
gst/vaapi/gstvaapivideocontext.h

index 5e9f9b7..214840b 100644 (file)
@@ -28,6 +28,9 @@
 #if USE_GST_GL_HELPERS
 # include <gst/gl/gl.h>
 #endif
+#if USE_X11
+#include <gst/vaapi/gstvaapidisplay_x11.h>
+#endif
 
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
 
@@ -78,12 +81,31 @@ gst_vaapi_video_context_get_display (GstContext * context,
   g_return_val_if_fail (GST_IS_CONTEXT (context), FALSE);
 
   type = gst_context_get_context_type (context);
-  if (g_strcmp0 (type, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME))
-    return FALSE;
 
-  structure = gst_context_get_structure (context);
-  return gst_structure_get (structure, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME,
-      GST_TYPE_VAAPI_DISPLAY, display_ptr, NULL);
+  if (!g_strcmp0 (type, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME)) {
+    structure = gst_context_get_structure (context);
+    return gst_structure_get (structure, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME,
+        GST_TYPE_VAAPI_DISPLAY, display_ptr, NULL);
+  } else if (!g_strcmp0 (type, GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME)) {
+    VADisplay va_display = NULL;
+    structure = gst_context_get_structure (context);
+
+    if (gst_structure_get (structure, "va-display", G_TYPE_POINTER, &va_display,
+            NULL)) {
+#if USE_X11
+      Display *x11_display = NULL;
+      if (gst_structure_get (structure, "x11-display", G_TYPE_POINTER,
+              &x11_display, NULL)) {
+        *display_ptr =
+            gst_vaapi_display_x11_new_with_va_display (va_display, x11_display);
+        return TRUE;
+      }
+#endif
+      GST_WARNING ("Not support if only VADisplay provided");
+    }
+  }
+
+  return FALSE;
 }
 
 static gboolean
@@ -204,8 +226,16 @@ gst_vaapi_video_context_prepare (GstElement * element,
 
   _gst_context_query (element, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME);
 
-  if (*display_ptr)
+  if (*display_ptr) {
     GST_LOG_OBJECT (element, "found a display (%p)", *display_ptr);
+    return TRUE;
+  }
+
+  _gst_context_query (element, GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME);
+
+  if (*display_ptr)
+    GST_LOG_OBJECT (element, "got a display with va display from app (%p)",
+        *display_ptr);
 
   return *display_ptr != NULL;
 }
index 437486b..0aaeb7e 100644 (file)
@@ -30,6 +30,7 @@
 #include <gst/vaapi/gstvaapidisplay.h>
 
 #define GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME "gst.vaapi.Display"
+#define GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME "gst.vaapi.app.Display"
 
 G_GNUC_INTERNAL
 void