From 8d6f745b78e8190cebd9061192975ad88a08efd5 Mon Sep 17 00:00:00 2001 From: "Wang Xin-yu (王昕宇)" Date: Tue, 26 Aug 2014 16:21:42 +0800 Subject: gl: qglwtextureshare demo fixes and cleanup 1. glcontextid function is replaced by gstreamer gst_gl_context_new_wrapped . 2. call gst_init before gst_gl_display_new , seems gst_gl_display_new depends on gst_allocator_register , which only worked after gst_init called 3. flush gstreamer OpenGL context before using shared texture, fix flicker problem. https://bugzilla.gnome.org/show_bug.cgi?id=735566 --- .../examples/gl/qt/qglwtextureshare/glcontextid.h | 65 ---------------------- tests/examples/gl/qt/qglwtextureshare/gstthread.h | 1 - tests/examples/gl/qt/qglwtextureshare/main.cpp | 2 + tests/examples/gl/qt/qglwtextureshare/pipeline.cpp | 1 - tests/examples/gl/qt/qglwtextureshare/pipeline.h | 1 - .../gl/qt/qglwtextureshare/qglrenderer.cpp | 8 +++ .../gl/qt/qglwtextureshare/qglwtextureshare.pro | 2 +- 7 files changed, 11 insertions(+), 69 deletions(-) delete mode 100644 tests/examples/gl/qt/qglwtextureshare/glcontextid.h diff --git a/tests/examples/gl/qt/qglwtextureshare/glcontextid.h b/tests/examples/gl/qt/qglwtextureshare/glcontextid.h deleted file mode 100644 index 7c59546f4..000000000 --- a/tests/examples/gl/qt/qglwtextureshare/glcontextid.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Julien Isorce - * Copyright (C) 2009 Andrey Nechypurenko - * Copyright (C) 2010 Nuno Santos - * - * 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 __GLCONTEXTID_H -#define __GLCONTEXTID_H - -#include - -#if GST_GL_HAVE_PLATFORM_WGL - #define WIN32_LEAN_AND_MEAN - #include - #include - #include -#elif GST_GL_HAVE_PLATFORM_CGL - #include - class NSOpenGLContext; -#else - #include - #include - #include - #include -#endif - - -#if GST_GL_HAVE_PLATFORM_WGL - typedef struct _tagGLContextID - { - HGLRC contextId; - HDC dc; - } GLContextID; -#elif GST_GL_HAVE_PLATFORM_CGL - typedef struct _tagGLContextID - { - NSOpenGLContext* contextId; - } GLContextID; -#elif GST_GL_HAVE_PLATFORM_GLX - typedef struct _tagGLContextID - { - GLXContext contextId; - Display *display; - Window wnd; - } GLContextID; -#endif - -#endif // __GLCONTEXTID_H - diff --git a/tests/examples/gl/qt/qglwtextureshare/gstthread.h b/tests/examples/gl/qt/qglwtextureshare/gstthread.h index 918859ee0..d18218c5c 100644 --- a/tests/examples/gl/qt/qglwtextureshare/gstthread.h +++ b/tests/examples/gl/qt/qglwtextureshare/gstthread.h @@ -26,7 +26,6 @@ #include -#include "glcontextid.h" class Pipeline; diff --git a/tests/examples/gl/qt/qglwtextureshare/main.cpp b/tests/examples/gl/qt/qglwtextureshare/main.cpp index f2eb2f11f..9ff8dbaa3 100644 --- a/tests/examples/gl/qt/qglwtextureshare/main.cpp +++ b/tests/examples/gl/qt/qglwtextureshare/main.cpp @@ -22,10 +22,12 @@ #include #include "qglrenderer.h" +#include int main(int argc, char *argv[]) { + gst_init (NULL, NULL); QApplication a(argc, argv); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); QGLRenderer w(argc > 1 ? argv[1] : ""); diff --git a/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp b/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp index a7dd4901f..942e1a76e 100644 --- a/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp +++ b/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp @@ -42,7 +42,6 @@ Pipeline::~Pipeline() void Pipeline::configure() { - gst_init (NULL, NULL); #ifdef Q_WS_WIN m_loop = g_main_loop_new (NULL, FALSE); diff --git a/tests/examples/gl/qt/qglwtextureshare/pipeline.h b/tests/examples/gl/qt/qglwtextureshare/pipeline.h index 5e59f1a04..c2a1c9daa 100644 --- a/tests/examples/gl/qt/qglwtextureshare/pipeline.h +++ b/tests/examples/gl/qt/qglwtextureshare/pipeline.h @@ -26,7 +26,6 @@ #include -#include "glcontextid.h" #include "AsyncQueue.h" diff --git a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp b/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp index 218b8e4a4..c7726d1d9 100644 --- a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp +++ b/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp @@ -122,6 +122,10 @@ QGLRenderer::newFrame() this->updateGL(); } +static void flushGstreamerGL(GstGLContext* context,void *data){ + context->gl_vtable->Flush(); +} + void QGLRenderer::paintGL() { @@ -142,6 +146,10 @@ QGLRenderer::paintGL() Q_ASSERT(gst_is_gl_memory (mem)); + GstGLMemory *gl_memory=(GstGLMemory*)mem; + + gst_gl_context_thread_add(gl_memory->context,flushGstreamerGL,NULL); + gst_video_info_set_format (&v_info, v_meta->format, v_meta->width, v_meta->height); diff --git a/tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro b/tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro index 13014ac11..83e67d806 100644 --- a/tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro +++ b/tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro @@ -18,6 +18,7 @@ INCLUDEPATH += \ LIBS += -L"C:/gstreamer/lib" \ -L"C:/gstreamer/bin" \ -lgstreamer-1.0 \ + -lgstgl-1.0 \ -lgstvideo-1.0 \ -lglib-2.0 \ -lgmodule-2.0 \ @@ -74,7 +75,6 @@ HEADERS += gstthread.h \ pipeline.h \ qglrenderer.h \ AsyncQueue.h \ - glcontextid.h # Source files SOURCES += gstthread.cpp \ -- cgit v1.2.3