From: Matthew Waters Date: Thu, 12 Jan 2017 10:35:25 +0000 (+1100) Subject: gl/utils: also take care of the local GL context in query functions X-Git-Tag: 1.19.3~509^2~1695^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd9db288b26bf3f902cdc75242c644cbd3f3a539;p=platform%2Fupstream%2Fgstreamer.git gl/utils: also take care of the local GL context in query functions Simplifies a deduplicates a lot of code in elements retrieving/setting the local OpenGL context. --- diff --git a/ext/qt/gstqtsink.cc b/ext/qt/gstqtsink.cc index 70e6858..2253156 100644 --- a/ext/qt/gstqtsink.cc +++ b/ext/qt/gstqtsink.cc @@ -239,41 +239,9 @@ gst_qt_sink_query (GstBaseSink * bsink, GstQuery * query) switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CONTEXT: { - const gchar *context_type; - GstContext *context, *old_context; - gboolean ret; - - ret = gst_gl_handle_context_query ((GstElement *) qt_sink, query, - &qt_sink->display, &qt_sink->qt_context); - - if (qt_sink->display) - gst_gl_display_filter_gl_api (qt_sink->display, gst_gl_context_get_gl_api (qt_sink->qt_context)); - - gst_query_parse_context_type (query, &context_type); - - if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) { - GstStructure *s; - - gst_query_parse_context (query, &old_context); - - if (old_context) - context = gst_context_copy (old_context); - else - context = gst_context_new ("gst.gl.local_context", FALSE); - - s = gst_context_writable_structure (context); - gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, qt_sink->context, - NULL); - gst_query_set_context (query, context); - gst_context_unref (context); - - ret = qt_sink->context != NULL; - } - GST_LOG_OBJECT (qt_sink, "context query of type %s %i", context_type, - ret); - - if (ret) - return ret; + if (gst_gl_handle_context_query ((GstElement *) qt_sink, query, + qt_sink->display, qt_sink->context, qt_sink->qt_context)) + return TRUE; /* fallthrough */ } diff --git a/ext/qt/gstqtsrc.cc b/ext/qt/gstqtsrc.cc index 849018e..518a5f3 100644 --- a/ext/qt/gstqtsrc.cc +++ b/ext/qt/gstqtsrc.cc @@ -283,10 +283,6 @@ gst_qt_src_query (GstBaseSrc * bsrc, GstQuery * query) switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CONTEXT: { - const gchar *context_type; - GstContext *context, *old_context; - gboolean ret; - if (!qt_window_is_scenegraph_initialized (qt_src->window)) return FALSE; @@ -295,37 +291,9 @@ gst_qt_src_query (GstBaseSrc * bsrc, GstQuery * query) qt_src->qt_context = qt_window_get_qt_context (qt_src->window); } - ret = gst_gl_handle_context_query ((GstElement *) qt_src, query, - &qt_src->display, &qt_src->qt_context); - - if (qt_src->display) - gst_gl_display_filter_gl_api (qt_src->display, - gst_gl_context_get_gl_api (qt_src->qt_context)); - - gst_query_parse_context_type (query, &context_type); - - if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) { - GstStructure *s; - - gst_query_parse_context (query, &old_context); - - if (old_context) - context = gst_context_copy (old_context); - else - context = gst_context_new ("gst.gl.app_context", FALSE); - - s = gst_context_writable_structure (context); - gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, - qt_src->qt_context, NULL); - gst_query_set_context (query, context); - gst_context_unref (context); - - ret = qt_src->qt_context != NULL; - } - GST_LOG_OBJECT (qt_src, "context query of type %s %i", context_type, ret); - - if (ret) - return ret; + if (gst_gl_handle_context_query ((GstElement *) qt_src, query, + qt_src->display, qt_src->context, qt_src->qt_context)) + return TRUE; /* fallthrough */ } @@ -340,31 +308,9 @@ gst_qt_src_query (GstBaseSrc * bsrc, GstQuery * query) static gboolean _find_local_gl_context (GstQtSrc * qt_src) { - GstQuery *query; - GstContext *context; - const GstStructure *s; - - if (qt_src->context) - return TRUE; - - query = gst_query_new_context ("gst.gl.local_context"); - if (!qt_src->context - && gst_gl_run_query (GST_ELEMENT (qt_src), 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, &qt_src->context, - NULL); - } - } - - GST_DEBUG_OBJECT (qt_src, "found local context %p", qt_src->context); - - gst_query_unref (query); - - if (qt_src->context) + if (gst_gl_query_local_gl_context (GST_ELEMENT (qt_src), GST_PAD_SRC, + &qt_src->context)) return TRUE; - return FALSE; }