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 | |
| 17 | /* |
| 18 | * This file defines an NDK API. |
| 19 | * Do not remove methods. |
| 20 | * Do not change method signatures. |
| 21 | * Do not change the value of constants. |
| 22 | * Do not change the size of any of the classes defined in here. |
| 23 | * Do not reference types that are not part of the NDK. |
| 24 | * Do not #include files that aren't part of the NDK. |
| 25 | */ |
| 26 | |
| 27 | #ifndef _NDK_CAMERA_METADATA_H |
| 28 | #define _NDK_CAMERA_METADATA_H |
| 29 | |
| 30 | #include "NdkCameraError.h" |
| 31 | #include "NdkCameraMetadataTags.h" |
| 32 | |
| 33 | #ifdef __cplusplus |
| 34 | extern "C" { |
| 35 | #endif |
| 36 | |
| 37 | typedef struct ACameraMetadata ACameraMetadata; |
| 38 | |
| 39 | // Keep in sync with system/media/include/system/camera_metadata.h |
| 40 | enum { |
| 41 | // Unsigned 8-bit integer (uint8_t) |
| 42 | ACAMERA_TYPE_BYTE = 0, |
| 43 | // Signed 32-bit integer (int32_t) |
| 44 | ACAMERA_TYPE_INT32 = 1, |
| 45 | // 32-bit float (float) |
| 46 | ACAMERA_TYPE_FLOAT = 2, |
| 47 | // Signed 64-bit integer (int64_t) |
| 48 | ACAMERA_TYPE_INT64 = 3, |
| 49 | // 64-bit float (double) |
| 50 | ACAMERA_TYPE_DOUBLE = 4, |
| 51 | // A 64-bit fraction (ACameraMetadata_rational) |
| 52 | ACAMERA_TYPE_RATIONAL = 5, |
| 53 | // Number of type fields |
| 54 | ACAMERA_NUM_TYPES |
| 55 | }; |
| 56 | |
| 57 | typedef struct ACameraMetadata_rational { |
| 58 | int32_t numerator; |
| 59 | int32_t denominator; |
| 60 | } ACameraMetadata_rational; |
| 61 | |
| 62 | typedef struct ACameraMetadata_entry { |
| 63 | uint32_t tag; |
| 64 | uint8_t type; |
| 65 | uint32_t count; |
| 66 | union { |
| 67 | uint8_t *u8; |
| 68 | int32_t *i32; |
| 69 | float *f; |
| 70 | int64_t *i64; |
| 71 | double *d; |
| 72 | ACameraMetadata_rational* r; |
| 73 | } data; |
| 74 | } ACameraMetadata_entry; |
| 75 | |
| 76 | typedef struct ACameraMetadata_const_entry { |
| 77 | uint32_t tag; |
| 78 | uint8_t type; |
| 79 | uint32_t count; |
| 80 | union { |
| 81 | const uint8_t *u8; |
| 82 | const int32_t *i32; |
| 83 | const float *f; |
| 84 | const int64_t *i64; |
| 85 | const double *d; |
| 86 | const ACameraMetadata_rational* r; |
| 87 | } data; |
| 88 | } ACameraMetadata_const_entry; |
| 89 | |
| 90 | /* |
| 91 | * Get a metadata entry |
| 92 | */ |
| 93 | camera_status_t ACameraMetadata_getConstEntry( |
| 94 | const ACameraMetadata*, uint32_t tag, ACameraMetadata_const_entry* entry); |
| 95 | |
| 96 | // TODO: need an API to list all tags in the metadata. Same for ACaptureRequest |
| 97 | |
| 98 | /** |
| 99 | * Copy a metadata. Duplicates a metadata structure. |
| 100 | * The destination ACameraMetadata must be freed by the application with ACameraMetadata_free |
| 101 | * after application is done using it. |
| 102 | * Returns NULL when src cannot be copied |
| 103 | */ |
| 104 | ACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src); |
| 105 | |
| 106 | /** |
| 107 | * Frees a metadata structure. |
| 108 | */ |
| 109 | void ACameraMetadata_free(ACameraMetadata*); |
| 110 | |
| 111 | #ifdef __cplusplus |
| 112 | } // extern "C" |
| 113 | #endif |
| 114 | |
| 115 | #endif //_NDK_CAMERA_METADATA_H |