diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2022-12-27 12:37:18 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-01-05 09:19:14 +0000 |
commit | 37727d6df9b4756453b19b2cbfc0b01834c07c49 (patch) | |
tree | 54923bb17e1d56b74b486889fa6aed43254f954c | |
parent | d3ba2ebbf800e04f6f10bc1e20a9dc241b9f13c9 (diff) |
Set ffmpeg as the default media backend
On windows, linux, macos, ios, and android
ffmpeg is decided to be default on 6.5.
Other backends are limitedly supported.
Change-Id: I78fac655e0bfd717cd50181e1f508e28187b2538
Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io>
Reviewed-by: Samuel Mira <samuel.mira@qt.io>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit ea55bf9c3d0e907d4dc2d269792e23743751d34f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/multimedia/platform/qplatformmediaintegration.cpp | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/multimedia/platform/qplatformmediaintegration.cpp b/src/multimedia/platform/qplatformmediaintegration.cpp index e97dca08c..4c1d0adae 100644 --- a/src/multimedia/platform/qplatformmediaintegration.cpp +++ b/src/multimedia/platform/qplatformmediaintegration.cpp @@ -3,7 +3,6 @@ #include <qtmultimediaglobal_p.h> #include "qplatformmediaintegration_p.h" -#include "qplatformmediadevices_p.h" #include <qatomic.h> #include <qmutex.h> #include <qplatformaudioinput_p.h> @@ -29,7 +28,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QPlatformMediaPlugin_iid, QLatin1String("/multimedia"))) -static QStringList backends() +static const auto FFmpegBackend = QStringLiteral("ffmpeg"); + +static QStringList availableBackends() { QStringList list; @@ -44,6 +45,22 @@ static QStringList backends() return list; } +static QString defaultBackend(const QStringList &backends) +{ +#if defined(Q_OS_DARWIN) || defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS) || defined(Q_OS_ANDROID) + // Return ffmpeg backend by default. + // Platform backends for the OS list are optionally available but have limited support. + if (backends.contains(FFmpegBackend)) + return FFmpegBackend; +#else + // Return platform backend (non-ffmpeg) by default. + if (backends.size() > 1 && backends[0] == FFmpegBackend) + return backends[1]; +#endif + + return backends[0]; +} + QT_BEGIN_NAMESPACE namespace { @@ -66,21 +83,17 @@ QPlatformMediaIntegration *QPlatformMediaIntegration::instance() if (holder.instance) return holder.instance; - auto plugins = backends(); - - QString type = QString::fromUtf8(qgetenv("QT_MEDIA_BACKEND")); - if (type.isEmpty() && !plugins.isEmpty()) { - type = plugins.first(); - // FIXME: prefer platform specific backend if available over ffmpeg until it becomes mature - if (type == QStringLiteral("ffmpeg") && plugins.size() > 1) - type = plugins[1]; - } + const auto backends = availableBackends(); + QString backend = QString::fromUtf8(qgetenv("QT_MEDIA_BACKEND")); + if (backend.isEmpty() && !backends.isEmpty()) + backend = defaultBackend(backends); - qCDebug(qLcMediaPlugin) << "loading backend" << type; - holder.nativeInstance = qLoadPlugin<QPlatformMediaIntegration, QPlatformMediaPlugin>(loader(), type); + qCDebug(qLcMediaPlugin) << "loading backend" << backend; + holder.nativeInstance = + qLoadPlugin<QPlatformMediaIntegration, QPlatformMediaPlugin>(loader(), backend); if (!holder.nativeInstance) { - qWarning() << "could not load multimedia backend" << type; + qWarning() << "could not load multimedia backend" << backend; holder.nativeInstance = new QDummyIntegration; } |