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 NdkMediaCodec.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_CODEC_H 37 #define _NDK_MEDIA_CODEC_H 38 39 #include <stdint.h> 40 #include <sys/cdefs.h> 41 42 #include <android/api-level.h> 43 44 #include "NdkMediaCrypto.h" 45 #include "NdkMediaError.h" 46 #include "NdkMediaFormat.h" 47 48 __BEGIN_DECLS 49 50 struct ANativeWindow; 51 typedef struct ANativeWindow ANativeWindow; 52 53 54 struct AMediaCodec; 55 typedef struct AMediaCodec AMediaCodec; 56 57 struct AMediaCodecBufferInfo { 58 int32_t offset; 59 int32_t size; 60 int64_t presentationTimeUs; 61 uint32_t flags; 62 }; 63 typedef struct AMediaCodecBufferInfo AMediaCodecBufferInfo; 64 typedef struct AMediaCodecCryptoInfo AMediaCodecCryptoInfo; 65 66 67 /** 68 * Definitions of per-buffer flags for operation with NdkMediaCodec. 69 * 70 * The semantics of these enums match those of the same name 71 * in {@link android.media.MediaCodec}. 72 */ 73 enum { 74 /** 75 * This indicates that the (encoded) buffer marked as such contains 76 * the data for a key frame. 77 * 78 * Semantics are the same as {@link android.media.MediaCodec#BUFFER_FLAG_KEY_FRAME} 79 */ 80 AMEDIACODEC_BUFFER_FLAG_KEY_FRAME = 1, // introduced in API 34 81 AMEDIACODEC_BUFFER_FLAG_CODEC_CONFIG = 2, 82 AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM = 4, 83 AMEDIACODEC_BUFFER_FLAG_PARTIAL_FRAME = 8, 84 /** 85 * This indicates that the buffer contains non-media data for the 86 * muxer to process. 87 * 88 * Semantics are the same as {@link android.media.MediaCodec#BUFFER_FLAG_MUXER_DATA} 89 */ 90 AMEDIACODEC_BUFFER_FLAG_MUXER_DATA = 16, // introduced in API 34 91 /** 92 * This indicates that the buffer is decoded and updates the internal state of the decoder, 93 * but does not produce any output buffer. 94 * 95 * Semantics are the same as {@link android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY} 96 */ 97 AMEDIACODEC_BUFFER_FLAG_DECODE_ONLY = 32, // introduced in API 34 98 }; 99 100 enum { 101 AMEDIACODEC_CONFIGURE_FLAG_ENCODE = 1, 102 AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED = -3, 103 AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED = -2, 104 AMEDIACODEC_INFO_TRY_AGAIN_LATER = -1, 105 }; 106 107 /** 108 * Called when an input buffer becomes available. 109 * The specified index is the index of the available input buffer. 110 */ 111 typedef void (*AMediaCodecOnAsyncInputAvailable)( 112 AMediaCodec *codec, 113 void *userdata, 114 int32_t index); 115 /** 116 * Called when an output buffer becomes available. 117 * The specified index is the index of the available output buffer. 118 * The specified bufferInfo contains information regarding the available output buffer. 119 */ 120 typedef void (*AMediaCodecOnAsyncOutputAvailable)( 121 AMediaCodec *codec, 122 void *userdata, 123 int32_t index, 124 AMediaCodecBufferInfo *bufferInfo); 125 /** 126 * Called when the output format has changed. 127 * The specified format contains the new output format. 128 */ 129 typedef void (*AMediaCodecOnAsyncFormatChanged)( 130 AMediaCodec *codec, 131 void *userdata, 132 AMediaFormat *format); 133 /** 134 * Called when the MediaCodec encountered an error. 135 * The specified actionCode indicates the possible actions that client can take, 136 * and it can be checked by calling AMediaCodecActionCode_isRecoverable or 137 * AMediaCodecActionCode_isTransient. If both AMediaCodecActionCode_isRecoverable() 138 * and AMediaCodecActionCode_isTransient() return false, then the codec error is fatal 139 * and the codec must be deleted. 140 * The specified detail may contain more detailed messages about this error. 141 */ 142 typedef void (*AMediaCodecOnAsyncError)( 143 AMediaCodec *codec, 144 void *userdata, 145 media_status_t error, 146 int32_t actionCode, 147 const char *detail); 148 149 typedef struct AMediaCodecOnAsyncNotifyCallback { 150 AMediaCodecOnAsyncInputAvailable onAsyncInputAvailable; 151 AMediaCodecOnAsyncOutputAvailable onAsyncOutputAvailable; 152 AMediaCodecOnAsyncFormatChanged onAsyncFormatChanged; 153 AMediaCodecOnAsyncError onAsyncError; 154 } AMediaCodecOnAsyncNotifyCallback; 155 156 /** 157 * Called when an output frame has rendered on the output surface. 158 * 159 * \param codec The codec object that generated this notification. 160 * \param userdata The user data set at AMediaCodec_setOnFrameRenderedCallback. 161 * \param mediaTimeUs The presentation time (media time) of the frame rendered. 162 * This is usually the same as specified in 163 * AMediaCodec_queueInputBuffer, but some codecs may alter 164 * the media time by applying some time-based transformation, 165 * such as frame rate conversion. In that case, presentation 166 * time corresponds to the actual output frame rendered. 167 * \param systemNano The system time when the frame was rendered. 168 */ 169 typedef void (*AMediaCodecOnFrameRendered)( 170 AMediaCodec *codec, 171 void *userdata, 172 int64_t mediaTimeUs, 173 int64_t systemNano); 174 175 /** 176 * Create codec by name. Use this if you know the exact codec you want to use. 177 * When configuring, you will need to specify whether to use the codec as an 178 * encoder or decoder. 179 * 180 * Available since API level 21. 181 */ 182 AMediaCodec* AMediaCodec_createCodecByName(const char *name) __INTRODUCED_IN(21); 183 184 /** 185 * Create codec by mime type. Most applications will use this, specifying a 186 * mime type obtained from media extractor. 187 * 188 * Available since API level 21. 189 */ 190 AMediaCodec* AMediaCodec_createDecoderByType(const char *mime_type) __INTRODUCED_IN(21); 191 192 /** 193 * Create encoder by name. 194 * 195 * Available since API level 21. 196 */ 197 AMediaCodec* AMediaCodec_createEncoderByType(const char *mime_type) __INTRODUCED_IN(21); 198 199 /** 200 * Delete the codec and free its resources. 201 * 202 * Available since API level 21. 203 */ 204 media_status_t AMediaCodec_delete(AMediaCodec*) __INTRODUCED_IN(21); 205 206 /** 207 * Configure the codec. For decoding you would typically get the format from an extractor. 208 * 209 * Available since API level 21. 210 */ 211 media_status_t AMediaCodec_configure( 212 AMediaCodec*, 213 const AMediaFormat* format, 214 ANativeWindow* surface, 215 AMediaCrypto *crypto, 216 uint32_t flags) __INTRODUCED_IN(21); 217 218 /** 219 * Start the codec. A codec must be configured before it can be started, and must be started 220 * before buffers can be sent to it. 221 * 222 * Available since API level 21. 223 */ 224 media_status_t AMediaCodec_start(AMediaCodec*) __INTRODUCED_IN(21); 225 226 /** 227 * Stop the codec. 228 * 229 * Available since API level 21. 230 */ 231 media_status_t AMediaCodec_stop(AMediaCodec*) __INTRODUCED_IN(21); 232 233 /* 234 * Flush the codec's input and output. All indices previously returned from calls to 235 * AMediaCodec_dequeueInputBuffer and AMediaCodec_dequeueOutputBuffer become invalid. 236 * 237 * Available since API level 21. 238 */ 239 media_status_t AMediaCodec_flush(AMediaCodec*) __INTRODUCED_IN(21); 240 241 /** 242 * Get an input buffer. The specified buffer index must have been previously obtained from 243 * dequeueInputBuffer, and not yet queued. 244 * 245 * Available since API level 21. 246 */ 247 uint8_t* AMediaCodec_getInputBuffer(AMediaCodec*, size_t idx, size_t *out_size) __INTRODUCED_IN(21); 248 249 /** 250 * Get an output buffer. The specified buffer index must have been previously obtained from 251 * dequeueOutputBuffer, and not yet queued. 252 * 253 * Available since API level 21. 254 */ 255 uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec*, size_t idx, size_t *out_size) __INTRODUCED_IN(21); 256 257 /** 258 * Get the index of the next available input buffer. An app will typically use this with 259 * getInputBuffer() to get a pointer to the buffer, then copy the data to be encoded or decoded 260 * into the buffer before passing it to the codec. 261 * 262 * Available since API level 21. 263 */ 264 ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec*, int64_t timeoutUs) __INTRODUCED_IN(21); 265 266 /* 267 * __USE_FILE_OFFSET64 changes the type of off_t in LP32, which changes the ABI 268 * of these declarations to not match the platform. In that case, define these 269 * APIs in terms of int32_t instead. Passing an off_t in this situation will 270 * result in silent truncation unless the user builds with -Wconversion, but the 271 * only alternative it to not expose them at all for this configuration, which 272 * makes the whole API unusable. 273 * 274 * https://github.com/android-ndk/ndk/issues/459 275 */ 276 #if defined(__USE_FILE_OFFSET64) && !defined(__LP64__) 277 #define _off_t_compat int32_t 278 #else 279 #define _off_t_compat off_t 280 #endif /* defined(__USE_FILE_OFFSET64) && !defined(__LP64__) */ 281 282 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ 283 __STDC_VERSION__ >= 201112L 284 #include <assert.h> 285 static_assert(sizeof(_off_t_compat) == sizeof(long), 286 "_off_t_compat does not match the NDK ABI. See " 287 "https://github.com/android-ndk/ndk/issues/459."); 288 #endif 289 290 /** 291 * Send the specified buffer to the codec for processing. 292 * 293 * Available since API level 21. 294 */ 295 media_status_t AMediaCodec_queueInputBuffer(AMediaCodec*, size_t idx, 296 _off_t_compat offset, size_t size, 297 uint64_t time, uint32_t flags) __INTRODUCED_IN(21); 298 299 /** 300 * Send the specified buffer to the codec for processing. 301 * 302 * Available since API level 21. 303 */ 304 media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*, size_t idx, 305 _off_t_compat offset, 306 AMediaCodecCryptoInfo*, 307 uint64_t time, uint32_t flags) __INTRODUCED_IN(21); 308 309 #undef _off_t_compat 310 311 /** 312 * Get the index of the next available buffer of processed data. 313 * 314 * Available since API level 21. 315 */ 316 ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, 317 int64_t timeoutUs) __INTRODUCED_IN(21); 318 319 /** 320 * Returns the format of the codec's output. 321 * The caller must free the returned format. 322 * 323 * Available since API level 21. 324 */ 325 AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec*) __INTRODUCED_IN(21); 326 327 /** 328 * If you are done with a buffer, use this call to return the buffer to 329 * the codec. If you previously specified a surface when configuring this 330 * video decoder you can optionally render the buffer. 331 * 332 * Available since API level 21. 333 */ 334 media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec*, size_t idx, bool render) __INTRODUCED_IN(21); 335 336 /** 337 * Dynamically sets the output surface of a codec. 338 * 339 * This can only be used if the codec was configured with an output surface. The 340 * new output surface should have a compatible usage type to the original output surface. 341 * E.g. codecs may not support switching from a SurfaceTexture (GPU readable) output 342 * to ImageReader (software readable) output. 343 * 344 * For more details, see the Java documentation for MediaCodec.setOutputSurface. 345 * 346 * Available since API level 21. 347 */ 348 media_status_t AMediaCodec_setOutputSurface(AMediaCodec*, ANativeWindow* surface) __INTRODUCED_IN(21); 349 350 /** 351 * If you are done with a buffer, use this call to update its surface timestamp 352 * and return it to the codec to render it on the output surface. If you 353 * have not specified an output surface when configuring this video codec, 354 * this call will simply return the buffer to the codec. 355 * 356 * For more details, see the Java documentation for MediaCodec.releaseOutputBuffer. 357 * 358 * Available since API level 21. 359 */ 360 media_status_t AMediaCodec_releaseOutputBufferAtTime( 361 AMediaCodec *mData, size_t idx, int64_t timestampNs) __INTRODUCED_IN(21); 362 363 /** 364 * Creates a Surface that can be used as the input to encoder, in place of input buffers 365 * 366 * This can only be called after the codec has been configured via 367 * AMediaCodec_configure(..); and before AMediaCodec_start() has been called. 368 * 369 * The application is responsible for releasing the surface by calling 370 * ANativeWindow_release() when done. 371 * 372 * For more details, see the Java documentation for MediaCodec.createInputSurface. 373 * 374 * Available since API level 26. 375 */ 376 media_status_t AMediaCodec_createInputSurface( 377 AMediaCodec *mData, ANativeWindow **surface) __INTRODUCED_IN(26); 378 379 /** 380 * Creates a persistent Surface that can be used as the input to encoder 381 * 382 * Persistent surface can be reused by MediaCodec instances and can be set 383 * on a new instance via AMediaCodec_setInputSurface(). 384 * A persistent surface can be connected to at most one instance of MediaCodec 385 * at any point in time. 386 * 387 * The application is responsible for releasing the surface by calling 388 * ANativeWindow_release() when done. 389 * 390 * For more details, see the Java documentation for MediaCodec.createPersistentInputSurface. 391 * 392 * Available since API level 26. 393 */ 394 media_status_t AMediaCodec_createPersistentInputSurface( 395 ANativeWindow **surface) __INTRODUCED_IN(26); 396 397 /** 398 * Set a persistent-surface that can be used as the input to encoder, in place of input buffers 399 * 400 * The surface provided *must* be a persistent surface created via 401 * AMediaCodec_createPersistentInputSurface() 402 * This can only be called after the codec has been configured by calling 403 * AMediaCodec_configure(..); and before AMediaCodec_start() has been called. 404 * 405 * For more details, see the Java documentation for MediaCodec.setInputSurface. 406 * 407 * Available since API level 26. 408 */ 409 media_status_t AMediaCodec_setInputSurface( 410 AMediaCodec *mData, ANativeWindow *surface) __INTRODUCED_IN(26); 411 412 /** 413 * Signal additional parameters to the codec instance. 414 * 415 * Parameters can be communicated only when the codec is running, i.e 416 * after AMediaCodec_start() has been called. 417 * 418 * NOTE: Some of these parameter changes may silently fail to apply. 419 * 420 * Available since API level 26. 421 */ 422 media_status_t AMediaCodec_setParameters( 423 AMediaCodec *mData, const AMediaFormat* params) __INTRODUCED_IN(26); 424 425 /** 426 * Signals end-of-stream on input. Equivalent to submitting an empty buffer with 427 * AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM set. 428 * 429 * Returns AMEDIA_ERROR_INVALID_OPERATION when used with an encoder not in executing state 430 * or not receiving input from a Surface created by AMediaCodec_createInputSurface or 431 * AMediaCodec_createPersistentInputSurface. 432 * 433 * Returns the previous codec error if one exists. 434 * 435 * Returns AMEDIA_OK when completed succesfully. 436 * 437 * For more details, see the Java documentation for MediaCodec.signalEndOfInputStream. 438 * 439 * Available since API level 26. 440 */ 441 media_status_t AMediaCodec_signalEndOfInputStream(AMediaCodec *mData) __INTRODUCED_IN(26); 442 443 /** 444 * Get format of the buffer. The specified buffer index must have been previously obtained from 445 * dequeueOutputBuffer. 446 * The caller must free the returned format. 447 * 448 * Available since API level 28. 449 */ 450 AMediaFormat* AMediaCodec_getBufferFormat(AMediaCodec*, size_t index) __INTRODUCED_IN(28); 451 452 /** 453 * Get the component name. If the codec was created by createDecoderByType 454 * or createEncoderByType, what component is chosen is not known beforehand. 455 * Caller shall call AMediaCodec_releaseName to free the returned pointer. 456 * 457 * Available since API level 28. 458 */ 459 media_status_t AMediaCodec_getName(AMediaCodec*, char** out_name) __INTRODUCED_IN(28); 460 461 /** 462 * Free the memory pointed by name which is returned by AMediaCodec_getName. 463 * 464 * Available since API level 28. 465 */ 466 void AMediaCodec_releaseName(AMediaCodec*, char* name) __INTRODUCED_IN(28); 467 468 /** 469 * Set an asynchronous callback for actionable AMediaCodec events. 470 * When asynchronous callback is enabled, it is an error for the client to call 471 * AMediaCodec_getInputBuffers(), AMediaCodec_getOutputBuffers(), 472 * AMediaCodec_dequeueInputBuffer() or AMediaCodec_dequeueOutputBuffer(). 473 * 474 * AMediaCodec_flush() behaves differently in asynchronous mode. 475 * After calling AMediaCodec_flush(), the client must call AMediaCodec_start() to 476 * "resume" receiving input buffers. Even if the client does not receive 477 * AMediaCodecOnAsyncInputAvailable callbacks from video encoders configured 478 * with an input surface, the client still needs to call AMediaCodec_start() 479 * to resume the input surface to send buffers to the encoders. 480 * 481 * When called with null callback, this method unregisters any previously set callback. 482 * 483 * Refer to the definition of AMediaCodecOnAsyncNotifyCallback on how each 484 * callback function is called and what are specified. 485 * The specified userdata is opaque data which will be passed along 486 * when the callback functions are called. MediaCodec does not look at or alter the 487 * value of userdata. Often it is a pointer to a client-owned object, 488 * and client manages the lifecycle of the object in that case. 489 * 490 * Once the callback is unregistered or the codec is reset / released, the 491 * previously registered callback will not be called. 492 * 493 * All callbacks are fired on one NDK internal thread. 494 * AMediaCodec_setAsyncNotifyCallback should not be called on the callback thread. 495 * No heavy duty task should be performed on callback thread. 496 * 497 * Available since API level 28. 498 */ 499 media_status_t AMediaCodec_setAsyncNotifyCallback( 500 AMediaCodec*, 501 AMediaCodecOnAsyncNotifyCallback callback, 502 void *userdata) __INTRODUCED_IN(28); 503 504 /** 505 * Registers a callback to be invoked when an output frame is rendered on the output surface. 506 * 507 * This method can be called in any codec state, but will only have an effect in the 508 * Executing state for codecs that render buffers to the output surface. 509 * 510 * This callback is for informational purposes only: to get precise 511 * render timing samples, and can be significantly delayed and batched. Some frames may have 512 * been rendered even if there was no callback generated. 513 * 514 * When called with null callback, this method unregisters any previously set callback. 515 * 516 * Refer to the definition of AMediaCodecOnFrameRendered on how each 517 * callback function is called and what are specified. 518 * The specified userdata is opaque data which will be passed along 519 * when the callback functions are called. MediaCodec does not look at or alter the 520 * value of userdata. Often it is a pointer to a client-owned object, 521 * and client manages the lifecycle of the object in that case. 522 * 523 * Once the callback is unregistered or the codec is reset / released, the 524 * previously registered callback will not be called. 525 * 526 * All callbacks are fired on one NDK internal thread. 527 * AMediaCodec_setOnFrameRenderedCallback should not be called on the callback thread. 528 * No heavy duty task should be performed on callback thread. 529 * 530 * Available since Android T. 531 */ 532 media_status_t AMediaCodec_setOnFrameRenderedCallback( 533 AMediaCodec*, 534 AMediaCodecOnFrameRendered callback, 535 void *userdata) __INTRODUCED_IN(__ANDROID_API_T__); 536 537 /** 538 * Release the crypto if applicable. 539 * 540 * Available since API level 28. 541 */ 542 media_status_t AMediaCodec_releaseCrypto(AMediaCodec*) __INTRODUCED_IN(28); 543 544 /** 545 * Call this after AMediaCodec_configure() returns successfully to get the input 546 * format accepted by the codec. Do this to determine what optional configuration 547 * parameters were supported by the codec. 548 * The caller must free the returned format. 549 * 550 * Available since API level 28. 551 */ 552 AMediaFormat* AMediaCodec_getInputFormat(AMediaCodec*) __INTRODUCED_IN(28); 553 554 /** 555 * Returns true if the codec cannot proceed further, but can be recovered by stopping, 556 * configuring, and starting again. 557 * 558 * Available since API level 28. 559 */ 560 bool AMediaCodecActionCode_isRecoverable(int32_t actionCode) __INTRODUCED_IN(28); 561 562 /** 563 * Returns true if the codec error is a transient issue, perhaps due to 564 * resource constraints, and that the method (or encoding/decoding) may be 565 * retried at a later time. 566 * 567 * Available since API level 28. 568 */ 569 bool AMediaCodecActionCode_isTransient(int32_t actionCode) __INTRODUCED_IN(28); 570 571 typedef enum { 572 AMEDIACODECRYPTOINFO_MODE_CLEAR = 0, 573 AMEDIACODECRYPTOINFO_MODE_AES_CTR = 1, 574 AMEDIACODECRYPTOINFO_MODE_AES_WV = 2, 575 AMEDIACODECRYPTOINFO_MODE_AES_CBC = 3 576 } cryptoinfo_mode_t; 577 578 typedef struct { 579 int32_t encryptBlocks; 580 int32_t skipBlocks; 581 } cryptoinfo_pattern_t; 582 583 /** 584 * Create an AMediaCodecCryptoInfo from scratch. Use this if you need to use custom 585 * crypto info, rather than one obtained from AMediaExtractor. 586 * 587 * AMediaCodecCryptoInfo describes the structure of an (at least 588 * partially) encrypted input sample. 589 * A buffer's data is considered to be partitioned into "subsamples", 590 * each subsample starts with a (potentially empty) run of plain, 591 * unencrypted bytes followed by a (also potentially empty) run of 592 * encrypted bytes. 593 * numBytesOfClearData can be null to indicate that all data is encrypted. 594 * This information encapsulates per-sample metadata as outlined in 595 * ISO/IEC FDIS 23001-7:2011 "Common encryption in ISO base media file format files". 596 * 597 * Available since API level 21. 598 */ 599 AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new( 600 int numsubsamples, 601 uint8_t key[16], 602 uint8_t iv[16], 603 cryptoinfo_mode_t mode, 604 size_t *clearbytes, 605 size_t *encryptedbytes) __INTRODUCED_IN(21); 606 607 /** 608 * Delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or 609 * obtained from AMediaExtractor. 610 * 611 * Available since API level 21. 612 */ 613 media_status_t AMediaCodecCryptoInfo_delete(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); 614 615 /** 616 * Set the crypto pattern on an AMediaCryptoInfo object. 617 * 618 * Available since API level 21. 619 */ 620 void AMediaCodecCryptoInfo_setPattern( 621 AMediaCodecCryptoInfo *info, 622 cryptoinfo_pattern_t *pattern) __INTRODUCED_IN(21); 623 624 /** 625 * The number of subsamples that make up the buffer's contents. 626 * 627 * Available since API level 21. 628 */ 629 size_t AMediaCodecCryptoInfo_getNumSubSamples(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); 630 631 /** 632 * A 16-byte opaque key. 633 * 634 * Available since API level 21. 635 */ 636 media_status_t AMediaCodecCryptoInfo_getKey(AMediaCodecCryptoInfo*, uint8_t *dst) __INTRODUCED_IN(21); 637 638 /** 639 * A 16-byte initialization vector. 640 * 641 * Available since API level 21. 642 */ 643 media_status_t AMediaCodecCryptoInfo_getIV(AMediaCodecCryptoInfo*, uint8_t *dst) __INTRODUCED_IN(21); 644 645 /** 646 * The type of encryption that has been applied, 647 * one of AMEDIACODECRYPTOINFO_MODE_CLEAR or AMEDIACODECRYPTOINFO_MODE_AES_CTR. 648 * 649 * Available since API level 21. 650 */ 651 cryptoinfo_mode_t AMediaCodecCryptoInfo_getMode(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); 652 653 /** 654 * The number of leading unencrypted bytes in each subsample. 655 * 656 * Available since API level 21. 657 */ 658 media_status_t AMediaCodecCryptoInfo_getClearBytes(AMediaCodecCryptoInfo*, size_t *dst) __INTRODUCED_IN(21); 659 660 /** 661 * The number of trailing encrypted bytes in each subsample. 662 * 663 * Available since API level 21. 664 */ 665 media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo*, size_t *dst) __INTRODUCED_IN(21); 666 667 extern const char* AMEDIACODEC_KEY_HDR10_PLUS_INFO __INTRODUCED_IN(31); 668 extern const char* AMEDIACODEC_KEY_LOW_LATENCY __INTRODUCED_IN(31); 669 extern const char* AMEDIACODEC_KEY_OFFSET_TIME __INTRODUCED_IN(31); 670 extern const char* AMEDIACODEC_KEY_REQUEST_SYNC_FRAME __INTRODUCED_IN(31); 671 extern const char* AMEDIACODEC_KEY_SUSPEND __INTRODUCED_IN(31); 672 extern const char* AMEDIACODEC_KEY_SUSPEND_TIME __INTRODUCED_IN(31); 673 extern const char* AMEDIACODEC_KEY_VIDEO_BITRATE __INTRODUCED_IN(31); 674 675 __END_DECLS 676 677 #endif //_NDK_MEDIA_CODEC_H 678 679 /** @} */ 680