• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * GStreamer
3  * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
4  * Copyright (C) 2009 Andrey Nechypurenko <andreynech@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #include "pipeline.h"
23 #include "gstthread.h"
24 
25 
GstThread(GstGLDisplay * display,GstGLContext * context,const QString & videoLocation,const char * renderer_slot,QObject * parent)26 GstThread::GstThread(GstGLDisplay *display,
27         GstGLContext *context,
28         const QString &videoLocation,
29         const char *renderer_slot,
30         QObject *parent):
31     QThread(parent),
32     m_videoLocation(videoLocation)
33 {
34     m_pipeline = new Pipeline(display, context, m_videoLocation, this);
35     QObject::connect(m_pipeline, SIGNAL(newFrameReady()), this->parent(), renderer_slot, Qt::QueuedConnection);
36 }
37 
~GstThread()38 GstThread::~GstThread()
39 {
40 }
41 
stop()42 void GstThread::stop()
43 {
44     if(m_pipeline)
45       m_pipeline->stop();
46 }
47 
run()48 void GstThread::run()
49 {
50     qDebug("Starting gst pipeline");
51     m_pipeline->start(); //it runs the gmainloop on win32
52 
53 #ifndef Q_WS_WIN
54     //works like the gmainloop on linux (GstEvent are handled)
55     connect(m_pipeline, SIGNAL(stopRequested()), this, SLOT(quit()));
56     exec();
57 #endif
58 
59     m_pipeline->unconfigure();
60 
61     m_pipeline = NULL;
62     // This is not a memory leak. Pipeline will be deleted
63     // when the parent object (this) will be destroyed.
64     // We set m_pipeline to NULL to prevent further attempts
65     // to stop already stopped pipeline
66 }
67