Merge lp:~uriboni/qtubuntu-camera/cameras-info into lp:qtubuntu-camera/staging
- cameras-info
- Merge into staging
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Florian Boucault | ||||||||
Approved revision: | 188 | ||||||||
Merged at revision: | 181 | ||||||||
Proposed branch: | lp:~uriboni/qtubuntu-camera/cameras-info | ||||||||
Merge into: | lp:qtubuntu-camera/staging | ||||||||
Diff against target: |
586 lines (+328/-34) 13 files modified
src/aalcamerainfocontrol.cpp (+33/-0) src/aalcamerainfocontrol.h (+32/-0) src/aalcameraservice.cpp (+17/-12) src/aalcameraservice.h (+3/-0) src/aalcameraserviceplugin.cpp (+71/-5) src/aalcameraserviceplugin.h (+5/-1) src/aalvideodeviceselectorcontrol.cpp (+4/-14) src/src.pro (+2/-0) unittests/aalvideodeviceselectorcontrol/aalvideodeviceselectorcontrol.pro (+6/-2) unittests/aalvideodeviceselectorcontrol/tst_aalvideodeviceselectorcontrol.cpp (+5/-0) unittests/stubs/qcamerainfo_stub.cpp (+81/-0) unittests/stubs/qcamerainfodata.cpp (+30/-0) unittests/stubs/qcamerainfodata.h (+39/-0) |
||||||||
To merge this branch: | bzr merge lp:~uriboni/qtubuntu-camera/cameras-info | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Florian Boucault (community) | Needs Fixing | ||
Review via email: mp+286283@code.launchpad.net |
Commit message
Implement qtmultimedia APIs to query the system for available cameras, their orientation and facing and replace some hardcoded logic to calls to these APIs.
Description of the change
Implement qtmultimedia APIs to query the system for available cameras, their orientation and facing and replace some hardcoded logic to calls to these APIs.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 184. By Ugo Riboni
-
Fix unit tests
- 185. By Ugo Riboni
-
Add useful info the human readable device description
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:185
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 186. By Ugo Riboni
-
Remove debug
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:186
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Florian Boucault (fboucault) wrote : | # |
src/aalcamerase
control returned by android_
Florian Boucault (fboucault) wrote : | # |
src/aalcamerase
return (result != 0) ? QCamera:
how about using some if blocks to help readability?
Florian Boucault (fboucault) wrote : | # |
src/aalcamerase
if (!ok) return 0;
[...]
if (!ok) return QCamera:
syntax rule is to always use {} for any block, even for 1 liners
- 187. By Ugo Riboni
-
Save the AndroidControl in case there is only one camera.Style fixes
- 188. By Ugo Riboni
-
Style fixes
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:188
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Michael Terry (mterry) wrote : | # |
I tested this branch and got crashes with the code samples from bug 1514253 or bug 1514250.
Ran like so: "qmlscene test.qml --desktop_
#0 0xb30193a8 in ?? () from /lib/arm-
#1 0xb3016ec4 in OPENSSL_cpuid_setup ()
from /lib/arm-
#2 0xb6fe280c in ?? () from /lib/ld-
#3 0x000243b0 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Michael Terry (mterry) wrote : | # |
Oh, and this was the phone:
current build number: 267
device name: mako
channel: ubuntu-
last update: 2016-03-19 11:53:04
version version: 267
version ubuntu: 20160318
version device: 20160315
version custom: 20160201-5-vivid
Preview Diff
1 | === added file 'src/aalcamerainfocontrol.cpp' |
2 | --- src/aalcamerainfocontrol.cpp 1970-01-01 00:00:00 +0000 |
3 | +++ src/aalcamerainfocontrol.cpp 2016-02-24 14:33:23 +0000 |
4 | @@ -0,0 +1,33 @@ |
5 | +/* |
6 | + * Copyright (C) 2016 Canonical, Ltd. |
7 | + * |
8 | + * This program is free software; you can redistribute it and/or modify |
9 | + * it under the terms of the GNU Lesser General Public License as published by |
10 | + * the Free Software Foundation; version 3. |
11 | + * |
12 | + * This program is distributed in the hope that it will be useful, |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | + * GNU Lesser General Public License for more details. |
16 | + * |
17 | + * You should have received a copy of the GNU Lesser General Public License |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | + */ |
20 | + |
21 | +#include "aalcamerainfocontrol.h" |
22 | + |
23 | +#include <QCameraInfo> |
24 | + |
25 | +AalCameraInfoControl::AalCameraInfoControl(QObject *parent) : QCameraInfoControl(parent) |
26 | +{ |
27 | +} |
28 | + |
29 | +QCamera::Position AalCameraInfoControl::cameraPosition(const QString &deviceName) const |
30 | +{ |
31 | + return QCameraInfo(deviceName.toLatin1()).position(); |
32 | +} |
33 | + |
34 | +int AalCameraInfoControl::cameraOrientation(const QString &deviceName) const |
35 | +{ |
36 | + return QCameraInfo(deviceName.toLatin1()).orientation(); |
37 | +} |
38 | |
39 | === added file 'src/aalcamerainfocontrol.h' |
40 | --- src/aalcamerainfocontrol.h 1970-01-01 00:00:00 +0000 |
41 | +++ src/aalcamerainfocontrol.h 2016-02-24 14:33:23 +0000 |
42 | @@ -0,0 +1,32 @@ |
43 | +/* |
44 | + * Copyright (C) 2016 Canonical, Ltd. |
45 | + * |
46 | + * This program is free software; you can redistribute it and/or modify |
47 | + * it under the terms of the GNU Lesser General Public License as published by |
48 | + * the Free Software Foundation; version 3. |
49 | + * |
50 | + * This program is distributed in the hope that it will be useful, |
51 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
52 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
53 | + * GNU Lesser General Public License for more details. |
54 | + * |
55 | + * You should have received a copy of the GNU Lesser General Public License |
56 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
57 | + */ |
58 | + |
59 | +#ifndef AALCAMERAINFOCONTROL_H |
60 | +#define AALCAMERAINFOCONTROL_H |
61 | + |
62 | +#include <QCameraInfoControl> |
63 | + |
64 | +class AalCameraInfoControl : public QCameraInfoControl |
65 | +{ |
66 | + Q_OBJECT |
67 | +public: |
68 | + AalCameraInfoControl(QObject *parent = 0); |
69 | + |
70 | + QCamera::Position cameraPosition(const QString &deviceName) const; |
71 | + int cameraOrientation(const QString &deviceName) const; |
72 | +}; |
73 | + |
74 | +#endif // AALCAMERAINFOCONTROL_H |
75 | |
76 | === modified file 'src/aalcameraservice.cpp' |
77 | --- src/aalcameraservice.cpp 2016-01-12 12:04:31 +0000 |
78 | +++ src/aalcameraservice.cpp 2016-02-24 14:33:23 +0000 |
79 | @@ -27,6 +27,7 @@ |
80 | #include "aalvideoencodersettingscontrol.h" |
81 | #include "aalvideorenderercontrol.h" |
82 | #include "aalviewfindersettingscontrol.h" |
83 | +#include "aalcamerainfocontrol.h" |
84 | #include "storagemanager.h" |
85 | #include "aalcameraexposurecontrol.h" |
86 | |
87 | @@ -60,6 +61,7 @@ |
88 | m_videoOutput = new AalVideoRendererControl(this); |
89 | m_viewfinderControl = new AalViewfinderSettingsControl(this); |
90 | m_exposureControl = new AalCameraExposureControl(this); |
91 | + m_infoControl = new AalCameraInfoControl(this); |
92 | |
93 | QGuiApplication* application = qobject_cast<QGuiApplication*>(QGuiApplication::instance()); |
94 | m_previousApplicationState = application->applicationState(); |
95 | @@ -84,6 +86,7 @@ |
96 | delete m_videoOutput; |
97 | delete m_viewfinderControl; |
98 | delete m_exposureControl; |
99 | + delete m_infoControl; |
100 | if (m_androidControl) |
101 | android_camera_delete(m_androidControl); |
102 | delete m_storageManager; |
103 | @@ -130,6 +133,9 @@ |
104 | if (qstrcmp(name, QCameraExposureControl_iid) == 0) |
105 | return m_exposureControl; |
106 | |
107 | + if (qstrcmp(name, QCameraInfoControl_iid) == 0) |
108 | + return m_infoControl; |
109 | + |
110 | return 0; |
111 | } |
112 | |
113 | @@ -153,21 +159,18 @@ |
114 | if (m_androidControl) |
115 | return true; |
116 | |
117 | - CameraType device = BACK_FACING_CAMERA_TYPE; |
118 | - if (!isBackCameraUsed()) |
119 | - device = FRONT_FACING_CAMERA_TYPE; |
120 | - |
121 | m_androidListener = new CameraControlListener; |
122 | memset(m_androidListener, 0, sizeof(*m_androidListener)); |
123 | |
124 | - m_androidControl = android_camera_connect_to(device, m_androidListener); |
125 | - |
126 | - // fallback if there is only one camera |
127 | - if (!m_androidControl && m_deviceSelectControl->deviceCount() == 1) { |
128 | - if (device == BACK_FACING_CAMERA_TYPE) |
129 | + // if there is only one camera fallback directly to the ID of whatever device we have |
130 | + if (m_deviceSelectControl->deviceCount() == 1) { |
131 | + m_androidControl = android_camera_connect_by_id(m_deviceSelectControl->selectedDevice(), m_androidListener); |
132 | + } else { |
133 | + CameraType device = BACK_FACING_CAMERA_TYPE; |
134 | + if (!isBackCameraUsed()) { |
135 | device = FRONT_FACING_CAMERA_TYPE; |
136 | - else |
137 | - device = BACK_FACING_CAMERA_TYPE; |
138 | + } |
139 | + |
140 | m_androidControl = android_camera_connect_to(device, m_androidListener); |
141 | } |
142 | |
143 | @@ -232,7 +235,9 @@ |
144 | |
145 | bool AalCameraService::isBackCameraUsed() const |
146 | { |
147 | - return m_deviceSelectControl->selectedDevice() == 0; |
148 | + int deviceIndex = m_deviceSelectControl->selectedDevice(); |
149 | + QString deviceName = m_deviceSelectControl->deviceName(deviceIndex); |
150 | + return m_infoControl->cameraPosition(deviceName) == QCamera::BackFace; |
151 | } |
152 | |
153 | /*! |
154 | |
155 | === modified file 'src/aalcameraservice.h' |
156 | --- src/aalcameraservice.h 2015-12-16 11:22:04 +0000 |
157 | +++ src/aalcameraservice.h 2016-02-24 14:33:23 +0000 |
158 | @@ -34,6 +34,7 @@ |
159 | class AalVideoRendererControl; |
160 | class AalViewfinderSettingsControl; |
161 | class AalCameraExposureControl; |
162 | +class AalCameraInfoControl; |
163 | class QCameraControl; |
164 | |
165 | struct CameraControl; |
166 | @@ -64,6 +65,7 @@ |
167 | AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; } |
168 | AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; } |
169 | AalCameraExposureControl *exposureControl() const { return m_exposureControl; } |
170 | + AalCameraInfoControl *infoControl() const { return m_infoControl; } |
171 | |
172 | CameraControl *androidControl(); |
173 | |
174 | @@ -110,6 +112,7 @@ |
175 | AalVideoRendererControl *m_videoOutput; |
176 | AalViewfinderSettingsControl *m_viewfinderControl; |
177 | AalCameraExposureControl *m_exposureControl; |
178 | + AalCameraInfoControl *m_infoControl; |
179 | |
180 | CameraControl *m_androidControl; |
181 | CameraControlListener *m_androidListener; |
182 | |
183 | === modified file 'src/aalcameraserviceplugin.cpp' |
184 | --- src/aalcameraserviceplugin.cpp 2013-03-12 16:17:37 +0000 |
185 | +++ src/aalcameraserviceplugin.cpp 2016-02-24 14:33:23 +0000 |
186 | @@ -21,6 +21,10 @@ |
187 | #include <QMetaType> |
188 | #include <qgl.h> |
189 | |
190 | +#include <hybris/camera/camera_compatibility_layer.h> |
191 | +#include <hybris/camera/camera_compatibility_layer_capabilities.h> |
192 | + |
193 | + |
194 | AalServicePlugin::AalServicePlugin() |
195 | { |
196 | } |
197 | @@ -42,13 +46,75 @@ |
198 | |
199 | QList<QByteArray> AalServicePlugin::devices(const QByteArray &service) const |
200 | { |
201 | - Q_UNUSED(service); |
202 | - return QList<QByteArray>(); |
203 | + QList<QByteArray> deviceList; |
204 | + |
205 | + if (QString::fromLatin1(service) != QLatin1String(Q_MEDIASERVICE_CAMERA)) { |
206 | + return deviceList; |
207 | + } |
208 | + |
209 | + // Devices are identified in android only by their index, so we do the same |
210 | + int cameras = android_camera_get_number_of_devices(); |
211 | + for (int deviceId = 0; deviceId < cameras; deviceId++) { |
212 | + QString camera("%1"); |
213 | + camera = camera.arg(deviceId); |
214 | + deviceList.append(camera.toLatin1()); |
215 | + } |
216 | + |
217 | + return deviceList; |
218 | } |
219 | |
220 | QString AalServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device) |
221 | { |
222 | - Q_UNUSED(service); |
223 | - Q_UNUSED(device); |
224 | - return QString(); |
225 | + if (QString::fromLatin1(service) != QLatin1String(Q_MEDIASERVICE_CAMERA)) { |
226 | + return QString(); |
227 | + } |
228 | + |
229 | + // Android does not provice a descriptive identifier for devices, so we just |
230 | + // send back the index plus some useful human readable information about position. |
231 | + bool ok; |
232 | + int deviceID = device.toInt(&ok, 10); |
233 | + if (!ok || deviceID >= android_camera_get_number_of_devices()) { |
234 | + qWarning() << "Requested description for invalid device ID:" << device; |
235 | + return QString(); |
236 | + } else { |
237 | + QCamera::Position position = cameraPosition(device); |
238 | + return QString("Camera %1%2").arg(QLatin1String(device)) |
239 | + .arg(position == QCamera::FrontFace ? " Front facing" : |
240 | + (position == QCamera::BackFace ? " Back facing" : "")); |
241 | + } |
242 | +} |
243 | + |
244 | +int AalServicePlugin::cameraOrientation(const QByteArray & device) const |
245 | +{ |
246 | + int facing; |
247 | + int orientation; |
248 | + |
249 | + bool ok; |
250 | + int deviceID = device.toInt(&ok, 10); |
251 | + if (!ok) { |
252 | + return 0; |
253 | + } |
254 | + |
255 | + int result = android_camera_get_device_info(deviceID, &facing, &orientation); |
256 | + return (result != 0) ? 0 : orientation; |
257 | +} |
258 | + |
259 | +QCamera::Position AalServicePlugin::cameraPosition(const QByteArray & device) const |
260 | +{ |
261 | + int facing; |
262 | + int orientation; |
263 | + |
264 | + bool ok; |
265 | + int deviceID = device.toInt(&ok, 10); |
266 | + if (!ok) { |
267 | + return QCamera::UnspecifiedPosition; |
268 | + } |
269 | + |
270 | + int result = android_camera_get_device_info(deviceID, &facing, &orientation); |
271 | + if (result != 0) { |
272 | + return QCamera::UnspecifiedPosition; |
273 | + } else { |
274 | + return facing == BACK_FACING_CAMERA_TYPE ? QCamera::BackFace : |
275 | + QCamera::FrontFace; |
276 | + } |
277 | } |
278 | |
279 | === modified file 'src/aalcameraserviceplugin.h' |
280 | --- src/aalcameraserviceplugin.h 2013-02-11 15:56:21 +0000 |
281 | +++ src/aalcameraserviceplugin.h 2016-02-24 14:33:23 +0000 |
282 | @@ -20,10 +20,12 @@ |
283 | #include <QMediaServiceProviderPlugin> |
284 | |
285 | class AalServicePlugin : public QMediaServiceProviderPlugin, |
286 | - public QMediaServiceSupportedDevicesInterface |
287 | + public QMediaServiceSupportedDevicesInterface, |
288 | + public QMediaServiceCameraInfoInterface |
289 | { |
290 | Q_OBJECT |
291 | Q_INTERFACES(QMediaServiceSupportedDevicesInterface) |
292 | + Q_INTERFACES(QMediaServiceCameraInfoInterface) |
293 | Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "aalcamera.json") |
294 | |
295 | public: |
296 | @@ -34,6 +36,8 @@ |
297 | |
298 | QList<QByteArray> devices(const QByteArray &service) const; |
299 | QString deviceDescription(const QByteArray &service, const QByteArray &device); |
300 | + int cameraOrientation(const QByteArray & device) const; |
301 | + QCamera::Position cameraPosition(const QByteArray & device) const; |
302 | }; |
303 | |
304 | #endif |
305 | |
306 | === modified file 'src/aalvideodeviceselectorcontrol.cpp' |
307 | --- src/aalvideodeviceselectorcontrol.cpp 2015-12-07 15:16:51 +0000 |
308 | +++ src/aalvideodeviceselectorcontrol.cpp 2016-02-24 14:33:23 +0000 |
309 | @@ -23,6 +23,7 @@ |
310 | |
311 | #include <QDebug> |
312 | #include <QtMultimedia/QCamera> |
313 | +#include <QtMultimedia/QCameraInfo> |
314 | |
315 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> |
316 | |
317 | @@ -41,28 +42,17 @@ |
318 | |
319 | int AalVideoDeviceSelectorControl::deviceCount() const |
320 | { |
321 | - if (m_numberOfCameras < 0) |
322 | - m_numberOfCameras = android_camera_get_number_of_devices(); |
323 | - |
324 | - return m_numberOfCameras; |
325 | + return QCameraInfo::availableCameras().count(); |
326 | } |
327 | |
328 | QString AalVideoDeviceSelectorControl::deviceDescription(int index) const |
329 | { |
330 | - switch (index) { |
331 | - case 0: return QLatin1String("Back camera"); |
332 | - case 1: return QLatin1String("Front camera"); |
333 | - default: return QLatin1String(""); |
334 | - } |
335 | + return QCameraInfo::availableCameras().value(index).description(); |
336 | } |
337 | |
338 | QString AalVideoDeviceSelectorControl::deviceName(int index) const |
339 | { |
340 | - switch (index) { |
341 | - case 0: return QLatin1String("Back"); |
342 | - case 1: return QLatin1String("Front"); |
343 | - default: return QLatin1String(""); |
344 | - } |
345 | + return QCameraInfo::availableCameras().value(index).deviceName(); |
346 | } |
347 | |
348 | int AalVideoDeviceSelectorControl::selectedDevice() const |
349 | |
350 | === modified file 'src/src.pro' |
351 | --- src/src.pro 2015-11-12 10:32:24 +0000 |
352 | +++ src/src.pro 2016-02-24 14:33:23 +0000 |
353 | @@ -29,6 +29,7 @@ |
354 | aalvideoencodersettingscontrol.h \ |
355 | aalvideorenderercontrol.h \ |
356 | aalviewfindersettingscontrol.h \ |
357 | + aalcamerainfocontrol.h \ |
358 | audiocapture.h \ |
359 | aalcameraexposurecontrol.h \ |
360 | storagemanager.h |
361 | @@ -48,6 +49,7 @@ |
362 | aalvideoencodersettingscontrol.cpp \ |
363 | aalvideorenderercontrol.cpp \ |
364 | aalviewfindersettingscontrol.cpp \ |
365 | + aalcamerainfocontrol.cpp \ |
366 | audiocapture.cpp \ |
367 | aalcameraexposurecontrol.cpp \ |
368 | storagemanager.cpp |
369 | |
370 | === modified file 'unittests/aalvideodeviceselectorcontrol/aalvideodeviceselectorcontrol.pro' |
371 | --- unittests/aalvideodeviceselectorcontrol/aalvideodeviceselectorcontrol.pro 2015-12-18 15:16:06 +0000 |
372 | +++ unittests/aalvideodeviceselectorcontrol/aalvideodeviceselectorcontrol.pro 2016-02-24 14:33:23 +0000 |
373 | @@ -7,11 +7,13 @@ |
374 | LIBS += -L../mocks/aal -laal |
375 | INCLUDEPATH += ../../src |
376 | INCLUDEPATH += ../mocks/aal |
377 | +INCLUDEPATH += ../stubs/ |
378 | |
379 | HEADERS += ../../src/aalvideodeviceselectorcontrol.h \ |
380 | ../../src/aalcameracontrol.h \ |
381 | ../../src/aalcameraservice.h \ |
382 | - ../../src/aalvideoencodersettingscontrol.h |
383 | + ../../src/aalvideoencodersettingscontrol.h \ |
384 | + ../stubs/qcamerainfodata.h |
385 | |
386 | SOURCES += tst_aalvideodeviceselectorcontrol.cpp \ |
387 | ../../src/aalvideodeviceselectorcontrol.cpp \ |
388 | @@ -19,7 +21,9 @@ |
389 | aalimageencodercontrol.cpp \ |
390 | aalviewfindersettingscontrol.cpp \ |
391 | ../stubs/aalcameracontrol_stub.cpp \ |
392 | - ../stubs/aalvideoencodersettingscontrol_stub.cpp |
393 | + ../stubs/aalvideoencodersettingscontrol_stub.cpp \ |
394 | + ../stubs/qcamerainfo_stub.cpp \ |
395 | + ../stubs/qcamerainfodata.cpp |
396 | |
397 | check.depends = $${TARGET} |
398 | check.commands = ./$${TARGET} |
399 | |
400 | === modified file 'unittests/aalvideodeviceselectorcontrol/tst_aalvideodeviceselectorcontrol.cpp' |
401 | --- unittests/aalvideodeviceselectorcontrol/tst_aalvideodeviceselectorcontrol.cpp 2014-07-31 16:44:03 +0000 |
402 | +++ unittests/aalvideodeviceselectorcontrol/tst_aalvideodeviceselectorcontrol.cpp 2016-02-24 14:33:23 +0000 |
403 | @@ -21,6 +21,7 @@ |
404 | |
405 | #define private public |
406 | #include "aalvideodeviceselectorcontrol.h" |
407 | +#include "qcamerainfodata.h" |
408 | |
409 | class tst_AalVideoDeviceSelectorControl : public QObject |
410 | { |
411 | @@ -53,6 +54,10 @@ |
412 | QSignalSpy spy(m_selectControl, SIGNAL(selectedDeviceChanged(int))); |
413 | QSignalSpy spy2(m_selectControl, SIGNAL(selectedDeviceChanged(QString))); |
414 | |
415 | + QCameraInfoData::availableDevices.clear(); |
416 | + QCameraInfoData::availableDevices.append(CameraInfo("0", "Camera 0")); |
417 | + QCameraInfoData::availableDevices.append(CameraInfo("1", "Camera 1")); |
418 | + |
419 | m_selectControl->setSelectedDevice(1); |
420 | |
421 | QCOMPARE(m_selectControl->selectedDevice(), 1); |
422 | |
423 | === added file 'unittests/stubs/qcamerainfo_stub.cpp' |
424 | --- unittests/stubs/qcamerainfo_stub.cpp 1970-01-01 00:00:00 +0000 |
425 | +++ unittests/stubs/qcamerainfo_stub.cpp 2016-02-24 14:33:23 +0000 |
426 | @@ -0,0 +1,81 @@ |
427 | +/* |
428 | + * Copyright (C) 2016 Canonical, Ltd. |
429 | + * |
430 | + * This program is free software; you can redistribute it and/or modify |
431 | + * it under the terms of the GNU Lesser General Public License as published by |
432 | + * the Free Software Foundation; version 3. |
433 | + * |
434 | + * This program is distributed in the hope that it will be useful, |
435 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
436 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
437 | + * GNU Lesser General Public License for more details. |
438 | + * |
439 | + * You should have received a copy of the GNU Lesser General Public License |
440 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
441 | + */ |
442 | + |
443 | +#include <QtMultimedia/QCameraInfo> |
444 | +#include "qcamerainfodata.h" |
445 | + |
446 | +class QCameraInfoPrivate { |
447 | +public: |
448 | + QString deviceID; |
449 | + QString description; |
450 | + int orientation; |
451 | + QCamera::Position position; |
452 | +}; |
453 | + |
454 | +QCameraInfo::QCameraInfo(const QByteArray &name) : d(new QCameraInfoPrivate()) |
455 | +{ |
456 | + QStringList info = QString::fromLatin1(name).split('|'); |
457 | + d->deviceID = info.at(0); |
458 | + d->description = info.at(1); |
459 | + d->orientation = info.at(2).toInt(); |
460 | + d->position = QCamera::Position(info.at(3).toInt()); |
461 | +} |
462 | + |
463 | +QCameraInfo::QCameraInfo(const QCamera &camera) : d(new QCameraInfoPrivate()) { |
464 | + Q_UNUSED(camera); |
465 | +} |
466 | + |
467 | +QCameraInfo::QCameraInfo(const QCameraInfo& other) : d(new QCameraInfoPrivate()) |
468 | +{ |
469 | + d->deviceID = other.deviceName(); |
470 | + d->description = other.description(); |
471 | + d->orientation = other.orientation(); |
472 | + d->position = other.position(); |
473 | +} |
474 | +QCameraInfo::~QCameraInfo() { } |
475 | + |
476 | +QCameraInfo& QCameraInfo::operator=(const QCameraInfo& other) { |
477 | + if (this != &other) { |
478 | + d->deviceID = other.deviceName(); |
479 | + d->description = other.description(); |
480 | + d->orientation = other.orientation(); |
481 | + d->position = other.position(); |
482 | + } |
483 | + return *this; |
484 | +} |
485 | +bool QCameraInfo::operator==(const QCameraInfo &other) const { Q_UNUSED(other); return false; } |
486 | + |
487 | +bool QCameraInfo::isNull() const { return false; } |
488 | + |
489 | +QString QCameraInfo::deviceName() const { return d->deviceID; } |
490 | +QString QCameraInfo::description() const { return d->description; } |
491 | +QCamera::Position QCameraInfo::position() const { return d->position; } |
492 | +int QCameraInfo::orientation() const { return d->orientation; } |
493 | + |
494 | +QCameraInfo QCameraInfo::defaultCamera() { return QCameraInfo(); } |
495 | +QList<QCameraInfo> QCameraInfo::availableCameras(QCamera::Position position) { |
496 | + Q_UNUSED(position); |
497 | + |
498 | + QList<QCameraInfo> list; |
499 | + Q_FOREACH(CameraInfo info, QCameraInfoData::availableDevices) { |
500 | + QString infoString = QString("%1|%2|%3|%4").arg(info.deviceID).arg(info.description) |
501 | + .arg(info.orientation).arg(info.position); |
502 | + QCameraInfo camera(infoString.toLatin1()); |
503 | + list.append(camera); |
504 | + } |
505 | + |
506 | + return list; |
507 | +} |
508 | |
509 | === added file 'unittests/stubs/qcamerainfodata.cpp' |
510 | --- unittests/stubs/qcamerainfodata.cpp 1970-01-01 00:00:00 +0000 |
511 | +++ unittests/stubs/qcamerainfodata.cpp 2016-02-24 14:33:23 +0000 |
512 | @@ -0,0 +1,30 @@ |
513 | +/* |
514 | + * Copyright (C) 2016 Canonical, Ltd. |
515 | + * |
516 | + * This program is free software; you can redistribute it and/or modify |
517 | + * it under the terms of the GNU Lesser General Public License as published by |
518 | + * the Free Software Foundation; version 3. |
519 | + * |
520 | + * This program is distributed in the hope that it will be useful, |
521 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
522 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
523 | + * GNU Lesser General Public License for more details. |
524 | + * |
525 | + * You should have received a copy of the GNU Lesser General Public License |
526 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
527 | + */ |
528 | + |
529 | +#include "qcamerainfodata.h" |
530 | + |
531 | +QList<CameraInfo> QCameraInfoData::availableDevices = QList<CameraInfo>(); |
532 | + |
533 | +CameraInfo::CameraInfo(QString deviceID, QString description, |
534 | + int orientation, QCamera::Position position) : |
535 | + deviceID(deviceID), |
536 | + description(description), |
537 | + orientation(orientation), |
538 | + position(position) |
539 | +{ |
540 | +} |
541 | + |
542 | + |
543 | |
544 | === added file 'unittests/stubs/qcamerainfodata.h' |
545 | --- unittests/stubs/qcamerainfodata.h 1970-01-01 00:00:00 +0000 |
546 | +++ unittests/stubs/qcamerainfodata.h 2016-02-24 14:33:23 +0000 |
547 | @@ -0,0 +1,39 @@ |
548 | +/* |
549 | + * Copyright (C) 2016 Canonical, Ltd. |
550 | + * |
551 | + * This program is free software; you can redistribute it and/or modify |
552 | + * it under the terms of the GNU Lesser General Public License as published by |
553 | + * the Free Software Foundation; version 3. |
554 | + * |
555 | + * This program is distributed in the hope that it will be useful, |
556 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
557 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
558 | + * GNU Lesser General Public License for more details. |
559 | + * |
560 | + * You should have received a copy of the GNU Lesser General Public License |
561 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
562 | + */ |
563 | + |
564 | +#ifndef QCAMERAINFODATA_H |
565 | +#define QCAMERAINFODATA_H |
566 | + |
567 | +#include <QCamera> |
568 | + |
569 | +class CameraInfo { |
570 | +public: |
571 | + CameraInfo(QString deviceID = QString(), QString description = QString(), |
572 | + int orientation = 0, QCamera::Position position = QCamera::UnspecifiedPosition); |
573 | + |
574 | + QString deviceID; |
575 | + QString description; |
576 | + int orientation; |
577 | + QCamera::Position position; |
578 | +}; |
579 | + |
580 | +class QCameraInfoData |
581 | +{ |
582 | +public: |
583 | + static QList<CameraInfo> availableDevices; |
584 | +}; |
585 | + |
586 | +#endif // QCAMERAINFODATA_H |
FAILED: Continuous integration, rev:183 jenkins. qa.ubuntu. com/job/ qtubuntu- camera- staging- ci/19/ jenkins. qa.ubuntu. com/job/ qtubuntu- camera- staging- vivid-amd64- ci/18/console jenkins. qa.ubuntu. com/job/ qtubuntu- camera- staging- vivid-armhf- ci/19/console jenkins. qa.ubuntu. com/job/ qtubuntu- camera- staging- vivid-i386- ci/18/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtubuntu- camera- staging- ci/19/rebuild
http://