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
@@ -58,6 +58,7 @@
|
||||
#include <qcameracapturedestinationcontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qcamera.h>
|
||||
#include <qcamerainfo.h>
|
||||
#include <qcameraimagecapture.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
#include <private/qmediaserviceprovider_p.h>
|
||||
@@ -82,7 +83,10 @@ public slots:
|
||||
private slots:
|
||||
void testAvailableDevices();
|
||||
void testDeviceDescription();
|
||||
void testCameraInfo();
|
||||
void testCtorWithDevice();
|
||||
void testCtorWithCameraInfo();
|
||||
void testCtorWithPosition();
|
||||
|
||||
void testCameraStates();
|
||||
void testCaptureMode();
|
||||
@@ -126,6 +130,23 @@ void tst_QCameraBackend::testDeviceDescription()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QCameraBackend::testCameraInfo()
|
||||
{
|
||||
int deviceCount = QMediaServiceProvider::defaultServiceProvider()->devices(QByteArray(Q_MEDIASERVICE_CAMERA)).count();
|
||||
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
|
||||
QCOMPARE(cameras.count(), deviceCount);
|
||||
if (cameras.isEmpty()) {
|
||||
QVERIFY(QCameraInfo::defaultCamera().isNull());
|
||||
QSKIP("Camera selection is not supported");
|
||||
}
|
||||
|
||||
foreach (const QCameraInfo &info, cameras) {
|
||||
QVERIFY(!info.deviceName().isEmpty());
|
||||
QVERIFY(!info.description().isEmpty());
|
||||
QVERIFY(info.orientation() % 90 == 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QCameraBackend::testCtorWithDevice()
|
||||
{
|
||||
if (QCamera::availableDevices().isEmpty())
|
||||
@@ -142,6 +163,58 @@ void tst_QCameraBackend::testCtorWithDevice()
|
||||
delete camera;
|
||||
}
|
||||
|
||||
void tst_QCameraBackend::testCtorWithCameraInfo()
|
||||
{
|
||||
if (QCameraInfo::availableCameras().isEmpty())
|
||||
QSKIP("Camera selection not supported");
|
||||
|
||||
{
|
||||
QCameraInfo info = QCameraInfo::defaultCamera();
|
||||
QCamera camera(info);
|
||||
QCOMPARE(camera.error(), QCamera::NoError);
|
||||
QCOMPARE(QCameraInfo(camera), info);
|
||||
}
|
||||
{
|
||||
QCameraInfo info = QCameraInfo::availableCameras().first();
|
||||
QCamera camera(info);
|
||||
QCOMPARE(camera.error(), QCamera::NoError);
|
||||
QCOMPARE(QCameraInfo(camera), info);
|
||||
}
|
||||
{
|
||||
// loading an invalid CameraInfo should fail
|
||||
QCamera *camera = new QCamera(QCameraInfo());
|
||||
QCOMPARE(camera->error(), QCamera::ServiceMissingError);
|
||||
QVERIFY(QCameraInfo(*camera).isNull());
|
||||
delete camera;
|
||||
}
|
||||
{
|
||||
// loading non existing camera should fail
|
||||
QCamera camera(QCameraInfo(QUuid::createUuid().toByteArray()));
|
||||
QCOMPARE(camera.error(), QCamera::ServiceMissingError);
|
||||
QVERIFY(QCameraInfo(camera).isNull());
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QCameraBackend::testCtorWithPosition()
|
||||
{
|
||||
{
|
||||
QCamera camera(QCamera::UnspecifiedPosition);
|
||||
QCOMPARE(camera.error(), QCamera::NoError);
|
||||
}
|
||||
{
|
||||
QCamera camera(QCamera::FrontFace);
|
||||
// even if no camera is available at this position, it should not fail
|
||||
// and load the default camera
|
||||
QCOMPARE(camera.error(), QCamera::NoError);
|
||||
}
|
||||
{
|
||||
QCamera camera(QCamera::BackFace);
|
||||
// even if no camera is available at this position, it should not fail
|
||||
// and load the default camera
|
||||
QCOMPARE(camera.error(), QCamera::NoError);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QCameraBackend::testCameraStates()
|
||||
{
|
||||
QCamera camera;
|
||||
|
||||
Reference in New Issue
Block a user