summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2022-01-10 09:31:48 +0100
committerLars Knoll <lars.knoll@qt.io>2022-01-11 15:16:12 +0100
commitccdc369cb82180bc12c3a6b00d33afad2848ba02 (patch)
treec22dd3e705c4bffe9b91aa0ddcd9e2edec3b752b
parent92f526ca472ba206883a8bbfd201469d52a1f1fc (diff)
Reintroduce a plugin architecture for multimedia backends
This is required, so we can introduce FFMpeg as a technology preview, and have both backends available in one compiled version of Qt. The plugin archicture is much simpler than in Qt 5, using one plugin per backend, not multiple. Export a couple of classes and methods from Qt Multimedia that are required for the backends to work. Change-Id: I99ab324c5ee018a3cefcf32d82f16a0bf6b5d409 Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/multimedia/CMakeLists.txt3
-rw-r--r--src/multimedia/audio/qaudiodevice_p.h2
-rw-r--r--src/multimedia/audio/qaudiohelpers_p.h2
-rw-r--r--src/multimedia/audio/qaudiosystem_p.h4
-rw-r--r--src/multimedia/platform/qplatformmediaintegration.cpp59
-rw-r--r--src/multimedia/platform/qplatformmediaplugin_p.h79
-rw-r--r--src/multimedia/qiso639_2_p.h4
-rw-r--r--src/multimedia/qmediastoragelocation_p.h4
-rw-r--r--src/multimedia/recording/qmediarecorder_p.h2
-rw-r--r--src/multimedia/video/qabstractvideobuffer_p.h2
-rw-r--r--src/multimedia/video/qvideotexturehelper.cpp11
-rw-r--r--src/plugins/CMakeLists.txt6
12 files changed, 144 insertions, 34 deletions
diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt
index a830ca770..12755ece1 100644
--- a/src/multimedia/CMakeLists.txt
+++ b/src/multimedia/CMakeLists.txt
@@ -13,7 +13,7 @@ qt_internal_find_apple_system_framework(FWVideoToolbox VideoToolbox) # special c
qt_internal_find_apple_system_framework(FWAVFoundation AVFoundation) # special case
qt_internal_add_module(Multimedia
- PLUGIN_TYPES video/gstvideorenderer video/videonode
+ PLUGIN_TYPES multimedia
SOURCES
audio/qaudio.cpp audio/qaudio.h
audio/qaudiobuffer.cpp audio/qaudiobuffer.h
@@ -43,6 +43,7 @@ qt_internal_add_module(Multimedia
platform/qplatformmediaformatinfo.cpp platform/qplatformmediaformatinfo_p.h
platform/qplatformmediaintegration.cpp platform/qplatformmediaintegration_p.h
platform/qplatformmediaplayer.cpp platform/qplatformmediaplayer_p.h
+ platform/qplatformmediaplugin_p.h
platform/qplatformvideosink.cpp platform/qplatformvideosink_p.h
playback/qmediaplayer.cpp playback/qmediaplayer.h playback/qmediaplayer_p.h
qmediadevices.cpp qmediadevices.h
diff --git a/src/multimedia/audio/qaudiodevice_p.h b/src/multimedia/audio/qaudiodevice_p.h
index 9ab75800c..8015da507 100644
--- a/src/multimedia/audio/qaudiodevice_p.h
+++ b/src/multimedia/audio/qaudiodevice_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-class QAudioDevicePrivate : public QSharedData
+class Q_MULTIMEDIA_EXPORT QAudioDevicePrivate : public QSharedData
{
public:
QAudioDevicePrivate(const QByteArray &i, QAudioDevice::Mode m)
diff --git a/src/multimedia/audio/qaudiohelpers_p.h b/src/multimedia/audio/qaudiohelpers_p.h
index 33ea308d3..c59e01cad 100644
--- a/src/multimedia/audio/qaudiohelpers_p.h
+++ b/src/multimedia/audio/qaudiohelpers_p.h
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
namespace QAudioHelperInternal
{
-void qMultiplySamples(qreal factor, const QAudioFormat& format, const void *src, void* dest, int len);
+Q_MULTIMEDIA_EXPORT void qMultiplySamples(qreal factor, const QAudioFormat& format, const void *src, void* dest, int len);
}
QT_END_NAMESPACE
diff --git a/src/multimedia/audio/qaudiosystem_p.h b/src/multimedia/audio/qaudiosystem_p.h
index ae1c54dde..c5e145fcc 100644
--- a/src/multimedia/audio/qaudiosystem_p.h
+++ b/src/multimedia/audio/qaudiosystem_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
class QIODevice;
-class QPlatformAudioSink : public QObject
+class Q_MULTIMEDIA_EXPORT QPlatformAudioSink : public QObject
{
Q_OBJECT
@@ -92,7 +92,7 @@ Q_SIGNALS:
void stateChanged(QAudio::State state);
};
-class QPlatformAudioSource : public QObject
+class Q_MULTIMEDIA_EXPORT QPlatformAudioSource : public QObject
{
Q_OBJECT
diff --git a/src/multimedia/platform/qplatformmediaintegration.cpp b/src/multimedia/platform/qplatformmediaintegration.cpp
index c3b4f1444..fc6e6b59a 100644
--- a/src/multimedia/platform/qplatformmediaintegration.cpp
+++ b/src/multimedia/platform/qplatformmediaintegration.cpp
@@ -43,6 +43,10 @@
#include <qmutex.h>
#include <qplatformaudioinput_p.h>
#include <qplatformaudiooutput_p.h>
+#include <qloggingcategory.h>
+
+#include "QtCore/private/qfactoryloader_p.h"
+#include "qplatformmediaplugin_p.h"
#if QT_CONFIG(gstreamer)
#include <private/qgstreamerintegration_p.h>
@@ -76,6 +80,27 @@ public:
using PlatformIntegration = QDummyIntegration;
#endif
+Q_LOGGING_CATEGORY(qLcMediaPlugin, "qt.multimedia.plugin")
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QPlatformMediaPlugin_iid,
+ QLatin1String("/multimedia")))
+
+static QStringList backends()
+{
+ QStringList list;
+
+ if (QFactoryLoader *fl = loader()) {
+ const auto keyMap = fl->keyMap();
+ for (auto it = keyMap.constBegin(); it != keyMap.constEnd(); ++it)
+ if (!list.contains(it.value()))
+ list << it.value();
+ }
+
+ qCDebug(qLcMediaPlugin) << "Available backends" << list;
+ return list;
+}
+
QT_BEGIN_NAMESPACE
namespace {
@@ -83,26 +108,37 @@ struct Holder {
~Holder()
{
QMutexLocker locker(&mutex);
- delete nativeInstance;
- nativeInstance = nullptr;
instance = nullptr;
}
QBasicMutex mutex;
QPlatformMediaIntegration *instance = nullptr;
- QAtomicPointer<QPlatformMediaIntegration> nativeInstance = nullptr;
+ QPlatformMediaIntegration *nativeInstance = nullptr;
+ QString preferred;
} holder;
}
QPlatformMediaIntegration *QPlatformMediaIntegration::instance()
{
- if (!holder.nativeInstance.loadRelaxed()) {
- QMutexLocker locker(&holder.mutex);
- if (!holder.nativeInstance.loadAcquire())
- holder.nativeInstance.storeRelease(new PlatformIntegration);
+ QMutexLocker locker(&holder.mutex);
+ if (holder.instance)
+ return holder.instance;
+
+ QString type = holder.preferred;
+ if (type.isEmpty())
+ type = QString::fromUtf8(qgetenv("QT_MEDIA_BACKEND"));
+ if (type.isEmpty())
+ type = backends().first();
+
+ qCDebug(qLcMediaPlugin) << "loading backend" << type;
+ holder.nativeInstance = qLoadPlugin<QPlatformMediaIntegration, QPlatformMediaPlugin>(loader(), type);
+
+ if (!holder.nativeInstance) {
+ qCDebug(qLcMediaPlugin) << "could not load plugins, loading fallback";
+ holder.nativeInstance = new PlatformIntegration;
}
- if (!holder.instance)
- holder.instance = holder.nativeInstance.loadRelaxed();
+
+ holder.instance = holder.nativeInstance;
return holder.instance;
}
@@ -111,7 +147,10 @@ QPlatformMediaIntegration *QPlatformMediaIntegration::instance()
*/
void QPlatformMediaIntegration::setIntegration(QPlatformMediaIntegration *integration)
{
- holder.instance = integration;
+ if (integration)
+ holder.instance = integration;
+ else
+ holder.instance = holder.nativeInstance;
}
QPlatformAudioInput *QPlatformMediaIntegration::createAudioInput(QAudioInput *q)
diff --git a/src/multimedia/platform/qplatformmediaplugin_p.h b/src/multimedia/platform/qplatformmediaplugin_p.h
new file mode 100644
index 000000000..f57d05e9b
--- /dev/null
+++ b/src/multimedia/platform/qplatformmediaplugin_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtSql module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QPLATFORMMEDIAPLUGIN_P_H
+#define QPLATFORMMEDIAPLUGIN_P_H
+
+#include <QtMultimedia/qtmultimediaglobal.h>
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformMediaIntegration;
+
+#define QPlatformMediaPlugin_iid "org.qt-project.Qt.QPlatformMediaPlugin"
+
+class Q_MULTIMEDIA_EXPORT QPlatformMediaPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QPlatformMediaPlugin(QObject *parent = nullptr)
+ : QObject(parent)
+ {}
+ ~QPlatformMediaPlugin() = default;
+
+ virtual QPlatformMediaIntegration *create(const QString &key) = 0;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLATFORMMEDIAPLUGIN_P_H
diff --git a/src/multimedia/qiso639_2_p.h b/src/multimedia/qiso639_2_p.h
index 27424068a..eef92cc0f 100644
--- a/src/multimedia/qiso639_2_p.h
+++ b/src/multimedia/qiso639_2_p.h
@@ -56,8 +56,8 @@
QT_BEGIN_NAMESPACE
namespace QtMultimediaPrivate {
-QLocale::Language fromIso639(const char *tag);
-QByteArray toIso639(QLocale::Language language);
+Q_MULTIMEDIA_EXPORT QLocale::Language fromIso639(const char *tag);
+Q_MULTIMEDIA_EXPORT QByteArray toIso639(QLocale::Language language);
}
QT_END_NAMESPACE
diff --git a/src/multimedia/qmediastoragelocation_p.h b/src/multimedia/qmediastoragelocation_p.h
index ec32cfdbe..6e658342c 100644
--- a/src/multimedia/qmediastoragelocation_p.h
+++ b/src/multimedia/qmediastoragelocation_p.h
@@ -59,8 +59,8 @@ QT_BEGIN_NAMESPACE
namespace QMediaStorageLocation
{
- QDir defaultDirectory(QStandardPaths::StandardLocation type);
- QString generateFileName(const QString &requestedName, QStandardPaths::StandardLocation type, const QString &extension);
+ Q_MULTIMEDIA_EXPORT QDir defaultDirectory(QStandardPaths::StandardLocation type);
+ Q_MULTIMEDIA_EXPORT QString generateFileName(const QString &requestedName, QStandardPaths::StandardLocation type, const QString &extension);
};
QT_END_NAMESPACE
diff --git a/src/multimedia/recording/qmediarecorder_p.h b/src/multimedia/recording/qmediarecorder_p.h
index 8e41079cc..ed46c5cba 100644
--- a/src/multimedia/recording/qmediarecorder_p.h
+++ b/src/multimedia/recording/qmediarecorder_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QPlatformMediaRecorder;
class QTimer;
-class QMediaRecorderPrivate
+class Q_MULTIMEDIA_EXPORT QMediaRecorderPrivate
{
Q_DECLARE_PUBLIC(QMediaRecorder)
diff --git a/src/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/video/qabstractvideobuffer_p.h
index 1d48a8f24..455d6069c 100644
--- a/src/multimedia/video/qabstractvideobuffer_p.h
+++ b/src/multimedia/video/qabstractvideobuffer_p.h
@@ -55,6 +55,7 @@
#include <QtMultimedia/qvideoframe.h>
#include <QtCore/qmetatype.h>
+#include <QtGui/qmatrix4x4.h>
QT_BEGIN_NAMESPACE
@@ -85,6 +86,7 @@ public:
virtual void mapTextures() {}
virtual quint64 textureHandle(int /*plane*/) const { return 0; }
+ virtual QMatrix4x4 externalTextureMatrix() const { return {}; }
protected:
QVideoFrame::HandleType m_type;
QRhi *rhi = nullptr;
diff --git a/src/multimedia/video/qvideotexturehelper.cpp b/src/multimedia/video/qvideotexturehelper.cpp
index b7911911b..05740afa1 100644
--- a/src/multimedia/video/qvideotexturehelper.cpp
+++ b/src/multimedia/video/qvideotexturehelper.cpp
@@ -39,9 +39,7 @@
#include "qvideotexturehelper_p.h"
#include "qvideoframe.h"
-#ifdef Q_OS_ANDROID
-#include <private/qandroidvideooutput_p.h>
-#endif
+#include "qabstractvideobuffer_p.h"
#include <qpainter.h>
@@ -442,13 +440,8 @@ void updateUniformData(QByteArray *dst, const QVideoFrameFormat &format, const Q
cmat = colorMatrix(format.yCbCrColorSpace());
break;
case QVideoFrameFormat::Format_SamplerExternalOES:
-#ifdef Q_OS_ANDROID
- {
// get Android specific transform for the externalsampler texture
- if (auto *buffer = static_cast<AndroidTextureVideoBuffer *>(frame.videoBuffer()))
- cmat = buffer->externalTextureMatrix();
- }
-#endif
+ cmat = frame.videoBuffer()->externalTextureMatrix();
break;
case QVideoFrameFormat::Format_SamplerRect:
{
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 73bcbf963..138e4c14b 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -1,5 +1 @@
-# Generated from plugins.pro.
-
-if(TARGET Qt::Quick)
- add_subdirectory(videonode)
-endif()
+#add_subdirectory(multimedia)