Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Yin-Chia Yeh | 3e49be1 | 2016-04-12 16:00:33 -0700 | [diff] [blame^] | 17 | /** |
| 18 | * @addtogroup Camera |
| 19 | * @{ |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * @file NdkCameraMetadata.h |
| 24 | */ |
| 25 | |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 26 | /* |
| 27 | * This file defines an NDK API. |
| 28 | * Do not remove methods. |
| 29 | * Do not change method signatures. |
| 30 | * Do not change the value of constants. |
| 31 | * Do not change the size of any of the classes defined in here. |
| 32 | * Do not reference types that are not part of the NDK. |
| 33 | * Do not #include files that aren't part of the NDK. |
| 34 | */ |
| 35 | |
| 36 | #ifndef _NDK_CAMERA_METADATA_H |
| 37 | #define _NDK_CAMERA_METADATA_H |
| 38 | |
| 39 | #include "NdkCameraError.h" |
| 40 | #include "NdkCameraMetadataTags.h" |
| 41 | |
| 42 | #ifdef __cplusplus |
| 43 | extern "C" { |
| 44 | #endif |
| 45 | |
| 46 | typedef struct ACameraMetadata ACameraMetadata; |
| 47 | |
| 48 | // Keep in sync with system/media/include/system/camera_metadata.h |
| 49 | enum { |
| 50 | // Unsigned 8-bit integer (uint8_t) |
| 51 | ACAMERA_TYPE_BYTE = 0, |
| 52 | // Signed 32-bit integer (int32_t) |
| 53 | ACAMERA_TYPE_INT32 = 1, |
| 54 | // 32-bit float (float) |
| 55 | ACAMERA_TYPE_FLOAT = 2, |
| 56 | // Signed 64-bit integer (int64_t) |
| 57 | ACAMERA_TYPE_INT64 = 3, |
| 58 | // 64-bit float (double) |
| 59 | ACAMERA_TYPE_DOUBLE = 4, |
| 60 | // A 64-bit fraction (ACameraMetadata_rational) |
| 61 | ACAMERA_TYPE_RATIONAL = 5, |
| 62 | // Number of type fields |
| 63 | ACAMERA_NUM_TYPES |
| 64 | }; |
| 65 | |
| 66 | typedef struct ACameraMetadata_rational { |
| 67 | int32_t numerator; |
| 68 | int32_t denominator; |
| 69 | } ACameraMetadata_rational; |
| 70 | |
| 71 | typedef struct ACameraMetadata_entry { |
| 72 | uint32_t tag; |
| 73 | uint8_t type; |
| 74 | uint32_t count; |
| 75 | union { |
| 76 | uint8_t *u8; |
| 77 | int32_t *i32; |
| 78 | float *f; |
| 79 | int64_t *i64; |
| 80 | double *d; |
| 81 | ACameraMetadata_rational* r; |
| 82 | } data; |
| 83 | } ACameraMetadata_entry; |
| 84 | |
| 85 | typedef struct ACameraMetadata_const_entry { |
| 86 | uint32_t tag; |
| 87 | uint8_t type; |
| 88 | uint32_t count; |
| 89 | union { |
| 90 | const uint8_t *u8; |
| 91 | const int32_t *i32; |
| 92 | const float *f; |
| 93 | const int64_t *i64; |
| 94 | const double *d; |
| 95 | const ACameraMetadata_rational* r; |
| 96 | } data; |
| 97 | } ACameraMetadata_const_entry; |
| 98 | |
| 99 | /* |
| 100 | * Get a metadata entry |
| 101 | */ |
| 102 | camera_status_t ACameraMetadata_getConstEntry( |
| 103 | const ACameraMetadata*, uint32_t tag, ACameraMetadata_const_entry* entry); |
| 104 | |
Yin-Chia Yeh | 8aac03f | 2016-03-03 15:45:23 -0800 | [diff] [blame] | 105 | /* |
| 106 | * List all the entry tags in this metadata. |
| 107 | * The memory of tags is managed by ACameraMetadata itself and must NOT be free/delete |
| 108 | * by application. Do NOT access tags after calling ACameraMetadata_free |
| 109 | */ |
| 110 | camera_status_t ACameraMetadata_getAllTags( |
| 111 | const ACameraMetadata*, /*out*/int32_t* numTags, /*out*/const uint32_t** tags); |
Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Copy a metadata. Duplicates a metadata structure. |
| 115 | * The destination ACameraMetadata must be freed by the application with ACameraMetadata_free |
| 116 | * after application is done using it. |
| 117 | * Returns NULL when src cannot be copied |
| 118 | */ |
| 119 | ACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src); |
| 120 | |
| 121 | /** |
| 122 | * Frees a metadata structure. |
| 123 | */ |
| 124 | void ACameraMetadata_free(ACameraMetadata*); |
| 125 | |
| 126 | #ifdef __cplusplus |
| 127 | } // extern "C" |
| 128 | #endif |
| 129 | |
| 130 | #endif //_NDK_CAMERA_METADATA_H |
Yin-Chia Yeh | 3e49be1 | 2016-04-12 16:00:33 -0700 | [diff] [blame^] | 131 | |
| 132 | /** @} */ |