mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
gl/examples: update qt examples for api changes
This commit is contained in:
parent
8c36e5193e
commit
aff768f34c
12 changed files with 39 additions and 43 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
*/
|
||||
|
||||
#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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -19,16 +19,18 @@
|
|||
*/
|
||||
|
||||
#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))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 ());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue