plugins: add gst_vaapi_plugin_base_set_srcpad_can_dmabuf()

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
This commit is contained in:
Víctor Manuel Jáquez Leal 2017-10-04 08:30:51 +02:00
parent 8ef3bc3cc2
commit 998e79ced6
2 changed files with 30 additions and 6 deletions

View 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
}

View 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 */