blob: a83632153f6176d5f5e2dfdb3b3b1d66aefb447a [file] [log] [blame]
Eino-Ville Talvala69230df2012-08-29 17:37:16 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "Camera2Client::CaptureSequencer"
18#define ATRACE_TAG ATRACE_TAG_CAMERA
19//#define LOG_NDEBUG 0
20
21#include <utils/Log.h>
22#include <utils/Trace.h>
23#include <utils/Vector.h>
24
25#include "CaptureSequencer.h"
James Painterc3dbf1a2012-09-05 18:02:32 -070026#include "BurstCapture.h"
Eino-Ville Talvala69230df2012-08-29 17:37:16 -070027#include "../Camera2Device.h"
28#include "../Camera2Client.h"
29#include "Parameters.h"
30
31namespace android {
32namespace camera2 {
33
34/** Public members */
35
36CaptureSequencer::CaptureSequencer(wp<Camera2Client> client):
37 Thread(false),
38 mStartCapture(false),
39 mBusy(false),
40 mNewAEState(false),
41 mNewFrameReceived(false),
42 mNewCaptureReceived(false),
43 mClient(client),
44 mCaptureState(IDLE),
45 mTriggerId(0),
46 mTimeoutCount(0),
47 mCaptureId(Camera2Client::kFirstCaptureRequestId) {
James Painterc3dbf1a2012-09-05 18:02:32 -070048 ALOGV("%s", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -070049}
50
51CaptureSequencer::~CaptureSequencer() {
52 ALOGV("%s: Exit", __FUNCTION__);
53}
54
55void CaptureSequencer::setZslProcessor(wp<ZslProcessor> processor) {
56 Mutex::Autolock l(mInputMutex);
57 mZslProcessor = processor;
58}
59
60status_t CaptureSequencer::startCapture() {
James Painterc3dbf1a2012-09-05 18:02:32 -070061 ALOGV("%s", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -070062 ATRACE_CALL();
63 Mutex::Autolock l(mInputMutex);
64 if (mBusy) {
65 ALOGE("%s: Already busy capturing!", __FUNCTION__);
66 return INVALID_OPERATION;
67 }
68 if (!mStartCapture) {
69 mStartCapture = true;
70 mStartCaptureSignal.signal();
71 }
72 return OK;
73}
74
75void CaptureSequencer::notifyAutoExposure(uint8_t newState, int triggerId) {
76 ATRACE_CALL();
77 Mutex::Autolock l(mInputMutex);
78 mAEState = newState;
79 mAETriggerId = triggerId;
80 if (!mNewAEState) {
81 mNewAEState = true;
82 mNewNotifySignal.signal();
83 }
84}
85
86void CaptureSequencer::onFrameAvailable(int32_t frameId,
87 CameraMetadata &frame) {
James Painterc3dbf1a2012-09-05 18:02:32 -070088 ALOGV("%s: Listener found new frame", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -070089 ATRACE_CALL();
90 Mutex::Autolock l(mInputMutex);
91 mNewFrameId = frameId;
92 mNewFrame.acquire(frame);
93 if (!mNewFrameReceived) {
94 mNewFrameReceived = true;
95 mNewFrameSignal.signal();
96 }
97}
98
Eino-Ville Talvala52e9ad42012-09-19 17:09:15 -070099void CaptureSequencer::onCaptureAvailable(nsecs_t timestamp,
100 sp<MemoryBase> captureBuffer) {
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700101 ATRACE_CALL();
James Painterc3dbf1a2012-09-05 18:02:32 -0700102 ALOGV("%s", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700103 Mutex::Autolock l(mInputMutex);
104 mCaptureTimestamp = timestamp;
Eino-Ville Talvala52e9ad42012-09-19 17:09:15 -0700105 mCaptureBuffer = captureBuffer;
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700106 if (!mNewCaptureReceived) {
107 mNewCaptureReceived = true;
108 mNewCaptureSignal.signal();
109 }
110}
111
112
113void CaptureSequencer::dump(int fd, const Vector<String16>& args) {
114 String8 result;
115 if (mCaptureRequest.entryCount() != 0) {
116 result = " Capture request:\n";
117 write(fd, result.string(), result.size());
118 mCaptureRequest.dump(fd, 2, 6);
119 } else {
120 result = " Capture request: undefined\n";
121 write(fd, result.string(), result.size());
122 }
123 result = String8::format(" Current capture state: %s\n",
124 kStateNames[mCaptureState]);
125 result.append(" Latest captured frame:\n");
126 write(fd, result.string(), result.size());
127 mNewFrame.dump(fd, 2, 6);
128}
129
130/** Private members */
131
132const char* CaptureSequencer::kStateNames[CaptureSequencer::NUM_CAPTURE_STATES+1] =
133{
134 "IDLE",
135 "START",
136 "ZSL_START",
137 "ZSL_WAITING",
138 "ZSL_REPROCESSING",
139 "STANDARD_START",
140 "STANDARD_PRECAPTURE",
141 "STANDARD_CAPTURING",
James Painterc3dbf1a2012-09-05 18:02:32 -0700142 "BURST_CAPTURE_START",
143 "BURST_CAPTURE_WAIT",
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700144 "DONE",
145 "ERROR",
146 "UNKNOWN"
147};
148
149const CaptureSequencer::StateManager
150 CaptureSequencer::kStateManagers[CaptureSequencer::NUM_CAPTURE_STATES-1] = {
151 &CaptureSequencer::manageIdle,
152 &CaptureSequencer::manageStart,
153 &CaptureSequencer::manageZslStart,
154 &CaptureSequencer::manageZslWaiting,
155 &CaptureSequencer::manageZslReprocessing,
156 &CaptureSequencer::manageStandardStart,
157 &CaptureSequencer::manageStandardPrecaptureWait,
158 &CaptureSequencer::manageStandardCapture,
159 &CaptureSequencer::manageStandardCaptureWait,
James Painterc3dbf1a2012-09-05 18:02:32 -0700160 &CaptureSequencer::manageBurstCaptureStart,
161 &CaptureSequencer::manageBurstCaptureWait,
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700162 &CaptureSequencer::manageDone,
163};
164
165bool CaptureSequencer::threadLoop() {
166 status_t res;
167
168 sp<Camera2Client> client = mClient.promote();
169 if (client == 0) return false;
170
171 if (mCaptureState < ERROR) {
172 mCaptureState = (this->*kStateManagers[mCaptureState])(client);
173 } else {
174 ALOGE("%s: Bad capture state: %s",
175 __FUNCTION__, kStateNames[mCaptureState]);
176 return false;
177 }
178
179 return true;
180}
181
182CaptureSequencer::CaptureState CaptureSequencer::manageIdle(sp<Camera2Client> &client) {
183 status_t res;
184 ATRACE_CALL();
185 Mutex::Autolock l(mInputMutex);
186 while (!mStartCapture) {
187 res = mStartCaptureSignal.waitRelative(mInputMutex,
188 kWaitDuration);
189 if (res == TIMED_OUT) break;
190 }
191 if (mStartCapture) {
192 mStartCapture = false;
193 mBusy = true;
194 return START;
195 }
196 return IDLE;
197}
198
199CaptureSequencer::CaptureState CaptureSequencer::manageDone(sp<Camera2Client> &client) {
Eino-Ville Talvala52e9ad42012-09-19 17:09:15 -0700200 status_t res = OK;
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700201 ATRACE_CALL();
202 mCaptureId++;
203
204 {
205 Mutex::Autolock l(mInputMutex);
206 mBusy = false;
207 }
208
Eino-Ville Talvala52e9ad42012-09-19 17:09:15 -0700209 {
210 SharedParameters::Lock l(client->getParameters());
211 switch (l.mParameters.state) {
212 case Parameters::STILL_CAPTURE:
213 l.mParameters.state = Parameters::STOPPED;
214 break;
215 case Parameters::VIDEO_SNAPSHOT:
216 l.mParameters.state = Parameters::RECORD;
217 break;
218 default:
219 ALOGE("%s: Camera %d: Still image produced unexpectedly "
220 "in state %s!",
221 __FUNCTION__, client->getCameraId(),
222 Parameters::getStateName(l.mParameters.state));
223 res = INVALID_OPERATION;
224 }
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700225 }
Eino-Ville Talvala5a8fed02012-09-19 17:11:04 -0700226 sp<ZslProcessor> processor = mZslProcessor.promote();
227 if (processor != 0) {
228 processor->clearZslQueue();
229 }
230
Eino-Ville Talvala52e9ad42012-09-19 17:09:15 -0700231 if (mCaptureBuffer != 0 && res == OK) {
232 Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
233 ALOGV("%s: Sending still image to client", __FUNCTION__);
234 if (l.mCameraClient != 0) {
235 l.mCameraClient->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE,
236 mCaptureBuffer, NULL);
237 } else {
238 ALOGV("%s: No client!", __FUNCTION__);
239 }
240 }
241 mCaptureBuffer.clear();
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700242
243 return IDLE;
244}
245
246CaptureSequencer::CaptureState CaptureSequencer::manageStart(
247 sp<Camera2Client> &client) {
James Painterc3dbf1a2012-09-05 18:02:32 -0700248 ALOGV("%s", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700249 status_t res;
250 ATRACE_CALL();
251 SharedParameters::Lock l(client->getParameters());
252 CaptureState nextState = DONE;
253
254 res = updateCaptureRequest(l.mParameters, client);
255 if (res != OK ) {
256 ALOGE("%s: Camera %d: Can't update still image capture request: %s (%d)",
257 __FUNCTION__, client->getCameraId(), strerror(-res), res);
258 return DONE;
259 }
260
James Painterc3dbf1a2012-09-05 18:02:32 -0700261 if(l.mParameters.lightFx != Parameters::LIGHTFX_NONE &&
262 l.mParameters.state == Parameters::STILL_CAPTURE) {
263 nextState = BURST_CAPTURE_START;
264 }
265 else if (l.mParameters.zslMode &&
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700266 l.mParameters.state == Parameters::STILL_CAPTURE) {
267 nextState = ZSL_START;
268 } else {
269 nextState = STANDARD_START;
270 }
271
272 return nextState;
273}
274
275CaptureSequencer::CaptureState CaptureSequencer::manageZslStart(
276 sp<Camera2Client> &client) {
Eino-Ville Talvala2954fe92012-09-12 10:42:10 -0700277 ALOGV("%s", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700278 status_t res;
279 sp<ZslProcessor> processor = mZslProcessor.promote();
280 if (processor == 0) {
281 ALOGE("%s: No ZSL queue to use!", __FUNCTION__);
282 return DONE;
283 }
284
285 client->registerFrameListener(mCaptureId,
286 this);
287
288 res = client->getCameraDevice()->clearStreamingRequest();
289 if (res != OK) {
290 ALOGE("%s: Camera %d: Unable to stop preview for ZSL capture: "
291 "%s (%d)",
292 __FUNCTION__, client->getCameraId(), strerror(-res), res);
293 return DONE;
294 }
295 // TODO: Actually select the right thing here.
Eino-Ville Talvala2954fe92012-09-12 10:42:10 -0700296 res = processor->pushToReprocess(mCaptureId);
297 if (res != OK) {
Eino-Ville Talvala22745492012-09-17 17:55:07 -0700298 if (res == NOT_ENOUGH_DATA) {
299 ALOGV("%s: Camera %d: ZSL queue doesn't have good frame, "
300 "falling back to normal capture", __FUNCTION__,
301 client->getCameraId());
302 } else {
303 ALOGE("%s: Camera %d: Error in ZSL queue: %s (%d)",
304 __FUNCTION__, client->getCameraId(), strerror(-res), res);
305 }
Eino-Ville Talvala2954fe92012-09-12 10:42:10 -0700306 return STANDARD_START;
307 }
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700308
Eino-Ville Talvalaa4247b82012-09-19 17:12:50 -0700309 SharedParameters::Lock l(client->getParameters());
310 if (l.mParameters.playShutterSound) {
311 client->getCameraService()->playSound(CameraService::SOUND_SHUTTER);
312 }
313
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700314 mTimeoutCount = kMaxTimeoutsForCaptureEnd;
315 return STANDARD_CAPTURE_WAIT;
316}
317
318CaptureSequencer::CaptureState CaptureSequencer::manageZslWaiting(
319 sp<Camera2Client> &client) {
Eino-Ville Talvala2954fe92012-09-12 10:42:10 -0700320 ALOGV("%s", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700321 return DONE;
322}
323
324CaptureSequencer::CaptureState CaptureSequencer::manageZslReprocessing(
325 sp<Camera2Client> &client) {
Eino-Ville Talvala2954fe92012-09-12 10:42:10 -0700326 ALOGV("%s", __FUNCTION__);
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700327 return START;
328}
329
330CaptureSequencer::CaptureState CaptureSequencer::manageStandardStart(
331 sp<Camera2Client> &client) {
332 ATRACE_CALL();
333 client->registerFrameListener(mCaptureId,
334 this);
335 {
336 SharedParameters::Lock l(client->getParameters());
337 mTriggerId = l.mParameters.precaptureTriggerCounter++;
338 }
339 client->getCameraDevice()->triggerPrecaptureMetering(mTriggerId);
340
341 mAeInPrecapture = false;
342 mTimeoutCount = kMaxTimeoutsForPrecaptureStart;
343 return STANDARD_PRECAPTURE_WAIT;
344}
345
346CaptureSequencer::CaptureState CaptureSequencer::manageStandardPrecaptureWait(
347 sp<Camera2Client> &client) {
348 status_t res;
349 ATRACE_CALL();
350 Mutex::Autolock l(mInputMutex);
351 while (!mNewAEState) {
352 res = mNewNotifySignal.waitRelative(mInputMutex, kWaitDuration);
353 if (res == TIMED_OUT) {
354 mTimeoutCount--;
355 break;
356 }
357 }
358 if (mTimeoutCount <= 0) {
359 ALOGW("Timed out waiting for precapture %s",
360 mAeInPrecapture ? "end" : "start");
361 return STANDARD_CAPTURE;
362 }
363 if (mNewAEState) {
364 if (!mAeInPrecapture) {
365 // Waiting to see PRECAPTURE state
366 if (mAETriggerId == mTriggerId &&
367 mAEState == ANDROID_CONTROL_AE_STATE_PRECAPTURE) {
368 ALOGV("%s: Got precapture start", __FUNCTION__);
369 mAeInPrecapture = true;
370 mTimeoutCount = kMaxTimeoutsForPrecaptureEnd;
371 }
372 } else {
373 // Waiting to see PRECAPTURE state end
374 if (mAETriggerId == mTriggerId &&
375 mAEState != ANDROID_CONTROL_AE_STATE_PRECAPTURE) {
376 ALOGV("%s: Got precapture end", __FUNCTION__);
377 return STANDARD_CAPTURE;
378 }
379 }
380 mNewAEState = false;
381 }
382 return STANDARD_PRECAPTURE_WAIT;
383}
384
385CaptureSequencer::CaptureState CaptureSequencer::manageStandardCapture(
386 sp<Camera2Client> &client) {
387 status_t res;
388 ATRACE_CALL();
389 SharedParameters::Lock l(client->getParameters());
390 Vector<uint8_t> outputStreams;
391
392 outputStreams.push(client->getPreviewStreamId());
393 outputStreams.push(client->getCaptureStreamId());
394
395 if (l.mParameters.previewCallbackFlags &
396 CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK) {
397 outputStreams.push(client->getCallbackStreamId());
398 }
399
400 if (l.mParameters.state == Parameters::VIDEO_SNAPSHOT) {
401 outputStreams.push(client->getRecordingStreamId());
402 }
403
404 res = mCaptureRequest.update(ANDROID_REQUEST_OUTPUT_STREAMS,
405 outputStreams);
406 if (res == OK) {
407 res = mCaptureRequest.update(ANDROID_REQUEST_ID,
408 &mCaptureId, 1);
409 }
410 if (res == OK) {
411 res = mCaptureRequest.sort();
412 }
413
414 if (res != OK) {
415 ALOGE("%s: Camera %d: Unable to set up still capture request: %s (%d)",
416 __FUNCTION__, client->getCameraId(), strerror(-res), res);
417 return DONE;
418 }
419
420 CameraMetadata captureCopy = mCaptureRequest;
421 if (captureCopy.entryCount() == 0) {
422 ALOGE("%s: Camera %d: Unable to copy capture request for HAL device",
423 __FUNCTION__, client->getCameraId());
424 return DONE;
425 }
426
427 if (l.mParameters.state == Parameters::STILL_CAPTURE) {
428 res = client->getCameraDevice()->clearStreamingRequest();
429 if (res != OK) {
430 ALOGE("%s: Camera %d: Unable to stop preview for still capture: "
431 "%s (%d)",
432 __FUNCTION__, client->getCameraId(), strerror(-res), res);
433 return DONE;
434 }
435 }
436 // TODO: Capture should be atomic with setStreamingRequest here
437 res = client->getCameraDevice()->capture(captureCopy);
438 if (res != OK) {
439 ALOGE("%s: Camera %d: Unable to submit still image capture request: "
440 "%s (%d)",
441 __FUNCTION__, client->getCameraId(), strerror(-res), res);
442 return DONE;
443 }
444
Eino-Ville Talvalabd3a8162012-09-15 13:27:52 -0700445 if (l.mParameters.playShutterSound &&
446 l.mParameters.state == Parameters::STILL_CAPTURE) {
Eino-Ville Talvala33578832012-09-06 18:26:58 -0700447 client->getCameraService()->playSound(CameraService::SOUND_SHUTTER);
448 }
449
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700450 mTimeoutCount = kMaxTimeoutsForCaptureEnd;
451 return STANDARD_CAPTURE_WAIT;
452}
453
454CaptureSequencer::CaptureState CaptureSequencer::manageStandardCaptureWait(
455 sp<Camera2Client> &client) {
456 status_t res;
457 ATRACE_CALL();
458 Mutex::Autolock l(mInputMutex);
459 while (!mNewFrameReceived) {
460 res = mNewFrameSignal.waitRelative(mInputMutex, kWaitDuration);
461 if (res == TIMED_OUT) {
462 mTimeoutCount--;
463 break;
464 }
465 }
466 while (!mNewCaptureReceived) {
467 res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration);
468 if (res == TIMED_OUT) {
469 mTimeoutCount--;
470 break;
471 }
472 }
473 if (mTimeoutCount <= 0) {
474 ALOGW("Timed out waiting for capture to complete");
475 return DONE;
476 }
477 if (mNewFrameReceived && mNewCaptureReceived) {
478 if (mNewFrameId != mCaptureId) {
479 ALOGW("Mismatched capture frame IDs: Expected %d, got %d",
480 mCaptureId, mNewFrameId);
481 }
482 camera_metadata_entry_t entry;
483 entry = mNewFrame.find(ANDROID_SENSOR_TIMESTAMP);
484 if (entry.count == 0) {
485 ALOGE("No timestamp field in capture frame!");
486 }
487 if (entry.data.i64[0] != mCaptureTimestamp) {
488 ALOGW("Mismatched capture timestamps: Metadata frame %lld,"
489 " captured buffer %lld", entry.data.i64[0], mCaptureTimestamp);
490 }
491 client->removeFrameListener(mCaptureId);
492
493 mNewFrameReceived = false;
494 mNewCaptureReceived = false;
495 return DONE;
496 }
497 return STANDARD_CAPTURE_WAIT;
498}
499
James Painterc3dbf1a2012-09-05 18:02:32 -0700500CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureStart(
501 sp<Camera2Client> &client) {
502 ALOGV("%s", __FUNCTION__);
503 status_t res;
504 ATRACE_CALL();
505
506 // check which burst mode is set, create respective burst object
507 {
508 SharedParameters::Lock l(client->getParameters());
509
510 res = updateCaptureRequest(l.mParameters, client);
511 if(res != OK) {
512 return DONE;
513 }
514
515 //
516 // check for burst mode type in mParameters here
517 //
518 mBurstCapture = new BurstCapture(client, this);
519 }
520
521 res = mCaptureRequest.update(ANDROID_REQUEST_ID, &mCaptureId, 1);
522 if (res == OK) {
523 res = mCaptureRequest.sort();
524 }
525 if (res != OK) {
526 ALOGE("%s: Camera %d: Unable to set up still capture request: %s (%d)",
527 __FUNCTION__, client->getCameraId(), strerror(-res), res);
528 return DONE;
529 }
530
531 CameraMetadata captureCopy = mCaptureRequest;
532 if (captureCopy.entryCount() == 0) {
533 ALOGE("%s: Camera %d: Unable to copy capture request for HAL device",
534 __FUNCTION__, client->getCameraId());
535 return DONE;
536 }
537
538 Vector<CameraMetadata> requests;
539 requests.push(mCaptureRequest);
540 res = mBurstCapture->start(requests, mCaptureId);
541 mTimeoutCount = kMaxTimeoutsForCaptureEnd * 10;
542 return BURST_CAPTURE_WAIT;
543}
544
545CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureWait(
546 sp<Camera2Client> &client) {
547 status_t res;
548 ATRACE_CALL();
549
550 while (!mNewCaptureReceived) {
551 res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration);
552 if (res == TIMED_OUT) {
553 mTimeoutCount--;
554 break;
555 }
556 }
557
558 if (mTimeoutCount <= 0) {
559 ALOGW("Timed out waiting for burst capture to complete");
560 return DONE;
561 }
562 if (mNewCaptureReceived) {
563 mNewCaptureReceived = false;
564 // TODO: update mCaptureId to last burst's capture ID + 1?
565 return DONE;
566 }
567
568 return BURST_CAPTURE_WAIT;
569}
570
Eino-Ville Talvala69230df2012-08-29 17:37:16 -0700571status_t CaptureSequencer::updateCaptureRequest(const Parameters &params,
572 sp<Camera2Client> &client) {
573 ATRACE_CALL();
574 status_t res;
575 if (mCaptureRequest.entryCount() == 0) {
576 res = client->getCameraDevice()->createDefaultRequest(
577 CAMERA2_TEMPLATE_STILL_CAPTURE,
578 &mCaptureRequest);
579 if (res != OK) {
580 ALOGE("%s: Camera %d: Unable to create default still image request:"
581 " %s (%d)", __FUNCTION__, client->getCameraId(),
582 strerror(-res), res);
583 return res;
584 }
585 }
586
587 res = params.updateRequest(&mCaptureRequest);
588 if (res != OK) {
589 ALOGE("%s: Camera %d: Unable to update common entries of capture "
590 "request: %s (%d)", __FUNCTION__, client->getCameraId(),
591 strerror(-res), res);
592 return res;
593 }
594
595 res = mCaptureRequest.update(ANDROID_JPEG_THUMBNAIL_SIZE,
596 params.jpegThumbSize, 2);
597 if (res != OK) return res;
598 res = mCaptureRequest.update(ANDROID_JPEG_THUMBNAIL_QUALITY,
599 &params.jpegThumbQuality, 1);
600 if (res != OK) return res;
601 res = mCaptureRequest.update(ANDROID_JPEG_QUALITY,
602 &params.jpegQuality, 1);
603 if (res != OK) return res;
604 res = mCaptureRequest.update(
605 ANDROID_JPEG_ORIENTATION,
606 &params.jpegRotation, 1);
607 if (res != OK) return res;
608
609 if (params.gpsEnabled) {
610 res = mCaptureRequest.update(
611 ANDROID_JPEG_GPS_COORDINATES,
612 params.gpsCoordinates, 3);
613 if (res != OK) return res;
614 res = mCaptureRequest.update(
615 ANDROID_JPEG_GPS_TIMESTAMP,
616 &params.gpsTimestamp, 1);
617 if (res != OK) return res;
618 res = mCaptureRequest.update(
619 ANDROID_JPEG_GPS_PROCESSING_METHOD,
620 params.gpsProcessingMethod);
621 if (res != OK) return res;
622 } else {
623 res = mCaptureRequest.erase(ANDROID_JPEG_GPS_COORDINATES);
624 if (res != OK) return res;
625 res = mCaptureRequest.erase(ANDROID_JPEG_GPS_TIMESTAMP);
626 if (res != OK) return res;
627 res = mCaptureRequest.erase(ANDROID_JPEG_GPS_PROCESSING_METHOD);
628 if (res != OK) return res;
629 }
630
631 return OK;
632}
633
634
635}; // namespace camera2
636}; // namespace android