* limitations under the License.
*/
-#ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_METADATA_H
-#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_METADATA_H
+#ifndef SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_METADATA_H
+#define SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_METADATA_H
#include <string.h>
#include <stdint.h>
} camera_metadata_entry_t;
/**
+ * A read-only reference to a metadata entry in a buffer. Identical to
+ * camera_metadata_entry in layout
+ */
+typedef struct camera_metadata_ro_entry {
+ size_t index;
+ uint32_t tag;
+ uint8_t type;
+ size_t count;
+ union {
+ const uint8_t *u8;
+ const int32_t *i32;
+ const float *f;
+ const int64_t *i64;
+ const double *d;
+ const camera_metadata_rational_t *r;
+ } data;
+} camera_metadata_ro_entry_t;
+
+/**
* Size in bytes of each entry type
*/
ANDROID_API
* can be freed with free_camera_metadata(). Returns NULL if cloning failed.
*/
ANDROID_API
-camera_metadata_t *clone_camera_metadata(camera_metadata_t *src);
+camera_metadata_t *clone_camera_metadata(const camera_metadata_t *src);
/**
* Calculate the number of bytes of extra data a given metadata entry will take
camera_metadata_entry_t *entry);
/**
+ * Find an entry with given tag value, but disallow editing the data
+ */
+ANDROID_API
+int find_camera_metadata_ro_entry(const camera_metadata_t *src,
+ uint32_t tag,
+ camera_metadata_ro_entry_t *entry);
+
+/**
* Delete an entry at given index. This is an expensive operation, since it
* requires repacking entries and possibly entry data. This also invalidates any
* existing camera_metadata_entry.data pointers to this buffer. Sorting is
camera_metadata_t *allocate_camera_metadata(size_t entry_capacity,
size_t data_capacity) {
+ if (entry_capacity == 0) return NULL;
+
size_t memory_needed = calculate_camera_metadata_size(entry_capacity,
data_capacity);
void *buffer = malloc(memory_needed);
return OK;
}
-camera_metadata_t *clone_camera_metadata(camera_metadata_t *src) {
+camera_metadata_t *clone_camera_metadata(const camera_metadata_t *src) {
int res;
+ if (src == NULL) return NULL;
camera_metadata_t *clone = allocate_camera_metadata(
get_camera_metadata_entry_count(src),
get_camera_metadata_data_count(src));
entry);
}
+int find_camera_metadata_ro_entry(const camera_metadata_t *src,
+ uint32_t tag,
+ camera_metadata_ro_entry_t *entry) {
+ return find_camera_metadata_entry((camera_metadata_t*)src, tag,
+ (camera_metadata_entry_t*)entry);
+}
+
+
int delete_camera_metadata_entry(camera_metadata_t *dst,
size_t index) {
if (dst == NULL) return ERROR;
int verbosity,
int indentation) {
if (metadata == NULL) {
- ALOGE("%s: Metadata is null.", __FUNCTION__);
+ fdprintf(fd, "%*sDumping camera metadata array: Not allocated",
+ indentation, "");
return;
}
unsigned int i;
fdprintf(fd,
- "%*sDumping camera metadata array. %d / %d entries, "
+ "%*sDumping camera metadata array: %d / %d entries, "
"%d / %d bytes of extra data.\n", indentation, "",
metadata->entry_count, metadata->entry_capacity,
metadata->data_count, metadata->data_capacity);