diff options
Diffstat (limited to 'tests/auto/unit/mockbackend')
-rw-r--r-- | tests/auto/unit/mockbackend/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/unit/mockbackend/qmockaudiooutput.h | 76 | ||||
-rw-r--r-- | tests/auto/unit/mockbackend/qmockintegration.cpp | 6 | ||||
-rw-r--r-- | tests/auto/unit/mockbackend/qmockintegration_p.h | 2 | ||||
-rw-r--r-- | tests/auto/unit/mockbackend/qmockmediaplayer.h | 34 |
5 files changed, 88 insertions, 31 deletions
diff --git a/tests/auto/unit/mockbackend/CMakeLists.txt b/tests/auto/unit/mockbackend/CMakeLists.txt index 8f43aafdd..56f2c11aa 100644 --- a/tests/auto/unit/mockbackend/CMakeLists.txt +++ b/tests/auto/unit/mockbackend/CMakeLists.txt @@ -14,6 +14,7 @@ target_link_libraries(QtMultimediaMockBackend INTERFACE ) target_sources(QtMultimediaMockBackend INTERFACE qmockaudiodecoder.h + qmockaudiooutput.h qmockcamera.h qmockimagecapture.h qmockimagecapture.cpp qmockmediaplayer.h diff --git a/tests/auto/unit/mockbackend/qmockaudiooutput.h b/tests/auto/unit/mockbackend/qmockaudiooutput.h new file mode 100644 index 000000000..02245a7a3 --- /dev/null +++ b/tests/auto/unit/mockbackend/qmockaudiooutput.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part 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$ +** +****************************************************************************/ +#ifndef QMOCKAUDIOOUTPUT_H +#define QMOCKAUDIOOUTPUT_H + +// +// 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. +// + +#include <private/qplatformaudiooutput_p.h> + +QT_BEGIN_NAMESPACE + +class QMockAudioOutput : public QPlatformAudioOutput +{ +public: + QMockAudioOutput(QAudioOutput *qq) : QPlatformAudioOutput(qq) {} + + virtual QList<QAudio::Role> supportedAudioRoles() const { + if (!hasAudioRole) + return {}; + return QList<QAudio::Role>() << QAudio::MusicRole + << QAudio::AlarmRole + << QAudio::NotificationRole; + } + + bool hasAudioRole = true; +}; + +QT_END_NAMESPACE + + +#endif // QMOCKAUDIOOUTPUT_H diff --git a/tests/auto/unit/mockbackend/qmockintegration.cpp b/tests/auto/unit/mockbackend/qmockintegration.cpp index 55a92c3c7..69e5c8e05 100644 --- a/tests/auto/unit/mockbackend/qmockintegration.cpp +++ b/tests/auto/unit/mockbackend/qmockintegration.cpp @@ -45,6 +45,7 @@ #include "qmockmediacapturesession.h" #include "qmockvideosink.h" #include "qmockimagecapture.h" +#include "qmockaudiooutput.h" QT_BEGIN_NAMESPACE @@ -118,6 +119,11 @@ QPlatformVideoSink *QMockIntegration::createVideoSink(QVideoSink *sink) return m_lastVideoSink; } +QPlatformAudioOutput *QMockIntegration::createAudioOutput(QAudioOutput *q) +{ + return new QMockAudioOutput(q); +} + bool QMockCamera::simpleCamera = false; QT_END_NAMESPACE diff --git a/tests/auto/unit/mockbackend/qmockintegration_p.h b/tests/auto/unit/mockbackend/qmockintegration_p.h index 5f11cb680..1625c021f 100644 --- a/tests/auto/unit/mockbackend/qmockintegration_p.h +++ b/tests/auto/unit/mockbackend/qmockintegration_p.h @@ -79,6 +79,8 @@ public: QPlatformMediaCaptureSession *createCaptureSession() override; QPlatformVideoSink *createVideoSink(QVideoSink *) override; + QPlatformAudioOutput *createAudioOutput(QAudioOutput *) override; + enum Flag { NoPlayerInterface = 0x1, NoAudioDecoderInterface = 0x2, diff --git a/tests/auto/unit/mockbackend/qmockmediaplayer.h b/tests/auto/unit/mockbackend/qmockmediaplayer.h index 793330f23..81969d256 100644 --- a/tests/auto/unit/mockbackend/qmockmediaplayer.h +++ b/tests/auto/unit/mockbackend/qmockmediaplayer.h @@ -45,8 +45,6 @@ public: , _error(QMediaPlayer::NoError) , _duration(0) , _position(0) - , _volume(100) - , _muted(false) , _bufferProgress(0) , _audioAvailable(false) , _videoAvailable(false) @@ -77,12 +75,6 @@ public: void setPosition(qint64 position) { if (position != _position) emit positionChanged(_position = position); } - int volume() const { return _volume; } - void setVolume(int volume) { emit volumeChanged(_volume = volume); } - - bool isMuted() const { return _muted; } - void setMuted(bool muted) { if (muted != _muted) emit mutedChanged(_muted = muted); } - float bufferProgress() const { return _bufferProgress; } void setBufferStatus(float status) { @@ -121,23 +113,10 @@ public: void pause() { if (_isValid && !_media.isEmpty()) setState(QMediaPlayer::PausedState); } void stop() { if (_state != QMediaPlayer::StoppedState) setState(QMediaPlayer::StoppedState); } - void setAudioRole(QAudio::Role role) - { - if (hasAudioRole) - m_audioRole = role; - } - - QList<QAudio::Role> supportedAudioRoles() const - { - if (!hasAudioRole) - return {}; - return QList<QAudio::Role>() << QAudio::MusicRole - << QAudio::AlarmRole - << QAudio::NotificationRole; - } - void setVideoSink(QVideoSink *) {} + void setAudioOutput(QPlatformAudioOutput *output) { m_audioOutput = output; } + void emitError(QMediaPlayer::Error err, const QString &errorString) { emit error(err, errorString); @@ -174,8 +153,6 @@ public: _error = QMediaPlayer::NoError; _duration = 0; _position = 0; - _volume = 0; - _muted = false; _bufferProgress = 0; _videoAvailable = false; _isSeekable = false; @@ -184,19 +161,13 @@ public: _stream = 0; _isValid = false; _errorString = QString(); - hasAudioRole = true; } - bool hasAudioRole = true; - QAudio::Role m_audioRole = QAudio::UnknownRole; - QMediaPlayer::PlaybackState _state; QMediaPlayer::Error _error; qint64 _duration; qint64 _position; - int _volume; - bool _muted; float _bufferProgress; bool _audioAvailable; bool _videoAvailable; @@ -208,6 +179,7 @@ public: bool _isValid; QString _errorString; bool m_supportsStreamPlayback = false; + QPlatformAudioOutput *m_audioOutput = nullptr; }; QT_END_NAMESPACE |