summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon@igalia.com>2017-07-05 15:31:55 +0900
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-07-18 18:51:41 +0200
commitb8265db2600e123ca921d710ff73b7cd3b330ede (patch)
tree581b390695afc98745a1c6660c8d2eddd9d7c8be
parentd78e094fd4bc112b40872de07b078455989292cc (diff)
videocontext: support "gst.vaapi.app.Display" context
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
-rw-r--r--gst/vaapi/gstvaapivideocontext.c42
-rw-r--r--gst/vaapi/gstvaapivideocontext.h1
2 files changed, 37 insertions, 6 deletions
diff --git a/gst/vaapi/gstvaapivideocontext.c b/gst/vaapi/gstvaapivideocontext.c
index 5e9f9b70..214840bc 100644
--- a/gst/vaapi/gstvaapivideocontext.c
+++ b/gst/vaapi/gstvaapivideocontext.c
@@ -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;
}
diff --git a/gst/vaapi/gstvaapivideocontext.h b/gst/vaapi/gstvaapivideocontext.h
index 437486b2..0aaeb7e8 100644
--- a/gst/vaapi/gstvaapivideocontext.h
+++ b/gst/vaapi/gstvaapivideocontext.h
@@ -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