gl/examples: update qt examples for api changes
authorMatthew Waters <matthew@centricular.com>
Mon, 15 Jun 2015 06:47:15 +0000 (16:47 +1000)
committerMatthew Waters <matthew@centricular.com>
Mon, 15 Jun 2015 06:47:15 +0000 (16:47 +1000)
12 files changed:
tests/examples/gl/qt/mousevideooverlay/main.cpp
tests/examples/gl/qt/mousevideooverlay/mousevideooverlay.pro
tests/examples/gl/qt/mousevideooverlay/pipeline.cpp
tests/examples/gl/qt/mousevideooverlay/pipeline.h
tests/examples/gl/qt/qglwidgetvideooverlay/main.cpp
tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp
tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h
tests/examples/gl/qt/qglwidgetvideooverlay/qglwidgetvideooverlay.pro
tests/examples/gl/qt/qglwtextureshare/pipeline.cpp
tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp
tests/examples/gl/qt/qglwtextureshare/qglwtextureshare.pro
tests/examples/gl/qt/videooverlay/videooverlay.pro

index de86b77..de5dfa5 100644 (file)
@@ -18,8 +18,8 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include <QtGui/QApplication>
-#include <QtGui/QFileDialog>
+#include <QApplication>
+#include <QFileDialog>
 #include "qrenderer.h"
 
 int main(int argc, char *argv[])
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
     a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
 
     QString videolocation = QFileDialog::getOpenFileName(0, "Select a video file", 
-        ".", "Format (*.avi *.mkv *.ogg *.asf *.mov)");
+        ".", "Format (*.avi *.mkv *.ogg *.asf *.mov *.mp4)");
 
     if (videolocation.isEmpty())
         return -1;
index 98e918d..14fb48d 100644 (file)
@@ -2,7 +2,7 @@ TEMPLATE = app
 TARGET = mousevideooverlay
 DESTDIR = ./debug
 QT += gui widgets opengl
-CONFIG += debug link_pkgconfig compile_libtool
+CONFIG += debug link_pkgconfig
 DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB
 PKGCONFIG = gstreamer-1.0 gstreamer-video-1.0
 
index 8ee60ff..51cc345 100644 (file)
  */
 
 #include <gst/video/videooverlay.h>
+#include <gst/video/video.h>
 #include <GL/gl.h>
 #include "pipeline.h"
 
+#define GST_MAP_GL (GST_MAP_FLAG_LAST << 1)
+
 Pipeline::Pipeline(const WId id, const QString videoLocation):
     m_winId(id),
     m_videoLocation(videoLocation),
@@ -170,7 +173,7 @@ gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guin
 }
 
 //client draw callback
-gboolean Pipeline::drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data)
+gboolean Pipeline::drawCallback (void * sink, void *context, GstSample * sample, gpointer data)
 {
     static GTimeVal current_time;
     static glong last_sec = current_time.tv_sec;
@@ -215,7 +218,7 @@ gboolean Pipeline::drawCallback (GstElement * gl_sink, GstGLContext *context, Gs
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
        
-    glTranslatef(0.0f,0.0f,-5.0f);
+    glScalef(0.5f,0.5f,0.5f);
 
     glRotatef(m_xrot,1.0f,0.0f,0.0f);
     glRotatef(m_yrot,0.0f,1.0f,0.0f);
index 66511ed..b2fe97b 100644 (file)
@@ -62,7 +62,7 @@ private:
     void doRotate();
 
     static gboolean reshapeCallback (void *sink, void *context, guint width, guint height, gpointer data);
-    static gboolean drawCallback (void *sink, void *context, guint texture, guint width, guint height, gpointer data);
+    static gboolean drawCallback (void * sink, void *context, GstSample * sample, gpointer data);
     static gboolean bus_call (GstBus *bus, GstMessage *msg, Pipeline* p);
     static void cb_new_pad (GstElement* decodebin, GstPad* pad, Pipeline* p);
     static gboolean cb_expose (gpointer data);
index a099d36..1265ae4 100644 (file)
@@ -18,8 +18,8 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include <QtGui/QApplication>
-#include <QtGui/QFileDialog>
+#include <QApplication>
+#include <QFileDialog>
 #include "qglrenderer.h"
 
 int main(int argc, char *argv[])
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
     a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
 
     QString videolocation = QFileDialog::getOpenFileName(0, "Select a video file", 
-        ".", "Format (*.avi *.mkv *.ogg *.asf *.mov)");
+        ".", "Format (*.avi *.mkv *.ogg *.asf *.mov *.mp4)");
 
     if (videolocation.isEmpty())
         return -1;
index 90c6be8..daf246a 100644 (file)
  */
 
 #include <gst/video/videooverlay.h>
+#include <gst/video/video.h>
 #include <GL/gl.h>
 #include "pipeline.h"
 
+#define GST_MAP_GL (GST_MAP_FLAG_LAST << 1)
+
 Pipeline::Pipeline(const WId id, const QString videoLocation):
     m_winId(id),
     m_videoLocation(videoLocation),
     m_loop(NULL),
     m_bus(NULL),
     m_pipeline(NULL),
-    m_glupload(NULL),
     m_glimagesink(NULL)
 {
     create();
@@ -56,34 +58,20 @@ void Pipeline::create()
 
     GstElement* videosrc = gst_element_factory_make ("filesrc", "filesrc0");
     GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin0");
-    m_glupload  = gst_element_factory_make ("glcolorscale", NULL);
     m_glimagesink  = gst_element_factory_make ("glimagesink", "sink0");
     
-    if (!videosrc || !decodebin || !m_glupload || !m_glimagesink )
+    if (!videosrc || !decodebin || !m_glimagesink )
     {
         qDebug ("one element could not be found");
         return;
     }
 
-    GstCaps *outcaps = gst_caps_new_simple("video/x-raw",
-                                           "width", G_TYPE_INT, 800,
-                                           "height", G_TYPE_INT, 600,
-                                           NULL) ;
-
     g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL);
     g_object_set(G_OBJECT(videosrc), "location", m_videoLocation.toLatin1().data(), NULL);
     g_signal_connect_object (G_OBJECT(m_glimagesink), "client-reshape", (GCallback) reshapeCallback, NULL, G_CONNECT_AFTER);
     g_signal_connect_object (G_OBJECT(m_glimagesink), "client-draw", (GCallback) drawCallback, NULL, G_CONNECT_AFTER);
 
-    gst_bin_add_many (GST_BIN (m_pipeline), videosrc, decodebin, m_glupload, m_glimagesink, NULL);
-
-    gboolean link_ok = gst_element_link_filtered(m_glupload, m_glimagesink, outcaps) ;
-    gst_caps_unref(outcaps) ;
-    if(!link_ok)
-    {
-        qDebug("Failed to link glupload to glimagesink!\n") ;
-        return;
-    }
+    gst_bin_add_many (GST_BIN (m_pipeline), videosrc, decodebin, m_glimagesink, NULL);
 
     gst_element_link_pads (videosrc, "src", decodebin, "sink");
 
@@ -156,7 +144,7 @@ void Pipeline::exposeRequested()
 //-----------------------------------------------------------------------
 
 //client reshape callback
-gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guint height, gpointer data)
+gboolean Pipeline::reshapeCallback (GstElement *sink, void *context, guint width, guint height, gpointer data)
 {
     glViewport(0, 0, width, height);
     glMatrixMode(GL_PROJECTION);
@@ -167,7 +155,7 @@ gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guin
 }
 
 //client draw callback
-gboolean Pipeline::drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data)
+gboolean Pipeline::drawCallback (GstElement * gl_sink, void *context, GstSample * sample, gpointer data)
 {
     static GLfloat     xrot = 0;
     static GLfloat     yrot = 0;                               
@@ -212,10 +200,10 @@ gboolean Pipeline::drawCallback (GstElement * gl_sink, GstGLContext *context, Gs
     glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-    glMatrixMode(GL_MODELVIEW);
+    glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
        
-    glTranslatef(0.0f,0.0f,-5.0f);
+    glScalef (0.5, 0.5, 0.5);
 
     glRotatef(xrot,1.0f,0.0f,0.0f);
     glRotatef(yrot,0.0f,1.0f,0.0f);
@@ -295,8 +283,8 @@ gboolean Pipeline::bus_call (GstBus *bus, GstMessage *msg, Pipeline* p)
 
 void Pipeline::cb_new_pad (GstElement* decodebin, GstPad* pad, Pipeline* p)
 {
-    GstElement* glupload = p->getVideoSink();
-    GstPad* glpad = gst_element_get_static_pad (glupload, "sink");
+    GstElement* sink = p->getVideoSink();
+    GstPad* glpad = gst_element_get_static_pad (sink, "sink");
     
     //only link once 
     if (GST_PAD_IS_LINKED (glpad)) 
index 459d117..294cb8f 100644 (file)
@@ -37,7 +37,7 @@ public:
     void stop();
     void unconfigure() const;
     void show();
-    GstElement* getVideoSink() { return m_glupload; } ;
+    GstElement* getVideoSink() { return m_glimagesink; } ;
 
 signals:
     void showRequested();
@@ -49,7 +49,6 @@ private:
     GMainLoop* m_loop;
     GstBus* m_bus;
     GstElement* m_pipeline;
-    GstElement* m_glupload;
     GstElement* m_glimagesink;
     static float m_xrot;
     static float m_yrot;
@@ -59,8 +58,8 @@ private:
     WId winId() const { return m_winId; }
     void doExpose() const;
 
-    static gboolean reshapeCallback (void *sink, void *context, guint width, guint height, gpointer data);
-    static gboolean drawCallback (void *sink, void *context, guint texture, guint width, guint height, gpointer data);
+    static gboolean reshapeCallback (GstElement *sink, void *context, guint width, guint height, gpointer data);
+    static gboolean drawCallback (GstElement *sink, void *context, GstSample * sample, gpointer data);
     static gboolean bus_call (GstBus *bus, GstMessage *msg, Pipeline* p);
     static void cb_new_pad (GstElement* decodebin, GstPad* pad, Pipeline* p);
     static gboolean cb_expose (gpointer data);
index 0fa30a9..45837b2 100644 (file)
@@ -4,7 +4,6 @@ DESTDIR = ./debug
 QT += opengl
 CONFIG += debug
 CONFIG += link_pkgconfig
-CONFIG+= compile_libtool
 DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB
 PKGCONFIG = gstreamer-1.0 gstreamer-video-1.0
 
index 404323a..9a8d583 100644 (file)
@@ -55,7 +55,7 @@ Pipeline::configure ()
         ("videotestsrc ! "
             "video/x-raw, width=640, height=480, "
             "framerate=(fraction)30/1 ! "
-            "gleffects effect=5 ! fakesink sync=1", NULL));
+            "glupload ! gleffects effect=5 ! fakesink sync=1", NULL));
   } else {
     QByteArray ba = m_videoLocation.toLocal8Bit ();
     qDebug ("Loading video: %s", ba.data ());
index 066a1f5..ee9c61e 100644 (file)
@@ -169,7 +169,7 @@ QGLRenderer::paintGL ()
 
     GstGLMemory *gl_memory = (GstGLMemory *) mem;
 
-    gst_gl_context_thread_add (gl_memory->context, flushGstreamerGL, NULL);
+    gst_gl_context_thread_add (gl_memory->mem.context, flushGstreamerGL, NULL);
 
     gst_video_info_set_format (&v_info, v_meta->format, v_meta->width,
         v_meta->height);
@@ -199,7 +199,7 @@ QGLRenderer::paintGL ()
     glMatrixMode (GL_MODELVIEW);
     glLoadIdentity ();
 
-    glTranslatef (0.0f, 0.0f, -5.0f);
+    glScalef (0.5f, 0.5f, 0.5f);
 
     glRotatef (xrot, 1.0f, 0.0f, 0.0f);
     glRotatef (yrot, 0.0f, 1.0f, 0.0f);
index 81dc333..9f60bf5 100644 (file)
@@ -5,8 +5,9 @@ QT += opengl
 # Add console to the CONFIG to see debug messages printed in 
 # the console on Windows
 # CONFIG += console
+DESTDIR = ./debug
 DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB
-CONFIG += link_pkgconfig compile_libtool
+CONFIG += link_pkgconfig
 PKGCONFIG=gstreamer-1.0 gstreamer-video-1.0 gstreamer-gl-1.0
 
 win32 {
@@ -71,3 +72,9 @@ SOURCES += gstthread.cpp \
     main.cpp \
     pipeline.cpp \
     qglrenderer.cpp
+
+DEPENDPATH += .
+MOC_DIR += ./GeneratedFiles/debug
+OBJECTS_DIR += debug
+UI_DIR += ./GeneratedFiles
+RCC_DIR += ./GeneratedFiles
index 91f8419..6973414 100644 (file)
@@ -1,7 +1,7 @@
 TEMPLATE = app
 TARGET = videooverlay
 DESTDIR = ./debug
-CONFIG += debug link_pkgconfig compile_libtool
+CONFIG += debug link_pkgconfig
 DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB
 QT += gui widgets
 PKGCONFIG=gstreamer-1.0 gstreamer-video-1.0