plugins: add gst_vaapi_plugin_base_set_srcpad_can_dmabuf()
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 4 Oct 2017 06:30:51 +0000 (08:30 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 20 Oct 2017 14:36:04 +0000 (16:36 +0200)
This patch refactors the code by adding the function
vaapi_plugin_base_set_srcpad_can_dmabuf(), it determines if the passed
GstGLContext can handle dmabuf-based buffers.

The function is exposed publicly since it is intended to be used later
at GstVaapiDisplay instantiation.

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

gst/vaapi/gstvaapipluginbase.c
gst/vaapi/gstvaapipluginbase.h

index 318e567..120879a 100644 (file)
@@ -1182,12 +1182,7 @@ gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
       break;
 #endif
     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
+      gst_vaapi_plugin_base_set_srcpad_can_dmabuf (plugin, object);
 #if USE_EGL
       display_type = GST_VAAPI_DISPLAY_TYPE_EGL;
       break;
@@ -1337,3 +1332,27 @@ gst_vaapi_plugin_base_get_allowed_raw_caps (GstVaapiPluginBase * plugin)
     return NULL;
   return plugin->allowed_raw_caps;
 }
+
+/**
+ * gst_vaapi_plugin_base_set_srcpad_can_dmabuf:
+ * @plugin: a #GstVaapiPluginBase
+ * @object: the GL context from gst-gl
+ *
+ * This function will determine if @object supports dmabuf
+ * importing.
+ *
+ * Please note that the context @object should come from downstream.
+ **/
+void
+gst_vaapi_plugin_base_set_srcpad_can_dmabuf (GstVaapiPluginBase * plugin,
+    GstObject * object)
+{
+#if VA_CHECK_VERSION (0,36,0) && USE_EGL && USE_GST_GL_HELPERS
+  GstGLContext *const gl_context = GST_GL_CONTEXT (object);
+
+  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
+}
index 276e130..f085482 100644 (file)
@@ -247,6 +247,11 @@ G_GNUC_INTERNAL
 GstCaps *
 gst_vaapi_plugin_base_get_allowed_raw_caps (GstVaapiPluginBase * plugin);
 
+G_GNUC_INTERNAL
+void
+gst_vaapi_plugin_base_set_srcpad_can_dmabuf (GstVaapiPluginBase * plugin,
+    GstObject * object);
+
 G_END_DECLS
 
 #endif /* GST_VAAPI_PLUGIN_BASE_H */