Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 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 | |
Dan Albert | ec6cd63 | 2018-04-13 15:57:25 -0700 | [diff] [blame] | 17 | /** |
| 18 | * @addtogroup Media |
| 19 | * @{ |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * @file NdkMediaCodec.h |
| 24 | */ |
| 25 | |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [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_MEDIA_CODEC_H |
| 37 | #define _NDK_MEDIA_CODEC_H |
| 38 | |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 39 | #include <stdint.h> |
Dan Albert | 2975a24 | 2016-09-23 16:17:45 -0700 | [diff] [blame] | 40 | #include <sys/cdefs.h> |
| 41 | |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 42 | #include "NdkMediaCrypto.h" |
Marco Nelissen | e419d7c | 2014-05-15 14:17:25 -0700 | [diff] [blame] | 43 | #include "NdkMediaError.h" |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 44 | #include "NdkMediaFormat.h" |
| 45 | |
Dan Albert | 5e496db | 2017-10-05 15:03:07 -0700 | [diff] [blame] | 46 | __BEGIN_DECLS |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 47 | |
Mathias Agopian | bc1713d | 2017-02-13 18:37:50 -0800 | [diff] [blame] | 48 | struct ANativeWindow; |
Robert Shih | f6d1049 | 2017-09-26 13:30:48 -0700 | [diff] [blame] | 49 | typedef struct ANativeWindow ANativeWindow; |
Mathias Agopian | bc1713d | 2017-02-13 18:37:50 -0800 | [diff] [blame] | 50 | |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 51 | |
| 52 | struct AMediaCodec; |
| 53 | typedef struct AMediaCodec AMediaCodec; |
| 54 | |
| 55 | struct AMediaCodecBufferInfo { |
| 56 | int32_t offset; |
| 57 | int32_t size; |
| 58 | int64_t presentationTimeUs; |
| 59 | uint32_t flags; |
| 60 | }; |
| 61 | typedef struct AMediaCodecBufferInfo AMediaCodecBufferInfo; |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 62 | typedef struct AMediaCodecCryptoInfo AMediaCodecCryptoInfo; |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 63 | |
| 64 | enum { |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 65 | AMEDIACODEC_BUFFER_FLAG_CODEC_CONFIG = 2, |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 66 | AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM = 4, |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 67 | AMEDIACODEC_BUFFER_FLAG_PARTIAL_FRAME = 8, |
| 68 | |
Marco Nelissen | 86aa02c | 2014-05-07 16:03:54 -0700 | [diff] [blame] | 69 | AMEDIACODEC_CONFIGURE_FLAG_ENCODE = 1, |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 70 | AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED = -3, |
| 71 | AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED = -2, |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 72 | AMEDIACODEC_INFO_TRY_AGAIN_LATER = -1, |
| 73 | }; |
| 74 | |
| 75 | /** |
| 76 | * Called when an input buffer becomes available. |
| 77 | * The specified index is the index of the available input buffer. |
| 78 | */ |
| 79 | typedef void (*AMediaCodecOnAsyncInputAvailable)( |
| 80 | AMediaCodec *codec, |
| 81 | void *userdata, |
| 82 | int32_t index); |
| 83 | /** |
| 84 | * Called when an output buffer becomes available. |
| 85 | * The specified index is the index of the available output buffer. |
| 86 | * The specified bufferInfo contains information regarding the available output buffer. |
| 87 | */ |
| 88 | typedef void (*AMediaCodecOnAsyncOutputAvailable)( |
| 89 | AMediaCodec *codec, |
| 90 | void *userdata, |
| 91 | int32_t index, |
| 92 | AMediaCodecBufferInfo *bufferInfo); |
| 93 | /** |
| 94 | * Called when the output format has changed. |
| 95 | * The specified format contains the new output format. |
| 96 | */ |
| 97 | typedef void (*AMediaCodecOnAsyncFormatChanged)( |
| 98 | AMediaCodec *codec, |
| 99 | void *userdata, |
| 100 | AMediaFormat *format); |
| 101 | /** |
| 102 | * Called when the MediaCodec encountered an error. |
| 103 | * The specified actionCode indicates the possible actions that client can take, |
| 104 | * and it can be checked by calling AMediaCodecActionCode_isRecoverable or |
| 105 | * AMediaCodecActionCode_isTransient. If both AMediaCodecActionCode_isRecoverable() |
| 106 | * and AMediaCodecActionCode_isTransient() return false, then the codec error is fatal |
| 107 | * and the codec must be deleted. |
| 108 | * The specified detail may contain more detailed messages about this error. |
| 109 | */ |
| 110 | typedef void (*AMediaCodecOnAsyncError)( |
| 111 | AMediaCodec *codec, |
| 112 | void *userdata, |
| 113 | media_status_t error, |
| 114 | int32_t actionCode, |
| 115 | const char *detail); |
| 116 | |
Dan Albert | dfb1521 | 2020-06-03 13:29:23 -0700 | [diff] [blame] | 117 | typedef struct AMediaCodecOnAsyncNotifyCallback { |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 118 | AMediaCodecOnAsyncInputAvailable onAsyncInputAvailable; |
| 119 | AMediaCodecOnAsyncOutputAvailable onAsyncOutputAvailable; |
| 120 | AMediaCodecOnAsyncFormatChanged onAsyncFormatChanged; |
| 121 | AMediaCodecOnAsyncError onAsyncError; |
Dan Albert | dfb1521 | 2020-06-03 13:29:23 -0700 | [diff] [blame] | 122 | } AMediaCodecOnAsyncNotifyCallback; |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 123 | |
Ryan Prichard | a524975 | 2018-07-19 18:03:48 -0700 | [diff] [blame] | 124 | #if __ANDROID_API__ >= 21 |
| 125 | |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 126 | /** |
Marco Nelissen | 86aa02c | 2014-05-07 16:03:54 -0700 | [diff] [blame] | 127 | * Create codec by name. Use this if you know the exact codec you want to use. |
| 128 | * When configuring, you will need to specify whether to use the codec as an |
| 129 | * encoder or decoder. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 130 | * |
| 131 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 132 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 133 | AMediaCodec* AMediaCodec_createCodecByName(const char *name) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * Create codec by mime type. Most applications will use this, specifying a |
| 137 | * mime type obtained from media extractor. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 138 | * |
| 139 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 140 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 141 | AMediaCodec* AMediaCodec_createDecoderByType(const char *mime_type) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 142 | |
| 143 | /** |
| 144 | * Create encoder by name. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 145 | * |
| 146 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 147 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 148 | AMediaCodec* AMediaCodec_createEncoderByType(const char *mime_type) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 151 | * Delete the codec and free its resources. |
| 152 | * |
| 153 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 154 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 155 | media_status_t AMediaCodec_delete(AMediaCodec*) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
| 158 | * Configure the codec. For decoding you would typically get the format from an extractor. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 159 | * |
| 160 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 161 | */ |
Marco Nelissen | e419d7c | 2014-05-15 14:17:25 -0700 | [diff] [blame] | 162 | media_status_t AMediaCodec_configure( |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 163 | AMediaCodec*, |
| 164 | const AMediaFormat* format, |
| 165 | ANativeWindow* surface, |
| 166 | AMediaCrypto *crypto, |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 167 | uint32_t flags) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 168 | |
| 169 | /** |
| 170 | * Start the codec. A codec must be configured before it can be started, and must be started |
| 171 | * before buffers can be sent to it. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 172 | * |
| 173 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 174 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 175 | media_status_t AMediaCodec_start(AMediaCodec*) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 176 | |
| 177 | /** |
| 178 | * Stop the codec. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 179 | * |
| 180 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 181 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 182 | media_status_t AMediaCodec_stop(AMediaCodec*) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 183 | |
| 184 | /* |
| 185 | * Flush the codec's input and output. All indices previously returned from calls to |
| 186 | * AMediaCodec_dequeueInputBuffer and AMediaCodec_dequeueOutputBuffer become invalid. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 187 | * |
| 188 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 189 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 190 | media_status_t AMediaCodec_flush(AMediaCodec*) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * Get an input buffer. The specified buffer index must have been previously obtained from |
| 194 | * dequeueInputBuffer, and not yet queued. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 195 | * |
| 196 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 197 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 198 | uint8_t* AMediaCodec_getInputBuffer(AMediaCodec*, size_t idx, size_t *out_size) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * Get an output buffer. The specified buffer index must have been previously obtained from |
| 202 | * dequeueOutputBuffer, and not yet queued. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 203 | * |
| 204 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 205 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 206 | uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec*, size_t idx, size_t *out_size) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 207 | |
| 208 | /** |
| 209 | * Get the index of the next available input buffer. An app will typically use this with |
| 210 | * getInputBuffer() to get a pointer to the buffer, then copy the data to be encoded or decoded |
| 211 | * into the buffer before passing it to the codec. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 212 | * |
| 213 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 214 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 215 | ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec*, int64_t timeoutUs) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 216 | |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 217 | /* |
| 218 | * __USE_FILE_OFFSET64 changes the type of off_t in LP32, which changes the ABI |
| 219 | * of these declarations to not match the platform. In that case, define these |
| 220 | * APIs in terms of int32_t instead. Passing an off_t in this situation will |
| 221 | * result in silent truncation unless the user builds with -Wconversion, but the |
| 222 | * only alternative it to not expose them at all for this configuration, which |
| 223 | * makes the whole API unusable. |
| 224 | * |
| 225 | * https://github.com/android-ndk/ndk/issues/459 |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 226 | */ |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 227 | #if defined(__USE_FILE_OFFSET64) && !defined(__LP64__) |
| 228 | #define _off_t_compat int32_t |
| 229 | #else |
| 230 | #define _off_t_compat off_t |
| 231 | #endif /* defined(__USE_FILE_OFFSET64) && !defined(__LP64__) */ |
| 232 | |
| 233 | #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ |
| 234 | __STDC_VERSION__ >= 201112L |
Elliott Hughes | 0d62652 | 2017-09-11 13:07:20 -0700 | [diff] [blame] | 235 | #include <assert.h> |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 236 | static_assert(sizeof(_off_t_compat) == sizeof(long), |
| 237 | "_off_t_compat does not match the NDK ABI. See " |
| 238 | "https://github.com/android-ndk/ndk/issues/459."); |
| 239 | #endif |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 240 | |
| 241 | /** |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 242 | * Send the specified buffer to the codec for processing. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 243 | * |
| 244 | * Available since API level 21. |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 245 | */ |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 246 | media_status_t AMediaCodec_queueInputBuffer(AMediaCodec*, size_t idx, |
| 247 | _off_t_compat offset, size_t size, |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 248 | uint64_t time, uint32_t flags) __INTRODUCED_IN(21); |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 249 | |
| 250 | /** |
| 251 | * Send the specified buffer to the codec for processing. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 252 | * |
| 253 | * Available since API level 21. |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 254 | */ |
| 255 | media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*, size_t idx, |
| 256 | _off_t_compat offset, |
| 257 | AMediaCodecCryptoInfo*, |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 258 | uint64_t time, uint32_t flags) __INTRODUCED_IN(21); |
Dan Albert | 19abcd8 | 2017-07-17 13:37:56 -0700 | [diff] [blame] | 259 | |
| 260 | #undef _off_t_compat |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 261 | |
| 262 | /** |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 263 | * Get the index of the next available buffer of processed data. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 264 | * |
| 265 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 266 | */ |
Glenn Kasten | b187de1 | 2014-12-30 08:18:15 -0800 | [diff] [blame] | 267 | ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 268 | int64_t timeoutUs) __INTRODUCED_IN(21); |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 269 | |
| 270 | /** |
Marco Nelissen | 1b247cc | 2019-12-05 12:35:09 -0800 | [diff] [blame] | 271 | * Returns the format of the codec's output. |
| 272 | * The caller must free the returned format. |
| 273 | * |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 274 | * Available since API level 21. |
| 275 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 276 | AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec*) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 277 | |
| 278 | /** |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 279 | * If you are done with a buffer, use this call to return the buffer to |
| 280 | * the codec. If you previously specified a surface when configuring this |
| 281 | * video decoder you can optionally render the buffer. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 282 | * |
| 283 | * Available since API level 21. |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 284 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 285 | media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec*, size_t idx, bool render) __INTRODUCED_IN(21); |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 286 | |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 287 | /** |
Vineeta Srivastava | 8c35da5 | 2016-01-08 17:33:09 -0800 | [diff] [blame] | 288 | * Dynamically sets the output surface of a codec. |
| 289 | * |
| 290 | * This can only be used if the codec was configured with an output surface. The |
| 291 | * new output surface should have a compatible usage type to the original output surface. |
| 292 | * E.g. codecs may not support switching from a SurfaceTexture (GPU readable) output |
| 293 | * to ImageReader (software readable) output. |
| 294 | * |
| 295 | * For more details, see the Java documentation for MediaCodec.setOutputSurface. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 296 | * |
| 297 | * Available since API level 21. |
Vineeta Srivastava | 8c35da5 | 2016-01-08 17:33:09 -0800 | [diff] [blame] | 298 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 299 | media_status_t AMediaCodec_setOutputSurface(AMediaCodec*, ANativeWindow* surface) __INTRODUCED_IN(21); |
Vineeta Srivastava | 8c35da5 | 2016-01-08 17:33:09 -0800 | [diff] [blame] | 300 | |
| 301 | /** |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 302 | * If you are done with a buffer, use this call to update its surface timestamp |
| 303 | * and return it to the codec to render it on the output surface. If you |
| 304 | * have not specified an output surface when configuring this video codec, |
| 305 | * this call will simply return the buffer to the codec. |
| 306 | * |
| 307 | * For more details, see the Java documentation for MediaCodec.releaseOutputBuffer. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 308 | * |
| 309 | * Available since API level 21. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 310 | */ |
| 311 | media_status_t AMediaCodec_releaseOutputBufferAtTime( |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 312 | AMediaCodec *mData, size_t idx, int64_t timestampNs) __INTRODUCED_IN(21); |
Robert Shih | 8f61a2b | 2017-09-11 14:03:11 -0700 | [diff] [blame] | 313 | |
Ryan Prichard | a524975 | 2018-07-19 18:03:48 -0700 | [diff] [blame] | 314 | #if __ANDROID_API__ >= 26 |
| 315 | |
Praveen Chavan | 1943158 | 2017-01-16 11:56:18 -0800 | [diff] [blame] | 316 | /** |
| 317 | * Creates a Surface that can be used as the input to encoder, in place of input buffers |
| 318 | * |
| 319 | * This can only be called after the codec has been configured via |
| 320 | * AMediaCodec_configure(..); and before AMediaCodec_start() has been called. |
| 321 | * |
| 322 | * The application is responsible for releasing the surface by calling |
| 323 | * ANativeWindow_release() when done. |
| 324 | * |
| 325 | * For more details, see the Java documentation for MediaCodec.createInputSurface. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 326 | * |
| 327 | * Available since API level 26. |
Praveen Chavan | 1943158 | 2017-01-16 11:56:18 -0800 | [diff] [blame] | 328 | */ |
Praveen Chavan | 85a5363 | 2017-01-31 12:21:33 -0800 | [diff] [blame] | 329 | media_status_t AMediaCodec_createInputSurface( |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 330 | AMediaCodec *mData, ANativeWindow **surface) __INTRODUCED_IN(26); |
Praveen Chavan | 85a5363 | 2017-01-31 12:21:33 -0800 | [diff] [blame] | 331 | |
| 332 | /** |
| 333 | * Creates a persistent Surface that can be used as the input to encoder |
| 334 | * |
| 335 | * Persistent surface can be reused by MediaCodec instances and can be set |
| 336 | * on a new instance via AMediaCodec_setInputSurface(). |
| 337 | * A persistent surface can be connected to at most one instance of MediaCodec |
| 338 | * at any point in time. |
| 339 | * |
| 340 | * The application is responsible for releasing the surface by calling |
| 341 | * ANativeWindow_release() when done. |
| 342 | * |
| 343 | * For more details, see the Java documentation for MediaCodec.createPersistentInputSurface. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 344 | * |
| 345 | * Available since API level 26. |
Praveen Chavan | 85a5363 | 2017-01-31 12:21:33 -0800 | [diff] [blame] | 346 | */ |
| 347 | media_status_t AMediaCodec_createPersistentInputSurface( |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 348 | ANativeWindow **surface) __INTRODUCED_IN(26); |
Praveen Chavan | 85a5363 | 2017-01-31 12:21:33 -0800 | [diff] [blame] | 349 | |
| 350 | /** |
| 351 | * Set a persistent-surface that can be used as the input to encoder, in place of input buffers |
| 352 | * |
| 353 | * The surface provided *must* be a persistent surface created via |
| 354 | * AMediaCodec_createPersistentInputSurface() |
| 355 | * This can only be called after the codec has been configured by calling |
| 356 | * AMediaCodec_configure(..); and before AMediaCodec_start() has been called. |
| 357 | * |
| 358 | * For more details, see the Java documentation for MediaCodec.setInputSurface. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 359 | * |
| 360 | * Available since API level 26. |
Praveen Chavan | 85a5363 | 2017-01-31 12:21:33 -0800 | [diff] [blame] | 361 | */ |
| 362 | media_status_t AMediaCodec_setInputSurface( |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 363 | AMediaCodec *mData, ANativeWindow *surface) __INTRODUCED_IN(26); |
Praveen Chavan | 85a5363 | 2017-01-31 12:21:33 -0800 | [diff] [blame] | 364 | |
Praveen Chavan | f373e84 | 2017-02-01 11:50:15 -0800 | [diff] [blame] | 365 | /** |
| 366 | * Signal additional parameters to the codec instance. |
| 367 | * |
| 368 | * Parameters can be communicated only when the codec is running, i.e |
| 369 | * after AMediaCodec_start() has been called. |
| 370 | * |
| 371 | * NOTE: Some of these parameter changes may silently fail to apply. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 372 | * |
| 373 | * Available since API level 26. |
Praveen Chavan | f373e84 | 2017-02-01 11:50:15 -0800 | [diff] [blame] | 374 | */ |
| 375 | media_status_t AMediaCodec_setParameters( |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 376 | AMediaCodec *mData, const AMediaFormat* params) __INTRODUCED_IN(26); |
Praveen Chavan | 85a5363 | 2017-01-31 12:21:33 -0800 | [diff] [blame] | 377 | |
Robert Shih | af42d3f | 2017-03-20 16:45:37 -0700 | [diff] [blame] | 378 | /** |
| 379 | * Signals end-of-stream on input. Equivalent to submitting an empty buffer with |
| 380 | * AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM set. |
| 381 | * |
| 382 | * Returns AMEDIA_ERROR_INVALID_OPERATION when used with an encoder not in executing state |
| 383 | * or not receiving input from a Surface created by AMediaCodec_createInputSurface or |
| 384 | * AMediaCodec_createPersistentInputSurface. |
| 385 | * |
| 386 | * Returns the previous codec error if one exists. |
| 387 | * |
| 388 | * Returns AMEDIA_OK when completed succesfully. |
| 389 | * |
| 390 | * For more details, see the Java documentation for MediaCodec.signalEndOfInputStream. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 391 | * |
| 392 | * Available since API level 26. |
Robert Shih | af42d3f | 2017-03-20 16:45:37 -0700 | [diff] [blame] | 393 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 394 | media_status_t AMediaCodec_signalEndOfInputStream(AMediaCodec *mData) __INTRODUCED_IN(26); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 395 | |
Ryan Prichard | a524975 | 2018-07-19 18:03:48 -0700 | [diff] [blame] | 396 | #endif /* __ANDROID_API__ >= 26 */ |
| 397 | |
| 398 | #if __ANDROID_API__ >= 28 |
| 399 | |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 400 | /** |
dimitry | 33019d5 | 2018-12-04 15:58:40 +0100 | [diff] [blame] | 401 | * Get format of the buffer. The specified buffer index must have been previously obtained from |
| 402 | * dequeueOutputBuffer. |
Marco Nelissen | 1b247cc | 2019-12-05 12:35:09 -0800 | [diff] [blame] | 403 | * The caller must free the returned format. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 404 | * |
| 405 | * Available since API level 28. |
dimitry | 33019d5 | 2018-12-04 15:58:40 +0100 | [diff] [blame] | 406 | */ |
| 407 | AMediaFormat* AMediaCodec_getBufferFormat(AMediaCodec*, size_t index) __INTRODUCED_IN(28); |
| 408 | |
| 409 | /** |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 410 | * Get the component name. If the codec was created by createDecoderByType |
| 411 | * or createEncoderByType, what component is chosen is not known beforehand. |
| 412 | * Caller shall call AMediaCodec_releaseName to free the returned pointer. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 413 | * |
| 414 | * Available since API level 28. |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 415 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 416 | media_status_t AMediaCodec_getName(AMediaCodec*, char** out_name) __INTRODUCED_IN(28); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 417 | |
| 418 | /** |
| 419 | * Free the memory pointed by name which is returned by AMediaCodec_getName. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 420 | * |
| 421 | * Available since API level 28. |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 422 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 423 | void AMediaCodec_releaseName(AMediaCodec*, char* name) __INTRODUCED_IN(28); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 424 | |
| 425 | /** |
| 426 | * Set an asynchronous callback for actionable AMediaCodec events. |
| 427 | * When asynchronous callback is enabled, the client should not call |
| 428 | * AMediaCodec_getInputBuffers(), AMediaCodec_getOutputBuffers(), |
| 429 | * AMediaCodec_dequeueInputBuffer() or AMediaCodec_dequeueOutputBuffer(). |
| 430 | * |
| 431 | * Also, AMediaCodec_flush() behaves differently in asynchronous mode. |
| 432 | * After calling AMediaCodec_flush(), you must call AMediaCodec_start() to |
| 433 | * "resume" receiving input buffers, even if an input surface was created. |
| 434 | * |
| 435 | * Refer to the definition of AMediaCodecOnAsyncNotifyCallback on how each |
| 436 | * callback function is called and what are specified. |
| 437 | * The specified userdata is the pointer used when those callback functions are |
| 438 | * called. |
| 439 | * |
| 440 | * All callbacks are fired on one NDK internal thread. |
| 441 | * AMediaCodec_setAsyncNotifyCallback should not be called on the callback thread. |
| 442 | * No heavy duty task should be performed on callback thread. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 443 | * |
| 444 | * Available since API level 28. |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 445 | */ |
| 446 | media_status_t AMediaCodec_setAsyncNotifyCallback( |
| 447 | AMediaCodec*, |
| 448 | AMediaCodecOnAsyncNotifyCallback callback, |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 449 | void *userdata) __INTRODUCED_IN(28); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 450 | |
| 451 | /** |
| 452 | * Release the crypto if applicable. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 453 | * |
| 454 | * Available since API level 28. |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 455 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 456 | media_status_t AMediaCodec_releaseCrypto(AMediaCodec*) __INTRODUCED_IN(28); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 457 | |
| 458 | /** |
| 459 | * Call this after AMediaCodec_configure() returns successfully to get the input |
| 460 | * format accepted by the codec. Do this to determine what optional configuration |
| 461 | * parameters were supported by the codec. |
Marco Nelissen | 1b247cc | 2019-12-05 12:35:09 -0800 | [diff] [blame] | 462 | * The caller must free the returned format. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 463 | * |
| 464 | * Available since API level 28. |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 465 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 466 | AMediaFormat* AMediaCodec_getInputFormat(AMediaCodec*) __INTRODUCED_IN(28); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 467 | |
| 468 | /** |
| 469 | * Returns true if the codec cannot proceed further, but can be recovered by stopping, |
| 470 | * configuring, and starting again. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 471 | * |
| 472 | * Available since API level 28. |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 473 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 474 | bool AMediaCodecActionCode_isRecoverable(int32_t actionCode) __INTRODUCED_IN(28); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 475 | |
| 476 | /** |
| 477 | * Returns true if the codec error is a transient issue, perhaps due to |
| 478 | * resource constraints, and that the method (or encoding/decoding) may be |
| 479 | * retried at a later time. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 480 | * |
| 481 | * Available since API level 28. |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 482 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 483 | bool AMediaCodecActionCode_isTransient(int32_t actionCode) __INTRODUCED_IN(28); |
Wei Jia | 00cc992 | 2017-11-23 08:00:34 -0800 | [diff] [blame] | 484 | |
Ryan Prichard | a524975 | 2018-07-19 18:03:48 -0700 | [diff] [blame] | 485 | #endif /* __ANDROID_API__ >= 28 */ |
| 486 | |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 487 | typedef enum { |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 488 | AMEDIACODECRYPTOINFO_MODE_CLEAR = 0, |
Jeff Tinker | f45c7e7 | 2016-03-23 17:50:11 -0700 | [diff] [blame] | 489 | AMEDIACODECRYPTOINFO_MODE_AES_CTR = 1, |
| 490 | AMEDIACODECRYPTOINFO_MODE_AES_WV = 2, |
| 491 | AMEDIACODECRYPTOINFO_MODE_AES_CBC = 3 |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 492 | } cryptoinfo_mode_t; |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 493 | |
Jeff Tinker | 18cb1ec | 2015-12-18 11:55:22 -0800 | [diff] [blame] | 494 | typedef struct { |
| 495 | int32_t encryptBlocks; |
| 496 | int32_t skipBlocks; |
| 497 | } cryptoinfo_pattern_t; |
| 498 | |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 499 | /** |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 500 | * Create an AMediaCodecCryptoInfo from scratch. Use this if you need to use custom |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 501 | * crypto info, rather than one obtained from AMediaExtractor. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 502 | * |
| 503 | * AMediaCodecCryptoInfo describes the structure of an (at least |
| 504 | * partially) encrypted input sample. |
| 505 | * A buffer's data is considered to be partitioned into "subsamples", |
| 506 | * each subsample starts with a (potentially empty) run of plain, |
| 507 | * unencrypted bytes followed by a (also potentially empty) run of |
| 508 | * encrypted bytes. |
| 509 | * numBytesOfClearData can be null to indicate that all data is encrypted. |
| 510 | * This information encapsulates per-sample metadata as outlined in |
| 511 | * ISO/IEC FDIS 23001-7:2011 "Common encryption in ISO base media file format files". |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 512 | * |
| 513 | * Available since API level 21. |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 514 | */ |
| 515 | AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new( |
| 516 | int numsubsamples, |
| 517 | uint8_t key[16], |
| 518 | uint8_t iv[16], |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 519 | cryptoinfo_mode_t mode, |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 520 | size_t *clearbytes, |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 521 | size_t *encryptedbytes) __INTRODUCED_IN(21); |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 522 | |
| 523 | /** |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 524 | * Delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or |
| 525 | * obtained from AMediaExtractor. |
| 526 | * |
| 527 | * Available since API level 21. |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 528 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 529 | media_status_t AMediaCodecCryptoInfo_delete(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); |
Marco Nelissen | 050eb32 | 2014-05-09 15:10:23 -0700 | [diff] [blame] | 530 | |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 531 | /** |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 532 | * Set the crypto pattern on an AMediaCryptoInfo object. |
| 533 | * |
| 534 | * Available since API level 21. |
Jeff Tinker | 18cb1ec | 2015-12-18 11:55:22 -0800 | [diff] [blame] | 535 | */ |
| 536 | void AMediaCodecCryptoInfo_setPattern( |
| 537 | AMediaCodecCryptoInfo *info, |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 538 | cryptoinfo_pattern_t *pattern) __INTRODUCED_IN(21); |
Jeff Tinker | 18cb1ec | 2015-12-18 11:55:22 -0800 | [diff] [blame] | 539 | |
| 540 | /** |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 541 | * The number of subsamples that make up the buffer's contents. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 542 | * |
| 543 | * Available since API level 21. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 544 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 545 | size_t AMediaCodecCryptoInfo_getNumSubSamples(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 546 | |
| 547 | /** |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 548 | * A 16-byte opaque key. |
| 549 | * |
| 550 | * Available since API level 21. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 551 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 552 | media_status_t AMediaCodecCryptoInfo_getKey(AMediaCodecCryptoInfo*, uint8_t *dst) __INTRODUCED_IN(21); |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 553 | |
| 554 | /** |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 555 | * A 16-byte initialization vector. |
| 556 | * |
| 557 | * Available since API level 21. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 558 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 559 | media_status_t AMediaCodecCryptoInfo_getIV(AMediaCodecCryptoInfo*, uint8_t *dst) __INTRODUCED_IN(21); |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 560 | |
| 561 | /** |
| 562 | * The type of encryption that has been applied, |
| 563 | * one of AMEDIACODECRYPTOINFO_MODE_CLEAR or AMEDIACODECRYPTOINFO_MODE_AES_CTR. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 564 | * |
| 565 | * Available since API level 21. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 566 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 567 | cryptoinfo_mode_t AMediaCodecCryptoInfo_getMode(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 568 | |
| 569 | /** |
| 570 | * The number of leading unencrypted bytes in each subsample. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 571 | * |
| 572 | * Available since API level 21. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 573 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 574 | media_status_t AMediaCodecCryptoInfo_getClearBytes(AMediaCodecCryptoInfo*, size_t *dst) __INTRODUCED_IN(21); |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 575 | |
| 576 | /** |
| 577 | * The number of trailing encrypted bytes in each subsample. |
Elliott Hughes | 64a3b06 | 2019-10-29 10:09:30 -0700 | [diff] [blame] | 578 | * |
| 579 | * Available since API level 21. |
Marco Nelissen | 79e2b62 | 2014-05-16 08:07:28 -0700 | [diff] [blame] | 580 | */ |
Elliott Hughes | 4280e86 | 2018-06-18 13:17:24 -0700 | [diff] [blame] | 581 | media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo*, size_t *dst) __INTRODUCED_IN(21); |
Dan Albert | 2975a24 | 2016-09-23 16:17:45 -0700 | [diff] [blame] | 582 | |
Ryan Prichard | a524975 | 2018-07-19 18:03:48 -0700 | [diff] [blame] | 583 | #endif /* __ANDROID_API__ >= 21 */ |
| 584 | |
Dan Albert | 5e496db | 2017-10-05 15:03:07 -0700 | [diff] [blame] | 585 | __END_DECLS |
Marco Nelissen | 0c3be87 | 2014-05-01 10:14:44 -0700 | [diff] [blame] | 586 | |
| 587 | #endif //_NDK_MEDIA_CODEC_H |
Dan Albert | ec6cd63 | 2018-04-13 15:57:25 -0700 | [diff] [blame] | 588 | |
| 589 | /** @} */ |