1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file expected in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "meta_data_test.h"
16
17 using namespace testing::ext;
18
19 constexpr uint32_t SLEEP_SECOND_ONE = 1;
20 constexpr uint32_t SLEEP_SECOND_TWO = 2;
21 constexpr uint32_t DATA_COUNT = 1;
22 constexpr uint32_t ENTRY_CAPACITY = 30;
23 constexpr uint32_t DATA_CAPACITY = 2000;
24 constexpr int32_t FPS_RANGE = 20;
25 constexpr int32_t FPS_RANGE_CHANGE = 30;
26
27 const std::vector<int32_t> DATA_BASE = {
28 OHOS_CAMERA_STREAM_ID,
29 OHOS_SENSOR_COLOR_CORRECTION_GAINS,
30 OHOS_SENSOR_EXPOSURE_TIME,
31 OHOS_CONTROL_EXPOSURE_MODE,
32 OHOS_CONTROL_AE_EXPOSURE_COMPENSATION,
33 OHOS_CONTROL_FOCUS_MODE,
34 OHOS_CONTROL_METER_MODE,
35 OHOS_CONTROL_FLASH_MODE,
36 OHOS_CONTROL_FPS_RANGES,
37 OHOS_CONTROL_AWB_MODE,
38 OHOS_CONTROL_AF_REGIONS,
39 OHOS_CONTROL_METER_POINT,
40 OHOS_CONTROL_VIDEO_STABILIZATION_MODE,
41 OHOS_CONTROL_FOCUS_STATE,
42 OHOS_CONTROL_EXPOSURE_STATE,
43 };
44
SetUpTestCase(void)45 void MetaDataTest::SetUpTestCase(void) {}
TearDownTestCase(void)46 void MetaDataTest::TearDownTestCase(void) {}
SetUp(void)47 void MetaDataTest::SetUp(void)
48 {
49 if (cameraBase_ == nullptr) {
50 cameraBase_ = std::make_shared<TestCameraBase>();
51 }
52 cameraBase_->Init();
53 }
TearDown(void)54 void MetaDataTest::TearDown(void)
55 {
56 cameraBase_->Close();
57 }
58
SetStreamInfo(StreamInfo & streamInfo,const std::shared_ptr<StreamCustomer> & streamCustomer,const int streamId,const StreamIntent intent)59 void MetaDataTest::SetStreamInfo(StreamInfo &streamInfo, const std::shared_ptr<StreamCustomer> &streamCustomer,
60 const int streamId, const StreamIntent intent)
61 {
62 sptr<OHOS::IBufferProducer> producer;
63 constexpr uint32_t dataSpace = 8;
64 constexpr uint32_t tunnelMode = 5;
65 constexpr uint32_t bufferQueueSize = 8;
66 if (intent == STILL_CAPTURE) {
67 streamInfo.encodeType_ = ENCODE_TYPE_JPEG;
68 } else if (intent == VIDEO) {
69 streamInfo.encodeType_ = ENCODE_TYPE_H264;
70 }
71 streamInfo.width_ = PREVIEW_WIDTH;
72 streamInfo.height_ = PREVIEW_HEIGHT;
73 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
74 streamInfo.streamId_ = streamId;
75 streamInfo.dataspace_ = dataSpace;
76 streamInfo.intent_ = intent;
77 streamInfo.tunneledMode_ = tunnelMode;
78 producer = streamCustomer->CreateProducer();
79 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
80 CHECK_IF_PTR_NULL_RETURN_VOID(streamInfo.bufferQueue_);
81 streamInfo.bufferQueue_->producer_->SetQueueSize(bufferQueueSize);
82 }
83
CreateStream(int streamId,StreamIntent intent)84 void MetaDataTest::CreateStream(int streamId, StreamIntent intent)
85 {
86 StreamInfo streamInfo = {};
87
88 if (intent == PREVIEW) {
89 if (streamId == cameraBase_->STREAM_ID_PREVIEW) {
90 if (streamCustomerPreview_ == nullptr) {
91 streamCustomerPreview_ = std::make_shared<StreamCustomer>();
92 SetStreamInfo(streamInfo, streamCustomerPreview_, streamId, intent);
93 }
94 }
95 } else if (intent == STILL_CAPTURE) {
96 if (streamCustomerSnapshot_ == nullptr) {
97 streamCustomerSnapshot_ = std::make_shared<StreamCustomer>();
98 SetStreamInfo(streamInfo, streamCustomerSnapshot_, streamId, intent);
99 }
100 } else if (intent == VIDEO) {
101 if (streamCustomerVideo_ == nullptr) {
102 streamCustomerVideo_ = std::make_shared<StreamCustomer>();
103 SetStreamInfo(streamInfo, streamCustomerVideo_, streamId, intent);
104 }
105 }
106
107 std::vector<StreamInfo>().swap(streamInfos_);
108 streamInfos_.push_back(streamInfo);
109 result_ = static_cast<CamRetCode>(cameraBase_->streamOperator->CreateStreams(streamInfos_));
110 EXPECT_EQ(result_, HDI::Camera::V1_0::NO_ERROR);
111
112 if (result_ == HDI::Camera::V1_0::NO_ERROR) {
113 CAMERA_LOGI("CreateStreams success.");
114 } else {
115 CAMERA_LOGE("CreateStreams fail, result_ = %{public}d", result_);
116 }
117 }
118
CommitStream()119 void MetaDataTest::CommitStream()
120 {
121 result_ = static_cast<CamRetCode>(cameraBase_->streamOperator->CommitStreams(NORMAL, cameraBase_->ability_));
122 EXPECT_EQ(result_, HDI::Camera::V1_0::NO_ERROR);
123 if (result_ == HDI::Camera::V1_0::NO_ERROR) {
124 CAMERA_LOGI("CommitStreams preview success.");
125 } else {
126 CAMERA_LOGE("CommitStreams preview fail, result_ = %{public}d", result_);
127 }
128 }
129
StartCapture(int streamId,int captureId,bool shutterCallback,bool isStreaming,const CaptureInfo captureInfo)130 void MetaDataTest::StartCapture(
131 int streamId, int captureId, bool shutterCallback, bool isStreaming, const CaptureInfo captureInfo)
132 {
133 captureInfo_.streamIds_ = {streamId};
134 captureInfo_.captureSetting_ = cameraBase_->ability_;
135 captureInfo_.enableShutterCallback_ = shutterCallback;
136 if (captureInfo.captureSetting_.size() != 0) {
137 result_ = static_cast<CamRetCode>(cameraBase_->streamOperator->Capture(captureId, captureInfo, isStreaming));
138 } else {
139 result_ = static_cast<CamRetCode>(cameraBase_->streamOperator->Capture(captureId, captureInfo_, isStreaming));
140 }
141 EXPECT_EQ(result_, HDI::Camera::V1_0::NO_ERROR);
142 if (result_ == HDI::Camera::V1_0::NO_ERROR) {
143 CAMERA_LOGI("Capture success, captureId = %{public}d", captureId);
144 } else {
145 CAMERA_LOGE("check Capture: Capture fail, captureId = %{public}d, result_ = %{public}d", captureId, result_);
146 }
147 if (captureId == cameraBase_->CAPTURE_ID_PREVIEW) {
148 streamCustomerPreview_->ReceiveFrameOn([this](const unsigned char *addr, const uint32_t size) {
149 CAMERA_LOGI("preview size = %{public}u", size);
150 });
151 } else if (captureId == cameraBase_->CAPTURE_ID_CAPTURE) {
152 streamCustomerSnapshot_->ReceiveFrameOn([this](const unsigned char *addr, const uint32_t size) {
153 CAMERA_LOGI("snapshot size = %{public}u", size);
154 });
155 } else if (captureId == cameraBase_->CAPTURE_ID_VIDEO) {
156 streamCustomerVideo_->ReceiveFrameOn([this](const unsigned char *addr, const uint32_t size) {
157 CAMERA_LOGI("video size = %{public}u", size);
158 });
159 } else {
160 CAMERA_LOGE("StartCapture ignore command ");
161 }
162 }
163
StopStream(std::vector<int> & captureIds,std::vector<int> & streamIds)164 void MetaDataTest::StopStream(std::vector<int> &captureIds, std::vector<int> &streamIds)
165 {
166 sleep(SLEEP_SECOND_TWO);
167 if (captureIds.size() == 0) {
168 return;
169 }
170 for (const auto &captureId : captureIds) {
171 if (captureId == cameraBase_->CAPTURE_ID_PREVIEW) {
172 streamCustomerPreview_->ReceiveFrameOff();
173 } else if (captureId == cameraBase_->CAPTURE_ID_CAPTURE) {
174 streamCustomerSnapshot_->ReceiveFrameOff();
175 } else if (captureId == cameraBase_->CAPTURE_ID_VIDEO) {
176 streamCustomerVideo_->ReceiveFrameOff();
177 sleep(SLEEP_SECOND_ONE);
178 } else {
179 CAMERA_LOGE("StopStream ignore command ");
180 }
181 }
182 for (auto &captureId : captureIds) {
183 result_ = static_cast<CamRetCode>(cameraBase_->streamOperator->CancelCapture(captureId));
184 sleep(SLEEP_SECOND_TWO);
185 EXPECT_EQ(result_, HDI::Camera::V1_0::NO_ERROR);
186 if (result_ == HDI::Camera::V1_0::NO_ERROR) {
187 CAMERA_LOGI("check Capture: CancelCapture success, captureId = %{public}d", captureId);
188 } else {
189 CAMERA_LOGE("check Capture: CancelCapture fail, captureId = %{public}d, result_ = %{public}d",
190 captureId, result_);
191 }
192 }
193 sleep(SLEEP_SECOND_ONE);
194 }
195
StartCustomCapture()196 void MetaDataTest::StartCustomCapture()
197 {
198 CaptureInfo captureInfo = {};
199 StartCapture(cameraBase_->STREAM_ID_PREVIEW, cameraBase_->CAPTURE_ID_PREVIEW, false, true, captureInfo);
200 constexpr double latitude = 27.987500; // dummy data: Qomolangma latitde
201 constexpr double longitude = 86.927500; // dummy data: Qomolangma longituude
202 constexpr double altitude = 8848.86; // dummy data: Qomolangma altitude
203 std::shared_ptr<CameraSetting> captureSetting = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
204 std::vector<double> gps;
205 gps.push_back(latitude);
206 gps.push_back(longitude);
207 gps.push_back(altitude);
208 captureSetting->addEntry(OHOS_JPEG_GPS_COORDINATES, gps.data(), gps.size());
209
210 captureInfo.streamIds_ = {cameraBase_->STREAM_ID_CAPTURE};
211 std::vector<uint8_t> snapshotSetting;
212 MetadataUtils::ConvertMetadataToVec(captureSetting, snapshotSetting);
213 captureInfo.captureSetting_ = snapshotSetting;
214 captureInfo.enableShutterCallback_ = false;
215 StartCapture(cameraBase_->STREAM_ID_CAPTURE, cameraBase_->CAPTURE_ID_CAPTURE, false, true, captureInfo);
216 }
217
StartPreviewVideoStream()218 void MetaDataTest::StartPreviewVideoStream()
219 {
220 CreateStream(cameraBase_->STREAM_ID_PREVIEW, PREVIEW);
221 CreateStream(cameraBase_->STREAM_ID_VIDEO, VIDEO);
222 CommitStream();
223 }
224
StartPreviewCaptureStream()225 void MetaDataTest::StartPreviewCaptureStream()
226 {
227 CreateStream(cameraBase_->STREAM_ID_PREVIEW, PREVIEW);
228 CreateStream(cameraBase_->STREAM_ID_CAPTURE, STILL_CAPTURE);
229 CommitStream();
230 }
231
StopPreviewVideoStream()232 void MetaDataTest::StopPreviewVideoStream()
233 {
234 sleep(SLEEP_SECOND_TWO);
235 std::vector<int> captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO};
236 std::vector<int> streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO};
237 StopStream(captureIds, streamIds);
238 }
239
StopPreviewCaptureStream()240 void MetaDataTest::StopPreviewCaptureStream()
241 {
242 sleep(SLEEP_SECOND_TWO);
243 std::vector<int> captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_CAPTURE};
244 std::vector<int> streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_CAPTURE};
245 StopStream(captureIds, streamIds);
246 }
247
SetFps(std::shared_ptr<CameraSetting> & metaData,int32_t fps,bool isUpdate)248 void MetaDataTest::SetFps(std::shared_ptr<CameraSetting> &metaData, int32_t fps, bool isUpdate)
249 {
250 std::vector<int32_t> fpsRange;
251 fpsRange.push_back(fps);
252 fpsRange.push_back(fps);
253
254 if (isUpdate) {
255 metaData->updateEntry(OHOS_CONTROL_FPS_RANGES, fpsRange.data(), fpsRange.size());
256 } else {
257 metaData->addEntry(OHOS_CONTROL_FPS_RANGES, fpsRange.data(), fpsRange.size());
258 }
259 }
260
Prepare(ResultCallbackMode mode,std::vector<MetaType> & results)261 void MetaDataTest::Prepare(ResultCallbackMode mode, std::vector<MetaType> &results)
262 {
263 cameraBase_->AchieveStreamOperator();
264 cameraBase_->cameraDevice->SetResultMode(mode);
265
266 if (results.size() == 0) {
267 CAMERA_LOGE("results size is null");
268 return;
269 }
270 cameraBase_->cameraDevice->EnableResult(results);
271 }
272
UpdateSettings(std::shared_ptr<CameraSetting> & metaData)273 void MetaDataTest::UpdateSettings(std::shared_ptr<CameraSetting> &metaData)
274 {
275 std::vector<uint8_t> setting;
276 MetadataUtils::ConvertMetadataToVec(metaData, setting);
277 cameraBase_->rc = static_cast<CamRetCode>(cameraBase_->cameraDevice->UpdateSettings(setting));
278 if (cameraBase_->rc != HDI::Camera::V1_0::NO_ERROR) {
279 CAMERA_LOGE("UpdateSettings error, rc = %{public}d", cameraBase_->rc);
280 return;
281 } else {
282 CAMERA_LOGI("UpdateSettings ok, rc = %{public}d", cameraBase_->rc);
283 }
284 }
285
StartPreviewVideoCapture()286 void MetaDataTest::StartPreviewVideoCapture()
287 {
288 CaptureInfo captureInfo = {};
289 StartCapture(cameraBase_->STREAM_ID_PREVIEW, cameraBase_->CAPTURE_ID_PREVIEW, false, true, captureInfo);
290 StartCapture(cameraBase_->STREAM_ID_VIDEO, cameraBase_->CAPTURE_ID_VIDEO, false, true, captureInfo);
291 }
292
293 /**
294 * @tc.name: double preview
295 * @tc.desc: Commit 2 streams together, preview and video streams, isStreaming is true.
296 * CallbackMode is PER_FRAME, set device stream fps range value.
297 * @tc.level: Level1
298 * @tc.size: MediumTest
299 * @tc.type: Function
300 */
301 static HWTEST_F(MetaDataTest, meta_data_001, TestSize.Level1)
302 {
303 std::vector<MetaType> results;
304 results.push_back(OHOS_CAMERA_STREAM_ID);
305 results.push_back(OHOS_CONTROL_FPS_RANGES);
306 Prepare(ResultCallbackMode::PER_FRAME, results);
307
308 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
309 const int32_t deviceStreamId = 0;
310 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, DATA_COUNT);
311
312 SetFps(metaData, FPS_RANGE, false);
313
314 StartPreviewVideoStream();
315
316 UpdateSettings(metaData);
317
318 StartPreviewVideoCapture();
319
320 StopPreviewVideoStream();
321 }
322
323 /**
324 * @tc.name: double preview
325 * @tc.desc: Commit 2 streams together, preview and video streams, isStreaming is true.
326 * CallbackMode is ON_CHANGED, but the device stream fps range value has not changed.
327 * @tc.level: Level1
328 * @tc.size: MediumTest
329 * @tc.type: Function
330 */
331 static HWTEST_F(MetaDataTest, meta_data_002, TestSize.Level1)
332 {
333 std::vector<MetaType> results;
334 results.push_back(OHOS_CAMERA_STREAM_ID);
335 results.push_back(OHOS_CONTROL_FPS_RANGES);
336 Prepare(ResultCallbackMode::ON_CHANGED, results);
337
338 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
339 const int32_t deviceStreamId = 0;
340 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, DATA_COUNT);
341
342 SetFps(metaData, FPS_RANGE, false);
343
344 StartPreviewVideoStream();
345
346 UpdateSettings(metaData);
347
348 StartPreviewVideoCapture();
349 sleep(SLEEP_SECOND_TWO);
350
351 SetFps(metaData, FPS_RANGE, true);
352
353 UpdateSettings(metaData);
354
355 StopPreviewVideoStream();
356 }
357
358 /**
359 * @tc.name: double preview
360 * @tc.desc: Commit 2 streams together, preview and video streams, isStreaming is true.
361 * CallbackMode is ON_CHANGED, set device stream fps range different value.
362 * @tc.level: Level1
363 * @tc.size: MediumTest
364 * @tc.type: Function
365 */
366 static HWTEST_F(MetaDataTest, meta_data_003, TestSize.Level1)
367 {
368 std::vector<MetaType> results;
369 results.push_back(OHOS_CAMERA_STREAM_ID);
370 results.push_back(OHOS_CONTROL_FPS_RANGES);
371 Prepare(ResultCallbackMode::ON_CHANGED, results);
372
373 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
374 const int32_t deviceStreamId = 0;
375 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, DATA_COUNT);
376
377 SetFps(metaData, FPS_RANGE, false);
378
379 StartPreviewVideoStream();
380
381 UpdateSettings(metaData);
382
383 StartPreviewVideoCapture();
384 sleep(SLEEP_SECOND_TWO);
385
386 SetFps(metaData, FPS_RANGE_CHANGE, true);
387
388 UpdateSettings(metaData);
389
390 StopPreviewVideoStream();
391 }
392
393 /**
394 * @tc.name: double preview
395 * @tc.desc: Commit 2 streams together, preview and video streams, isStreaming is true.
396 * CallbackMode is PER_FRAME,set video stream stability mode value.
397 * @tc.level: Level1
398 * @tc.size: MediumTest
399 * @tc.type: Function
400 */
401 static HWTEST_F(MetaDataTest, meta_data_004, TestSize.Level1)
402 {
403 std::vector<MetaType> results;
404 results.push_back(OHOS_CAMERA_STREAM_ID);
405 Prepare(ResultCallbackMode::PER_FRAME, results);
406
407 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
408 const int32_t streamId = cameraBase_->STREAM_ID_VIDEO;
409 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &streamId, DATA_COUNT);
410
411 uint8_t videoStabilizationMode = OHOS_CAMERA_VIDEO_STABILIZATION_LOW;
412 metaData->addEntry(OHOS_CONTROL_VIDEO_STABILIZATION_MODE, &videoStabilizationMode, sizeof(videoStabilizationMode));
413
414 StartPreviewVideoStream();
415
416 UpdateSettings(metaData);
417
418 StartPreviewVideoCapture();
419
420 StopPreviewVideoStream();
421 }
422
423 /**
424 * @tc.name: double preview
425 * @tc.desc: Commit 2 streams together, preview and video streams, isStreaming is true.
426 * CallbackMode is ON_CHANGED, set video stream stability mode different value.
427 * @tc.level: Level1
428 * @tc.size: MediumTest
429 * @tc.type: Function
430 */
431 static HWTEST_F(MetaDataTest, meta_data_005, TestSize.Level1)
432 {
433 std::vector<MetaType> results;
434 results.push_back(OHOS_CAMERA_STREAM_ID);
435 Prepare(ResultCallbackMode::ON_CHANGED, results);
436
437 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
438 const int32_t streamId = cameraBase_->STREAM_ID_VIDEO;
439 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &streamId, DATA_COUNT);
440
441 uint8_t videoStabilizationMode = OHOS_CAMERA_VIDEO_STABILIZATION_LOW;
442 metaData->addEntry(OHOS_CONTROL_VIDEO_STABILIZATION_MODE, &videoStabilizationMode, sizeof(videoStabilizationMode));
443
444 StartPreviewVideoStream();
445
446 UpdateSettings(metaData);
447
448 StartPreviewVideoCapture();
449 sleep(SLEEP_SECOND_TWO);
450
451 uint8_t videoStabilizationModeChange = OHOS_CAMERA_VIDEO_STABILIZATION_MIDDLE;
452 metaData->updateEntry(
453 OHOS_CONTROL_VIDEO_STABILIZATION_MODE, &videoStabilizationModeChange, sizeof(videoStabilizationModeChange));
454 UpdateSettings(metaData);
455
456 StopPreviewVideoStream();
457 }
458
459 /**
460 * @tc.name: double preview
461 * @tc.desc: Commit 2 streams together, preview and video streams, isStreaming is true.
462 * CallbackMode is PER_FRAME, set device stream fps range value and exposure time value.
463 * @tc.level: Level1
464 * @tc.size: MediumTest
465 * @tc.type: Function
466 */
467 static HWTEST_F(MetaDataTest, meta_data_006, TestSize.Level1)
468 {
469 std::vector<MetaType> results;
470 results.push_back(OHOS_CAMERA_STREAM_ID);
471 results.push_back(OHOS_CONTROL_FPS_RANGES);
472 results.push_back(OHOS_SENSOR_EXPOSURE_TIME);
473 Prepare(ResultCallbackMode::PER_FRAME, results);
474
475 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
476 const int32_t deviceStreamId = 0;
477 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, DATA_COUNT);
478
479 SetFps(metaData, FPS_RANGE, false);
480
481 StartPreviewVideoStream();
482
483 UpdateSettings(metaData);
484
485 StartPreviewVideoCapture();
486 sleep(SLEEP_SECOND_TWO);
487
488 int64_t exposureTime = 10;
489 metaData->addEntry(OHOS_SENSOR_EXPOSURE_TIME, &exposureTime, DATA_COUNT);
490
491 UpdateSettings(metaData);
492
493 StopPreviewVideoStream();
494 }
495
496 /**
497 * @tc.name: double preview
498 * @tc.desc: Commit 2 streams together, preview and video streams, isStreaming is true.
499 * CallbackMode is PER_FRAME, set device stream fps range different value and exposure time value.
500 * @tc.level: Level1
501 * @tc.size: MediumTest
502 * @tc.type: Function
503 */
504 static HWTEST_F(MetaDataTest, meta_data_007, TestSize.Level1)
505 {
506 std::vector<MetaType> results;
507 results.push_back(OHOS_CAMERA_STREAM_ID);
508 results.push_back(OHOS_CONTROL_FPS_RANGES);
509 results.push_back(OHOS_SENSOR_EXPOSURE_TIME);
510 Prepare(ResultCallbackMode::PER_FRAME, results);
511
512 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
513 const int32_t deviceStreamId = 0;
514 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, DATA_COUNT);
515
516 SetFps(metaData, FPS_RANGE, false);
517
518 StartPreviewVideoStream();
519
520 UpdateSettings(metaData);
521
522 StartPreviewVideoCapture();
523 sleep(SLEEP_SECOND_TWO);
524
525 SetFps(metaData, FPS_RANGE_CHANGE, true);
526
527 UpdateSettings(metaData);
528 sleep(SLEEP_SECOND_TWO);
529
530 int64_t exposureTime = 10;
531 metaData->addEntry(OHOS_SENSOR_EXPOSURE_TIME, &exposureTime, DATA_COUNT);
532
533 UpdateSettings(metaData);
534
535 StopPreviewVideoStream();
536 }
537
538 /**
539 * @tc.name: double preview
540 * @tc.desc: Commit 2 streams together, preview and still picture streams, isStreaming is true.
541 * CallbackMode is ON_CHANGED, set still picture stream exposure mode different value.
542 * @tc.level: Level1
543 * @tc.size: MediumTest
544 * @tc.type: Function
545 */
546 static HWTEST_F(MetaDataTest, meta_data_008, TestSize.Level1)
547 {
548 std::vector<MetaType> results;
549 results.push_back(OHOS_CAMERA_STREAM_ID);
550 Prepare(ResultCallbackMode::ON_CHANGED, results);
551
552 std::shared_ptr<CameraSetting> metaData = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
553 const int32_t deviceStreamId = cameraBase_->STREAM_ID_CAPTURE;
554 metaData->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, DATA_COUNT);
555
556 uint8_t aeMode = OHOS_CAMERA_EXPOSURE_MODE_CONTINUOUS_AUTO;
557 metaData->addEntry(OHOS_CONTROL_EXPOSURE_MODE, &aeMode, sizeof(aeMode));
558
559 StartPreviewCaptureStream();
560
561 UpdateSettings(metaData);
562
563 StartCustomCapture();
564 sleep(SLEEP_SECOND_TWO);
565
566 uint8_t aeModeChangeValue = OHOS_CAMERA_EXPOSURE_MODE_LOCKED;
567 metaData->updateEntry(OHOS_CONTROL_EXPOSURE_MODE, &aeModeChangeValue, sizeof(aeModeChangeValue));
568
569 UpdateSettings(metaData);
570
571 StopPreviewCaptureStream();
572 }
573
574 /**
575 * @tc.name: double preview
576 * @tc.desc: Commit 2 streams together, preview and still picture streams, isStreaming is true.
577 * CallbackMode is ON_CHANGED, set still picture stream exposure mode/time different value and device stream fps range
578 * different value.
579 * @tc.level: Level1
580 * @tc.size: MediumTest
581 * @tc.type: Function
582 */
583 static HWTEST_F(MetaDataTest, meta_data_009, TestSize.Level1)
584 {
585 std::vector<MetaType> results;
586 results.push_back(OHOS_CAMERA_STREAM_ID);
587 results.push_back(OHOS_CONTROL_FPS_RANGES);
588 Prepare(ResultCallbackMode::ON_CHANGED, results);
589
590 std::shared_ptr<CameraSetting> metaDataDevice = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
591 const int32_t deviceStreamId = 0;
592 metaDataDevice->addEntry(OHOS_CAMERA_STREAM_ID, &deviceStreamId, DATA_COUNT);
593
594 SetFps(metaDataDevice, FPS_RANGE, false);
595
596 std::shared_ptr<CameraSetting> metaDataStream = std::make_shared<CameraSetting>(ENTRY_CAPACITY, DATA_CAPACITY);
597 const int32_t streamId = cameraBase_->STREAM_ID_CAPTURE;
598 metaDataStream->addEntry(OHOS_CAMERA_STREAM_ID, &streamId, DATA_COUNT);
599
600 uint8_t aeMode = OHOS_CAMERA_EXPOSURE_MODE_CONTINUOUS_AUTO;
601 metaDataStream->addEntry(OHOS_CONTROL_EXPOSURE_MODE, &aeMode, sizeof(aeMode));
602
603 int64_t exposureTime = 10;
604 metaDataStream->addEntry(OHOS_SENSOR_EXPOSURE_TIME, &exposureTime, DATA_COUNT);
605
606 StartPreviewCaptureStream();
607
608 UpdateSettings(metaDataDevice);
609 sleep(SLEEP_SECOND_TWO);
610 UpdateSettings(metaDataStream);
611 StartCustomCapture();
612 sleep(SLEEP_SECOND_TWO);
613
614 uint8_t aeModeChangeValue = OHOS_CAMERA_EXPOSURE_MODE_LOCKED;
615 metaDataStream->updateEntry(OHOS_CONTROL_EXPOSURE_MODE, &aeModeChangeValue, sizeof(aeModeChangeValue));
616
617 UpdateSettings(metaDataStream);
618 sleep(SLEEP_SECOND_TWO);
619 SetFps(metaDataDevice, FPS_RANGE_CHANGE, true);
620 UpdateSettings(metaDataDevice);
621
622 StopPreviewCaptureStream();
623 }
624