diff options
47 files changed, 281 insertions, 1107 deletions
diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir index e7dcc3dd6..d68049f63 100644 --- a/src/imports/multimedia/qmldir +++ b/src/imports/multimedia/qmldir @@ -4,4 +4,3 @@ classname QMultimediaDeclarativeModule typeinfo plugins.qmltypes typeinfo plugins.qmltypes Video 5.0 Video.qml - diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt index 7681cae2e..e72d67228 100644 --- a/src/multimedia/CMakeLists.txt +++ b/src/multimedia/CMakeLists.txt @@ -44,7 +44,6 @@ qt_internal_add_module(Multimedia platform/qmediaplatformcaptureinterface.cpp platform/qmediaplatformcaptureinterface_p.h platform/qmediaplatformdevicemanager.cpp platform/qmediaplatformdevicemanager_p.h platform/qmediaplatformintegration.cpp platform/qmediaplatformintegration_p.h - platform/qmediaplatformplayerinterface.cpp platform/qmediaplatformplayerinterface_p.h platform/qmediaplatformformatinfo.cpp platform/qmediaplatformformatinfo_p.h playback/qmediaplayer.cpp playback/qmediaplayer.h playback/qmediaplaylist.cpp playback/qmediaplaylist.h playback/qmediaplaylist_p.h @@ -148,7 +147,6 @@ qt_internal_extend_target(Multimedia CONDITION WIN32 platform/windows/player/mfevrvideowindowcontrol.cpp platform/windows/player/mfevrvideowindowcontrol_p.h platform/windows/player/mfmetadata.cpp platform/windows/player/mfmetadata_p.h platform/windows/player/mfplayercontrol.cpp platform/windows/player/mfplayercontrol_p.h - platform/windows/player/mfplayerservice.cpp platform/windows/player/mfplayerservice_p.h platform/windows/player/mfplayersession.cpp platform/windows/player/mfplayersession_p.h platform/windows/player/mftvideo.cpp platform/windows/player/mftvideo_p.h platform/windows/player/mfvideorenderercontrol.cpp platform/windows/player/mfvideorenderercontrol_p.h @@ -208,7 +206,6 @@ qt_internal_extend_target(Multimedia CONDITION QT_FEATURE_gstreamer platform/gstreamer/common/qgstvideobuffer.cpp platform/gstreamer/common/qgstvideobuffer_p.h platform/gstreamer/common/qgstvideorendererplugin.cpp platform/gstreamer/common/qgstvideorendererplugin_p.h platform/gstreamer/common/qgstvideorenderersink.cpp platform/gstreamer/common/qgstvideorenderersink_p.h - platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h platform/gstreamer/mediaplayer/qgstreamerstreamscontrol.cpp platform/gstreamer/mediaplayer/qgstreamerstreamscontrol_p.h platform/gstreamer/qgstreamerdevicemanager.cpp platform/gstreamer/qgstreamerdevicemanager_p.h platform/gstreamer/qgstreamerformatsinfo.cpp platform/gstreamer/qgstreamerformatsinfo_p.h @@ -336,7 +333,6 @@ qt_internal_extend_target(Multimedia CONDITION ANDROID platform/android/mediacapture/qandroidmediarecordercontrol.cpp platform/android/mediacapture/qandroidmediarecordercontrol_p.h platform/android/mediaplayer/qandroidmediaplayercontrol.cpp platform/android/mediaplayer/qandroidmediaplayercontrol_p.h platform/android/mediaplayer/qandroidmediaplayervideorenderercontrol.cpp platform/android/mediaplayer/qandroidmediaplayervideorenderercontrol_p.h - platform/android/mediaplayer/qandroidmediaservice.cpp platform/android/mediaplayer/qandroidmediaservice_p.h platform/android/mediaplayer/qandroidmetadata.cpp platform/android/mediaplayer/qandroidmetadata_p.h platform/android/qandroiddevicemanager.cpp platform/android/qandroiddevicemanager_p.h platform/android/qandroidformatsinfo.cpp platform/android/qandroidformatsinfo_p.h @@ -381,8 +377,7 @@ qt_internal_extend_target(Multimedia CONDITION APPLE AND NOT WATCHOS platform/darwin/audio/qcoreaudioinput.mm platform/darwin/audio/qcoreaudioinput_p.h platform/darwin/audio/qcoreaudiooutput.mm platform/darwin/audio/qcoreaudiooutput_p.h platform/darwin/audio/qcoreaudioutils.mm platform/darwin/audio/qcoreaudioutils_p.h - platform/darwin/mediaplayer/avfmediaplayercontrol.mm platform/darwin/mediaplayer/avfmediaplayercontrol_p.h - platform/darwin/mediaplayer/avfmediaplayerservice.mm platform/darwin/mediaplayer/avfmediaplayerservice_p.h + platform/darwin/mediaplayer/avfmediaplayer.mm platform/darwin/mediaplayer/avfmediaplayer_p.h platform/darwin/mediaplayer/avfmediaplayersession.mm platform/darwin/mediaplayer/avfmediaplayersession_p.h platform/darwin/mediaplayer/avfmetadata.mm platform/darwin/mediaplayer/avfmetadata_p.h platform/darwin/mediaplayer/avfvideooutput.mm platform/darwin/mediaplayer/avfvideooutput_p.h diff --git a/src/multimedia/platform/android/mediaplayer/mediaplayer.pri b/src/multimedia/platform/android/mediaplayer/mediaplayer.pri index 184e7efc3..8478398bb 100644 --- a/src/multimedia/platform/android/mediaplayer/mediaplayer.pri +++ b/src/multimedia/platform/android/mediaplayer/mediaplayer.pri @@ -2,12 +2,10 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/qandroidmediaplayercontrol_p.h \ - $$PWD/qandroidmediaservice_p.h \ $$PWD/qandroidmetadata_p.h \ $$PWD/qandroidmediaplayervideorenderercontrol_p.h SOURCES += \ $$PWD/qandroidmediaplayercontrol.cpp \ - $$PWD/qandroidmediaservice.cpp \ $$PWD/qandroidmetadata.cpp \ $$PWD/qandroidmediaplayervideorenderercontrol.cpp diff --git a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice.cpp b/src/multimedia/platform/android/mediaplayer/qandroidmediaservice.cpp deleted file mode 100644 index 722d37335..000000000 --- a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#include "qandroidmediaservice_p.h" - -#include "qandroidmediaplayercontrol_p.h" -#include "qandroidmediaplayervideorenderercontrol_p.h" - -QT_BEGIN_NAMESPACE - -QAndroidMediaService::QAndroidMediaService() -{ - mMediaControl = new QAndroidMediaPlayerControl; -} - -QAndroidMediaService::~QAndroidMediaService() -{ - delete mMediaControl; -} - -QMediaPlayerControl *QAndroidMediaService::player() -{ - return mMediaControl; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice_p.h b/src/multimedia/platform/android/mediaplayer/qandroidmediaservice_p.h deleted file mode 100644 index 6973f7fa5..000000000 --- a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 QANDROIDMEDIASERVICE_H -#define QANDROIDMEDIASERVICE_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/qmediaplatformplayerinterface_p.h> - -QT_BEGIN_NAMESPACE - -class QAndroidMediaPlayerControl; - -class QAndroidMediaService : public QMediaPlatformPlayerInterface -{ - Q_OBJECT -public: - explicit QAndroidMediaService(); - ~QAndroidMediaService() override; - - // QMediaPlatformPlayerInterface - QMediaPlayerControl *player() override; -// QMediaStreamsControl *streams() override; - -private: - QAndroidMediaPlayerControl *mMediaControl = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDMEDIASERVICE_H diff --git a/src/multimedia/platform/android/qandroidintegration.cpp b/src/multimedia/platform/android/qandroidintegration.cpp index 7ee99b74e..4e5987564 100644 --- a/src/multimedia/platform/android/qandroidintegration.cpp +++ b/src/multimedia/platform/android/qandroidintegration.cpp @@ -39,7 +39,6 @@ #include "qandroidintegration_p.h" #include "qandroiddevicemanager_p.h" -#include "private/qandroidmediaservice_p.h" #include "private/qandroidglobal_p.h" #include "private/qandroidcaptureservice_p.h" #include "private/androidmediaplayer_p.h" @@ -49,6 +48,7 @@ #include "private/androidcamera_p.h" #include "private/androidmediarecorder_p.h" #include "private/qandroidformatsinfo_p.h" +#include "private/qandroidmediaplayercontrol_p.h" QT_BEGIN_NAMESPACE @@ -85,9 +85,9 @@ QMediaPlatformCaptureInterface *QAndroidIntegration::createCaptureInterface(QMed return new QAndroidCaptureService(mode); } -QMediaPlatformPlayerInterface *QAndroidIntegration::createPlayerInterface() +QMediaPlayerControl *QAndroidIntegration::createPlayer() { - return new QAndroidMediaService(); + return new QAndroidMediaPlayerControl(); } Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) diff --git a/src/multimedia/platform/android/qandroidintegration_p.h b/src/multimedia/platform/android/qandroidintegration_p.h index ca8f384af..36e936599 100644 --- a/src/multimedia/platform/android/qandroidintegration_p.h +++ b/src/multimedia/platform/android/qandroidintegration_p.h @@ -56,7 +56,6 @@ QT_BEGIN_NAMESPACE class QAndroidDeviceManager; -class QAndroidPlayerInterface; class QAndroidIntegration : public QMediaPlatformIntegration { @@ -68,7 +67,7 @@ public: QMediaPlatformFormatInfo *formatInfo() override; QMediaPlatformCaptureInterface *createCaptureInterface(QMediaRecorder::CaptureMode mode) override; - QMediaPlatformPlayerInterface *createPlayerInterface() override; + QMediaPlayerControl *createPlayer() override; QAndroidDeviceManager *m_manager = nullptr; QMediaPlatformFormatInfo *m_formatInfo = nullptr; diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayercontrol.mm b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm index 301eb6790..47b47e8c6 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayercontrol.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer.mm @@ -37,24 +37,25 @@ ** ****************************************************************************/ -#include "avfmediaplayercontrol_p.h" +#include "avfmediaplayer_p.h" #include "avfmediaplayersession_p.h" QT_USE_NAMESPACE -AVFMediaPlayerControl::AVFMediaPlayerControl(QObject *parent) : +AVFMediaPlayer::AVFMediaPlayer(QObject *parent) : QMediaPlayerControl(parent) { + setSession(new AVFMediaPlayerSession(this)); } -AVFMediaPlayerControl::~AVFMediaPlayerControl() +AVFMediaPlayer::~AVFMediaPlayer() { #ifdef QT_DEBUG_AVF qDebug() << Q_FUNC_INFO; #endif } -void AVFMediaPlayerControl::setSession(AVFMediaPlayerSession *session) +void AVFMediaPlayer::setSession(AVFMediaPlayerSession *session) { m_session = session; @@ -71,94 +72,94 @@ void AVFMediaPlayerControl::setSession(AVFMediaPlayerSession *session) connect(m_session, SIGNAL(videoAvailableChanged(bool)), this, SIGNAL(videoAvailableChanged(bool))); connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); connect(m_session, &AVFMediaPlayerSession::playbackRateChanged, - this, &AVFMediaPlayerControl::playbackRateChanged); + this, &AVFMediaPlayer::playbackRateChanged); connect(m_session, &AVFMediaPlayerSession::seekableChanged, - this, &AVFMediaPlayerControl::seekableChanged); + this, &AVFMediaPlayer::seekableChanged); } -QMediaPlayer::State AVFMediaPlayerControl::state() const +QMediaPlayer::State AVFMediaPlayer::state() const { return m_session->state(); } -QMediaPlayer::MediaStatus AVFMediaPlayerControl::mediaStatus() const +QMediaPlayer::MediaStatus AVFMediaPlayer::mediaStatus() const { return m_session->mediaStatus(); } -QUrl AVFMediaPlayerControl::media() const +QUrl AVFMediaPlayer::media() const { return m_session->media(); } -const QIODevice *AVFMediaPlayerControl::mediaStream() const +const QIODevice *AVFMediaPlayer::mediaStream() const { return m_session->mediaStream(); } -void AVFMediaPlayerControl::setMedia(const QUrl &content, QIODevice *stream) +void AVFMediaPlayer::setMedia(const QUrl &content, QIODevice *stream) { const QUrl oldContent = m_session->media(); m_session->setMedia(content, stream); } -qint64 AVFMediaPlayerControl::position() const +qint64 AVFMediaPlayer::position() const { return m_session->position(); } -qint64 AVFMediaPlayerControl::duration() const +qint64 AVFMediaPlayer::duration() const { return m_session->duration(); } -int AVFMediaPlayerControl::bufferStatus() const +int AVFMediaPlayer::bufferStatus() const { return m_session->bufferStatus(); } -int AVFMediaPlayerControl::volume() const +int AVFMediaPlayer::volume() const { return m_session->volume(); } -bool AVFMediaPlayerControl::isMuted() const +bool AVFMediaPlayer::isMuted() const { return m_session->isMuted(); } -bool AVFMediaPlayerControl::isAudioAvailable() const +bool AVFMediaPlayer::isAudioAvailable() const { return m_session->isAudioAvailable(); } -bool AVFMediaPlayerControl::isVideoAvailable() const +bool AVFMediaPlayer::isVideoAvailable() const { return m_session->isVideoAvailable(); } -bool AVFMediaPlayerControl::isSeekable() const +bool AVFMediaPlayer::isSeekable() const { return m_session->isSeekable(); } -QMediaTimeRange AVFMediaPlayerControl::availablePlaybackRanges() const +QMediaTimeRange AVFMediaPlayer::availablePlaybackRanges() const { return m_session->availablePlaybackRanges(); } -qreal AVFMediaPlayerControl::playbackRate() const +qreal AVFMediaPlayer::playbackRate() const { return m_session->playbackRate(); } -void AVFMediaPlayerControl::setPlaybackRate(qreal rate) +void AVFMediaPlayer::setPlaybackRate(qreal rate) { m_session->setPlaybackRate(rate); } -bool AVFMediaPlayerControl::setAudioOutput(const QAudioDeviceInfo &info) +bool AVFMediaPlayer::setAudioOutput(const QAudioDeviceInfo &info) { #ifdef Q_OS_IOS Q_UNUSED(info); @@ -168,7 +169,7 @@ bool AVFMediaPlayerControl::setAudioOutput(const QAudioDeviceInfo &info) #endif } -QAudioDeviceInfo AVFMediaPlayerControl::audioOutput() const +QAudioDeviceInfo AVFMediaPlayer::audioOutput() const { #ifdef Q_OS_IOS return QAudioDeviceInfo(); @@ -177,48 +178,48 @@ QAudioDeviceInfo AVFMediaPlayerControl::audioOutput() const #endif } -QMediaMetaData AVFMediaPlayerControl::metaData() const +QMediaMetaData AVFMediaPlayer::metaData() const { return m_metaData; } -void AVFMediaPlayerControl::setMetaData(const QMediaMetaData &metaData) +void AVFMediaPlayer::setMetaData(const QMediaMetaData &metaData) { m_metaData = metaData; metaDataChanged(); } -void AVFMediaPlayerControl::setPosition(qint64 pos) +void AVFMediaPlayer::setPosition(qint64 pos) { m_session->setPosition(pos); } -void AVFMediaPlayerControl::play() +void AVFMediaPlayer::play() { m_session->play(); } -void AVFMediaPlayerControl::pause() +void AVFMediaPlayer::pause() { m_session->pause(); } -void AVFMediaPlayerControl::stop() +void AVFMediaPlayer::stop() { m_session->stop(); } -void AVFMediaPlayerControl::setVolume(int volume) +void AVFMediaPlayer::setVolume(int volume) { m_session->setVolume(volume); } -void AVFMediaPlayerControl::setMuted(bool muted) +void AVFMediaPlayer::setMuted(bool muted) { m_session->setMuted(muted); } -void AVFMediaPlayerControl::setVideoSurface(QAbstractVideoSurface *surface) +void AVFMediaPlayer::setVideoSurface(QAbstractVideoSurface *surface) { m_session->setVideoSurface(surface); } diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayercontrol_p.h b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer_p.h index 10a592972..6338572e6 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayercontrol_p.h +++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayer_p.h @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#ifndef AVFMEDIAPLAYERCONTROL_H -#define AVFMEDIAPLAYERCONTROL_H +#ifndef AVFMEDIAPLAYER_H +#define AVFMEDIAPLAYER_H // // W A R N I N G @@ -58,12 +58,12 @@ QT_BEGIN_NAMESPACE class AVFMediaPlayerSession; -class AVFMediaPlayerControl : public QMediaPlayerControl +class AVFMediaPlayer : public QMediaPlayerControl { Q_OBJECT public: - explicit AVFMediaPlayerControl(QObject *parent = nullptr); - ~AVFMediaPlayerControl(); + explicit AVFMediaPlayer(QObject *parent = nullptr); + ~AVFMediaPlayer(); void setSession(AVFMediaPlayerSession *session); @@ -116,4 +116,4 @@ private: QT_END_NAMESPACE -#endif // AVFMEDIAPLAYERCONTROL_H +#endif // AVFMEDIAPLAYER_H diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm deleted file mode 100644 index 660332695..000000000 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). -** 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$ -** -****************************************************************************/ - -#include "avfmediaplayerservice_p.h" -#include "avfmediaplayersession_p.h" -#include "avfmediaplayercontrol_p.h" -#include "avfvideooutput_p.h" -#if QT_CONFIG(opengl) -#include "avfvideorenderercontrol_p.h" -#endif -#include "avfvideowindowcontrol_p.h" - -#import <AVFoundation/AVFoundation.h> - -QT_USE_NAMESPACE - -AVFMediaPlayerService::AVFMediaPlayerService() -{ - m_session = new AVFMediaPlayerSession(this); - m_control = new AVFMediaPlayerControl(this); - m_control->setSession(m_session); -} - -AVFMediaPlayerService::~AVFMediaPlayerService() -{ -#ifdef QT_DEBUG_AVF - qDebug() << Q_FUNC_INFO; -#endif - delete m_session; - //delete m_control; -} - -QMediaPlayerControl *AVFMediaPlayerService::player() -{ - return m_control; -} diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h deleted file mode 100644 index 5755f87c9..000000000 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 AVFMEDIAPLAYERSERVICE_H -#define AVFMEDIAPLAYERSERVICE_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/qmediaplatformplayerinterface_p.h> - -QT_BEGIN_NAMESPACE - -class AVFMediaPlayerSession; -class AVFMediaPlayerControl; -class AVFVideoOutput; - -class AVFMediaPlayerService : public QMediaPlatformPlayerInterface -{ -public: - explicit AVFMediaPlayerService(); - ~AVFMediaPlayerService(); - - // QMediaPlatformPlayerInterface - QMediaPlayerControl *player() override; -// QMediaStreamsControl *streams() override; - -private: - AVFMediaPlayerSession *m_session = nullptr; - AVFMediaPlayerControl *m_control = nullptr; -}; - -QT_END_NAMESPACE - -#endif // AVFMEDIAPLAYERSERVICE_H diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession.mm b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession.mm index 1bc8a675b..867d1b2d3 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession.mm @@ -38,8 +38,7 @@ ****************************************************************************/ #include "avfmediaplayersession_p.h" -#include "avfmediaplayerservice_p.h" -#include "avfmediaplayercontrol_p.h" +#include "avfmediaplayer_p.h" #include "avfvideorenderercontrol_p.h" #include "avfvideooutput_p.h" #include "avfmetadata_p.h" @@ -465,9 +464,9 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext } @end -AVFMediaPlayerSession::AVFMediaPlayerSession(AVFMediaPlayerService *service, QObject *parent) +AVFMediaPlayerSession::AVFMediaPlayerSession(AVFMediaPlayer *player, QObject *parent) : QObject(parent) - , m_service(service) + , m_player(player) , m_videoOutput(nullptr) , m_state(QMediaPlayer::StoppedState) , m_mediaStatus(QMediaPlayer::NoMedia) @@ -956,7 +955,7 @@ void AVFMediaPlayerSession::processLoadStateChange(QMediaPlayer::State newState) // get the meta data QMediaMetaData metaData = AVFMetaData::fromAsset(playerItem.asset); - static_cast<AVFMediaPlayerControl *>(m_service->player())->setMetaData(metaData); + m_player->setMetaData(metaData); if (playerItem) { // Check each track for audio and video content diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession_p.h b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession_p.h index ec364b29d..4c8fc6f48 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession_p.h +++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayersession_p.h @@ -65,7 +65,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(AVFMediaPlayerSessionObserver); QT_BEGIN_NAMESPACE -class AVFMediaPlayerService; +class AVFMediaPlayer; class AVFVideoOutput; class AVFVideoRendererControl; @@ -73,7 +73,7 @@ class AVFMediaPlayerSession : public QObject { Q_OBJECT public: - AVFMediaPlayerSession(AVFMediaPlayerService *service, QObject *parent = nullptr); + AVFMediaPlayerSession(AVFMediaPlayer *control, QObject *parent = nullptr); virtual ~AVFMediaPlayerSession(); void setVideoSurface(QAbstractVideoSurface *surface); @@ -156,7 +156,7 @@ private: void setSeekable(bool seekable); void resetStream(QIODevice *stream = nullptr); - AVFMediaPlayerService *m_service; + AVFMediaPlayer *m_player; AVFVideoRendererControl *m_videoOutput; QMediaPlayer::State m_state; diff --git a/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol_p.h b/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol_p.h index 9f94aa6a3..4c5f292ea 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol_p.h +++ b/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol_p.h @@ -67,7 +67,6 @@ class AVFVideoFrameRenderer; class AVFVideoRendererControl : public QVideoRendererControl, public AVFVideoOutput { Q_OBJECT - Q_INTERFACES(AVFVideoOutput) public: explicit AVFVideoRendererControl(QObject *parent = nullptr); virtual ~AVFVideoRendererControl(); diff --git a/src/multimedia/platform/darwin/mediaplayer/avfvideowindowcontrol_p.h b/src/multimedia/platform/darwin/mediaplayer/avfvideowindowcontrol_p.h index 37840eb4a..9e6bcfed2 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfvideowindowcontrol_p.h +++ b/src/multimedia/platform/darwin/mediaplayer/avfvideowindowcontrol_p.h @@ -69,7 +69,6 @@ QT_BEGIN_NAMESPACE class AVFVideoWindowControl : public QVideoWindowControl, public AVFVideoOutput { Q_OBJECT - Q_INTERFACES(AVFVideoOutput) public: AVFVideoWindowControl(QObject *parent = nullptr); diff --git a/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri b/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri index 0aab9faa5..546673d62 100644 --- a/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri +++ b/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri @@ -1,17 +1,15 @@ QT += opengl network HEADERS += \ - $$PWD/avfmediaplayercontrol_p.h \ + $$PWD/avfmediaplayer_p.h \ $$PWD/avfmetadata_p.h \ - $$PWD/avfmediaplayerservice_p.h \ $$PWD/avfmediaplayersession_p.h \ $$PWD/avfvideooutput_p.h \ $$PWD/avfvideowindowcontrol_p.h SOURCES += \ - $$PWD/avfmediaplayercontrol.mm \ + $$PWD/avfmediaplayer.mm \ $$PWD/avfmetadata.mm \ - $$PWD/avfmediaplayerservice.mm \ $$PWD/avfmediaplayersession.mm \ $$PWD/avfvideooutput.mm \ $$PWD/avfvideowindowcontrol.mm diff --git a/src/multimedia/platform/darwin/qdarwinintegration.cpp b/src/multimedia/platform/darwin/qdarwinintegration.cpp index 0d53feb29..9c1207c91 100644 --- a/src/multimedia/platform/darwin/qdarwinintegration.cpp +++ b/src/multimedia/platform/darwin/qdarwinintegration.cpp @@ -39,7 +39,7 @@ #include "qdarwinintegration_p.h" #include "qdarwindevicemanager_p.h" -#include <private/avfmediaplayerservice_p.h> +#include <private/avfmediaplayer_p.h> #include <private/avfcameraservice_p.h> #include <private/qdarwinformatsinfo_p.h> @@ -75,9 +75,9 @@ QMediaPlatformCaptureInterface *QDarwinIntegration::createCaptureInterface(QMedi return new AVFCameraService; } -QMediaPlatformPlayerInterface *QDarwinIntegration::createPlayerInterface() +QMediaPlayerControl *QDarwinIntegration::createPlayer() { - return new AVFMediaPlayerService; + return new AVFMediaPlayer; } QT_END_NAMESPACE diff --git a/src/multimedia/platform/darwin/qdarwinintegration_p.h b/src/multimedia/platform/darwin/qdarwinintegration_p.h index 2a82448a7..31405b62e 100644 --- a/src/multimedia/platform/darwin/qdarwinintegration_p.h +++ b/src/multimedia/platform/darwin/qdarwinintegration_p.h @@ -67,7 +67,7 @@ public: QMediaPlatformFormatInfo *formatInfo() override; QMediaPlatformCaptureInterface *createCaptureInterface(QMediaRecorder::CaptureMode /*mode*/) override; - QMediaPlatformPlayerInterface *createPlayerInterface() override; + QMediaPlayerControl *createPlayer() override; QDarwinDeviceManager *m_manager = nullptr; QMediaPlatformFormatInfo *m_formatInfo = nullptr; diff --git a/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri b/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri index 1071b25a2..bd19bd507 100644 --- a/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri +++ b/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri @@ -1,9 +1,7 @@ INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/qgstreamerplayerservice_p.h \ $$PWD/qgstreamerstreamscontrol_p.h \ SOURCES += \ - $$PWD/qgstreamerplayerservice.cpp \ $$PWD/qgstreamerstreamscontrol.cpp \ diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp deleted file mode 100644 index f08f43d95..000000000 --- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#include <QtMultimedia/private/qtmultimediaglobal_p.h> -#include <QtCore/qvariant.h> -#include <QtCore/qdebug.h> - - -#include "qgstreamerplayerservice_p.h" - -#include "qgstreamerstreamscontrol_p.h" -#include <private/qgstreamerplayersession_p.h> -#include <private/qgstreamerplayercontrol_p.h> - -QT_BEGIN_NAMESPACE - -QGstreamerPlayerService::QGstreamerPlayerService() - : QMediaPlatformPlayerInterface() -{ - m_control = new QGstreamerPlayerControl(this); -} - -QGstreamerPlayerService::~QGstreamerPlayerService() -{ - // delete m_session; - // delete m_control; - // delete m_streamsControl; - // delete m_videoRenderer; - // delete m_videoWindow; -} - -QMediaPlayerControl *QGstreamerPlayerService::player() -{ - return m_control; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h deleted file mode 100644 index 1dc1c8423..000000000 --- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 QGSTREAMERPLAYERSERVICE_H -#define QGSTREAMERPLAYERSERVICE_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 <QtCore/qobject.h> -#include <QtCore/qiodevice.h> - -#include <private/qmediaplatformplayerinterface_p.h> - -QT_BEGIN_NAMESPACE -class QMediaPlayerControl; - -class QGstreamerMetaData; -class QGstreamerPlayerControl; -class QGstreamerPlayerSession; -class QGStreamerAvailabilityControl; - -class QGstreamerPlayerService : public QMediaPlatformPlayerInterface -{ - Q_OBJECT -public: - QGstreamerPlayerService(); - ~QGstreamerPlayerService(); - - // QMediaPlatformPlayerInterface - QMediaPlayerControl *player() override; - -private: - QGstreamerPlayerControl *m_control = nullptr; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp b/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp index c6ad99411..3fcda4754 100644 --- a/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp +++ b/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp @@ -39,8 +39,7 @@ #include "qgstreamerintegration_p.h" #include "qgstreamerdevicemanager_p.h" -#include "qgstreamerplayerservice_p.h" -#include "private/qgstreamerplayerservice_p.h" +#include "private/qgstreamerplayercontrol_p.h" #include "private/qgstreamercaptureservice_p.h" #include "private/qgstreameraudiodecodercontrol_p.h" #include "private/qgstreamerformatsinfo_p.h" @@ -83,9 +82,9 @@ QMediaPlatformCaptureInterface *QGstreamerIntegration::createCaptureInterface(QM return new QGstreamerCaptureService(mode); } -QMediaPlatformPlayerInterface *QGstreamerIntegration::createPlayerInterface() +QMediaPlayerControl *QGstreamerIntegration::createPlayer() { - return new QGstreamerPlayerService(); + return new QGstreamerPlayerControl(); } QT_END_NAMESPACE diff --git a/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h b/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h index a06beb34a..5e9825c9d 100644 --- a/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h +++ b/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h @@ -71,7 +71,7 @@ public: QAudioDecoderControl *createAudioDecoder() override; QMediaPlatformCaptureInterface *createCaptureInterface(QMediaRecorder::CaptureMode mode) override; - QMediaPlatformPlayerInterface *createPlayerInterface() override; + QMediaPlayerControl *createPlayer() override; QGstreamerDeviceManager *m_manager = nullptr; QGstreamerFormatsInfo *m_formatsInfo = nullptr; diff --git a/src/multimedia/platform/platform.pri b/src/multimedia/platform/platform.pri index 1d3481583..6ac9c6a7f 100644 --- a/src/multimedia/platform/platform.pri +++ b/src/multimedia/platform/platform.pri @@ -2,14 +2,12 @@ HEADERS += \ $$PWD/qmediaplatformcaptureinterface_p.h \ $$PWD/qmediaplatformintegration_p.h \ $$PWD/qmediaplatformdevicemanager_p.h \ - $$PWD/qmediaplatformplayerinterface_p.h \ $$PWD/qmediaplatformformatinfo_p.h SOURCES += \ $$PWD/qmediaplatformcaptureinterface.cpp \ $$PWD/qmediaplatformintegration.cpp \ $$PWD/qmediaplatformdevicemanager.cpp \ - $$PWD/qmediaplatformplayerinterface.cpp \ $$PWD/qmediaplatformformatinfo.cpp qtConfig(gstreamer):include(gstreamer/gstreamer.pri) diff --git a/src/multimedia/platform/qmediaplatformintegration_p.h b/src/multimedia/platform/qmediaplatformintegration_p.h index b154b41aa..e17e9f958 100644 --- a/src/multimedia/platform/qmediaplatformintegration_p.h +++ b/src/multimedia/platform/qmediaplatformintegration_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE class QMediaDeviceManager; class QMediaPlatformDeviceManager; class QMediaPlatformCaptureInterface; -class QMediaPlatformPlayerInterface; +class QMediaPlayerControl; class QAudioDecoderControl; class QMediaPlatformFormatInfo; class QVideoRendererControl; @@ -77,7 +77,7 @@ public: virtual QAudioDecoderControl *createAudioDecoder() { return nullptr; } virtual QMediaPlatformCaptureInterface *createCaptureInterface(QMediaRecorder::CaptureMode /*mode*/) { return nullptr; } - virtual QMediaPlatformPlayerInterface *createPlayerInterface() { return nullptr; } + virtual QMediaPlayerControl *createPlayer() { return nullptr; } }; QT_END_NAMESPACE diff --git a/src/multimedia/platform/qmediaplatformplayerinterface.cpp b/src/multimedia/platform/qmediaplatformplayerinterface.cpp deleted file mode 100644 index 4f29273fe..000000000 --- a/src/multimedia/platform/qmediaplatformplayerinterface.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include <qtmultimediaglobal_p.h> -#include "qmediaplatformplayerinterface_p.h" - -QT_BEGIN_NAMESPACE - -QMediaPlatformPlayerInterface::QMediaPlatformPlayerInterface() - : QObject(nullptr) -{ -} - -QMediaPlatformPlayerInterface::~QMediaPlatformPlayerInterface() -{ -} - -QT_END_NAMESPACE diff --git a/src/multimedia/platform/qmediaplatformplayerinterface_p.h b/src/multimedia/platform/qmediaplatformplayerinterface_p.h deleted file mode 100644 index ac728341d..000000000 --- a/src/multimedia/platform/qmediaplatformplayerinterface_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 QMEDIAPLATFORMPLAYERINTERFACE_H -#define QMEDIAPLATFORMPLAYERINTERFACE_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/qtmultimediaglobal_p.h> -#include <QtCore/qobject.h> - -QT_BEGIN_NAMESPACE - -class QMediaPlayerControl; -class QMediaStreamsControl; -class QVideoRendererControl; -class QVideoWindowControl; - -class Q_MULTIMEDIA_EXPORT QMediaPlatformPlayerInterface : public QObject -{ -public: - QMediaPlatformPlayerInterface(); - virtual ~QMediaPlatformPlayerInterface(); - - virtual QMediaPlayerControl *player() = 0; - - // ### nothing in the frontend uses the stream info currently. Needs implementation in QMediaPlayer - virtual QMediaStreamsControl *streams() { return nullptr; } -}; - -QT_END_NAMESPACE - - -#endif // QMEDIAPLATFORMINTERFACE_H diff --git a/src/multimedia/platform/windows/player/mfmetadata.cpp b/src/multimedia/platform/windows/player/mfmetadata.cpp index 632ba3686..e3af53d70 100644 --- a/src/multimedia/platform/windows/player/mfmetadata.cpp +++ b/src/multimedia/platform/windows/player/mfmetadata.cpp @@ -42,7 +42,7 @@ #include <qimage.h> #include "mfmetadata_p.h" -#include "mfplayerservice_p.h" +#include "mfplayercontrol_p.h" #include "Propkey.h" //#define DEBUG_MEDIAFOUNDATION diff --git a/src/multimedia/platform/windows/player/mfplayercontrol.cpp b/src/multimedia/platform/windows/player/mfplayercontrol.cpp index 7381b3c3f..1ff6e25bd 100644 --- a/src/multimedia/platform/windows/player/mfplayercontrol.cpp +++ b/src/multimedia/platform/windows/player/mfplayercontrol.cpp @@ -38,21 +38,22 @@ ****************************************************************************/ #include "mfplayercontrol_p.h" +#include "mfplayersession_p.h" #include "mfvideorenderercontrol_p.h" #include <qtcore/qdebug.h> //#define DEBUG_MEDIAFOUNDATION -MFPlayerControl::MFPlayerControl(MFPlayerSession *session) -: QMediaPlayerControl(session) -, m_state(QMediaPlayer::StoppedState) -, m_stateDirty(false) -, m_videoAvailable(false) -, m_audioAvailable(false) -, m_duration(-1) -, m_seekable(false) -, m_session(session) +MFPlayerControl::MFPlayerControl() + : QMediaPlayerControl() + , m_state(QMediaPlayer::StoppedState) + , m_stateDirty(false) + , m_videoAvailable(false) + , m_audioAvailable(false) + , m_duration(-1) + , m_seekable(false) { + m_session = new MFPlayerSession(this); QObject::connect(m_session, SIGNAL(statusChanged()), this, SLOT(handleStatusChanged())); QObject::connect(m_session, SIGNAL(videoAvailable()), this, SLOT(handleVideoAvailable())); QObject::connect(m_session, SIGNAL(audioAvailable()), this, SLOT(handleAudioAvailable())); @@ -68,6 +69,7 @@ MFPlayerControl::MFPlayerControl(MFPlayerSession *session) MFPlayerControl::~MFPlayerControl() { + m_session->Release(); } void MFPlayerControl::setMedia(const QUrl &media, QIODevice *stream) diff --git a/src/multimedia/platform/windows/player/mfplayercontrol_p.h b/src/multimedia/platform/windows/player/mfplayercontrol_p.h index 3b9ae083e..4170bfc8b 100644 --- a/src/multimedia/platform/windows/player/mfplayercontrol_p.h +++ b/src/multimedia/platform/windows/player/mfplayercontrol_p.h @@ -64,7 +64,7 @@ class MFPlayerControl : public QMediaPlayerControl { Q_OBJECT public: - MFPlayerControl(MFPlayerSession *session); + MFPlayerControl(); ~MFPlayerControl(); QMediaPlayer::State state() const; diff --git a/src/multimedia/platform/windows/player/mfplayerservice.cpp b/src/multimedia/platform/windows/player/mfplayerservice.cpp deleted file mode 100644 index 43c22beeb..000000000 --- a/src/multimedia/platform/windows/player/mfplayerservice.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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$ -** -****************************************************************************/ - -#include "qurl.h" - -#include <QtCore/qdebug.h> - -#include "mfplayercontrol_p.h" -#include "mfevrvideowindowcontrol_p.h" -#include "mfvideorenderercontrol_p.h" -#include "mfplayerservice_p.h" -#include "mfplayersession_p.h" - -MFPlayerService::MFPlayerService() -{ - m_session = new MFPlayerSession(this); - m_player = new MFPlayerControl(m_session); -} - -MFPlayerService::~MFPlayerService() -{ - m_session->close(); - - m_session->Release(); - - //delete m_player; -} - -QMediaPlayerControl *MFPlayerService::player() -{ - return m_player; -} diff --git a/src/multimedia/platform/windows/player/mfplayerservice_p.h b/src/multimedia/platform/windows/player/mfplayerservice_p.h deleted file mode 100644 index e986c2111..000000000 --- a/src/multimedia/platform/windows/player/mfplayerservice_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 MFPLAYERSERVICE_H -#define MFPLAYERSERVICE_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 <mfapi.h> -#include <mfidl.h> - -#include "qmediaplayer.h" -#include "qmediatimerange.h" -#include <private/qmediaplatformplayerinterface_p.h> - -QT_BEGIN_NAMESPACE -class QUrl; -QT_END_NAMESPACE - -QT_USE_NAMESPACE - -class MFEvrVideoWindowControl; -class MFVideoRendererControl; -class MFPlayerControl; -class MFPlayerSession; - -class MFPlayerService : public QMediaPlatformPlayerInterface -{ - Q_OBJECT -public: - MFPlayerService(); - ~MFPlayerService(); - - QMediaPlayerControl *player() override; - // ### QMediaStreamsControl *streams() override; - -private: - MFPlayerSession *m_session = nullptr; - MFPlayerControl *m_player = nullptr; -}; - -#endif diff --git a/src/multimedia/platform/windows/player/mfplayersession.cpp b/src/multimedia/platform/windows/player/mfplayersession.cpp index e0abfbd61..5d8dcd1e6 100644 --- a/src/multimedia/platform/windows/player/mfplayersession.cpp +++ b/src/multimedia/platform/windows/player/mfplayersession.cpp @@ -53,7 +53,6 @@ #include "mfmetadata_p.h" #include "mfplayersession_p.h" -#include "mfplayerservice_p.h" #include <mferror.h> #include <nserror.h> #include "private/sourceresolver_p.h" @@ -66,9 +65,9 @@ //#define DEBUG_MEDIAFOUNDATION -MFPlayerSession::MFPlayerSession(MFPlayerService *playerService) +MFPlayerSession::MFPlayerSession(MFPlayerControl *playerControl) : m_cRef(1) - , m_playerService(playerService) + , m_playerControl(playerControl) , m_session(0) , m_presentationClock(0) , m_rateControl(0) @@ -76,16 +75,16 @@ MFPlayerSession::MFPlayerSession(MFPlayerService *playerService) , m_volumeControl(0) , m_netsourceStatistics(0) , m_duration(0) + , m_scrubbing(false) + , m_restoreRate(1) , m_sourceResolver(0) , m_hCloseEvent(0) , m_closing(false) + , m_mediaTypes(0) , m_pendingRate(1) + , m_status(QMediaPlayer::NoMedia) , m_volume(100) , m_muted(false) - , m_status(QMediaPlayer::NoMedia) - , m_scrubbing(false) - , m_restoreRate(1) - , m_mediaTypes(0) , m_audioSampleGrabber(0) , m_audioSampleGrabberNode(0) , m_videoProbeMFT(0) diff --git a/src/multimedia/platform/windows/player/mfplayersession_p.h b/src/multimedia/platform/windows/player/mfplayersession_p.h index d44ca61f7..60fcea291 100644 --- a/src/multimedia/platform/windows/player/mfplayersession_p.h +++ b/src/multimedia/platform/windows/player/mfplayersession_p.h @@ -83,7 +83,7 @@ class MFPlayerSession : public QObject, public IMFAsyncCallback Q_OBJECT friend class SourceResolver; public: - MFPlayerSession(MFPlayerService *playerService = 0); + MFPlayerSession(MFPlayerControl *playerControl = 0); ~MFPlayerSession(); STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject); @@ -151,7 +151,7 @@ private Q_SLOTS: private: long m_cRef; - MFPlayerService *m_playerService; + MFPlayerControl *m_playerControl; MFVideoRendererControl *m_videoRendererControl = nullptr; IMFMediaSession *m_session; IMFPresentationClock *m_presentationClock; diff --git a/src/multimedia/platform/windows/player/player.pri b/src/multimedia/platform/windows/player/player.pri index 2008bc092..0f79f7433 100644 --- a/src/multimedia/platform/windows/player/player.pri +++ b/src/multimedia/platform/windows/player/player.pri @@ -4,7 +4,6 @@ LIBS += -lgdi32 -luser32 QMAKE_USE += wmf HEADERS += \ - $$PWD/mfplayerservice_p.h \ $$PWD/mfplayersession_p.h \ $$PWD/mfplayercontrol_p.h \ $$PWD/mfvideorenderercontrol_p.h \ @@ -15,7 +14,6 @@ HEADERS += \ $$PWD/mfactivate_p.h SOURCES += \ - $$PWD/mfplayerservice.cpp \ $$PWD/mfplayersession.cpp \ $$PWD/mfplayercontrol.cpp \ $$PWD/mfvideorenderercontrol.cpp \ diff --git a/src/multimedia/platform/windows/qwindowsintegration.cpp b/src/multimedia/platform/windows/qwindowsintegration.cpp index c4b9142ed..190e1dd32 100644 --- a/src/multimedia/platform/windows/qwindowsintegration.cpp +++ b/src/multimedia/platform/windows/qwindowsintegration.cpp @@ -40,7 +40,7 @@ #include "qwindowsintegration_p.h" #include "qwindowsdevicemanager_p.h" #include "qwindowsformatinfo_p.h" -#include <private/mfplayerservice_p.h> +#include <private/mfplayercontrol_p.h> #include <private/mfaudiodecodercontrol_p.h> QT_BEGIN_NAMESPACE @@ -88,9 +88,9 @@ QAudioDecoderControl *QWindowsIntegration::createAudioDecoder() return new MFAudioDecoderControl; } -QMediaPlatformPlayerInterface *QWindowsIntegration::createPlayerInterface() +QMediaPlayerControl *QWindowsIntegration::createPlayer() { - return new MFPlayerService; + return new MFPlayerControl; } QT_END_NAMESPACE diff --git a/src/multimedia/platform/windows/qwindowsintegration_p.h b/src/multimedia/platform/windows/qwindowsintegration_p.h index ee37c27ed..8207f2ba2 100644 --- a/src/multimedia/platform/windows/qwindowsintegration_p.h +++ b/src/multimedia/platform/windows/qwindowsintegration_p.h @@ -71,7 +71,7 @@ public: QMediaPlatformFormatInfo *formatInfo() override; QAudioDecoderControl *createAudioDecoder() override; - QMediaPlatformPlayerInterface *createPlayerInterface() override; + QMediaPlayerControl *createPlayer() override; QWindowsDeviceManager *m_manager = nullptr; QWindowsFormatInfo *m_formatInfo = nullptr; diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index e2d51a2d9..7ba09dc4f 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -42,7 +42,6 @@ #include "private/qobject_p.h" #include <qmediaplayercontrol.h> -#include <private/qmediaplatformplayerinterface_p.h> #include <private/qmediaplatformintegration_p.h> #include <QtCore/qcoreevent.h> @@ -92,7 +91,6 @@ class QMediaPlayerPrivate : public QObjectPrivate public: QMediaPlayerPrivate() : notifyTimer(nullptr) {} - QMediaPlatformPlayerInterface *playerInterface = nullptr; QMediaPlayerControl* control = nullptr; QString errorString; @@ -278,15 +276,9 @@ QMediaPlayer::QMediaPlayer(QObject *parent): d->notifyTimer->setInterval(1000); connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - d->playerInterface = QMediaPlatformIntegration::instance()->createPlayerInterface(); - if (!d->playerInterface) { - qWarning() << "QPlatformMediaPlayerInterface not implemented!"; - d->_q_error(QMediaPlayer::ServiceMissingError, QString::fromUtf8("QMediaPlayer is not supported.")); - return; - } - - d->control = d->playerInterface->player(); + d->control = QMediaPlatformIntegration::instance()->createPlayer(); Q_ASSERT(d->control); + connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State))); connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus))); @@ -328,7 +320,7 @@ QMediaPlayer::~QMediaPlayer() // when a receiver is already destroyed. disconnect(); - delete d->playerInterface; + delete d->control; } int QMediaPlayer::notifyInterval() const @@ -760,7 +752,7 @@ bool QMediaPlayer::isAvailable() const { Q_D(const QMediaPlayer); - if (!d->control || !d->playerInterface) + if (!d->control) return false; return true; diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp index 73c7930df..2a5bbca4a 100644 --- a/src/multimediawidgets/qvideowidget.cpp +++ b/src/multimediawidgets/qvideowidget.cpp @@ -671,8 +671,8 @@ bool QVideoWidget::nativeEvent(const QByteArray &eventType, void *message, qintp MSG *mes = reinterpret_cast<MSG *>(message); if (mes->message == WM_PAINT || mes->message == WM_ERASEBKGND) { - if (d->windowBackend) - d->windowBackend->showEvent(); +// if (d->windowBackend) +// d->windowBackend->showEvent(); } return false; diff --git a/tests/auto/unit/mockbackend/CMakeLists.txt b/tests/auto/unit/mockbackend/CMakeLists.txt index 28d16108b..47a32f755 100644 --- a/tests/auto/unit/mockbackend/CMakeLists.txt +++ b/tests/auto/unit/mockbackend/CMakeLists.txt @@ -19,8 +19,7 @@ target_sources(QtMultimediaMockBackend INTERFACE mockcamerafocuscontrol.h mockcameraimagecapturecontrol.h mockcameraimageprocessingcontrol.h - mockmediaplayercontrol.h - mockmediaplayerservice.h + mockmediaplayer.h mockmediarecordercontrol.h mockmediarecorderservice.h mockmediastreamscontrol.h diff --git a/tests/auto/unit/mockbackend/mockmediaplayercontrol.h b/tests/auto/unit/mockbackend/mockmediaplayer.h index 26075ba2e..8263f935d 100644 --- a/tests/auto/unit/mockbackend/mockmediaplayercontrol.h +++ b/tests/auto/unit/mockbackend/mockmediaplayer.h @@ -26,19 +26,19 @@ ** ****************************************************************************/ -#ifndef MOCKMEDIAPLAYERCONTROL_H -#define MOCKMEDIAPLAYERCONTROL_H +#ifndef MOCKMEDIAPLAYER_H +#define MOCKMEDIAPLAYER_H #include "qmediaplayercontrol.h" #include "mockmediastreamscontrol.h" #include <qurl.h> -class MockMediaPlayerControl : public QMediaPlayerControl +class MockMediaPlayer : public QMediaPlayerControl { friend class MockMediaPlayerService; public: - MockMediaPlayerControl() + MockMediaPlayer() : QMediaPlayerControl(0) , _state(QMediaPlayer::StoppedState) , _mediaStatus(QMediaPlayer::NoMedia) @@ -57,7 +57,7 @@ public: { mockStreamsControl = new MockStreamsControl; } - ~MockMediaPlayerControl() + ~MockMediaPlayer() { delete mockStreamsControl; } @@ -161,6 +161,42 @@ public: emit error(err, errorString); } + void setState(QMediaPlayer::State state) { emit stateChanged(_state = state); } + void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) { + _state = state; + _mediaStatus = status; + emit mediaStatusChanged(status); + emit stateChanged(state); + } + void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mediaStatusChanged(_mediaStatus = status); } + void setIsValid(bool isValid) { _isValid = isValid; } + void setMedia(QUrl media) { _media = media; } + void setVideoAvailable(bool videoAvailable) { _videoAvailable = videoAvailable; } + void setError(QMediaPlayer::Error err) { _error = err; emit error(_error, _errorString); } + void setErrorString(QString errorString) { _errorString = errorString; emit error(_error, _errorString); } + + void reset() + { + _state = QMediaPlayer::StoppedState; + _mediaStatus = QMediaPlayer::UnknownMediaStatus; + _error = QMediaPlayer::NoError; + _duration = 0; + _position = 0; + _volume = 0; + _muted = false; + _bufferStatus = 0; + _videoAvailable = false; + _isSeekable = false; + _playbackRate = 0.0; + _media = QUrl(); + _stream = 0; + _isValid = false; + _errorString = QString(); + hasAudioRole = true; + hasCustomAudioRole = true; + } + + MockStreamsControl *mockStreamsControl; bool hasAudioRole = true; bool hasCustomAudioRole = true; diff --git a/tests/auto/unit/mockbackend/mockmediaplayerservice.h b/tests/auto/unit/mockbackend/mockmediaplayerservice.h deleted file mode 100644 index d6a37c958..000000000 --- a/tests/auto/unit/mockbackend/mockmediaplayerservice.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MOCKPLAYERSERVICE_H -#define MOCKPLAYERSERVICE_H - -#include "private/qmediaplatformplayerinterface_p.h" - -#include "mockmediaplayercontrol.h" - -class MockMediaPlayerService : public QMediaPlatformPlayerInterface -{ - Q_OBJECT - -public: - MockMediaPlayerService() - { - mockControl = new MockMediaPlayerControl; - } - - ~MockMediaPlayerService() - { - delete mockControl; - } - - MockMediaPlayerControl *player() { return mockControl; } - - void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); } - void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) { - mockControl->_state = state; - mockControl->_mediaStatus = status; - emit mockControl->mediaStatusChanged(status); - emit mockControl->stateChanged(state); - } - void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mockControl->mediaStatusChanged(mockControl->_mediaStatus = status); } - void setIsValid(bool isValid) { mockControl->_isValid = isValid; } - void setMedia(QUrl media) { mockControl->_media = media; } - void setDuration(qint64 duration) { mockControl->_duration = duration; } - void setPosition(qint64 position) { mockControl->_position = position; } - void setSeekable(bool seekable) { mockControl->_isSeekable = seekable; } - void setVolume(int volume) { mockControl->_volume = volume; } - void setMuted(bool muted) { mockControl->_muted = muted; } - void setVideoAvailable(bool videoAvailable) { mockControl->_videoAvailable = videoAvailable; } - void setBufferStatus(int bufferStatus) { mockControl->_bufferStatus = bufferStatus; } - void setPlaybackRate(qreal playbackRate) { mockControl->_playbackRate = playbackRate; } - void setError(QMediaPlayer::Error error) { mockControl->_error = error; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - void setErrorString(QString errorString) { mockControl->_errorString = errorString; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - - void reset() - { - mockControl->_state = QMediaPlayer::StoppedState; - mockControl->_mediaStatus = QMediaPlayer::UnknownMediaStatus; - mockControl->_error = QMediaPlayer::NoError; - mockControl->_duration = 0; - mockControl->_position = 0; - mockControl->_volume = 0; - mockControl->_muted = false; - mockControl->_bufferStatus = 0; - mockControl->_videoAvailable = false; - mockControl->_isSeekable = false; - mockControl->_playbackRate = 0.0; - mockControl->_media = QUrl(); - mockControl->_stream = 0; - mockControl->_isValid = false; - mockControl->_errorString = QString(); - mockControl->hasAudioRole = true; - mockControl->hasCustomAudioRole = true; - } - - MockMediaPlayerControl *mockControl; -}; - - - -#endif // MOCKPLAYERSERVICE_H diff --git a/tests/auto/unit/mockbackend/qmockintegration.cpp b/tests/auto/unit/mockbackend/qmockintegration.cpp index cc532e17d..348933fd7 100644 --- a/tests/auto/unit/mockbackend/qmockintegration.cpp +++ b/tests/auto/unit/mockbackend/qmockintegration.cpp @@ -39,7 +39,7 @@ #include "qmockintegration_p.h" #include "qmockdevicemanager_p.h" -#include "mockmediaplayerservice.h" +#include "mockmediaplayer.h" #include "mockaudiodecodercontrol.h" #include "mockmediarecorderservice.h" @@ -72,13 +72,13 @@ QAudioDecoderControl *QMockIntegration::createAudioDecoder() return m_lastAudioDecoderControl; } -QMediaPlatformPlayerInterface *QMockIntegration::createPlayerInterface() +QMediaPlayerControl *QMockIntegration::createPlayer() { if (m_flags & NoPlayerInterface) - m_lastPlayerService = nullptr; + m_lastPlayer = nullptr; else - m_lastPlayerService = new MockMediaPlayerService; - return m_lastPlayerService; + m_lastPlayer = new MockMediaPlayer; + return m_lastPlayer; } QMediaPlatformCaptureInterface *QMockIntegration::createCaptureInterface(QMediaRecorder::CaptureMode mode) diff --git a/tests/auto/unit/mockbackend/qmockintegration_p.h b/tests/auto/unit/mockbackend/qmockintegration_p.h index 2870633b9..391bac4dd 100644 --- a/tests/auto/unit/mockbackend/qmockintegration_p.h +++ b/tests/auto/unit/mockbackend/qmockintegration_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE class QMockDeviceManager; -class MockMediaPlayerService; +class MockMediaPlayer; class MockAudioDecoderControl; class MockMediaRecorderService; @@ -70,7 +70,7 @@ public: QMediaPlatformFormatInfo *formatInfo() override { return nullptr; } QAudioDecoderControl *createAudioDecoder() override; - QMediaPlatformPlayerInterface *createPlayerInterface() override; + QMediaPlayerControl *createPlayer() override; QMediaPlatformCaptureInterface *createCaptureInterface(QMediaRecorder::CaptureMode mode) override; enum Flag { @@ -83,14 +83,14 @@ public: void setFlags(Flags f) { m_flags = f; } Flags flags() const { return m_flags; } - MockMediaPlayerService *lastPlayerService() const { return m_lastPlayerService; } + MockMediaPlayer *lastPlayer() const { return m_lastPlayer; } MockAudioDecoderControl *lastAudioDecoder() const { return m_lastAudioDecoderControl; } MockMediaRecorderService *lastCaptureService() const { return m_lastCaptureService; } private: Flags m_flags = {}; QMockDeviceManager *m_manager = nullptr; - MockMediaPlayerService *m_lastPlayerService = nullptr; + MockMediaPlayer *m_lastPlayer = nullptr; MockAudioDecoderControl *m_lastAudioDecoderControl = nullptr; MockMediaRecorderService *m_lastCaptureService = nullptr; }; diff --git a/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp index 02283359e..2a22321f8 100644 --- a/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp +++ b/tests/auto/unit/multimedia/qmediaplayer/tst_qmediaplayer.cpp @@ -41,7 +41,7 @@ #include <qvideorenderercontrol.h> #include "qmockintegration_p.h" -#include "mockmediaplayerservice.h" +#include "mockmediaplayer.h" #include "mockvideosurface.h" QT_USE_NAMESPACE @@ -132,7 +132,7 @@ private: void setupCommonTestData(); QMockIntegration *mockIntegration; - MockMediaPlayerService *mockService; + MockMediaPlayer *mockPlayer; QMediaPlayer *player; }; @@ -413,8 +413,8 @@ void tst_QMediaPlayer::init() { mockIntegration = new QMockIntegration; player = new QMediaPlayer; - mockService = mockIntegration->lastPlayerService(); - Q_ASSERT(mockService); + mockPlayer = mockIntegration->lastPlayer(); + Q_ASSERT(mockPlayer); } void tst_QMediaPlayer::cleanup() @@ -432,7 +432,7 @@ void tst_QMediaPlayer::testNullService() { mockIntegration->setFlags(QMockIntegration::NoPlayerInterface); QMediaPlayer player; - QCOMPARE(mockIntegration->lastPlayerService(), nullptr); + QCOMPARE(mockIntegration->lastPlayer(), nullptr); const QIODevice *nullDevice = nullptr; @@ -537,7 +537,7 @@ void tst_QMediaPlayer::testMedia() { QFETCH(QUrl, mediaContent); - mockService->setMedia(mediaContent); + mockPlayer->setMedia(mediaContent); QCOMPARE(player->media(), mediaContent); QBuffer stream; @@ -555,7 +555,7 @@ void tst_QMediaPlayer::testDuration() { QFETCH(qint64, duration); - mockService->setDuration(duration); + mockPlayer->setDuration(duration); QVERIFY(player->duration() == duration); } @@ -571,10 +571,10 @@ void tst_QMediaPlayer::testPosition() QFETCH(qint64, position); QFETCH(qint64, duration); - mockService->setIsValid(valid); - mockService->setSeekable(seekable); - mockService->setPosition(position); - mockService->setDuration(duration); + mockPlayer->setIsValid(valid); + mockPlayer->setSeekable(seekable); + mockPlayer->setPosition(position); + mockPlayer->setDuration(duration); QVERIFY(player->isSeekable() == seekable); QVERIFY(player->position() == position); QVERIFY(player->duration() == duration); @@ -585,19 +585,19 @@ void tst_QMediaPlayer::testPosition() QCOMPARE(player->position(), position); QCOMPARE(spy.count(), 0); } - mockService->setPosition(position); + mockPlayer->setPosition(position); { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); player->setPosition(0); QCOMPARE(player->position(), qint64(0)); QCOMPARE(spy.count(), position == 0 ? 0 : 1); } - mockService->setPosition(position); + mockPlayer->setPosition(position); { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); player->setPosition(duration); QCOMPARE(player->position(), duration); QCOMPARE(spy.count(), position == duration ? 0 : 1); } - mockService->setPosition(position); + mockPlayer->setPosition(position); { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); player->setPosition(-1); QCOMPARE(player->position(), qint64(0)); @@ -623,7 +623,7 @@ void tst_QMediaPlayer::testVolume() QFETCH(bool, valid); QFETCH(int, volume); - mockService->setVolume(volume); + mockPlayer->setVolume(volume); QVERIFY(player->volume() == volume); if (valid) { @@ -661,8 +661,8 @@ void tst_QMediaPlayer::testMuted() QFETCH(int, volume); if (valid) { - mockService->setMuted(muted); - mockService->setVolume(volume); + mockPlayer->setMuted(muted); + mockPlayer->setVolume(volume); QVERIFY(player->isMuted() == muted); QSignalSpy spy(player, SIGNAL(mutedChanged(bool))); @@ -682,7 +682,7 @@ void tst_QMediaPlayer::testVideoAvailable() { QFETCH(bool, videoAvailable); - mockService->setVideoAvailable(videoAvailable); + mockPlayer->setVideoAvailable(videoAvailable); QVERIFY(player->isVideoAvailable() == videoAvailable); } @@ -695,7 +695,7 @@ void tst_QMediaPlayer::testBufferStatus() { QFETCH(int, bufferStatus); - mockService->setBufferStatus(bufferStatus); + mockPlayer->setBufferStatus(bufferStatus); QVERIFY(player->bufferStatus() == bufferStatus); } @@ -708,7 +708,7 @@ void tst_QMediaPlayer::testSeekable() { QFETCH(bool, seekable); - mockService->setSeekable(seekable); + mockPlayer->setSeekable(seekable); QVERIFY(player->isSeekable() == seekable); } @@ -723,7 +723,7 @@ void tst_QMediaPlayer::testPlaybackRate() QFETCH(qreal, playbackRate); if (valid) { - mockService->setPlaybackRate(playbackRate); + mockPlayer->setPlaybackRate(playbackRate); QVERIFY(player->playbackRate() == playbackRate); QSignalSpy spy(player, SIGNAL(playbackRateChanged(qreal))); @@ -742,7 +742,7 @@ void tst_QMediaPlayer::testError() { QFETCH(QMediaPlayer::Error, error); - mockService->setError(error); + mockPlayer->setError(error); QVERIFY(player->error() == error); } @@ -755,7 +755,7 @@ void tst_QMediaPlayer::testErrorString() { QFETCH(QString, errorString); - mockService->setErrorString(errorString); + mockPlayer->setErrorString(errorString); QVERIFY(player->errorString() == errorString); } @@ -789,8 +789,8 @@ void tst_QMediaPlayer::testPlay() QFETCH(QUrl, mediaContent); QFETCH(QMediaPlayer::State, state); - mockService->setIsValid(valid); - mockService->setState(state); + mockPlayer->setIsValid(valid); + mockPlayer->setState(state); player->setMedia(mediaContent); QVERIFY(player->state() == state); QVERIFY(player->media() == mediaContent); @@ -820,9 +820,9 @@ void tst_QMediaPlayer::testPause() QFETCH(QUrl, mediaContent); QFETCH(QMediaPlayer::State, state); - mockService->setIsValid(valid); - mockService->setState(state); - mockService->setMedia(mediaContent); + mockPlayer->setIsValid(valid); + mockPlayer->setState(state); + mockPlayer->setMedia(mediaContent); QVERIFY(player->state() == state); QVERIFY(player->media() == mediaContent); @@ -850,8 +850,8 @@ void tst_QMediaPlayer::testStop() QFETCH(QUrl, mediaContent); QFETCH(QMediaPlayer::State, state); - mockService->setState(state); - mockService->setMedia(mediaContent); + mockPlayer->setState(state); + mockPlayer->setMedia(mediaContent); QVERIFY(player->state() == state); QVERIFY(player->media() == mediaContent); @@ -881,8 +881,8 @@ void tst_QMediaPlayer::testMediaStatus() player->setNotifyInterval(10); - mockService->setMediaStatus(QMediaPlayer::NoMedia); - mockService->setBufferStatus(bufferStatus); + mockPlayer->setMediaStatus(QMediaPlayer::NoMedia); + mockPlayer->setBufferStatus(bufferStatus); AutoConnection connection( player, SIGNAL(bufferStatusChanged(int)), @@ -893,14 +893,14 @@ void tst_QMediaPlayer::testMediaStatus() QCOMPARE(player->mediaStatus(), QMediaPlayer::NoMedia); - mockService->setMediaStatus(QMediaPlayer::LoadingMedia); + mockPlayer->setMediaStatus(QMediaPlayer::LoadingMedia); QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadingMedia); QCOMPARE(statusSpy.count(), 1); QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), QMediaPlayer::LoadingMedia); - mockService->setMediaStatus(QMediaPlayer::LoadedMedia); + mockPlayer->setMediaStatus(QMediaPlayer::LoadedMedia); QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadedMedia); QCOMPARE(statusSpy.count(), 2); @@ -911,7 +911,7 @@ void tst_QMediaPlayer::testMediaStatus() QTestEventLoop::instance().enterLoop(1); QCOMPARE(bufferSpy.count(), 0); - mockService->setMediaStatus(QMediaPlayer::StalledMedia); + mockPlayer->setMediaStatus(QMediaPlayer::StalledMedia); QCOMPARE(player->mediaStatus(), QMediaPlayer::StalledMedia); QCOMPARE(statusSpy.count(), 3); @@ -924,7 +924,7 @@ void tst_QMediaPlayer::testMediaStatus() QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); bufferSignals = bufferSpy.count(); - mockService->setMediaStatus(QMediaPlayer::BufferingMedia); + mockPlayer->setMediaStatus(QMediaPlayer::BufferingMedia); QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferingMedia); QCOMPARE(statusSpy.count(), 4); @@ -937,7 +937,7 @@ void tst_QMediaPlayer::testMediaStatus() QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); bufferSignals = bufferSpy.count(); - mockService->setMediaStatus(QMediaPlayer::BufferedMedia); + mockPlayer->setMediaStatus(QMediaPlayer::BufferedMedia); QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferedMedia); QCOMPARE(statusSpy.count(), 5); @@ -948,7 +948,7 @@ void tst_QMediaPlayer::testMediaStatus() QTestEventLoop::instance().enterLoop(1); QCOMPARE(bufferSpy.count(), bufferSignals); - mockService->setMediaStatus(QMediaPlayer::EndOfMedia); + mockPlayer->setMediaStatus(QMediaPlayer::EndOfMedia); QCOMPARE(player->mediaStatus(), QMediaPlayer::EndOfMedia); QCOMPARE(statusSpy.count(), 6); @@ -1061,7 +1061,7 @@ void tst_QMediaPlayer::testQrc() QMediaPlayer player; - mockService->setState(QMediaPlayer::PlayingState, QMediaPlayer::NoMedia); + mockPlayer->setState(QMediaPlayer::PlayingState, QMediaPlayer::NoMedia); QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QUrl))); QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); @@ -1085,14 +1085,14 @@ void tst_QMediaPlayer::testQrc() } // Check the media actually passed to the backend - QCOMPARE(mockService->mockControl->media().scheme(), backendMediaContentScheme); - QCOMPARE(bool(mockService->mockControl->mediaStream()), backendHasStream); + QCOMPARE(mockPlayer->media().scheme(), backendMediaContentScheme); + QCOMPARE(bool(mockPlayer->mediaStream()), backendHasStream); } void tst_QMediaPlayer::testAudioRole() { { - mockService->mockControl->hasAudioRole = false; + mockPlayer->hasAudioRole = false; QMediaPlayer player; QCOMPARE(player.audioRole(), QAudio::UnknownRole); @@ -1105,8 +1105,8 @@ void tst_QMediaPlayer::testAudioRole() } { - mockService->reset(); - mockService->mockControl->hasAudioRole = true; + mockPlayer->reset(); + mockPlayer->hasAudioRole = true; QMediaPlayer player; QSignalSpy spy(&player, SIGNAL(audioRoleChanged(QAudio::Role))); @@ -1130,7 +1130,7 @@ void tst_QMediaPlayer::testAudioRole() void tst_QMediaPlayer::testCustomAudioRole() { { - mockService->mockControl->hasCustomAudioRole = false; + mockPlayer->hasCustomAudioRole = false; QMediaPlayer player; QVERIFY(player.customAudioRole().isEmpty()); @@ -1146,8 +1146,8 @@ void tst_QMediaPlayer::testCustomAudioRole() } { - mockService->reset(); - mockService->mockControl->hasAudioRole = false; + mockPlayer->reset(); + mockPlayer->hasAudioRole = false; QMediaPlayer player; QVERIFY(player.customAudioRole().isEmpty()); @@ -1163,7 +1163,7 @@ void tst_QMediaPlayer::testCustomAudioRole() } { - mockService->reset(); + mockPlayer->reset(); QMediaPlayer player; QSignalSpy spyRole(&player, SIGNAL(audioRoleChanged(QAudio::Role))); QSignalSpy spyCustomRole(&player, SIGNAL(customAudioRoleChanged(const QString &))); diff --git a/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp b/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp index 859df70e0..cc9b0f653 100644 --- a/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp +++ b/tests/auto/unit/multimediawidgets/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp @@ -37,7 +37,6 @@ #include <qmediaplayer.h> #include <qmediaplayercontrol.h> -#include "mockmediaplayerservice.h" #include "mockvideosurface.h" #include "qmockintegration_p.h" diff --git a/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp index f93b5eb43..99422d6b0 100644 --- a/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ b/tests/auto/unit/qml/qdeclarativeaudio/tst_qdeclarativeaudio.cpp @@ -33,7 +33,7 @@ #include "qdeclarativeaudio_p.h" #include "qdeclarativemediametadata_p.h" -#include "mockmediaplayerservice.h" +#include "mockmediaplayer.h" #include "qmockintegration_p.h" #include <QtMultimedia/qmediametadata.h> @@ -144,7 +144,7 @@ void tst_QDeclarativeAudio::source() const QUrl url3; QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -152,17 +152,17 @@ void tst_QDeclarativeAudio::source() audio.setSource(url1); QCOMPARE(audio.source(), url1); - QCOMPARE(service->player()->media(), url1); + QCOMPARE(player->media(), url1); QCOMPARE(spy.count(), 1); audio.setSource(url2); QCOMPARE(audio.source(), url2); - QCOMPARE(service->player()->media(), url2); + QCOMPARE(player->media(), url2); QCOMPARE(spy.count(), 2); audio.setSource(url3); QCOMPARE(audio.source(), url3); - QCOMPARE(service->player()->media(), url3); + QCOMPARE(player->media(), url3); QCOMPARE(spy.count(), 3); } @@ -196,7 +196,7 @@ void tst_QDeclarativeAudio::autoLoad() void tst_QDeclarativeAudio::playing() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *mockPlayer = mockIntegration->lastPlayer(); audio.classBegin(); QSignalSpy stateChangedSpy(&audio, SIGNAL(playbackStateChanged())); @@ -215,7 +215,7 @@ void tst_QDeclarativeAudio::playing() // play() when stopped. audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(mockPlayer->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(playingSpy.count(), ++playing); QCOMPARE(stoppedSpy.count(), stopped); @@ -223,7 +223,7 @@ void tst_QDeclarativeAudio::playing() // stop() when playing. audio.stop(); QCOMPARE(audio.playbackState(), audio.StoppedState); - QCOMPARE(service->player()->state(), QMediaPlayer::StoppedState); + QCOMPARE(mockPlayer->state(), QMediaPlayer::StoppedState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(playingSpy.count(), playing); QCOMPARE(stoppedSpy.count(), ++stopped); @@ -231,14 +231,14 @@ void tst_QDeclarativeAudio::playing() // stop() when stopped. audio.stop(); QCOMPARE(audio.playbackState(), audio.StoppedState); - QCOMPARE(service->player()->state(), QMediaPlayer::StoppedState); + QCOMPARE(mockPlayer->state(), QMediaPlayer::StoppedState); QCOMPARE(stateChangedSpy.count(), stateChanged); QCOMPARE(playingSpy.count(), playing); QCOMPARE(stoppedSpy.count(), stopped); audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(mockPlayer->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(playingSpy.count(), ++playing); QCOMPARE(stoppedSpy.count(), stopped); @@ -246,7 +246,7 @@ void tst_QDeclarativeAudio::playing() // play() when playing. audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(mockPlayer->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), stateChanged); QCOMPARE(playingSpy.count(), playing); QCOMPARE(stoppedSpy.count(), stopped); @@ -255,7 +255,7 @@ void tst_QDeclarativeAudio::playing() void tst_QDeclarativeAudio::paused() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); QSignalSpy stateChangedSpy(&audio, SIGNAL(playbackStateChanged())); @@ -271,42 +271,42 @@ void tst_QDeclarativeAudio::paused() // play() when stopped. audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(pausedSpy.count(), pausedCount); // pause() when playing. audio.pause(); QCOMPARE(audio.playbackState(), audio.PausedState); - QCOMPARE(service->player()->state(), QMediaPlayer::PausedState); + QCOMPARE(player->state(), QMediaPlayer::PausedState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(pausedSpy.count(), ++pausedCount); // pause() when paused. audio.pause(); QCOMPARE(audio.playbackState(), audio.PausedState); - QCOMPARE(service->player()->state(), QMediaPlayer::PausedState); + QCOMPARE(player->state(), QMediaPlayer::PausedState); QCOMPARE(stateChangedSpy.count(), stateChanged); QCOMPARE(pausedSpy.count(), pausedCount); // stop() when paused. audio.stop(); QCOMPARE(audio.playbackState(), audio.StoppedState); - QCOMPARE(service->player()->state(), QMediaPlayer::StoppedState); + QCOMPARE(player->state(), QMediaPlayer::StoppedState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(pausedSpy.count(), pausedCount); // pause() when stopped. audio.pause(); QCOMPARE(audio.playbackState(), audio.PausedState); - QCOMPARE(service->player()->state(), QMediaPlayer::PausedState); + QCOMPARE(player->state(), QMediaPlayer::PausedState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(pausedSpy.count(), ++pausedCount); // play() when paused. audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(pausedSpy.count(), pausedCount); } @@ -314,7 +314,7 @@ void tst_QDeclarativeAudio::paused() void tst_QDeclarativeAudio::duration() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -322,20 +322,20 @@ void tst_QDeclarativeAudio::duration() QCOMPARE(audio.duration(), 0); - service->player()->setDuration(4040); + player->setDuration(4040); QCOMPARE(audio.duration(), 4040); QCOMPARE(spy.count(), 1); - service->player()->setDuration(-129); + player->setDuration(-129); QCOMPARE(audio.duration(), -129); QCOMPARE(spy.count(), 2); - service->player()->setDuration(0); + player->setDuration(0); QCOMPARE(audio.duration(), 0); QCOMPARE(spy.count(), 3); // Unnecessary duration changed signals aren't filtered. - service->player()->setDuration(0); + player->setDuration(0); QCOMPARE(audio.duration(), 0); QCOMPARE(spy.count(), 4); } @@ -343,7 +343,7 @@ void tst_QDeclarativeAudio::duration() void tst_QDeclarativeAudio::position() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -356,31 +356,31 @@ void tst_QDeclarativeAudio::position() audio.seek(450); QCOMPARE(audio.position(), 450); - QCOMPARE(service->player()->position(), qint64(450)); + QCOMPARE(player->position(), qint64(450)); QCOMPARE(spy.count(), 1); audio.seek(-5403); QCOMPARE(audio.position(), 0); - QCOMPARE(service->player()->position(), qint64(0)); + QCOMPARE(player->position(), qint64(0)); QCOMPARE(spy.count(), 2); audio.seek(-5403); QCOMPARE(audio.position(), 0); - QCOMPARE(service->player()->position(), qint64(0)); + QCOMPARE(player->position(), qint64(0)); QCOMPARE(spy.count(), 2); // Check the signal change signal is emitted if the change originates from the media service. - service->player()->setPosition(450); + player->setPosition(450); QCOMPARE(audio.position(), 450); QCOMPARE(spy.count(), 3); connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - service->player()->updateState(QMediaPlayer::PlayingState); + player->updateState(QMediaPlayer::PlayingState); QTestEventLoop::instance().enterLoop(2); QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - service->player()->updateState(QMediaPlayer::PausedState); + player->updateState(QMediaPlayer::PausedState); QTestEventLoop::instance().enterLoop(1); QVERIFY(spy.count() < 6); } @@ -388,7 +388,7 @@ void tst_QDeclarativeAudio::position() void tst_QDeclarativeAudio::volume() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -398,15 +398,15 @@ void tst_QDeclarativeAudio::volume() audio.setVolume(0.7); QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(service->player()->volume(), 70); + QCOMPARE(player->volume(), 70); QCOMPARE(spy.count(), 1); audio.setVolume(0.7); QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(service->player()->volume(), 70); + QCOMPARE(player->volume(), 70); QCOMPARE(spy.count(), 1); - service->player()->setVolume(30); + player->setVolume(30); QCOMPARE(audio.volume(), qreal(0.3)); QCOMPARE(spy.count(), 2); } @@ -414,7 +414,7 @@ void tst_QDeclarativeAudio::volume() void tst_QDeclarativeAudio::muted() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -424,23 +424,23 @@ void tst_QDeclarativeAudio::muted() audio.setMuted(true); QCOMPARE(audio.isMuted(), true); - QCOMPARE(service->player()->isMuted(), true); + QCOMPARE(player->isMuted(), true); QCOMPARE(spy.count(), 1); - service->player()->setMuted(false); + player->setMuted(false); QCOMPARE(audio.isMuted(), false); QCOMPARE(spy.count(), 2); audio.setMuted(false); QCOMPARE(audio.isMuted(), false); - QCOMPARE(service->player()->isMuted(), false); + QCOMPARE(player->isMuted(), false); QCOMPARE(spy.count(), 2); } void tst_QDeclarativeAudio::bufferProgress() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -448,26 +448,26 @@ void tst_QDeclarativeAudio::bufferProgress() QCOMPARE(audio.bufferProgress(), qreal(0.0)); - service->player()->setBufferStatus(20); + player->setBufferStatus(20); QCOMPARE(audio.bufferProgress(), qreal(0.2)); QCOMPARE(spy.count(), 1); - service->player()->setBufferStatus(20); + player->setBufferStatus(20); QCOMPARE(audio.bufferProgress(), qreal(0.2)); QCOMPARE(spy.count(), 2); - service->player()->setBufferStatus(40); + player->setBufferStatus(40); QCOMPARE(audio.bufferProgress(), qreal(0.4)); QCOMPARE(spy.count(), 3); connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - service->player()->updateMediaStatus( + player->updateMediaStatus( QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState); QTestEventLoop::instance().enterLoop(2); QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - service->player()->updateMediaStatus(QMediaPlayer::BufferedMedia); + player->updateMediaStatus(QMediaPlayer::BufferedMedia); QTestEventLoop::instance().enterLoop(1); QVERIFY(spy.count() < 6); } @@ -475,7 +475,7 @@ void tst_QDeclarativeAudio::bufferProgress() void tst_QDeclarativeAudio::seekable() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -483,15 +483,15 @@ void tst_QDeclarativeAudio::seekable() QCOMPARE(audio.isSeekable(), false); - service->player()->setSeekable(true); + player->setSeekable(true); QCOMPARE(audio.isSeekable(), true); QCOMPARE(spy.count(), 1); - service->player()->setSeekable(true); + player->setSeekable(true); QCOMPARE(audio.isSeekable(), true); QCOMPARE(spy.count(), 2); - service->player()->setSeekable(false); + player->setSeekable(false); QCOMPARE(audio.isSeekable(), false); QCOMPARE(spy.count(), 3); } @@ -499,7 +499,7 @@ void tst_QDeclarativeAudio::seekable() void tst_QDeclarativeAudio::playbackRate() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -509,23 +509,23 @@ void tst_QDeclarativeAudio::playbackRate() audio.setPlaybackRate(0.5); QCOMPARE(audio.playbackRate(), qreal(0.5)); - QCOMPARE(service->player()->playbackRate(), qreal(0.5)); + QCOMPARE(player->playbackRate(), qreal(0.5)); QCOMPARE(spy.count(), 1); - service->player()->setPlaybackRate(2.0); - QCOMPARE(service->player()->playbackRate(), qreal(2.0)); + player->setPlaybackRate(2.0); + QCOMPARE(player->playbackRate(), qreal(2.0)); QCOMPARE(spy.count(), 2); audio.setPlaybackRate(2.0); QCOMPARE(audio.playbackRate(), qreal(2.0)); - QCOMPARE(service->player()->playbackRate(), qreal(2.0)); + QCOMPARE(player->playbackRate(), qreal(2.0)); QCOMPARE(spy.count(), 2); } void tst_QDeclarativeAudio::status() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -534,48 +534,48 @@ void tst_QDeclarativeAudio::status() QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); // Set media, start loading. - service->player()->updateMediaStatus(QMediaPlayer::LoadingMedia); + player->updateMediaStatus(QMediaPlayer::LoadingMedia); QCOMPARE(audio.status(), QDeclarativeAudio::Loading); QCOMPARE(statusChangedSpy.count(), 1); // Finish loading. - service->player()->updateMediaStatus(QMediaPlayer::LoadedMedia); + player->updateMediaStatus(QMediaPlayer::LoadedMedia); QCOMPARE(audio.status(), QDeclarativeAudio::Loaded); QCOMPARE(statusChangedSpy.count(), 2); // Play, start buffering. - service->player()->updateMediaStatus( + player->updateMediaStatus( QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState); QCOMPARE(audio.status(), QDeclarativeAudio::Stalled); QCOMPARE(statusChangedSpy.count(), 3); // Enough data buffered to proceed. - service->player()->updateMediaStatus(QMediaPlayer::BufferingMedia); + player->updateMediaStatus(QMediaPlayer::BufferingMedia); QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); QCOMPARE(statusChangedSpy.count(), 4); // Errant second buffering status changed. - service->player()->updateMediaStatus(QMediaPlayer::BufferingMedia); + player->updateMediaStatus(QMediaPlayer::BufferingMedia); QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); QCOMPARE(statusChangedSpy.count(), 4); // Buffer full. - service->player()->updateMediaStatus(QMediaPlayer::BufferedMedia); + player->updateMediaStatus(QMediaPlayer::BufferedMedia); QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); QCOMPARE(statusChangedSpy.count(), 5); // Buffer getting low. - service->player()->updateMediaStatus(QMediaPlayer::BufferingMedia); + player->updateMediaStatus(QMediaPlayer::BufferingMedia); QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); QCOMPARE(statusChangedSpy.count(), 6); // Buffer full. - service->player()->updateMediaStatus(QMediaPlayer::BufferedMedia); + player->updateMediaStatus(QMediaPlayer::BufferedMedia); QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); QCOMPARE(statusChangedSpy.count(), 7); // Finished. - service->player()->updateMediaStatus( + player->updateMediaStatus( QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); QCOMPARE(audio.status(), QDeclarativeAudio::EndOfMedia); QCOMPARE(statusChangedSpy.count(), 8); @@ -631,7 +631,7 @@ void tst_QDeclarativeAudio::error() const QString errorString = QLatin1String("Failed to open device."); QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); audio.classBegin(); audio.componentComplete(); @@ -641,7 +641,7 @@ void tst_QDeclarativeAudio::error() QCOMPARE(audio.error(), QDeclarativeAudio::NoError); QCOMPARE(audio.errorString(), QString()); - service->player()->emitError(QMediaPlayer::ResourceError, errorString); + player->emitError(QMediaPlayer::ResourceError, errorString); QCOMPARE(audio.error(), QDeclarativeAudio::ResourceError); QCOMPARE(audio.errorString(), errorString); @@ -666,7 +666,7 @@ void tst_QDeclarativeAudio::error() void tst_QDeclarativeAudio::loops() { QDeclarativeAudio audio; - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); QSignalSpy loopsChangedSpy(&audio, SIGNAL(loopCountChanged())); QSignalSpy stateChangedSpy(&audio, SIGNAL(playbackStateChanged())); @@ -689,42 +689,42 @@ void tst_QDeclarativeAudio::loops() //play till end audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(stoppedSpy.count(), stoppedCount); // play() when playing. audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), stateChanged); QCOMPARE(stoppedSpy.count(), stoppedCount); - service->player()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); + player->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), stateChanged); QCOMPARE(stoppedSpy.count(), stoppedCount); //play to end - service->player()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); + player->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); QCOMPARE(stoppedSpy.count(), stoppedCount); //play to end - service->player()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); + player->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); QCOMPARE(audio.playbackState(), audio.StoppedState); - QCOMPARE(service->player()->state(), QMediaPlayer::StoppedState); + QCOMPARE(player->state(), QMediaPlayer::StoppedState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(stoppedSpy.count(), ++stoppedCount); // stop when playing audio.play(); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(stoppedSpy.count(), stoppedCount); - service->player()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); + player->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); audio.stop(); QCOMPARE(audio.playbackState(), audio.StoppedState); - QCOMPARE(service->player()->state(), QMediaPlayer::StoppedState); + QCOMPARE(player->state(), QMediaPlayer::StoppedState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(stoppedSpy.count(), ++stoppedCount); @@ -735,16 +735,16 @@ void tst_QDeclarativeAudio::loops() audio.play(); QCOMPARE(audio.playbackState(), audio.PlayingState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); - service->player()->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); + player->updateMediaStatus(QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); QCOMPARE(audio.playbackState(), audio.PlayingState); - QCOMPARE(service->player()->state(), QMediaPlayer::PlayingState); + QCOMPARE(player->state(), QMediaPlayer::PlayingState); QCOMPARE(stateChangedSpy.count(), stateChanged); // stop() when playing in infinite loop. audio.stop(); QCOMPARE(audio.playbackState(), audio.StoppedState); - QCOMPARE(service->player()->state(), QMediaPlayer::StoppedState); + QCOMPARE(player->state(), QMediaPlayer::StoppedState); QCOMPARE(stateChangedSpy.count(), ++stateChanged); QCOMPARE(stoppedSpy.count(), ++stoppedCount); @@ -759,8 +759,8 @@ void tst_QDeclarativeAudio::audioRole() { QDeclarativeAudio *audio = static_cast<QDeclarativeAudio*>(component.create()); - auto *service = mockIntegration->lastPlayerService(); - service->player()->hasAudioRole = false; + auto *player = mockIntegration->lastPlayer(); + player->hasAudioRole = false; QCOMPARE(audio->audioRole(), QDeclarativeAudio::UnknownRole); QVERIFY(audio->supportedAudioRoles().isArray()); @@ -774,8 +774,8 @@ void tst_QDeclarativeAudio::audioRole() { QDeclarativeAudio *audio = static_cast<QDeclarativeAudio*>(component.create()); - auto *service = mockIntegration->lastPlayerService(); - service->player()->hasAudioRole = false; + auto *player = mockIntegration->lastPlayer(); + player->hasAudioRole = false; QSignalSpy spy(audio, SIGNAL(audioRoleChanged())); QCOMPARE(audio->audioRole(), QDeclarativeAudio::UnknownRole); @@ -793,10 +793,10 @@ void tst_QDeclarativeAudio::customAudioRole() QQmlEngine engine; QQmlComponent component(&engine); component.setData("import QtQuick 2.0 \n import QtMultimedia 5.11 \n Audio { }", QUrl()); - auto *service = mockIntegration->lastPlayerService(); + auto *player = mockIntegration->lastPlayer(); { - service->player()->hasCustomAudioRole = false; + player->hasCustomAudioRole = false; QObject *audio = component.create(); QVERIFY(audio); @@ -816,7 +816,7 @@ void tst_QDeclarativeAudio::customAudioRole() } { - service->player()->hasAudioRole = false; + player->hasAudioRole = false; QObject *audio = component.create(); QVERIFY(audio); |