diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-01-12 14:22:08 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-01-22 07:02:55 +0000 |
commit | 98148969b112f82d2b49e77950ea5f6d8b37b8b2 (patch) | |
tree | 48fffe0533a647bb53bec7e6e33dee1b95fcd849 /src/multimedia/qmediaserviceprovider.cpp | |
parent | b947bcabfef5f0df32a4e09b55eaa581281b4edd (diff) |
Get rid of plugins for MM backends
There's no need for having those in plugins and we can
further remove abstractions and simplify our code if
the code is directly compiled into Qt Multimedia.
Change-Id: I5267a6a776375d99be8f0de4207f0288d963e620
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia/qmediaserviceprovider.cpp')
-rw-r--r-- | src/multimedia/qmediaserviceprovider.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/src/multimedia/qmediaserviceprovider.cpp b/src/multimedia/qmediaserviceprovider.cpp index f729e3876..72690da50 100644 --- a/src/multimedia/qmediaserviceprovider.cpp +++ b/src/multimedia/qmediaserviceprovider.cpp @@ -37,6 +37,8 @@ ** ****************************************************************************/ +#include <qtmultimediaglobal_p.h> + #include <QtCore/qdebug.h> #include <QtCore/qmap.h> @@ -47,15 +49,58 @@ #include "qmediaplayer.h" #include "qvideodeviceselectorcontrol.h" +#if QT_CONFIG(gstreamer) +#include <private/qgstreamerplayerserviceplugin_p.h> +#include <private/qgstreamercaptureserviceplugin_p.h> +#elif defined(Q_OS_WIN) +#include <private/mfplayerservice_p.h> +#elif defined(Q_OS_DARWIN) +#include <private/avfcameraserviceplugin_p.h> +#include <private/avfmediaplayerserviceplugin_p.h> +#elif defined(Q_OS_ANDROID) +#include <private/qandroidmediaserviceplugin_p.h> +#elif defined(Q_OS_QNX) +#include <private/neutrinoserviceplugin_p.h> +#endif + QT_BEGIN_NAMESPACE QMediaServiceProviderFactoryInterface::~QMediaServiceProviderFactoryInterface() { } -Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, loader, - (QMediaServiceProviderFactoryInterface_iid, QLatin1String("mediaservice"), Qt::CaseInsensitive)) +class Loader +{ +#define GET_PLUGIN(Key, Class) \ + if (key.toUtf8() == Key) { \ + static QObject *instance = nullptr; \ + if (!instance) \ + instance = new Class; \ + return instance; \ + } + +public: + QObject *instance(const QString &key) { +#if QT_CONFIG(gstreamer) + GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, QGstreamerPlayerServicePlugin) + GET_PLUGIN(Q_MEDIASERVICE_CAMERA, QGstreamerCaptureServicePlugin) + GET_PLUGIN(Q_MEDIASERVICE_AUDIOSOURCE, QGstreamerCaptureServicePlugin) +#elif defined(Q_OS_WIN) + GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, MFPlayerService) +#elif defined(Q_OS_DARWIN) + GET_PLUGIN(Q_MEDIASERVICE_CAMERA, AVFServicePlugin) + GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, AVFMediaPlayerServicePlugin) +#elif defined(Q_OS_ANDROID) + GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, QAndroidMediaServicePlugin) + GET_PLUGIN(Q_MEDIASERVICE_CAMERA, QAndroidMediaServicePlugin) +#elif defined(Q_OS_QNX) + GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, NeutrinoServicePlugin) +#endif + return nullptr; + } +}; +Q_GLOBAL_STATIC(Loader, loader); class QPluginServiceProvider : public QMediaServiceProvider { |