From e297811c19111e4696813e3c09187b9dff794ed2 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Sun, 12 Jul 2009 19:35:10 +0300 Subject: [PATCH] Add a simple echo example, which forwards audio from the mic to the speakers. --- CMakeLists.txt | 1 + examples/CMakeLists.txt | 1 + examples/echo/CMakeLists.txt | 2 ++ examples/echo/main.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 examples/CMakeLists.txt create mode 100644 examples/echo/CMakeLists.txt create mode 100644 examples/echo/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 10e948a..6a9cf43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,3 +32,4 @@ include(${QT_USE_FILE}) add_subdirectory(src) add_subdirectory(tests) +add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..de9dcfd --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(echo) diff --git a/examples/echo/CMakeLists.txt b/examples/echo/CMakeLists.txt new file mode 100644 index 0000000..a3bfdf0 --- /dev/null +++ b/examples/echo/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(echo main.cpp) +target_link_libraries(echo ${QT_QTCORE_LIBRARY} QtGstreamer) diff --git a/examples/echo/main.cpp b/examples/echo/main.cpp new file mode 100644 index 0000000..f91b5f0 --- /dev/null +++ b/examples/echo/main.cpp @@ -0,0 +1,52 @@ +/* + Copyright (C) 2009 George Kiagiadakis + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +#include "../../src/qgstpipeline.h" +#include "../../src/qgstelementfactory.h" +#include "../../src/qgstglobal.h" +#include +#include +#include + +using namespace QtGstreamer; + +static void sighandler(int code) +{ + qDebug("SIGINT"); + QCoreApplication::quit(); +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + qGstInit(&argc, &argv); + + QGstPipeline pipeline; + + QGstElement *src = QGstElementFactory::make("autoaudiosrc"); + QGstElement *sink = QGstElementFactory::make("autoaudiosink"); + + pipeline << src << sink; + QGstElement::link(src, sink); + + pipeline.setState(QGstElement::Playing); + + signal(SIGINT, sighandler); + int result = app.exec(); + + pipeline.setState(QGstElement::Null); + return result; +} -- 2.1.4