1 /*
2  * Copyright (C) 2014 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  * @addtogroup Media
19  * @{
20  */
21 
22 /**
23  * @file NdkMediaFormat.h
24  */
25 
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_MEDIA_FORMAT_H
37 #define _NDK_MEDIA_FORMAT_H
38 
39 #include <stdbool.h>
40 #include <sys/cdefs.h>
41 #include <sys/types.h>
42 
43 #ifndef __ANDROID__
44 // Value copied from 'bionic/libc/include/android/api-level.h' which is not available on
45 // non Android systems. It is set to 10000 which is same as __ANDROID_API_FUTURE__ value.
46 #ifndef __ANDROID_API__
47 #define __ANDROID_API__ 10000
48 #endif
49 
50 // Value copied from 'bionic/libc/include/android/versioning.h' which is not available on
51 // non Android systems
52 #ifndef __INTRODUCED_IN
53 #define __INTRODUCED_IN(api_level)
54 #endif
55 #endif
56 
57 #include "NdkMediaError.h"
58 
59 __BEGIN_DECLS
60 
61 struct AMediaFormat;
62 typedef struct AMediaFormat AMediaFormat;
63 
64 #if __ANDROID_API__ >= 21
65 
66 /**
67  * Available since API level 21.
68  */
69 AMediaFormat *AMediaFormat_new() __INTRODUCED_IN(21);
70 
71 /**
72  * Available since API level 21.
73  */
74 media_status_t AMediaFormat_delete(AMediaFormat*) __INTRODUCED_IN(21);
75 
76 /**
77  * Human readable representation of the format. The returned string is owned by the format,
78  * and remains valid until the next call to toString, or until the format is deleted.
79  *
80  * Available since API level 21.
81  */
82 const char* AMediaFormat_toString(AMediaFormat*) __INTRODUCED_IN(21);
83 
84 /**
85  * Available since API level 21.
86  */
87 bool AMediaFormat_getInt32(AMediaFormat*, const char *name, int32_t *out) __INTRODUCED_IN(21);
88 /**
89  * Available since API level 21.
90  */
91 bool AMediaFormat_getInt64(AMediaFormat*, const char *name, int64_t *out) __INTRODUCED_IN(21);
92 /**
93  * Available since API level 21.
94  */
95 bool AMediaFormat_getFloat(AMediaFormat*, const char *name, float *out) __INTRODUCED_IN(21);
96 /**
97  * Available since API level 21.
98  */
99 bool AMediaFormat_getSize(AMediaFormat*, const char *name, size_t *out) __INTRODUCED_IN(21);
100 /**
101  * The returned data is owned by the format and remains valid as long as the named entry
102  * is part of the format.
103  *
104  * Available since API level 21.
105  */
106 bool AMediaFormat_getBuffer(AMediaFormat*, const char *name, void** data, size_t *size) __INTRODUCED_IN(21);
107 /**
108  * The returned string is owned by the format, and remains valid until the next call to getString,
109  * or until the format is deleted.
110  *
111  * Available since API level 21.
112  */
113 bool AMediaFormat_getString(AMediaFormat*, const char *name, const char **out) __INTRODUCED_IN(21);
114 
115 
116 /**
117  * Available since API level 21.
118  */
119 void AMediaFormat_setInt32(AMediaFormat*, const char* name, int32_t value) __INTRODUCED_IN(21);
120 /**
121  * Available since API level 21.
122  */
123 void AMediaFormat_setInt64(AMediaFormat*, const char* name, int64_t value) __INTRODUCED_IN(21);
124 /**
125  * Available since API level 21.
126  */
127 void AMediaFormat_setFloat(AMediaFormat*, const char* name, float value) __INTRODUCED_IN(21);
128 /**
129  * The provided string is copied into the format.
130  *
131  * Available since API level 21.
132  */
133 void AMediaFormat_setString(AMediaFormat*, const char* name, const char* value) __INTRODUCED_IN(21);
134 /**
135  * The provided data is copied into the format.
136  *
137  * Available since API level 21.
138  */
139 void AMediaFormat_setBuffer(AMediaFormat*, const char* name, const void* data, size_t size) __INTRODUCED_IN(21);
140 
141 
142 extern const char* AMEDIAFORMAT_KEY_AAC_DRC_ATTENUATION_FACTOR __INTRODUCED_IN(28);
143 extern const char* AMEDIAFORMAT_KEY_AAC_DRC_BOOST_FACTOR __INTRODUCED_IN(28);
144 extern const char* AMEDIAFORMAT_KEY_AAC_DRC_HEAVY_COMPRESSION __INTRODUCED_IN(28);
145 extern const char* AMEDIAFORMAT_KEY_AAC_DRC_TARGET_REFERENCE_LEVEL __INTRODUCED_IN(28);
146 extern const char* AMEDIAFORMAT_KEY_AAC_ENCODED_TARGET_LEVEL __INTRODUCED_IN(28);
147 extern const char* AMEDIAFORMAT_KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT __INTRODUCED_IN(28);
148 extern const char* AMEDIAFORMAT_KEY_AAC_PROFILE __INTRODUCED_IN(21);
149 extern const char* AMEDIAFORMAT_KEY_AAC_SBR_MODE __INTRODUCED_IN(28);
150 extern const char* AMEDIAFORMAT_KEY_AUDIO_SESSION_ID __INTRODUCED_IN(28);
151 extern const char* AMEDIAFORMAT_KEY_BITRATE_MODE __INTRODUCED_IN(28);
152 extern const char* AMEDIAFORMAT_KEY_BIT_RATE __INTRODUCED_IN(21);
153 extern const char* AMEDIAFORMAT_KEY_CAPTURE_RATE __INTRODUCED_IN(28);
154 extern const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT __INTRODUCED_IN(21);
155 extern const char* AMEDIAFORMAT_KEY_CHANNEL_MASK __INTRODUCED_IN(21);
156 extern const char* AMEDIAFORMAT_KEY_COLOR_FORMAT __INTRODUCED_IN(21);
157 extern const char* AMEDIAFORMAT_KEY_COLOR_RANGE __INTRODUCED_IN(28);
158 extern const char* AMEDIAFORMAT_KEY_COLOR_STANDARD __INTRODUCED_IN(28);
159 extern const char* AMEDIAFORMAT_KEY_COLOR_TRANSFER __INTRODUCED_IN(28);
160 extern const char* AMEDIAFORMAT_KEY_COMPLEXITY __INTRODUCED_IN(28);
161 extern const char* AMEDIAFORMAT_KEY_CSD __INTRODUCED_IN(28);
162 extern const char* AMEDIAFORMAT_KEY_CSD_0 __INTRODUCED_IN(28);
163 extern const char* AMEDIAFORMAT_KEY_CSD_1 __INTRODUCED_IN(28);
164 extern const char* AMEDIAFORMAT_KEY_CSD_2 __INTRODUCED_IN(28);
165 extern const char* AMEDIAFORMAT_KEY_DISPLAY_CROP __INTRODUCED_IN(28);
166 extern const char* AMEDIAFORMAT_KEY_DISPLAY_HEIGHT __INTRODUCED_IN(28);
167 extern const char* AMEDIAFORMAT_KEY_DISPLAY_WIDTH __INTRODUCED_IN(28);
168 extern const char* AMEDIAFORMAT_KEY_DURATION __INTRODUCED_IN(21);
169 extern const char* AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL __INTRODUCED_IN(21);
170 extern const char* AMEDIAFORMAT_KEY_FRAME_RATE __INTRODUCED_IN(21);
171 extern const char* AMEDIAFORMAT_KEY_GRID_COLUMNS __INTRODUCED_IN(28);
172 extern const char* AMEDIAFORMAT_KEY_GRID_ROWS __INTRODUCED_IN(28);
173 extern const char* AMEDIAFORMAT_KEY_HDR_STATIC_INFO __INTRODUCED_IN(28);
174 extern const char* AMEDIAFORMAT_KEY_HEIGHT __INTRODUCED_IN(21);
175 extern const char* AMEDIAFORMAT_KEY_INTRA_REFRESH_PERIOD __INTRODUCED_IN(28);
176 extern const char* AMEDIAFORMAT_KEY_IS_ADTS __INTRODUCED_IN(21);
177 extern const char* AMEDIAFORMAT_KEY_IS_AUTOSELECT __INTRODUCED_IN(21);
178 extern const char* AMEDIAFORMAT_KEY_IS_DEFAULT __INTRODUCED_IN(21);
179 extern const char* AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE __INTRODUCED_IN(21);
180 extern const char* AMEDIAFORMAT_KEY_I_FRAME_INTERVAL __INTRODUCED_IN(21);
181 extern const char* AMEDIAFORMAT_KEY_LANGUAGE __INTRODUCED_IN(21);
182 extern const char* AMEDIAFORMAT_KEY_LATENCY __INTRODUCED_IN(28);
183 extern const char* AMEDIAFORMAT_KEY_LEVEL __INTRODUCED_IN(28);
184 extern const char* AMEDIAFORMAT_KEY_MAX_HEIGHT __INTRODUCED_IN(21);
185 extern const char* AMEDIAFORMAT_KEY_MAX_INPUT_SIZE __INTRODUCED_IN(21);
186 extern const char* AMEDIAFORMAT_KEY_MAX_WIDTH __INTRODUCED_IN(21);
187 extern const char* AMEDIAFORMAT_KEY_MIME __INTRODUCED_IN(21);
188 extern const char* AMEDIAFORMAT_KEY_MPEG_USER_DATA __INTRODUCED_IN(28);
189 extern const char* AMEDIAFORMAT_KEY_OPERATING_RATE __INTRODUCED_IN(28);
190 extern const char* AMEDIAFORMAT_KEY_PCM_ENCODING __INTRODUCED_IN(28);
191 extern const char* AMEDIAFORMAT_KEY_PRIORITY __INTRODUCED_IN(28);
192 extern const char* AMEDIAFORMAT_KEY_PROFILE __INTRODUCED_IN(28);
193 extern const char* AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP __INTRODUCED_IN(21);
194 extern const char* AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER __INTRODUCED_IN(21);
195 extern const char* AMEDIAFORMAT_KEY_ROTATION __INTRODUCED_IN(28);
196 extern const char* AMEDIAFORMAT_KEY_SAMPLE_RATE __INTRODUCED_IN(21);
197 extern const char* AMEDIAFORMAT_KEY_SEI __INTRODUCED_IN(28);
198 extern const char* AMEDIAFORMAT_KEY_SLICE_HEIGHT __INTRODUCED_IN(28);
199 extern const char* AMEDIAFORMAT_KEY_STRIDE __INTRODUCED_IN(21);
200 extern const char* AMEDIAFORMAT_KEY_TEMPORAL_LAYER_ID __INTRODUCED_IN(28);
201 extern const char* AMEDIAFORMAT_KEY_TEMPORAL_LAYERING __INTRODUCED_IN(28);
202 extern const char* AMEDIAFORMAT_KEY_TILE_HEIGHT __INTRODUCED_IN(28);
203 extern const char* AMEDIAFORMAT_KEY_TILE_WIDTH __INTRODUCED_IN(28);
204 extern const char* AMEDIAFORMAT_KEY_TIME_US __INTRODUCED_IN(28);
205 extern const char* AMEDIAFORMAT_KEY_TRACK_ID __INTRODUCED_IN(28);
206 extern const char* AMEDIAFORMAT_KEY_TRACK_INDEX __INTRODUCED_IN(28);
207 extern const char* AMEDIAFORMAT_KEY_WIDTH __INTRODUCED_IN(21);
208 #endif /* __ANDROID_API__ >= 21 */
209 
210 #if __ANDROID_API__ >= 28
211 /**
212  * Available since API level 28.
213  */
214 bool AMediaFormat_getDouble(AMediaFormat*, const char *name, double *out) __INTRODUCED_IN(28);
215 /**
216  * Available since API level 28.
217  */
218 bool AMediaFormat_getRect(AMediaFormat*, const char *name,
219         int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) __INTRODUCED_IN(28);
220 
221 /**
222  * Available since API level 28.
223  */
224 void AMediaFormat_setDouble(AMediaFormat*, const char* name, double value) __INTRODUCED_IN(28);
225 /**
226  * Available since API level 28.
227  */
228 void AMediaFormat_setSize(AMediaFormat*, const char* name, size_t value) __INTRODUCED_IN(28);
229 /**
230  * Available since API level 28.
231  */
232 void AMediaFormat_setRect(AMediaFormat*, const char* name,
233         int32_t left, int32_t top, int32_t right, int32_t bottom) __INTRODUCED_IN(28);
234 #endif /* __ANDROID_API__ >= 28 */
235 
236 #if __ANDROID_API__ >= 29
237 /**
238  * Remove all key/value pairs from the given AMediaFormat.
239  *
240  * Available since API level 29.
241  */
242 void AMediaFormat_clear(AMediaFormat*) __INTRODUCED_IN(29);
243 
244 /**
245  * Copy one AMediaFormat to another.
246  *
247  * Available since API level 29.
248  */
249 media_status_t AMediaFormat_copy(AMediaFormat *to, AMediaFormat *from) __INTRODUCED_IN(29);
250 
251 extern const char* AMEDIAFORMAT_KEY_ALBUM __INTRODUCED_IN(29);
252 extern const char* AMEDIAFORMAT_KEY_ALBUMART __INTRODUCED_IN(29);
253 extern const char* AMEDIAFORMAT_KEY_ALBUMARTIST __INTRODUCED_IN(29);
254 extern const char* AMEDIAFORMAT_KEY_ARTIST __INTRODUCED_IN(29);
255 extern const char* AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_INFO __INTRODUCED_IN(29);
256 extern const char* AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PRESENTATION_ID __INTRODUCED_IN(29);
257 extern const char* AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PROGRAM_ID __INTRODUCED_IN(29);
258 extern const char* AMEDIAFORMAT_KEY_AUTHOR __INTRODUCED_IN(29);
259 extern const char* AMEDIAFORMAT_KEY_BITS_PER_SAMPLE __INTRODUCED_IN(29);
260 extern const char* AMEDIAFORMAT_KEY_CDTRACKNUMBER __INTRODUCED_IN(29);
261 extern const char* AMEDIAFORMAT_KEY_COMPILATION __INTRODUCED_IN(29);
262 extern const char* AMEDIAFORMAT_KEY_COMPOSER __INTRODUCED_IN(29);
263 extern const char* AMEDIAFORMAT_KEY_CREATE_INPUT_SURFACE_SUSPENDED __INTRODUCED_IN(29);
264 extern const char* AMEDIAFORMAT_KEY_CRYPTO_DEFAULT_IV_SIZE __INTRODUCED_IN(29);
265 extern const char* AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_BYTE_BLOCK __INTRODUCED_IN(29);
266 extern const char* AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_SIZES __INTRODUCED_IN(29);
267 extern const char* AMEDIAFORMAT_KEY_CRYPTO_IV __INTRODUCED_IN(29);
268 extern const char* AMEDIAFORMAT_KEY_CRYPTO_KEY __INTRODUCED_IN(29);
269 extern const char* AMEDIAFORMAT_KEY_CRYPTO_MODE __INTRODUCED_IN(29);
270 extern const char* AMEDIAFORMAT_KEY_CRYPTO_PLAIN_SIZES __INTRODUCED_IN(29);
271 extern const char* AMEDIAFORMAT_KEY_CRYPTO_SKIP_BYTE_BLOCK __INTRODUCED_IN(29);
272 extern const char* AMEDIAFORMAT_KEY_CSD_AVC __INTRODUCED_IN(29);
273 extern const char* AMEDIAFORMAT_KEY_CSD_HEVC __INTRODUCED_IN(29);
274 extern const char* AMEDIAFORMAT_KEY_D263 __INTRODUCED_IN(29);
275 extern const char* AMEDIAFORMAT_KEY_DATE __INTRODUCED_IN(29);
276 extern const char* AMEDIAFORMAT_KEY_DISCNUMBER __INTRODUCED_IN(29);
277 extern const char* AMEDIAFORMAT_KEY_ENCODER_DELAY __INTRODUCED_IN(29);
278 extern const char* AMEDIAFORMAT_KEY_ENCODER_PADDING __INTRODUCED_IN(29);
279 extern const char* AMEDIAFORMAT_KEY_ESDS __INTRODUCED_IN(29);
280 extern const char* AMEDIAFORMAT_KEY_EXIF_OFFSET __INTRODUCED_IN(29);
281 extern const char* AMEDIAFORMAT_KEY_EXIF_SIZE __INTRODUCED_IN(29);
282 extern const char* AMEDIAFORMAT_KEY_FRAME_COUNT __INTRODUCED_IN(29);
283 extern const char* AMEDIAFORMAT_KEY_GENRE __INTRODUCED_IN(29);
284 extern const char* AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT __INTRODUCED_IN(29);
285 extern const char* AMEDIAFORMAT_KEY_ICC_PROFILE __INTRODUCED_IN(29);
286 extern const char* AMEDIAFORMAT_KEY_IS_SYNC_FRAME __INTRODUCED_IN(29);
287 extern const char* AMEDIAFORMAT_KEY_LOCATION __INTRODUCED_IN(29);
288 extern const char* AMEDIAFORMAT_KEY_LOOP __INTRODUCED_IN(29);
289 extern const char* AMEDIAFORMAT_KEY_LYRICIST __INTRODUCED_IN(29);
290 extern const char* AMEDIAFORMAT_KEY_MANUFACTURER __INTRODUCED_IN(29);
291 extern const char* AMEDIAFORMAT_KEY_MAX_BIT_RATE __INTRODUCED_IN(29);
292 extern const char* AMEDIAFORMAT_KEY_MAX_FPS_TO_ENCODER __INTRODUCED_IN(29);
293 extern const char* AMEDIAFORMAT_KEY_MAX_PTS_GAP_TO_ENCODER __INTRODUCED_IN(29);
294 extern const char* AMEDIAFORMAT_KEY_MPEG2_STREAM_HEADER __INTRODUCED_IN(29);
295 extern const char* AMEDIAFORMAT_KEY_PCM_BIG_ENDIAN __INTRODUCED_IN(29);
296 extern const char* AMEDIAFORMAT_KEY_PSSH __INTRODUCED_IN(29);
297 extern const char* AMEDIAFORMAT_KEY_SAR_HEIGHT __INTRODUCED_IN(29);
298 extern const char* AMEDIAFORMAT_KEY_SAR_WIDTH __INTRODUCED_IN(29);
299 extern const char* AMEDIAFORMAT_KEY_TARGET_TIME __INTRODUCED_IN(29);
300 extern const char* AMEDIAFORMAT_KEY_TEMPORAL_LAYER_COUNT __INTRODUCED_IN(29);
301 extern const char* AMEDIAFORMAT_KEY_TEXT_FORMAT_DATA __INTRODUCED_IN(29);
302 extern const char* AMEDIAFORMAT_KEY_THUMBNAIL_CSD_HEVC __INTRODUCED_IN(29);
303 extern const char* AMEDIAFORMAT_KEY_THUMBNAIL_HEIGHT __INTRODUCED_IN(29);
304 extern const char* AMEDIAFORMAT_KEY_THUMBNAIL_TIME __INTRODUCED_IN(29);
305 extern const char* AMEDIAFORMAT_KEY_THUMBNAIL_WIDTH __INTRODUCED_IN(29);
306 extern const char* AMEDIAFORMAT_KEY_TITLE __INTRODUCED_IN(29);
307 extern const char* AMEDIAFORMAT_KEY_VALID_SAMPLES __INTRODUCED_IN(29);
308 extern const char* AMEDIAFORMAT_KEY_YEAR __INTRODUCED_IN(29);
309 
310 #endif /* __ANDROID_API__ >= 29 */
311 
312 __END_DECLS
313 
314 #endif // _NDK_MEDIA_FORMAT_H
315 
316 /** @} */
317