diff options
author | Igor Murashkin <iam@google.com> | 2012-12-03 13:55:33 -0800 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2013-01-30 16:16:33 -0800 |
commit | 5b6e79aad5371d5651268c65f9fef9c07c9d1a89 (patch) | |
tree | 46bdeb6aa63ae1ef529e2b3d7614750ed4c32924 | |
parent | d728474a27777e3a153088a01099109f16c6a0de (diff) | |
download | android_system_media-5b6e79aad5371d5651268c65f9fef9c07c9d1a89.tar.gz android_system_media-5b6e79aad5371d5651268c65f9fef9c07c9d1a89.tar.bz2 android_system_media-5b6e79aad5371d5651268c65f9fef9c07c9d1a89.zip |
Camera2: Dump enum data types as strings, not integers: DO NOT MERGE
Change-Id: Ia225662d4ee0aad81b22b96355d7f39c4aa70d42
-rw-r--r-- | camera/docs/camera_metadata_tag_info.mako | 6 | ||||
-rw-r--r-- | camera/docs/metadata_model.py | 28 | ||||
-rw-r--r-- | camera/src/camera_metadata.c | 36 | ||||
-rw-r--r-- | camera/src/camera_metadata_tag_info.c | 2 |
4 files changed, 52 insertions, 20 deletions
diff --git a/camera/docs/camera_metadata_tag_info.mako b/camera/docs/camera_metadata_tag_info.mako index bceadc15..26ba619a 100644 --- a/camera/docs/camera_metadata_tag_info.mako +++ b/camera/docs/camera_metadata_tag_info.mako @@ -101,3 +101,9 @@ int camera_metadata_enum_snprint(uint32_t tag, return ret; } +<% + find_values = lambda x: isinstance(x, metadata_model.EnumValue) + enum_values = metadata.find_all(find_values) + enum_value_max_len = max([len(value.name) for value in enum_values]) + 1 +%> +#define CAMERA_METADATA_ENUM_STRING_MAX_SIZE ${enum_value_max_len} diff --git a/camera/docs/metadata_model.py b/camera/docs/metadata_model.py index e91fcd13..b403a47d 100644 --- a/camera/docs/metadata_model.py +++ b/camera/docs/metadata_model.py @@ -720,7 +720,7 @@ class InnerNamespace(Node): for i in self.entries: yield i -class EnumValue(object): +class EnumValue(Node): """ A class corresponding to a <value> element within an <enum> within an <entry>. @@ -729,16 +729,14 @@ class EnumValue(object): id: An optional numeric string, e.g. '0' or '0xFF' optional: A boolean notes: A string describing the notes, or None. + parent: An edge to the parent, always an Enum instance. """ - def __init__(self, name, id=None, optional=False, notes=None): + def __init__(self, name, parent, id=None, optional=False, notes=None): self._name = name # str, e.g. 'ON' or 'OFF' self._id = id # int, e.g. '0' self._optional = optional # bool self._notes = notes # None or str - - @property - def name(self): - return self._name + self._parent = parent @property def id(self): @@ -752,7 +750,10 @@ class EnumValue(object): def notes(self): return self._notes -class Enum(object): + def _get_children(self): + return None + +class Enum(Node): """ A class corresponding to an <enum> element within an <entry>. @@ -762,19 +763,19 @@ class Enum(object): """ def __init__(self, parent, values, ids={}, optionals=[], notes={}): self._values = \ - [ EnumValue(val, ids.get(val), val in optionals, notes.get(val)) \ + [ EnumValue(val, self, ids.get(val), val in optionals, notes.get(val)) \ for val in values ] self._parent = parent - - @property - def parent(self): - return self._parent + self._name = None @property def values(self): return (i for i in self._values) + def _get_children(self): + return (i for i in self._values) + class Entry(Node): """ A node corresponding to an <entry> element. @@ -910,7 +911,8 @@ class Entry(Node): return self._enum def _get_children(self): - return None + if self.enum: + yield self.enum def sort_children(self): return None diff --git a/camera/src/camera_metadata.c b/camera/src/camera_metadata.c index e5c2f251..1963b89a 100644 --- a/camera/src/camera_metadata.c +++ b/camera/src/camera_metadata.c @@ -640,7 +640,8 @@ int set_camera_metadata_vendor_tag_ops(const vendor_tag_query_ops_t *query_ops) return OK; } -static void print_data(int fd, const uint8_t *data_ptr, int type, int count, +static void print_data(int fd, const uint8_t *data_ptr, uint32_t tag, int type, + int count, int indentation); void dump_camera_metadata(const camera_metadata_t *metadata, @@ -714,11 +715,11 @@ void dump_indented_camera_metadata(const camera_metadata_t *metadata, int count = entry->count; if (verbosity < 2 && count > 16) count = 16; - print_data(fd, data_ptr, entry->type, count, indentation); + print_data(fd, data_ptr, entry->tag, entry->type, count, indentation); } } -static void print_data(int fd, const uint8_t *data_ptr, +static void print_data(int fd, const uint8_t *data_ptr, uint32_t tag, int type, int count, int indentation) { static int values_per_line[NUM_TYPES] = { [TYPE_BYTE] = 16, @@ -729,6 +730,8 @@ static void print_data(int fd, const uint8_t *data_ptr, [TYPE_RATIONAL] = 2, }; size_t type_size = camera_metadata_type_size[type]; + char value_string_tmp[CAMERA_METADATA_ENUM_STRING_MAX_SIZE]; + uint32_t value; int lines = count / values_per_line[type]; if (count % values_per_line[type] != 0) lines++; @@ -743,12 +746,31 @@ static void print_data(int fd, const uint8_t *data_ptr, switch (type) { case TYPE_BYTE: - fdprintf(fd, "%hhu ", - *(data_ptr + index)); + value = *(data_ptr + index); + if (camera_metadata_enum_snprint(tag, + value, + value_string_tmp, + sizeof(value_string_tmp)) + == OK) { + fdprintf(fd, "%s ", value_string_tmp); + } else { + fdprintf(fd, "%hhu ", + *(data_ptr + index)); + } break; case TYPE_INT32: - fdprintf(fd, "%d ", - *(int32_t*)(data_ptr + index)); + value = + *(int32_t*)(data_ptr + index); + if (camera_metadata_enum_snprint(tag, + value, + value_string_tmp, + sizeof(value_string_tmp)) + == OK) { + fdprintf(fd, "%s ", value_string_tmp); + } else { + fdprintf(fd, "%d ", + *(int32_t*)(data_ptr + index)); + } break; case TYPE_FLOAT: fdprintf(fd, "%0.2f ", diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c index b32fd101..5eee1404 100644 --- a/camera/src/camera_metadata_tag_info.c +++ b/camera/src/camera_metadata_tag_info.c @@ -1775,3 +1775,5 @@ int camera_metadata_enum_snprint(uint32_t tag, } +#define CAMERA_METADATA_ENUM_STRING_MAX_SIZE 23 + |