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

Introduce capture backend interface.

parent 5328db17
......@@ -35,6 +35,7 @@ include_directories(
set(sound_LIB_SRCS
capturedevicecontroller.cpp
outputdevicecontroller.cpp
capturebackendinterface.cpp
outputbackendinterface.cpp
qtgstreamercapturebackend.cpp
qtgstreameroutputbackend.cpp
......
/*
* Copyright 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* 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 Lesser 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 <http://www.gnu.org/licenses/>.
*/
#include "capturebackendinterface.h"
CaptureBackendInterface::CaptureBackendInterface(QObject *parent)
: QObject(parent)
{
}
CaptureBackendInterface::~CaptureBackendInterface()
{
}
/*
* Copyright 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* 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 Lesser 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CAPTUREBACKENDINTERFACE_H
#define CAPTUREBACKENDINTERFACE_H
#include "capturedevicecontroller.h"
#include "libsound_export.h"
#include <QObject>
class LIBSOUND_EXPORT CaptureBackendInterface : public QObject
{
Q_OBJECT
public:
explicit CaptureBackendInterface(QObject *parent = nullptr);
virtual ~CaptureBackendInterface();
virtual void startCapture(const QString &filePath) = 0;
virtual void stopCapture() = 0;
virtual CaptureDeviceController::State captureState() const = 0;
virtual QStringList devices() const = 0;
virtual void setDevice(const QString &deviceIdentifier) = 0;
};
#endif
......@@ -16,6 +16,7 @@
*/
#include "capturedevicecontroller.h"
#include "capturebackendinterface.h"
#include "qtgstreamercapturebackend.h"
#include <QUrl>
#include <QStringList>
......@@ -42,7 +43,7 @@ public:
~CaptureDeviceControllerPrivate()
{
delete m_backend;
m_backend = 0;
m_backend = nullptr;
}
void lazyInit()
......@@ -54,14 +55,14 @@ public:
m_initialized = true;
}
QtGStreamerCaptureBackend * backend() const
CaptureBackendInterface * backend() const
{
Q_ASSERT(m_backend);
return m_backend;
}
QObject *m_parent;
QtGStreamerCaptureBackend *m_backend;
CaptureBackendInterface *m_backend;
bool m_initialized;
};
......
......@@ -51,7 +51,7 @@ QtGStreamerCaptureBackend::~QtGStreamerCaptureBackend()
m_pipeline.clear();
}
CaptureDeviceController::State QtGStreamerCaptureBackend::captureState()
CaptureDeviceController::State QtGStreamerCaptureBackend::captureState() const
{
if (!m_pipeline) {
return CaptureDeviceController::StoppedState;
......
......@@ -19,13 +19,14 @@
#define QTGSTREAMERCAPTUREBACKEND_H
#include "capturedevicecontroller.h"
#include "capturebackendinterface.h"
#include <QString>
#include <QGst/global.h>
#include <QGst/Pipeline>
class QtGStreamerCaptureBackend : public QObject
class QtGStreamerCaptureBackend : public CaptureBackendInterface
{
Q_OBJECT
......@@ -36,7 +37,7 @@ public:
void startCapture(const QString &filePath);
void stopCapture();
CaptureDeviceController::State captureState();
CaptureDeviceController::State captureState() const;
QStringList devices() const;
void setDevice(const QString &deviceIdentifier);
......
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