Hi,<br><br><div class="gmail_quote">2009/3/24 Andres Colubri <span dir="ltr"><<a href="mailto:andres.colubri@gmail.com">andres.colubri@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi, I have been following this discussion with interest and I just<br>
wanted to add a couple of comments/questions.<br>
<br>
I'm currently combining opengl and gstreamer within my application.<br>
Right now, the gst-originated video buffers are pushed out of the<br>
pipeline with a handoff signal, and then uploaded to an opengl texture<br>
for further gpu-accelerated processing and final display on the<br>
application window.</blockquote><div>ok <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
But it would be quite great if I can just get the gl texture id from the<br>
gst-plugins, for instance glupload, and then directly use the texture<br>
inside my application.</blockquote><div><br>Would be cool but it's not possible for the reasons you explain next. (a texture id can be used only inside the opengl context where it comes from)<br><br>But there is maybe an other way:<br>
--on win32:<br>wglCopyContext(glcontextSrc, glcontextDst, GL_TEXTURE_BIT);<br>--on linux (assume it's X):<br>glXCopyContext(disp, glcontextSrc, glcontextDst, GL_TEXTURE_BIT);<br>--on OpenGL ES 2.0:<br><a href="http://www.khronos.org/opengles/sdk/1.1/docs/man/eglCreateContext.xml">http://www.khronos.org/opengles/sdk/1.1/docs/man/eglCreateContext.xml</a><br>
(Specifies the EGL rendering context with which to share texture objects)<br><br>I have not experimented those things a lot. So I cannot tell more about this possible way. (there is some restrictions but in our case we are ok)<br>
<strong></strong><br>So we can try it, for example I enable a function from a glfilter that would allow to retrieve the glcontext used inside the pipeline. <br>You could then just call glCopyContext one time, and then use the texture id(s) just like you want.<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Since my app is cross-platform (linux, win, osx), the composite<br>
redirection approach doesn't seem viable. The XOverlay interface won't<br>
work either, because I need to do some gpgpu post-processing before the<br>
actual image rendering.</blockquote><div> </div><div>Yup, the XOverlay interface is only there to specify a window id. There is not any relation with OpenGL (I mean about the goal).<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>From what I read, one alternative (perhaps the only one under this type<br>
of scenarios) would be to share the opengl context between the app and<br>
the gst gl-plugin. Basically, the app would create the opengl context<br>
and then pass it to the plugin when initializing the gst pipeline.</blockquote><div><br>This is a solution (use the same opengl context bettween you app and the plugin).<br>I also first added a function but it's currently not implemented because of time (and I think there is a better/prefered way).<br>
<a href="http://cgit.freedesktop.org/gstreamer/gst-plugins-gl/tree/gst-libs/gst/gl/gstglwindow.h">http://cgit.freedesktop.org/gstreamer/gst-plugins-gl/tree/gst-libs/gst/gl/gstglwindow.h</a><br><a href="http://cgit.freedesktop.org/gstreamer/gst-plugins-gl/tree/gst-libs/gst/gl">http://cgit.freedesktop.org/gstreamer/gst-plugins-gl/tree/gst-libs/gst/gl</a><br>
<br>The main bad thing would be to use a lot of glMakeCurrent call (for each frame), inside your app thread and inside the gst-gl thread.<br>For now, there is only one call to glMakeCurrent at gst-gl init.<br>Switching a gl context bettween different threads it's very expensive. More over with several opengl context (several branch in the pipeline)<br>
this solution would be like a hell. I have experience on this so I can tell more and that's a bad way.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Is this possible in the current implementation of gst-plugins? If not,<br>
wouldn't be an useful (additional) method for setting up gl-accelerated<br>
pipelines?</blockquote><div><br>There is 2 other solutions.<br><br>First, have you take a look at glfilterapp ? <br>Look at the code of gst-plugins-gl/tests/examples/generic/recordgraphic/main.cpp<br><div>There is a drawcallback, which is invoked each time a new video frame is upload, and at the point of <span class="il">glfilterapp</span> place in the graph.<br>
This is the easiest way, if your scene is not extremelly complex. <br>In this way, you have not to create/handle the opengl context, but you
can give a windows ID in which you want see the gl scene.<br><br></div>The last solution is to write a glfilter as glbumper, gleffects,
glfiltercube, glfiltersobel (etc..) are, and use you animation API
inside the implementation of its.<br>Also you could control your filter through gobject properties as it's done for gleffects (see property "effect").<br>
And it would be more flexible.<br>Finally,
you could also split your rendering process in several glfilters. For
example, one for the scene (rotation, quad), and one other for the
effect on the texture.<br>In this way too, you have not to
create/handle the opengl context, but you can give a windows ID in
which you want see the gl scene.<br>I think it's the best way, the more viable, useable, flexible.<br><br>So we have 4 solutions.<br>The 3 (glfilterapp), and 4 (create a glfilter) are already fully implemented.<br>The 1 (copyContext), we have to test it.<br>
The 2, (use the same context) must be used only if 1, 3 and 4 are not possible (because really a bad way). And it's not yet implemented.<br><br>About the solution 4, you will tell me that you can implement a glfilter because you are using a framework that comes with its own opengl context management. So the problem is still the same.<br>
(I mean, all the opengl framework focused on draw and esthetic: clutter etc...)<br>Then I will say yes, but then I will tell you that the solution is to implement glwindow with your friendly framework.<br>I am mean if it's clutter, then you have to create a gstglwindow_clutter.c. I can help on this.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Thanks,<br>
<font color="#888888">Andres</font></blockquote><div><br>I hope this can help. <br><br>Sincerely<br><br>Julien<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<font color="#888888"><br>
</font><div><div></div><div class="h5"><br>
Florent wrote:<br>
> Hi,<br>
><br>
><br>
>> Thanks Jan, I installed gst-plugins-gl from git and did some first<br>
>> experiments. This seems to be what I'm looking for. Is it correct that<br>
>> I would use 'glimagesink' and do the drawing using the<br>
>> client-draw-callback? I'm not experienced with OpenGL, is it safe to<br>
>> just redraw the part of the scene that shows the video in the<br>
>> callback?<br>
>><br>
><br>
> If i'm not mistaken glimagesink isn't what you are looking for, except<br>
> if your opengl application supports composite redirection (when<br>
> glimagesink's textures are redirected inside your own opengl app): the<br>
> glimagesink will be a dedicated, separate window and gl context. If<br>
> you need to display gst-gl-originating frames inside your own opengl<br>
> canvas, then you need to develop some form of a gstreamer sink for<br>
> your canvas.<br>
><br>
> This is what has been done in both pigment (with pgmimagesink) and<br>
> clutter (cluttergstsink).<br>
><br>
> The clutter section in gst-gl examples directory shows a<br>
> gst-gl-originating texture redirection inside a clutter application<br>
> (using composite redirection).<br>
><br>
><br>
>> I'm wondering as this callback function is called by a<br>
>> gstreamer thread and if the application is doing other OpenGL stuff or<br>
>> contains more than one video display, multiple threads are doing<br>
>> OpenGL drawing operations simultaneously.<br>
>><br>
><br>
> Your application should take care of the draws sync so that no<br>
> conflict between opengl operations exists. Also, sharing opengl<br>
> contexts between apps seems a difficult task.<br>
><br>
><br>
>> self.videosink = gst.element_factory_make('glimagesink', 'videosink')<br>
>> self.videosink.set_property('client-draw-callback', self.draw_callback)<br>
>><br>
><br>
> I think the client-draw-callback will offer you a way to manipulate<br>
> the video texture inside the glimagesink context, not the other way<br>
> around (drawing video inside your own app).<br>
><br>
> I assume you are only trying to display gst-originating (decoded<br>
> video) video inside your Gl app. If so, you can prototype things using<br>
> the fakesink element, by connecting it's handoff signals to a texture<br>
> upload in your application. See [1] and [2] for more info<br>
><br>
> Florent<br>
><br>
> [1] <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-data-spoof.html" target="_blank">http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-data-spoof.html</a><br>
> [2] <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-fakesink.html#GstFakeSink-handoff" target="_blank">http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-fakesink.html#GstFakeSink-handoff</a><br>
><br>
> ------------------------------------------------------------------------------<br>
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are<br>
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and<br>
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development<br>
> software that enables intelligent coding and step-through debugging.<br>
> Download the free 60 day trial. <a href="http://p.sf.net/sfu/www-adobe-com" target="_blank">http://p.sf.net/sfu/www-adobe-com</a><br>
> _______________________________________________<br>
> gstreamer-devel mailing list<br>
> <a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
> <a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
><br>
><br>
<br>
<br>
------------------------------------------------------------------------------<br>
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are<br>
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and<br>
easily build your RIAs with Flex Builder, the Eclipse(TM)based development<br>
software that enables intelligent coding and step-through debugging.<br>
Download the free 60 day trial. <a href="http://p.sf.net/sfu/www-adobe-com" target="_blank">http://p.sf.net/sfu/www-adobe-com</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</div></div></blockquote></div><br>