From 37b774393413aec9c444bc45f08be2bf385e3be2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 2 Jun 2016 22:13:51 +0200 Subject: [PATCH] plugins: check if negotiate dmabuf with downstream 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 --- gst/vaapi/gstvaapipluginbase.c | 8 +++++++- gst/vaapi/gstvaapipluginbase.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index f2929db..8c23110 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -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 diff --git a/gst/vaapi/gstvaapipluginbase.h b/gst/vaapi/gstvaapipluginbase.h index e1db5e7..bfeeb10 100644 --- a/gst/vaapi/gstvaapipluginbase.h +++ b/gst/vaapi/gstvaapipluginbase.h @@ -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 -- 2.7.4