New QCameraInfo class.
The class allows to get the list of available cameras on the system as well as getting some static information about them such as their unique ID, display name, physical position and sensor orientation. This makes QCamera::availableDevices() and QCamera::deviceDescription() obsolete. This patch contains the API, documentation and auto-tests but not the actual implementation by each backend (except for retrieving the default camera device). [ChangeLog][QtMultimedia] Added new QCameraInfo class [ChangeLog][QtMultimedia] QCamera: availableDevices() and deviceDescription() are deprecated, use QCameraInfo instead Change-Id: I64fd65729ab26a789468979ed5444ee90bb82cd0 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
d964388b38
commit
b28ee24628
@@ -44,17 +44,22 @@
|
||||
#include "../mockservice.h"
|
||||
|
||||
class MockServicePlugin3 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
public QMediaServiceSupportedDevicesInterface,
|
||||
public QMediaServiceDefaultDeviceInterface,
|
||||
public QMediaServiceCameraInfoInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
|
||||
Q_INTERFACES(QMediaServiceCameraInfoInterface)
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin3.json")
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() <<
|
||||
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) <<
|
||||
QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE);
|
||||
QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE) <<
|
||||
QLatin1String(Q_MEDIASERVICE_CAMERA);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
@@ -70,12 +75,26 @@ public:
|
||||
delete service;
|
||||
}
|
||||
|
||||
QByteArray defaultDevice(const QByteArray &service) const
|
||||
{
|
||||
if (service == Q_MEDIASERVICE_AUDIOSOURCE)
|
||||
return "audiosource1";
|
||||
|
||||
if (service == Q_MEDIASERVICE_CAMERA)
|
||||
return "frontcamera";
|
||||
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const
|
||||
{
|
||||
QList<QByteArray> res;
|
||||
if (service == QByteArray(Q_MEDIASERVICE_AUDIOSOURCE))
|
||||
if (service == Q_MEDIASERVICE_AUDIOSOURCE)
|
||||
res << "audiosource1" << "audiosource2";
|
||||
|
||||
if (service == Q_MEDIASERVICE_CAMERA)
|
||||
res << "frontcamera";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -86,6 +105,22 @@ public:
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
|
||||
QCamera::Position cameraPosition(const QByteArray &device) const
|
||||
{
|
||||
if (device == "frontcamera")
|
||||
return QCamera::FrontFace;
|
||||
|
||||
return QCamera::UnspecifiedPosition;
|
||||
}
|
||||
|
||||
int cameraOrientation(const QByteArray &device) const
|
||||
{
|
||||
if (device == "frontcamera")
|
||||
return 270;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
#include "mockserviceplugin3.moc"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"Keys": ["mockserviceplugin3"],
|
||||
"Services": ["org.qt-project.qt.mediaplayer", "org.qt-project.qt.audiosource"]
|
||||
"Services": ["org.qt-project.qt.mediaplayer", "org.qt-project.qt.audiosource", "org.qt-project.qt.camera"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user