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 except 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
16 #include "metadata_controller.h"
17
18 namespace OHOS {
19 namespace Camera {
20 const std::vector<int32_t> DATA_BASE = {
21 OHOS_CAMERA_STREAM_ID,
22 OHOS_SENSOR_COLOR_CORRECTION_GAINS,
23 OHOS_SENSOR_EXPOSURE_TIME,
24 OHOS_CONTROL_EXPOSURE_MODE,
25 OHOS_CONTROL_AE_EXPOSURE_COMPENSATION,
26 OHOS_CONTROL_FOCUS_MODE,
27 OHOS_CONTROL_METER_MODE,
28 OHOS_CONTROL_FLASH_MODE,
29 OHOS_CONTROL_FPS_RANGES,
30 OHOS_CONTROL_AWB_MODE,
31 OHOS_CONTROL_AF_REGIONS,
32 OHOS_CONTROL_METER_POINT,
33 OHOS_CONTROL_VIDEO_STABILIZATION_MODE,
34 OHOS_CONTROL_FOCUS_STATE,
35 OHOS_CONTROL_EXPOSURE_STATE,
36 };
37
MetadataController()38 MetadataController::MetadataController() {}
39
~MetadataController()40 MetadataController::~MetadataController()
41 {
42 if (isRunning_.load()) {
43 isRunning_.store(false);
44 }
45 cv_.notify_all();
46 StopThread();
47 }
48
GetInstance()49 MetadataController &MetadataController::GetInstance()
50 {
51 static MetadataController controller;
52 return controller;
53 }
54
SetUpdateSettingCallback(const MetaDataCb & cb)55 void MetadataController::SetUpdateSettingCallback(const MetaDataCb &cb)
56 {
57 std::unique_lock<std::mutex> lock(dataConfigLock_);
58 if (!isInit_) {
59 CAMERA_LOGE("already set update setting callback.");
60 return;
61 }
62 updateSettingFunc_ = cb;
63 }
64
UnSetUpdateSettingCallback()65 void MetadataController::UnSetUpdateSettingCallback()
66 {
67 std::unique_lock<std::mutex> lock(dataConfigLock_);
68 if (!isInit_) {
69 CAMERA_LOGE("already set update setting callback.");
70 return;
71 }
72 updateSettingFunc_ = nullptr;
73 }
74
AddNodeCallback(const MetaDataCb & cb)75 void MetadataController::AddNodeCallback(const MetaDataCb &cb)
76 {
77 std::unique_lock<std::mutex> lock(queueLock_);
78 if (cb != nullptr) {
79 nodeFunc_.push_back(cb);
80 }
81 }
82
ClearNodeCallback()83 void MetadataController::ClearNodeCallback()
84 {
85 if (nodeFunc_.empty()) {
86 CAMERA_LOGE("nodeFunc_ empty");
87 return;
88 }
89 std::unique_lock<std::mutex> lock(queueLock_);
90 nodeFunc_.clear();
91 }
92
SetPeerFrameFlag(bool flag)93 void MetadataController::SetPeerFrameFlag(bool flag)
94 {
95 std::unique_lock<std::mutex> lock(dataConfigLock_);
96 peerFrame_ = flag;
97 }
98
AddEnabledAbility(const std::vector<int32_t> & abilityMetaDataTag)99 void MetadataController::AddEnabledAbility(const std::vector<int32_t> &abilityMetaDataTag)
100 {
101 std::unique_lock<std::mutex> lock(dataConfigLock_);
102 std::vector<int32_t>().swap(abilityMetaData_);
103 for (auto it = abilityMetaDataTag.cbegin(); it != abilityMetaDataTag.cend(); it++) {
104 switch (*it) {
105 case OHOS_CAMERA_STREAM_ID: // fallthrough
106 case OHOS_SENSOR_COLOR_CORRECTION_GAINS: // fallthrough
107 case OHOS_SENSOR_EXPOSURE_TIME: // fallthrough
108 case OHOS_CONTROL_EXPOSURE_MODE: // fallthrough
109 case OHOS_CONTROL_AE_EXPOSURE_COMPENSATION: // fallthrough
110 case OHOS_CONTROL_FOCUS_MODE: // fallthrough
111 case OHOS_CONTROL_METER_MODE: // fallthrough
112 case OHOS_CONTROL_FLASH_MODE: // fallthrough
113 case OHOS_CONTROL_FPS_RANGES: // fallthrough
114 case OHOS_CONTROL_AWB_MODE: // fallthrough
115 case OHOS_CONTROL_AF_REGIONS: // fallthrough
116 case OHOS_CONTROL_METER_POINT: // fallthrough
117 case OHOS_CONTROL_VIDEO_STABILIZATION_MODE: // fallthrough
118 case OHOS_CONTROL_FOCUS_STATE: // fallthrough
119 case OHOS_CONTROL_EXPOSURE_STATE: {
120 abilityMetaData_.push_back((*it));
121 break;
122 }
123 default:
124 break;
125 }
126 }
127 }
128
GetEnabledAbility(std::vector<int32_t> & results)129 int32_t MetadataController::GetEnabledAbility(std::vector<int32_t> &results)
130 {
131 std::unique_lock<std::mutex> lock(dataConfigLock_);
132 results = abilityMetaData_;
133 return RC_OK;
134 }
135
DelEnabledAbility(const std::vector<int32_t> & results)136 int32_t MetadataController::DelEnabledAbility(const std::vector<int32_t> &results)
137 {
138 std::unique_lock<std::mutex> lock(dataConfigLock_);
139 for (auto &metaType : results) {
140 auto itr = std::find(abilityMetaData_.begin(), abilityMetaData_.end(), metaType);
141 if (itr != abilityMetaData_.end()) {
142 abilityMetaData_.erase(itr);
143 } else {
144 CAMERA_LOGW("enabled result is not found. [metaType = %{public}d]", metaType);
145 return RC_ERROR;
146 }
147 }
148 return RC_OK;
149 }
150
UpdateSettingsConfig(const std::shared_ptr<CameraMetadata> & meta)151 bool MetadataController::UpdateSettingsConfig(const std::shared_ptr<CameraMetadata> &meta)
152 {
153 bool result = false;
154 int32_t streamId = GetStreamId(meta);
155 if (streamId < 0) {
156 CAMERA_LOGE("streamId is invalid %{public}d", streamId);
157 return false;
158 }
159 result = FilterUpdateKeys(streamId, meta);
160 if (!result) {
161 CAMERA_LOGE("filter update keys fail and streamId = %{public}d", streamId);
162 return false;
163 }
164 return DealMetadata(streamId, meta);
165 }
166
GetSettingsConfig(std::shared_ptr<CameraMetadata> & meta)167 void MetadataController::GetSettingsConfig(std::shared_ptr<CameraMetadata> &meta)
168 {
169 std::unique_lock<std::mutex> lock(dataConfigLock_);
170 metaDataConfig_->GetMetadata(DEVICE_STREAM_ID, meta);
171 }
172
GetStreamId(const std::shared_ptr<CameraMetadata> & meta)173 int32_t MetadataController::GetStreamId(const std::shared_ptr<CameraMetadata> &meta)
174 {
175 common_metadata_header_t *data = meta->get();
176 if (data == nullptr) {
177 CAMERA_LOGE("data is nullptr");
178 return RC_ERROR;
179 }
180 camera_metadata_item_t entry;
181 int32_t streamId = -1;
182 int rc = FindCameraMetadataItem(data, OHOS_CAMERA_STREAM_ID, &entry);
183 if (rc == 0) {
184 streamId = *entry.data.i32;
185 }
186 return streamId;
187 }
188
FilterUpdateKeys(int32_t streamId,const std::shared_ptr<CameraMetadata> & meta)189 bool MetadataController::FilterUpdateKeys(int32_t streamId, const std::shared_ptr<CameraMetadata> &meta)
190 {
191 common_metadata_header_t *data = meta->get();
192 if (data == nullptr) {
193 CAMERA_LOGE("data is nullptr");
194 return false;
195 }
196
197 std::vector<int32_t> metaKeys;
198 for (auto &metaKey : DATA_BASE) {
199 camera_metadata_item_t entry;
200 int rc = FindCameraMetadataItem(data, metaKey, &entry);
201 if (rc != 0) {
202 continue;
203 }
204 metaKeys.push_back(metaKey);
205 }
206
207 if (metaKeys.size() == 0) {
208 return false;
209 }
210 std::unique_lock<std::mutex> lock(dataConfigLock_);
211 updateMetaDataKeys_[streamId] = metaKeys;
212 return true;
213 }
214
DealMetadata(int32_t streamId,const std::shared_ptr<CameraMetadata> & meta)215 bool MetadataController::DealMetadata(int32_t streamId, const std::shared_ptr<CameraMetadata> &meta)
216 {
217 bool result = false;
218 if (firstNotifyNodes_.count(streamId) == 0 && streamId != DEVICE_STREAM_ID) {
219 {
220 std::unique_lock<std::mutex> lock(dataConfigLock_);
221 changeDataKeys_[streamId] = updateMetaDataKeys_[streamId];
222 result = metaDataConfig_->UpdateSettingsConfig(streamId, true, updateMetaDataKeys_[streamId], meta);
223 if (!result) {
224 CAMERA_LOGE("set metadata config fail and streamId = %{public}d", streamId);
225 return false;
226 }
227 }
228 firstNotifyNodes_.insert(streamId);
229 {
230 std::unique_lock<std::mutex> lock(queueLock_);
231 queue_.push(meta);
232 cv_.notify_all();
233 }
234 return true;
235 }
236 std::shared_ptr<CameraMetadata> metaTemp = nullptr;
237 {
238 std::unique_lock<std::mutex> lock(dataConfigLock_);
239 if (!metaDataConfig_->GetMetadata(streamId, metaTemp)) {
240 CAMERA_LOGE("get metadata fail and streamId = %{public}d", streamId);
241 return false;
242 }
243 }
244
245 std::shared_ptr<CameraMetadata> changeMetadata = std::make_shared<CameraMetadata>(ENTRY_CAPACITY, DATA_CAPACITY);
246 result = CompareMetadata(streamId, metaTemp, meta, changeMetadata);
247 if (!result) {
248 CAMERA_LOGE("compare metadata fail and streamId = %{public}d", streamId);
249 return false;
250 }
251 std::unique_lock<std::mutex> lock(queueLock_);
252 queue_.push(changeMetadata);
253 cv_.notify_all();
254 return true;
255 }
256
CompareMetadata(int32_t streamId,const std::shared_ptr<CameraMetadata> & oldMeta,const std::shared_ptr<CameraMetadata> & newMeta,std::shared_ptr<CameraMetadata> & outMetadata)257 bool MetadataController::CompareMetadata(int32_t streamId, const std::shared_ptr<CameraMetadata> &oldMeta,
258 const std::shared_ptr<CameraMetadata> &newMeta, std::shared_ptr<CameraMetadata> &outMetadata)
259 {
260 std::vector<int32_t> updateKeys;
261 std::vector<int32_t> newKeys;
262 common_metadata_header_t *metadataOld = oldMeta->get();
263 common_metadata_header_t *metadataNew = newMeta->get();
264 if (metadataOld == nullptr || metadataNew == nullptr) {
265 CAMERA_LOGE("get metadata failed.");
266 return false;
267 }
268 bool result = false;
269 for (auto &metaType : updateMetaDataKeys_[streamId]) {
270 camera_metadata_item_t baseEntry;
271 int ret = FindCameraMetadataItem(metadataOld, metaType, &baseEntry);
272 if (ret != 0) {
273 CAMERA_LOGE("metadata base not found tag.[metaType = %{public}d]", metaType);
274 newKeys.push_back(metaType);
275 continue;
276 }
277 camera_metadata_item_t newEntry;
278 ret = FindCameraMetadataItem(metadataNew, metaType, &newEntry);
279 if (ret != 0) {
280 CAMERA_LOGE("metadata result not found tag.[metaType = %{public}d]", metaType);
281 continue;
282 }
283 bool isChange = IsChangeTagData(metaType, baseEntry, newEntry);
284 if (isChange) {
285 updateKeys.push_back(OHOS_CAMERA_STREAM_ID);
286 updateKeys.push_back(metaType);
287 result = UpdateNewTagData(updateKeys, newMeta, outMetadata);
288 if (!result) {
289 CAMERA_LOGE("compare update change meta failed.");
290 return false;
291 }
292 }
293 }
294
295 if (updateKeys.size() == 0 && newKeys.size() == 0) {
296 CAMERA_LOGW("ignore meta data");
297 return false;
298 }
299 std::unique_lock<std::mutex> lock(dataConfigLock_);
300 if (newKeys.size() > 0) {
301 newKeys.push_back(OHOS_CAMERA_STREAM_ID);
302 }
303
304 if (updateKeys.size() > 0) {
305 updateKeys.push_back(OHOS_CAMERA_STREAM_ID);
306 }
307 return UpdateChangeMetadata(streamId, updateKeys, newKeys, newMeta, outMetadata);
308 }
309
UpdateChangeMetadata(int32_t streamId,const std::vector<int32_t> & updateKeys,const std::vector<int32_t> & newKeys,const std::shared_ptr<CameraMetadata> & newMeta,std::shared_ptr<CameraMetadata> & outMetadata)310 bool MetadataController::UpdateChangeMetadata(int32_t streamId, const std::vector<int32_t> &updateKeys,
311 const std::vector<int32_t> &newKeys, const std::shared_ptr<CameraMetadata> &newMeta,
312 std::shared_ptr<CameraMetadata> &outMetadata)
313 {
314 bool result = false;
315 if (updateKeys.size() == 0 && newKeys.size() > 1) {
316 changeDataKeys_[streamId] = newKeys;
317 result = metaDataConfig_->UpdateSettingsConfig(streamId, true, newKeys, newMeta);
318 if (!result) {
319 CAMERA_LOGE("set meta config new keys failed.");
320 return false;
321 }
322 result = UpdateNewTagData(newKeys, newMeta, outMetadata);
323 } else {
324 changeDataKeys_[streamId] = updateKeys;
325 if (newKeys.size() > 1) {
326 result = UpdateNewTagData(newKeys, newMeta, outMetadata);
327 if (!result) {
328 CAMERA_LOGE("update keys metadata failed.");
329 return false;
330 }
331 changeDataKeys_[streamId].insert(changeDataKeys_[streamId].end(), newKeys.begin(), newKeys.end());
332 result = metaDataConfig_->UpdateSettingsConfig(streamId, true, newKeys, newMeta);
333 if (!result) {
334 CAMERA_LOGE("set metadta config keys failed.");
335 return false;
336 }
337 }
338 result = metaDataConfig_->UpdateSettingsConfig(streamId, false, updateKeys, newMeta);
339 }
340 if (!result) {
341 CAMERA_LOGE("update change metadata failed.");
342 return false;
343 }
344 return true;
345 }
346
IsChangeTagData(int32_t key,const camera_metadata_item_t & baseEntry,const camera_metadata_item_t & newEntry)347 bool MetadataController::IsChangeTagData(
348 int32_t key, const camera_metadata_item_t &baseEntry, const camera_metadata_item_t &newEntry)
349 {
350 bool result = false;
351 switch (key) {
352 case OHOS_CONTROL_AWB_MODE: // fallthrough
353 case OHOS_CONTROL_FOCUS_MODE: // fallthrough
354 case OHOS_CONTROL_FOCUS_STATE: // fallthrough
355 case OHOS_CONTROL_EXPOSURE_MODE: // fallthrough
356 case OHOS_CONTROL_EXPOSURE_STATE: // fallthrough
357 case OHOS_CONTROL_FLASH_MODE: // fallthrough
358 case OHOS_CONTROL_METER_MODE: // fallthrough
359 case OHOS_CONTROL_VIDEO_STABILIZATION_MODE: {
360 result = IsChangeU8Metadata(baseEntry, newEntry);
361 break;
362 }
363 case OHOS_CONTROL_AE_EXPOSURE_COMPENSATION: {
364 result = IsChangeI32Metadata(baseEntry, newEntry);
365 break;
366 }
367 case OHOS_SENSOR_EXPOSURE_TIME: {
368 result = IsChangeI64Metadata(baseEntry, newEntry);
369 break;
370 }
371 case OHOS_SENSOR_COLOR_CORRECTION_GAINS: {
372 result = IsChangeFloatMetadata(baseEntry, newEntry);
373 break;
374 }
375 case OHOS_CONTROL_FPS_RANGES: // fallthrough
376 case OHOS_CONTROL_AF_REGIONS: // fallthrough
377 case OHOS_CONTROL_METER_POINT: {
378 result = IsChangeI32ArrayMetadata(baseEntry, newEntry);
379 break;
380 }
381 default: {
382 CAMERA_LOGW("invalid key %{public}d", key);
383 break;
384 }
385 }
386 return result;
387 }
388
IsChangeU8Metadata(const camera_metadata_item_t & baseEntry,const camera_metadata_item_t & newEntry)389 bool MetadataController::IsChangeU8Metadata(
390 const camera_metadata_item_t &baseEntry, const camera_metadata_item_t &newEntry)
391 {
392 if (*(baseEntry.data.u8) == *(newEntry.data.u8)) {
393 return false;
394 }
395 return true;
396 }
397
IsChangeI32Metadata(const camera_metadata_item_t & baseEntry,const camera_metadata_item_t & newEntry)398 bool MetadataController::IsChangeI32Metadata(
399 const camera_metadata_item_t &baseEntry, const camera_metadata_item_t &newEntry)
400 {
401 if (*(baseEntry.data.i32) == *(newEntry.data.i32)) {
402 return false;
403 }
404 return true;
405 }
406
IsChangeI64Metadata(const camera_metadata_item_t & baseEntry,const camera_metadata_item_t & newEntry)407 bool MetadataController::IsChangeI64Metadata(
408 const camera_metadata_item_t &baseEntry, const camera_metadata_item_t &newEntry)
409 {
410 if (*(baseEntry.data.i64) == *(newEntry.data.i64)) {
411 return false;
412 }
413 return true;
414 }
415
IsChangeFloatMetadata(const camera_metadata_item_t & baseEntry,const camera_metadata_item_t & newEntry)416 bool MetadataController::IsChangeFloatMetadata(
417 const camera_metadata_item_t &baseEntry, const camera_metadata_item_t &newEntry)
418 {
419 std::string baseValue = std::to_string(*(baseEntry.data.f));
420 std::string newValue = std::to_string(*(newEntry.data.f));
421 if (strcmp(baseValue.c_str(), newValue.c_str()) == 0) {
422 return false;
423 }
424 return true;
425 }
426
IsChangeI32ArrayMetadata(const camera_metadata_item_t & baseEntry,const camera_metadata_item_t & newEntry)427 bool MetadataController::IsChangeI32ArrayMetadata(
428 const camera_metadata_item_t &baseEntry, const camera_metadata_item_t &newEntry)
429 {
430 uint32_t count = newEntry.count;
431 bool isDiff = false;
432 for (int i = 0; i < count; i++) {
433 if (*(baseEntry.data.i32 + i) != *(newEntry.data.i32 + i)) {
434 isDiff = true;
435 break;
436 }
437 }
438 if (!isDiff) {
439 return false;
440 }
441 return true;
442 }
443
UpdateNewTagData(const std::vector<int32_t> & keys,const std::shared_ptr<CameraMetadata> & inMeta,std::shared_ptr<CameraMetadata> & outMeta)444 bool MetadataController::UpdateNewTagData(const std::vector<int32_t> &keys,
445 const std::shared_ptr<CameraMetadata> &inMeta, std::shared_ptr<CameraMetadata> &outMeta)
446 {
447 if (keys.size() == 0) {
448 CAMERA_LOGE("invalid size.");
449 return false;
450 }
451 common_metadata_header_t *data = inMeta->get();
452 if (data == nullptr) {
453 CAMERA_LOGE("data is null");
454 return false;
455 }
456 return DealUpdateNewTagData(keys, data, outMeta);
457 }
458
DealUpdateNewTagData(const std::vector<int32_t> & keys,common_metadata_header_t * data,std::shared_ptr<CameraMetadata> & outMeta)459 bool MetadataController::DealUpdateNewTagData(
460 const std::vector<int32_t> &keys, common_metadata_header_t *data, std::shared_ptr<CameraMetadata> &outMeta)
461 {
462 bool result = false;
463 for (auto it = keys.cbegin(); it != keys.cend(); it++) {
464 camera_metadata_item_t entry;
465 int ret = FindCameraMetadataItem(data, *it, &entry);
466 if (ret != 0) {
467 CAMERA_LOGE("get [%{public}d] error", *it);
468 return false;
469 }
470
471 result = outMeta->addEntry(*it, static_cast<void *>(entry.data.u8), entry.count);
472 if (!result) {
473 CAMERA_LOGE("update key [%{public}d] error", *it);
474 return false;
475 }
476 }
477 return result;
478 }
479
DealMessage()480 void MetadataController::DealMessage()
481 {
482 while (isRunning_.load()) {
483 std::unique_lock<std::mutex> lock(queueLock_);
484 if (queue_.empty()) {
485 cv_.wait(lock, [this] {
486 return isRunning_.load() == false || !queue_.empty();
487 });
488 }
489 if (!isRunning_.load()) {
490 break;
491 }
492 std::shared_ptr<CameraMetadata> meta = queue_.front();
493 for (auto nodeCallback : nodeFunc_) {
494 nodeCallback(meta);
495 }
496 queue_.pop();
497 }
498 CAMERA_LOGI("thread closed");
499 }
500
SetDeviceDefaultMetadata(std::shared_ptr<CameraMetadata> & meta)501 void MetadataController::SetDeviceDefaultMetadata(std::shared_ptr<CameraMetadata> &meta)
502 {
503 if (isInit_) {
504 CAMERA_LOGE("already set device default meta data.");
505 return;
506 }
507 isInit_ = true;
508 if (metaDataConfig_ != nullptr) {
509 metaDataConfig_.reset();
510 }
511 metaDataConfig_ = std::make_shared<MetadataConfig>();
512 metaDataConfig_->GetDeviceDefaultMetadata(meta);
513 FilterUpdateKeys(DEVICE_STREAM_ID, meta);
514 metaDataConfig_->UpdateSettingsConfig(DEVICE_STREAM_ID, true, updateMetaDataKeys_[DEVICE_STREAM_ID], meta);
515 }
516
Start()517 void MetadataController::Start()
518 {
519 if (!isInit_) {
520 CAMERA_LOGE("already start.");
521 return;
522 }
523 peerFrame_ = true;
524 updateSettingFunc_ = nullptr;
525
526 abilityMetaData_.clear();
527
528 if (isRunning_.load()) {
529 isRunning_.store(false);
530 }
531 cv_.notify_all();
532 StopThread();
533
534 isRunning_.store(true);
535
536 std::queue<std::shared_ptr<CameraMetadata>> empty;
537 swap(empty, queue_);
538
539 nodeFunc_.clear();
540 firstNotifyNodes_.clear();
541 updateMetaDataKeys_.clear();
542 changeDataKeys_.clear();
543
544 if (notifyChangedMetadata_ == nullptr) {
545 notifyChangedMetadata_ = new (std::nothrow) std::thread(&MetadataController::DealMessage, this);
546 if (notifyChangedMetadata_ == nullptr) {
547 CAMERA_LOGE("notifyChangedMetadata_ create failed\n");
548 return;
549 }
550 }
551 }
552
Stop()553 void MetadataController::Stop()
554 {
555 if (!isInit_) {
556 CAMERA_LOGE("invalid stop.");
557 return;
558 }
559 isInit_ = false;
560 isRunning_.store(false);
561 cv_.notify_all();
562 StopThread();
563 ClearNodeCallback();
564 }
565
StopThread()566 void MetadataController::StopThread()
567 {
568 if (notifyChangedMetadata_ != nullptr) {
569 notifyChangedMetadata_->join();
570 delete notifyChangedMetadata_;
571 notifyChangedMetadata_ = nullptr;
572 }
573 }
574
NotifyMetaData(int32_t streamId)575 void MetadataController::NotifyMetaData(int32_t streamId)
576 {
577 std::unique_lock<std::mutex> lock(dataConfigLock_);
578 if (updateSettingFunc_ == nullptr) {
579 CAMERA_LOGE("%{public}s updateSettingFunc_ is null and streamId=%{public}d", __FUNCTION__, streamId);
580 return;
581 }
582
583 std::shared_ptr<CameraMetadata> metaTemp = nullptr;
584 bool result = metaDataConfig_->GetMetadata(streamId, metaTemp);
585 if (!result) {
586 CAMERA_LOGE("%{public}s GetMetaData failed and streamId=%{public}d", __FUNCTION__, streamId);
587 return;
588 }
589
590 std::shared_ptr<CameraMetadata> metaData = {};
591 if (streamId == DEVICE_STREAM_ID) {
592 metaData = std::make_shared<CameraMetadata>(ENTRY_CAPACITY, DATA_CAPACITY);
593 UpdateNewTagData(abilityMetaData_, metaTemp, metaData);
594 metaTemp = std::move(metaData);
595 }
596
597 if (peerFrame_) {
598 updateSettingFunc_(metaTemp);
599 return;
600 }
601 if (changeDataKeys_.count(streamId) == 0) {
602 CAMERA_LOGE("%{public}s invalid streamId and streamId=%{public}d", __FUNCTION__, streamId);
603 return;
604 }
605 updateSettingFunc_(metaTemp);
606 changeDataKeys_.erase(streamId);
607 }
608 } // namespace Camera
609 } // namespace OHOS
610