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:
Jonas Rabbe
2012-03-14 13:02:32 +10:00
committed by Qt by Nokia
parent 61c09d1614
commit a8ba6e3c7f
61 changed files with 630 additions and 745 deletions

View File

@@ -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()