Port the 'echo' example to the new bindings to make it work again.
[qtgstreamer:qtgstreamer.git] / examples / echo / main.cpp
1 /*
2     Copyright (C) 2009-2010  George Kiagiadakis <kiagiadakis.george@gmail.com>
3
4     This library is free software; you can redistribute it and/or modify
5     it under the terms of the GNU Lesser General Public License as published
6     by the Free Software Foundation; either version 2.1 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include <QGst/Pipeline>
18 #include <QGst/ElementFactory>
19 #include <QGst/Global>
20 #include <QtCore/QCoreApplication>
21 #include <QtCore/QFile>
22 #include <signal.h>
23
24 static void sighandler(int code)
25 {
26     Q_UNUSED(code);
27     qDebug("SIGINT");
28     QCoreApplication::quit();
29 }
30
31 int main(int argc, char **argv)
32 {
33     QCoreApplication app(argc, argv);
34     QGst::init(&argc, &argv);
35
36     QGst::PipelinePtr pipeline = QGst::Pipeline::newPipeline();
37
38     QGst::ElementPtr src = QGst::ElementFactory::make("audiotestsrc");
39     QGst::ElementPtr sink = QGst::ElementFactory::make("autoaudiosink");
40
41     pipeline->add(src);
42     pipeline->add(sink);
43     src->link(sink);
44
45     pipeline->setState(QGst::StatePlaying);
46
47     signal(SIGINT, sighandler);
48     int result = app.exec();
49
50     pipeline->setState(QGst::StateNull);
51     QGst::deinit();
52
53     return result;
54 }