Commit b3e579c9 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Remove sound backend layer.

We finally only support QtGStreamer and to not have to provide an
interface to plug in other sound backends.
parent f6d1ec71
......@@ -32,8 +32,7 @@ include_directories(
set(sound_LIB_SRCS
capturedevicecontroller.cpp
outputdevicecontroller.cpp
qtgstreamerbackend.cpp
soundbackendinterface.cpp
qtgstreamercapturebackend.cpp
)
kde4_add_library(artikulatesound SHARED ${sound_LIB_SRCS})
......
......@@ -19,8 +19,7 @@
*/
#include "capturedevicecontroller.h"
#include "soundbackendinterface.h"
#include "qtgstreamerbackend.h"
#include "qtgstreamercapturebackend.h"
#include <config.h>
#include <QUrl>
#include <QStringList>
......@@ -46,10 +45,8 @@ public:
~CaptureDeviceControllerPrivate()
{
for (int i = 0; i < m_backends.size(); ++i) {
m_backends.at(i)->deleteLater();
}
m_backends.clear();
delete m_backend;
m_backend = 0;
}
void lazyInit()
......@@ -57,18 +54,18 @@ public:
if (m_initialized) {
return;
}
m_backends.append(new QtGStreamerBackend());
m_backend = new QtGStreamerCaptureBackend();
m_initialized = true;
}
SoundBackendInterface * backend() const
QtGStreamerCaptureBackend * backend() const
{
Q_ASSERT(m_backends.count() > 0);
return m_backends.first();
Q_ASSERT(m_backend);
return m_backend;
}
QObject *m_parent;
QList<SoundBackendInterface*> m_backends;
QtGStreamerCaptureBackend *m_backend;
bool m_initialized;
};
......
......@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qtgstreamerbackend.h"
#include "qtgstreamercapturebackend.h"
#include <QGlib/Error>
#include <QGlib/Connect>
......@@ -34,7 +34,7 @@
#include <KDebug>
#include <KLocale>
QtGStreamerBackend::QtGStreamerBackend()
QtGStreamerCaptureBackend::QtGStreamerCaptureBackend()
{
QGst::init();
......@@ -50,17 +50,12 @@ QtGStreamerBackend::QtGStreamerBackend()
m_availableDevices.insert("", i18nc("default sound device", "Default"));
}
QtGStreamerBackend::~QtGStreamerBackend()
QtGStreamerCaptureBackend::~QtGStreamerCaptureBackend()
{
m_pipeline.clear();
}
QString QtGStreamerBackend::identifier()
{
return QLatin1String("qtgstreamerbackend");
}
CaptureDeviceController::State QtGStreamerBackend::captureState()
CaptureDeviceController::State QtGStreamerCaptureBackend::captureState()
{
if (!m_pipeline) {
return CaptureDeviceController::StoppedState;
......@@ -81,7 +76,7 @@ CaptureDeviceController::State QtGStreamerBackend::captureState()
}
}
QGst::BinPtr QtGStreamerBackend::createAudioSrcBin()
QGst::BinPtr QtGStreamerCaptureBackend::createAudioSrcBin()
{
QGst::BinPtr audioBin;
......@@ -99,7 +94,7 @@ QGst::BinPtr QtGStreamerBackend::createAudioSrcBin()
return audioBin;
}
void QtGStreamerBackend::onBusMessage(const QGst::MessagePtr & message)
void QtGStreamerCaptureBackend::onBusMessage(const QGst::MessagePtr & message)
{
switch (message->type()) {
case QGst::MessageEos:
......@@ -121,7 +116,7 @@ void QtGStreamerBackend::onBusMessage(const QGst::MessagePtr & message)
}
}
void QtGStreamerBackend::startCapture(const QString &filePath)
void QtGStreamerCaptureBackend::startCapture(const QString &filePath)
{
// clear pipeline if still existing
if (m_pipeline) {
......@@ -154,11 +149,11 @@ void QtGStreamerBackend::startCapture(const QString &filePath)
//connect the bus
m_pipeline->bus()->addSignalWatch();
QGlib::connect(m_pipeline->bus(), "message", this, &QtGStreamerBackend::onBusMessage);
QGlib::connect(m_pipeline->bus(), "message", this, &QtGStreamerCaptureBackend::onBusMessage);
m_pipeline->setState(QGst::StatePlaying);
}
void QtGStreamerBackend::stopCapture()
void QtGStreamerCaptureBackend::stopCapture()
{
if (m_pipeline) { //pipeline exists - destroy it
//send an end-of-stream event to flush metadata and cause an EosMessage to be delivered
......@@ -166,7 +161,7 @@ void QtGStreamerBackend::stopCapture()
}
}
void QtGStreamerBackend::stopPipeline()
void QtGStreamerCaptureBackend::stopPipeline()
{
if (!m_pipeline) {
kWarning() << "Stopping non-existing pipeline, aborting";
......@@ -176,7 +171,7 @@ void QtGStreamerBackend::stopPipeline()
m_pipeline.clear();
}
QStringList QtGStreamerBackend::devices() const
QStringList QtGStreamerCaptureBackend::devices() const
{
//TODO qtgstreamer backend currently only provides access to default backend,
// reenable selection by using Gst::Device
......@@ -184,7 +179,7 @@ QStringList QtGStreamerBackend::devices() const
return m_availableDevices.keys();
}
void QtGStreamerBackend::setDevice(const QString& deviceIdentifier)
void QtGStreamerCaptureBackend::setDevice(const QString& deviceIdentifier)
{
//TODO add sanity check
m_device = deviceIdentifier;
......
......@@ -18,33 +18,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QTGSTREAMERBACKEND_H
#define QTGSTREAMERBACKEND_H
#ifndef QTGSTREAMERCAPTUREBACKEND_H
#define QTGSTREAMERCAPTUREBACKEND_H
#include "soundbackendinterface.h"
#include "capturedevicecontroller.h"
#include <QString>
#include <QGst/global.h>
#include <QGst/Pipeline>
class QtGStreamerBackend : public SoundBackendInterface
class QtGStreamerCaptureBackend : public QObject
{
Q_OBJECT
public:
QtGStreamerBackend();
QtGStreamerCaptureBackend();
virtual ~QtGStreamerBackend();
~QtGStreamerCaptureBackend();
virtual QString identifier();
void startCapture(const QString &filePath);
void stopCapture();
CaptureDeviceController::State captureState();
virtual void startCapture(const QString &filePath);
virtual void stopCapture();
virtual CaptureDeviceController::State captureState();
virtual QStringList devices() const;
virtual void setDevice(const QString &deviceIdentifier);
QStringList devices() const;
void setDevice(const QString &deviceIdentifier);
private:
void onBusMessage(const QGst::MessagePtr &message);
......
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "soundbackendinterface.h"
QString SoundBackendInterface::identifier()
{
return "ERROR_unset";
}
SoundBackendInterface::SoundBackendInterface(): QObject()
{
}
SoundBackendInterface::~SoundBackendInterface()
{
}
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOUNDBACKENDINTERFACE_H
#define SOUNDBACKENDINTERFACE_H
#include <QObject>
#include "capturedevicecontroller.h"
class SoundBackendInterface : public QObject
{
Q_OBJECT
public:
SoundBackendInterface();
virtual ~SoundBackendInterface();
virtual QString identifier();
virtual QStringList devices() const = 0;
virtual void setDevice(const QString &device) = 0;
virtual void startCapture(const QString &filePath) = 0;
virtual void stopCapture() = 0;
virtual CaptureDeviceController::State captureState() = 0;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment