| 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 namespace media { |
| 8 |
| 9 const arc::mojom::CameraMetadataEntryPtr* GetMetadataEntry( |
| 10 const arc::mojom::CameraMetadataPtr& camera_metadata, |
| 11 arc::mojom::CameraMetadataTag tag) { |
| 12 if (!camera_metadata->entries.has_value()) { |
| 13 return nullptr; |
| 14 } |
| 15 for (const auto& e : camera_metadata->entries.value()) { |
| 16 if (e->tag == tag) { |
| 17 return &e; |
| 18 } |
| 19 } |
| 20 return nullptr; |
| 21 } |
| 22 |
| 23 void MergeMetadata(arc::mojom::CameraMetadataPtr* to, |
| 24 const arc::mojom::CameraMetadataPtr& from) { |
| 25 DCHECK(to); |
| 26 arc::mojom::CameraMetadataPtr result = arc::mojom::CameraMetadata::New(); |
| 27 (*to)->entry_count += from->entry_count; |
| 28 (*to)->entry_capacity += from->entry_count; |
| 29 (*to)->data_count += from->data_count; |
| 30 (*to)->data_capacity += from->data_count; |
| 31 std::set<arc::mojom::CameraMetadataTag> tags; |
| 32 |
| 33 if ((*to)->entries.has_value()) { |
| 34 for (const auto& e : (*to)->entries.value()) { |
| 35 tags.insert(e->tag); |
| 36 } |
| 37 } |
| 38 |
| 39 if (from->entries.has_value()) { |
| 40 if (!(*to)->entries.has_value()) { |
| 41 (*to)->entries = std::vector<arc::mojom::CameraMetadataEntryPtr>(); |
| 42 } |
| 43 for (const auto& e : from->entries.value()) { |
| 44 if (tags.find(e->tag) != tags.end()) { |
| 45 LOG(ERROR) << "Found duplicated entries for tag " << e->tag; |
| 46 continue; |
| 47 } |
| 48 tags.insert(e->tag); |
| 49 (*to)->entries->push_back(e->Clone()); |
| 50 } |
| 51 } |
| 52 } |
| 53 |
| 54 } // namespace media |
| OLD | NEW |