Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1221)

Unified Diff: media/capture/video/chromeos/camera_metadata_utils.cc

Issue 2837273004: media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: revise some code comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+ (*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;
+
+ 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()) {
+ 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

Powered by Google App Engine
This is Rietveld 408576698