plugins: check if negotiate dmabuf with downstream
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Thu, 2 Jun 2016 20:13:51 +0000 (22:13 +0200)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Thu, 2 Feb 2017 19:33:36 +0000 (20:33 +0100)
In order to enable, in the future, dmabuf-based buffers, the vaapi base
plugin needs to check if downstream can import dmabuf buffers.

This patch checks if downstream can handle dmabuf, by introspecting the
shared GL context. If the GL context is EGL/GLES2 and have the extension
EGL_EXT_image_dma_buf_import, then dmabuf can be negotiated.

Original-patch-by: Julien Isorce <j.isorce@samsung.com>
gst/vaapi/gstvaapipluginbase.c
gst/vaapi/gstvaapipluginbase.h

index f2929db..8c23110 100644 (file)
@@ -1103,8 +1103,14 @@ gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
       display_type = GST_VAAPI_DISPLAY_TYPE_GLX;
       break;
 #endif
-#if USE_EGL
     case GST_GL_PLATFORM_EGL:
+#if VA_CHECK_VERSION (0,36,0) && USE_GST_GL_HELPERS
+      plugin->srcpad_can_dmabuf =
+          (!(gst_gl_context_get_gl_api (gl_context) & GST_GL_API_GLES1)
+          && gst_gl_context_check_feature (gl_context,
+              "EGL_EXT_image_dma_buf_import"));
+#endif
+#if USE_EGL
       display_type = GST_VAAPI_DISPLAY_TYPE_EGL;
       break;
 #endif
index e1db5e7..bfeeb10 100644 (file)
@@ -87,6 +87,8 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_caps)
 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_INFO(plugin) \
   (&GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_info)
+#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAN_DMABUF(plugin) \
+  (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_can_dmabuf)
 
 #define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
   (GST_VAAPI_PLUGIN_BASE(plugin)->display)
@@ -146,6 +148,7 @@ struct _GstVaapiPluginBase
   GstCaps *allowed_raw_caps;
   GstAllocator *sinkpad_allocator;
   GstAllocator *srcpad_allocator;
+  gboolean srcpad_can_dmabuf;
 };
 
 struct _GstVaapiPluginBaseClass