[libcamera-devel] [PATCH 2/6] android: CameraMetadata: Add copy constructor and getEntry
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Jan 15 18:06:36 CET 2021
Hi Paul,
Thank you for the patch.
On Thu, Jan 14, 2021 at 07:40:31PM +0900, Paul Elder wrote:
> Add a copy constructor to CameraMetadata, as well as a constructor from
You also need a copy assignement operator then. See
https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming).
> camera_metadata_t. Also add a function getEntry to allow getting
> metadata entries from CameraMetadata. This allows us to use
> CameraMetadata for reading form camera_metadata_t.
s/form/from/
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> ---
> src/android/camera_metadata.cpp | 23 +++++++++++++++++++++++
> src/android/camera_metadata.h | 3 +++
> 2 files changed, 26 insertions(+)
>
> diff --git a/src/android/camera_metadata.cpp b/src/android/camera_metadata.cpp
> index edea48fe..57ac6009 100644
> --- a/src/android/camera_metadata.cpp
> +++ b/src/android/camera_metadata.cpp
> @@ -19,12 +19,35 @@ 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)
> +{
> + metadata_ = clone_camera_metadata(other.get());
> + valid_ = metadata_ != nullptr;
> +}
> +
> CameraMetadata::~CameraMetadata()
> {
> if (metadata_)
> free_camera_metadata(metadata_);
> }
>
> +int CameraMetadata::getEntry(uint32_t tag, camera_metadata_ro_entry_t *entry) const
Should this return a bool like addEntry() and updateEntry() ?
> +{
> + if (!entry)
> + return -EINVAL;
I'd drop this, it shouldn't happen.
> +
> + if (find_camera_metadata_ro_entry(metadata_, tag, entry))
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> bool CameraMetadata::addEntry(uint32_t tag, const void *data, size_t count)
> {
> if (!valid_)
> diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h
> index 9d047b1b..fa1c4983 100644
> --- a/src/android/camera_metadata.h
> +++ b/src/android/camera_metadata.h
> @@ -15,9 +15,12 @@ class CameraMetadata
> {
> public:
> CameraMetadata(size_t entryCapacity, size_t dataCapacity);
> + CameraMetadata(const camera_metadata_t *metadata);
> + CameraMetadata(const CameraMetadata &other);
> ~CameraMetadata();
>
> bool isValid() const { return valid_; }
> + int getEntry(uint32_t tag, camera_metadata_ro_entry_t *entry) const;
> bool addEntry(uint32_t tag, const void *data, size_t data_count);
> bool updateEntry(uint32_t tag, const void *data, size_t data_count);
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list