| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/capture/video/chromeos/camera_metadata_utils.h" |
| 6 |
| 7 #include <set> |
| 8 |
| 9 namespace media { |
| 10 |
| 11 const arc::mojom::CameraMetadataEntryPtr* GetMetadataEntry( |
| 12 const arc::mojom::CameraMetadataPtr& camera_metadata, |
| 13 arc::mojom::CameraMetadataTag tag) { |
| 14 if (!camera_metadata->entries.has_value()) { |
| 15 return nullptr; |
| 16 } |
| 17 for (const auto& entry : camera_metadata->entries.value()) { |
| 18 if (entry->tag == tag) { |
| 19 return &entry; |
| 20 } |
| 21 } |
| 22 return nullptr; |
| 23 } |
| 24 |
| 25 void MergeMetadata(arc::mojom::CameraMetadataPtr* to, |
| 26 const arc::mojom::CameraMetadataPtr& from) { |
| 27 DCHECK(to); |
| 28 (*to)->entry_count += from->entry_count; |
| 29 (*to)->entry_capacity += from->entry_count; |
| 30 (*to)->data_count += from->data_count; |
| 31 (*to)->data_capacity += from->data_count; |
| 32 |
| 33 if (!from->entries) { |
| 34 return; |
| 35 } |
| 36 |
| 37 std::set<arc::mojom::CameraMetadataTag> tags; |
| 38 if ((*to)->entries) { |
| 39 for (const auto& entry : (*to)->entries.value()) { |
| 40 tags.insert(entry->tag); |
| 41 } |
| 42 } else { |
| 43 (*to)->entries = std::vector<arc::mojom::CameraMetadataEntryPtr>(); |
| 44 } |
| 45 for (const auto& entry : from->entries.value()) { |
| 46 if (tags.find(entry->tag) != tags.end()) { |
| 47 LOG(ERROR) << "Found duplicated entries for tag " << entry->tag; |
| 48 continue; |
| 49 } |
| 50 tags.insert(entry->tag); |
| 51 (*to)->entries->push_back(entry->Clone()); |
| 52 } |
| 53 } |
| 54 |
| 55 } // namespace media |
| OLD | NEW |