2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #define LOG_TAG "CameraMultiStreamTest"
19 //#define LOG_NDEBUG 0
20 #include "CameraStreamFixture.h"
21 #include "TestExtensions.h"
23 #include <gtest/gtest.h>
24 #include <utils/Log.h>
25 #include <utils/StrongPointer.h>
26 #include <common/CameraDeviceBase.h>
27 #include <hardware/hardware.h>
28 #include <hardware/camera2.h>
29 #include <gui/SurfaceComposerClient.h>
30 #include <gui/Surface.h>
32 #define DEFAULT_FRAME_DURATION 33000000LL // 33ms
33 #define CAMERA_HEAP_COUNT 1
34 #define CAMERA_EXPOSURE_FORMAT CAMERA_STREAM_AUTO_CPU_FORMAT
35 #define CAMERA_DISPLAY_FORMAT HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
36 #define CAMERA_MULTI_STREAM_DEBUGGING 0
37 #define CAMERA_FRAME_TIMEOUT 1000000000LL // nsecs (1 secs)
38 #define PREVIEW_RENDERING_TIME_INTERVAL 200000 // in unit of us, 200ms
39 // 1% tolerance margin for exposure sanity check against metadata
40 #define TOLERANCE_MARGIN_METADATA 0.01
41 // 5% tolerance margin for exposure sanity check against capture times
42 #define TOLERANCE_MARGIN_CAPTURE 0.05
43 /* constants for display */
44 #define DISPLAY_BUFFER_HEIGHT 1024
45 #define DISPLAY_BUFFER_WIDTH 1024
46 #define DISPLAY_BUFFER_FORMAT PIXEL_FORMAT_RGB_888
48 // This test intends to test large preview size but less than 1080p.
49 #define PREVIEW_WIDTH_CAP 1920
50 #define PREVIEW_HEIGHT_CAP 1080
51 // This test intends to test small metering burst size that is less than 640x480
52 #define METERING_WIDTH_CAP 640
53 #define METERING_HEIGHT_CAP 480
55 #define EXP_WAIT_MULTIPLIER 2
61 static const CameraStreamParams DEFAULT_STREAM_PARAMETERS = {
62 /*mFormat*/ CAMERA_EXPOSURE_FORMAT,
63 /*mHeapCount*/ CAMERA_HEAP_COUNT
66 static const CameraStreamParams DISPLAY_STREAM_PARAMETERS = {
67 /*mFormat*/ CAMERA_DISPLAY_FORMAT,
68 /*mHeapCount*/ CAMERA_HEAP_COUNT
71 class CameraMultiStreamTest
72 : public ::testing::Test,
73 public CameraStreamFixture {
76 CameraMultiStreamTest() : CameraStreamFixture(DEFAULT_STREAM_PARAMETERS) {
77 TEST_EXTENSION_FORKING_CONSTRUCTOR;
79 if (HasFatalFailure()) {
83 * Don't create default stream, each test is in charge of creating
88 ~CameraMultiStreamTest() {
89 TEST_EXTENSION_FORKING_DESTRUCTOR;
92 sp<SurfaceComposerClient> mComposerClient;
93 sp<SurfaceControl> mSurfaceControl;
95 void CreateOnScreenSurface(sp<ANativeWindow>& surface) {
96 mComposerClient = new SurfaceComposerClient;
97 ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
99 mSurfaceControl = mComposerClient->createSurface(
100 String8("CameraMultiStreamTest StreamingImage Surface"),
101 DISPLAY_BUFFER_HEIGHT, DISPLAY_BUFFER_WIDTH,
102 DISPLAY_BUFFER_FORMAT, 0);
104 ASSERT_NE((void*)NULL, mSurfaceControl.get());
105 ASSERT_TRUE(mSurfaceControl->isValid());
107 SurfaceComposerClient::openGlobalTransaction();
108 ASSERT_EQ(NO_ERROR, mSurfaceControl->setLayer(0x7FFFFFFF));
109 ASSERT_EQ(NO_ERROR, mSurfaceControl->show());
110 SurfaceComposerClient::closeGlobalTransaction();
112 surface = mSurfaceControl->getSurface();
114 ASSERT_NE((void*)NULL, surface.get());
122 // Select minimal size by number of pixels.
123 void GetMinSize(const int32_t* data, size_t count,
124 Size* min, int32_t* idx) {
125 ASSERT_NE((int32_t*)NULL, data);
127 int32_t minSize = INT_MAX, tempSize;
128 for (size_t i = 0; i < count; i+=2) {
129 tempSize = data[i] * data[i+1];
130 if (minSize > tempSize) {
135 min->width = data[minIdx];
136 min->height = data[minIdx + 1];
140 // Select maximal size by number of pixels.
141 void GetMaxSize(const int32_t* data, size_t count,
142 Size* max, int32_t* idx) {
143 ASSERT_NE((int32_t*)NULL, data);
145 int32_t maxSize = INT_MIN, tempSize;
146 for (size_t i = 0; i < count; i+=2) {
147 tempSize = data[i] * data[i+1];
148 if (maxSize < tempSize) {
153 max->width = data[maxIdx];
154 max->height = data[maxIdx + 1];
158 // Cap size by number of pixels.
159 Size CapSize(Size cap, Size input) {
160 if (input.width * input.height > cap.width * cap.height) {
166 struct CameraStream : public RefBase {
170 * Only initialize the variables here, do the ASSERT check in
171 * SetUp function. To make this stream useful, the SetUp must
172 * be called before using it.
177 const sp<CameraDeviceBase>& device,
178 CameraStreamParams param, sp<ANativeWindow> surface,
183 mFormat = param.mFormat;
184 if (useCpuConsumer) {
185 sp<IGraphicBufferProducer> producer;
186 sp<IGraphicBufferConsumer> consumer;
187 BufferQueue::createBufferQueue(&producer, &consumer);
188 mCpuConsumer = new CpuConsumer(consumer, param.mHeapCount);
189 mCpuConsumer->setName(String8(
190 "CameraMultiStreamTest::mCpuConsumer"));
191 mNativeWindow = new Surface(producer);
193 // Render the stream to screen.
195 mNativeWindow = surface;
198 mFrameListener = new FrameListener();
199 if (mCpuConsumer != 0) {
200 mCpuConsumer->setFrameAvailableListener(mFrameListener);
205 * Finally create camera stream, and do the ASSERT check, since we
206 * can not do it in ctor.
210 mDevice->createStream(mNativeWindow,
211 mWidth, mHeight, mFormat,
214 ASSERT_NE(-1, mStreamId);
217 int GetStreamId() { return mStreamId; }
218 sp<CpuConsumer> GetConsumer() { return mCpuConsumer; }
219 sp<FrameListener> GetFrameListener() { return mFrameListener; }
224 mDevice->waitUntilDrained();
225 mDevice->deleteStream(mStreamId);
227 // Clear producer before consumer.
228 mNativeWindow.clear();
229 mCpuConsumer.clear();
233 sp<FrameListener> mFrameListener;
234 sp<CpuConsumer> mCpuConsumer;
235 sp<ANativeWindow> mNativeWindow;
236 sp<CameraDeviceBase> mDevice;
243 int64_t GetExposureValue(const CameraMetadata& metaData) {
244 camera_metadata_ro_entry_t entry =
245 metaData.find(ANDROID_SENSOR_EXPOSURE_TIME);
246 EXPECT_EQ(1u, entry.count);
247 if (entry.count == 1) {
248 return entry.data.i64[0];
253 int32_t GetSensitivity(const CameraMetadata& metaData) {
254 camera_metadata_ro_entry_t entry =
255 metaData.find(ANDROID_SENSOR_SENSITIVITY);
256 EXPECT_EQ(1u, entry.count);
257 if (entry.count == 1) {
258 return entry.data.i32[0];
263 int64_t GetFrameDuration(const CameraMetadata& metaData) {
264 camera_metadata_ro_entry_t entry =
265 metaData.find(ANDROID_SENSOR_FRAME_DURATION);
266 EXPECT_EQ(1u, entry.count);
267 if (entry.count == 1) {
268 return entry.data.i64[0];
273 void CreateRequests(CameraMetadata& previewRequest,
274 CameraMetadata& meteringRequest,
275 CameraMetadata& captureRequest,
277 int meteringStreamId,
278 int captureStreamId) {
279 int32_t requestId = 0;
280 Vector<int32_t> previewStreamIds;
281 previewStreamIds.push(previewStreamId);
282 ASSERT_EQ(OK, mDevice->createDefaultRequest(CAMERA2_TEMPLATE_PREVIEW,
284 ASSERT_EQ(OK, previewRequest.update(ANDROID_REQUEST_OUTPUT_STREAMS,
286 ASSERT_EQ(OK, previewRequest.update(ANDROID_REQUEST_ID,
289 // Create metering request, manual settings
290 // Manual control: Disable 3A, noise reduction, edge sharping
291 uint8_t cmOff = static_cast<uint8_t>(ANDROID_CONTROL_MODE_OFF);
292 uint8_t nrOff = static_cast<uint8_t>(ANDROID_NOISE_REDUCTION_MODE_OFF);
293 uint8_t sharpOff = static_cast<uint8_t>(ANDROID_EDGE_MODE_OFF);
294 Vector<int32_t> meteringStreamIds;
295 meteringStreamIds.push(meteringStreamId);
296 ASSERT_EQ(OK, mDevice->createDefaultRequest(
297 CAMERA2_TEMPLATE_PREVIEW,
299 ASSERT_EQ(OK, meteringRequest.update(
300 ANDROID_REQUEST_OUTPUT_STREAMS,
302 ASSERT_EQ(OK, meteringRequest.update(
303 ANDROID_CONTROL_MODE,
305 ASSERT_EQ(OK, meteringRequest.update(
306 ANDROID_NOISE_REDUCTION_MODE,
308 ASSERT_EQ(OK, meteringRequest.update(
312 // Create capture request, manual settings
313 Vector<int32_t> captureStreamIds;
314 captureStreamIds.push(captureStreamId);
315 ASSERT_EQ(OK, mDevice->createDefaultRequest(
316 CAMERA2_TEMPLATE_PREVIEW,
318 ASSERT_EQ(OK, captureRequest.update(
319 ANDROID_REQUEST_OUTPUT_STREAMS,
321 ASSERT_EQ(OK, captureRequest.update(
322 ANDROID_CONTROL_MODE,
324 ASSERT_EQ(OK, captureRequest.update(
325 ANDROID_NOISE_REDUCTION_MODE,
327 ASSERT_EQ(OK, captureRequest.update(
332 sp<CameraStream> CreateStream(
335 const sp<CameraDeviceBase>& device,
336 CameraStreamParams param = DEFAULT_STREAM_PARAMETERS,
337 sp<ANativeWindow> surface = NULL,
338 bool useCpuConsumer = true) {
339 param.mFormat = MapAutoFormat(param.mFormat);
340 return new CameraStream(width, height, device,
341 param, surface, useCpuConsumer);
344 void CaptureBurst(CameraMetadata& request, size_t requestCount,
345 const Vector<int64_t>& exposures,
346 const Vector<int32_t>& sensitivities,
347 const sp<CameraStream>& stream,
348 int64_t minFrameDuration,
349 int32_t* requestIdStart) {
350 ASSERT_EQ(OK, request.update(ANDROID_SENSOR_FRAME_DURATION,
351 &minFrameDuration, 1));
352 // Submit a series of requests with the specified exposure/gain values.
353 int32_t targetRequestId = *requestIdStart;
354 for (size_t i = 0; i < requestCount; i++) {
355 ASSERT_EQ(OK, request.update(ANDROID_REQUEST_ID, requestIdStart, 1));
356 ASSERT_EQ(OK, request.update(ANDROID_SENSOR_EXPOSURE_TIME, &exposures[i], 1));
357 ASSERT_EQ(OK, request.update(ANDROID_SENSOR_SENSITIVITY, &sensitivities[i], 1));
358 ASSERT_EQ(OK, mDevice->capture(request));
359 ALOGV("Submitting request with: id %d with exposure %"PRId64", sensitivity %d",
360 *requestIdStart, exposures[i], sensitivities[i]);
361 if (CAMERA_MULTI_STREAM_DEBUGGING) {
362 request.dump(STDOUT_FILENO);
366 // Get capture burst results.
367 Vector<nsecs_t> captureBurstTimes;
368 sp<CpuConsumer> consumer = stream->GetConsumer();
369 sp<FrameListener> listener = stream->GetFrameListener();
371 // Set wait limit based on expected frame duration.
372 int64_t waitLimit = CAMERA_FRAME_TIMEOUT;
373 for (size_t i = 0; i < requestCount; i++) {
374 ALOGV("Reading request result %zu", i);
377 * Raise the timeout to be at least twice as long as the exposure
378 * time. to avoid a false positive when the timeout is too short.
380 if ((exposures[i] * EXP_WAIT_MULTIPLIER) > waitLimit) {
381 waitLimit = exposures[i] * EXP_WAIT_MULTIPLIER;
384 CaptureResult result;
385 CameraMetadata frameMetadata;
386 int32_t resultRequestId;
388 ASSERT_EQ(OK, mDevice->waitForNextFrame(waitLimit));
389 ASSERT_EQ(OK, mDevice->getNextResult(&result));
390 frameMetadata = result.mMetadata;
392 camera_metadata_entry_t resultEntry = frameMetadata.find(ANDROID_REQUEST_ID);
393 ASSERT_EQ(1u, resultEntry.count);
394 resultRequestId = resultEntry.data.i32[0];
395 if (CAMERA_MULTI_STREAM_DEBUGGING) {
396 std::cout << "capture result req id: " << resultRequestId << std::endl;
398 } while (resultRequestId != targetRequestId);
400 ALOGV("Got capture burst result for request %zu", i);
402 // Validate capture result
403 if (CAMERA_MULTI_STREAM_DEBUGGING) {
404 frameMetadata.dump(STDOUT_FILENO);
407 // TODO: Need revisit it to figure out an accurate margin.
408 int64_t resultExposure = GetExposureValue(frameMetadata);
409 int32_t resultSensitivity = GetSensitivity(frameMetadata);
410 EXPECT_LE(sensitivities[i] * (1.0 - TOLERANCE_MARGIN_METADATA), resultSensitivity);
411 EXPECT_GE(sensitivities[i] * (1.0 + TOLERANCE_MARGIN_METADATA), resultSensitivity);
412 EXPECT_LE(exposures[i] * (1.0 - TOLERANCE_MARGIN_METADATA), resultExposure);
413 EXPECT_GE(exposures[i] * (1.0 + TOLERANCE_MARGIN_METADATA), resultExposure);
415 ASSERT_EQ(OK, listener->waitForFrame(waitLimit));
416 captureBurstTimes.push_back(systemTime());
417 CpuConsumer::LockedBuffer imgBuffer;
418 ASSERT_EQ(OK, consumer->lockNextBuffer(&imgBuffer));
419 ALOGV("Got capture buffer for request %zu", i);
422 * TODO: Validate capture buffer. Current brightness calculation
423 * is too slow, it also doesn't account for saturation effects,
424 * which is quite common since we are going over a significant
425 * range of EVs. we need figure out some reliable way to validate
429 ASSERT_EQ(OK, consumer->unlockBuffer(imgBuffer));
432 captureBurstTimes[i] - captureBurstTimes[i-1];
433 EXPECT_GE(timeDelta * ( 1 + TOLERANCE_MARGIN_CAPTURE), exposures[i]);
439 * Intentionally shadow default CreateStream function from base class,
440 * because we don't want any test in this class to use the default
441 * stream creation function.
443 void CreateStream() {
448 * This test adds multiple stream use case test, basically, test 3
451 * 1. Preview stream, with large size that is no bigger than 1080p
452 * we render this stream to display and vary the exposure time for
453 * for certain amount of time for visualization purpose.
455 * 2. Metering stream, with small size that is no bigger than VGA size.
456 * a burst is issued for different exposure times and analog gains
457 * (or analog gain implemented sensitivities) then check if the capture
458 * result metadata matches the request.
460 * 3. Capture stream, this is basically similar as meterting stream, but
461 * has large size, which is the largest supported JPEG capture size.
463 * This multiple stream test is to test if HAL supports:
465 * 1. Multiple streams like above, HAL should support at least 3 streams
466 * concurrently: one preview stream, 2 other YUV stream.
468 * 2. Manual control(gain/exposure) of mutiple burst capture.
470 // Disable this test for now, as we need cleanup the usage of the deprecated tag quite a bit.
471 TEST_F(CameraMultiStreamTest, DISABLED_MultiBurst) {
473 TEST_EXTENSION_FORKING_INIT;
475 camera_metadata_ro_entry availableProcessedSizes =
476 GetStaticEntry(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES);
477 ASSERT_EQ(0u, availableProcessedSizes.count % 2);
478 ASSERT_GE(availableProcessedSizes.count, 2u);
479 camera_metadata_ro_entry availableProcessedMinFrameDurations =
480 GetStaticEntry(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS);
481 EXPECT_EQ(availableProcessedSizes.count,
482 availableProcessedMinFrameDurations.count * 2);
484 camera_metadata_ro_entry availableJpegSizes =
485 GetStaticEntry(ANDROID_SCALER_AVAILABLE_JPEG_SIZES);
486 ASSERT_EQ(0u, availableJpegSizes.count % 2);
487 ASSERT_GE(availableJpegSizes.count, 2u);
489 camera_metadata_ro_entry hardwareLevel =
490 GetStaticEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL);
491 ASSERT_EQ(1u, hardwareLevel.count);
492 uint8_t level = hardwareLevel.data.u8[0];
493 ASSERT_GE(level, ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED);
494 ASSERT_LE(level, ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
495 if (level == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED) {
496 const ::testing::TestInfo* const test_info =
497 ::testing::UnitTest::GetInstance()->current_test_info();
498 std::cerr << "Skipping test "
499 << test_info->test_case_name() << "."
501 << " because HAL hardware supported level is limited "
506 // Find the right sizes for preview, metering, and capture streams
507 // assumes at least 2 entries in availableProcessedSizes.
508 int64_t minFrameDuration = DEFAULT_FRAME_DURATION;
509 Size processedMinSize, processedMaxSize, jpegMaxSize;
510 const int32_t* data = availableProcessedSizes.data.i32;
511 size_t count = availableProcessedSizes.count;
513 int32_t minIdx, maxIdx;
514 GetMinSize(data, count, &processedMinSize, &minIdx);
515 GetMaxSize(data, count, &processedMaxSize, &maxIdx);
516 ALOGV("Found processed max size: %dx%d, min size = %dx%d",
517 processedMaxSize.width, processedMaxSize.height,
518 processedMinSize.width, processedMinSize.height);
520 if (availableProcessedSizes.count ==
521 availableProcessedMinFrameDurations.count * 2) {
523 availableProcessedMinFrameDurations.data.i64[maxIdx / 2];
526 EXPECT_GT(minFrameDuration, 0);
528 if (minFrameDuration <= 0) {
529 minFrameDuration = DEFAULT_FRAME_DURATION;
532 ALOGV("targeted minimal frame duration is: %"PRId64"ns", minFrameDuration);
534 data = &(availableJpegSizes.data.i32[0]);
535 count = availableJpegSizes.count;
536 GetMaxSize(data, count, &jpegMaxSize, &maxIdx);
537 ALOGV("Found Jpeg size max idx = %d", maxIdx);
539 // Max Jpeg size should be available in processed sizes. Use it for
540 // YUV capture anyway.
541 EXPECT_EQ(processedMaxSize.width, jpegMaxSize.width);
542 EXPECT_EQ(processedMaxSize.height, jpegMaxSize.height);
545 Size previewLimit = { PREVIEW_WIDTH_CAP, PREVIEW_HEIGHT_CAP };
546 // FIXME: need make sure the previewLimit is supported by HAL.
547 Size previewSize = CapSize(previewLimit, processedMaxSize);
548 // Cap Metering size.
549 Size meteringLimit = { METERING_WIDTH_CAP, METERING_HEIGHT_CAP };
550 // Cap metering size to VGA (VGA is mandatory by CDD)
551 Size meteringSize = CapSize(meteringLimit, processedMinSize);
552 // Capture stream should be the max size of jpeg sizes.
553 ALOGV("preview size: %dx%d, metering size: %dx%d, capture size: %dx%d",
554 previewSize.width, previewSize.height,
555 meteringSize.width, meteringSize.height,
556 jpegMaxSize.width, jpegMaxSize.height);
559 // Preview stream: small resolution, render on the screen.
560 sp<CameraStream> previewStream;
562 sp<ANativeWindow> surface;
563 ASSERT_NO_FATAL_FAILURE(CreateOnScreenSurface(/*out*/surface));
564 previewStream = CreateStream(
568 DISPLAY_STREAM_PARAMETERS,
571 ASSERT_NE((void*)NULL, previewStream.get());
572 ASSERT_NO_FATAL_FAILURE(previewStream->SetUp());
574 // Metering burst stream: small resolution yuv stream
575 sp<CameraStream> meteringStream =
580 ASSERT_NE((void*)NULL, meteringStream.get());
581 ASSERT_NO_FATAL_FAILURE(meteringStream->SetUp());
582 // Capture burst stream: full resolution yuv stream
583 sp<CameraStream> captureStream =
588 ASSERT_NE((void*)NULL, captureStream.get());
589 ASSERT_NO_FATAL_FAILURE(captureStream->SetUp());
591 // Create Preview request.
592 CameraMetadata previewRequest, meteringRequest, captureRequest;
593 ASSERT_NO_FATAL_FAILURE(CreateRequests(previewRequest, meteringRequest,
594 captureRequest, previewStream->GetStreamId(),
595 meteringStream->GetStreamId(), captureStream->GetStreamId()));
598 if (CAMERA_MULTI_STREAM_DEBUGGING) {
599 previewRequest.dump(STDOUT_FILENO);
602 // Generate exposure and sensitivity lists
603 camera_metadata_ro_entry exposureTimeRange =
604 GetStaticEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE);
605 ASSERT_EQ(exposureTimeRange.count, 2u);
606 int64_t minExp = exposureTimeRange.data.i64[0];
607 int64_t maxExp = exposureTimeRange.data.i64[1];
608 ASSERT_GT(maxExp, minExp);
610 camera_metadata_ro_entry sensivityRange =
611 GetStaticEntry(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE);
612 ASSERT_EQ(2u, sensivityRange.count);
613 int32_t minSensitivity = sensivityRange.data.i32[0];
614 int32_t maxSensitivity = sensivityRange.data.i32[1];
615 camera_metadata_ro_entry maxAnalogSenEntry =
616 GetStaticEntry(ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY);
617 EXPECT_EQ(1u, maxAnalogSenEntry.count);
618 int32_t maxAnalogSensitivity = maxAnalogSenEntry.data.i32[0];
619 EXPECT_LE(maxAnalogSensitivity, maxSensitivity);
620 // Only test the sensitivity implemented by analog gain.
621 if (maxAnalogSensitivity > maxSensitivity) {
622 // Fallback to maxSensitity
623 maxAnalogSensitivity = maxSensitivity;
626 // sensitivity list, only include the sensitivities that are implemented
627 // purely by analog gain if possible.
628 Vector<int32_t> sensitivities;
629 Vector<int64_t> exposures;
630 count = (maxAnalogSensitivity - minSensitivity + 99) / 100;
631 sensitivities.push_back(minSensitivity);
632 for (size_t i = 1; i < count; i++) {
633 sensitivities.push_back(minSensitivity + i * 100);
635 sensitivities.push_back(maxAnalogSensitivity);
636 ALOGV("Sensitivity Range: min=%d, max=%d", minSensitivity,
637 maxAnalogSensitivity);
638 int64_t exp = minExp;
639 while (exp < maxExp) {
640 exposures.push_back(exp);
643 // Sweep the exposure value for preview, just for visual inspection purpose.
644 uint8_t cmOff = static_cast<uint8_t>(ANDROID_CONTROL_MODE_OFF);
645 for (size_t i = 0; i < exposures.size(); i++) {
646 ASSERT_EQ(OK, previewRequest.update(
647 ANDROID_CONTROL_MODE,
649 ASSERT_EQ(OK, previewRequest.update(
650 ANDROID_SENSOR_EXPOSURE_TIME,
652 ALOGV("Submitting preview request %zu with exposure %"PRId64,
655 ASSERT_EQ(OK, mDevice->setStreamingRequest(previewRequest));
657 // Let preview run 200ms on screen for each exposure time.
658 usleep(PREVIEW_RENDERING_TIME_INTERVAL);
661 size_t requestCount = sensitivities.size();
662 if (requestCount > exposures.size()) {
663 requestCount = exposures.size();
666 // To maintain the request id uniqueness (preview request id is 0), make burst capture start
667 // request id 1 here.
668 int32_t requestIdStart = 1;
670 * Submit metering request, set default frame duration to minimal possible
671 * value, we want the capture to run as fast as possible. HAL should adjust
672 * the frame duration to minimal necessary value to support the requested
673 * exposure value if exposure is larger than frame duration.
675 CaptureBurst(meteringRequest, requestCount, exposures, sensitivities,
676 meteringStream, minFrameDuration, &requestIdStart);
679 * Submit capture request, set default frame duration to minimal possible
680 * value, we want the capture to run as fast as possible. HAL should adjust
681 * the frame duration to minimal necessary value to support the requested
682 * exposure value if exposure is larger than frame duration.
684 CaptureBurst(captureRequest, requestCount, exposures, sensitivities,
685 captureStream, minFrameDuration, &requestIdStart);
687 ASSERT_EQ(OK, mDevice->clearStreamingRequest());