diff options
author | Doris Verria <doris.verria@qt.io> | 2021-02-09 22:55:31 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-02-17 08:25:35 +0000 |
commit | 03f3201a24514f43e781bf59026ca5039fd9ab21 (patch) | |
tree | c7567ecc5088aa7fbd66a03d71b40212f87576e1 /src/multimedia/platform | |
parent | 187419edb2c087063afc5931134d36692f4b39a4 (diff) |
Remove QMediaService dependency from QMediaPlatformPlayerInterface
Change-Id: I33e6ba9de3fa00617657d85b4558d39af400280d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia/platform')
12 files changed, 50 insertions, 208 deletions
diff --git a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice.cpp b/src/multimedia/platform/android/mediaplayer/qandroidmediaservice.cpp index 6f8e88dc0..aa00dedce 100644 --- a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice.cpp +++ b/src/multimedia/platform/android/mediaplayer/qandroidmediaservice.cpp @@ -55,29 +55,6 @@ QAndroidMediaService::~QAndroidMediaService() delete mMediaControl; } -QObject *QAndroidMediaService::requestControl(const char *name) -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return mMediaControl; - - if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (!mVideoRendererControl) { - mVideoRendererControl = new QAndroidMediaPlayerVideoRendererControl(mMediaControl); - return mVideoRendererControl; - } - } - - return 0; -} - -void QAndroidMediaService::releaseControl(QObject *control) -{ - if (control == mVideoRendererControl) { - delete mVideoRendererControl; - mVideoRendererControl = 0; - } -} - QMediaPlayerControl *QAndroidMediaService::player() { return mMediaControl; diff --git a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice_p.h b/src/multimedia/platform/android/mediaplayer/qandroidmediaservice_p.h index 9b227809e..d01cf59fe 100644 --- a/src/multimedia/platform/android/mediaplayer/qandroidmediaservice_p.h +++ b/src/multimedia/platform/android/mediaplayer/qandroidmediaservice_p.h @@ -65,9 +65,6 @@ public: explicit QAndroidMediaService(); ~QAndroidMediaService() override; - QObject *requestControl(const char *name) override; - void releaseControl(QObject *control) override; - // QMediaPlatformPlayerInterface QMediaPlayerControl *player() override; // QMediaStreamsControl *streams() override; diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm index 32cc5fd27..5d6422530 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm @@ -63,53 +63,7 @@ AVFMediaPlayerService::~AVFMediaPlayerService() qDebug() << Q_FUNC_INFO; #endif delete m_session; -} - -QObject *AVFMediaPlayerService::requestControl(const char *name) -{ -#ifdef QT_DEBUG_AVF - qDebug() << Q_FUNC_INFO << name; -#endif - - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return m_control; - -#if QT_CONFIG(opengl) - if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (!m_videoOutput) - m_videoOutput = new AVFVideoRendererControl(this); - - m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput)); - return m_videoOutput; - } -#endif - if (qstrcmp(name, QVideoWindowControl_iid) == 0) { - if (!m_videoOutput) - m_videoOutput = new AVFVideoWindowControl(this); - - m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput)); - return m_videoOutput; - } - return nullptr; -} - -void AVFMediaPlayerService::releaseControl(QObject *control) -{ -#ifdef QT_DEBUG_AVF - qDebug() << Q_FUNC_INFO << control; -#endif - if (m_videoOutput == control) { -#if QT_CONFIG(opengl) - AVFVideoRendererControl *renderControl = qobject_cast<AVFVideoRendererControl*>(m_videoOutput); - - if (renderControl) - renderControl->setSurface(nullptr); -#endif - m_videoOutput = nullptr; - m_session->setVideoOutput(nullptr); - - delete control; - } + //delete m_control; } QMediaPlayerControl *AVFMediaPlayerService::player() diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h index 2690c7828..185f1d805 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h +++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h @@ -65,9 +65,6 @@ public: explicit AVFMediaPlayerService(); ~AVFMediaPlayerService(); - QObject *requestControl(const char *name) override; - void releaseControl(QObject *control) override; - // QMediaPlatformPlayerInterface QMediaPlayerControl *player() override; // QMediaStreamsControl *streams() override; diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp index 3a00d7673..3608ff868 100644 --- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp +++ b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp @@ -71,39 +71,11 @@ QGstreamerPlayerService::QGstreamerPlayerService() QGstreamerPlayerService::~QGstreamerPlayerService() { -} - -QObject *QGstreamerPlayerService::requestControl(const char *name) -{ - if (qstrcmp(name,QMediaPlayerControl_iid) == 0) - return m_control; - - if (!m_videoOutput) { - if (qstrcmp(name, QVideoRendererControl_iid) == 0) - m_videoOutput = m_videoRenderer; - else if (qstrcmp(name, QVideoWindowControl_iid) == 0) - m_videoOutput = m_videoWindow; - - if (m_videoOutput) { - increaseVideoRef(); - m_control->setVideoOutput(m_videoOutput); - return m_videoOutput; - } - } - - return 0; -} - -void QGstreamerPlayerService::releaseControl(QObject *control) -{ - if (!control) - return; - - if (control == m_videoOutput) { - m_videoOutput = 0; - m_control->setVideoOutput(0); - decreaseVideoRef(); - } + // delete m_session; + // delete m_control; + // delete m_streamsControl; + // delete m_videoRenderer; + // delete m_videoWindow; } QMediaPlayerControl *QGstreamerPlayerService::player() diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h index 52cd7f848..e3f9862b4 100644 --- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h +++ b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h @@ -74,10 +74,6 @@ public: QGstreamerPlayerService(); ~QGstreamerPlayerService(); - // ### QMediaService, go away - QObject *requestControl(const char *name) override; - void releaseControl(QObject *control) override; - // QMediaPlatformPlayerInterface QMediaPlayerControl *player() override; QMediaStreamsControl *streams() override; diff --git a/src/multimedia/platform/qmediaplatformplayerinterface.cpp b/src/multimedia/platform/qmediaplatformplayerinterface.cpp index 570c7fd90..4f29273fe 100644 --- a/src/multimedia/platform/qmediaplatformplayerinterface.cpp +++ b/src/multimedia/platform/qmediaplatformplayerinterface.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QMediaPlatformPlayerInterface::QMediaPlatformPlayerInterface() - : QMediaService(nullptr) + : QObject(nullptr) { } diff --git a/src/multimedia/platform/qmediaplatformplayerinterface_p.h b/src/multimedia/platform/qmediaplatformplayerinterface_p.h index b3598eb86..c086f637e 100644 --- a/src/multimedia/platform/qmediaplatformplayerinterface_p.h +++ b/src/multimedia/platform/qmediaplatformplayerinterface_p.h @@ -60,7 +60,7 @@ class QMediaStreamsControl; class QVideoRendererControl; class QVideoWindowControl; -class Q_MULTIMEDIA_EXPORT QMediaPlatformPlayerInterface : public QMediaService // ### for now, get rid of me +class Q_MULTIMEDIA_EXPORT QMediaPlatformPlayerInterface : public QObject { public: QMediaPlatformPlayerInterface(); diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice.cpp b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice.cpp index 00b4e76bb..fe111aca0 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice.cpp +++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice.cpp @@ -65,53 +65,6 @@ MmRendererMediaPlayerService::~MmRendererMediaPlayerService() delete m_mediaPlayerControl; } -QObject *MmRendererMediaPlayerService::requestControl(const char *name) -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) { - if (!m_mediaPlayerControl) { - m_mediaPlayerControl = new MmrEventMediaPlayerControl; - updateControls(); - } - return m_mediaPlayerControl; - } else if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (!m_appHasDrmPermissionChecked) { - m_appHasDrmPermission = checkForDrmPermission(); - m_appHasDrmPermissionChecked = true; - } - - if (m_appHasDrmPermission) { - // When the application wants to play back DRM secured media, we can't use - // the QVideoRendererControl, because we won't have access to the pixel data - // in this case. - return 0; - } - - if (!m_videoRendererControl) { - m_videoRendererControl = new MmRendererPlayerVideoRendererControl(); - updateControls(); - } - return m_videoRendererControl; - } else if (qstrcmp(name, QVideoWindowControl_iid) == 0) { - if (!m_videoWindowControl) { - m_videoWindowControl = new MmRendererVideoWindowControl(); - updateControls(); - } - return m_videoWindowControl; - } - return 0; -} - -void MmRendererMediaPlayerService::releaseControl(QObject *control) -{ - if (control == m_videoRendererControl) - m_videoRendererControl = 0; - if (control == m_videoWindowControl) - m_videoWindowControl = 0; - if (control == m_mediaPlayerControl) - m_mediaPlayerControl = 0; - delete control; -} - void MmRendererMediaPlayerService::updateControls() { if (m_videoRendererControl && m_mediaPlayerControl) @@ -123,16 +76,40 @@ void MmRendererMediaPlayerService::updateControls() QMediaPlayerControl *MmRendererMediaPlayerService::player() { + if (!m_mediaPlayerControl) { + m_mediaPlayerControl = new MmrEventMediaPlayerControl; + updateControls(); + } return m_mediaPlayerControl; } QVideoRendererControl *MmRendererMediaPlayerService::createVideoRenderer() { + if (!m_appHasDrmPermissionChecked) { + m_appHasDrmPermission = checkForDrmPermission(); + m_appHasDrmPermissionChecked = true; + } + + if (m_appHasDrmPermission) { + // When the application wants to play back DRM secured media, we can't use + // the QVideoRendererControl, because we won't have access to the pixel data + // in this case. + return nullptr; + } + + if (!m_videoRendererControl) { + m_videoRendererControl = new MmRendererPlayerVideoRendererControl(); + updateControls(); + } return m_videoRendererControl; } QVideoWindowControl *MmRendererMediaPlayerService::createVideoWindow() { + if (!m_videoWindowControl) { + m_videoWindowControl = new MmRendererVideoWindowControl(); + updateControls(); + } return m_videoWindowControl; } diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice_p.h b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice_p.h index 441ebfd61..206277e8b 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice_p.h +++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderermediaplayerservice_p.h @@ -66,9 +66,6 @@ public: explicit MmRendererMediaPlayerService(QObject *parent = 0); ~MmRendererMediaPlayerService(); - QObject *requestControl(const char *name) override; - void releaseControl(QObject *control) override; - // QMediaPlatformPlayerInterface QMediaPlayerControl *player() override; // QMediaStreamsControl *streams() override; @@ -79,9 +76,13 @@ public: private: void updateControls(); - QPointer<MmRendererPlayerVideoRendererControl> m_videoRendererControl; - QPointer<MmRendererVideoWindowControl> m_videoWindowControl; - QPointer<MmRendererMediaPlayerControl> m_mediaPlayerControl; + // QPointer<MmRendererPlayerVideoRendererControl> m_videoRendererControl; + // QPointer<MmRendererVideoWindowControl> m_videoWindowControl; + // QPointer<MmRendererMediaPlayerControl> m_mediaPlayerControl; + + MmRendererPlayerVideoRendererControl *m_videoRendererControl; + MmRendererVideoWindowControl *m_videoWindowControl; + MmRendererMediaPlayerControl *m_mediaPlayerControl; bool m_appHasDrmPermission : 1; bool m_appHasDrmPermissionChecked : 1; diff --git a/src/multimedia/platform/windows/player/mfplayerservice.cpp b/src/multimedia/platform/windows/player/mfplayerservice.cpp index 5099a1706..d5d461082 100644 --- a/src/multimedia/platform/windows/player/mfplayerservice.cpp +++ b/src/multimedia/platform/windows/player/mfplayerservice.cpp @@ -64,42 +64,8 @@ MFPlayerService::~MFPlayerService() delete m_videoRendererControl; m_session->Release(); -} - -QObject *MFPlayerService::requestControl(const char *name) -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) { - return m_player; - } else if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (!m_videoRendererControl && !m_videoWindowControl) { - m_videoRendererControl = new MFVideoRendererControl; - return m_videoRendererControl; - } - } else if (qstrcmp(name, QVideoWindowControl_iid) == 0) { - if (!m_videoRendererControl && !m_videoWindowControl) { - m_videoWindowControl = new MFEvrVideoWindowControl; - return m_videoWindowControl; - } - } - return 0; -} - -void MFPlayerService::releaseControl(QObject *control) -{ - if (!control) { - qWarning("QMediaService::releaseControl():" - " Attempted release of null control"); - } else if (control == m_videoRendererControl) { - m_videoRendererControl->setSurface(0); - delete m_videoRendererControl; - m_videoRendererControl = 0; - return; - } else if (control == m_videoWindowControl) { - delete m_videoWindowControl; - m_videoWindowControl = 0; - return; - } + //delete m_player; } QMediaPlayerControl *MFPlayerService::player() @@ -109,12 +75,20 @@ QMediaPlayerControl *MFPlayerService::player() QVideoRendererControl *MFPlayerService::createVideoRenderer() { - return m_videoRendererControl; + if (!m_videoRendererControl && !m_videoWindowControl) { + m_videoRendererControl = new MFVideoRendererControl; + return m_videoRendererControl; + } + return nullptr; } QVideoWindowControl *MFPlayerService::createVideoWindow() { - return m_videoWindowControl; + if (!m_videoRendererControl && !m_videoWindowControl) { + m_videoWindowControl = new MFEvrVideoWindowControl; + return m_videoWindowControl; + } + return nullptr; } MFVideoRendererControl* MFPlayerService::videoRendererControl() const diff --git a/src/multimedia/platform/windows/player/mfplayerservice_p.h b/src/multimedia/platform/windows/player/mfplayerservice_p.h index 7c0685a78..1170d7be9 100644 --- a/src/multimedia/platform/windows/player/mfplayerservice_p.h +++ b/src/multimedia/platform/windows/player/mfplayerservice_p.h @@ -77,9 +77,6 @@ public: MFPlayerService(); ~MFPlayerService(); - QObject *requestControl(const char *name) override; - void releaseControl(QObject *control) override; - QMediaPlayerControl *player() override; // ### QMediaStreamsControl *streams() override; |