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 | 1 | /* | ||
6 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
7 | 3 | * | ||
8 | 4 | * This program is free software; you can redistribute it and/or modify | ||
9 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
10 | 6 | * the Free Software Foundation; version 3. | ||
11 | 7 | * | ||
12 | 8 | * This program is distributed in the hope that it will be useful, | ||
13 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | 11 | * GNU Lesser General Public License for more details. | ||
16 | 12 | * | ||
17 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
18 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | 15 | */ | ||
20 | 16 | |||
21 | 17 | #include "aalcamerainfocontrol.h" | ||
22 | 18 | |||
23 | 19 | #include <QCameraInfo> | ||
24 | 20 | |||
25 | 21 | AalCameraInfoControl::AalCameraInfoControl(QObject *parent) : QCameraInfoControl(parent) | ||
26 | 22 | { | ||
27 | 23 | } | ||
28 | 24 | |||
29 | 25 | QCamera::Position AalCameraInfoControl::cameraPosition(const QString &deviceName) const | ||
30 | 26 | { | ||
31 | 27 | return QCameraInfo(deviceName.toLatin1()).position(); | ||
32 | 28 | } | ||
33 | 29 | |||
34 | 30 | int AalCameraInfoControl::cameraOrientation(const QString &deviceName) const | ||
35 | 31 | { | ||
36 | 32 | return QCameraInfo(deviceName.toLatin1()).orientation(); | ||
37 | 33 | } | ||
38 | 0 | 34 | ||
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 | 1 | /* | ||
44 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
45 | 3 | * | ||
46 | 4 | * This program is free software; you can redistribute it and/or modify | ||
47 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
48 | 6 | * the Free Software Foundation; version 3. | ||
49 | 7 | * | ||
50 | 8 | * This program is distributed in the hope that it will be useful, | ||
51 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
52 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
53 | 11 | * GNU Lesser General Public License for more details. | ||
54 | 12 | * | ||
55 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
56 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
57 | 15 | */ | ||
58 | 16 | |||
59 | 17 | #ifndef AALCAMERAINFOCONTROL_H | ||
60 | 18 | #define AALCAMERAINFOCONTROL_H | ||
61 | 19 | |||
62 | 20 | #include <QCameraInfoControl> | ||
63 | 21 | |||
64 | 22 | class AalCameraInfoControl : public QCameraInfoControl | ||
65 | 23 | { | ||
66 | 24 | Q_OBJECT | ||
67 | 25 | public: | ||
68 | 26 | AalCameraInfoControl(QObject *parent = 0); | ||
69 | 27 | |||
70 | 28 | QCamera::Position cameraPosition(const QString &deviceName) const; | ||
71 | 29 | int cameraOrientation(const QString &deviceName) const; | ||
72 | 30 | }; | ||
73 | 31 | |||
74 | 32 | #endif // AALCAMERAINFOCONTROL_H | ||
75 | 0 | 33 | ||
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 | 27 | #include "aalvideoencodersettingscontrol.h" | 27 | #include "aalvideoencodersettingscontrol.h" |
81 | 28 | #include "aalvideorenderercontrol.h" | 28 | #include "aalvideorenderercontrol.h" |
82 | 29 | #include "aalviewfindersettingscontrol.h" | 29 | #include "aalviewfindersettingscontrol.h" |
83 | 30 | #include "aalcamerainfocontrol.h" | ||
84 | 30 | #include "storagemanager.h" | 31 | #include "storagemanager.h" |
85 | 31 | #include "aalcameraexposurecontrol.h" | 32 | #include "aalcameraexposurecontrol.h" |
86 | 32 | 33 | ||
87 | @@ -60,6 +61,7 @@ | |||
88 | 60 | m_videoOutput = new AalVideoRendererControl(this); | 61 | m_videoOutput = new AalVideoRendererControl(this); |
89 | 61 | m_viewfinderControl = new AalViewfinderSettingsControl(this); | 62 | m_viewfinderControl = new AalViewfinderSettingsControl(this); |
90 | 62 | m_exposureControl = new AalCameraExposureControl(this); | 63 | m_exposureControl = new AalCameraExposureControl(this); |
91 | 64 | m_infoControl = new AalCameraInfoControl(this); | ||
92 | 63 | 65 | ||
93 | 64 | QGuiApplication* application = qobject_cast<QGuiApplication*>(QGuiApplication::instance()); | 66 | QGuiApplication* application = qobject_cast<QGuiApplication*>(QGuiApplication::instance()); |
94 | 65 | m_previousApplicationState = application->applicationState(); | 67 | m_previousApplicationState = application->applicationState(); |
95 | @@ -84,6 +86,7 @@ | |||
96 | 84 | delete m_videoOutput; | 86 | delete m_videoOutput; |
97 | 85 | delete m_viewfinderControl; | 87 | delete m_viewfinderControl; |
98 | 86 | delete m_exposureControl; | 88 | delete m_exposureControl; |
99 | 89 | delete m_infoControl; | ||
100 | 87 | if (m_androidControl) | 90 | if (m_androidControl) |
101 | 88 | android_camera_delete(m_androidControl); | 91 | android_camera_delete(m_androidControl); |
102 | 89 | delete m_storageManager; | 92 | delete m_storageManager; |
103 | @@ -130,6 +133,9 @@ | |||
104 | 130 | if (qstrcmp(name, QCameraExposureControl_iid) == 0) | 133 | if (qstrcmp(name, QCameraExposureControl_iid) == 0) |
105 | 131 | return m_exposureControl; | 134 | return m_exposureControl; |
106 | 132 | 135 | ||
107 | 136 | if (qstrcmp(name, QCameraInfoControl_iid) == 0) | ||
108 | 137 | return m_infoControl; | ||
109 | 138 | |||
110 | 133 | return 0; | 139 | return 0; |
111 | 134 | } | 140 | } |
112 | 135 | 141 | ||
113 | @@ -153,21 +159,18 @@ | |||
114 | 153 | if (m_androidControl) | 159 | if (m_androidControl) |
115 | 154 | return true; | 160 | return true; |
116 | 155 | 161 | ||
117 | 156 | CameraType device = BACK_FACING_CAMERA_TYPE; | ||
118 | 157 | if (!isBackCameraUsed()) | ||
119 | 158 | device = FRONT_FACING_CAMERA_TYPE; | ||
120 | 159 | |||
121 | 160 | m_androidListener = new CameraControlListener; | 162 | m_androidListener = new CameraControlListener; |
122 | 161 | memset(m_androidListener, 0, sizeof(*m_androidListener)); | 163 | memset(m_androidListener, 0, sizeof(*m_androidListener)); |
123 | 162 | 164 | ||
129 | 163 | m_androidControl = android_camera_connect_to(device, m_androidListener); | 165 | // if there is only one camera fallback directly to the ID of whatever device we have |
130 | 164 | 166 | if (m_deviceSelectControl->deviceCount() == 1) { | |
131 | 165 | // fallback if there is only one camera | 167 | m_androidControl = android_camera_connect_by_id(m_deviceSelectControl->selectedDevice(), m_androidListener); |
132 | 166 | if (!m_androidControl && m_deviceSelectControl->deviceCount() == 1) { | 168 | } else { |
133 | 167 | if (device == BACK_FACING_CAMERA_TYPE) | 169 | CameraType device = BACK_FACING_CAMERA_TYPE; |
134 | 170 | if (!isBackCameraUsed()) { | ||
135 | 168 | device = FRONT_FACING_CAMERA_TYPE; | 171 | device = FRONT_FACING_CAMERA_TYPE; |
138 | 169 | else | 172 | } |
139 | 170 | device = BACK_FACING_CAMERA_TYPE; | 173 | |
140 | 171 | m_androidControl = android_camera_connect_to(device, m_androidListener); | 174 | m_androidControl = android_camera_connect_to(device, m_androidListener); |
141 | 172 | } | 175 | } |
142 | 173 | 176 | ||
143 | @@ -232,7 +235,9 @@ | |||
144 | 232 | 235 | ||
145 | 233 | bool AalCameraService::isBackCameraUsed() const | 236 | bool AalCameraService::isBackCameraUsed() const |
146 | 234 | { | 237 | { |
148 | 235 | return m_deviceSelectControl->selectedDevice() == 0; | 238 | int deviceIndex = m_deviceSelectControl->selectedDevice(); |
149 | 239 | QString deviceName = m_deviceSelectControl->deviceName(deviceIndex); | ||
150 | 240 | return m_infoControl->cameraPosition(deviceName) == QCamera::BackFace; | ||
151 | 236 | } | 241 | } |
152 | 237 | 242 | ||
153 | 238 | /*! | 243 | /*! |
154 | 239 | 244 | ||
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 | 34 | class AalVideoRendererControl; | 34 | class AalVideoRendererControl; |
160 | 35 | class AalViewfinderSettingsControl; | 35 | class AalViewfinderSettingsControl; |
161 | 36 | class AalCameraExposureControl; | 36 | class AalCameraExposureControl; |
162 | 37 | class AalCameraInfoControl; | ||
163 | 37 | class QCameraControl; | 38 | class QCameraControl; |
164 | 38 | 39 | ||
165 | 39 | struct CameraControl; | 40 | struct CameraControl; |
166 | @@ -64,6 +65,7 @@ | |||
167 | 64 | AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; } | 65 | AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; } |
168 | 65 | AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; } | 66 | AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; } |
169 | 66 | AalCameraExposureControl *exposureControl() const { return m_exposureControl; } | 67 | AalCameraExposureControl *exposureControl() const { return m_exposureControl; } |
170 | 68 | AalCameraInfoControl *infoControl() const { return m_infoControl; } | ||
171 | 67 | 69 | ||
172 | 68 | CameraControl *androidControl(); | 70 | CameraControl *androidControl(); |
173 | 69 | 71 | ||
174 | @@ -110,6 +112,7 @@ | |||
175 | 110 | AalVideoRendererControl *m_videoOutput; | 112 | AalVideoRendererControl *m_videoOutput; |
176 | 111 | AalViewfinderSettingsControl *m_viewfinderControl; | 113 | AalViewfinderSettingsControl *m_viewfinderControl; |
177 | 112 | AalCameraExposureControl *m_exposureControl; | 114 | AalCameraExposureControl *m_exposureControl; |
178 | 115 | AalCameraInfoControl *m_infoControl; | ||
179 | 113 | 116 | ||
180 | 114 | CameraControl *m_androidControl; | 117 | CameraControl *m_androidControl; |
181 | 115 | CameraControlListener *m_androidListener; | 118 | CameraControlListener *m_androidListener; |
182 | 116 | 119 | ||
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 | 21 | #include <QMetaType> | 21 | #include <QMetaType> |
188 | 22 | #include <qgl.h> | 22 | #include <qgl.h> |
189 | 23 | 23 | ||
190 | 24 | #include <hybris/camera/camera_compatibility_layer.h> | ||
191 | 25 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> | ||
192 | 26 | |||
193 | 27 | |||
194 | 24 | AalServicePlugin::AalServicePlugin() | 28 | AalServicePlugin::AalServicePlugin() |
195 | 25 | { | 29 | { |
196 | 26 | } | 30 | } |
197 | @@ -42,13 +46,75 @@ | |||
198 | 42 | 46 | ||
199 | 43 | QList<QByteArray> AalServicePlugin::devices(const QByteArray &service) const | 47 | QList<QByteArray> AalServicePlugin::devices(const QByteArray &service) const |
200 | 44 | { | 48 | { |
203 | 45 | Q_UNUSED(service); | 49 | QList<QByteArray> deviceList; |
204 | 46 | return QList<QByteArray>(); | 50 | |
205 | 51 | if (QString::fromLatin1(service) != QLatin1String(Q_MEDIASERVICE_CAMERA)) { | ||
206 | 52 | return deviceList; | ||
207 | 53 | } | ||
208 | 54 | |||
209 | 55 | // Devices are identified in android only by their index, so we do the same | ||
210 | 56 | int cameras = android_camera_get_number_of_devices(); | ||
211 | 57 | for (int deviceId = 0; deviceId < cameras; deviceId++) { | ||
212 | 58 | QString camera("%1"); | ||
213 | 59 | camera = camera.arg(deviceId); | ||
214 | 60 | deviceList.append(camera.toLatin1()); | ||
215 | 61 | } | ||
216 | 62 | |||
217 | 63 | return deviceList; | ||
218 | 47 | } | 64 | } |
219 | 48 | 65 | ||
220 | 49 | QString AalServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device) | 66 | QString AalServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device) |
221 | 50 | { | 67 | { |
225 | 51 | Q_UNUSED(service); | 68 | if (QString::fromLatin1(service) != QLatin1String(Q_MEDIASERVICE_CAMERA)) { |
226 | 52 | Q_UNUSED(device); | 69 | return QString(); |
227 | 53 | return QString(); | 70 | } |
228 | 71 | |||
229 | 72 | // Android does not provice a descriptive identifier for devices, so we just | ||
230 | 73 | // send back the index plus some useful human readable information about position. | ||
231 | 74 | bool ok; | ||
232 | 75 | int deviceID = device.toInt(&ok, 10); | ||
233 | 76 | if (!ok || deviceID >= android_camera_get_number_of_devices()) { | ||
234 | 77 | qWarning() << "Requested description for invalid device ID:" << device; | ||
235 | 78 | return QString(); | ||
236 | 79 | } else { | ||
237 | 80 | QCamera::Position position = cameraPosition(device); | ||
238 | 81 | return QString("Camera %1%2").arg(QLatin1String(device)) | ||
239 | 82 | .arg(position == QCamera::FrontFace ? " Front facing" : | ||
240 | 83 | (position == QCamera::BackFace ? " Back facing" : "")); | ||
241 | 84 | } | ||
242 | 85 | } | ||
243 | 86 | |||
244 | 87 | int AalServicePlugin::cameraOrientation(const QByteArray & device) const | ||
245 | 88 | { | ||
246 | 89 | int facing; | ||
247 | 90 | int orientation; | ||
248 | 91 | |||
249 | 92 | bool ok; | ||
250 | 93 | int deviceID = device.toInt(&ok, 10); | ||
251 | 94 | if (!ok) { | ||
252 | 95 | return 0; | ||
253 | 96 | } | ||
254 | 97 | |||
255 | 98 | int result = android_camera_get_device_info(deviceID, &facing, &orientation); | ||
256 | 99 | return (result != 0) ? 0 : orientation; | ||
257 | 100 | } | ||
258 | 101 | |||
259 | 102 | QCamera::Position AalServicePlugin::cameraPosition(const QByteArray & device) const | ||
260 | 103 | { | ||
261 | 104 | int facing; | ||
262 | 105 | int orientation; | ||
263 | 106 | |||
264 | 107 | bool ok; | ||
265 | 108 | int deviceID = device.toInt(&ok, 10); | ||
266 | 109 | if (!ok) { | ||
267 | 110 | return QCamera::UnspecifiedPosition; | ||
268 | 111 | } | ||
269 | 112 | |||
270 | 113 | int result = android_camera_get_device_info(deviceID, &facing, &orientation); | ||
271 | 114 | if (result != 0) { | ||
272 | 115 | return QCamera::UnspecifiedPosition; | ||
273 | 116 | } else { | ||
274 | 117 | return facing == BACK_FACING_CAMERA_TYPE ? QCamera::BackFace : | ||
275 | 118 | QCamera::FrontFace; | ||
276 | 119 | } | ||
277 | 54 | } | 120 | } |
278 | 55 | 121 | ||
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 | 20 | #include <QMediaServiceProviderPlugin> | 20 | #include <QMediaServiceProviderPlugin> |
284 | 21 | 21 | ||
285 | 22 | class AalServicePlugin : public QMediaServiceProviderPlugin, | 22 | class AalServicePlugin : public QMediaServiceProviderPlugin, |
287 | 23 | public QMediaServiceSupportedDevicesInterface | 23 | public QMediaServiceSupportedDevicesInterface, |
288 | 24 | public QMediaServiceCameraInfoInterface | ||
289 | 24 | { | 25 | { |
290 | 25 | Q_OBJECT | 26 | Q_OBJECT |
291 | 26 | Q_INTERFACES(QMediaServiceSupportedDevicesInterface) | 27 | Q_INTERFACES(QMediaServiceSupportedDevicesInterface) |
292 | 28 | Q_INTERFACES(QMediaServiceCameraInfoInterface) | ||
293 | 27 | Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "aalcamera.json") | 29 | Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "aalcamera.json") |
294 | 28 | 30 | ||
295 | 29 | public: | 31 | public: |
296 | @@ -34,6 +36,8 @@ | |||
297 | 34 | 36 | ||
298 | 35 | QList<QByteArray> devices(const QByteArray &service) const; | 37 | QList<QByteArray> devices(const QByteArray &service) const; |
299 | 36 | QString deviceDescription(const QByteArray &service, const QByteArray &device); | 38 | QString deviceDescription(const QByteArray &service, const QByteArray &device); |
300 | 39 | int cameraOrientation(const QByteArray & device) const; | ||
301 | 40 | QCamera::Position cameraPosition(const QByteArray & device) const; | ||
302 | 37 | }; | 41 | }; |
303 | 38 | 42 | ||
304 | 39 | #endif | 43 | #endif |
305 | 40 | 44 | ||
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 | 23 | 23 | ||
311 | 24 | #include <QDebug> | 24 | #include <QDebug> |
312 | 25 | #include <QtMultimedia/QCamera> | 25 | #include <QtMultimedia/QCamera> |
313 | 26 | #include <QtMultimedia/QCameraInfo> | ||
314 | 26 | 27 | ||
315 | 27 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> | 28 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> |
316 | 28 | 29 | ||
317 | @@ -41,28 +42,17 @@ | |||
318 | 41 | 42 | ||
319 | 42 | int AalVideoDeviceSelectorControl::deviceCount() const | 43 | int AalVideoDeviceSelectorControl::deviceCount() const |
320 | 43 | { | 44 | { |
325 | 44 | if (m_numberOfCameras < 0) | 45 | return QCameraInfo::availableCameras().count(); |
322 | 45 | m_numberOfCameras = android_camera_get_number_of_devices(); | ||
323 | 46 | |||
324 | 47 | return m_numberOfCameras; | ||
326 | 48 | } | 46 | } |
327 | 49 | 47 | ||
328 | 50 | QString AalVideoDeviceSelectorControl::deviceDescription(int index) const | 48 | QString AalVideoDeviceSelectorControl::deviceDescription(int index) const |
329 | 51 | { | 49 | { |
335 | 52 | switch (index) { | 50 | return QCameraInfo::availableCameras().value(index).description(); |
331 | 53 | case 0: return QLatin1String("Back camera"); | ||
332 | 54 | case 1: return QLatin1String("Front camera"); | ||
333 | 55 | default: return QLatin1String(""); | ||
334 | 56 | } | ||
336 | 57 | } | 51 | } |
337 | 58 | 52 | ||
338 | 59 | QString AalVideoDeviceSelectorControl::deviceName(int index) const | 53 | QString AalVideoDeviceSelectorControl::deviceName(int index) const |
339 | 60 | { | 54 | { |
345 | 61 | switch (index) { | 55 | return QCameraInfo::availableCameras().value(index).deviceName(); |
341 | 62 | case 0: return QLatin1String("Back"); | ||
342 | 63 | case 1: return QLatin1String("Front"); | ||
343 | 64 | default: return QLatin1String(""); | ||
344 | 65 | } | ||
346 | 66 | } | 56 | } |
347 | 67 | 57 | ||
348 | 68 | int AalVideoDeviceSelectorControl::selectedDevice() const | 58 | int AalVideoDeviceSelectorControl::selectedDevice() const |
349 | 69 | 59 | ||
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 | 29 | aalvideoencodersettingscontrol.h \ | 29 | aalvideoencodersettingscontrol.h \ |
355 | 30 | aalvideorenderercontrol.h \ | 30 | aalvideorenderercontrol.h \ |
356 | 31 | aalviewfindersettingscontrol.h \ | 31 | aalviewfindersettingscontrol.h \ |
357 | 32 | aalcamerainfocontrol.h \ | ||
358 | 32 | audiocapture.h \ | 33 | audiocapture.h \ |
359 | 33 | aalcameraexposurecontrol.h \ | 34 | aalcameraexposurecontrol.h \ |
360 | 34 | storagemanager.h | 35 | storagemanager.h |
361 | @@ -48,6 +49,7 @@ | |||
362 | 48 | aalvideoencodersettingscontrol.cpp \ | 49 | aalvideoencodersettingscontrol.cpp \ |
363 | 49 | aalvideorenderercontrol.cpp \ | 50 | aalvideorenderercontrol.cpp \ |
364 | 50 | aalviewfindersettingscontrol.cpp \ | 51 | aalviewfindersettingscontrol.cpp \ |
365 | 52 | aalcamerainfocontrol.cpp \ | ||
366 | 51 | audiocapture.cpp \ | 53 | audiocapture.cpp \ |
367 | 52 | aalcameraexposurecontrol.cpp \ | 54 | aalcameraexposurecontrol.cpp \ |
368 | 53 | storagemanager.cpp | 55 | storagemanager.cpp |
369 | 54 | 56 | ||
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 | 7 | LIBS += -L../mocks/aal -laal | 7 | LIBS += -L../mocks/aal -laal |
375 | 8 | INCLUDEPATH += ../../src | 8 | INCLUDEPATH += ../../src |
376 | 9 | INCLUDEPATH += ../mocks/aal | 9 | INCLUDEPATH += ../mocks/aal |
377 | 10 | INCLUDEPATH += ../stubs/ | ||
378 | 10 | 11 | ||
379 | 11 | HEADERS += ../../src/aalvideodeviceselectorcontrol.h \ | 12 | HEADERS += ../../src/aalvideodeviceselectorcontrol.h \ |
380 | 12 | ../../src/aalcameracontrol.h \ | 13 | ../../src/aalcameracontrol.h \ |
381 | 13 | ../../src/aalcameraservice.h \ | 14 | ../../src/aalcameraservice.h \ |
383 | 14 | ../../src/aalvideoencodersettingscontrol.h | 15 | ../../src/aalvideoencodersettingscontrol.h \ |
384 | 16 | ../stubs/qcamerainfodata.h | ||
385 | 15 | 17 | ||
386 | 16 | SOURCES += tst_aalvideodeviceselectorcontrol.cpp \ | 18 | SOURCES += tst_aalvideodeviceselectorcontrol.cpp \ |
387 | 17 | ../../src/aalvideodeviceselectorcontrol.cpp \ | 19 | ../../src/aalvideodeviceselectorcontrol.cpp \ |
388 | @@ -19,7 +21,9 @@ | |||
389 | 19 | aalimageencodercontrol.cpp \ | 21 | aalimageencodercontrol.cpp \ |
390 | 20 | aalviewfindersettingscontrol.cpp \ | 22 | aalviewfindersettingscontrol.cpp \ |
391 | 21 | ../stubs/aalcameracontrol_stub.cpp \ | 23 | ../stubs/aalcameracontrol_stub.cpp \ |
393 | 22 | ../stubs/aalvideoencodersettingscontrol_stub.cpp | 24 | ../stubs/aalvideoencodersettingscontrol_stub.cpp \ |
394 | 25 | ../stubs/qcamerainfo_stub.cpp \ | ||
395 | 26 | ../stubs/qcamerainfodata.cpp | ||
396 | 23 | 27 | ||
397 | 24 | check.depends = $${TARGET} | 28 | check.depends = $${TARGET} |
398 | 25 | check.commands = ./$${TARGET} | 29 | check.commands = ./$${TARGET} |
399 | 26 | 30 | ||
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 | 21 | 21 | ||
405 | 22 | #define private public | 22 | #define private public |
406 | 23 | #include "aalvideodeviceselectorcontrol.h" | 23 | #include "aalvideodeviceselectorcontrol.h" |
407 | 24 | #include "qcamerainfodata.h" | ||
408 | 24 | 25 | ||
409 | 25 | class tst_AalVideoDeviceSelectorControl : public QObject | 26 | class tst_AalVideoDeviceSelectorControl : public QObject |
410 | 26 | { | 27 | { |
411 | @@ -53,6 +54,10 @@ | |||
412 | 53 | QSignalSpy spy(m_selectControl, SIGNAL(selectedDeviceChanged(int))); | 54 | QSignalSpy spy(m_selectControl, SIGNAL(selectedDeviceChanged(int))); |
413 | 54 | QSignalSpy spy2(m_selectControl, SIGNAL(selectedDeviceChanged(QString))); | 55 | QSignalSpy spy2(m_selectControl, SIGNAL(selectedDeviceChanged(QString))); |
414 | 55 | 56 | ||
415 | 57 | QCameraInfoData::availableDevices.clear(); | ||
416 | 58 | QCameraInfoData::availableDevices.append(CameraInfo("0", "Camera 0")); | ||
417 | 59 | QCameraInfoData::availableDevices.append(CameraInfo("1", "Camera 1")); | ||
418 | 60 | |||
419 | 56 | m_selectControl->setSelectedDevice(1); | 61 | m_selectControl->setSelectedDevice(1); |
420 | 57 | 62 | ||
421 | 58 | QCOMPARE(m_selectControl->selectedDevice(), 1); | 63 | QCOMPARE(m_selectControl->selectedDevice(), 1); |
422 | 59 | 64 | ||
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 | 1 | /* | ||
428 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
429 | 3 | * | ||
430 | 4 | * This program is free software; you can redistribute it and/or modify | ||
431 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
432 | 6 | * the Free Software Foundation; version 3. | ||
433 | 7 | * | ||
434 | 8 | * This program is distributed in the hope that it will be useful, | ||
435 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
436 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
437 | 11 | * GNU Lesser General Public License for more details. | ||
438 | 12 | * | ||
439 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
440 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
441 | 15 | */ | ||
442 | 16 | |||
443 | 17 | #include <QtMultimedia/QCameraInfo> | ||
444 | 18 | #include "qcamerainfodata.h" | ||
445 | 19 | |||
446 | 20 | class QCameraInfoPrivate { | ||
447 | 21 | public: | ||
448 | 22 | QString deviceID; | ||
449 | 23 | QString description; | ||
450 | 24 | int orientation; | ||
451 | 25 | QCamera::Position position; | ||
452 | 26 | }; | ||
453 | 27 | |||
454 | 28 | QCameraInfo::QCameraInfo(const QByteArray &name) : d(new QCameraInfoPrivate()) | ||
455 | 29 | { | ||
456 | 30 | QStringList info = QString::fromLatin1(name).split('|'); | ||
457 | 31 | d->deviceID = info.at(0); | ||
458 | 32 | d->description = info.at(1); | ||
459 | 33 | d->orientation = info.at(2).toInt(); | ||
460 | 34 | d->position = QCamera::Position(info.at(3).toInt()); | ||
461 | 35 | } | ||
462 | 36 | |||
463 | 37 | QCameraInfo::QCameraInfo(const QCamera &camera) : d(new QCameraInfoPrivate()) { | ||
464 | 38 | Q_UNUSED(camera); | ||
465 | 39 | } | ||
466 | 40 | |||
467 | 41 | QCameraInfo::QCameraInfo(const QCameraInfo& other) : d(new QCameraInfoPrivate()) | ||
468 | 42 | { | ||
469 | 43 | d->deviceID = other.deviceName(); | ||
470 | 44 | d->description = other.description(); | ||
471 | 45 | d->orientation = other.orientation(); | ||
472 | 46 | d->position = other.position(); | ||
473 | 47 | } | ||
474 | 48 | QCameraInfo::~QCameraInfo() { } | ||
475 | 49 | |||
476 | 50 | QCameraInfo& QCameraInfo::operator=(const QCameraInfo& other) { | ||
477 | 51 | if (this != &other) { | ||
478 | 52 | d->deviceID = other.deviceName(); | ||
479 | 53 | d->description = other.description(); | ||
480 | 54 | d->orientation = other.orientation(); | ||
481 | 55 | d->position = other.position(); | ||
482 | 56 | } | ||
483 | 57 | return *this; | ||
484 | 58 | } | ||
485 | 59 | bool QCameraInfo::operator==(const QCameraInfo &other) const { Q_UNUSED(other); return false; } | ||
486 | 60 | |||
487 | 61 | bool QCameraInfo::isNull() const { return false; } | ||
488 | 62 | |||
489 | 63 | QString QCameraInfo::deviceName() const { return d->deviceID; } | ||
490 | 64 | QString QCameraInfo::description() const { return d->description; } | ||
491 | 65 | QCamera::Position QCameraInfo::position() const { return d->position; } | ||
492 | 66 | int QCameraInfo::orientation() const { return d->orientation; } | ||
493 | 67 | |||
494 | 68 | QCameraInfo QCameraInfo::defaultCamera() { return QCameraInfo(); } | ||
495 | 69 | QList<QCameraInfo> QCameraInfo::availableCameras(QCamera::Position position) { | ||
496 | 70 | Q_UNUSED(position); | ||
497 | 71 | |||
498 | 72 | QList<QCameraInfo> list; | ||
499 | 73 | Q_FOREACH(CameraInfo info, QCameraInfoData::availableDevices) { | ||
500 | 74 | QString infoString = QString("%1|%2|%3|%4").arg(info.deviceID).arg(info.description) | ||
501 | 75 | .arg(info.orientation).arg(info.position); | ||
502 | 76 | QCameraInfo camera(infoString.toLatin1()); | ||
503 | 77 | list.append(camera); | ||
504 | 78 | } | ||
505 | 79 | |||
506 | 80 | return list; | ||
507 | 81 | } | ||
508 | 0 | 82 | ||
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 | 1 | /* | ||
514 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
515 | 3 | * | ||
516 | 4 | * This program is free software; you can redistribute it and/or modify | ||
517 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
518 | 6 | * the Free Software Foundation; version 3. | ||
519 | 7 | * | ||
520 | 8 | * This program is distributed in the hope that it will be useful, | ||
521 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
522 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
523 | 11 | * GNU Lesser General Public License for more details. | ||
524 | 12 | * | ||
525 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
526 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
527 | 15 | */ | ||
528 | 16 | |||
529 | 17 | #include "qcamerainfodata.h" | ||
530 | 18 | |||
531 | 19 | QList<CameraInfo> QCameraInfoData::availableDevices = QList<CameraInfo>(); | ||
532 | 20 | |||
533 | 21 | CameraInfo::CameraInfo(QString deviceID, QString description, | ||
534 | 22 | int orientation, QCamera::Position position) : | ||
535 | 23 | deviceID(deviceID), | ||
536 | 24 | description(description), | ||
537 | 25 | orientation(orientation), | ||
538 | 26 | position(position) | ||
539 | 27 | { | ||
540 | 28 | } | ||
541 | 29 | |||
542 | 30 | |||
543 | 0 | 31 | ||
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 | 1 | /* | ||
549 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
550 | 3 | * | ||
551 | 4 | * This program is free software; you can redistribute it and/or modify | ||
552 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
553 | 6 | * the Free Software Foundation; version 3. | ||
554 | 7 | * | ||
555 | 8 | * This program is distributed in the hope that it will be useful, | ||
556 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
557 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
558 | 11 | * GNU Lesser General Public License for more details. | ||
559 | 12 | * | ||
560 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
561 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
562 | 15 | */ | ||
563 | 16 | |||
564 | 17 | #ifndef QCAMERAINFODATA_H | ||
565 | 18 | #define QCAMERAINFODATA_H | ||
566 | 19 | |||
567 | 20 | #include <QCamera> | ||
568 | 21 | |||
569 | 22 | class CameraInfo { | ||
570 | 23 | public: | ||
571 | 24 | CameraInfo(QString deviceID = QString(), QString description = QString(), | ||
572 | 25 | int orientation = 0, QCamera::Position position = QCamera::UnspecifiedPosition); | ||
573 | 26 | |||
574 | 27 | QString deviceID; | ||
575 | 28 | QString description; | ||
576 | 29 | int orientation; | ||
577 | 30 | QCamera::Position position; | ||
578 | 31 | }; | ||
579 | 32 | |||
580 | 33 | class QCameraInfoData | ||
581 | 34 | { | ||
582 | 35 | public: | ||
583 | 36 | static QList<CameraInfo> availableDevices; | ||
584 | 37 | }; | ||
585 | 38 | |||
586 | 39 | #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://