Chromium Code Reviews| 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(); | |
|
wuchengli
2017/05/18 02:43:05
remove. unused
jcliang
2017/05/22 13:54:13
Done.
| |
| 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 | |
|
wuchengli
2017/05/18 02:43:05
if (!from->entries.has_value())
return;
jcliang
2017/05/22 13:54:13
Done.
| |
| 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()) { | |
|
wuchengli
2017/05/18 02:43:05
s/e/entry/
jcliang
2017/05/22 13:54:13
Done.
| |
| 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 |