Merge lp:qtubuntu-camera/staging into lp:qtubuntu-camera
- staging
- Merge into trunk
Proposed by
Florian Boucault
Status: | Merged |
---|---|
Approved by: | Florian Boucault |
Approved revision: | 179 |
Merged at revision: | 157 |
Proposed branch: | lp:qtubuntu-camera/staging |
Merge into: | lp:qtubuntu-camera |
Diff against target: |
1363 lines (+394/-621) 20 files modified
aalCamera.pro (+0/-1) src/aalcamerafocuscontrol.cpp (+1/-1) src/aalimagecapturecontrol.cpp (+63/-133) src/aalimagecapturecontrol.h (+8/-4) src/storagemanager.cpp (+173/-1) src/storagemanager.h (+29/-5) unittests/aalcamerafocuscontrol/aalcamerafocuscontrol.pro (+3/-1) unittests/aalcamerafocuscontrol/aalimagecapturecontrol.cpp (+10/-8) unittests/aalcamerafocuscontrol/storagemanager.cpp (+76/-0) unittests/aalcamerafocuscontrol/tst_aalcamerafocuscontrol.cpp (+2/-2) unittests/aalimagecapturecontrol/aalcameraservice.cpp (+0/-99) unittests/aalimagecapturecontrol/aalimagecapturecontrol.pro (+0/-31) unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp (+0/-125) unittests/aalimagecapturecontrol/aalvideorenderercontrol.cpp (+0/-84) unittests/aalimagecapturecontrol/storagemanager.cpp (+0/-50) unittests/aalimagecapturecontrol/tst_aalimagecapturecontrol.cpp (+0/-74) unittests/storagemanager/storagemanager.pro (+5/-0) unittests/storagemanager/tst_storagemanager.cpp (+22/-0) unittests/stubs/storagemanager_stub.cpp (+2/-1) unittests/unittests.pro (+0/-1) |
To merge this branch: | bzr merge lp:qtubuntu-camera/staging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Ubuntu Phablet Team | Pending | ||
Review via email: mp+286880@code.launchpad.net |
Commit message
New release:
- Performance improvements to minimize the time necessary between when pressing the shutter button and being able to capture the next pitcure. Remove sliding out the preview as a part of this.
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'aalCamera.pro' | |||
2 | --- aalCamera.pro 2015-11-12 10:32:24 +0000 | |||
3 | +++ aalCamera.pro 2016-02-23 11:36:01 +0000 | |||
4 | @@ -5,5 +5,4 @@ | |||
5 | 5 | SUBDIRS += \ | 5 | SUBDIRS += \ |
6 | 6 | src \ | 6 | src \ |
7 | 7 | unittests | 7 | unittests |
8 | 8 | |||
9 | 9 | OTHER_FILES += .qmake.conf | 8 | OTHER_FILES += .qmake.conf |
10 | 10 | 9 | ||
11 | === modified file 'src/aalcamerafocuscontrol.cpp' | |||
12 | --- src/aalcamerafocuscontrol.cpp 2015-10-14 13:54:37 +0000 | |||
13 | +++ src/aalcamerafocuscontrol.cpp 2016-02-23 11:36:01 +0000 | |||
14 | @@ -212,7 +212,7 @@ | |||
15 | 212 | int centerX = (point.x() * (2* focusFullSize)) - focusFullSize; | 212 | int centerX = (point.x() * (2* focusFullSize)) - focusFullSize; |
16 | 213 | int maxCenterPosition = focusFullSize - focusRegionSize; | 213 | int maxCenterPosition = focusFullSize - focusRegionSize; |
17 | 214 | centerX = std::max(std::min(centerX, maxCenterPosition), -maxCenterPosition); | 214 | centerX = std::max(std::min(centerX, maxCenterPosition), -maxCenterPosition); |
19 | 215 | int centerY = -1 * ((point.y() * (2 * focusFullSize)) - focusFullSize); | 215 | int centerY = (point.y() * (2 * focusFullSize)) - focusFullSize; |
20 | 216 | centerY = std::max(std::min(centerY, maxCenterPosition), -maxCenterPosition); | 216 | centerY = std::max(std::min(centerY, maxCenterPosition), -maxCenterPosition); |
21 | 217 | 217 | ||
22 | 218 | FocusRegion region; | 218 | FocusRegion region; |
23 | 219 | 219 | ||
24 | === modified file 'src/aalimagecapturecontrol.cpp' | |||
25 | --- src/aalimagecapturecontrol.cpp 2016-01-11 15:10:38 +0000 | |||
26 | +++ src/aalimagecapturecontrol.cpp 2016-02-23 11:36:01 +0000 | |||
27 | @@ -19,13 +19,14 @@ | |||
28 | 19 | #include "aalimageencodercontrol.h" | 19 | #include "aalimageencodercontrol.h" |
29 | 20 | #include "aalmetadatawritercontrol.h" | 20 | #include "aalmetadatawritercontrol.h" |
30 | 21 | #include "aalvideorenderercontrol.h" | 21 | #include "aalvideorenderercontrol.h" |
31 | 22 | #include "aalviewfindersettingscontrol.h" | ||
32 | 22 | #include "storagemanager.h" | 23 | #include "storagemanager.h" |
33 | 23 | 24 | ||
34 | 24 | #include <hybris/camera/camera_compatibility_layer.h> | 25 | #include <hybris/camera/camera_compatibility_layer.h> |
35 | 25 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> | 26 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> |
36 | 26 | #include <exiv2/exiv2.hpp> | ||
37 | 27 | 27 | ||
38 | 28 | #include <QDir> | 28 | #include <QDir> |
39 | 29 | #include <QObject> | ||
40 | 29 | #include <QFile> | 30 | #include <QFile> |
41 | 30 | #include <QFileInfo> | 31 | #include <QFileInfo> |
42 | 31 | #include <QMediaPlayer> | 32 | #include <QMediaPlayer> |
43 | @@ -34,8 +35,7 @@ | |||
44 | 34 | #include <QGuiApplication> | 35 | #include <QGuiApplication> |
45 | 35 | #include <QScreen> | 36 | #include <QScreen> |
46 | 36 | #include <QSettings> | 37 | #include <QSettings> |
49 | 37 | 38 | #include <QtConcurrent/QtConcurrent> | |
48 | 38 | #include <cmath> | ||
50 | 39 | 39 | ||
51 | 40 | AalImageCaptureControl::AalImageCaptureControl(AalCameraService *service, QObject *parent) | 40 | AalImageCaptureControl::AalImageCaptureControl(AalCameraService *service, QObject *parent) |
52 | 41 | : QCameraImageCaptureControl(parent), | 41 | : QCameraImageCaptureControl(parent), |
53 | @@ -43,7 +43,7 @@ | |||
54 | 43 | m_cameraControl(service->cameraControl()), | 43 | m_cameraControl(service->cameraControl()), |
55 | 44 | m_lastRequestId(0), | 44 | m_lastRequestId(0), |
56 | 45 | m_ready(false), | 45 | m_ready(false), |
58 | 46 | m_pendingCaptureFile(), | 46 | m_targetFileName(), |
59 | 47 | m_captureCancelled(false), | 47 | m_captureCancelled(false), |
60 | 48 | m_screenAspectRatio(0.0), | 48 | m_screenAspectRatio(0.0), |
61 | 49 | m_audioPlayer(new QMediaPlayer(this)) | 49 | m_audioPlayer(new QMediaPlayer(this)) |
62 | @@ -55,6 +55,9 @@ | |||
63 | 55 | #else | 55 | #else |
64 | 56 | m_audioPlayer->setAudioRole(QAudio::NotificationRole); | 56 | m_audioPlayer->setAudioRole(QAudio::NotificationRole); |
65 | 57 | #endif | 57 | #endif |
66 | 58 | |||
67 | 59 | QObject::connect(&m_storageManager, &StorageManager::previewReady, | ||
68 | 60 | this, &AalImageCaptureControl::imageCaptured); | ||
69 | 58 | } | 61 | } |
70 | 59 | 62 | ||
71 | 60 | AalImageCaptureControl::~AalImageCaptureControl() | 63 | AalImageCaptureControl::~AalImageCaptureControl() |
72 | @@ -76,58 +79,24 @@ | |||
73 | 76 | return m_lastRequestId; | 79 | return m_lastRequestId; |
74 | 77 | } | 80 | } |
75 | 78 | 81 | ||
76 | 82 | m_targetFileName = fileName; | ||
77 | 79 | m_captureCancelled = false; | 83 | m_captureCancelled = false; |
78 | 80 | QFileInfo fi(fileName); | ||
79 | 81 | if (fileName.isEmpty() || fi.isDir()) { | ||
80 | 82 | m_pendingCaptureFile = m_storageManager.nextPhotoFileName(fileName); | ||
81 | 83 | } else { | ||
82 | 84 | m_pendingCaptureFile = fileName; | ||
83 | 85 | } | ||
84 | 86 | bool diskOk = m_storageManager.checkDirectory(m_pendingCaptureFile); | ||
85 | 87 | if (!diskOk) { | ||
86 | 88 | emit error(m_lastRequestId, QCameraImageCapture::ResourceError, | ||
87 | 89 | QString("Won't be able to save file %1 to disk").arg(m_pendingCaptureFile)); | ||
88 | 90 | return m_lastRequestId; | ||
89 | 91 | } | ||
90 | 92 | 84 | ||
91 | 93 | AalMetaDataWriterControl* metadataControl = m_service->metadataWriterControl(); | 85 | AalMetaDataWriterControl* metadataControl = m_service->metadataWriterControl(); |
92 | 94 | |||
93 | 95 | int rotation = metadataControl->correctedOrientation(); | 86 | int rotation = metadataControl->correctedOrientation(); |
94 | 96 | android_camera_set_rotation(m_service->androidControl(), rotation); | 87 | android_camera_set_rotation(m_service->androidControl(), rotation); |
95 | 97 | 88 | ||
96 | 98 | QStringList availableMetadata = metadataControl->availableMetaData(); | ||
97 | 99 | if (availableMetadata.contains("GPSLatitude") && | ||
98 | 100 | availableMetadata.contains("GPSLongitude") && | ||
99 | 101 | availableMetadata.contains("GPSTimeStamp")) { | ||
100 | 102 | float latitude = metadataControl->metaData("GPSLatitude").toFloat(); | ||
101 | 103 | float longitude = metadataControl->metaData("GPSLongitude").toFloat(); | ||
102 | 104 | float altitude = 0.0f; | ||
103 | 105 | if (availableMetadata.contains("GPSAltitude")) { | ||
104 | 106 | altitude = metadataControl->metaData("GPSAltitude").toFloat(); | ||
105 | 107 | } | ||
106 | 108 | QDateTime timestamp = metadataControl->metaData("GPSTimeStamp").toDateTime(); | ||
107 | 109 | QString processingMethod = metadataControl->metaData("GPSProcessingMethod").toString(); | ||
108 | 110 | android_camera_set_location(m_service->androidControl(), | ||
109 | 111 | &latitude, &longitude, &altitude, | ||
110 | 112 | timestamp.toTime_t(), | ||
111 | 113 | processingMethod.toLocal8Bit().constData()); | ||
112 | 114 | } | ||
113 | 115 | |||
114 | 116 | android_camera_take_snapshot(m_service->androidControl()); | 89 | android_camera_take_snapshot(m_service->androidControl()); |
115 | 117 | 90 | ||
116 | 118 | m_service->updateCaptureReady(); | 91 | m_service->updateCaptureReady(); |
117 | 119 | 92 | ||
118 | 120 | m_service->videoOutputControl()->createPreview(); | ||
119 | 121 | |||
120 | 122 | m_service->metadataWriterControl()->clearAllMetaData(); | ||
121 | 123 | |||
122 | 124 | return m_lastRequestId; | 93 | return m_lastRequestId; |
123 | 125 | } | 94 | } |
124 | 126 | 95 | ||
125 | 127 | void AalImageCaptureControl::cancelCapture() | 96 | void AalImageCaptureControl::cancelCapture() |
126 | 128 | { | 97 | { |
127 | 129 | m_captureCancelled = true; | 98 | m_captureCancelled = true; |
129 | 130 | m_pendingCaptureFile.clear(); | 99 | m_targetFileName.clear(); |
130 | 131 | } | 100 | } |
131 | 132 | 101 | ||
132 | 133 | void AalImageCaptureControl::shutterCB(void *context) | 102 | void AalImageCaptureControl::shutterCB(void *context) |
133 | @@ -140,7 +109,14 @@ | |||
134 | 140 | void AalImageCaptureControl::saveJpegCB(void *data, uint32_t data_size, void *context) | 109 | void AalImageCaptureControl::saveJpegCB(void *data, uint32_t data_size, void *context) |
135 | 141 | { | 110 | { |
136 | 142 | Q_UNUSED(context); | 111 | Q_UNUSED(context); |
138 | 143 | AalCameraService::instance()->imageCaptureControl()->saveJpeg(data, data_size); | 112 | |
139 | 113 | // Copy the data buffer so that it is safe to pass it off to another thread, | ||
140 | 114 | // since it will be destroyed once this function returns | ||
141 | 115 | QByteArray dataCopy((const char*)data, data_size); | ||
142 | 116 | |||
143 | 117 | QMetaObject::invokeMethod(AalCameraService::instance()->imageCaptureControl(), | ||
144 | 118 | "saveJpeg", Qt::QueuedConnection, | ||
145 | 119 | Q_ARG(QByteArray, dataCopy)); | ||
146 | 144 | } | 120 | } |
147 | 145 | 121 | ||
148 | 146 | void AalImageCaptureControl::init(CameraControl *control, CameraControlListener *listener) | 122 | void AalImageCaptureControl::init(CameraControl *control, CameraControlListener *listener) |
149 | @@ -153,12 +129,6 @@ | |||
150 | 153 | connect(m_service->videoOutputControl(), SIGNAL(previewReady()), this, SLOT(onPreviewReady())); | 129 | connect(m_service->videoOutputControl(), SIGNAL(previewReady()), this, SLOT(onPreviewReady())); |
151 | 154 | } | 130 | } |
152 | 155 | 131 | ||
153 | 156 | void AalImageCaptureControl::onPreviewReady() | ||
154 | 157 | { | ||
155 | 158 | // The preview image was fully captured, notify the UI layer | ||
156 | 159 | Q_EMIT imageCaptured(m_lastRequestId, m_service->videoOutputControl()->preview()); | ||
157 | 160 | } | ||
158 | 161 | |||
159 | 162 | void AalImageCaptureControl::setReady(bool ready) | 132 | void AalImageCaptureControl::setReady(bool ready) |
160 | 163 | { | 133 | { |
161 | 164 | if (m_ready != ready) { | 134 | if (m_ready != ready) { |
162 | @@ -169,7 +139,7 @@ | |||
163 | 169 | 139 | ||
164 | 170 | bool AalImageCaptureControl::isCaptureRunning() const | 140 | bool AalImageCaptureControl::isCaptureRunning() const |
165 | 171 | { | 141 | { |
167 | 172 | return !m_pendingCaptureFile.isNull(); | 142 | return !m_targetFileName.isEmpty(); |
168 | 173 | } | 143 | } |
169 | 174 | 144 | ||
170 | 175 | void AalImageCaptureControl::shutter() | 145 | void AalImageCaptureControl::shutter() |
171 | @@ -181,96 +151,56 @@ | |||
172 | 181 | Q_EMIT imageExposed(m_lastRequestId); | 151 | Q_EMIT imageExposed(m_lastRequestId); |
173 | 182 | } | 152 | } |
174 | 183 | 153 | ||
221 | 184 | bool AalImageCaptureControl::updateJpegMetadata(void* data, uint32_t dataSize, QTemporaryFile* destination) | 154 | void AalImageCaptureControl::saveJpeg(const QByteArray& data) |
176 | 185 | { | ||
177 | 186 | if (data == 0 || destination == 0) return false; | ||
178 | 187 | |||
179 | 188 | Exiv2::Image::AutoPtr image; | ||
180 | 189 | try { | ||
181 | 190 | image = Exiv2::ImageFactory::open(static_cast<Exiv2::byte*>(data), dataSize); | ||
182 | 191 | if (!image.get()) { | ||
183 | 192 | return false; | ||
184 | 193 | } | ||
185 | 194 | } catch(const Exiv2::AnyError&) { | ||
186 | 195 | return false; | ||
187 | 196 | } | ||
188 | 197 | |||
189 | 198 | try { | ||
190 | 199 | image->readMetadata(); | ||
191 | 200 | Exiv2::ExifData ed = image->exifData(); | ||
192 | 201 | const QString now = QDateTime::currentDateTime().toString("yyyy:MM:dd HH:mm:ss"); | ||
193 | 202 | ed["Exif.Photo.DateTimeOriginal"].setValue(now.toStdString()); | ||
194 | 203 | ed["Exif.Photo.DateTimeDigitized"].setValue(now.toStdString()); | ||
195 | 204 | image->setExifData(ed); | ||
196 | 205 | image->writeMetadata(); | ||
197 | 206 | } catch(const Exiv2::AnyError&) { | ||
198 | 207 | return false; | ||
199 | 208 | } | ||
200 | 209 | |||
201 | 210 | if (!destination->open()) { | ||
202 | 211 | return false; | ||
203 | 212 | } | ||
204 | 213 | |||
205 | 214 | try { | ||
206 | 215 | Exiv2::BasicIo& io = image->io(); | ||
207 | 216 | char* modifiedMetadata = reinterpret_cast<char*>(io.mmap()); | ||
208 | 217 | const long size = io.size(); | ||
209 | 218 | const qint64 writtenSize = destination->write(modifiedMetadata, size); | ||
210 | 219 | io.munmap(); | ||
211 | 220 | destination->close(); | ||
212 | 221 | return (writtenSize == size); | ||
213 | 222 | |||
214 | 223 | } catch(const Exiv2::AnyError&) { | ||
215 | 224 | destination->close(); | ||
216 | 225 | return false; | ||
217 | 226 | } | ||
218 | 227 | } | ||
219 | 228 | |||
220 | 229 | void AalImageCaptureControl::saveJpeg(void *data, uint32_t dataSize) | ||
222 | 230 | { | 155 | { |
223 | 231 | if (m_captureCancelled) { | 156 | if (m_captureCancelled) { |
224 | 232 | m_captureCancelled = false; | 157 | m_captureCancelled = false; |
225 | 233 | return; | 158 | return; |
226 | 234 | } | 159 | } |
227 | 235 | 160 | ||
267 | 236 | if (m_pendingCaptureFile.isNull() || !m_service->androidControl()) | 161 | // Copy the metadata so that we can clear its container |
268 | 237 | return; | 162 | QVariantMap metadata; |
269 | 238 | 163 | AalMetaDataWriterControl* metadataControl = m_service->metadataWriterControl(); | |
270 | 239 | QTemporaryFile file; | 164 | Q_FOREACH(QString key, metadataControl->availableMetaData()) { |
271 | 240 | if (!updateJpegMetadata(data, dataSize, &file)) { | 165 | metadata.insert(key, metadataControl->metaData(key)); |
272 | 241 | qWarning() << "Failed to update EXIF timestamps. Picture will be saved as UTC timezone."; | 166 | } |
273 | 242 | if (!file.open()) { | 167 | m_service->metadataWriterControl()->clearAllMetaData(); |
274 | 243 | emit error(m_lastRequestId, QCameraImageCapture::ResourceError, | 168 | |
275 | 244 | QString("Could not open temprary file %1").arg(file.fileName())); | 169 | QString fileName = m_targetFileName; |
276 | 245 | m_pendingCaptureFile.clear(); | 170 | m_targetFileName.clear(); |
277 | 246 | m_service->updateCaptureReady(); | 171 | |
278 | 247 | return; | 172 | AalViewfinderSettingsControl* viewfinder = m_service->viewfinderControl(); |
279 | 248 | } | 173 | QSize resolution = viewfinder->viewfinderParameter(QCameraViewfinderSettingsControl::Resolution).toSize(); |
280 | 249 | 174 | ||
281 | 250 | const qint64 writtenSize = file.write(static_cast<const char*>(data), dataSize); | 175 | // Restart the viewfinder and notify that the camera is ready to capture again |
282 | 251 | file.close(); | 176 | if (m_service->androidControl()) { |
283 | 252 | if (writtenSize != dataSize) { | 177 | android_camera_start_preview(m_service->androidControl()); |
284 | 253 | emit error(m_lastRequestId, QCameraImageCapture::ResourceError, | 178 | } |
246 | 254 | QString("Could not write file %1").arg(file.fileName())); | ||
247 | 255 | m_pendingCaptureFile.clear(); | ||
248 | 256 | m_service->updateCaptureReady(); | ||
249 | 257 | return; | ||
250 | 258 | } | ||
251 | 259 | } | ||
252 | 260 | |||
253 | 261 | QFile finalFile(file.fileName()); | ||
254 | 262 | bool ok = finalFile.rename(m_pendingCaptureFile); | ||
255 | 263 | if (!ok) { | ||
256 | 264 | emit error(m_lastRequestId, QCameraImageCapture::ResourceError, | ||
257 | 265 | QString("Could not save image to %1").arg(m_pendingCaptureFile)); | ||
258 | 266 | m_pendingCaptureFile.clear(); | ||
259 | 267 | m_service->updateCaptureReady(); | ||
260 | 268 | return; | ||
261 | 269 | } | ||
262 | 270 | |||
263 | 271 | Q_EMIT imageSaved(m_lastRequestId, m_pendingCaptureFile); | ||
264 | 272 | m_pendingCaptureFile.clear(); | ||
265 | 273 | |||
266 | 274 | android_camera_start_preview(m_service->androidControl()); | ||
285 | 275 | m_service->updateCaptureReady(); | 179 | m_service->updateCaptureReady(); |
286 | 180 | |||
287 | 181 | DiskWriteWatcher* watcher = new DiskWriteWatcher(this); | ||
288 | 182 | QObject::connect(watcher, &QFutureWatcher<QString>::finished, this, &AalImageCaptureControl::onImageFileSaved); | ||
289 | 183 | m_pendingSaveOperations.insert(watcher, m_lastRequestId); | ||
290 | 184 | |||
291 | 185 | QFuture<SaveToDiskResult> future = QtConcurrent::run(&m_storageManager, &StorageManager::saveJpegImage, | ||
292 | 186 | data, metadata, fileName, resolution, m_lastRequestId); | ||
293 | 187 | watcher->setFuture(future); | ||
294 | 188 | } | ||
295 | 189 | |||
296 | 190 | void AalImageCaptureControl::onImageFileSaved() | ||
297 | 191 | { | ||
298 | 192 | DiskWriteWatcher* watcher = static_cast<DiskWriteWatcher*>(sender()); | ||
299 | 193 | |||
300 | 194 | if (m_pendingSaveOperations.contains(watcher)) { | ||
301 | 195 | int requestID = m_pendingSaveOperations.take(watcher); | ||
302 | 196 | |||
303 | 197 | SaveToDiskResult result = watcher->result(); | ||
304 | 198 | delete watcher; | ||
305 | 199 | |||
306 | 200 | if (result.success) { | ||
307 | 201 | Q_EMIT imageSaved(requestID, result.fileName); | ||
308 | 202 | } else { | ||
309 | 203 | Q_EMIT error(requestID, QCameraImageCapture::ResourceError, result.errorMessage); | ||
310 | 204 | } | ||
311 | 205 | } | ||
312 | 276 | } | 206 | } |
313 | 277 | 207 | ||
314 | === modified file 'src/aalimagecapturecontrol.h' | |||
315 | --- src/aalimagecapturecontrol.h 2016-01-11 15:10:38 +0000 | |||
316 | +++ src/aalimagecapturecontrol.h 2016-02-23 11:36:01 +0000 | |||
317 | @@ -20,7 +20,7 @@ | |||
318 | 20 | #include <QCameraImageCaptureControl> | 20 | #include <QCameraImageCaptureControl> |
319 | 21 | #include <QSettings> | 21 | #include <QSettings> |
320 | 22 | #include <QString> | 22 | #include <QString> |
322 | 23 | #include <QTemporaryFile> | 23 | #include <QFutureWatcher> |
323 | 24 | #include <storagemanager.h> | 24 | #include <storagemanager.h> |
324 | 25 | 25 | ||
325 | 26 | #include <stdint.h> | 26 | #include <stdint.h> |
326 | @@ -31,6 +31,8 @@ | |||
327 | 31 | class CameraControlListener; | 31 | class CameraControlListener; |
328 | 32 | class QMediaPlayer; | 32 | class QMediaPlayer; |
329 | 33 | 33 | ||
330 | 34 | typedef QFutureWatcher<SaveToDiskResult> DiskWriteWatcher; | ||
331 | 35 | |||
332 | 34 | class AalImageCaptureControl : public QCameraImageCaptureControl | 36 | class AalImageCaptureControl : public QCameraImageCaptureControl |
333 | 35 | { | 37 | { |
334 | 36 | Q_OBJECT | 38 | Q_OBJECT |
335 | @@ -55,13 +57,13 @@ | |||
336 | 55 | 57 | ||
337 | 56 | public Q_SLOTS: | 58 | public Q_SLOTS: |
338 | 57 | void init(CameraControl *control, CameraControlListener *listener); | 59 | void init(CameraControl *control, CameraControlListener *listener); |
340 | 58 | void onPreviewReady(); | 60 | void onImageFileSaved(); |
341 | 59 | 61 | ||
342 | 60 | private Q_SLOTS: | 62 | private Q_SLOTS: |
343 | 61 | void shutter(); | 63 | void shutter(); |
344 | 64 | void saveJpeg(const QByteArray& data); | ||
345 | 62 | 65 | ||
346 | 63 | private: | 66 | private: |
347 | 64 | void saveJpeg(void* data, uint32_t dataSize); | ||
348 | 65 | bool updateJpegMetadata(void* data, uint32_t dataSize, QTemporaryFile* destination); | 67 | bool updateJpegMetadata(void* data, uint32_t dataSize, QTemporaryFile* destination); |
349 | 66 | 68 | ||
350 | 67 | AalCameraService *m_service; | 69 | AalCameraService *m_service; |
351 | @@ -69,7 +71,7 @@ | |||
352 | 69 | int m_lastRequestId; | 71 | int m_lastRequestId; |
353 | 70 | StorageManager m_storageManager; | 72 | StorageManager m_storageManager; |
354 | 71 | bool m_ready; | 73 | bool m_ready; |
356 | 72 | QString m_pendingCaptureFile; | 74 | QString m_targetFileName; |
357 | 73 | bool m_captureCancelled; | 75 | bool m_captureCancelled; |
358 | 74 | float m_screenAspectRatio; | 76 | float m_screenAspectRatio; |
359 | 75 | /// Maintains a list of highest priority aspect ratio to lowest, for the | 77 | /// Maintains a list of highest priority aspect ratio to lowest, for the |
360 | @@ -78,6 +80,8 @@ | |||
361 | 78 | QString m_galleryPath; | 80 | QString m_galleryPath; |
362 | 79 | QMediaPlayer *m_audioPlayer; | 81 | QMediaPlayer *m_audioPlayer; |
363 | 80 | QSettings m_settings; | 82 | QSettings m_settings; |
364 | 83 | |||
365 | 84 | QMap<DiskWriteWatcher*, int> m_pendingSaveOperations; | ||
366 | 81 | }; | 85 | }; |
367 | 82 | 86 | ||
368 | 83 | #endif | 87 | #endif |
369 | 84 | 88 | ||
370 | === modified file 'src/storagemanager.cpp' | |||
371 | --- src/storagemanager.cpp 2014-09-10 19:48:00 +0000 | |||
372 | +++ src/storagemanager.cpp 2016-02-23 11:36:01 +0000 | |||
373 | @@ -15,12 +15,18 @@ | |||
374 | 15 | */ | 15 | */ |
375 | 16 | 16 | ||
376 | 17 | #include "storagemanager.h" | 17 | #include "storagemanager.h" |
377 | 18 | |||
378 | 18 | #include <QDateTime> | 19 | #include <QDateTime> |
379 | 19 | #include <QDebug> | 20 | #include <QDebug> |
380 | 20 | #include <QDir> | 21 | #include <QDir> |
381 | 21 | #include <QFileInfo> | 22 | #include <QFileInfo> |
382 | 22 | #include <QStandardPaths> | 23 | #include <QStandardPaths> |
383 | 23 | #include <QCoreApplication> | 24 | #include <QCoreApplication> |
384 | 25 | #include <QBuffer> | ||
385 | 26 | #include <QImageReader> | ||
386 | 27 | |||
387 | 28 | #include <exiv2/exiv2.hpp> | ||
388 | 29 | #include <cmath> | ||
389 | 24 | 30 | ||
390 | 25 | const QLatin1String photoBase = QLatin1String("image"); | 31 | const QLatin1String photoBase = QLatin1String("image"); |
391 | 26 | const QLatin1String videoBase = QLatin1String("video"); | 32 | const QLatin1String videoBase = QLatin1String("video"); |
392 | @@ -28,7 +34,7 @@ | |||
393 | 28 | const QLatin1String videoExtension = QLatin1String("mp4"); | 34 | const QLatin1String videoExtension = QLatin1String("mp4"); |
394 | 29 | const QLatin1String dateFormat = QLatin1String("yyyyMMdd_HHmmsszzz"); | 35 | const QLatin1String dateFormat = QLatin1String("yyyyMMdd_HHmmsszzz"); |
395 | 30 | 36 | ||
397 | 31 | StorageManager::StorageManager() | 37 | StorageManager::StorageManager(QObject* parent) : QObject(parent) |
398 | 32 | { | 38 | { |
399 | 33 | } | 39 | } |
400 | 34 | 40 | ||
401 | @@ -87,3 +93,169 @@ | |||
402 | 87 | .arg(date) | 93 | .arg(date) |
403 | 88 | .arg(extension); | 94 | .arg(extension); |
404 | 89 | } | 95 | } |
405 | 96 | |||
406 | 97 | bool StorageManager::updateJpegMetadata(QByteArray data, QVariantMap metadata, QTemporaryFile* destination) | ||
407 | 98 | { | ||
408 | 99 | if (data.isEmpty() || destination == 0) return false; | ||
409 | 100 | |||
410 | 101 | Exiv2::Image::AutoPtr image; | ||
411 | 102 | try { | ||
412 | 103 | image = Exiv2::ImageFactory::open(static_cast<const Exiv2::byte*>((const unsigned char*)data.constData()), data.size()); | ||
413 | 104 | if (!image.get()) { | ||
414 | 105 | return false; | ||
415 | 106 | } | ||
416 | 107 | } catch(const Exiv2::AnyError&) { | ||
417 | 108 | return false; | ||
418 | 109 | } | ||
419 | 110 | |||
420 | 111 | try { | ||
421 | 112 | image->readMetadata(); | ||
422 | 113 | Exiv2::ExifData ed = image->exifData(); | ||
423 | 114 | const QString now = QDateTime::currentDateTime().toString("yyyy:MM:dd HH:mm:ss"); | ||
424 | 115 | ed["Exif.Photo.DateTimeOriginal"].setValue(now.toStdString()); | ||
425 | 116 | ed["Exif.Photo.DateTimeDigitized"].setValue(now.toStdString()); | ||
426 | 117 | |||
427 | 118 | if (metadata.contains("GPSLatitude") && | ||
428 | 119 | metadata.contains("GPSLongitude") && | ||
429 | 120 | metadata.contains("GPSTimeStamp")) { | ||
430 | 121 | |||
431 | 122 | // Write all GPS metadata according to version 2.2 of the EXIF spec, | ||
432 | 123 | // which is what Android did. See: http://www.exiv2.org/Exif2-2.PDF | ||
433 | 124 | const char version[4] = {2, 2, 0, 0}; | ||
434 | 125 | Exiv2::DataValue versionValue(Exiv2::unsignedByte); | ||
435 | 126 | versionValue.read((const Exiv2::byte*)version, 4); | ||
436 | 127 | ed.add(Exiv2::ExifKey("Exif.GPSInfo.GPSVersionID"), &versionValue); | ||
437 | 128 | |||
438 | 129 | // According to the spec, the GPS processing method is a buffer of type Undefined, which | ||
439 | 130 | // does not need to be zero terminated. It should be prepended by an 8 byte, zero padded | ||
440 | 131 | // string specifying the encoding. | ||
441 | 132 | const char methodHeader[8] = {'A', 'S', 'C', 'I', 'I', 0, 0, 0}; | ||
442 | 133 | QByteArray method = metadata.value("GPSProcessingMethod").toString().toLatin1(); | ||
443 | 134 | method.prepend(methodHeader, 8); | ||
444 | 135 | Exiv2::DataValue methodValue(Exiv2::undefined); | ||
445 | 136 | methodValue.read((const Exiv2::byte*)method.constData(), method.size()); | ||
446 | 137 | ed.add(Exiv2::ExifKey("Exif.GPSInfo.GPSProcessingMethod"), &methodValue); | ||
447 | 138 | |||
448 | 139 | double latitude = metadata.value("GPSLatitude").toDouble(); | ||
449 | 140 | ed["Exif.GPSInfo.GPSLatitude"] = decimalToExifRational(latitude).toStdString(); | ||
450 | 141 | ed["Exif.GPSInfo.GPSLatitudeRef"] = (latitude < 0 ) ? "S" : "N"; | ||
451 | 142 | |||
452 | 143 | double longitude = metadata.value("GPSLongitude").toDouble(); | ||
453 | 144 | ed["Exif.GPSInfo.GPSLongitude"] = decimalToExifRational(longitude).toStdString(); | ||
454 | 145 | ed["Exif.GPSInfo.GPSLongitudeRef"] = (longitude < 0 ) ? "W" : "E"; | ||
455 | 146 | |||
456 | 147 | if (metadata.contains("GPSAltitude")) { | ||
457 | 148 | // Assume altitude precision to the meter | ||
458 | 149 | unsigned int altitude = floor(metadata.value("GPSAltitude").toDouble()); | ||
459 | 150 | Exiv2::URationalValue::AutoPtr altitudeValue(new Exiv2::URationalValue); | ||
460 | 151 | altitudeValue->value_.push_back(std::make_pair(altitude,1)); | ||
461 | 152 | ed.add(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitude"), altitudeValue.get()); | ||
462 | 153 | |||
463 | 154 | // Byte field of lenght 1. Value of 0 means the reference is sea level. | ||
464 | 155 | const char reference = 0; | ||
465 | 156 | Exiv2::DataValue referenceValue(Exiv2::unsignedByte); | ||
466 | 157 | referenceValue.read((const Exiv2::byte*) &reference, 1); | ||
467 | 158 | ed.add(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitudeRef"), &referenceValue); | ||
468 | 159 | } | ||
469 | 160 | |||
470 | 161 | QDateTime stamp = metadata.value("GPSTimeStamp").toDateTime(); | ||
471 | 162 | ed["Exif.GPSInfo.GPSTimeStamp"] = stamp.toString("HH/1 mm/1 ss/1").toStdString(); | ||
472 | 163 | ed["Exif.GPSInfo.GPSDateStamp"] = stamp.toString("yyyy:MM:dd").toStdString(); | ||
473 | 164 | } | ||
474 | 165 | |||
475 | 166 | image->setExifData(ed); | ||
476 | 167 | image->writeMetadata(); | ||
477 | 168 | } catch(const Exiv2::AnyError&) { | ||
478 | 169 | return false; | ||
479 | 170 | } | ||
480 | 171 | |||
481 | 172 | if (!destination->open()) { | ||
482 | 173 | return false; | ||
483 | 174 | } | ||
484 | 175 | |||
485 | 176 | try { | ||
486 | 177 | Exiv2::BasicIo& io = image->io(); | ||
487 | 178 | char* modifiedMetadata = reinterpret_cast<char*>(io.mmap()); | ||
488 | 179 | const long size = io.size(); | ||
489 | 180 | const qint64 writtenSize = destination->write(modifiedMetadata, size); | ||
490 | 181 | io.munmap(); | ||
491 | 182 | destination->close(); | ||
492 | 183 | return (writtenSize == size); | ||
493 | 184 | |||
494 | 185 | } catch(const Exiv2::AnyError&) { | ||
495 | 186 | destination->close(); | ||
496 | 187 | return false; | ||
497 | 188 | } | ||
498 | 189 | } | ||
499 | 190 | |||
500 | 191 | SaveToDiskResult StorageManager::saveJpegImage(QByteArray data, QVariantMap metadata, QString fileName, | ||
501 | 192 | QSize previewResolution, int captureID) | ||
502 | 193 | { | ||
503 | 194 | SaveToDiskResult result; | ||
504 | 195 | |||
505 | 196 | QString captureFile; | ||
506 | 197 | QFileInfo fi(fileName); | ||
507 | 198 | if (fileName.isEmpty() || fi.isDir()) { | ||
508 | 199 | captureFile = nextPhotoFileName(fileName); | ||
509 | 200 | } else { | ||
510 | 201 | captureFile = fileName; | ||
511 | 202 | } | ||
512 | 203 | result.fileName = captureFile; | ||
513 | 204 | |||
514 | 205 | bool diskOk = checkDirectory(captureFile); | ||
515 | 206 | if (!diskOk) { | ||
516 | 207 | result.errorMessage = QString("Won't be able to save file %1 to disk").arg(captureFile); | ||
517 | 208 | return result; | ||
518 | 209 | } | ||
519 | 210 | |||
520 | 211 | QBuffer buffer(&data); | ||
521 | 212 | QImageReader reader(&buffer, "jpg"); | ||
522 | 213 | |||
523 | 214 | QSize scaledSize = reader.size(); // fast, as it does not decode the JPEG | ||
524 | 215 | scaledSize.scale(previewResolution, Qt::KeepAspectRatio); | ||
525 | 216 | reader.setScaledSize(scaledSize); | ||
526 | 217 | reader.setQuality(25); | ||
527 | 218 | QImage image = reader.read(); | ||
528 | 219 | Q_EMIT previewReady(captureID, image); | ||
529 | 220 | |||
530 | 221 | QTemporaryFile file; | ||
531 | 222 | if (!updateJpegMetadata(data, metadata, &file)) { | ||
532 | 223 | qWarning() << "Failed to update EXIF timestamps. Picture will be saved as UTC timezone."; | ||
533 | 224 | if (!file.open()) { | ||
534 | 225 | result.errorMessage = QString("Could not open temprary file %1").arg(file.fileName()); | ||
535 | 226 | return result; | ||
536 | 227 | } | ||
537 | 228 | |||
538 | 229 | const qint64 writtenSize = file.write(data); | ||
539 | 230 | file.close(); | ||
540 | 231 | if (writtenSize != data.size()) { | ||
541 | 232 | result.errorMessage = QString("Could not write file %1").arg(fileName); | ||
542 | 233 | return result; | ||
543 | 234 | } | ||
544 | 235 | } | ||
545 | 236 | |||
546 | 237 | QFile finalFile(file.fileName()); | ||
547 | 238 | bool ok = finalFile.rename(captureFile); | ||
548 | 239 | if (!ok) { | ||
549 | 240 | result.errorMessage = QString("Could not save image to %1").arg(fileName); | ||
550 | 241 | return result; | ||
551 | 242 | } | ||
552 | 243 | |||
553 | 244 | result.success = true; | ||
554 | 245 | return result; | ||
555 | 246 | } | ||
556 | 247 | |||
557 | 248 | QString StorageManager::decimalToExifRational(double decimal) | ||
558 | 249 | { | ||
559 | 250 | decimal = fabs(decimal); | ||
560 | 251 | unsigned int degrees = floor(decimal); | ||
561 | 252 | unsigned int minutes = floor((decimal - degrees) * 60); | ||
562 | 253 | double seconds = (decimal - degrees - minutes / 60) * 3600; | ||
563 | 254 | seconds = floor(seconds * 100); | ||
564 | 255 | |||
565 | 256 | return QString("%1/1 %2/1 %3/100").arg(degrees).arg(minutes).arg(seconds); | ||
566 | 257 | } | ||
567 | 258 | |||
568 | 259 | SaveToDiskResult::SaveToDiskResult() : success(false) | ||
569 | 260 | { | ||
570 | 261 | } | ||
571 | 90 | 262 | ||
572 | === modified file 'src/storagemanager.h' | |||
573 | --- src/storagemanager.h 2014-09-10 19:48:00 +0000 | |||
574 | +++ src/storagemanager.h 2016-02-23 11:36:01 +0000 | |||
575 | @@ -18,19 +18,43 @@ | |||
576 | 18 | #define STORAGEMANAGER_H | 18 | #define STORAGEMANAGER_H |
577 | 19 | 19 | ||
578 | 20 | #include <QString> | 20 | #include <QString> |
584 | 21 | 21 | #include <QVariantMap> | |
585 | 22 | class StorageManager | 22 | #include <QByteArray> |
586 | 23 | { | 23 | #include <QTemporaryFile> |
587 | 24 | public: | 24 | #include <QImage> |
588 | 25 | StorageManager(); | 25 | |
589 | 26 | class SaveToDiskResult | ||
590 | 27 | { | ||
591 | 28 | public: | ||
592 | 29 | SaveToDiskResult(); | ||
593 | 30 | bool success; | ||
594 | 31 | QString fileName; | ||
595 | 32 | QString errorMessage; | ||
596 | 33 | }; | ||
597 | 34 | |||
598 | 35 | class StorageManager : public QObject | ||
599 | 36 | { | ||
600 | 37 | Q_OBJECT | ||
601 | 38 | |||
602 | 39 | public: | ||
603 | 40 | explicit StorageManager(QObject* parent = 0); | ||
604 | 26 | 41 | ||
605 | 27 | QString nextPhotoFileName(const QString &directoy = QString()); | 42 | QString nextPhotoFileName(const QString &directoy = QString()); |
606 | 28 | QString nextVideoFileName(const QString &directoy = QString()); | 43 | QString nextVideoFileName(const QString &directoy = QString()); |
607 | 29 | 44 | ||
608 | 30 | bool checkDirectory(const QString &path) const; | 45 | bool checkDirectory(const QString &path) const; |
609 | 31 | 46 | ||
610 | 47 | SaveToDiskResult saveJpegImage(QByteArray data, QVariantMap metadata, | ||
611 | 48 | QString fileName, QSize previewResolution, | ||
612 | 49 | int captureID); | ||
613 | 50 | |||
614 | 51 | Q_SIGNALS: | ||
615 | 52 | void previewReady(int captureID, QImage image); | ||
616 | 53 | |||
617 | 32 | private: | 54 | private: |
618 | 33 | QString fileNameGenerator(const QString &base, const QString &extension); | 55 | QString fileNameGenerator(const QString &base, const QString &extension); |
619 | 56 | bool updateJpegMetadata(QByteArray data, QVariantMap metadata, QTemporaryFile* destination); | ||
620 | 57 | QString decimalToExifRational(double decimal); | ||
621 | 34 | 58 | ||
622 | 35 | QString m_directory; | 59 | QString m_directory; |
623 | 36 | }; | 60 | }; |
624 | 37 | 61 | ||
625 | === modified file 'unittests/aalcamerafocuscontrol/aalcamerafocuscontrol.pro' | |||
626 | --- unittests/aalcamerafocuscontrol/aalcamerafocuscontrol.pro 2014-01-16 14:20:08 +0000 | |||
627 | +++ unittests/aalcamerafocuscontrol/aalcamerafocuscontrol.pro 2016-02-23 11:36:01 +0000 | |||
628 | @@ -10,10 +10,12 @@ | |||
629 | 10 | 10 | ||
630 | 11 | HEADERS += ../../src/aalcamerafocuscontrol.h \ | 11 | HEADERS += ../../src/aalcamerafocuscontrol.h \ |
631 | 12 | ../../src/aalcameraservice.h \ | 12 | ../../src/aalcameraservice.h \ |
633 | 13 | ../../src/aalimagecapturecontrol.h | 13 | ../../src/aalimagecapturecontrol.h \ |
634 | 14 | ../../src/storagemanager.h | ||
635 | 14 | 15 | ||
636 | 15 | SOURCES += tst_aalcamerafocuscontrol.cpp \ | 16 | SOURCES += tst_aalcamerafocuscontrol.cpp \ |
637 | 16 | ../../src/aalcamerafocuscontrol.cpp \ | 17 | ../../src/aalcamerafocuscontrol.cpp \ |
638 | 18 | storagemanager.cpp \ | ||
639 | 17 | aalcameraservice.cpp \ | 19 | aalcameraservice.cpp \ |
640 | 18 | aalimagecapturecontrol.cpp | 20 | aalimagecapturecontrol.cpp |
641 | 19 | 21 | ||
642 | 20 | 22 | ||
643 | === modified file 'unittests/aalcamerafocuscontrol/aalimagecapturecontrol.cpp' | |||
644 | --- unittests/aalcamerafocuscontrol/aalimagecapturecontrol.cpp 2013-06-05 16:11:12 +0000 | |||
645 | +++ unittests/aalcamerafocuscontrol/aalimagecapturecontrol.cpp 2016-02-23 11:36:01 +0000 | |||
646 | @@ -19,10 +19,6 @@ | |||
647 | 19 | #include <hybris/camera/camera_compatibility_layer.h> | 19 | #include <hybris/camera/camera_compatibility_layer.h> |
648 | 20 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> | 20 | #include <hybris/camera/camera_compatibility_layer_capabilities.h> |
649 | 21 | 21 | ||
650 | 22 | StorageManager::StorageManager() | ||
651 | 23 | { | ||
652 | 24 | } | ||
653 | 25 | |||
654 | 26 | AalImageCaptureControl::AalImageCaptureControl(AalCameraService *service, QObject *parent) | 22 | AalImageCaptureControl::AalImageCaptureControl(AalCameraService *service, QObject *parent) |
655 | 27 | : QCameraImageCaptureControl(parent) | 23 | : QCameraImageCaptureControl(parent) |
656 | 28 | { | 24 | { |
657 | @@ -54,10 +50,6 @@ | |||
658 | 54 | Q_UNUSED(listener); | 50 | Q_UNUSED(listener); |
659 | 55 | } | 51 | } |
660 | 56 | 52 | ||
661 | 57 | void AalImageCaptureControl::onPreviewReady() | ||
662 | 58 | { | ||
663 | 59 | } | ||
664 | 60 | |||
665 | 61 | void AalImageCaptureControl::setReady(bool ready) | 53 | void AalImageCaptureControl::setReady(bool ready) |
666 | 62 | { | 54 | { |
667 | 63 | Q_UNUSED(ready); | 55 | Q_UNUSED(ready); |
668 | @@ -66,3 +58,13 @@ | |||
669 | 66 | void AalImageCaptureControl::shutter() | 58 | void AalImageCaptureControl::shutter() |
670 | 67 | { | 59 | { |
671 | 68 | } | 60 | } |
672 | 61 | |||
673 | 62 | void AalImageCaptureControl::onImageFileSaved() | ||
674 | 63 | { | ||
675 | 64 | } | ||
676 | 65 | |||
677 | 66 | void AalImageCaptureControl::saveJpeg(const QByteArray& data) | ||
678 | 67 | { | ||
679 | 68 | Q_UNUSED(data); | ||
680 | 69 | } | ||
681 | 70 | |||
682 | 69 | 71 | ||
683 | === added file 'unittests/aalcamerafocuscontrol/storagemanager.cpp' | |||
684 | --- unittests/aalcamerafocuscontrol/storagemanager.cpp 1970-01-01 00:00:00 +0000 | |||
685 | +++ unittests/aalcamerafocuscontrol/storagemanager.cpp 2016-02-23 11:36:01 +0000 | |||
686 | @@ -0,0 +1,76 @@ | |||
687 | 1 | /* | ||
688 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
689 | 3 | * | ||
690 | 4 | * This program is free software; you can redistribute it and/or modify | ||
691 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
692 | 6 | * the Free Software Foundation; version 3. | ||
693 | 7 | * | ||
694 | 8 | * This program is distributed in the hope that it will be useful, | ||
695 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
696 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
697 | 11 | * GNU Lesser General Public License for more details. | ||
698 | 12 | * | ||
699 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
700 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
701 | 15 | */ | ||
702 | 16 | |||
703 | 17 | #include "storagemanager.h" | ||
704 | 18 | |||
705 | 19 | StorageManager::StorageManager(QObject* parent) : QObject(parent) | ||
706 | 20 | { | ||
707 | 21 | } | ||
708 | 22 | |||
709 | 23 | QString StorageManager::nextPhotoFileName(const QString &directoy) | ||
710 | 24 | { | ||
711 | 25 | Q_UNUSED(directoy); | ||
712 | 26 | return QString(); | ||
713 | 27 | } | ||
714 | 28 | |||
715 | 29 | QString StorageManager::nextVideoFileName(const QString &directoy) | ||
716 | 30 | { | ||
717 | 31 | Q_UNUSED(directoy); | ||
718 | 32 | return QString(); | ||
719 | 33 | } | ||
720 | 34 | |||
721 | 35 | bool StorageManager::checkDirectory(const QString &path) const | ||
722 | 36 | { | ||
723 | 37 | Q_UNUSED(path); | ||
724 | 38 | return true; | ||
725 | 39 | } | ||
726 | 40 | |||
727 | 41 | QString StorageManager::fileNameGenerator(const QString &base, const QString& extension) | ||
728 | 42 | { | ||
729 | 43 | Q_UNUSED(base); | ||
730 | 44 | Q_UNUSED(extension); | ||
731 | 45 | return QString(); | ||
732 | 46 | } | ||
733 | 47 | |||
734 | 48 | bool StorageManager::updateJpegMetadata(QByteArray data, QVariantMap metadata, QTemporaryFile* destination) | ||
735 | 49 | { | ||
736 | 50 | Q_UNUSED(data); | ||
737 | 51 | Q_UNUSED(metadata); | ||
738 | 52 | Q_UNUSED(destination); | ||
739 | 53 | |||
740 | 54 | return true; | ||
741 | 55 | } | ||
742 | 56 | |||
743 | 57 | SaveToDiskResult StorageManager::saveJpegImage(QByteArray data, QVariantMap metadata, | ||
744 | 58 | QString fileName, QSize previewResolution, int captureID) | ||
745 | 59 | { | ||
746 | 60 | Q_UNUSED(data); | ||
747 | 61 | Q_UNUSED(metadata); | ||
748 | 62 | Q_UNUSED(fileName); | ||
749 | 63 | Q_UNUSED(captureID); | ||
750 | 64 | Q_UNUSED(previewResolution); | ||
751 | 65 | return SaveToDiskResult(); | ||
752 | 66 | } | ||
753 | 67 | |||
754 | 68 | QString StorageManager::decimalToExifRational(double decimal) | ||
755 | 69 | { | ||
756 | 70 | Q_UNUSED(decimal); | ||
757 | 71 | return QString(); | ||
758 | 72 | } | ||
759 | 73 | |||
760 | 74 | SaveToDiskResult::SaveToDiskResult() : success(false) | ||
761 | 75 | { | ||
762 | 76 | } | ||
763 | 0 | 77 | ||
764 | === modified file 'unittests/aalcamerafocuscontrol/tst_aalcamerafocuscontrol.cpp' | |||
765 | --- unittests/aalcamerafocuscontrol/tst_aalcamerafocuscontrol.cpp 2015-04-08 12:57:01 +0000 | |||
766 | +++ unittests/aalcamerafocuscontrol/tst_aalcamerafocuscontrol.cpp 2016-02-23 11:36:01 +0000 | |||
767 | @@ -127,8 +127,8 @@ | |||
768 | 127 | QTest::addColumn<int>("bottom"); | 127 | QTest::addColumn<int>("bottom"); |
769 | 128 | 128 | ||
770 | 129 | QTest::newRow("center") << (qreal)0.5 << (qreal)0.5 << -100 << 100 << -100 << 100; | 129 | QTest::newRow("center") << (qreal)0.5 << (qreal)0.5 << -100 << 100 << -100 << 100; |
773 | 130 | QTest::newRow("topLeft") << (qreal)0.0 << (qreal)1.0 << -1000 << -800 << -1000 << -800; | 130 | QTest::newRow("topLeft") << (qreal)0.0 << (qreal)1.0 << -1000 << -800 << 800 << 1000; |
774 | 131 | QTest::newRow("bottomRight") << (qreal)1.0 << (qreal)0.0 << 800 << 1000 << 800 << 1000; | 131 | QTest::newRow("bottomRight") << (qreal)1.0 << (qreal)0.0 << 800 << 1000 << -1000 << -800; |
775 | 132 | } | 132 | } |
776 | 133 | 133 | ||
777 | 134 | void tst_AalCameraFocusControl::point2Region() | 134 | void tst_AalCameraFocusControl::point2Region() |
778 | 135 | 135 | ||
779 | === removed directory 'unittests/aalimagecapturecontrol' | |||
780 | === removed file 'unittests/aalimagecapturecontrol/aalcameraservice.cpp' | |||
781 | --- unittests/aalimagecapturecontrol/aalcameraservice.cpp 2015-12-07 15:16:51 +0000 | |||
782 | +++ unittests/aalimagecapturecontrol/aalcameraservice.cpp 1970-01-01 00:00:00 +0000 | |||
783 | @@ -1,99 +0,0 @@ | |||
784 | 1 | /* | ||
785 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
786 | 3 | * | ||
787 | 4 | * This program is free software; you can redistribute it and/or modify | ||
788 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
789 | 6 | * the Free Software Foundation; version 3. | ||
790 | 7 | * | ||
791 | 8 | * This program is distributed in the hope that it will be useful, | ||
792 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
793 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
794 | 11 | * GNU Lesser General Public License for more details. | ||
795 | 12 | * | ||
796 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
797 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
798 | 15 | */ | ||
799 | 16 | |||
800 | 17 | #include "aalcameraservice.h" | ||
801 | 18 | |||
802 | 19 | AalCameraService *AalCameraService::m_service = 0; | ||
803 | 20 | |||
804 | 21 | AalCameraService::AalCameraService(QObject *parent) : | ||
805 | 22 | QMediaService(parent), | ||
806 | 23 | m_androidControl(0), | ||
807 | 24 | m_androidListener(0) | ||
808 | 25 | { | ||
809 | 26 | } | ||
810 | 27 | |||
811 | 28 | AalCameraService::~AalCameraService() | ||
812 | 29 | { | ||
813 | 30 | } | ||
814 | 31 | |||
815 | 32 | QMediaControl *AalCameraService::requestControl(const char *name) | ||
816 | 33 | { | ||
817 | 34 | Q_UNUSED(name); | ||
818 | 35 | return 0; | ||
819 | 36 | } | ||
820 | 37 | |||
821 | 38 | void AalCameraService::releaseControl(QMediaControl *control) | ||
822 | 39 | { | ||
823 | 40 | Q_UNUSED(control); | ||
824 | 41 | } | ||
825 | 42 | |||
826 | 43 | CameraControl *AalCameraService::androidControl() | ||
827 | 44 | { | ||
828 | 45 | return m_androidControl; | ||
829 | 46 | } | ||
830 | 47 | |||
831 | 48 | bool AalCameraService::connectCamera() | ||
832 | 49 | { | ||
833 | 50 | return true; | ||
834 | 51 | } | ||
835 | 52 | |||
836 | 53 | void AalCameraService::disconnectCamera() | ||
837 | 54 | { | ||
838 | 55 | } | ||
839 | 56 | |||
840 | 57 | void AalCameraService::startPreview() | ||
841 | 58 | { | ||
842 | 59 | } | ||
843 | 60 | |||
844 | 61 | void AalCameraService::stopPreview() | ||
845 | 62 | { | ||
846 | 63 | } | ||
847 | 64 | |||
848 | 65 | bool AalCameraService::isPreviewStarted() const | ||
849 | 66 | { | ||
850 | 67 | return true; | ||
851 | 68 | } | ||
852 | 69 | |||
853 | 70 | void AalCameraService::onApplicationStateChanged() | ||
854 | 71 | { | ||
855 | 72 | } | ||
856 | 73 | |||
857 | 74 | void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener) | ||
858 | 75 | { | ||
859 | 76 | Q_UNUSED(camControl); | ||
860 | 77 | Q_UNUSED(listener); | ||
861 | 78 | } | ||
862 | 79 | |||
863 | 80 | bool AalCameraService::isCameraActive() const | ||
864 | 81 | { | ||
865 | 82 | return true; | ||
866 | 83 | } | ||
867 | 84 | |||
868 | 85 | bool AalCameraService::isBackCameraUsed() const | ||
869 | 86 | { | ||
870 | 87 | return true; | ||
871 | 88 | } | ||
872 | 89 | |||
873 | 90 | void AalCameraService::updateCaptureReady() | ||
874 | 91 | { | ||
875 | 92 | } | ||
876 | 93 | |||
877 | 94 | QSize AalCameraService::selectSizeWithAspectRatio(const QList<QSize> &sizes, float targetAspectRatio) const | ||
878 | 95 | { | ||
879 | 96 | Q_UNUSED(sizes); | ||
880 | 97 | Q_UNUSED(targetAspectRatio); | ||
881 | 98 | return QSize(); | ||
882 | 99 | } | ||
883 | 100 | 0 | ||
884 | === removed file 'unittests/aalimagecapturecontrol/aalimagecapturecontrol.pro' | |||
885 | --- unittests/aalimagecapturecontrol/aalimagecapturecontrol.pro 2014-09-23 18:12:45 +0000 | |||
886 | +++ unittests/aalimagecapturecontrol/aalimagecapturecontrol.pro 1970-01-01 00:00:00 +0000 | |||
887 | @@ -1,31 +0,0 @@ | |||
888 | 1 | include(../../coverage.pri) | ||
889 | 2 | |||
890 | 3 | TARGET = tst_aalimagecapturecontrol | ||
891 | 4 | |||
892 | 5 | QT += testlib multimedia opengl | ||
893 | 6 | |||
894 | 7 | LIBS += -L../mocks/aal -laal | ||
895 | 8 | INCLUDEPATH += ../../src | ||
896 | 9 | INCLUDEPATH += ../mocks/aal | ||
897 | 10 | |||
898 | 11 | CONFIG += link_pkgconfig | ||
899 | 12 | PKGCONFIG += exiv2 | ||
900 | 13 | |||
901 | 14 | HEADERS += ../../src/aalimagecapturecontrol.h \ | ||
902 | 15 | ../../src/aalcameraservice.h \ | ||
903 | 16 | ../../src/aalimageencodercontrol.h \ | ||
904 | 17 | ../../src/aalmetadatawritercontrol.h \ | ||
905 | 18 | ../../src/aalvideorenderercontrol.h \ | ||
906 | 19 | ../../src/storagemanager.h | ||
907 | 20 | |||
908 | 21 | SOURCES += tst_aalimagecapturecontrol.cpp \ | ||
909 | 22 | ../../src/aalimagecapturecontrol.cpp \ | ||
910 | 23 | aalcameraservice.cpp \ | ||
911 | 24 | aalimageencodercontrol.cpp \ | ||
912 | 25 | ../stubs/aalmetadatawritercontrol_stub.cpp \ | ||
913 | 26 | aalvideorenderercontrol.cpp \ | ||
914 | 27 | storagemanager.cpp | ||
915 | 28 | |||
916 | 29 | check.depends = $${TARGET} | ||
917 | 30 | check.commands = ./$${TARGET} | ||
918 | 31 | QMAKE_EXTRA_TARGETS += check | ||
919 | 32 | 0 | ||
920 | === removed file 'unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp' | |||
921 | --- unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp 2015-10-14 21:22:46 +0000 | |||
922 | +++ unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp 1970-01-01 00:00:00 +0000 | |||
923 | @@ -1,125 +0,0 @@ | |||
924 | 1 | /* | ||
925 | 2 | * Copyright (C) 2013-2014 Canonical, Ltd. | ||
926 | 3 | * | ||
927 | 4 | * This program is free software; you can redistribute it and/or modify | ||
928 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
929 | 6 | * the Free Software Foundation; version 3. | ||
930 | 7 | * | ||
931 | 8 | * This program is distributed in the hope that it will be useful, | ||
932 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
933 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
934 | 11 | * GNU Lesser General Public License for more details. | ||
935 | 12 | * | ||
936 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
937 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
938 | 15 | */ | ||
939 | 16 | |||
940 | 17 | #include <QImageEncoderControl> | ||
941 | 18 | #include <QList> | ||
942 | 19 | #include <QString> | ||
943 | 20 | #include <QStringList> | ||
944 | 21 | |||
945 | 22 | #include <QDebug> | ||
946 | 23 | |||
947 | 24 | #include "aalimageencodercontrol.h" | ||
948 | 25 | |||
949 | 26 | AalImageEncoderControl::AalImageEncoderControl(AalCameraService *service, QObject *parent) | ||
950 | 27 | : QImageEncoderControl(parent), | ||
951 | 28 | m_service(service), | ||
952 | 29 | m_currentSize() | ||
953 | 30 | { | ||
954 | 31 | } | ||
955 | 32 | |||
956 | 33 | AalImageEncoderControl::~AalImageEncoderControl() | ||
957 | 34 | { | ||
958 | 35 | } | ||
959 | 36 | |||
960 | 37 | QString AalImageEncoderControl::imageCodecDescription(const QString &codec) const | ||
961 | 38 | { | ||
962 | 39 | Q_UNUSED(codec); | ||
963 | 40 | return QString(); | ||
964 | 41 | } | ||
965 | 42 | |||
966 | 43 | QImageEncoderSettings AalImageEncoderControl::imageSettings() const | ||
967 | 44 | { | ||
968 | 45 | return QImageEncoderSettings(); | ||
969 | 46 | } | ||
970 | 47 | |||
971 | 48 | void AalImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings) | ||
972 | 49 | { | ||
973 | 50 | Q_UNUSED(settings); | ||
974 | 51 | } | ||
975 | 52 | |||
976 | 53 | QStringList AalImageEncoderControl::supportedImageCodecs() const | ||
977 | 54 | { | ||
978 | 55 | return QStringList(); | ||
979 | 56 | } | ||
980 | 57 | |||
981 | 58 | QList<QSize> AalImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const | ||
982 | 59 | { | ||
983 | 60 | Q_UNUSED(settings); | ||
984 | 61 | Q_UNUSED(continuous); | ||
985 | 62 | |||
986 | 63 | return QList<QSize>(); | ||
987 | 64 | } | ||
988 | 65 | |||
989 | 66 | QList<QSize> AalImageEncoderControl::supportedThumbnailResolutions(const QImageEncoderSettings &settings, bool *continuous) const | ||
990 | 67 | { | ||
991 | 68 | Q_UNUSED(settings); | ||
992 | 69 | Q_UNUSED(continuous); | ||
993 | 70 | |||
994 | 71 | return QList<QSize>(); | ||
995 | 72 | } | ||
996 | 73 | |||
997 | 74 | void AalImageEncoderControl::init(CameraControl *control) | ||
998 | 75 | { | ||
999 | 76 | Q_UNUSED(control); | ||
1000 | 77 | } | ||
1001 | 78 | |||
1002 | 79 | bool AalImageEncoderControl::setSize(const QSize &size) | ||
1003 | 80 | { | ||
1004 | 81 | Q_UNUSED(size); | ||
1005 | 82 | return true; | ||
1006 | 83 | } | ||
1007 | 84 | |||
1008 | 85 | void AalImageEncoderControl::resetAllSettings() | ||
1009 | 86 | { | ||
1010 | 87 | } | ||
1011 | 88 | |||
1012 | 89 | void AalImageEncoderControl::getPictureSizeCb(void *ctx, int width, int height) | ||
1013 | 90 | { | ||
1014 | 91 | Q_UNUSED(ctx); | ||
1015 | 92 | Q_UNUSED(width); | ||
1016 | 93 | Q_UNUSED(height); | ||
1017 | 94 | } | ||
1018 | 95 | |||
1019 | 96 | void AalImageEncoderControl::getPictureSize(int width, int height) | ||
1020 | 97 | { | ||
1021 | 98 | Q_UNUSED(width); | ||
1022 | 99 | Q_UNUSED(height); | ||
1023 | 100 | } | ||
1024 | 101 | |||
1025 | 102 | void AalImageEncoderControl::getThumbnailSizeCb(void *ctx, int width, int height) | ||
1026 | 103 | { | ||
1027 | 104 | Q_UNUSED(ctx); | ||
1028 | 105 | Q_UNUSED(width); | ||
1029 | 106 | Q_UNUSED(height); | ||
1030 | 107 | } | ||
1031 | 108 | |||
1032 | 109 | void AalImageEncoderControl::getThumbnailSize(int width, int height) | ||
1033 | 110 | { | ||
1034 | 111 | Q_UNUSED(width); | ||
1035 | 112 | Q_UNUSED(height); | ||
1036 | 113 | } | ||
1037 | 114 | |||
1038 | 115 | QMultimedia::EncodingQuality AalImageEncoderControl::jpegQualityToQtEncodingQuality(int jpegQuality) | ||
1039 | 116 | { | ||
1040 | 117 | Q_UNUSED(jpegQuality) | ||
1041 | 118 | return QMultimedia::NormalQuality; | ||
1042 | 119 | } | ||
1043 | 120 | |||
1044 | 121 | int AalImageEncoderControl::qtEncodingQualityToJpegQuality(QMultimedia::EncodingQuality quality) | ||
1045 | 122 | { | ||
1046 | 123 | Q_UNUSED(quality) | ||
1047 | 124 | return 100; | ||
1048 | 125 | } | ||
1049 | 126 | 0 | ||
1050 | === removed file 'unittests/aalimagecapturecontrol/aalvideorenderercontrol.cpp' | |||
1051 | --- unittests/aalimagecapturecontrol/aalvideorenderercontrol.cpp 2015-12-07 15:16:51 +0000 | |||
1052 | +++ unittests/aalimagecapturecontrol/aalvideorenderercontrol.cpp 1970-01-01 00:00:00 +0000 | |||
1053 | @@ -1,84 +0,0 @@ | |||
1054 | 1 | /* | ||
1055 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
1056 | 3 | * | ||
1057 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1058 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1059 | 6 | * the Free Software Foundation; version 3. | ||
1060 | 7 | * | ||
1061 | 8 | * This program is distributed in the hope that it will be useful, | ||
1062 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1063 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1064 | 11 | * GNU Lesser General Public License for more details. | ||
1065 | 12 | * | ||
1066 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1067 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1068 | 15 | */ | ||
1069 | 16 | |||
1070 | 17 | #include "aalvideorenderercontrol.h" | ||
1071 | 18 | #include "aalcameraservice.h" | ||
1072 | 19 | |||
1073 | 20 | |||
1074 | 21 | AalVideoRendererControl::AalVideoRendererControl(AalCameraService *service, QObject *parent) | ||
1075 | 22 | : QVideoRendererControl(parent) | ||
1076 | 23 | , m_surface(0), | ||
1077 | 24 | m_service(service), | ||
1078 | 25 | m_viewFinderRunning(false), | ||
1079 | 26 | m_textureId(0) | ||
1080 | 27 | { | ||
1081 | 28 | } | ||
1082 | 29 | |||
1083 | 30 | AalVideoRendererControl::~AalVideoRendererControl() | ||
1084 | 31 | { | ||
1085 | 32 | } | ||
1086 | 33 | |||
1087 | 34 | QAbstractVideoSurface *AalVideoRendererControl::surface() const | ||
1088 | 35 | { | ||
1089 | 36 | return m_surface; | ||
1090 | 37 | } | ||
1091 | 38 | |||
1092 | 39 | void AalVideoRendererControl::setSurface(QAbstractVideoSurface *surface) | ||
1093 | 40 | { | ||
1094 | 41 | Q_UNUSED(surface); | ||
1095 | 42 | } | ||
1096 | 43 | |||
1097 | 44 | void AalVideoRendererControl::init(CameraControl *control, CameraControlListener *listener) | ||
1098 | 45 | { | ||
1099 | 46 | Q_UNUSED(control); | ||
1100 | 47 | Q_UNUSED(listener); | ||
1101 | 48 | } | ||
1102 | 49 | |||
1103 | 50 | void AalVideoRendererControl::startPreview() | ||
1104 | 51 | { | ||
1105 | 52 | } | ||
1106 | 53 | |||
1107 | 54 | void AalVideoRendererControl::stopPreview() | ||
1108 | 55 | { | ||
1109 | 56 | } | ||
1110 | 57 | |||
1111 | 58 | bool AalVideoRendererControl::isPreviewStarted() const | ||
1112 | 59 | { | ||
1113 | 60 | return true; | ||
1114 | 61 | } | ||
1115 | 62 | |||
1116 | 63 | void AalVideoRendererControl::updateViewfinderFrame() | ||
1117 | 64 | { | ||
1118 | 65 | } | ||
1119 | 66 | |||
1120 | 67 | void AalVideoRendererControl::onTextureCreated(unsigned int textureID) | ||
1121 | 68 | { | ||
1122 | 69 | Q_UNUSED(textureID); | ||
1123 | 70 | } | ||
1124 | 71 | |||
1125 | 72 | void AalVideoRendererControl::onSnapshotTaken(QImage snapshotImage) | ||
1126 | 73 | { | ||
1127 | 74 | Q_UNUSED(snapshotImage); | ||
1128 | 75 | } | ||
1129 | 76 | |||
1130 | 77 | const QImage &AalVideoRendererControl::preview() const | ||
1131 | 78 | { | ||
1132 | 79 | return m_preview; | ||
1133 | 80 | } | ||
1134 | 81 | |||
1135 | 82 | void AalVideoRendererControl::createPreview() | ||
1136 | 83 | { | ||
1137 | 84 | } | ||
1138 | 85 | 0 | ||
1139 | === removed file 'unittests/aalimagecapturecontrol/storagemanager.cpp' | |||
1140 | --- unittests/aalimagecapturecontrol/storagemanager.cpp 2014-09-10 19:48:00 +0000 | |||
1141 | +++ unittests/aalimagecapturecontrol/storagemanager.cpp 1970-01-01 00:00:00 +0000 | |||
1142 | @@ -1,50 +0,0 @@ | |||
1143 | 1 | /* | ||
1144 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
1145 | 3 | * | ||
1146 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1147 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1148 | 6 | * the Free Software Foundation; version 3. | ||
1149 | 7 | * | ||
1150 | 8 | * This program is distributed in the hope that it will be useful, | ||
1151 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1152 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1153 | 11 | * GNU Lesser General Public License for more details. | ||
1154 | 12 | * | ||
1155 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1156 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1157 | 15 | */ | ||
1158 | 16 | |||
1159 | 17 | #include <QDebug> | ||
1160 | 18 | #include <QString> | ||
1161 | 19 | |||
1162 | 20 | #include "storagemanager.h" | ||
1163 | 21 | |||
1164 | 22 | StorageManager::StorageManager() | ||
1165 | 23 | { | ||
1166 | 24 | } | ||
1167 | 25 | |||
1168 | 26 | QString StorageManager::nextPhotoFileName(const QString &directory) | ||
1169 | 27 | { | ||
1170 | 28 | Q_UNUSED(directory); | ||
1171 | 29 | return QString(); | ||
1172 | 30 | } | ||
1173 | 31 | |||
1174 | 32 | QString StorageManager::nextVideoFileName(const QString &directory) | ||
1175 | 33 | { | ||
1176 | 34 | Q_UNUSED(directory); | ||
1177 | 35 | return QString(); | ||
1178 | 36 | } | ||
1179 | 37 | |||
1180 | 38 | bool StorageManager::checkDirectory(const QString &path) const | ||
1181 | 39 | { | ||
1182 | 40 | Q_UNUSED(path); | ||
1183 | 41 | return true; | ||
1184 | 42 | } | ||
1185 | 43 | |||
1186 | 44 | QString StorageManager::fileNameGenerator(const QString &base, | ||
1187 | 45 | const QString& extension) | ||
1188 | 46 | { | ||
1189 | 47 | Q_UNUSED(base); | ||
1190 | 48 | Q_UNUSED(extension); | ||
1191 | 49 | return QString(); | ||
1192 | 50 | } | ||
1193 | 51 | 0 | ||
1194 | === removed file 'unittests/aalimagecapturecontrol/tst_aalimagecapturecontrol.cpp' | |||
1195 | --- unittests/aalimagecapturecontrol/tst_aalimagecapturecontrol.cpp 2015-10-14 21:22:46 +0000 | |||
1196 | +++ unittests/aalimagecapturecontrol/tst_aalimagecapturecontrol.cpp 1970-01-01 00:00:00 +0000 | |||
1197 | @@ -1,74 +0,0 @@ | |||
1198 | 1 | /* | ||
1199 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
1200 | 3 | * | ||
1201 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1202 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1203 | 6 | * the Free Software Foundation; version 3. | ||
1204 | 7 | * | ||
1205 | 8 | * This program is distributed in the hope that it will be useful, | ||
1206 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1207 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1208 | 11 | * GNU Lesser General Public License for more details. | ||
1209 | 12 | * | ||
1210 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1211 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1212 | 15 | */ | ||
1213 | 16 | |||
1214 | 17 | #include <QtTest/QtTest> | ||
1215 | 18 | #include <cmath> | ||
1216 | 19 | |||
1217 | 20 | #include "aalcameraservice.h" | ||
1218 | 21 | #include "data_validjpeg.h" | ||
1219 | 22 | #include "data_noexifjpeg.h" | ||
1220 | 23 | |||
1221 | 24 | #define private public | ||
1222 | 25 | #include "aalimagecapturecontrol.h" | ||
1223 | 26 | |||
1224 | 27 | class tst_AalImageCaptureControl : public QObject | ||
1225 | 28 | { | ||
1226 | 29 | Q_OBJECT | ||
1227 | 30 | private slots: | ||
1228 | 31 | void initTestCase(); | ||
1229 | 32 | void cleanupTestCase(); | ||
1230 | 33 | |||
1231 | 34 | void updateEXIF(); | ||
1232 | 35 | |||
1233 | 36 | private: | ||
1234 | 37 | AalImageCaptureControl *m_icControl; | ||
1235 | 38 | AalCameraService *m_service; | ||
1236 | 39 | |||
1237 | 40 | friend class AalImageCaptureControl; | ||
1238 | 41 | }; | ||
1239 | 42 | |||
1240 | 43 | void tst_AalImageCaptureControl::initTestCase() | ||
1241 | 44 | { | ||
1242 | 45 | m_service = new AalCameraService(); | ||
1243 | 46 | m_icControl = new AalImageCaptureControl(m_service); | ||
1244 | 47 | } | ||
1245 | 48 | |||
1246 | 49 | void tst_AalImageCaptureControl::cleanupTestCase() | ||
1247 | 50 | { | ||
1248 | 51 | delete m_icControl; | ||
1249 | 52 | delete m_service; | ||
1250 | 53 | } | ||
1251 | 54 | |||
1252 | 55 | void tst_AalImageCaptureControl::updateEXIF() | ||
1253 | 56 | { | ||
1254 | 57 | bool result; | ||
1255 | 58 | QTemporaryFile tmp; | ||
1256 | 59 | char *invalidJPEG = "INVALID_IMAGE"; | ||
1257 | 60 | result = m_icControl->updateJpegMetadata(0, 0, &tmp); | ||
1258 | 61 | QCOMPARE(result, false); | ||
1259 | 62 | result = m_icControl->updateJpegMetadata(invalidJPEG, strlen(invalidJPEG), 0); | ||
1260 | 63 | QCOMPARE(result, false); | ||
1261 | 64 | result = m_icControl->updateJpegMetadata(invalidJPEG, strlen(invalidJPEG), &tmp); | ||
1262 | 65 | QCOMPARE(result, false); | ||
1263 | 66 | result = m_icControl->updateJpegMetadata(data_validjpeg, data_validjpeg_len, &tmp); | ||
1264 | 67 | QCOMPARE(result, true); | ||
1265 | 68 | result = m_icControl->updateJpegMetadata(data_noexifjpeg, data_noexifjpeg_len, &tmp); | ||
1266 | 69 | QCOMPARE(result, true); | ||
1267 | 70 | } | ||
1268 | 71 | |||
1269 | 72 | QTEST_GUILESS_MAIN(tst_AalImageCaptureControl) | ||
1270 | 73 | |||
1271 | 74 | #include "tst_aalimagecapturecontrol.moc" | ||
1272 | 75 | 0 | ||
1273 | === renamed file 'unittests/aalimagecapturecontrol/data_noexifjpeg.h' => 'unittests/storagemanager/data_noexifjpeg.h' | |||
1274 | === renamed file 'unittests/aalimagecapturecontrol/data_validjpeg.h' => 'unittests/storagemanager/data_validjpeg.h' | |||
1275 | === modified file 'unittests/storagemanager/storagemanager.pro' | |||
1276 | --- unittests/storagemanager/storagemanager.pro 2013-06-13 19:13:27 +0000 | |||
1277 | +++ unittests/storagemanager/storagemanager.pro 2016-02-23 11:36:01 +0000 | |||
1278 | @@ -4,6 +4,11 @@ | |||
1279 | 4 | 4 | ||
1280 | 5 | QT += testlib | 5 | QT += testlib |
1281 | 6 | 6 | ||
1282 | 7 | CONFIG += link_pkgconfig | ||
1283 | 8 | PKGCONFIG += exiv2 | ||
1284 | 9 | |||
1285 | 10 | HEADERS += ../../src/storagemanager.h | ||
1286 | 11 | |||
1287 | 7 | SOURCES += tst_storagemanager.cpp \ | 12 | SOURCES += tst_storagemanager.cpp \ |
1288 | 8 | ../../src/storagemanager.cpp | 13 | ../../src/storagemanager.cpp |
1289 | 9 | 14 | ||
1290 | 10 | 15 | ||
1291 | === modified file 'unittests/storagemanager/tst_storagemanager.cpp' | |||
1292 | --- unittests/storagemanager/tst_storagemanager.cpp 2014-09-10 19:48:00 +0000 | |||
1293 | +++ unittests/storagemanager/tst_storagemanager.cpp 2016-02-23 11:36:01 +0000 | |||
1294 | @@ -22,6 +22,8 @@ | |||
1295 | 22 | 22 | ||
1296 | 23 | #define private public | 23 | #define private public |
1297 | 24 | #include "storagemanager.h" | 24 | #include "storagemanager.h" |
1298 | 25 | #include "data_validjpeg.h" | ||
1299 | 26 | #include "data_noexifjpeg.h" | ||
1300 | 25 | 27 | ||
1301 | 26 | const QLatin1String testPath("/tmp/aalCameraStorageManagerUnitTestDirectory0192837465/"); | 28 | const QLatin1String testPath("/tmp/aalCameraStorageManagerUnitTestDirectory0192837465/"); |
1302 | 27 | 29 | ||
1303 | @@ -34,6 +36,7 @@ | |||
1304 | 34 | void checkDirectory(); | 36 | void checkDirectory(); |
1305 | 35 | void fileNameGenerator_data(); | 37 | void fileNameGenerator_data(); |
1306 | 36 | void fileNameGenerator(); | 38 | void fileNameGenerator(); |
1307 | 39 | void updateEXIF(); | ||
1308 | 37 | 40 | ||
1309 | 38 | private: | 41 | private: |
1310 | 39 | void removeTestDirectory(); | 42 | void removeTestDirectory(); |
1311 | @@ -112,6 +115,25 @@ | |||
1312 | 112 | dir.rmdir(testPath); | 115 | dir.rmdir(testPath); |
1313 | 113 | } | 116 | } |
1314 | 114 | 117 | ||
1315 | 118 | void tst_StorageManager::updateEXIF() | ||
1316 | 119 | { | ||
1317 | 120 | StorageManager storage; | ||
1318 | 121 | bool result; | ||
1319 | 122 | QTemporaryFile tmp; | ||
1320 | 123 | QVariantMap metadata; | ||
1321 | 124 | QByteArray invalidJPEG("INVALID_IMAGE"); | ||
1322 | 125 | result = storage.updateJpegMetadata(invalidJPEG, metadata, &tmp); | ||
1323 | 126 | QCOMPARE(result, false); | ||
1324 | 127 | result = storage.updateJpegMetadata(invalidJPEG, metadata, 0); | ||
1325 | 128 | QCOMPARE(result, false); | ||
1326 | 129 | result = storage.updateJpegMetadata(invalidJPEG, metadata, &tmp); | ||
1327 | 130 | QCOMPARE(result, false); | ||
1328 | 131 | result = storage.updateJpegMetadata(QByteArray((char*)data_validjpeg, data_validjpeg_len), metadata, &tmp); | ||
1329 | 132 | QCOMPARE(result, true); | ||
1330 | 133 | result = storage.updateJpegMetadata(QByteArray((char*)data_noexifjpeg, data_noexifjpeg_len), metadata, &tmp); | ||
1331 | 134 | QCOMPARE(result, true); | ||
1332 | 135 | } | ||
1333 | 136 | |||
1334 | 115 | QTEST_GUILESS_MAIN(tst_StorageManager); | 137 | QTEST_GUILESS_MAIN(tst_StorageManager); |
1335 | 116 | 138 | ||
1336 | 117 | #include "tst_storagemanager.moc" | 139 | #include "tst_storagemanager.moc" |
1337 | 118 | 140 | ||
1338 | === modified file 'unittests/stubs/storagemanager_stub.cpp' | |||
1339 | --- unittests/stubs/storagemanager_stub.cpp 2014-09-10 19:48:00 +0000 | |||
1340 | +++ unittests/stubs/storagemanager_stub.cpp 2016-02-23 11:36:01 +0000 | |||
1341 | @@ -19,8 +19,9 @@ | |||
1342 | 19 | 19 | ||
1343 | 20 | #include "storagemanager.h" | 20 | #include "storagemanager.h" |
1344 | 21 | 21 | ||
1346 | 22 | StorageManager::StorageManager() | 22 | StorageManager::StorageManager(QObject* parent) |
1347 | 23 | { | 23 | { |
1348 | 24 | Q_UNUSED(parent); | ||
1349 | 24 | } | 25 | } |
1350 | 25 | 26 | ||
1351 | 26 | QString StorageManager::nextPhotoFileName(const QString &directory) | 27 | QString StorageManager::nextPhotoFileName(const QString &directory) |
1352 | 27 | 28 | ||
1353 | === modified file 'unittests/unittests.pro' | |||
1354 | --- unittests/unittests.pro 2014-07-14 16:18:14 +0000 | |||
1355 | +++ unittests/unittests.pro 2016-02-23 11:36:01 +0000 | |||
1356 | @@ -7,7 +7,6 @@ | |||
1357 | 7 | aalcameraflashcontrol \ | 7 | aalcameraflashcontrol \ |
1358 | 8 | aalcamerafocuscontrol \ | 8 | aalcamerafocuscontrol \ |
1359 | 9 | aalcamerazoomcontrol \ | 9 | aalcamerazoomcontrol \ |
1360 | 10 | aalimagecapturecontrol \ | ||
1361 | 11 | aalmediarecordercontrol \ | 10 | aalmediarecordercontrol \ |
1362 | 12 | aalvideodeviceselectorcontrol \ | 11 | aalvideodeviceselectorcontrol \ |
1363 | 13 | aalviewfindersettingscontrol \ | 12 | aalviewfindersettingscontrol \ |
PASSED: Continuous integration, rev:179 jenkins. qa.ubuntu. com/job/ qtubuntu- camera- ci/139/ jenkins. qa.ubuntu. com/job/ qtubuntu- camera- vivid-amd64- ci/42 jenkins. qa.ubuntu. com/job/ qtubuntu- camera- vivid-armhf- ci/43 jenkins. qa.ubuntu. com/job/ qtubuntu- camera- vivid-armhf- ci/43/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ qtubuntu- camera- vivid-i386- ci/42
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtubuntu- camera- ci/139/ rebuild
http://