Merge lp:~fboucault/qtubuntu-camera/hdr_scene_mode into lp:qtubuntu-camera
- hdr_scene_mode
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Jim Hodapp |
Approved revision: | 104 |
Merged at revision: | 96 |
Proposed branch: | lp:~fboucault/qtubuntu-camera/hdr_scene_mode |
Merge into: | lp:qtubuntu-camera |
Diff against target: |
585 lines (+413/-4) 12 files modified
src/aalcameraexposurecontrol.cpp (+141/-0) src/aalcameraexposurecontrol.h (+52/-0) src/aalcameraservice.cpp (+7/-0) src/aalcameraservice.h (+3/-0) src/src.pro (+2/-0) unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro (+20/-0) unittests/aalcameraexposurecontrol/aalcameraservice.cpp (+76/-0) unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp (+96/-0) unittests/mocks/aal/camera_compatibility_layer.cpp (+10/-2) unittests/mocks/aal/camera_compatibility_layer_capabilities.h (+4/-1) unittests/mocks/aal/media_recorder_layer.cpp (+1/-1) unittests/unittests.pro (+1/-0) |
To merge this branch: | bzr merge lp:~fboucault/qtubuntu-camera/hdr_scene_mode |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jim Hodapp (community) | code | Approve | |
PS Jenkins bot | continuous-integration | Approve | |
Review via email:
|
Commit message
Expose scene modes through a custom QCameraExposure
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Florian Boucault (fboucault) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:94
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:95
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:96
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:97
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Florian Boucault (fboucault) wrote : | # |
Good to go apart from that we need to define a better enum value for HDR than QCameraExposure
Build will be green when relevant libhybris patch lands.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Florian Boucault (fboucault) wrote : | # |
Patch in libhybris is at: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:98
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:99
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:100
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : | # |
The main code looks great, I'd like to see some tests for the logic of setting the exposure mode and making sure the appropriate signals are emitted when expected.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : | # |
By tests, I mean unit tests
- 102. By Florian Boucault
-
Empty commit
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:102
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 103. By Florian Boucault
-
Fix unit test.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:103
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 104. By Florian Boucault
-
Properly fixed unit tests.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:104
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : | # |
Looks great, thanks
Preview Diff
1 | === added file 'src/aalcameraexposurecontrol.cpp' | |||
2 | --- src/aalcameraexposurecontrol.cpp 1970-01-01 00:00:00 +0000 | |||
3 | +++ src/aalcameraexposurecontrol.cpp 2014-07-15 12:39:22 +0000 | |||
4 | @@ -0,0 +1,141 @@ | |||
5 | 1 | /* | ||
6 | 2 | * Copyright (C) 2014 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 "aalcameraexposurecontrol.h" | ||
22 | 18 | #include "aalcameracontrol.h" | ||
23 | 19 | #include "aalcameraservice.h" | ||
24 | 20 | |||
25 | 21 | #include <hybris/camera/camera_compatibility_layer.h> | ||
26 | 22 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> | ||
27 | 23 | |||
28 | 24 | // Definition of this enum value is duplicated in camera-app | ||
29 | 25 | static const QCameraExposure::ExposureMode ExposureHdr = static_cast<QCameraExposure::ExposureMode>(QCameraExposure::ExposureModeVendor + 1); | ||
30 | 26 | |||
31 | 27 | AalCameraExposureControl::AalCameraExposureControl(AalCameraService *service, QObject *parent) | ||
32 | 28 | : QCameraExposureControl(parent), | ||
33 | 29 | m_service(service), | ||
34 | 30 | m_requestedExposureMode(QCameraExposure::ExposureAuto), | ||
35 | 31 | m_actualExposureMode(QCameraExposure::ExposureAuto) | ||
36 | 32 | { | ||
37 | 33 | m_androidToQtExposureModes[SCENE_MODE_AUTO] = QCameraExposure::ExposureAuto; | ||
38 | 34 | m_androidToQtExposureModes[SCENE_MODE_ACTION] = QCameraExposure::ExposureSports; | ||
39 | 35 | m_androidToQtExposureModes[SCENE_MODE_NIGHT] = QCameraExposure::ExposureNight; | ||
40 | 36 | m_androidToQtExposureModes[SCENE_MODE_PARTY] = QCameraExposure::ExposureAuto; // FIXME: no correspondance | ||
41 | 37 | m_androidToQtExposureModes[SCENE_MODE_SUNSET] = QCameraExposure::ExposureAuto; // FIXME: no correspondance | ||
42 | 38 | m_androidToQtExposureModes[SCENE_MODE_HDR] = ExposureHdr; | ||
43 | 39 | } | ||
44 | 40 | |||
45 | 41 | void AalCameraExposureControl::init(CameraControl *control, CameraControlListener *listener) | ||
46 | 42 | { | ||
47 | 43 | Q_UNUSED(listener); | ||
48 | 44 | |||
49 | 45 | m_requestedExposureMode = QCameraExposure::ExposureAuto; | ||
50 | 46 | m_actualExposureMode = QCameraExposure::ExposureAuto; | ||
51 | 47 | |||
52 | 48 | m_supportedExposureModes.clear(); | ||
53 | 49 | android_camera_enumerate_supported_scene_modes(control, &AalCameraExposureControl::supportedSceneModesCallback, this); | ||
54 | 50 | |||
55 | 51 | Q_EMIT requestedValueChanged(QCameraExposureControl::ExposureMode); | ||
56 | 52 | Q_EMIT actualValueChanged(QCameraExposureControl::ExposureMode); | ||
57 | 53 | Q_EMIT parameterRangeChanged(QCameraExposureControl::ExposureMode); | ||
58 | 54 | } | ||
59 | 55 | |||
60 | 56 | void AalCameraExposureControl::supportedSceneModesCallback(void *context, SceneMode sceneMode) | ||
61 | 57 | { | ||
62 | 58 | AalCameraExposureControl *self = (AalCameraExposureControl*)context; | ||
63 | 59 | self->m_supportedExposureModes << QVariant::fromValue(self->m_androidToQtExposureModes[sceneMode]); | ||
64 | 60 | } | ||
65 | 61 | |||
66 | 62 | bool AalCameraExposureControl::setValue(ExposureParameter parameter, const QVariant& value) | ||
67 | 63 | { | ||
68 | 64 | if (!value.isValid()) { | ||
69 | 65 | return false; | ||
70 | 66 | } | ||
71 | 67 | |||
72 | 68 | if (parameter == QCameraExposureControl::ExposureMode) { | ||
73 | 69 | m_requestedExposureMode = value.value<QCameraExposure::ExposureMode>(); | ||
74 | 70 | Q_EMIT requestedValueChanged(QCameraExposureControl::ExposureMode); | ||
75 | 71 | |||
76 | 72 | if (m_supportedExposureModes.contains(value)) { | ||
77 | 73 | SceneMode sceneMode = m_androidToQtExposureModes.key(m_requestedExposureMode); | ||
78 | 74 | android_camera_set_scene_mode(m_service->androidControl(), sceneMode); | ||
79 | 75 | m_actualExposureMode = m_requestedExposureMode; | ||
80 | 76 | Q_EMIT actualValueChanged(QCameraExposureControl::ExposureMode); | ||
81 | 77 | return true; | ||
82 | 78 | } | ||
83 | 79 | } | ||
84 | 80 | |||
85 | 81 | return false; | ||
86 | 82 | } | ||
87 | 83 | |||
88 | 84 | QVariant AalCameraExposureControl::requestedValue(ExposureParameter parameter) const | ||
89 | 85 | { | ||
90 | 86 | if (parameter == QCameraExposureControl::ExposureMode) { | ||
91 | 87 | return QVariant::fromValue(m_requestedExposureMode); | ||
92 | 88 | } | ||
93 | 89 | |||
94 | 90 | return QVariant(); | ||
95 | 91 | } | ||
96 | 92 | |||
97 | 93 | QVariant AalCameraExposureControl::actualValue(ExposureParameter parameter) const | ||
98 | 94 | { | ||
99 | 95 | if (parameter == QCameraExposureControl::ExposureMode) { | ||
100 | 96 | return QVariant::fromValue(m_actualExposureMode); | ||
101 | 97 | } | ||
102 | 98 | |||
103 | 99 | return QVariant(); | ||
104 | 100 | } | ||
105 | 101 | |||
106 | 102 | bool AalCameraExposureControl::isParameterSupported(ExposureParameter parameter) const | ||
107 | 103 | { | ||
108 | 104 | switch (parameter) { | ||
109 | 105 | case QCameraExposureControl::ISO: | ||
110 | 106 | return false; | ||
111 | 107 | case QCameraExposureControl::Aperture: | ||
112 | 108 | return false; | ||
113 | 109 | case QCameraExposureControl::ShutterSpeed: | ||
114 | 110 | return false; | ||
115 | 111 | case QCameraExposureControl::ExposureCompensation: | ||
116 | 112 | return false; | ||
117 | 113 | case QCameraExposureControl::FlashPower: | ||
118 | 114 | return false; | ||
119 | 115 | case QCameraExposureControl::FlashCompensation: | ||
120 | 116 | return false; | ||
121 | 117 | case QCameraExposureControl::TorchPower: | ||
122 | 118 | return false; | ||
123 | 119 | case QCameraExposureControl::SpotMeteringPoint: | ||
124 | 120 | return false; | ||
125 | 121 | case QCameraExposureControl::ExposureMode: | ||
126 | 122 | return true; | ||
127 | 123 | case QCameraExposureControl::MeteringMode: | ||
128 | 124 | return false; | ||
129 | 125 | default: | ||
130 | 126 | return false; | ||
131 | 127 | } | ||
132 | 128 | } | ||
133 | 129 | |||
134 | 130 | QVariantList AalCameraExposureControl::supportedParameterRange(ExposureParameter parameter, bool *continuous) const | ||
135 | 131 | { | ||
136 | 132 | if (continuous != NULL) { | ||
137 | 133 | *continuous = false; | ||
138 | 134 | } | ||
139 | 135 | |||
140 | 136 | if (parameter == QCameraExposureControl::ExposureMode) { | ||
141 | 137 | return m_supportedExposureModes; | ||
142 | 138 | } | ||
143 | 139 | |||
144 | 140 | return QVariantList(); | ||
145 | 141 | } | ||
146 | 0 | 142 | ||
147 | === added file 'src/aalcameraexposurecontrol.h' | |||
148 | --- src/aalcameraexposurecontrol.h 1970-01-01 00:00:00 +0000 | |||
149 | +++ src/aalcameraexposurecontrol.h 2014-07-15 12:39:22 +0000 | |||
150 | @@ -0,0 +1,52 @@ | |||
151 | 1 | /* | ||
152 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
153 | 3 | * | ||
154 | 4 | * This program is free software; you can redistribute it and/or modify | ||
155 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
156 | 6 | * the Free Software Foundation; version 3. | ||
157 | 7 | * | ||
158 | 8 | * This program is distributed in the hope that it will be useful, | ||
159 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
160 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
161 | 11 | * GNU Lesser General Public License for more details. | ||
162 | 12 | * | ||
163 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
164 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
165 | 15 | */ | ||
166 | 16 | |||
167 | 17 | #ifndef AALCAMERAEXPOSURECONTROL_H | ||
168 | 18 | #define AALCAMERAEXPOSURECONTROL_H | ||
169 | 19 | |||
170 | 20 | #include <QtCore/QMap> | ||
171 | 21 | #include <QCameraExposureControl> | ||
172 | 22 | |||
173 | 23 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> | ||
174 | 24 | |||
175 | 25 | class AalCameraService; | ||
176 | 26 | class CameraControl; | ||
177 | 27 | class CameraControlListener; | ||
178 | 28 | |||
179 | 29 | class AalCameraExposureControl : public QCameraExposureControl | ||
180 | 30 | { | ||
181 | 31 | Q_OBJECT | ||
182 | 32 | public: | ||
183 | 33 | explicit AalCameraExposureControl(AalCameraService *service, QObject *parent = 0); | ||
184 | 34 | |||
185 | 35 | void init(CameraControl *control, CameraControlListener *listener); | ||
186 | 36 | bool setValue(ExposureParameter parameter, const QVariant& value); | ||
187 | 37 | QVariant requestedValue(ExposureParameter parameter) const; | ||
188 | 38 | QVariant actualValue(ExposureParameter parameter) const; | ||
189 | 39 | bool isParameterSupported(ExposureParameter parameter) const; | ||
190 | 40 | QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const; | ||
191 | 41 | |||
192 | 42 | static void supportedSceneModesCallback(void *context, SceneMode sceneMode); | ||
193 | 43 | |||
194 | 44 | private: | ||
195 | 45 | QMap<SceneMode, QCameraExposure::ExposureMode> m_androidToQtExposureModes; | ||
196 | 46 | AalCameraService *m_service; | ||
197 | 47 | QVariantList m_supportedExposureModes; | ||
198 | 48 | QCameraExposure::ExposureMode m_requestedExposureMode; | ||
199 | 49 | QCameraExposure::ExposureMode m_actualExposureMode; | ||
200 | 50 | }; | ||
201 | 51 | |||
202 | 52 | #endif // AALCAMERAEXPOSURECONTROL_H | ||
203 | 0 | 53 | ||
204 | === modified file 'src/aalcameraservice.cpp' | |||
205 | --- src/aalcameraservice.cpp 2013-08-01 10:41:04 +0000 | |||
206 | +++ src/aalcameraservice.cpp 2014-07-15 12:39:22 +0000 | |||
207 | @@ -27,6 +27,7 @@ | |||
208 | 27 | #include "aalvideoencodersettingscontrol.h" | 27 | #include "aalvideoencodersettingscontrol.h" |
209 | 28 | #include "aalvideorenderercontrol.h" | 28 | #include "aalvideorenderercontrol.h" |
210 | 29 | #include "aalviewfindersettingscontrol.h" | 29 | #include "aalviewfindersettingscontrol.h" |
211 | 30 | #include "aalcameraexposurecontrol.h" | ||
212 | 30 | #include <storagemanager.h> | 31 | #include <storagemanager.h> |
213 | 31 | 32 | ||
214 | 32 | #include <hybris/camera/camera_compatibility_layer.h> | 33 | #include <hybris/camera/camera_compatibility_layer.h> |
215 | @@ -56,6 +57,7 @@ | |||
216 | 56 | m_videoEncoderControl = new AalVideoEncoderSettingsControl(this); | 57 | m_videoEncoderControl = new AalVideoEncoderSettingsControl(this); |
217 | 57 | m_videoOutput = new AalVideoRendererControl(this); | 58 | m_videoOutput = new AalVideoRendererControl(this); |
218 | 58 | m_viewfinderControl = new AalViewfinderSettingsControl(this); | 59 | m_viewfinderControl = new AalViewfinderSettingsControl(this); |
219 | 60 | m_exposureControl = new AalCameraExposureControl(this); | ||
220 | 59 | } | 61 | } |
221 | 60 | 62 | ||
222 | 61 | AalCameraService::~AalCameraService() | 63 | AalCameraService::~AalCameraService() |
223 | @@ -74,6 +76,7 @@ | |||
224 | 74 | delete m_videoEncoderControl; | 76 | delete m_videoEncoderControl; |
225 | 75 | delete m_videoOutput; | 77 | delete m_videoOutput; |
226 | 76 | delete m_viewfinderControl; | 78 | delete m_viewfinderControl; |
227 | 79 | delete m_exposureControl; | ||
228 | 77 | if (m_oldAndroidControl) | 80 | if (m_oldAndroidControl) |
229 | 78 | android_camera_delete(m_oldAndroidControl); | 81 | android_camera_delete(m_oldAndroidControl); |
230 | 79 | if (m_androidControl) | 82 | if (m_androidControl) |
231 | @@ -119,6 +122,9 @@ | |||
232 | 119 | if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0) | 122 | if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0) |
233 | 120 | return m_viewfinderControl; | 123 | return m_viewfinderControl; |
234 | 121 | 124 | ||
235 | 125 | if (qstrcmp(name, QCameraExposureControl_iid) == 0) | ||
236 | 126 | return m_exposureControl; | ||
237 | 127 | |||
238 | 122 | return 0; | 128 | return 0; |
239 | 123 | } | 129 | } |
240 | 124 | 130 | ||
241 | @@ -285,4 +291,5 @@ | |||
242 | 285 | m_viewfinderControl->setAspectRatio(m_videoEncoderControl->getAspectRatio()); | 291 | m_viewfinderControl->setAspectRatio(m_videoEncoderControl->getAspectRatio()); |
243 | 286 | m_viewfinderControl->init(camControl, listener); | 292 | m_viewfinderControl->init(camControl, listener); |
244 | 287 | m_videoOutput->init(camControl, listener); | 293 | m_videoOutput->init(camControl, listener); |
245 | 294 | m_exposureControl->init(camControl, listener); | ||
246 | 288 | } | 295 | } |
247 | 289 | 296 | ||
248 | === modified file 'src/aalcameraservice.h' | |||
249 | --- src/aalcameraservice.h 2013-08-01 10:41:04 +0000 | |||
250 | +++ src/aalcameraservice.h 2014-07-15 12:39:22 +0000 | |||
251 | @@ -31,6 +31,7 @@ | |||
252 | 31 | class AalVideoEncoderSettingsControl; | 31 | class AalVideoEncoderSettingsControl; |
253 | 32 | class AalVideoRendererControl; | 32 | class AalVideoRendererControl; |
254 | 33 | class AalViewfinderSettingsControl; | 33 | class AalViewfinderSettingsControl; |
255 | 34 | class AalCameraExposureControl; | ||
256 | 34 | class QCameraControl; | 35 | class QCameraControl; |
257 | 35 | 36 | ||
258 | 36 | struct CameraControl; | 37 | struct CameraControl; |
259 | @@ -60,6 +61,7 @@ | |||
260 | 60 | AalVideoEncoderSettingsControl *videoEncoderControl() const { return m_videoEncoderControl; } | 61 | AalVideoEncoderSettingsControl *videoEncoderControl() const { return m_videoEncoderControl; } |
261 | 61 | AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; } | 62 | AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; } |
262 | 62 | AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; } | 63 | AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; } |
263 | 64 | AalCameraExposureControl *exposureControl() const { return m_exposureControl; } | ||
264 | 63 | 65 | ||
265 | 64 | CameraControl *androidControl(); | 66 | CameraControl *androidControl(); |
266 | 65 | 67 | ||
267 | @@ -99,6 +101,7 @@ | |||
268 | 99 | AalVideoEncoderSettingsControl *m_videoEncoderControl; | 101 | AalVideoEncoderSettingsControl *m_videoEncoderControl; |
269 | 100 | AalVideoRendererControl *m_videoOutput; | 102 | AalVideoRendererControl *m_videoOutput; |
270 | 101 | AalViewfinderSettingsControl *m_viewfinderControl; | 103 | AalViewfinderSettingsControl *m_viewfinderControl; |
271 | 104 | AalCameraExposureControl *m_exposureControl; | ||
272 | 102 | 105 | ||
273 | 103 | CameraControl *m_androidControl; | 106 | CameraControl *m_androidControl; |
274 | 104 | CameraControlListener *m_androidListener; | 107 | CameraControlListener *m_androidListener; |
275 | 105 | 108 | ||
276 | === modified file 'src/src.pro' | |||
277 | --- src/src.pro 2014-01-16 14:20:08 +0000 | |||
278 | +++ src/src.pro 2014-07-15 12:39:22 +0000 | |||
279 | @@ -33,6 +33,7 @@ | |||
280 | 33 | aalvideoencodersettingscontrol.h \ | 33 | aalvideoencodersettingscontrol.h \ |
281 | 34 | aalvideorenderercontrol.h \ | 34 | aalvideorenderercontrol.h \ |
282 | 35 | aalviewfindersettingscontrol.h \ | 35 | aalviewfindersettingscontrol.h \ |
283 | 36 | aalcameraexposurecontrol.h \ | ||
284 | 36 | storagemanager.h | 37 | storagemanager.h |
285 | 37 | 38 | ||
286 | 38 | SOURCES += \ | 39 | SOURCES += \ |
287 | @@ -50,4 +51,5 @@ | |||
288 | 50 | aalvideoencodersettingscontrol.cpp \ | 51 | aalvideoencodersettingscontrol.cpp \ |
289 | 51 | aalvideorenderercontrol.cpp \ | 52 | aalvideorenderercontrol.cpp \ |
290 | 52 | aalviewfindersettingscontrol.cpp \ | 53 | aalviewfindersettingscontrol.cpp \ |
291 | 54 | aalcameraexposurecontrol.cpp \ | ||
292 | 53 | storagemanager.cpp | 55 | storagemanager.cpp |
293 | 54 | 56 | ||
294 | === added directory 'unittests/aalcameraexposurecontrol' | |||
295 | === added file 'unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro' | |||
296 | --- unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro 1970-01-01 00:00:00 +0000 | |||
297 | +++ unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro 2014-07-15 12:39:22 +0000 | |||
298 | @@ -0,0 +1,20 @@ | |||
299 | 1 | include(../../coverage.pri) | ||
300 | 2 | |||
301 | 3 | TARGET = tst_aalcameraexposurecontrol | ||
302 | 4 | |||
303 | 5 | QT += testlib multimedia opengl | ||
304 | 6 | |||
305 | 7 | LIBS += -L../mocks/aal -laal | ||
306 | 8 | INCLUDEPATH += ../../src | ||
307 | 9 | INCLUDEPATH += ../mocks/aal | ||
308 | 10 | |||
309 | 11 | HEADERS += ../../src/aalcameraexposurecontrol.h \ | ||
310 | 12 | ../../src/aalcameraservice.h | ||
311 | 13 | |||
312 | 14 | SOURCES += tst_aalcameraexposurecontrol.cpp \ | ||
313 | 15 | ../../src/aalcameraexposurecontrol.cpp \ | ||
314 | 16 | aalcameraservice.cpp | ||
315 | 17 | |||
316 | 18 | check.depends = $${TARGET} | ||
317 | 19 | check.commands = ./$${TARGET} | ||
318 | 20 | QMAKE_EXTRA_TARGETS += check | ||
319 | 0 | 21 | ||
320 | === added file 'unittests/aalcameraexposurecontrol/aalcameraservice.cpp' | |||
321 | --- unittests/aalcameraexposurecontrol/aalcameraservice.cpp 1970-01-01 00:00:00 +0000 | |||
322 | +++ unittests/aalcameraexposurecontrol/aalcameraservice.cpp 2014-07-15 12:39:22 +0000 | |||
323 | @@ -0,0 +1,76 @@ | |||
324 | 1 | /* | ||
325 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
326 | 3 | * | ||
327 | 4 | * This program is free software; you can redistribute it and/or modify | ||
328 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
329 | 6 | * the Free Software Foundation; version 3. | ||
330 | 7 | * | ||
331 | 8 | * This program is distributed in the hope that it will be useful, | ||
332 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
333 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
334 | 11 | * GNU Lesser General Public License for more details. | ||
335 | 12 | * | ||
336 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
337 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
338 | 15 | */ | ||
339 | 16 | |||
340 | 17 | #include "aalcameraservice.h" | ||
341 | 18 | #include "aalcameraexposurecontrol.h" | ||
342 | 19 | #include "camera_control.h" | ||
343 | 20 | #include "camera_compatibility_layer.h" | ||
344 | 21 | |||
345 | 22 | AalCameraService *AalCameraService::m_service = 0; | ||
346 | 23 | |||
347 | 24 | AalCameraService::AalCameraService(QObject *parent) : | ||
348 | 25 | QMediaService(parent), | ||
349 | 26 | m_androidControl(0), | ||
350 | 27 | m_androidListener(0) | ||
351 | 28 | { | ||
352 | 29 | m_exposureControl = new AalCameraExposureControl(this); | ||
353 | 30 | } | ||
354 | 31 | |||
355 | 32 | AalCameraService::~AalCameraService() | ||
356 | 33 | { | ||
357 | 34 | delete m_exposureControl; | ||
358 | 35 | } | ||
359 | 36 | |||
360 | 37 | QMediaControl *AalCameraService::requestControl(const char *name) | ||
361 | 38 | { | ||
362 | 39 | Q_UNUSED(name); | ||
363 | 40 | return 0; | ||
364 | 41 | } | ||
365 | 42 | |||
366 | 43 | void AalCameraService::releaseControl(QMediaControl *control) | ||
367 | 44 | { | ||
368 | 45 | Q_UNUSED(control); | ||
369 | 46 | } | ||
370 | 47 | |||
371 | 48 | CameraControl *AalCameraService::androidControl() | ||
372 | 49 | { | ||
373 | 50 | return m_androidControl; | ||
374 | 51 | } | ||
375 | 52 | |||
376 | 53 | bool AalCameraService::connectCamera() | ||
377 | 54 | { | ||
378 | 55 | m_androidListener = new CameraControlListener; | ||
379 | 56 | m_androidControl = android_camera_connect_to(BACK_FACING_CAMERA_TYPE, m_androidListener); | ||
380 | 57 | |||
381 | 58 | initControls(m_androidControl, m_androidListener); | ||
382 | 59 | |||
383 | 60 | return true; | ||
384 | 61 | } | ||
385 | 62 | |||
386 | 63 | void AalCameraService::disconnectCamera() | ||
387 | 64 | { | ||
388 | 65 | delete m_androidListener; | ||
389 | 66 | android_camera_disconnect(m_androidControl); | ||
390 | 67 | } | ||
391 | 68 | |||
392 | 69 | void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener) | ||
393 | 70 | { | ||
394 | 71 | m_exposureControl->init(camControl, listener); | ||
395 | 72 | } | ||
396 | 73 | |||
397 | 74 | void AalCameraService::updateCaptureReady() | ||
398 | 75 | { | ||
399 | 76 | } | ||
400 | 0 | 77 | ||
401 | === added file 'unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp' | |||
402 | --- unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp 1970-01-01 00:00:00 +0000 | |||
403 | +++ unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp 2014-07-15 12:39:22 +0000 | |||
404 | @@ -0,0 +1,96 @@ | |||
405 | 1 | /* | ||
406 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
407 | 3 | * | ||
408 | 4 | * This program is free software; you can redistribute it and/or modify | ||
409 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
410 | 6 | * the Free Software Foundation; version 3. | ||
411 | 7 | * | ||
412 | 8 | * This program is distributed in the hope that it will be useful, | ||
413 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
414 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
415 | 11 | * GNU Lesser General Public License for more details. | ||
416 | 12 | * | ||
417 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
418 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
419 | 15 | */ | ||
420 | 16 | |||
421 | 17 | #include <QtTest/QtTest> | ||
422 | 18 | #include <QSignalSpy> | ||
423 | 19 | |||
424 | 20 | #include "aalcameraservice.h" | ||
425 | 21 | |||
426 | 22 | #define private public | ||
427 | 23 | #include "aalcameraexposurecontrol.h" | ||
428 | 24 | |||
429 | 25 | class tst_AalCameraExposureControl : public QObject | ||
430 | 26 | { | ||
431 | 27 | Q_OBJECT | ||
432 | 28 | private slots: | ||
433 | 29 | void initTestCase(); | ||
434 | 30 | void cleanupTestCase(); | ||
435 | 31 | |||
436 | 32 | void setUnsupportedParameter(); | ||
437 | 33 | void setExposureMode(); | ||
438 | 34 | |||
439 | 35 | private: | ||
440 | 36 | AalCameraExposureControl *m_exposureControl; | ||
441 | 37 | AalCameraService *m_service; | ||
442 | 38 | }; | ||
443 | 39 | |||
444 | 40 | void tst_AalCameraExposureControl::initTestCase() | ||
445 | 41 | { | ||
446 | 42 | m_service = new AalCameraService(); | ||
447 | 43 | m_exposureControl = m_service->exposureControl(); | ||
448 | 44 | m_service->connectCamera(); | ||
449 | 45 | } | ||
450 | 46 | |||
451 | 47 | void tst_AalCameraExposureControl::cleanupTestCase() | ||
452 | 48 | { | ||
453 | 49 | delete m_service; | ||
454 | 50 | } | ||
455 | 51 | |||
456 | 52 | void tst_AalCameraExposureControl::setUnsupportedParameter() | ||
457 | 53 | { | ||
458 | 54 | QCameraExposureControl::ExposureParameter parameter = QCameraExposureControl::ISO; | ||
459 | 55 | |||
460 | 56 | QSignalSpy spyActual(m_exposureControl, SIGNAL(actualValueChanged(int))); | ||
461 | 57 | QSignalSpy spyRequested(m_exposureControl, SIGNAL(requestedValueChanged(int))); | ||
462 | 58 | |||
463 | 59 | bool supported = m_exposureControl->isParameterSupported(parameter); | ||
464 | 60 | bool valid = m_exposureControl->setValue(parameter, QVariant::fromValue(200)); | ||
465 | 61 | QVariant requestedValue = m_exposureControl->requestedValue(parameter); | ||
466 | 62 | QVariant actualValue = m_exposureControl->actualValue(parameter); | ||
467 | 63 | |||
468 | 64 | QVERIFY(!supported); | ||
469 | 65 | QVERIFY(!valid); | ||
470 | 66 | QCOMPARE(requestedValue, QVariant()); | ||
471 | 67 | QCOMPARE(actualValue, QVariant()); | ||
472 | 68 | |||
473 | 69 | QCOMPARE(spyActual.count(), 0); | ||
474 | 70 | QCOMPARE(spyRequested.count(), 0); | ||
475 | 71 | } | ||
476 | 72 | |||
477 | 73 | void tst_AalCameraExposureControl::setExposureMode() | ||
478 | 74 | { | ||
479 | 75 | QCameraExposureControl::ExposureParameter parameter = QCameraExposureControl::ExposureMode; | ||
480 | 76 | |||
481 | 77 | QSignalSpy spyActual(m_exposureControl, SIGNAL(actualValueChanged(int))); | ||
482 | 78 | QSignalSpy spyRequested(m_exposureControl, SIGNAL(requestedValueChanged(int))); | ||
483 | 79 | |||
484 | 80 | bool supported = m_exposureControl->isParameterSupported(parameter); | ||
485 | 81 | bool valid = m_exposureControl->setValue(parameter, QVariant::fromValue(QCameraExposure::ExposureSports)); | ||
486 | 82 | QVariant requestedValue = m_exposureControl->requestedValue(parameter); | ||
487 | 83 | QVariant actualValue = m_exposureControl->actualValue(parameter); | ||
488 | 84 | |||
489 | 85 | QVERIFY(supported); | ||
490 | 86 | QVERIFY(valid); | ||
491 | 87 | QCOMPARE(requestedValue, QVariant::fromValue(QCameraExposure::ExposureSports)); | ||
492 | 88 | QCOMPARE(actualValue, QVariant::fromValue(QCameraExposure::ExposureSports)); | ||
493 | 89 | |||
494 | 90 | QCOMPARE(spyActual.count(), 1); | ||
495 | 91 | QCOMPARE(spyRequested.count(), 1); | ||
496 | 92 | } | ||
497 | 93 | |||
498 | 94 | QTEST_MAIN(tst_AalCameraExposureControl) | ||
499 | 95 | |||
500 | 96 | #include "tst_aalcameraexposurecontrol.moc" | ||
501 | 0 | 97 | ||
502 | === modified file 'unittests/mocks/aal/camera_compatibility_layer.cpp' | |||
503 | --- unittests/mocks/aal/camera_compatibility_layer.cpp 2013-06-07 08:54:10 +0000 | |||
504 | +++ unittests/mocks/aal/camera_compatibility_layer.cpp 2014-07-15 12:39:22 +0000 | |||
505 | @@ -16,8 +16,8 @@ | |||
506 | 16 | * Authored by: Thomas Voss <thomas.voss@canonical.com> | 16 | * Authored by: Thomas Voss <thomas.voss@canonical.com> |
507 | 17 | */ | 17 | */ |
508 | 18 | 18 | ||
511 | 19 | #include <hybris/camera/camera_compatibility_layer.h> | 19 | #include "camera_compatibility_layer.h" |
512 | 20 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> | 20 | #include "camera_compatibility_layer_capabilities.h" |
513 | 21 | 21 | ||
514 | 22 | #include "camera_control.h" | 22 | #include "camera_control.h" |
515 | 23 | 23 | ||
516 | @@ -95,6 +95,14 @@ | |||
517 | 95 | crashTest(control); | 95 | crashTest(control); |
518 | 96 | } | 96 | } |
519 | 97 | 97 | ||
520 | 98 | void android_camera_enumerate_supported_scene_modes(CameraControl* control, scene_mode_callback cb, void* ctx) | ||
521 | 99 | { | ||
522 | 100 | Q_UNUSED(cb); | ||
523 | 101 | Q_UNUSED(ctx); | ||
524 | 102 | crashTest(control); | ||
525 | 103 | cb(ctx, SCENE_MODE_ACTION); | ||
526 | 104 | } | ||
527 | 105 | |||
528 | 98 | void android_camera_set_scene_mode(CameraControl* control, SceneMode mode) | 106 | void android_camera_set_scene_mode(CameraControl* control, SceneMode mode) |
529 | 99 | { | 107 | { |
530 | 100 | Q_UNUSED(mode); | 108 | Q_UNUSED(mode); |
531 | 101 | 109 | ||
532 | === modified file 'unittests/mocks/aal/camera_compatibility_layer_capabilities.h' | |||
533 | --- unittests/mocks/aal/camera_compatibility_layer_capabilities.h 2013-02-11 15:56:21 +0000 | |||
534 | +++ unittests/mocks/aal/camera_compatibility_layer_capabilities.h 2014-07-15 12:39:22 +0000 | |||
535 | @@ -48,7 +48,8 @@ | |||
536 | 48 | SCENE_MODE_ACTION, | 48 | SCENE_MODE_ACTION, |
537 | 49 | SCENE_MODE_NIGHT, | 49 | SCENE_MODE_NIGHT, |
538 | 50 | SCENE_MODE_PARTY, | 50 | SCENE_MODE_PARTY, |
540 | 51 | SCENE_MODE_SUNSET | 51 | SCENE_MODE_SUNSET, |
541 | 52 | SCENE_MODE_HDR | ||
542 | 52 | } SceneMode; | 53 | } SceneMode; |
543 | 53 | 54 | ||
544 | 54 | typedef enum | 55 | typedef enum |
545 | @@ -95,6 +96,7 @@ | |||
546 | 95 | } FocusRegion; | 96 | } FocusRegion; |
547 | 96 | 97 | ||
548 | 97 | typedef void (*size_callback)(void* ctx, int width, int height); | 98 | typedef void (*size_callback)(void* ctx, int width, int height); |
549 | 99 | typedef void (*scene_mode_callback)(void* ctx, SceneMode mode); | ||
550 | 98 | 100 | ||
551 | 99 | // Dumps the camera parameters to stdout. | 101 | // Dumps the camera parameters to stdout. |
552 | 100 | void android_camera_dump_parameters(CameraControl* control); | 102 | void android_camera_dump_parameters(CameraControl* control); |
553 | @@ -115,6 +117,7 @@ | |||
554 | 115 | void android_camera_get_effect_mode(CameraControl* control, EffectMode* mode); | 117 | void android_camera_get_effect_mode(CameraControl* control, EffectMode* mode); |
555 | 116 | void android_camera_get_flash_mode(CameraControl* control, FlashMode* mode); | 118 | void android_camera_get_flash_mode(CameraControl* control, FlashMode* mode); |
556 | 117 | void android_camera_get_white_balance_mode(CameraControl* control, WhiteBalanceMode* mode); | 119 | void android_camera_get_white_balance_mode(CameraControl* control, WhiteBalanceMode* mode); |
557 | 120 | void android_camera_enumerate_supported_scene_modes(CameraControl* control, scene_mode_callback cb, void* ctx); | ||
558 | 118 | void android_camera_get_scene_mode(CameraControl* control, SceneMode* mode); | 121 | void android_camera_get_scene_mode(CameraControl* control, SceneMode* mode); |
559 | 119 | void android_camera_get_auto_focus_mode(CameraControl* control, AutoFocusMode* mode); | 122 | void android_camera_get_auto_focus_mode(CameraControl* control, AutoFocusMode* mode); |
560 | 120 | void android_camera_get_preview_format(CameraControl* control, CameraPixelFormat* format); | 123 | void android_camera_get_preview_format(CameraControl* control, CameraPixelFormat* format); |
561 | 121 | 124 | ||
562 | === modified file 'unittests/mocks/aal/media_recorder_layer.cpp' | |||
563 | --- unittests/mocks/aal/media_recorder_layer.cpp 2014-06-19 20:54:56 +0000 | |||
564 | +++ unittests/mocks/aal/media_recorder_layer.cpp 2014-07-15 12:39:22 +0000 | |||
565 | @@ -15,7 +15,7 @@ | |||
566 | 15 | * | 15 | * |
567 | 16 | */ | 16 | */ |
568 | 17 | 17 | ||
570 | 18 | #include <hybris/media/media_recorder_layer.h> | 18 | #include "media_recorder_layer.h" |
571 | 19 | #include "camera_control.h" | 19 | #include "camera_control.h" |
572 | 20 | 20 | ||
573 | 21 | #include <qglobal.h> | 21 | #include <qglobal.h> |
574 | 22 | 22 | ||
575 | === modified file 'unittests/unittests.pro' | |||
576 | --- unittests/unittests.pro 2013-05-24 11:25:15 +0000 | |||
577 | +++ unittests/unittests.pro 2014-07-15 12:39:22 +0000 | |||
578 | @@ -3,6 +3,7 @@ | |||
579 | 3 | SUBDIRS += \ | 3 | SUBDIRS += \ |
580 | 4 | mocks \ | 4 | mocks \ |
581 | 5 | aalcameracontrol \ | 5 | aalcameracontrol \ |
582 | 6 | aalcameraexposurecontrol \ | ||
583 | 6 | aalcameraflashcontrol \ | 7 | aalcameraflashcontrol \ |
584 | 7 | aalcamerafocuscontrol \ | 8 | aalcamerafocuscontrol \ |
585 | 8 | aalcamerazoomcontrol \ | 9 | aalcamerazoomcontrol \ |
MR not ready for review.