diff options
author | Paul Elder <paul.elder@ideasonboard.com> | 2021-07-16 18:38:44 +0900 |
---|---|---|
committer | Paul Elder <paul.elder@ideasonboard.com> | 2021-08-02 18:07:19 +0900 |
commit | 24f80f14af50872c2294bce96da97492ca41f72f (patch) | |
tree | 21706481c9fc14fd6799a6d12b733f8d25cf30e7 /src/android/camera_metadata.cpp | |
parent | 10cdc914dad282b4ca0ad11067d5c6d446af1fcc (diff) |
android: metadata: Add hasEntry and entryContains
Add convenience functions for checking if an entry is present in a
CameraMetadata instance, and to check if an array entry includes a
specific value.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android/camera_metadata.cpp')
-rw-r--r-- | src/android/camera_metadata.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/android/camera_metadata.cpp b/src/android/camera_metadata.cpp index 3fc7cf27..075b6a22 100644 --- a/src/android/camera_metadata.cpp +++ b/src/android/camera_metadata.cpp @@ -121,6 +121,26 @@ bool CameraMetadata::resize(size_t count, size_t size) return true; } +template<> bool CameraMetadata::entryContains(uint32_t tag, uint8_t value) const +{ + camera_metadata_ro_entry_t entry; + if (!getEntry(tag, &entry)) + return false; + + for (unsigned int i = 0; i < entry.count; i++) { + if (entry.data.u8[i] == value) + return true; + } + + return false; +} + +bool CameraMetadata::hasEntry(uint32_t tag) const +{ + camera_metadata_ro_entry_t entry; + return getEntry(tag, &entry); +} + bool CameraMetadata::addEntry(uint32_t tag, const void *data, size_t count, size_t elementSize) { |