gst_gl_ensure_element_data
gst_gl_get_plane_data_size
gst_gl_get_plane_start
-gst_gl_run_query
gst_gl_value_get_texture_target_mask
gst_gl_value_set_texture_target
gst_gl_value_set_texture_target_from_mask
static gboolean
_find_local_gl_context (GstGLBaseMixer * mix)
{
- GstQuery *query;
- GstContext *context;
- const GstStructure *s;
-
- if (mix->context)
+ if (gst_gl_query_local_gl_context (GST_ELEMENT (mix), GST_PAD_SRC,
+ &mix->context))
return TRUE;
-
- query = gst_query_new_context ("gst.gl.local_context");
- if (!mix->context && gst_gl_run_query (GST_ELEMENT (mix), 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, &mix->context,
- NULL);
- }
- }
- if (!mix->context
- && gst_gl_run_query (GST_ELEMENT (mix), 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, &mix->context,
- NULL);
- }
- }
-
- GST_DEBUG_OBJECT (mix, "found local context %p", mix->context);
-
- gst_query_unref (query);
-
- if (mix->context)
+ if (gst_gl_query_local_gl_context (GST_ELEMENT (mix), GST_PAD_SINK,
+ &mix->context))
return TRUE;
-
return FALSE;
}
}
case GST_QUERY_CONTEXT:
{
- const gchar *context_type;
- GstContext *context, *old_context;
-
- ret = gst_gl_handle_context_query ((GstElement *) mix, query,
- &mix->display, &mix->priv->other_context);
- if (mix->display)
- gst_gl_display_filter_gl_api (mix->display,
- mix_class->supported_gl_api);
- 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, mix->context,
- NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- ret = mix->context != NULL;
- }
- GST_LOG_OBJECT (mix, "context query of type %s %i", context_type, ret);
-
- if (ret)
- return ret;
-
+ if (gst_gl_handle_context_query ((GstElement *) mix, query,
+ mix->display, mix->context, mix->priv->other_context))
+ return TRUE;
break;
}
default:
static gboolean
gst_gl_base_mixer_src_query (GstAggregator * agg, GstQuery * query)
{
- gboolean res = FALSE;
GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
- GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_GET_CLASS (mix);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
{
- const gchar *context_type;
- GstContext *context, *old_context;
-
- res = gst_gl_handle_context_query ((GstElement *) mix, query,
- &mix->display, &mix->priv->other_context);
- if (mix->display)
- gst_gl_display_filter_gl_api (mix->display,
- mix_class->supported_gl_api);
- 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, mix->context,
- NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- res = mix->context != NULL;
- }
- GST_LOG_OBJECT (mix, "context query of type %s %i", context_type, res);
-
- if (res)
- return res;
-
+ if (gst_gl_handle_context_query ((GstElement *) mix, query,
+ mix->display, mix->context, mix->priv->other_context))
+ return TRUE;
break;
}
default:
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
{
- const gchar *context_type;
- GstContext *context, *old_context;
-
- res = gst_gl_handle_context_query ((GstElement *) glimage_sink, query,
- &glimage_sink->display, &glimage_sink->other_context);
- if (glimage_sink->display)
- gst_gl_display_filter_gl_api (glimage_sink->display, SUPPORTED_GL_APIS);
-
- 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,
- glimage_sink->context, NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- res = glimage_sink->context != NULL;
- }
- GST_LOG_OBJECT (glimage_sink, "context query of type %s %i", context_type,
- res);
-
- if (res)
- return res;
+ if (gst_gl_handle_context_query ((GstElement *) glimage_sink, query,
+ glimage_sink->display, glimage_sink->context,
+ glimage_sink->other_context))
+ return TRUE;
break;
}
case GST_QUERY_DRAIN:
GstVideoMultiviewFlags flags, mask;
gst_structure_remove_field (st, "multiview-mode");
- if (gst_structure_get_flagset (st, "multiview-flags", (guint*) &flags,
- (guint*) &mask)) {
+ if (gst_structure_get_flagset (st, "multiview-flags", (guint *) & flags,
+ (guint *) & mask)) {
flags &= keep_flags;
mask = keep_flags;
gst_structure_set (st, "multiview-flags",
static gboolean
_find_local_gl_context (GstGLStereoSplit * split)
{
- GstQuery *query;
- GstContext *context;
- const GstStructure *s;
-
- if (split->context)
+ if (gst_gl_query_local_gl_context (GST_ELEMENT (split), GST_PAD_SRC,
+ &split->context))
return TRUE;
-
- query = gst_query_new_context ("gst.gl.local_context");
- if (!split->context
- && gst_gl_run_query (GST_ELEMENT (split), 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, &split->context,
- NULL);
- }
- }
- if (!split->context
- && gst_gl_run_query (GST_ELEMENT (split), 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, &split->context,
- NULL);
- }
- }
-
- GST_DEBUG_OBJECT (split, "found local context %p", split->context);
-
- gst_query_unref (query);
-
- if (split->context)
+ if (gst_gl_query_local_gl_context (GST_ELEMENT (split), GST_PAD_SINK,
+ &split->context))
return TRUE;
-
return FALSE;
}
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 *) split, query,
- &split->display, &split->other_context);
- if (split->display)
- gst_gl_display_filter_gl_api (split->display, SUPPORTED_GL_APIS);
- 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, split->context,
- NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- ret = split->context != NULL;
- }
- GST_LOG_OBJECT (split, "context query of type %s %i", context_type, ret);
-
- if (ret)
- return ret;
+ if (gst_gl_handle_context_query ((GstElement *) split, query,
+ split->display, split->context, split->other_context))
+ return TRUE;
return gst_pad_query_default (pad, parent, 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 *) split, query,
- &split->display, &split->other_context);
- if (split->display)
- gst_gl_display_filter_gl_api (split->display, SUPPORTED_GL_APIS);
- 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, split->context,
- NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- ret = split->context != NULL;
- }
- GST_LOG_OBJECT (split, "context query of type %s %i", context_type, ret);
-
- if (ret)
- return ret;
+ if (gst_gl_handle_context_query ((GstElement *) split, query,
+ split->display, split->context, split->other_context))
+ return TRUE;
return gst_pad_query_default (pad, parent, query);
}
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
{
- const gchar *context_type;
- GstContext *context, *old_context;
-
- res = gst_gl_handle_context_query ((GstElement *) src, query,
- &src->display, &src->other_context);
- if (src->display)
- gst_gl_display_filter_gl_api (src->display, SUPPORTED_GL_APIS);
-
- 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, src->context,
- NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- res = src->context != NULL;
- }
- GST_LOG_OBJECT (src, "context query of type %s %i", context_type, res);
-
- if (res)
- return res;
-
+ if (gst_gl_handle_context_query ((GstElement *) src, query,
+ src->display, src->context, src->other_context))
+ return TRUE;
break;
}
case GST_QUERY_CONVERT:
static gboolean
_find_local_gl_context (GstGLTestSrc * src)
{
- GstQuery *query;
- GstContext *context;
- const GstStructure *s;
-
- if (src->context)
+ if (gst_gl_query_local_gl_context (GST_ELEMENT (src), GST_PAD_SRC,
+ &src->context))
return TRUE;
-
- query = gst_query_new_context ("gst.gl.local_context");
- if (!src->context && gst_gl_run_query (GST_ELEMENT (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, &src->context,
- NULL);
- }
- }
- if (!src->context
- && gst_gl_run_query (GST_ELEMENT (src), 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, &src->context,
- NULL);
- }
- }
-
- GST_DEBUG_OBJECT (src, "found local context %p", src->context);
-
- gst_query_unref (query);
-
- if (src->context)
- return TRUE;
-
return FALSE;
}
G_BEGIN_DECLS
-GST_EXPORT
gboolean gst_gl_context_gen_shader (GstGLContext * context,
const gchar * shader_vertex_source,
const gchar * shader_fragment_source, GstGLShader ** shader);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
{
- const gchar *context_type;
- GstContext *context, *old_context;
-
- res = gst_gl_handle_context_query ((GstElement *) gtk_sink, query,
- >k_sink->display, >k_sink->gtk_context);
-
- if (gtk_sink->display)
- gst_gl_display_filter_gl_api (gtk_sink->display, GST_GL_API_OPENGL3);
-
- 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, gtk_sink->context,
- NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- res = gtk_sink->context != NULL;
- }
- GST_LOG_OBJECT (gtk_sink, "context query of type %s %i", context_type,
- res);
+ if (gst_gl_handle_context_query ((GstElement *) gtk_sink, query,
+ gtk_sink->display, gtk_sink->context, gtk_sink->gtk_context))
+ return TRUE;
break;
}
default:
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 */
}
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;
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 */
}
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;
}
#include <gst/video/gstvideometa.h>
#include <gst/gl/gl.h>
+#include <gst/gl/gstglutils_private.h>
/**
* SECTION:gstglbasefilter
#define gst_gl_base_filter_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLBaseFilter, gst_gl_base_filter,
GST_TYPE_BASE_TRANSFORM, GST_DEBUG_CATEGORY_INIT (gst_gl_base_filter_debug,
- "glbasefilter", 0, "glbasefilter element");
- );
+ "glbasefilter", 0, "glbasefilter element"););
static void gst_gl_base_filter_finalize (GObject * object);
static void gst_gl_base_filter_set_property (GObject * object, guint prop_id,
static gboolean
_find_local_gl_context (GstGLBaseFilter * filter)
{
- GstQuery *query;
- GstContext *context;
- const GstStructure *s;
-
- if (filter->context)
+ if (gst_gl_query_local_gl_context (GST_ELEMENT (filter), GST_PAD_SRC,
+ &filter->context))
return TRUE;
-
- query = gst_query_new_context ("gst.gl.local_context");
- if (!filter->context
- && gst_gl_run_query (GST_ELEMENT (filter), 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, &filter->context,
- NULL);
- }
- }
- if (!filter->context
- && gst_gl_run_query (GST_ELEMENT (filter), 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, &filter->context,
- NULL);
- }
- }
-
- GST_DEBUG_OBJECT (filter, "found local context %p", filter->context);
-
- gst_query_unref (query);
-
- if (filter->context)
+ if (gst_gl_query_local_gl_context (GST_ELEMENT (filter), GST_PAD_SINK,
+ &filter->context))
return TRUE;
-
return FALSE;
}
GstQuery * query)
{
GstGLBaseFilter *filter = GST_GL_BASE_FILTER (trans);
- GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_ALLOCATION:
}
case GST_QUERY_CONTEXT:
{
- const gchar *context_type;
- GstContext *context, *old_context;
- gboolean ret;
-
- ret = gst_gl_handle_context_query ((GstElement *) filter, query,
- &filter->display, &filter->priv->other_context);
- if (filter->display)
- gst_gl_display_filter_gl_api (filter->display,
- filter_class->supported_gl_api);
-
- 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, filter->context,
- NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
-
- ret = filter->context != NULL;
- }
- GST_LOG_OBJECT (filter, "context query of type %s %i", context_type, ret);
-
- if (ret)
- return ret;
+ if (gst_gl_handle_context_query ((GstElement *) filter, query,
+ filter->display, filter->context, filter->priv->other_context))
+ return TRUE;
break;
}
default:
#include "gl.h"
#include "gstglutils.h"
+#include "gstglutils_private.h"
#if GST_GL_HAVE_WINDOW_X11
#include <gst/gl/x11/gstgldisplay_x11.h>
#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
+#ifndef GST_DISABLE_GST_DEBUG
+GST_DEBUG_CATEGORY_STATIC (gst_gl_utils_debug);
+static GstDebugCategory *
+_init_gl_utils_debug_category (void)
+{
+ static volatile gsize _init = 0;
+
+ if (g_once_init_enter (&_init)) {
+ GST_DEBUG_CATEGORY_INIT (gst_gl_utils_debug, "glutils", 0,
+ "OpenGL Utilities");
+ g_once_init_leave (&_init, 1);
+ }
+
+ return gst_gl_utils_debug;
+}
+
+#define GST_CAT_DEFAULT _init_gl_utils_debug_category()
+#endif
static gboolean
gst_gl_display_found (GstElement * element, GstGLDisplay * display)
gboolean
gst_gl_handle_context_query (GstElement * element, GstQuery * query,
- GstGLDisplay ** display, GstGLContext ** other_context)
+ GstGLDisplay * display, GstGLContext * gl_context,
+ GstGLContext * other_context)
{
- gboolean res = FALSE;
const gchar *context_type;
GstContext *context, *old_context;
- g_return_val_if_fail (element != NULL, FALSE);
- g_return_val_if_fail (query != NULL, FALSE);
- g_return_val_if_fail (display != NULL, FALSE);
- g_return_val_if_fail (other_context != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
+ g_return_val_if_fail (GST_IS_QUERY (query), FALSE);
+ g_return_val_if_fail (display == NULL || GST_IS_GL_DISPLAY (display), FALSE);
+ g_return_val_if_fail (gl_context == NULL
+ || GST_IS_GL_CONTEXT (gl_context), FALSE);
+ g_return_val_if_fail (other_context == NULL
+ || GST_IS_GL_CONTEXT (other_context), FALSE);
+ GST_LOG_OBJECT (element, "handle context query %" GST_PTR_FORMAT, query);
gst_query_parse_context_type (query, &context_type);
- if (g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) {
-
+ if (display && g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) {
gst_query_parse_context (query, &old_context);
if (old_context)
else
context = gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
- gst_context_set_gl_display (context, *display);
+ gst_context_set_gl_display (context, display);
gst_query_set_context (query, context);
gst_context_unref (context);
+ GST_DEBUG_OBJECT (element, "successfully set %" GST_PTR_FORMAT
+ " on %" GST_PTR_FORMAT, display, query);
- res = *display != NULL;
+ return TRUE;
}
#if GST_GL_HAVE_WINDOW_X11
- else if (g_strcmp0 (context_type, "gst.x11.display.handle") == 0) {
+ else if (display && g_strcmp0 (context_type, "gst.x11.display.handle") == 0) {
GstStructure *s;
- Display *x11_display = NULL;
gst_query_parse_context (query, &old_context);
else
context = gst_context_new ("gst.x11.display.handle", TRUE);
- if (*display
- && ((*display)->type & GST_GL_DISPLAY_TYPE_X11) ==
- GST_GL_DISPLAY_TYPE_X11)
- x11_display = (Display *) gst_gl_display_get_handle (*display);
+ if (gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_X11) {
+ Display *x11_display = (Display *) gst_gl_display_get_handle (display);
- s = gst_context_writable_structure (context);
- gst_structure_set (s, "display", G_TYPE_POINTER, x11_display, NULL);
+ if (x11_display) {
+ s = gst_context_writable_structure (context);
+ gst_structure_set (s, "display", G_TYPE_POINTER, x11_display, NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
+ gst_query_set_context (query, context);
+ gst_context_unref (context);
- res = x11_display != NULL;
+ GST_DEBUG_OBJECT (element, "successfully set x11 display %p (from %"
+ GST_PTR_FORMAT ") on %" GST_PTR_FORMAT, x11_display, display,
+ query);
+
+ return TRUE;
+ }
+ }
}
#endif
#if GST_GL_HAVE_WINDOW_WAYLAND
- else if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) {
+ else if (display
+ && g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) {
GstStructure *s;
- struct wl_display *wayland_display = NULL;
gst_query_parse_context (query, &old_context);
else
context = gst_context_new ("GstWaylandDisplayHandleContextType", TRUE);
- if (*display
- && ((*display)->type & GST_GL_DISPLAY_TYPE_WAYLAND) ==
- GST_GL_DISPLAY_TYPE_WAYLAND)
- wayland_display =
- (struct wl_display *) gst_gl_display_get_handle (*display);
+ if (gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WAYLAND) {
+ struct wl_display *wayland_display =
+ (struct wl_display *) gst_gl_display_get_handle (display);
- s = gst_context_writable_structure (context);
- gst_structure_set (s, "display", G_TYPE_POINTER, wayland_display, NULL);
+ if (wayland_display) {
+ s = gst_context_writable_structure (context);
+ gst_structure_set (s, "display", G_TYPE_POINTER, wayland_display, NULL);
- gst_query_set_context (query, context);
- gst_context_unref (context);
+ gst_query_set_context (query, context);
+ gst_context_unref (context);
+
+ GST_DEBUG_OBJECT (element, "successfully set wayland display %p (from %"
+ GST_PTR_FORMAT ") on %" GST_PTR_FORMAT, wayland_display, display,
+ query);
- res = wayland_display != NULL;
+ return TRUE;
+ }
+ }
}
#endif
- else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
+ else if (other_context && g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
GstStructure *s;
gst_query_parse_context (query, &old_context);
context = gst_context_new ("gst.gl.app_context", TRUE);
s = gst_context_writable_structure (context);
- gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, *other_context, NULL);
+ gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, other_context, NULL);
+ gst_query_set_context (query, context);
+ gst_context_unref (context);
+
+ GST_DEBUG_OBJECT (element, "successfully set application GL context %"
+ GST_PTR_FORMAT " on %" GST_PTR_FORMAT, other_context, query);
+
+ return TRUE;
+ } else if (gl_context
+ && 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", TRUE);
+
+ s = gst_context_writable_structure (context);
+ gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, gl_context, NULL);
gst_query_set_context (query, context);
gst_context_unref (context);
- res = *other_context != NULL;
+ GST_DEBUG_OBJECT (element, "successfully set GL context %"
+ GST_PTR_FORMAT " on %" GST_PTR_FORMAT, gl_context, query);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+gst_gl_query_local_gl_context (GstElement * element, GstPadDirection direction,
+ GstGLContext ** context_ptr)
+{
+ GstQuery *query;
+ GstContext *context;
+ const GstStructure *s;
+
+ g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
+ g_return_val_if_fail (context_ptr != NULL, FALSE);
+
+ if (*context_ptr)
+ return TRUE;
+
+ query = gst_query_new_context ("gst.gl.local_context");
+ if (gst_gl_run_query (GST_ELEMENT (element), query, direction)) {
+ gst_query_parse_context (query, &context);
+ if (context) {
+ s = gst_context_get_structure (context);
+ gst_structure_get (s, "context", GST_TYPE_GL_CONTEXT, context_ptr, NULL);
+ }
}
- return res;
+ gst_query_unref (query);
+
+ return *context_ptr != NULL;
}
gsize
return plane_size;
}
-/* find the difference between the start of the plane and where the video
- * data starts in the plane */
gsize
gst_gl_get_plane_start (GstVideoInfo * info, GstVideoAlignment * valign,
guint plane)
GstGLDisplay ** display, GstGLContext ** other_context);
GST_EXPORT
gboolean gst_gl_handle_context_query (GstElement * element, GstQuery * query,
- GstGLDisplay ** display, GstGLContext ** other_context);
-
+ GstGLDisplay * display, GstGLContext * context, GstGLContext * other_context);
GST_EXPORT
-gboolean gst_gl_run_query (GstElement * element,
- GstQuery * query, GstPadDirection direction);
+gboolean gst_gl_query_local_gl_context (GstElement * element, GstPadDirection direction,
+ GstGLContext ** context_ptr);
+
GST_EXPORT
gsize gst_gl_get_plane_data_size (GstVideoInfo * info, GstVideoAlignment * align,
guint plane);
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_GL_UTILS_PRIVATE_H__
+#define __GST_GL_UTILS_PRIVATE_H__
+
+#include <gst/gl/gstgl_fwd.h>
+
+G_BEGIN_DECLS
+
+gboolean gst_gl_run_query (GstElement * element, GstQuery * query, GstPadDirection direction);
+
+G_END_DECLS
+
+#endif /* __GST_GL_UTILS_H__ */