blob: 8a8865de2bfe6576bf502c91bf85841d42171df7 [file] [log] [blame]
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -08001/*
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 Yeh3e49be12016-04-12 16:00:33 -070017/**
18 * @addtogroup Camera
19 * @{
20 */
21
22/**
23 * @file NdkCameraMetadata.h
24 */
25
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -080026/*
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
43extern "C" {
44#endif
45
46typedef struct ACameraMetadata ACameraMetadata;
47
48// Keep in sync with system/media/include/system/camera_metadata.h
49enum {
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
66typedef struct ACameraMetadata_rational {
67 int32_t numerator;
68 int32_t denominator;
69} ACameraMetadata_rational;
70
71typedef 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
85typedef 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 */
102camera_status_t ACameraMetadata_getConstEntry(
103 const ACameraMetadata*, uint32_t tag, ACameraMetadata_const_entry* entry);
104
Yin-Chia Yeh8aac03f2016-03-03 15:45:23 -0800105/*
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 */
110camera_status_t ACameraMetadata_getAllTags(
111 const ACameraMetadata*, /*out*/int32_t* numTags, /*out*/const uint32_t** tags);
Yin-Chia Yeh0dea57f2015-12-09 16:46:07 -0800112
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 */
119ACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src);
120
121/**
122 * Frees a metadata structure.
123 */
124void ACameraMetadata_free(ACameraMetadata*);
125
126#ifdef __cplusplus
127} // extern "C"
128#endif
129
130#endif //_NDK_CAMERA_METADATA_H
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -0700131
132/** @} */