vaapivideocontext: return the direction of gl context

In function gst_vaapi_find_gl_context() add a direction parameter to
return back the direction where the GstGL context was found.

This is going to be useful when checking if downstream can import
dmabuf-based buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=788503
This commit is contained in:
Víctor Manuel Jáquez Leal 2017-10-04 11:50:25 +02:00
parent 998e79ced6
commit 6b2b1294f8
3 changed files with 9 additions and 3 deletions

View file

@ -248,6 +248,7 @@ gst_vaapi_find_gl_context (GstElement * element)
{
GstObject *gl_context;
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
GstPadDirection direction = GST_PAD_UNKNOWN;
/* if the element is vaapisink or any vaapi encoder it doesn't need
* to know a GstGLContext in order to create an appropriate
@ -257,7 +258,7 @@ gst_vaapi_find_gl_context (GstElement * element)
return;
gl_context = NULL;
if (!gst_vaapi_find_gl_local_context (element, &gl_context))
if (!gst_vaapi_find_gl_local_context (element, &gl_context, &direction))
gl_context = gst_vaapi_plugin_base_create_gl_context (plugin);
if (gl_context) {

View file

@ -263,16 +263,18 @@ gst_vaapi_video_context_propagate (GstElement * element,
gboolean
gst_vaapi_find_gl_local_context (GstElement * element,
GstObject ** gl_context_ptr)
GstObject ** gl_context_ptr, GstPadDirection * direction_ptr)
{
#if USE_GST_GL_HELPERS
GstQuery *query;
GstContext *context;
const GstStructure *s;
GstObject *gl_context;
GstPadDirection direction;
g_return_val_if_fail (gl_context_ptr, FALSE);
direction = GST_PAD_UNKNOWN;
gl_context = NULL;
query = gst_query_new_context ("gst.gl.local_context");
if (_gst_context_run_query (element, query, GST_PAD_SRC)) {
@ -280,6 +282,7 @@ gst_vaapi_find_gl_local_context (GstElement * element,
if (context) {
s = gst_context_get_structure (context);
gst_structure_get (s, "context", GST_TYPE_GL_CONTEXT, &gl_context, NULL);
direction = GST_PAD_SRC;
}
}
if (!gl_context && _gst_context_run_query (element, query, GST_PAD_SINK)) {
@ -287,11 +290,13 @@ gst_vaapi_find_gl_local_context (GstElement * element,
if (context) {
s = gst_context_get_structure (context);
gst_structure_get (s, "context", GST_TYPE_GL_CONTEXT, &gl_context, NULL);
direction = GST_PAD_SINK;
}
}
gst_query_unref (query);
if (gl_context) {
*gl_context_ptr = gl_context;
*direction_ptr = direction;
return TRUE;
}
#endif

View file

@ -60,6 +60,6 @@ gst_vaapi_video_context_propagate (GstElement * element,
G_GNUC_INTERNAL
gboolean
gst_vaapi_find_gl_local_context (GstElement * element,
GstObject ** gl_context_ptr);
GstObject ** gl_context_ptr, GstPadDirection * direction);
#endif /* GST_VAAPI_VIDEO_CONTEXT_H */