Updated plugins to use new plugin architecture
Changed QMediaPluginLoader to use QFactoryLoader instead of QPluginLoader and used metadata to get keys. Removed QAudioPluginLoader and changed audio classes to use instead use QMediaPluginLoader. The plugins must include the Q_PLUGIN_METADATA macro, and no longer use the Q_PLUGIN_EXPORT/Q_PLUGIN_EXPORT2 macros. A json file has been added for each plugin which can contain metadata which is available to the plugin loader before the plugin is actually loaded, and is used to read the keys for the plugin, e.g. supported services. QFactoryInterface will be deprecated and has been removed from all plugins. Change-Id: I035b82f9c9c65717bebf704d560ea8f891df21da Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
@@ -122,7 +122,6 @@ void tst_QMediaPlaylist::initTestCase()
|
||||
content2 = QMediaContent(QUrl(QLatin1String("file:///2")));
|
||||
content3 = QMediaContent(QUrl(QLatin1String("file:///3")));
|
||||
|
||||
QMediaPluginLoader::setStaticPlugins(QLatin1String("playlistformats"), QObjectList() << new QM3uPlaylistPlugin(this));
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::cleanup()
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
void tst_QMediaPluginLoader::initTestCase()
|
||||
{
|
||||
loader = new QMediaPluginLoader(QMediaServiceProviderFactoryInterface_iid,
|
||||
QLatin1String("/mediaservice"),
|
||||
QLatin1String("mediaservice"),
|
||||
Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
|
||||
59
tests/auto/unit/qmediaserviceprovider/mockservice.h
Normal file
59
tests/auto/unit/qmediaserviceprovider/mockservice.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MOCKSERVICE_H
|
||||
#define MOCKSERVICE_H
|
||||
|
||||
#include <qmediaservice.h>
|
||||
|
||||
class MockMediaService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockMediaService(const QString& name, QObject *parent = 0) : QMediaService(parent)
|
||||
{ setObjectName(name); }
|
||||
~MockMediaService() {}
|
||||
|
||||
QMediaControl* requestControl(const char *) {return 0;}
|
||||
void releaseControl(QMediaControl *) {}
|
||||
};
|
||||
|
||||
#endif // MOCKSERVICE_H
|
||||
@@ -0,0 +1,108 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qmediaserviceproviderplugin.h>
|
||||
#include <qmediaservice.h>
|
||||
#include "../mockservice.h"
|
||||
|
||||
class MockServicePlugin1 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
Q_PLUGIN_METADATA(IID "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" FILE "mockserviceplugin1.json")
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() <<
|
||||
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin1");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
if (codecs.contains(QLatin1String("mpeg4")))
|
||||
return QtMultimedia::NotSupported;
|
||||
|
||||
if (mimeType == "audio/ogg") {
|
||||
return QtMultimedia::ProbablySupported;
|
||||
}
|
||||
|
||||
return QtMultimedia::MaybeSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList("audio/ogg");
|
||||
}
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const
|
||||
{
|
||||
Q_UNUSED(service);
|
||||
QList<QByteArray> res;
|
||||
return res;
|
||||
}
|
||||
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
if (devices(service).contains(device))
|
||||
return QString(device)+" description";
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
#include "mockserviceplugin1.moc"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["com.nokia.qt.mediaplayer"]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
load(qt_module)
|
||||
|
||||
TARGET = mockserviceplugin1
|
||||
QT += multimedia-private
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
PLUGIN_TYPE=mediaservice
|
||||
DESTDIR = ../$${PLUGIN_TYPE}
|
||||
|
||||
load(qt_plugin)
|
||||
|
||||
HEADERS += ../mockservice.h
|
||||
SOURCES += mockserviceplugin1.cpp
|
||||
OTHER_FILES += mockserviceplugin1.json
|
||||
|
||||
target.path += $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
|
||||
INSTALLS += target
|
||||
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qmediaserviceproviderplugin.h>
|
||||
#include <qmediaservice.h>
|
||||
#include "../mockservice.h"
|
||||
|
||||
class MockServicePlugin2 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceFeaturesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceFeaturesInterface)
|
||||
Q_PLUGIN_METADATA(IID "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" FILE "mockserviceplugin2.json")
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)
|
||||
<< QLatin1String(Q_MEDIASERVICE_RADIO);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin2");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
Q_UNUSED(codecs);
|
||||
|
||||
if (mimeType == "audio/wav")
|
||||
return QtMultimedia::PreferredService;
|
||||
|
||||
return QtMultimedia::NotSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList("audio/wav");
|
||||
}
|
||||
|
||||
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
|
||||
{
|
||||
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return QMediaServiceProviderHint::LowLatencyPlayback;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
#include "mockserviceplugin2.moc"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["com.nokia.qt.mediaplayer", "com.nokia.qt.radio"]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
load(qt_module)
|
||||
|
||||
TARGET = mockserviceplugin2
|
||||
QT += multimedia-private
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
PLUGIN_TYPE=mediaservice
|
||||
DESTDIR = ../$${PLUGIN_TYPE}
|
||||
|
||||
load(qt_plugin)
|
||||
|
||||
HEADERS += ../mockservice.h
|
||||
SOURCES += mockserviceplugin2.cpp
|
||||
OTHER_FILES += mockserviceplugin2.json
|
||||
|
||||
target.path += $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
|
||||
INSTALLS += target
|
||||
@@ -0,0 +1,92 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qmediaserviceproviderplugin.h>
|
||||
#include <qmediaservice.h>
|
||||
#include "../mockservice.h"
|
||||
|
||||
class MockServicePlugin3 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
Q_PLUGIN_METADATA(IID "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" FILE "mockserviceplugin3.json")
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() <<
|
||||
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) <<
|
||||
QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin3");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const
|
||||
{
|
||||
QList<QByteArray> res;
|
||||
if (service == QByteArray(Q_MEDIASERVICE_AUDIOSOURCE))
|
||||
res << "audiosource1" << "audiosource2";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
if (devices(service).contains(device))
|
||||
return QString(device)+" description";
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
#include "mockserviceplugin3.moc"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["com.nokia.qt.mediaplayer", "com.nokia.qt.audiosource"]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
load(qt_module)
|
||||
|
||||
TARGET = mockserviceplugin3
|
||||
QT += multimedia-private
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
PLUGIN_TYPE=mediaservice
|
||||
DESTDIR = ../$${PLUGIN_TYPE}
|
||||
|
||||
load(qt_plugin)
|
||||
|
||||
HEADERS += ../mockservice.h
|
||||
SOURCES += mockserviceplugin3.cpp
|
||||
OTHER_FILES += mockserviceplugin3.json
|
||||
|
||||
target.path += $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
|
||||
INSTALLS += target
|
||||
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qmediaserviceproviderplugin.h>
|
||||
#include <qmediaservice.h>
|
||||
#include "../mockservice.h"
|
||||
|
||||
class MockServicePlugin4 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceFeaturesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceFeaturesInterface)
|
||||
Q_PLUGIN_METADATA(IID "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" FILE "mockserviceplugin4.json")
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin4");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
if (codecs.contains(QLatin1String("jpeg2000")))
|
||||
return QtMultimedia::NotSupported;
|
||||
|
||||
if (supportedMimeTypes().contains(mimeType))
|
||||
return QtMultimedia::ProbablySupported;
|
||||
|
||||
return QtMultimedia::MaybeSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList() << "video/mp4" << "video/quicktime";
|
||||
}
|
||||
|
||||
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
|
||||
{
|
||||
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return QMediaServiceProviderHint::StreamPlayback;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
#include "mockserviceplugin4.moc"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["com.nokia.qt.mediaplayer"]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
load(qt_module)
|
||||
|
||||
TARGET = mockserviceplugin4
|
||||
QT += multimedia-private
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
PLUGIN_TYPE=mediaservice
|
||||
DESTDIR = ../$${PLUGIN_TYPE}
|
||||
|
||||
load(qt_plugin)
|
||||
|
||||
HEADERS += ../mockservice.h
|
||||
SOURCES += mockserviceplugin4.cpp
|
||||
OTHER_FILES += mockserviceplugin4.json
|
||||
|
||||
target.path += $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
|
||||
INSTALLS += target
|
||||
@@ -1,8 +1,13 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaserviceprovider
|
||||
TEMPLATE = subdirs
|
||||
CONFIG += ORDERED
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
SUBDIRS += \
|
||||
test \
|
||||
mockserviceplugin1 \
|
||||
mockserviceplugin2 \
|
||||
mockserviceplugin3 \
|
||||
mockserviceplugin4
|
||||
|
||||
SOURCES += tst_qmediaserviceprovider.cpp
|
||||
# no special install rule for subdir
|
||||
INSTALLS =
|
||||
|
||||
|
||||
16
tests/auto/unit/qmediaserviceprovider/test/test.pro
Normal file
16
tests/auto/unit/qmediaserviceprovider/test/test.pro
Normal file
@@ -0,0 +1,16 @@
|
||||
CONFIG += testcase
|
||||
TARGET = ../tst_qmediaserviceprovider
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += ../tst_qmediaserviceprovider.cpp
|
||||
|
||||
win32 {
|
||||
CONFIG(debug, debug|release) {
|
||||
TARGET = ../../debug/tst_qmediaserviceprovider
|
||||
} else {
|
||||
TARGET = ../../release/tst_qmediaserviceprovider
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,226 +54,6 @@
|
||||
#include <qaudiorecorder.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class MockMediaService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockMediaService(const QString& name, QObject *parent = 0) : QMediaService(parent)
|
||||
{ setObjectName(name); }
|
||||
~MockMediaService() {}
|
||||
|
||||
QMediaControl* requestControl(const char *) {return 0;}
|
||||
void releaseControl(QMediaControl *) {}
|
||||
};
|
||||
|
||||
class MockServicePlugin1 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() <<
|
||||
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin1");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
if (codecs.contains(QLatin1String("mpeg4")))
|
||||
return QtMultimedia::NotSupported;
|
||||
|
||||
if (mimeType == "audio/ogg") {
|
||||
return QtMultimedia::ProbablySupported;
|
||||
}
|
||||
|
||||
return QtMultimedia::MaybeSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList("audio/ogg");
|
||||
}
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const
|
||||
{
|
||||
Q_UNUSED(service);
|
||||
QList<QByteArray> res;
|
||||
return res;
|
||||
}
|
||||
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
if (devices(service).contains(device))
|
||||
return QString(device)+" description";
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
class MockServicePlugin2 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceFeaturesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceFeaturesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)
|
||||
<< QLatin1String(Q_MEDIASERVICE_RADIO);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin2");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
Q_UNUSED(codecs);
|
||||
|
||||
if (mimeType == "audio/wav")
|
||||
return QtMultimedia::PreferredService;
|
||||
|
||||
return QtMultimedia::NotSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList("audio/wav");
|
||||
}
|
||||
|
||||
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
|
||||
{
|
||||
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return QMediaServiceProviderHint::LowLatencyPlayback;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class MockServicePlugin3 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() <<
|
||||
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) <<
|
||||
QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin3");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const
|
||||
{
|
||||
QList<QByteArray> res;
|
||||
if (service == QByteArray(Q_MEDIASERVICE_AUDIOSOURCE))
|
||||
res << "audiosource1" << "audiosource2";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
if (devices(service).contains(device))
|
||||
return QString(device)+" description";
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
class MockServicePlugin4 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceFeaturesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceFeaturesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin4");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
if (codecs.contains(QLatin1String("jpeg2000")))
|
||||
return QtMultimedia::NotSupported;
|
||||
|
||||
if (supportedMimeTypes().contains(mimeType))
|
||||
return QtMultimedia::ProbablySupported;
|
||||
|
||||
return QtMultimedia::MaybeSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList() << "video/mp4" << "video/quicktime";
|
||||
}
|
||||
|
||||
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
|
||||
{
|
||||
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return QMediaServiceProviderHint::StreamPlayback;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MockMediaServiceProvider : public QMediaServiceProvider
|
||||
{
|
||||
@@ -310,12 +90,8 @@ private:
|
||||
|
||||
void tst_QMediaServiceProvider::initTestCase()
|
||||
{
|
||||
plugins << new MockServicePlugin1;
|
||||
plugins << new MockServicePlugin2;
|
||||
plugins << new MockServicePlugin3;
|
||||
plugins << new MockServicePlugin4;
|
||||
|
||||
QMediaPluginLoader::setStaticPlugins(QLatin1String("mediaservice"), plugins);
|
||||
// QMediaPluginLoader::setStaticPlugins(QLatin1String("mediaservice"), plugins);
|
||||
QCoreApplication::setLibraryPaths(QStringList() << QCoreApplication::applicationDirPath());
|
||||
}
|
||||
|
||||
void tst_QMediaServiceProvider::testDefaultProviderAvailable()
|
||||
|
||||
Reference in New Issue
Block a user