Chromium Code Reviews| Index: media/capture/video/chromeos/camera_metadata_utils.cc |
| diff --git a/media/capture/video/chromeos/camera_metadata_utils.cc b/media/capture/video/chromeos/camera_metadata_utils.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c5e1f88fefc246f73161484ebf5f85bc91f30cd9 |
| --- /dev/null |
| +++ b/media/capture/video/chromeos/camera_metadata_utils.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/capture/video/chromeos/camera_metadata_utils.h" |
| + |
| +namespace media { |
| + |
| +const arc::mojom::CameraMetadataEntryPtr* GetMetadataEntry( |
| + const arc::mojom::CameraMetadataPtr& camera_metadata, |
| + arc::mojom::CameraMetadataTag tag) { |
| + if (!camera_metadata->entries.has_value()) { |
| + return nullptr; |
| + } |
| + for (const auto& e : camera_metadata->entries.value()) { |
| + if (e->tag == tag) { |
| + return &e; |
| + } |
| + } |
| + return nullptr; |
| +} |
| + |
| +void MergeMetadata(arc::mojom::CameraMetadataPtr* to, |
| + const arc::mojom::CameraMetadataPtr& from) { |
| + DCHECK(to); |
| + 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.
|
| + (*to)->entry_count += from->entry_count; |
| + (*to)->entry_capacity += from->entry_count; |
| + (*to)->data_count += from->data_count; |
| + (*to)->data_capacity += from->data_count; |
| + std::set<arc::mojom::CameraMetadataTag> tags; |
| + |
|
wuchengli
2017/05/18 02:43:05
if (!from->entries.has_value())
return;
jcliang
2017/05/22 13:54:13
Done.
|
| + if ((*to)->entries.has_value()) { |
| + for (const auto& e : (*to)->entries.value()) { |
| + tags.insert(e->tag); |
| + } |
| + } |
| + |
| + if (from->entries.has_value()) { |
| + if (!(*to)->entries.has_value()) { |
| + (*to)->entries = std::vector<arc::mojom::CameraMetadataEntryPtr>(); |
| + } |
| + 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.
|
| + if (tags.find(e->tag) != tags.end()) { |
| + LOG(ERROR) << "Found duplicated entries for tag " << e->tag; |
| + continue; |
| + } |
| + tags.insert(e->tag); |
| + (*to)->entries->push_back(e->Clone()); |
| + } |
| + } |
| +} |
| + |
| +} // namespace media |