diff options
-rw-r--r-- | gst/vaapi/gstvaapipluginbase.c | 6 | ||||
-rw-r--r-- | gst/vaapi/gstvaapipluginutil.c | 33 | ||||
-rw-r--r-- | gst/vaapi/gstvaapivideocontext.c | 41 | ||||
-rw-r--r-- | gst/vaapi/gstvaapivideocontext.h | 2 |
4 files changed, 33 insertions, 49 deletions
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 18c35767..d23b519a 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -1215,10 +1215,8 @@ gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin) GstGLContext *gl_other_context = NULL, *gl_context = NULL; GstGLDisplay *gl_display = NULL; - if (!gst_gl_ensure_element_data (plugin, - (GstGLDisplay **) & plugin->gl_display, - (GstGLContext **) & plugin->gl_other_context)) - goto no_valid_gl_display; + if (!plugin->gl_display) + return NULL; gl_display = (GstGLDisplay *) plugin->gl_display; if (gst_gl_display_get_handle_type (gl_display) == GST_GL_DISPLAY_TYPE_ANY) diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index 0ff46bc0..fa25131e 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -246,9 +246,7 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object) static void 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,15 +255,32 @@ gst_vaapi_find_gl_context (GstElement * element) if (GST_IS_VIDEO_SINK (element) || GST_IS_VIDEO_ENCODER (element)) return; - gl_context = NULL; - if (!gst_vaapi_find_gl_local_context (element, &gl_context, &direction)) + if (!gst_gl_ensure_element_data (plugin, + (GstGLDisplay **) & plugin->gl_display, + (GstGLContext **) & plugin->gl_other_context)) + goto no_valid_gl_display; + + gst_vaapi_find_gl_local_context (element, &plugin->gl_context); + + if (plugin->gl_context) { + gst_vaapi_plugin_base_set_srcpad_can_dmabuf (plugin, plugin->gl_context); + } else { + GstObject *gl_context; + gl_context = gst_vaapi_plugin_base_create_gl_context (plugin); + if (gl_context) { + gst_vaapi_plugin_base_set_gl_context (plugin, gl_context); + gst_object_unref (gl_context); + } + } - if (gl_context) { - gst_vaapi_plugin_base_set_gl_context (plugin, gl_context); - if (direction == GST_PAD_SRC) - gst_vaapi_plugin_base_set_srcpad_can_dmabuf (plugin, gl_context); - gst_object_unref (gl_context); + /* ERRORS */ +no_valid_gl_display: + { + GST_INFO_OBJECT (plugin, "No valid GL display found"); + gst_object_replace (&plugin->gl_display, NULL); + gst_object_replace (&plugin->gl_other_context, NULL); + return; } } diff --git a/gst/vaapi/gstvaapivideocontext.c b/gst/vaapi/gstvaapivideocontext.c index 4c5a1d3c..70f73e5b 100644 --- a/gst/vaapi/gstvaapivideocontext.c +++ b/gst/vaapi/gstvaapivideocontext.c @@ -307,8 +307,6 @@ gst_vaapi_video_context_propagate (GstElement * element, * @element: the #GstElement where the search begins * @gl_context_ptr: the pointer where the GstGL context is going to be * stored - * @direction_ptr: the pointer of the #GstPadDirection where the GstGL - * context was found * * Query the pipeline, downstream and upstream for a GstGL context * @@ -316,42 +314,15 @@ gst_vaapi_video_context_propagate (GstElement * element, **/ gboolean gst_vaapi_find_gl_local_context (GstElement * element, - GstObject ** gl_context_ptr, GstPadDirection * direction_ptr) + GstObject ** gl_context_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)) { - gst_query_parse_context (query, &context); - 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)) { - gst_query_parse_context (query, &context); - 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; + GstGLContext **context_ptr = (GstGLContext **) gl_context_ptr; + + if (gst_gl_query_local_gl_context (element, GST_PAD_SRC, context_ptr)) + return TRUE; + if (gst_gl_query_local_gl_context (element, GST_PAD_SINK, context_ptr)) return TRUE; - } #endif return FALSE; } diff --git a/gst/vaapi/gstvaapivideocontext.h b/gst/vaapi/gstvaapivideocontext.h index cdac0f9b..8577ca45 100644 --- a/gst/vaapi/gstvaapivideocontext.h +++ b/gst/vaapi/gstvaapivideocontext.h @@ -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, GstPadDirection * direction); + GstObject ** gl_context_ptr); #endif /* GST_VAAPI_VIDEO_CONTEXT_H */ |