summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-01-20 13:45:37 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-29 08:47:33 +0000
commit39833f266589dedc014f045c8d42df1edb13fcec (patch)
treed0d45f7fa05f1d6f2838ae4b9a54640c16b419af /src
parented3301b9d4479f24b1588d802d4f017e394bd56b (diff)
Start using the new QMediaPlatformPlayerInterface
And get rid of the corresponding service plugins. Change-Id: I4b5b694e0cae93ba116a2dd58efd5ad8a2eb0743 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/multimedia/qmldir2
-rw-r--r--src/multimedia/CMakeLists.txt3
-rw-r--r--src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm55
-rw-r--r--src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h27
-rw-r--r--src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin.mm99
-rw-r--r--src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin_p.h84
-rw-r--r--src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri2
-rw-r--r--src/multimedia/platform/darwin/qdarwinintegration.cpp6
-rw-r--r--src/multimedia/platform/darwin/qdarwinintegration_p.h2
-rw-r--r--src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri6
-rw-r--r--src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp115
-rw-r--r--src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h21
-rw-r--r--src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin.cpp93
-rw-r--r--src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin_p.h84
-rw-r--r--src/multimedia/platform/gstreamer/qgstreamerintegration.cpp7
-rw-r--r--src/multimedia/platform/gstreamer/qgstreamerintegration_p.h3
-rw-r--r--src/multimedia/platform/qmediaplatformintegration_p.h2
-rw-r--r--src/multimedia/platform/qmediaplatformplayerinterface.cpp6
-rw-r--r--src/multimedia/platform/qmediaplatformplayerinterface_p.h12
-rw-r--r--src/multimedia/platform/windows/player/mfplayerservice.cpp63
-rw-r--r--src/multimedia/platform/windows/player/mfplayerservice_p.h30
-rw-r--r--src/multimedia/platform/windows/qwindowsintegration.cpp19
-rw-r--r--src/multimedia/platform/windows/qwindowsintegration_p.h5
-rw-r--r--src/multimedia/platform/windows/windows.pri2
-rw-r--r--src/multimedia/platform/windows/wmfserviceplugin.cpp103
-rw-r--r--src/multimedia/platform/windows/wmfserviceplugin_p.h75
-rw-r--r--src/multimedia/playback/qmediaplayer.cpp87
-rw-r--r--src/multimedia/qmediaserviceprovider.cpp8
28 files changed, 376 insertions, 645 deletions
diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir
index 3d2d7c460..e7dcc3dd6 100644
--- a/src/imports/multimedia/qmldir
+++ b/src/imports/multimedia/qmldir
@@ -2,4 +2,6 @@ module QtMultimedia
plugin declarative_multimedia
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 a1dce9d91..2245eeb43 100644
--- a/src/multimedia/CMakeLists.txt
+++ b/src/multimedia/CMakeLists.txt
@@ -174,7 +174,6 @@ qt_internal_extend_target(Multimedia CONDITION WIN32
platform/windows/qwindowsdevicemanager.cpp platform/windows/qwindowsdevicemanager_p.h
platform/windows/qwindowsintegration.cpp platform/windows/qwindowsintegration_p.h
platform/windows/sourceresolver.cpp platform/windows/sourceresolver_p.h
- platform/windows/wmfserviceplugin.cpp platform/windows/wmfserviceplugin_p.h
INCLUDE_DIRECTORIES
platform/windows/decoder
platform/windows/evr
@@ -231,7 +230,6 @@ qt_internal_extend_target(Multimedia CONDITION QT_FEATURE_gstreamer
platform/gstreamer/common/qgstvideorenderersink.cpp platform/gstreamer/common/qgstvideorenderersink_p.h
platform/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp platform/gstreamer/mediaplayer/qgstreamermetadataprovider_p.h
platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h
- platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin.cpp platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin_p.h
platform/gstreamer/mediaplayer/qgstreamerstreamscontrol.cpp platform/gstreamer/mediaplayer/qgstreamerstreamscontrol_p.h
platform/gstreamer/qgstreamerdevicemanager.cpp platform/gstreamer/qgstreamerdevicemanager_p.h
platform/gstreamer/qgstreamerintegration.cpp platform/gstreamer/qgstreamerintegration_p.h
@@ -429,7 +427,6 @@ qt_internal_extend_target(Multimedia CONDITION APPLE AND NOT WATCHOS
platform/darwin/mediaplayer/avfmediaplayercontrol.mm platform/darwin/mediaplayer/avfmediaplayercontrol_p.h
platform/darwin/mediaplayer/avfmediaplayermetadatacontrol.mm platform/darwin/mediaplayer/avfmediaplayermetadatacontrol_p.h
platform/darwin/mediaplayer/avfmediaplayerservice.mm platform/darwin/mediaplayer/avfmediaplayerservice_p.h
- platform/darwin/mediaplayer/avfmediaplayerserviceplugin.mm platform/darwin/mediaplayer/avfmediaplayerserviceplugin_p.h
platform/darwin/mediaplayer/avfmediaplayersession.mm platform/darwin/mediaplayer/avfmediaplayersession_p.h
platform/darwin/mediaplayer/avfvideooutput.mm platform/darwin/mediaplayer/avfvideooutput_p.h
platform/darwin/mediaplayer/avfvideowindowcontrol.mm platform/darwin/mediaplayer/avfvideowindowcontrol_p.h
diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm
index b8d3d4e82..b300c4c1a 100644
--- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm
+++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice.mm
@@ -51,9 +51,7 @@
QT_USE_NAMESPACE
-AVFMediaPlayerService::AVFMediaPlayerService(QObject *parent)
- : QMediaService(parent)
- , m_videoOutput(nullptr)
+AVFMediaPlayerService::AVFMediaPlayerService()
{
m_session = new AVFMediaPlayerSession(this);
m_control = new AVFMediaPlayerControl(this);
@@ -120,3 +118,54 @@ void AVFMediaPlayerService::releaseControl(QObject *control)
delete control;
}
}
+
+QMediaPlayerControl *AVFMediaPlayerService::player()
+{
+ return m_control;
+}
+
+QMetaDataReaderControl *AVFMediaPlayerService::dataReader()
+{
+ return m_playerMetaDataControl;
+}
+
+QVideoRendererControl *AVFMediaPlayerService::createVideoRenderer()
+{
+ if (m_videoOutput)
+ return nullptr;
+
+ auto *control = new AVFVideoRendererControl(this);
+ m_videoOutput = control;
+
+ m_session->setVideoOutput(control);
+ return control;
+}
+
+QVideoWindowControl *AVFMediaPlayerService::createVideoWindow()
+{
+ if (m_videoOutput)
+ return nullptr;
+
+ auto *control = new AVFVideoWindowControl(this);
+ m_videoOutput = control;
+
+ m_session->setVideoOutput(control);
+ return control;
+}
+
+#if 0
+void listSupportedMimeTypes()
+{
+ //Populate m_supportedMimeTypes with mimetypes AVAsset supports
+ NSArray *mimeTypes = [AVURLAsset audiovisualMIMETypes];
+ for (NSString *mimeType in mimeTypes)
+ {
+ m_supportedMimeTypes.append(QString::fromUtf8([mimeType UTF8String]));
+ }
+#ifdef QT_DEBUG_AVF
+ qDebug() << "AVFMediaPlayerServicePlugin::buildSupportedTypes";
+ qDebug() << "Supported Types: " << m_supportedMimeTypes;
+#endif
+
+}
+#endif
diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h
index 8d5f63da2..927726cc3 100644
--- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h
+++ b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerservice_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtMultimedia/QMediaService>
+#include <private/qmediaplatformplayerinterface_p.h>
QT_BEGIN_NAMESPACE
@@ -60,20 +60,33 @@ class AVFMediaPlayerControl;
class AVFMediaPlayerMetaDataControl;
class AVFVideoOutput;
-class AVFMediaPlayerService : public QMediaService
+class AVFMediaPlayerService : public QMediaPlatformPlayerInterface
{
public:
- explicit AVFMediaPlayerService(QObject *parent = nullptr);
+ explicit AVFMediaPlayerService();
~AVFMediaPlayerService();
QObject *requestControl(const char *name) override;
void releaseControl(QObject *control) override;
+ // QMediaPlatformPlayerInterface
+ QMediaPlayerControl *player() override;
+ QMetaDataReaderControl *dataReader() override;
+// QMediaStreamsControl *streams() override;
+// QMediaVideoProbeControl *videoProbe() override;
+// void releaseVideoProbe(QMediaVideoProbeControl *) override;
+// QMediaAudioProbeControl *audioProbe() override;
+// void releaseAudioProbe(QMediaAudioProbeControl *) override;
+
+ QVideoRendererControl *createVideoRenderer() override;
+ QVideoWindowControl *createVideoWindow() override;;
+
+
private:
- AVFMediaPlayerSession *m_session;
- AVFMediaPlayerControl *m_control;
- QObject *m_videoOutput;
- AVFMediaPlayerMetaDataControl *m_playerMetaDataControl;
+ AVFMediaPlayerSession *m_session = nullptr;
+ AVFMediaPlayerControl *m_control = nullptr;
+ QObject *m_videoOutput = nullptr;
+ AVFMediaPlayerMetaDataControl *m_playerMetaDataControl = nullptr;
};
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin.mm b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin.mm
deleted file mode 100644
index 504909598..000000000
--- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin.mm
+++ /dev/null
@@ -1,99 +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 "avfmediaplayerserviceplugin_p.h"
-#include <QtCore/QDebug>
-
-#include "avfmediaplayerservice_p.h"
-
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-AVFMediaPlayerServicePlugin::AVFMediaPlayerServicePlugin()
-{
- buildSupportedTypes();
-}
-
-QMediaService *AVFMediaPlayerServicePlugin::create(const QString &key)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << "AVFMediaPlayerServicePlugin::create" << key;
-#endif
- if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
- return new AVFMediaPlayerService;
-
- qWarning() << "unsupported key: " << key;
- return nullptr;
-}
-
-void AVFMediaPlayerServicePlugin::release(QMediaService *service)
-{
- delete service;
-}
-
-QMultimedia::SupportEstimate AVFMediaPlayerServicePlugin::hasSupport(const QString &mimeType, const QStringList &codecs) const
-{
- Q_UNUSED(codecs);
-
- if (m_supportedMimeTypes.contains(mimeType))
- return QMultimedia::ProbablySupported;
-
- return QMultimedia::MaybeSupported;
-}
-
-QStringList AVFMediaPlayerServicePlugin::supportedMimeTypes() const
-{
- return m_supportedMimeTypes;
-}
-
-void AVFMediaPlayerServicePlugin::buildSupportedTypes()
-{
- //Populate m_supportedMimeTypes with mimetypes AVAsset supports
- NSArray *mimeTypes = [AVURLAsset audiovisualMIMETypes];
- for (NSString *mimeType in mimeTypes)
- {
- m_supportedMimeTypes.append(QString::fromUtf8([mimeType UTF8String]));
- }
-#ifdef QT_DEBUG_AVF
- qDebug() << "AVFMediaPlayerServicePlugin::buildSupportedTypes";
- qDebug() << "Supported Types: " << m_supportedMimeTypes;
-#endif
-
-}
diff --git a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin_p.h b/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin_p.h
deleted file mode 100644
index d6e17c446..000000000
--- a/src/multimedia/platform/darwin/mediaplayer/avfmediaplayerserviceplugin_p.h
+++ /dev/null
@@ -1,84 +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 AVFMEDIAPLAYERSERVICEPLUGIN_H
-#define AVFMEDIAPLAYERSERVICEPLUGIN_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/qglobal.h>
-#include <QtMultimedia/qmediaserviceproviderplugin.h>
-
-QT_BEGIN_NAMESPACE
-
-class AVFMediaPlayerServicePlugin
- : public QMediaServiceProviderPlugin
- , public QMediaServiceSupportedFormatsInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
-
-public:
- explicit AVFMediaPlayerServicePlugin();
-
- QMediaService* create(QString const& key) override;
- void release(QMediaService *service) override;
-
- QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const override;
- QStringList supportedMimeTypes() const override;
-
-private:
- void buildSupportedTypes();
-
- QStringList m_supportedMimeTypes;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFMEDIAPLAYERSERVICEPLUGIN_H
diff --git a/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri b/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri
index 2929ffe50..6c02ed23d 100644
--- a/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri
+++ b/src/multimedia/platform/darwin/mediaplayer/mediaplayer.pri
@@ -5,7 +5,6 @@ HEADERS += \
$$PWD/avfmediaplayermetadatacontrol_p.h \
$$PWD/avfmediaplayerservice_p.h \
$$PWD/avfmediaplayersession_p.h \
- $$PWD/avfmediaplayerserviceplugin_p.h \
$$PWD/avfvideooutput_p.h \
$$PWD/avfvideowindowcontrol_p.h
@@ -13,7 +12,6 @@ SOURCES += \
$$PWD/avfmediaplayercontrol.mm \
$$PWD/avfmediaplayermetadatacontrol.mm \
$$PWD/avfmediaplayerservice.mm \
- $$PWD/avfmediaplayerserviceplugin.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 792dda097..ed38141e1 100644
--- a/src/multimedia/platform/darwin/qdarwinintegration.cpp
+++ b/src/multimedia/platform/darwin/qdarwinintegration.cpp
@@ -39,6 +39,7 @@
#include "qdarwinintegration_p.h"
#include "qdarwindevicemanager_p.h"
+#include <private/avfmediaplayerservice_p.h>
QT_BEGIN_NAMESPACE
@@ -59,4 +60,9 @@ QMediaPlatformDeviceManager *QDarwinIntegration::deviceManager()
return m_manager;
}
+QMediaPlatformPlayerInterface *QDarwinIntegration::createPlayerInterface()
+{
+ return new AVFMediaPlayerService;
+}
+
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/darwin/qdarwinintegration_p.h b/src/multimedia/platform/darwin/qdarwinintegration_p.h
index c4ca1a990..af59fb093 100644
--- a/src/multimedia/platform/darwin/qdarwinintegration_p.h
+++ b/src/multimedia/platform/darwin/qdarwinintegration_p.h
@@ -65,6 +65,8 @@ public:
QMediaPlatformDeviceManager *deviceManager() override;
+ QMediaPlatformPlayerInterface *createPlayerInterface() override;
+
QDarwinDeviceManager *m_manager = nullptr;
};
diff --git a/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri b/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri
index 0e7502105..1a0d7cefc 100644
--- a/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri
+++ b/src/multimedia/platform/gstreamer/mediaplayer/mediaplayer.pri
@@ -3,11 +3,9 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qgstreamerplayerservice_p.h \
$$PWD/qgstreamerstreamscontrol_p.h \
- $$PWD/qgstreamermetadataprovider_p.h \
- $$PWD/qgstreamerplayerserviceplugin_p.h
+ $$PWD/qgstreamermetadataprovider_p.h
SOURCES += \
$$PWD/qgstreamerplayerservice.cpp \
$$PWD/qgstreamerstreamscontrol.cpp \
- $$PWD/qgstreamermetadataprovider.cpp \
- $$PWD/qgstreamerplayerserviceplugin.cpp
+ $$PWD/qgstreamermetadataprovider.cpp
diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp
index 0c548c730..acc7958ae 100644
--- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp
+++ b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice.cpp
@@ -56,8 +56,8 @@
QT_BEGIN_NAMESPACE
-QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent)
- : QMediaService(parent)
+QGstreamerPlayerService::QGstreamerPlayerService()
+ : QMediaPlatformPlayerInterface()
{
m_session = new QGstreamerPlayerSession(this);
m_control = new QGstreamerPlayerControl(m_session, this);
@@ -85,9 +85,6 @@ QObject *QGstreamerPlayerService::requestControl(const char *name)
if (qstrcmp(name,QMetaDataReaderControl_iid) == 0)
return m_metaData;
- if (qstrcmp(name,QMediaStreamsControl_iid) == 0)
- return m_streamsControl;
-
if (qstrcmp(name, QMediaVideoProbeControl_iid) == 0) {
if (!m_videoProbeControl) {
increaseVideoRef();
@@ -144,6 +141,86 @@ void QGstreamerPlayerService::releaseControl(QObject *control)
}
}
+QMediaPlayerControl *QGstreamerPlayerService::player()
+{
+ return m_control;
+}
+
+QMetaDataReaderControl *QGstreamerPlayerService::dataReader()
+{
+ return m_metaData;
+}
+
+QMediaStreamsControl *QGstreamerPlayerService::streams()
+{
+ return m_streamsControl;
+}
+
+QMediaVideoProbeControl *QGstreamerPlayerService::videoProbe()
+{
+ if (!m_videoProbeControl) {
+ increaseVideoRef();
+ m_videoProbeControl = new QGstreamerVideoProbeControl(this);
+ m_session->addProbe(m_videoProbeControl);
+ }
+ return m_videoProbeControl;
+}
+
+void QGstreamerPlayerService::releaseVideoProbe(QMediaVideoProbeControl *)
+{
+ Q_ASSERT(m_videoProbeControl);
+ if (!m_videoProbeControl->ref.deref()) {
+ m_session->removeProbe(m_videoProbeControl);
+ delete m_videoProbeControl;
+ m_videoProbeControl = nullptr;
+ decreaseVideoRef();
+ }
+}
+
+QMediaAudioProbeControl *QGstreamerPlayerService::audioProbe()
+{
+ if (!m_audioProbeControl) {
+ m_audioProbeControl = new QGstreamerAudioProbeControl(this);
+ m_session->addProbe(m_audioProbeControl);
+ }
+ m_audioProbeControl->ref.ref();
+ return m_audioProbeControl;
+}
+
+void QGstreamerPlayerService::releaseAudioProbe(QMediaAudioProbeControl *)
+{
+ Q_ASSERT(m_audioProbeControl);
+ if (!m_audioProbeControl->ref.deref()) {
+ m_session->removeProbe(m_audioProbeControl);
+ delete m_audioProbeControl;
+ m_audioProbeControl = nullptr;
+ }
+}
+
+QVideoRendererControl *QGstreamerPlayerService::createVideoRenderer()
+{
+ if (!m_videoOutput) {
+ m_videoOutput = m_videoRenderer;
+
+ increaseVideoRef();
+ m_control->setVideoOutput(m_videoOutput);
+ return m_videoRenderer;
+ }
+ return nullptr;
+}
+
+QVideoWindowControl *QGstreamerPlayerService::createVideoWindow()
+{
+ if (!m_videoOutput) {
+ m_videoOutput = m_videoWindow;
+
+ increaseVideoRef();
+ m_control->setVideoOutput(m_videoOutput);
+ return m_videoWindow;
+ }
+ return nullptr;
+}
+
void QGstreamerPlayerService::increaseVideoRef()
{
m_videoReferenceCount++;
@@ -154,4 +231,32 @@ void QGstreamerPlayerService::decreaseVideoRef()
m_videoReferenceCount--;
}
+#if 0
+// ### Re-add something similar to be able to check for support of certain file formats
+QMultimedia::SupportEstimate QGstreamerPlayerServicePlugin::hasSupport(const QString &mimeType,
+ const QStringList &codecs) const
+{
+ if (m_supportedMimeTypeSet.isEmpty())
+ updateSupportedMimeTypes();
+
+ return QGstUtils::hasSupport(mimeType, codecs, m_supportedMimeTypeSet);
+}
+
+static bool isDecoderOrDemuxer(GstElementFactory *factory)
+{
+ return gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DEMUXER)
+ || gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DECODER);
+}
+
+void QGstreamerPlayerServicePlugin::updateSupportedMimeTypes() const
+{
+ m_supportedMimeTypeSet = QGstUtils::supportedMimeTypes(isDecoderOrDemuxer);
+}
+
+QStringList QGstreamerPlayerServicePlugin::supportedMimeTypes() const
+{
+ return QStringList();
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h
index 12550be16..816f84830 100644
--- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h
+++ b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerservice_p.h
@@ -54,7 +54,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qiodevice.h>
-#include <qmediaservice.h>
+#include <private/qmediaplatformplayerinterface_p.h>
QT_BEGIN_NAMESPACE
class QMediaPlayerControl;
@@ -70,16 +70,29 @@ class QGStreamerAvailabilityControl;
class QGstreamerAudioProbeControl;
class QGstreamerVideoProbeControl;
-class QGstreamerPlayerService : public QMediaService
+class QGstreamerPlayerService : public QMediaPlatformPlayerInterface
{
Q_OBJECT
public:
- QGstreamerPlayerService(QObject *parent = 0);
+ QGstreamerPlayerService();
~QGstreamerPlayerService();
+ // ### QMediaService, go away
QObject *requestControl(const char *name) override;
void releaseControl(QObject *control) override;
+ // QMediaPlatformPlayerInterface
+ QMediaPlayerControl *player() override;
+ QMetaDataReaderControl *dataReader() override;
+ QMediaStreamsControl *streams() override;
+ QMediaVideoProbeControl *videoProbe() override;
+ void releaseVideoProbe(QMediaVideoProbeControl *) override;
+ QMediaAudioProbeControl *audioProbe() override;
+ void releaseAudioProbe(QMediaAudioProbeControl *) override;
+
+ QVideoRendererControl *createVideoRenderer() override;
+ QVideoWindowControl *createVideoWindow() override;;
+
private:
QGstreamerPlayerControl *m_control = nullptr;
QGstreamerPlayerSession *m_session = nullptr;
@@ -90,7 +103,7 @@ private:
QGstreamerVideoProbeControl *m_videoProbeControl = nullptr;
QObject *m_videoOutput = nullptr;
- QObject *m_videoRenderer = nullptr;
+ QVideoRendererControl *m_videoRenderer = nullptr;
QGstreamerVideoWindow *m_videoWindow = nullptr;
void increaseVideoRef();
diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin.cpp b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin.cpp
deleted file mode 100644
index 4da251014..000000000
--- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin.cpp
+++ /dev/null
@@ -1,93 +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/qstring.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/QDir>
-#include <QtCore/QDebug>
-
-#include "qgstreamerplayerserviceplugin_p.h"
-
-//#define QT_SUPPORTEDMIMETYPES_DEBUG
-
-#include "qgstreamerplayerservice_p.h"
-#include <private/qgstutils_p.h>
-
-QMediaService* QGstreamerPlayerServicePlugin::create(const QString &key)
-{
- QGstUtils::initializeGst();
-
- if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
- return new QGstreamerPlayerService;
-
- qWarning() << "Gstreamer service plugin: unsupported key:" << key;
- return 0;
-}
-
-void QGstreamerPlayerServicePlugin::release(QMediaService *service)
-{
- delete service;
-}
-
-QMultimedia::SupportEstimate QGstreamerPlayerServicePlugin::hasSupport(const QString &mimeType,
- const QStringList &codecs) const
-{
- if (m_supportedMimeTypeSet.isEmpty())
- updateSupportedMimeTypes();
-
- return QGstUtils::hasSupport(mimeType, codecs, m_supportedMimeTypeSet);
-}
-
-static bool isDecoderOrDemuxer(GstElementFactory *factory)
-{
- return gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DEMUXER)
- || gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_DECODER);
-}
-
-void QGstreamerPlayerServicePlugin::updateSupportedMimeTypes() const
-{
- m_supportedMimeTypeSet = QGstUtils::supportedMimeTypes(isDecoderOrDemuxer);
-}
-
-QStringList QGstreamerPlayerServicePlugin::supportedMimeTypes() const
-{
- return QStringList();
-}
-
diff --git a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin_p.h b/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin_p.h
deleted file mode 100644
index 8c4e6630c..000000000
--- a/src/multimedia/platform/gstreamer/mediaplayer/qgstreamerplayerserviceplugin_p.h
+++ /dev/null
@@ -1,84 +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 QGSTREAMERPLAYERSERVICEPLUGIN_H
-#define QGSTREAMERPLAYERSERVICEPLUGIN_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 <qmediaserviceproviderplugin.h>
-#include <QtCore/qset.h>
-#include <QtCore/QObject>
-
-QT_BEGIN_NAMESPACE
-
-
-class QGstreamerPlayerServicePlugin
- : public QMediaServiceProviderPlugin
- , public QMediaServiceSupportedFormatsInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
-public:
- QMediaService* create(const QString &key) override;
- void release(QMediaService *service) override;
-
- QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList &codecs) const override;
- QStringList supportedMimeTypes() const override;
-
-private:
- void updateSupportedMimeTypes() const;
-
- mutable QSet<QString> m_supportedMimeTypeSet; //for fast access
-};
-
-QT_END_NAMESPACE
-
-#endif // QGSTREAMERPLAYERSERVICEPLUGIN_H
-
diff --git a/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp b/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp
index fac81e281..9b41815de 100644
--- a/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp
+++ b/src/multimedia/platform/gstreamer/qgstreamerintegration.cpp
@@ -39,6 +39,8 @@
#include "qgstreamerintegration_p.h"
#include "qgstreamerdevicemanager_p.h"
+#include "qgstreamerplayerservice_p.h"
+#include "private/qgstreamerplayerservice_p.h"
QT_BEGIN_NAMESPACE
@@ -59,4 +61,9 @@ QMediaPlatformDeviceManager *QGstreamerIntegration::deviceManager()
return m_manager;
}
+QMediaPlatformPlayerInterface *QGstreamerIntegration::createPlayerInterface()
+{
+ return new QGstreamerPlayerService();
+}
+
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h b/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h
index 97344e873..fabab4e4e 100644
--- a/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h
+++ b/src/multimedia/platform/gstreamer/qgstreamerintegration_p.h
@@ -56,6 +56,7 @@
QT_BEGIN_NAMESPACE
class QGstreamerDeviceManager;
+class QGstreamerPlayerInterface;
class QGstreamerIntegration : public QMediaPlatformIntegration
{
@@ -65,6 +66,8 @@ public:
QMediaPlatformDeviceManager *deviceManager() override;
+ QMediaPlatformPlayerInterface *createPlayerInterface() override;
+
QGstreamerDeviceManager *m_manager = nullptr;
};
diff --git a/src/multimedia/platform/qmediaplatformintegration_p.h b/src/multimedia/platform/qmediaplatformintegration_p.h
index 38627dd93..09c15bf0f 100644
--- a/src/multimedia/platform/qmediaplatformintegration_p.h
+++ b/src/multimedia/platform/qmediaplatformintegration_p.h
@@ -68,7 +68,7 @@ public:
virtual QMediaPlatformDeviceManager *deviceManager() = 0;
virtual QMediaPlatformCaptureInterface *captureInterface() { return nullptr; }
- virtual QMediaPlatformPlayerInterface *playerInterface() { return nullptr; }
+ virtual QMediaPlatformPlayerInterface *createPlayerInterface() { return nullptr; }
};
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/qmediaplatformplayerinterface.cpp b/src/multimedia/platform/qmediaplatformplayerinterface.cpp
index c8e2bcc3a..570c7fd90 100644
--- a/src/multimedia/platform/qmediaplatformplayerinterface.cpp
+++ b/src/multimedia/platform/qmediaplatformplayerinterface.cpp
@@ -42,9 +42,13 @@
QT_BEGIN_NAMESPACE
-QMediaPlatformPlayerInterface::~QMediaPlatformPlayerInterface()
+QMediaPlatformPlayerInterface::QMediaPlatformPlayerInterface()
+ : QMediaService(nullptr)
{
+}
+QMediaPlatformPlayerInterface::~QMediaPlatformPlayerInterface()
+{
}
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/qmediaplatformplayerinterface_p.h b/src/multimedia/platform/qmediaplatformplayerinterface_p.h
index 2fe3e539f..620d65d73 100644
--- a/src/multimedia/platform/qmediaplatformplayerinterface_p.h
+++ b/src/multimedia/platform/qmediaplatformplayerinterface_p.h
@@ -51,27 +51,33 @@
//
#include <qtmultimediaglobal_p.h>
+#include <qmediaservice.h>
QT_BEGIN_NAMESPACE
class QMediaPlayerControl;
-class QMediaDataReaderControl;
+class QMetaDataReaderControl;
class QMediaStreamsControl;
class QMediaVideoProbeControl;
class QMediaAudioProbeControl;
class QVideoRendererControl;
class QVideoWindowControl;
-class Q_MULTIMEDIA_EXPORT QMediaPlatformPlayerInterface
+class Q_MULTIMEDIA_EXPORT QMediaPlatformPlayerInterface : public QMediaService // ### for now, get rid of me
{
public:
+ QMediaPlatformPlayerInterface();
virtual ~QMediaPlatformPlayerInterface();
virtual QMediaPlayerControl *player() = 0;
- virtual QMediaDataReaderControl *dataReader() { return nullptr; }
+ virtual QMetaDataReaderControl *dataReader() { return nullptr; }
+
+ // ### nothing in the frontend uses the stream info currently. Needs implementation in QMediaPlayer
virtual QMediaStreamsControl *streams() { return nullptr; }
virtual QMediaVideoProbeControl *videoProbe() { return nullptr; }
+ virtual void releaseVideoProbe(QMediaVideoProbeControl *) {}
virtual QMediaAudioProbeControl *audioProbe() { return nullptr; }
+ virtual void releaseAudioProbe(QMediaAudioProbeControl *) {}
virtual QVideoRendererControl *createVideoRenderer() = 0;
virtual QVideoWindowControl *createVideoWindow() { return nullptr; };
diff --git a/src/multimedia/platform/windows/player/mfplayerservice.cpp b/src/multimedia/platform/windows/player/mfplayerservice.cpp
index 8ce196a62..3cbcc2aa2 100644
--- a/src/multimedia/platform/windows/player/mfplayerservice.cpp
+++ b/src/multimedia/platform/windows/player/mfplayerservice.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "QUrl.h"
+#include "qurl.h"
#include <QtCore/qdebug.h>
@@ -50,11 +50,7 @@
#include "mfplayersession_p.h"
#include "mfmetadatacontrol_p.h"
-MFPlayerService::MFPlayerService(QObject *parent)
- : QMediaService(parent)
- , m_session(0)
- , m_videoWindowControl(0)
- , m_videoRendererControl(0)
+MFPlayerService::MFPlayerService()
{
m_session = new MFPlayerSession(this);
m_player = new MFPlayerControl(m_session);
@@ -142,6 +138,61 @@ void MFPlayerService::releaseControl(QObject *control)
}
}
+QMediaPlayerControl *MFPlayerService::player()
+{
+ return m_player;
+}
+
+QMetaDataReaderControl *MFPlayerService::dataReader()
+{
+ return m_metaDataControl;
+}
+
+QMediaVideoProbeControl *MFPlayerService::videoProbe()
+{
+ if (m_session) {
+ MFVideoProbeControl *probe = new MFVideoProbeControl(this);
+ m_session->addProbe(probe);
+ return probe;
+ }
+ return 0;
+}
+
+void MFPlayerService::releaseVideoProbe(QMediaVideoProbeControl *probe)
+{
+ MFVideoProbeControl* videoProbe = qobject_cast<MFVideoProbeControl*>(probe);
+ if (m_session)
+ m_session->removeProbe(videoProbe);
+ delete videoProbe;
+}
+
+QMediaAudioProbeControl *MFPlayerService::audioProbe()
+{
+ if (m_session) {
+ MFAudioProbeControl *probe = new MFAudioProbeControl(this);
+ m_session->addProbe(probe);
+ return probe;
+ }
+}
+
+void MFPlayerService::releaseAudioProbe(QMediaAudioProbeControl *probe)
+{
+ MFAudioProbeControl* audioProbe = qobject_cast<MFAudioProbeControl*>(probe);
+ if (m_session)
+ m_session->removeProbe(audioProbe);
+ delete audioProbe;
+}
+
+QVideoRendererControl *MFPlayerService::createVideoRenderer()
+{
+ return m_videoRendererControl;
+}
+
+QVideoWindowControl *MFPlayerService::createVideoWindow()
+{
+ return m_videoWindowControl;
+}
+
MFVideoRendererControl* MFPlayerService::videoRendererControl() const
{
return m_videoRendererControl;
diff --git a/src/multimedia/platform/windows/player/mfplayerservice_p.h b/src/multimedia/platform/windows/player/mfplayerservice_p.h
index 11b34f819..26fd2d8df 100644
--- a/src/multimedia/platform/windows/player/mfplayerservice_p.h
+++ b/src/multimedia/platform/windows/player/mfplayerservice_p.h
@@ -57,6 +57,7 @@
#include "qmediaplayer.h"
#include "qmediaservice.h"
#include "qmediatimerange.h"
+#include <private/qmediaplatformplayerinterface_p.h>
QT_BEGIN_NAMESPACE
class QUrl;
@@ -70,26 +71,37 @@ class MFPlayerControl;
class MFMetaDataControl;
class MFPlayerSession;
-class MFPlayerService : public QMediaService
+class MFPlayerService : public QMediaPlatformPlayerInterface
{
Q_OBJECT
public:
- MFPlayerService(QObject *parent = 0);
+ MFPlayerService();
~MFPlayerService();
- QObject *requestControl(const char *name);
- void releaseControl(QObject *control);
+ QObject *requestControl(const char *name) override;
+ void releaseControl(QObject *control) override;
+
+ QMediaPlayerControl *player() override;
+ QMetaDataReaderControl *dataReader() override;
+ // ### QMediaStreamsControl *streams() override;
+ QMediaVideoProbeControl *videoProbe() override;
+ void releaseVideoProbe(QMediaVideoProbeControl *) override;
+ QMediaAudioProbeControl *audioProbe() override;
+ void releaseAudioProbe(QMediaAudioProbeControl *) override;
+
+ virtual QVideoRendererControl *createVideoRenderer() override;
+ virtual QVideoWindowControl *createVideoWindow() override;
MFVideoRendererControl* videoRendererControl() const;
MFEvrVideoWindowControl* videoWindowControl() const;
MFMetaDataControl* metaDataControl() const;
private:
- MFPlayerSession *m_session;
- MFVideoRendererControl *m_videoRendererControl;
- MFEvrVideoWindowControl *m_videoWindowControl;
- MFPlayerControl *m_player;
- MFMetaDataControl *m_metaDataControl;
+ MFPlayerSession *m_session = nullptr;
+ MFVideoRendererControl *m_videoRendererControl = nullptr;
+ MFEvrVideoWindowControl *m_videoWindowControl = nullptr;
+ MFPlayerControl *m_player = nullptr;
+ MFMetaDataControl *m_metaDataControl = nullptr;
};
#endif
diff --git a/src/multimedia/platform/windows/qwindowsintegration.cpp b/src/multimedia/platform/windows/qwindowsintegration.cpp
index 0f4ccaae0..2787aeb7f 100644
--- a/src/multimedia/platform/windows/qwindowsintegration.cpp
+++ b/src/multimedia/platform/windows/qwindowsintegration.cpp
@@ -39,16 +39,30 @@
#include "qwindowsintegration_p.h"
#include "qwindowsdevicemanager_p.h"
+#include <private/mfplayerservice_p.h>
QT_BEGIN_NAMESPACE
+static int g_refCount = 0;
+
QWindowsIntegration::QWindowsIntegration()
{
+ g_refCount++;
+ if (g_refCount == 1) {
+ CoInitialize(NULL);
+ MFStartup(MF_VERSION);
+ }
}
QWindowsIntegration::~QWindowsIntegration()
{
+ g_refCount--;
delete m_manager;
+ if (g_refCount == 0) {
+ // ### This currently crashes on exit
+// MFShutdown();
+// CoUninitialize();
+ }
}
QMediaPlatformDeviceManager *QWindowsIntegration::deviceManager()
@@ -58,4 +72,9 @@ QMediaPlatformDeviceManager *QWindowsIntegration::deviceManager()
return m_manager;
}
+QMediaPlatformPlayerInterface *QWindowsIntegration::createPlayerInterface()
+{
+ return new MFPlayerService;
+}
+
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/windows/qwindowsintegration_p.h b/src/multimedia/platform/windows/qwindowsintegration_p.h
index 557ed2a22..cbd0e3c75 100644
--- a/src/multimedia/platform/windows/qwindowsintegration_p.h
+++ b/src/multimedia/platform/windows/qwindowsintegration_p.h
@@ -63,8 +63,13 @@ public:
QWindowsIntegration();
~QWindowsIntegration();
+ void addRefCount();
+ void releaseRefCount();
+
QMediaPlatformDeviceManager *deviceManager() override;
+ QMediaPlatformPlayerInterface *createPlayerInterface() override;
+
QWindowsDeviceManager *m_manager = nullptr;
};
diff --git a/src/multimedia/platform/windows/windows.pri b/src/multimedia/platform/windows/windows.pri
index 579ea123b..701267b64 100644
--- a/src/multimedia/platform/windows/windows.pri
+++ b/src/multimedia/platform/windows/windows.pri
@@ -7,14 +7,12 @@ win32:!qtHaveModule(opengl) {
INCLUDEPATH += .
HEADERS += \
- $$PWD/wmfserviceplugin_p.h \
$$PWD/mfstream_p.h \
$$PWD/sourceresolver_p.h \
$$PWD/qwindowsdevicemanager_p.h \
$$PWD/qwindowsintegration_p.h
SOURCES += \
- $$PWD/wmfserviceplugin.cpp \
$$PWD/mfstream.cpp \
$$PWD/sourceresolver.cpp \
$$PWD/qwindowsdevicemanager.cpp \
diff --git a/src/multimedia/platform/windows/wmfserviceplugin.cpp b/src/multimedia/platform/windows/wmfserviceplugin.cpp
deleted file mode 100644
index 0eb20e482..000000000
--- a/src/multimedia/platform/windows/wmfserviceplugin.cpp
+++ /dev/null
@@ -1,103 +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 <QtCore/qstring.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/QFile>
-
-#include "wmfserviceplugin_p.h"
-#include "mfplayerservice_p.h"
-
-#include <mfapi.h>
-
-namespace
-{
-static int g_refCount = 0;
-void addRefCount()
-{
- g_refCount++;
- if (g_refCount == 1) {
- CoInitialize(NULL);
- MFStartup(MF_VERSION);
- }
-}
-
-void releaseRefCount()
-{
- g_refCount--;
- if (g_refCount == 0) {
- MFShutdown();
- CoUninitialize();
- }
-}
-
-}
-
-QMediaService* WMFServicePlugin::create(QString const& key)
-{
- if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) {
- addRefCount();
- return new MFPlayerService;
- }
-
- //qDebug() << "unsupported key:" << key;
- return 0;
-}
-
-void WMFServicePlugin::release(QMediaService *service)
-{
- delete service;
- releaseRefCount();
-}
-
-QByteArray WMFServicePlugin::defaultDevice(const QByteArray &) const
-{
- return QByteArray();
-}
-
-QList<QByteArray> WMFServicePlugin::devices(const QByteArray &) const
-{
- return QList<QByteArray>();
-}
-
-QString WMFServicePlugin::deviceDescription(const QByteArray &, const QByteArray &)
-{
- return QString();
-}
-
diff --git a/src/multimedia/platform/windows/wmfserviceplugin_p.h b/src/multimedia/platform/windows/wmfserviceplugin_p.h
deleted file mode 100644
index c0ff90ce9..000000000
--- a/src/multimedia/platform/windows/wmfserviceplugin_p.h
+++ /dev/null
@@ -1,75 +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 WMFSERVICEPLUGIN_H
-#define WMFSERVICEPLUGIN_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 <QtMultimedia/private/qtmultimediaglobal_p.h>
-#include "qmediaserviceproviderplugin.h"
-
-QT_USE_NAMESPACE
-
-class WMFServicePlugin
- : public QMediaServiceProviderPlugin
- , public QMediaServiceSupportedDevicesInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
-
-public:
- QMediaService* create(QString const& key);
- void release(QMediaService *service);
-
- QByteArray defaultDevice(const QByteArray &service) const;
- QList<QByteArray> devices(const QByteArray &service) const;
- QString deviceDescription(const QByteArray &service, const QByteArray &device);
-};
-
-#endif // WMFSERVICEPLUGIN_H
diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp
index fcf044cf7..b54912731 100644
--- a/src/multimedia/playback/qmediaplayer.cpp
+++ b/src/multimedia/playback/qmediaplayer.cpp
@@ -44,7 +44,8 @@
#include "qmediasource_p.h"
#include <qmediaservice.h>
#include <qmediaplayercontrol.h>
-#include <qmediaserviceprovider_p.h>
+#include <private/qmediaplatformplayerinterface_p.h>
+#include <private/qmediaplatformintegration_p.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qmetaobject.h>
@@ -99,7 +100,7 @@ class QMediaPlayerPrivate : public QMediaSourcePrivate
Q_DECLARE_NON_CONST_PUBLIC(QMediaPlayer)
public:
- QMediaServiceProvider *provider = nullptr;
+ QMediaPlatformPlayerInterface *playerInterface = nullptr;
QMediaPlayerControl* control = nullptr;
QString errorString;
@@ -249,13 +250,6 @@ void QMediaPlayerPrivate::setMedia(const QUrl &media, QIODevice *stream)
qrcFile.swap(file); // Cleans up any previous file
}
-static QMediaService *playerService()
-{
- QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
- return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER);
-}
-
-
/*!
Construct a QMediaPlayer instance
parented to \a parent and with \a flags.
@@ -264,44 +258,44 @@ static QMediaService *playerService()
QMediaPlayer::QMediaPlayer(QObject *parent):
QMediaSource(*new QMediaPlayerPrivate,
parent,
- playerService())
+ QMediaPlatformIntegration::instance()->createPlayerInterface())
{
Q_D(QMediaPlayer);
- d->provider = QMediaServiceProvider::defaultServiceProvider();
- if (d->service == nullptr) {
- d->error = ServiceMissingError;
- } else {
- d->control = qobject_cast<QMediaPlayerControl*>(d->service->requestControl(QMediaPlayerControl_iid));
- if (d->control != nullptr) {
- connect(d->control, SIGNAL(mediaChanged(QUrl)), SLOT(_q_handleMediaChanged(QUrl)));
- connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State)));
- connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
- SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus)));
- connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString)));
-
- connect(d->control, &QMediaPlayerControl::durationChanged, this, &QMediaPlayer::durationChanged);
- connect(d->control, &QMediaPlayerControl::positionChanged, this, &QMediaPlayer::positionChanged);
- connect(d->control, &QMediaPlayerControl::audioAvailableChanged, this, &QMediaPlayer::audioAvailableChanged);
- connect(d->control, &QMediaPlayerControl::videoAvailableChanged, this, &QMediaPlayer::videoAvailableChanged);
- connect(d->control, &QMediaPlayerControl::volumeChanged, this, &QMediaPlayer::volumeChanged);
- connect(d->control, &QMediaPlayerControl::mutedChanged, this, &QMediaPlayer::mutedChanged);
- connect(d->control, &QMediaPlayerControl::seekableChanged, this, &QMediaPlayer::seekableChanged);
- connect(d->control, &QMediaPlayerControl::playbackRateChanged, this, &QMediaPlayer::playbackRateChanged);
- connect(d->control, &QMediaPlayerControl::bufferStatusChanged, this, &QMediaPlayer::bufferStatusChanged);
-
- d->state = d->control->state();
- d->status = d->control->mediaStatus();
-
- if (d->state == PlayingState)
- addPropertyWatch("position");
-
- if (d->status == StalledMedia || d->status == BufferingMedia)
- addPropertyWatch("bufferStatus");
-
- d->hasStreamPlaybackFeature = d->control->streamPlaybackSupported();
- }
+ d->playerInterface = static_cast<QMediaPlatformPlayerInterface *>(service());
+ if (!d->playerInterface) {
+ qWarning() << "QPlatformMediaPlayerInterface not implemented!";
+ return;
}
+
+ d->control = d->playerInterface->player();
+ Q_ASSERT(d->control);
+ connect(d->control, SIGNAL(mediaChanged(QUrl)), SLOT(_q_handleMediaChanged(QUrl)));
+ connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State)));
+ connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
+ SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus)));
+ connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString)));
+
+ connect(d->control, &QMediaPlayerControl::durationChanged, this, &QMediaPlayer::durationChanged);
+ connect(d->control, &QMediaPlayerControl::positionChanged, this, &QMediaPlayer::positionChanged);
+ connect(d->control, &QMediaPlayerControl::audioAvailableChanged, this, &QMediaPlayer::audioAvailableChanged);
+ connect(d->control, &QMediaPlayerControl::videoAvailableChanged, this, &QMediaPlayer::videoAvailableChanged);
+ connect(d->control, &QMediaPlayerControl::volumeChanged, this, &QMediaPlayer::volumeChanged);
+ connect(d->control, &QMediaPlayerControl::mutedChanged, this, &QMediaPlayer::mutedChanged);
+ connect(d->control, &QMediaPlayerControl::seekableChanged, this, &QMediaPlayer::seekableChanged);
+ connect(d->control, &QMediaPlayerControl::playbackRateChanged, this, &QMediaPlayer::playbackRateChanged);
+ connect(d->control, &QMediaPlayerControl::bufferStatusChanged, this, &QMediaPlayer::bufferStatusChanged);
+
+ d->state = d->control->state();
+ d->status = d->control->mediaStatus();
+
+ if (d->state == PlayingState)
+ addPropertyWatch("position");
+
+ if (d->status == StalledMedia || d->status == BufferingMedia)
+ addPropertyWatch("bufferStatus");
+
+ d->hasStreamPlaybackFeature = d->control->streamPlaybackSupported();
}
@@ -317,12 +311,7 @@ QMediaPlayer::~QMediaPlayer()
// when a receiver is already destroyed.
disconnect();
- if (d->service) {
- if (d->control)
- d->service->releaseControl(d->control);
-
- d->provider->releaseService(d->service);
- }
+ delete d->playerInterface;
}
QUrl QMediaPlayer::media() const
diff --git a/src/multimedia/qmediaserviceprovider.cpp b/src/multimedia/qmediaserviceprovider.cpp
index fe7628fa0..35bf6ff38 100644
--- a/src/multimedia/qmediaserviceprovider.cpp
+++ b/src/multimedia/qmediaserviceprovider.cpp
@@ -50,13 +50,9 @@
#include "qvideodeviceselectorcontrol.h"
#if QT_CONFIG(gstreamer)
-#include <private/qgstreamerplayerserviceplugin_p.h>
#include <private/qgstreamercaptureserviceplugin_p.h>
-#elif defined(Q_OS_WIN)
-#include <private/wmfserviceplugin_p.h>
#elif defined(Q_OS_DARWIN)
#include <private/avfcameraserviceplugin_p.h>
-#include <private/avfmediaplayerserviceplugin_p.h>
#elif defined(Q_OS_ANDROID)
#include <private/qandroidmediaserviceplugin_p.h>
#elif defined(Q_OS_QNX)
@@ -82,14 +78,10 @@ class Loader
public:
QObject *instance(const QString &key) {
#if QT_CONFIG(gstreamer)
- GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, QGstreamerPlayerServicePlugin)
GET_PLUGIN(Q_MEDIASERVICE_CAMERA, QGstreamerCaptureServicePlugin)
GET_PLUGIN(Q_MEDIASERVICE_AUDIOSOURCE, QGstreamerCaptureServicePlugin)
-#elif defined(Q_OS_WIN)
- GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, WMFServicePlugin)
#elif defined(Q_OS_DARWIN)
GET_PLUGIN(Q_MEDIASERVICE_CAMERA, AVFServicePlugin)
- GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, AVFMediaPlayerServicePlugin)
#elif defined(Q_OS_ANDROID)
GET_PLUGIN(Q_MEDIASERVICE_MEDIAPLAYER, QAndroidMediaServicePlugin)
GET_PLUGIN(Q_MEDIASERVICE_CAMERA, QAndroidMediaServicePlugin)