mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-15 08:25:07 +03:00
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>
This commit is contained in:
parent
10cdc914da
commit
24f80f14af
2 changed files with 24 additions and 0 deletions
|
@ -121,6 +121,26 @@ bool CameraMetadata::resize(size_t count, size_t size)
|
||||||
return true;
|
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,
|
bool CameraMetadata::addEntry(uint32_t tag, const void *data, size_t count,
|
||||||
size_t elementSize)
|
size_t elementSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,10 @@ public:
|
||||||
bool isValid() const { return valid_; }
|
bool isValid() const { return valid_; }
|
||||||
bool getEntry(uint32_t tag, camera_metadata_ro_entry_t *entry) const;
|
bool getEntry(uint32_t tag, camera_metadata_ro_entry_t *entry) const;
|
||||||
|
|
||||||
|
template<typename T> bool entryContains(uint32_t tag, T value) const;
|
||||||
|
|
||||||
|
bool hasEntry(uint32_t tag) const;
|
||||||
|
|
||||||
template<typename T,
|
template<typename T,
|
||||||
std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
|
std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
|
||||||
bool addEntry(uint32_t tag, const T &data)
|
bool addEntry(uint32_t tag, const T &data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue