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
This commit is contained in:
Wang Xin-yu (王昕宇) 2014-08-26 16:21:42 +08:00 committed by Tim-Philipp Müller
parent 62bebdb4e6
commit a8093c56d5
7 changed files with 11 additions and 69 deletions

View file

@ -1,65 +0,0 @@
/*
* GStreamer
* Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
* Copyright (C) 2009 Andrey Nechypurenko <andreynech@gmail.com>
* Copyright (C) 2010 Nuno Santos <nunosantos@imaginando.net>
*
* 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 <gst/gl/gstglconfig.h>
#if GST_GL_HAVE_PLATFORM_WGL
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Wingdi.h>
#include <GL/gl.h>
#elif GST_GL_HAVE_PLATFORM_CGL
#include <OpenGL/OpenGL.h>
class NSOpenGLContext;
#else
#include <X11/Xlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#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

View file

@ -26,7 +26,6 @@
#include <gst/gl/gstglcontext.h> #include <gst/gl/gstglcontext.h>
#include "glcontextid.h"
class Pipeline; class Pipeline;

View file

@ -22,10 +22,12 @@
#include <QApplication> #include <QApplication>
#include "qglrenderer.h" #include "qglrenderer.h"
#include <gst/gst.h>
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
gst_init (NULL, NULL);
QApplication a(argc, argv); QApplication a(argc, argv);
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
QGLRenderer w(argc > 1 ? argv[1] : ""); QGLRenderer w(argc > 1 ? argv[1] : "");

View file

@ -42,7 +42,6 @@ Pipeline::~Pipeline()
void void
Pipeline::configure() Pipeline::configure()
{ {
gst_init (NULL, NULL);
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
m_loop = g_main_loop_new (NULL, FALSE); m_loop = g_main_loop_new (NULL, FALSE);

View file

@ -26,7 +26,6 @@
#include <gst/gl/gstglcontext.h> #include <gst/gl/gstglcontext.h>
#include "glcontextid.h"
#include "AsyncQueue.h" #include "AsyncQueue.h"

View file

@ -122,6 +122,10 @@ QGLRenderer::newFrame()
this->updateGL(); this->updateGL();
} }
static void flushGstreamerGL(GstGLContext* context,void *data){
context->gl_vtable->Flush();
}
void void
QGLRenderer::paintGL() QGLRenderer::paintGL()
{ {
@ -142,6 +146,10 @@ QGLRenderer::paintGL()
Q_ASSERT(gst_is_gl_memory (mem)); 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, gst_video_info_set_format (&v_info, v_meta->format, v_meta->width,
v_meta->height); v_meta->height);

View file

@ -18,6 +18,7 @@ INCLUDEPATH += \
LIBS += -L"C:/gstreamer/lib" \ LIBS += -L"C:/gstreamer/lib" \
-L"C:/gstreamer/bin" \ -L"C:/gstreamer/bin" \
-lgstreamer-1.0 \ -lgstreamer-1.0 \
-lgstgl-1.0 \
-lgstvideo-1.0 \ -lgstvideo-1.0 \
-lglib-2.0 \ -lglib-2.0 \
-lgmodule-2.0 \ -lgmodule-2.0 \
@ -74,7 +75,6 @@ HEADERS += gstthread.h \
pipeline.h \ pipeline.h \
qglrenderer.h \ qglrenderer.h \
AsyncQueue.h \ AsyncQueue.h \
glcontextid.h
# Source files # Source files
SOURCES += gstthread.cpp \ SOURCES += gstthread.cpp \