summaryrefslogtreecommitdiff
path: root/src/android/camera_metadata.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2021-01-21 19:15:42 +0900
committerJacopo Mondi <jacopo@jmondi.org>2021-01-22 10:35:28 +0100
commit5e2596006bc662c1e565052728cd732d8f78bf1e (patch)
tree8c72dfafb1b46a063819c2870f72e2bc7bb5ddca /src/android/camera_metadata.cpp
parentafbf0ec626db43b0117d28ef4f9b825a7d19929a (diff)
android: camera_metadata: Add copy constructor and getEntry
Add a copy constructor and assignment operator to CameraMetadata, as well a constructor from camera_metadata_t. Also add a function getEntry to allow getting metadata entries from CameraMetadata. This allows us to use CameraMetadata for reading from camera_metadata_t. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android/camera_metadata.cpp')
-rw-r--r--src/android/camera_metadata.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/android/camera_metadata.cpp b/src/android/camera_metadata.cpp
index edea48fe..8e36e758 100644
--- a/src/android/camera_metadata.cpp
+++ b/src/android/camera_metadata.cpp
@@ -19,12 +19,45 @@ CameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity)
valid_ = metadata_ != nullptr;
}
+CameraMetadata::CameraMetadata(const camera_metadata_t *metadata)
+{
+ metadata_ = clone_camera_metadata(metadata);
+ valid_ = metadata_ != nullptr;
+}
+
+CameraMetadata::CameraMetadata(const CameraMetadata &other)
+ : CameraMetadata(other.get())
+{
+}
+
CameraMetadata::~CameraMetadata()
{
if (metadata_)
free_camera_metadata(metadata_);
}
+CameraMetadata &CameraMetadata::operator=(const CameraMetadata &other)
+{
+ if (this == &other)
+ return *this;
+
+ if (metadata_)
+ free_camera_metadata(metadata_);
+
+ metadata_ = clone_camera_metadata(other.get());
+ valid_ = metadata_ != nullptr;
+
+ return *this;
+}
+
+bool CameraMetadata::getEntry(uint32_t tag, camera_metadata_ro_entry_t *entry) const
+{
+ if (find_camera_metadata_ro_entry(metadata_, tag, entry))
+ return false;
+
+ return true;
+}
+
bool CameraMetadata::addEntry(uint32_t tag, const void *data, size_t count)
{
if (!valid_)