summaryrefslogtreecommitdiffstats
path: root/tests/auto/unit/qmultimedia_common
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2014-01-22 16:18:42 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-28 14:10:00 +0100
commitb28ee24628f77fced393cacc45500be6761e4497 (patch)
tree811173f8a2caf84e0fa386010283ccfd32c6ad0d /tests/auto/unit/qmultimedia_common
parentd964388b38ec4762e315d86aacb779604bcdca1b (diff)
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>
Diffstat (limited to 'tests/auto/unit/qmultimedia_common')
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamera.pri2
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h85
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraservice.h12
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h36
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h99
5 files changed, 234 insertions, 0 deletions
diff --git a/tests/auto/unit/qmultimedia_common/mockcamera.pri b/tests/auto/unit/qmultimedia_common/mockcamera.pri
index 22a9dc155..c12ac3c62 100644
--- a/tests/auto/unit/qmultimedia_common/mockcamera.pri
+++ b/tests/auto/unit/qmultimedia_common/mockcamera.pri
@@ -17,6 +17,8 @@ HEADERS *= \
../qmultimedia_common/mockcameracapturebuffercontrol.h \
../qmultimedia_common/mockimageencodercontrol.h \
../qmultimedia_common/mockcameracontrol.h \
+ ../qmultimedia_common/mockvideodeviceselectorcontrol.h \
+ ../qmultimedia_common/mockcamerainfocontrol.h
include(mockvideo.pri)
diff --git a/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h b/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h
new file mode 100644
index 000000000..65b29d48e
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKCAMERAINFOCONTROL_H
+#define MOCKCAMERAINFOCONTROL_H
+
+#include <qcamerainfocontrol.h>
+
+class MockCameraInfoControl : public QCameraInfoControl
+{
+ Q_OBJECT
+public:
+ MockCameraInfoControl(QObject *parent)
+ : QCameraInfoControl(parent)
+ {
+ }
+
+ ~MockCameraInfoControl() { }
+
+ QCamera::Position cameraPosition(const QString &deviceName) const
+ {
+ return position(deviceName.toLatin1());
+ }
+
+ int cameraOrientation(const QString &deviceName) const
+ {
+ return orientation(deviceName.toLatin1());
+ }
+
+ static QCamera::Position position(const QByteArray &camera)
+ {
+ if (camera == "backcamera")
+ return QCamera::BackFace;
+ else
+ return QCamera::UnspecifiedPosition;
+ }
+
+ static int orientation(const QByteArray &camera)
+ {
+ if (camera == "backcamera")
+ return 90;
+ else
+ return 0;
+ }
+};
+
+#endif // MOCKCAMERAINFOCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraservice.h b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
index 633b28488..f12b0eab0 100644
--- a/tests/auto/unit/qmultimedia_common/mockcameraservice.h
+++ b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
@@ -57,6 +57,8 @@
#include "../qmultimedia_common/mockvideosurface.h"
#include "../qmultimedia_common/mockvideorenderercontrol.h"
#include "../qmultimedia_common/mockvideowindowcontrol.h"
+#include "../qmultimedia_common/mockvideodeviceselectorcontrol.h"
+#include "../qmultimedia_common/mockcamerainfocontrol.h"
class MockSimpleCameraService : public QMediaService
{
@@ -105,6 +107,8 @@ public:
mockImageEncoderControl = new MockImageEncoderControl(this);
rendererControl = new MockVideoRendererControl(this);
windowControl = new MockVideoWindowControl(this);
+ mockVideoDeviceSelectorControl = new MockVideoDeviceSelectorControl(this);
+ mockCameraInfoControl = new MockCameraInfoControl(this);
rendererRef = 0;
windowRef = 0;
}
@@ -148,6 +152,12 @@ public:
if (qstrcmp(iid, QImageEncoderControl_iid) == 0)
return mockImageEncoderControl;
+ if (qstrcmp(iid, QVideoDeviceSelectorControl_iid) == 0)
+ return mockVideoDeviceSelectorControl;
+
+ if (qstrcmp(iid, QCameraInfoControl_iid) == 0)
+ return mockCameraInfoControl;
+
if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
if (rendererRef == 0) {
rendererRef += 1;
@@ -184,6 +194,8 @@ public:
MockImageEncoderControl *mockImageEncoderControl;
MockVideoRendererControl *rendererControl;
MockVideoWindowControl *windowControl;
+ MockVideoDeviceSelectorControl *mockVideoDeviceSelectorControl;
+ MockCameraInfoControl *mockCameraInfoControl;
int rendererRef;
int windowRef;
};
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h b/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
index d582ea319..6bf221c50 100644
--- a/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
+++ b/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
@@ -44,6 +44,8 @@
#include "private/qmediaserviceprovider_p.h"
#include "qmediaservice.h"
+#include "mockvideodeviceselectorcontrol.h"
+#include "mockcamerainfocontrol.h"
// Simple provider that lets you set the service
class MockMediaServiceProvider : public QMediaServiceProvider
@@ -67,6 +69,40 @@ public:
}
}
+ QByteArray defaultDevice(const QByteArray &serviceType) const
+ {
+ if (serviceType == Q_MEDIASERVICE_CAMERA)
+ return MockVideoDeviceSelectorControl::defaultCamera();
+
+ return QByteArray();
+ }
+
+ QList<QByteArray> devices(const QByteArray &serviceType) const
+ {
+ if (serviceType == Q_MEDIASERVICE_CAMERA)
+ return MockVideoDeviceSelectorControl::availableCameras();
+
+ return QList<QByteArray>();
+ }
+
+ QString deviceDescription(const QByteArray &serviceType, const QByteArray &device)
+ {
+ if (serviceType == Q_MEDIASERVICE_CAMERA)
+ return MockVideoDeviceSelectorControl::cameraDescription(device);
+
+ return QString();
+ }
+
+ QCamera::Position cameraPosition(const QByteArray &device) const
+ {
+ return MockCameraInfoControl::position(device);
+ }
+
+ int cameraOrientation(const QByteArray &device) const
+ {
+ return MockCameraInfoControl::orientation(device);
+ }
+
QMediaService *service;
bool deleteServiceOnRelease;
};
diff --git a/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h b/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h
new file mode 100644
index 000000000..04aec6f7b
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKVIDEODEVICESELECTORCONTROL_H
+#define MOCKVIDEODEVICESELECTORCONTROL_H
+
+#include <qvideodeviceselectorcontrol.h>
+
+class MockVideoDeviceSelectorControl : public QVideoDeviceSelectorControl
+{
+ Q_OBJECT
+public:
+ MockVideoDeviceSelectorControl(QObject *parent)
+ : QVideoDeviceSelectorControl(parent)
+ , m_selectedDevice(1)
+ {
+ }
+
+ ~MockVideoDeviceSelectorControl() { }
+
+ int deviceCount() const { return availableCameras().count(); }
+
+ QString deviceName(int index) const { return QString::fromLatin1(availableCameras().at(index)); }
+ QString deviceDescription(int index) const { return cameraDescription(availableCameras().at(index)); }
+
+ int defaultDevice() const { return availableCameras().indexOf(defaultCamera()); }
+ int selectedDevice() const { return m_selectedDevice; }
+ void setSelectedDevice(int index)
+ {
+ m_selectedDevice = index;
+ emit selectedDeviceChanged(m_selectedDevice);
+ emit selectedDeviceChanged(deviceName(m_selectedDevice));
+ }
+
+ static QByteArray defaultCamera()
+ {
+ return "othercamera";
+ }
+
+ static QList<QByteArray> availableCameras()
+ {
+ return QList<QByteArray>() << "backcamera" << "othercamera";
+ }
+
+ static QString cameraDescription(const QByteArray &camera)
+ {
+ if (camera == "backcamera")
+ return QStringLiteral("backcamera desc");
+ else if (camera == "othercamera")
+ return QStringLiteral("othercamera desc");
+ else
+ return QString();
+ }
+
+private:
+ int m_selectedDevice;
+ QStringList m_devices;
+ QStringList m_descriptions;
+};
+
+#endif // MOCKVIDEODEVICESELECTORCONTROL_H