summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-01-21 13:55:39 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-29 08:50:03 +0000
commit4b720199c379b90b160a7b9632388ebbc44e55c3 (patch)
tree3e9d098edd85881c82ffdffc6cbe940131372a56 /src
parent8b749d4fc21a3a94afb58e86f384221e4ccaee66 (diff)
Move QAudioDecoder over to use the new platform infrastructure
And remove the hasSupport() method for now as with QMediaPlayer and QMediaRecorder. Also adjust the auto test to use the new mock infrastructure. Change-Id: I84a8587f273525d1ee1ed26ded6822bb92448e01 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/multimedia/audio/qaudiodecoder.cpp39
-rw-r--r--src/multimedia/audio/qaudiodecoder.h2
-rw-r--r--src/multimedia/platform/gstreamer/audio/qgstreameraudiodecodercontrol.cpp17
-rw-r--r--src/multimedia/platform/gstreamer/qgstreamerintegration.cpp6
-rw-r--r--src/multimedia/platform/gstreamer/qgstreamerintegration_p.h1
-rw-r--r--src/multimedia/platform/qmediaplatformintegration_p.h2
-rw-r--r--src/multimedia/platform/windows/qwindowsintegration.cpp6
-rw-r--r--src/multimedia/platform/windows/qwindowsintegration_p.h1
8 files changed, 35 insertions, 39 deletions
diff --git a/src/multimedia/audio/qaudiodecoder.cpp b/src/multimedia/audio/qaudiodecoder.cpp
index 1e333f132..85fd3a5d0 100644
--- a/src/multimedia/audio/qaudiodecoder.cpp
+++ b/src/multimedia/audio/qaudiodecoder.cpp
@@ -45,12 +45,7 @@
#include "qaudiodecodercontrol.h"
#include <private/qmediaserviceprovider_p.h>
-#if QT_CONFIG(gstreamer)
-#include <private/qgstreameraudiodecodercontrol_p.h>
-#include <private/qgstutils_p.h>
-#elif defined(Q_OS_WIN)
-#include <private/mfaudiodecodercontrol_p.h>
-#endif
+#include <private/qmediaplatformintegration_p.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qmetaobject.h>
@@ -132,12 +127,7 @@ QAudioDecoder::QAudioDecoder(QObject *parent)
{
Q_D(QAudioDecoder);
-#if QT_CONFIG(gstreamer)
- gst_init(nullptr, nullptr);
- d->control = new QGstreamerAudioDecoderControl(this);
-#elif defined(Q_OS_WIN)
- d->control = new MFAudioDecoderControl(this);
-#endif
+ d->control = QMediaPlatformIntegration::instance()->createAudioDecoder();
if (d->control != nullptr) {
connect(d->control, SIGNAL(stateChanged(QAudioDecoder::State)), SLOT(_q_stateChanged(QAudioDecoder::State)));
connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString)));
@@ -329,31 +319,6 @@ void QAudioDecoder::setAudioFormat(const QAudioFormat &format)
}
/*!
- Returns the level of support an audio decoder has for a \a mimeType and a set of \a codecs.
-*/
-QMultimedia::SupportEstimate QAudioDecoder::hasSupport(const QString &mimeType,
- const QStringList& codecs)
-{
-#if QT_CONFIG(gstreamer)
- // ### this code should not be there
- auto isDecoderOrDemuxer = [](GstElementFactory *factory) -> bool
- {
- return gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DEMUXER)
- || gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DECODER
- | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO);
- };
- gst_init(nullptr, nullptr);
- auto set = QGstUtils::supportedMimeTypes(isDecoderOrDemuxer);
- return QGstUtils::hasSupport(mimeType, codecs, set);
-#elif defined(Q_OS_WIN)
- return QMultimedia::MaybeSupported;
-#endif
- Q_UNUSED(mimeType);
- Q_UNUSED(codecs);
- return QMultimedia::NotSupported;
-}
-
-/*!
Returns true if a buffer is available to be read,
and false otherwise. If there is no buffer available, calling
the \l read() function will return an invalid buffer.
diff --git a/src/multimedia/audio/qaudiodecoder.h b/src/multimedia/audio/qaudiodecoder.h
index 0045f92b7..670af4027 100644
--- a/src/multimedia/audio/qaudiodecoder.h
+++ b/src/multimedia/audio/qaudiodecoder.h
@@ -78,8 +78,6 @@ public:
explicit QAudioDecoder(QObject *parent = nullptr);
~QAudioDecoder();
- static QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs = QStringList());
-
State state() const;
QString sourceFilename() const;
diff --git a/src/multimedia/platform/gstreamer/audio/qgstreameraudiodecodercontrol.cpp b/src/multimedia/platform/gstreamer/audio/qgstreameraudiodecodercontrol.cpp
index 73cfe02b5..91827ce4b 100644
--- a/src/multimedia/platform/gstreamer/audio/qgstreameraudiodecodercontrol.cpp
+++ b/src/multimedia/platform/gstreamer/audio/qgstreameraudiodecodercontrol.cpp
@@ -596,4 +596,21 @@ qint64 QGstreamerAudioDecoderControl::getPositionFromBuffer(GstBuffer* buffer)
return position;
}
+#if 0
+QMultimedia::SupportEstimate QAudioDecoder::hasSupport(const QString &mimeType,
+ const QStringList& codecs)
+{
+ // ### this code should not be there
+ auto isDecoderOrDemuxer = [](GstElementFactory *factory) -> bool
+ {
+ return gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DEMUXER)
+ || gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DECODER
+ | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO);
+ };
+ gst_init(nullptr, nullptr);
+ auto set = QGstUtils::supportedMimeTypes(isDecoderOrDemuxer);
+ return QGstUtils::hasSupport(mimeType, codecs, set);
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp b/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp
index 495bb6ecd..4ba8f1d43 100644
--- a/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp
+++ b/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp
@@ -42,6 +42,7 @@
#include "qgstreamerplayerservice_p.h"
#include "private/qgstreamerplayerservice_p.h"
#include "private/qgstreamercaptureservice_p.h"
+#include "private/qgstreameraudiodecodercontrol_p.h"
QT_BEGIN_NAMESPACE
@@ -62,6 +63,11 @@ QMediaPlatformDeviceManager *QGstreamerIntegration::deviceManager()
return m_manager;
}
+QAudioDecoderControl *QGstreamerIntegration::createAudioDecoder()
+{
+ return new QGstreamerAudioDecoderControl(nullptr);
+}
+
QMediaPlatformCaptureInterface *QGstreamerIntegration::createCaptureInterface(CaptureMode mode)
{
return new QGstreamerCaptureService(mode);
diff --git a/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h b/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h
index 23d811749..5f79c8c09 100644
--- a/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h
+++ b/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h
@@ -66,6 +66,7 @@ public:
QMediaPlatformDeviceManager *deviceManager() override;
+ QAudioDecoderControl *createAudioDecoder() override;
QMediaPlatformCaptureInterface *createCaptureInterface(CaptureMode mode) override;
QMediaPlatformPlayerInterface *createPlayerInterface() override;
diff --git a/src/multimedia/platform/qmediaplatformintegration_p.h b/src/multimedia/platform/qmediaplatformintegration_p.h
index dbf1f6cc1..ed0be7959 100644
--- a/src/multimedia/platform/qmediaplatformintegration_p.h
+++ b/src/multimedia/platform/qmediaplatformintegration_p.h
@@ -58,6 +58,7 @@ class QMediaDeviceManager;
class QMediaPlatformDeviceManager;
class QMediaPlatformCaptureInterface;
class QMediaPlatformPlayerInterface;
+class QAudioDecoderControl;
class Q_MULTIMEDIA_EXPORT QMediaPlatformIntegration
{
@@ -75,6 +76,7 @@ public:
AudioAndVideo
};
+ virtual QAudioDecoderControl *createAudioDecoder() { return nullptr; }
virtual QMediaPlatformCaptureInterface *createCaptureInterface(CaptureMode /*mode*/) { return nullptr; }
virtual QMediaPlatformPlayerInterface *createPlayerInterface() { return nullptr; }
};
diff --git a/src/multimedia/platform/windows/qwindowsintegration.cpp b/src/multimedia/platform/windows/qwindowsintegration.cpp
index 2787aeb7f..2b610cde6 100644
--- a/src/multimedia/platform/windows/qwindowsintegration.cpp
+++ b/src/multimedia/platform/windows/qwindowsintegration.cpp
@@ -40,6 +40,7 @@
#include "qwindowsintegration_p.h"
#include "qwindowsdevicemanager_p.h"
#include <private/mfplayerservice_p.h>
+#include <private/mfaudiodecodercontrol_p.h>
QT_BEGIN_NAMESPACE
@@ -72,6 +73,11 @@ QMediaPlatformDeviceManager *QWindowsIntegration::deviceManager()
return m_manager;
}
+QAudioDecoderControl *QWindowsIntegration::createAudioDecoder()
+{
+ return new MFAudioDecoderControl;
+}
+
QMediaPlatformPlayerInterface *QWindowsIntegration::createPlayerInterface()
{
return new MFPlayerService;
diff --git a/src/multimedia/platform/windows/qwindowsintegration_p.h b/src/multimedia/platform/windows/qwindowsintegration_p.h
index cbd0e3c75..5997fdc3b 100644
--- a/src/multimedia/platform/windows/qwindowsintegration_p.h
+++ b/src/multimedia/platform/windows/qwindowsintegration_p.h
@@ -68,6 +68,7 @@ public:
QMediaPlatformDeviceManager *deviceManager() override;
+ QAudioDecoderControl *createAudioDecoder() override;
QMediaPlatformPlayerInterface *createPlayerInterface() override;
QWindowsDeviceManager *m_manager = nullptr;