summaryrefslogtreecommitdiff
path: root/src/android/camera_metadata.h
AgeCommit message (Collapse)Author
2021-05-18android: camera_metadata: Add type sanity check to updateEntry()Laurent Pinchart
The CameraMetadata::updateEntry() functions cast the data pointer to a void pointer, which is then used internally to call update_camera_metadata_entry(). If the caller passes a pointer to an incorrect data type, the behaviour is undefined, with possible crashes if the incorrect data type is smaller than expected by the Android metadata library. To avoid crashes, make all public updateEntry() functions take typed pointers, and pass the element size to the internal function. The element size is then checked against the expected size, and an error message logged if they don't match. This won't catch incorrect data types that have the same size as the correct type, but will at least avoid potential crashes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-18android: camera_metadata: Make internal functions privateLaurent Pinchart
The resize() function and the addEntry() override that takes a void pointer are not meant to be called by the user of the CameraMetadata class. Make them private. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-18android: camera_metadata: Constify argument to addEntry() and updateEntry()Laurent Pinchart
The addEntry() and updateEntry() overrides that take a reference to a container don't need to modify the container. Make it const. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-18android: camera_metadata: Rename sizeofT argument to elementSizeLaurent Pinchart
The sizeofT argument to CameraMetadata::addEntry() stores the size of one element. Its name is a bit cryptic as the function isn't a template function with a typename T. Rename it to elementSize. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-14android: camera_metadata: Auto-resize CameraMetadataPaul Elder
Previously we had to manually declare the size of CameraMetadata on allocation, and its count could not be changed after construction. Change CameraMetadata's behavior so that the user can simply add or update entries, and the CameraMetadata will auto-resize (double the size) as necessary. Also remove everything involved with calculating the initial size for any CameraMetadata instances. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-01-22android: camera_metadata: Add defaul constructorJacopo Mondi
Add a default constructor that initializes a non valid CameraMetadata to allow embedding instances of the class in other types. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-22android: camera_metadata: Add copy constructor and getEntryPaul Elder
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>
2020-08-05android: camera_metadata: Add method to update an entryJacopo Mondi
Add a method to update an existing metadata tag entry, by wrapping the update_metadata_entry() function provided by the Android metadata library. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05android: camera_metadata: Add const version of get()Jacopo Mondi
Add a const version of the CameraMetadata::get() method to retrieve a const pointer to the camera metadata wrapped by the class instance. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05android: camera_metadata: Mark isValid() as constJacopo Mondi
The CameraMetadata::isValid() method does not modify the object state and can be called on const instances of the CameraMetadata class. Mark the method as const to allow that. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-05android: Add CameraMetadata helper classLaurent Pinchart
The new CameraMetadata helper class wraps the Android camera_metadata_t to simplify its usage. Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>