summaryrefslogtreecommitdiff
path: root/ext/qt
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2017-01-12 21:35:25 +1100
committerMatthew Waters <matthew@centricular.com>2017-01-13 11:20:51 +1100
commit4315a4b54d9c830d9380e3d5c9413601f9a136fe (patch)
tree20eec73c439bef5a4fb48848a259c48f53876e7d /ext/qt
parent3fba2909799ab48fa53ec721b4b3291fecf55357 (diff)
downloadgstreamer-plugins-bad-4315a4b54d9c830d9380e3d5c9413601f9a136fe.tar.gz
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.
Diffstat (limited to 'ext/qt')
-rw-r--r--ext/qt/gstqtsink.cc38
-rw-r--r--ext/qt/gstqtsrc.cc64
2 files changed, 8 insertions, 94 deletions
diff --git a/ext/qt/gstqtsink.cc b/ext/qt/gstqtsink.cc
index 70e6858b4..2253156e2 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 849018e8f..518a5f3fa 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;
}