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

Remove obsolete sound plugin infrastructure and GStreamer backend

The original reason for the plugin infrastructure was due to the
GStreamer 0.10 to 1.x porting because of distros possibly shipping
incompatible versions of QtMultimedia and GStreamer. This reason does
not exist anymore. Moreover, the to expecte QtMultimedia version with
Qt6 will a future proof solution to target more operating systems than
just Linux via GStreamer.
parent a02aebc1
......@@ -34,6 +34,7 @@ include(GenerateExportHeader)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS
Widgets
Sql
Multimedia
XmlPatterns
Qml
Quick
......@@ -48,10 +49,6 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Kirigami2
)
# options
option(BUILD_QTMULTIMEDIA_PLUGIN "Build QtMultimedia sound backend" ON)
option(BUILD_GSTREAMER_PLUGIN "Build GStreamer sound backend" OFF)
add_definitions(
-DQT_NO_URL_CAST_FROM_STRING
)
......
......@@ -5,12 +5,13 @@
kde_enable_exceptions()
set(sound_LIB_SRCS
backendinterface.cpp
capturedevicecontroller.cpp
outputdevicecontroller.cpp
capturebackendinterface.cpp
outputbackendinterface.cpp
libsound_debug.cpp
qtmultimediabackend/qtmultimediacapturebackend.cpp
qtmultimediabackend/qtmultimediaoutputbackend.cpp
)
add_library(artikulatesound SHARED ${sound_LIB_SRCS})
......@@ -21,6 +22,7 @@ target_link_libraries(
LINK_PUBLIC
KF5::CoreAddons
KF5::I18n
Qt::Multimedia
)
# internal library without any API or ABI guarantee
set(GENERIC_LIB_VERSION "0")
......@@ -36,10 +38,3 @@ install(
LIBRARY NAMELINK_SKIP
${KDE_INSTALL_TARGETS_DEFAULT_ARGS}
)
if (BUILD_GSTREAMER_PLUGIN)
ecm_optional_add_subdirectory(qtgstreamerbackend)
endif()
if (BUILD_QTMULTIMEDIA_PLUGIN)
ecm_optional_add_subdirectory(qtmultimediabackend)
endif()
/*
SPDX-FileCopyrightText: 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "backendinterface.h"
BackendInterface::BackendInterface(const QString &name, QObject *parent)
: QObject(parent)
, m_name(name)
{
}
BackendInterface::~BackendInterface()
{
}
QString BackendInterface::name() const
{
return m_name;
}
/*
SPDX-FileCopyrightText: 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef BACKENDINTERFACE_H
#define BACKENDINTERFACE_H
#include "libsound_export.h"
#include <QObject>
#include <QString>
class CaptureBackendInterface;
class OutputBackendInterface;
class LIBSOUND_EXPORT BackendInterface : public QObject
{
Q_OBJECT
public:
explicit BackendInterface(const QString &name, QObject *parent = nullptr);
~BackendInterface() override;
QString name() const;
virtual CaptureBackendInterface *captureBackend() const = 0;
virtual OutputBackendInterface *outputBackend() const = 0;
private:
const QString m_name;
};
#endif
......@@ -11,6 +11,4 @@ CaptureBackendInterface::CaptureBackendInterface(QObject *parent)
{
}
CaptureBackendInterface::~CaptureBackendInterface()
{
}
CaptureBackendInterface::~CaptureBackendInterface() = default;
......@@ -5,14 +5,10 @@
*/
#include "capturedevicecontroller.h"
#include "backendinterface.h"
#include "capturebackendinterface.h"
#include "libsound_debug.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
#include "qtmultimediabackend/qtmultimediacapturebackend.h"
#include <memory>
/**
* \class CaptureDeviceControllerPrivate
......@@ -27,54 +23,17 @@ class CaptureDeviceControllerPrivate
{
public:
CaptureDeviceControllerPrivate(QObject *parent)
: m_parent(parent)
, m_backend(nullptr)
, m_initialized(false)
{
// load plugins
const QVector<KPluginMetaData> metadataList = KPluginLoader::findPlugins(QStringLiteral("artikulate/libsound"));
for (const auto &metadata : metadataList) {
qCDebug(LIBSOUND_LOG) << "Load Plugin: " << metadata.name();
KPluginFactory *factory = KPluginLoader(metadata.fileName()).factory();
if (!factory) {
qCCritical(LIBSOUND_LOG) << "Could not load plugin: " << metadata.name();
continue;
}
BackendInterface *plugin = factory->create<BackendInterface>(parent, QList<QVariant>());
if (plugin->captureBackend()) {
m_backendList.append(plugin->captureBackend());
}
}
if (!m_backend && !m_backendList.isEmpty()) {
m_backend = m_backendList.first();
}
}
~CaptureDeviceControllerPrivate()
: m_backend(new QtMultimediaCaptureBackend(parent))
{
delete m_backend;
m_backend = nullptr;
}
void lazyInit()
{
if (m_initialized) {
return;
}
// TODO currently nothing to do
m_initialized = true;
}
CaptureBackendInterface *backend() const
{
Q_ASSERT(m_backend);
return m_backend;
return m_backend.get();
}
QObject *m_parent;
CaptureBackendInterface *m_backend;
QList<CaptureBackendInterface *> m_backendList;
bool m_initialized;
std::unique_ptr<CaptureBackendInterface> m_backend;
};
CaptureDeviceController::CaptureDeviceController()
......@@ -82,14 +41,11 @@ CaptureDeviceController::CaptureDeviceController()
{
}
CaptureDeviceController::~CaptureDeviceController()
{
}
CaptureDeviceController::~CaptureDeviceController() = default;
CaptureDeviceController &CaptureDeviceController::self()
{
static CaptureDeviceController instance;
instance.d->lazyInit();
return instance;
}
......
......@@ -8,8 +8,8 @@
#define CAPTUREDEVICECONTROLLER_H
#include "libsound_export.h"
#include <QObject>
#include <memory>
class CaptureDeviceControllerPrivate;
......@@ -62,7 +62,7 @@ private:
*/
~CaptureDeviceController() override;
const QScopedPointer<CaptureDeviceControllerPrivate> d;
const std::unique_ptr<CaptureDeviceControllerPrivate> d;
};
#endif
......@@ -11,6 +11,4 @@ OutputBackendInterface::OutputBackendInterface(QObject *parent)
{
}
OutputBackendInterface::~OutputBackendInterface()
{
}
OutputBackendInterface::~OutputBackendInterface() = default;
......@@ -5,17 +5,11 @@
*/
#include "outputdevicecontroller.h"
#include "backendinterface.h"
#include "libsound_debug.h"
#include "outputbackendinterface.h"
#include "qtmultimediabackend/qtmultimediaoutputbackend.h"
#include <QUrl>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
#include "libsound_debug.h"
/**
* \class OutputDeviceControllerPrivate
* \internal
......@@ -29,55 +23,20 @@ class OutputDeviceControllerPrivate
{
public:
OutputDeviceControllerPrivate(OutputDeviceController *parent)
: m_parent(parent)
, m_backend(nullptr)
, m_volume(0)
, m_initialized(false)
{
const QVector<KPluginMetaData> metadataList = KPluginLoader::findPlugins(QStringLiteral("artikulate/libsound"));
for (const auto &metadata : metadataList) {
qCDebug(LIBSOUND_LOG) << "Load Plugin: " << metadata.name();
KPluginFactory *factory = KPluginLoader(metadata.fileName()).factory();
if (!factory) {
qCCritical(LIBSOUND_LOG) << "Could not load plugin:" << metadata.name();
continue;
}
BackendInterface *plugin = factory->create<BackendInterface>(parent, QList<QVariant>());
if (plugin->outputBackend()) {
m_backendList.append(plugin->outputBackend());
}
}
if (!m_backend && !m_backendList.isEmpty()) {
m_backend = m_backendList.first();
}
}
~OutputDeviceControllerPrivate()
{
delete m_backend;
}
void lazyInit()
: m_backend(new QtMultimediaOutputBackend(parent))
, m_volume(m_backend->volume())
{
if (m_initialized) {
return;
}
m_parent->connect(m_backend, &OutputBackendInterface::stateChanged, m_parent, &OutputDeviceController::emitChangedState);
m_volume = m_backend->volume();
m_initialized = true;
parent->connect(m_backend.get(), &OutputBackendInterface::stateChanged, parent, &OutputDeviceController::emitChangedState);
}
OutputBackendInterface *backend() const
{
Q_ASSERT(m_backend);
return m_backend;
return m_backend.get();
}
OutputDeviceController *m_parent;
OutputBackendInterface *m_backend;
QList<OutputBackendInterface *> m_backendList;
int m_volume; // volume as cubic value
bool m_initialized;
std::unique_ptr<OutputBackendInterface> m_backend;
int m_volume{0}; // volume as cubic value
};
OutputDeviceController::OutputDeviceController()
......@@ -92,7 +51,6 @@ OutputDeviceController::~OutputDeviceController()
OutputDeviceController &OutputDeviceController::self()
{
static OutputDeviceController instance;
instance.d->lazyInit();
return instance;
}
......
......@@ -9,6 +9,7 @@
#include "libsound_export.h"
#include <QObject>
#include <memory>
class OutputDeviceControllerPrivate;
class QUrl;
......@@ -23,7 +24,11 @@ class LIBSOUND_EXPORT OutputDeviceController : public QObject
Q_OBJECT
public:
enum State { StoppedState, PlayingState, PausedState };
enum State {
StoppedState,
PlayingState,
PausedState,
};
/**
* Returns self reference to the controller. First call of this method initializes
......@@ -60,7 +65,7 @@ private:
*/
~OutputDeviceController() override;
const QScopedPointer<OutputDeviceControllerPrivate> d;
const std::unique_ptr<OutputDeviceControllerPrivate> d;
};
#endif
# SPDX-FileCopyrightText: 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
# SPDX-License-Identifier: BSD-2-Clause
find_package(Qt5GStreamer 1.2.0 REQUIRED)
include_directories(
${QTGSTREAMER_INCLUDES}
)
set(qtgstreamerbackend_SRCS
qtgstreamerbackend.cpp
qtgstreamercapturebackend.cpp
qtgstreameroutputbackend.cpp
../libsound_debug.cpp
)
add_library(qtgstreamerbackend MODULE ${qtgstreamerbackend_SRCS})
target_link_libraries(
qtgstreamerbackend
LINK_PUBLIC
artikulatesound
KF5::CoreAddons
${QTGLIB_LIBRARIES}
${QTGLIB_LIBRARY}
${QTGSTREAMER_LIBRARIES}
)
install(TARGETS qtgstreamerbackend DESTINATION ${KDE_INSTALL_PLUGINDIR}/artikulate/libsound)
/*
SPDX-FileCopyrightText: 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "qtgstreamerbackend.h"
#include "qtgstreamercapturebackend.h"
#include "qtgstreameroutputbackend.h"
#include <KPluginFactory>
K_PLUGIN_FACTORY_WITH_JSON(BackendFactory, "qtgstreamerbackend.json", registerPlugin<QtGStreamerBackend>();)
QtGStreamerBackend::QtGStreamerBackend(QObject *parent, const QList<QVariant> &)
: BackendInterface("qtgstreamer", parent)
, m_captureBackend(nullptr)
, m_outputBackend(nullptr)
{
}
QtGStreamerBackend::~QtGStreamerBackend()
{
if (m_captureBackend) {
m_captureBackend->deleteLater();
m_captureBackend = nullptr;
}
if (m_outputBackend) {
m_outputBackend->deleteLater();
m_outputBackend = nullptr;
}
}
CaptureBackendInterface *QtGStreamerBackend::captureBackend() const
{
if (!m_captureBackend) {
m_captureBackend = new QtGStreamerCaptureBackend();
}
return m_captureBackend;
}
OutputBackendInterface *QtGStreamerBackend::outputBackend() const
{
if (!m_outputBackend) {
m_outputBackend = new QtGStreamerOutputBackend();
}
return m_outputBackend;
}
#include "qtgstreamerbackend.moc"
/*
SPDX-FileCopyrightText: 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef GSTREAMERBACKEND_H
#define GSTREAMERBACKEND_H
#include "../backendinterface.h"
class CaptureBackendInterface;
class OutputBackendInterface;
class QtGStreamerCaptureBackend;
class QtGStreamerOutputBackend;
class QtGStreamerBackend : public BackendInterface
{
Q_OBJECT
public:
explicit QtGStreamerBackend(QObject *parent, const QList<QVariant> &);
virtual ~QtGStreamerBackend();
CaptureBackendInterface *captureBackend() const;
OutputBackendInterface *outputBackend() const;
private:
mutable QtGStreamerCaptureBackend *m_captureBackend;
mutable QtGStreamerOutputBackend *m_outputBackend;
};
#endif
{
"Encoding": "UTF-8",
"KPlugin": {
"Category": "Plugins",
"Description": "Sound backend for GStreamer.",
"Description[ar]": "خلفية الصوت لجي ستريمر",
"Description[az]": "GStreamer üçün Səs modulu.",
"Description[ca@valencia]": "Dorsal de so per GStreamer.",
"Description[ca]": "Dorsal de so pel GStreamer.",
"Description[cs]": "Podpůrná vrstva zvuku pro GStreamer.",
"Description[de]": "Sound-Backend für GStreamer.",
"Description[el]": "Σύστημα υποστήριξης ήχου για GStreamer.",
"Description[en_GB]": "Sound backend for GStreamer.",
"Description[es]": "Motor de sonido para GStreamer.",
"Description[et]": "GStreameri heli-taustaprogramm",
"Description[eu]": "GStreamer-rerako soinu-bizkarraldekoa.",
"Description[fi]": "GStreamer-äänitaustajärjestelmä",
"Description[fr]": "Moteur de son pour GStreamer.",
"Description[gl]": "Infraestrutura de son para GStreamer.",
"Description[hi]": "जी-स्ट्रीमर के लिए ध्वनि बैकएंड।",
"Description[hu]": "Hangmodul GStreamerhez.",
"Description[ia]": "Retro-administration de Sono per GStreamer.",
"Description[it]": "Motore sonoro per GStreamer.",
"Description[ka]": "ხმის უკანაბოლო GStreamer-სთვის.",
"Description[ko]": "GStreamer 소리 백엔드입니다.",
"Description[nl]": "Geluidsbackend voor GStreamer.",
"Description[nn]": "Lydmotor for GStreamer.",
"Description[pl]": "Silnik dźwięku dla GStreamer.",
"Description[pt]": "Infra-estrutura de som para o GStreamer.",
"Description[pt_BR]": "Infraestrutura de som para o GStreamer.",
"Description[ru]": "Работа со звуком через GStreamer.",
"Description[sk]": "Zvukový backend pre GStreamer.",
"Description[sl]": "Zvočno zaledje za GStreamer.",
"Description[sv]": "Ljudgränssnitt för Gstreamer.",
"Description[tr]": "GStreamer için ses arka ucu.",
"Description[uk]": "Звуковий модуль для GStreamer.",
"Description[x-test]": "xxSound backend for GStreamer.xx",
"Description[zh_CN]": "GStreamer 声音后端",
"Description[zh_TW]": "GStreamer 音效後端介面。",
"Id": "artikulate_gstreamer_backend",
"License": "GPL",
"Name": "GStreamer Backend",
"Name[ar]": "خلفية جي ستريمر",
"Name[az]": "GStreamer Modulu",
"Name[ca@valencia]": "Dorsal GStreamer",
"Name[ca]": "Dorsal GStreamer",
"Name[cs]": "Podpůrná vrstva GStreamer",
"Name[de]": "Backend für GStreamer",
"Name[el]": "Σύστημα υποστήριξης GStreamer",
"Name[en_GB]": "GStreamer Backend",
"Name[es]": "Motor GStreamer",
"Name[et]": "GStreameri taustaprogramm",
"Name[eu]": "GStreamer bizkarraldekoa",
"Name[fi]": "GStreamer-taustajärjestelmä",
"Name[fr]": "Moteur GStreamer",
"Name[gl]": "Infraestrutura de GStreamer",
"Name[hi]": "जी-स्ट्रीमर बैकएंड",
"Name[hu]": "GStreamer modul",
"Name[ia]": "Retro-administration de GStreamer",
"Name[it]": "Motore GStreamer",
"Name[ka]": "GStreamer -ის უკანაბოლო",
"Name[ko]": "GStreamer 백엔드",
"Name[nl]": "GStreamer-backend",
"Name[nn]": "GStreamer-motor",
"Name[pl]": "Silnik GStreamer",
"Name[pt]": "Infra-Estrutura para o GStreamer",
"Name[pt_BR]": "Infraestrutura do GStreamer",
"Name[ru]": "Модуль поддержки GStreamer",
"Name[sk]": "GStreamer Backend",
"Name[sl]": "Zaledje GStreamer",
"Name[sv]": "Gstreamer-gränssnitt",
"Name[tr]": "GStreamer Arka Ucu",
"Name[uk]": "Модуль GStreamer",
"Name[x-test]": "xxGStreamer Backendxx",
"Name[zh_CN]": "GStreamer 后端",
"Name[zh_TW]": "GStreamer 後端介面",
"Version": "0.1"
}
}
SPDX-FileCopyrightText: 2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
SPDX-FileCopyrightText: KDE Translators
SPDX-License-Identifier: LGPL-2.1-or-later
/*
SPDX-FileCopyrightText: 2013-2014 Andreas Cord-Landwehr <cordlandwehr@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "qtgstreamercapturebackend.h"
#include "libsound_debug.h"
#include <KLocalizedString>
#include <QGlib/Error>
#include <QGst/Bus>
#include <QGst/ElementFactory>
#include <QGst/Event>
#include <QGst/Message>
#include <QGst/Pad>
QtGStreamerCaptureBackend::QtGStreamerCaptureBackend()
{
QGst::init();
// setup the device list
QGst::ElementPtr src = QGst::ElementFactory::make("autoaudiosrc");
if (!src) {
qCritical() << "Failed to create element \"autoaudiosrc\". Make sure you have "
<< "gstreamer-plugins-good installed";
return;
}
m_availableDevices.insert("", i18nc("default sound device", "Default"));
}
QtGStreamerCaptureBackend::~QtGStreamerCaptureBackend()
{
m_pipeline.clear();
}
CaptureDeviceController::State QtGStreamerCaptureBackend::captureState() const
{
if (!m_pipeline) {
return CaptureDeviceController::StoppedState;
}
switch (m_pipeline->currentState()) {
case QGst::StateNull:
return CaptureDeviceController::StoppedState;
break;
case QGst::StatePaused:
return CaptureDeviceController::RecordingState;
break;
case QGst::StatePlaying:
return CaptureDeviceController::RecordingState;