diff options
author | Matthew Waters <ystreet00@gmail.com> | 2014-03-15 14:06:40 +0100 |
---|---|---|
committer | Matthew Waters <ystreet00@gmail.com> | 2014-03-15 18:37:07 +0100 |
commit | a8ce124628696f423dc82b4c7657a02874a0c016 (patch) | |
tree | 258a3762609af2fdd6f8af165c7452c84b52df03 /gst | |
parent | f0b10d4edfc6737b4ce73997ffe38ca3d263b8d2 (diff) | |
download | gstreamer-plugins-bad-a8ce124628696f423dc82b4c7657a02874a0c016.tar.gz |
[905/906] Add GL context sharing support for non-gstgl elements
Diffstat (limited to 'gst')
-rw-r--r-- | gst/gl/gstglimagesink.c | 16 | ||||
-rw-r--r-- | gst/gl/gstgltestsrc.c | 25 |
2 files changed, 39 insertions, 2 deletions
diff --git a/gst/gl/gstglimagesink.c b/gst/gl/gstglimagesink.c index 269234a15..f49422cdd 100644 --- a/gst/gl/gstglimagesink.c +++ b/gst/gl/gstglimagesink.c @@ -861,6 +861,8 @@ gst_glimage_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) guint size; gboolean need_pool; GstStructure *gl_context; + gchar *platform, *gl_apis; + gpointer handle; if (!_ensure_gl_setup (glimage_sink)) return FALSE; @@ -915,11 +917,23 @@ gst_glimage_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) gst_object_unref (pool); + gl_apis = + gst_gl_api_to_string (gst_gl_context_get_gl_api (glimage_sink->context)); + platform = + gst_gl_platform_to_string (gst_gl_context_get_gl_platform + (glimage_sink->context)); + handle = (gpointer) gst_gl_context_get_gl_context (glimage_sink->context); + gl_context = gst_structure_new ("GstVideoGLTextureUploadMeta", "gst.gl.GstGLContext", - GST_GL_TYPE_CONTEXT, glimage_sink->context, NULL); + GST_GL_TYPE_CONTEXT, glimage_sink->context, "gst.gl.context.handle", + G_TYPE_POINTER, handle, "gst.gl.context.type", G_TYPE_STRING, platform, + "gst.gl.context.apis", G_TYPE_STRING, gl_apis, NULL); gst_query_add_allocation_meta (query, GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, gl_context); + + g_free (gl_apis); + g_free (platform); gst_structure_free (gl_context); return TRUE; diff --git a/gst/gl/gstgltestsrc.c b/gst/gl/gstgltestsrc.c index 1d9d3434b..b788dcd5c 100644 --- a/gst/gl/gstgltestsrc.c +++ b/gst/gl/gstgltestsrc.c @@ -597,6 +597,7 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query) GError *error = NULL; guint idx; guint out_width, out_height; + GstGLContext *other_context = NULL; gst_query_parse_allocation (query, &caps, NULL); @@ -621,6 +622,9 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query) GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx)) { GstGLContext *context; const GstStructure *upload_meta_params; + gpointer handle; + gchar *type; + gchar *apis; gst_query_parse_nth_allocation_meta (query, idx, &upload_meta_params); if (gst_structure_get (upload_meta_params, "gst.gl.GstGLContext", @@ -630,12 +634,31 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query) src->context = context; if (old) gst_object_unref (old); + } else if (gst_structure_get (upload_meta_params, "gst.gl.context.handle", + G_TYPE_POINTER, &handle, "gst.gl.context.type", G_TYPE_STRING, + &type, "gst.gl.context.apis", G_TYPE_STRING, &apis, NULL) + && handle) { + GstGLPlatform platform = GST_GL_PLATFORM_NONE; + GstGLAPI gl_apis; + + GST_DEBUG ("got GL context handle 0x%p with type %s and apis %s", handle, + type, apis); + + if (g_strcmp0 (type, "glx") == 0) + platform = GST_GL_PLATFORM_GLX; + + gl_apis = gst_gl_api_from_string (apis); + + if (gl_apis && platform) + other_context = + gst_gl_context_new_wrapped (src->display, (guintptr) handle, + platform, gl_apis); } } if (!src->context) { src->context = gst_gl_context_new (src->display); - if (!gst_gl_context_create (src->context, NULL, &error)) + if (!gst_gl_context_create (src->context, other_context, &error)) goto context_error; } |