Managing contexts for getting texture via appsink in OSX Cocoa application

Benoît LAHOZ | L'ange Carasuelo benoit.lahoz at carasuelo.org
Thu Mar 19 10:37:17 PDT 2015


Hello,

This is a newbie question and I already had a lot of help from the IRC 
channel in compiling from cerbero, but I can't find a simple solution 
for this problem.

My pipeline looks like this : videotestsrc -> videoconvert -> 
glfilterapp -> appsink (with callback)
I try to get a valid OpenGL texture from the appsink's callback and to 
display it in an NSOpenGLView.

It looks like I manage to get one via :

GstVideoFrame frame;
GstVideoInfo info;

gst_video_info_init(&info);
gst_video_info_from_caps(&info, caps);

if (gst_video_frame_map(&frame, &info, buf, (GstMapFlags)(GST_MAP_READ | 
GST_MAP_GL))) // (GST_MAP_FLAG_LAST << 1)  ?
{

      GLuint tex = (*(guint *) frame.data[0]);
     gst_video_frame_unmap(&frame);

}

It returns a texture ID between 5 and 8.

Actually I got this code from various places and I don't really 
understand what I'm doing with the flags.
But when I'm passing the texture to my NSOpenGLView it only display white.
The OpenGL Profiler tool tells me that I have (obviously) 2 contexts 
running.

So I tried to create a shared context via :

GstGLDisplay *display = gst_gl_display_new();
GstGLContext *ctx = gst_gl_context_new_wrapped(display, 
(guintptr)cgl_ctx, GST_GL_PLATFORM_CGL, GST_GL_API_ANY);
gst_gl_context_create(context, ctx, NULL); // to share the 2 contexts if 
I understand well

where "cgl_ctx" is a CGLContextObj I get from my NSOpenGLView and 
"context" the context I want to pass to the appsink.

First, I have this error : [GLib-CRITICAL **: 
g_hash_table_insert_internal: assertion 'hash_table != NULL' failed].
When I play the pipeline, I have this other error : [GStreamer-CRITICAL 
**: gst_object_unref: assertion 'object != NULL' failed]
The 2 errors disappear if I don't create the context.

Second, I don't know how to pass the context (if it is well created) to 
the glfilterapp element in order (I guess) to have a texture from the 
appsink in the shared context.

I know this is a usual question, but any advice would really be great !
Thank you.

Benoît.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150319/5559fbaa/attachment.html>


More information about the gstreamer-devel mailing list