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 * <p> 255 * At or before API level 35, the out_size returned was invalid, and instead the 256 * size returned in the AMediaCodecBufferInfo struct from 257 * AMediaCodec_dequeueOutputBuffer() should be used. After API 258 * level 35, this API returns the correct output buffer size as well. 259 */ 260 uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec*, size_t idx, size_t *out_size) __INTRODUCED_IN(21); 261 262 /** 263 * Get the index of the next available input buffer. An app will typically use this with 264 * getInputBuffer() to get a pointer to the buffer, then copy the data to be encoded or decoded 265 * into the buffer before passing it to the codec. 266 * 267 * Available since API level 21. 268 */ 269 ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec*, int64_t timeoutUs) __INTRODUCED_IN(21); 270 271 /* 272 * __USE_FILE_OFFSET64 changes the type of off_t in LP32, which changes the ABI 273 * of these declarations to not match the platform. In that case, define these 274 * APIs in terms of int32_t instead. Passing an off_t in this situation will 275 * result in silent truncation unless the user builds with -Wconversion, but the 276 * only alternative it to not expose them at all for this configuration, which 277 * makes the whole API unusable. 278 * 279 * https://github.com/android-ndk/ndk/issues/459 280 */ 281 #if defined(__USE_FILE_OFFSET64) && !defined(__LP64__) 282 #define _off_t_compat int32_t 283 #else 284 #define _off_t_compat off_t 285 #endif /* defined(__USE_FILE_OFFSET64) && !defined(__LP64__) */ 286 287 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ 288 __STDC_VERSION__ >= 201112L 289 #include <assert.h> 290 static_assert(sizeof(_off_t_compat) == sizeof(long), 291 "_off_t_compat does not match the NDK ABI. See " 292 "https://github.com/android-ndk/ndk/issues/459."); 293 #endif 294 295 /** 296 * Send the specified buffer to the codec for processing. 297 * 298 * Available since API level 21. 299 */ 300 media_status_t AMediaCodec_queueInputBuffer(AMediaCodec*, size_t idx, 301 _off_t_compat offset, size_t size, 302 uint64_t time, uint32_t flags) __INTRODUCED_IN(21); 303 304 /** 305 * Send the specified buffer to the codec for processing. 306 * 307 * Available since API level 21. 308 */ 309 media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*, size_t idx, 310 _off_t_compat offset, 311 AMediaCodecCryptoInfo*, 312 uint64_t time, uint32_t flags) __INTRODUCED_IN(21); 313 314 #undef _off_t_compat 315 316 /** 317 * Get the index of the next available buffer of processed data along with the 318 * metadata associated with it. 319 * 320 * Available since API level 21. 321 * <p> 322 * At or before API level 35, the offset in the AMediaCodecBufferInfo struct 323 * was invalid and should be ignored; however, at the same time 324 * the buffer size could only be obtained from this struct. After API 325 * level 35, the offset returned in the struct is always set to 0, and the 326 * buffer size can also be obtained from the AMediaCodec_getOutputBuffer() call. 327 */ 328 ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, 329 int64_t timeoutUs) __INTRODUCED_IN(21); 330 331 /** 332 * Returns the format of the codec's output. 333 * The caller must free the returned format. 334 * 335 * Available since API level 21. 336 */ 337 AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec*) __INTRODUCED_IN(21); 338 339 /** 340 * If you are done with a buffer, use this call to return the buffer to 341 * the codec. If you previously specified a surface when configuring this 342 * video decoder you can optionally render the buffer. 343 * 344 * Available since API level 21. 345 */ 346 media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec*, size_t idx, bool render) __INTRODUCED_IN(21); 347 348 /** 349 * Dynamically sets the output surface of a codec. 350 * 351 * This can only be used if the codec was configured with an output surface. The 352 * new output surface should have a compatible usage type to the original output surface. 353 * E.g. codecs may not support switching from a SurfaceTexture (GPU readable) output 354 * to ImageReader (software readable) output. 355 * 356 * For more details, see the Java documentation for MediaCodec.setOutputSurface. 357 * 358 * Available since API level 21. 359 */ 360 media_status_t AMediaCodec_setOutputSurface(AMediaCodec*, ANativeWindow* surface) __INTRODUCED_IN(21); 361 362 /** 363 * If you are done with a buffer, use this call to update its surface timestamp 364 * and return it to the codec to render it on the output surface. If you 365 * have not specified an output surface when configuring this video codec, 366 * this call will simply return the buffer to the codec. 367 * 368 * For more details, see the Java documentation for MediaCodec.releaseOutputBuffer. 369 * 370 * Available since API level 21. 371 */ 372 media_status_t AMediaCodec_releaseOutputBufferAtTime( 373 AMediaCodec *mData, size_t idx, int64_t timestampNs) __INTRODUCED_IN(21); 374 375 /** 376 * Creates a Surface that can be used as the input to encoder, in place of input buffers 377 * 378 * This can only be called after the codec has been configured via 379 * AMediaCodec_configure(..); and before AMediaCodec_start() has been called. 380 * 381 * The application is responsible for releasing the surface by calling 382 * ANativeWindow_release() when done. 383 * 384 * For more details, see the Java documentation for MediaCodec.createInputSurface. 385 * 386 * Available since API level 26. 387 */ 388 media_status_t AMediaCodec_createInputSurface( 389 AMediaCodec *mData, ANativeWindow **surface) __INTRODUCED_IN(26); 390 391 /** 392 * Creates a persistent Surface that can be used as the input to encoder 393 * 394 * Persistent surface can be reused by MediaCodec instances and can be set 395 * on a new instance via AMediaCodec_setInputSurface(). 396 * A persistent surface can be connected to at most one instance of MediaCodec 397 * at any point in time. 398 * 399 * The application is responsible for releasing the surface by calling 400 * ANativeWindow_release() when done. 401 * 402 * For more details, see the Java documentation for MediaCodec.createPersistentInputSurface. 403 * 404 * Available since API level 26. 405 */ 406 media_status_t AMediaCodec_createPersistentInputSurface( 407 ANativeWindow **surface) __INTRODUCED_IN(26); 408 409 /** 410 * Set a persistent-surface that can be used as the input to encoder, in place of input buffers 411 * 412 * The surface provided *must* be a persistent surface created via 413 * AMediaCodec_createPersistentInputSurface() 414 * This can only be called after the codec has been configured by calling 415 * AMediaCodec_configure(..); and before AMediaCodec_start() has been called. 416 * 417 * For more details, see the Java documentation for MediaCodec.setInputSurface. 418 * 419 * Available since API level 26. 420 */ 421 media_status_t AMediaCodec_setInputSurface( 422 AMediaCodec *mData, ANativeWindow *surface) __INTRODUCED_IN(26); 423 424 /** 425 * Signal additional parameters to the codec instance. 426 * 427 * Parameters can be communicated only when the codec is running, i.e 428 * after AMediaCodec_start() has been called. 429 * 430 * NOTE: Some of these parameter changes may silently fail to apply. 431 * 432 * Available since API level 26. 433 */ 434 media_status_t AMediaCodec_setParameters( 435 AMediaCodec *mData, const AMediaFormat* params) __INTRODUCED_IN(26); 436 437 /** 438 * Signals end-of-stream on input. Equivalent to submitting an empty buffer with 439 * AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM set. 440 * 441 * Returns AMEDIA_ERROR_INVALID_OPERATION when used with an encoder not in executing state 442 * or not receiving input from a Surface created by AMediaCodec_createInputSurface or 443 * AMediaCodec_createPersistentInputSurface. 444 * 445 * Returns the previous codec error if one exists. 446 * 447 * Returns AMEDIA_OK when completed succesfully. 448 * 449 * For more details, see the Java documentation for MediaCodec.signalEndOfInputStream. 450 * 451 * Available since API level 26. 452 */ 453 media_status_t AMediaCodec_signalEndOfInputStream(AMediaCodec *mData) __INTRODUCED_IN(26); 454 455 /** 456 * Get format of the buffer. The specified buffer index must have been previously obtained from 457 * dequeueOutputBuffer. 458 * The caller must free the returned format. 459 * 460 * Available since API level 28. 461 */ 462 AMediaFormat* AMediaCodec_getBufferFormat(AMediaCodec*, size_t index) __INTRODUCED_IN(28); 463 464 /** 465 * Get the component name. If the codec was created by createDecoderByType 466 * or createEncoderByType, what component is chosen is not known beforehand. 467 * Caller shall call AMediaCodec_releaseName to free the returned pointer. 468 * 469 * Available since API level 28. 470 */ 471 media_status_t AMediaCodec_getName(AMediaCodec*, char** out_name) __INTRODUCED_IN(28); 472 473 /** 474 * Free the memory pointed by name which is returned by AMediaCodec_getName. 475 * 476 * Available since API level 28. 477 */ 478 void AMediaCodec_releaseName(AMediaCodec*, char* name) __INTRODUCED_IN(28); 479 480 /** 481 * Set an asynchronous callback for actionable AMediaCodec events. 482 * When asynchronous callback is enabled, it is an error for the client to call 483 * AMediaCodec_dequeueInputBuffer() or AMediaCodec_dequeueOutputBuffer(). 484 * 485 * AMediaCodec_flush() behaves differently in asynchronous mode. 486 * After calling AMediaCodec_flush(), the client must call AMediaCodec_start() to 487 * "resume" receiving input buffers. Even if the client does not receive 488 * AMediaCodecOnAsyncInputAvailable callbacks from video encoders configured 489 * with an input surface, the client still needs to call AMediaCodec_start() 490 * to resume the input surface to send buffers to the encoders. 491 * 492 * When called with null callback, this method unregisters any previously set callback. 493 * 494 * Refer to the definition of AMediaCodecOnAsyncNotifyCallback on how each 495 * callback function is called and what are specified. 496 * The specified userdata is opaque data which will be passed along 497 * when the callback functions are called. MediaCodec does not look at or alter the 498 * value of userdata. Often it is a pointer to a client-owned object, 499 * and client manages the lifecycle of the object in that case. 500 * 501 * Once the callback is unregistered or the codec is reset / released, the 502 * previously registered callback will not be called. 503 * 504 * All callbacks are fired on one NDK internal thread. 505 * AMediaCodec_setAsyncNotifyCallback should not be called on the callback thread. 506 * No heavy duty task should be performed on callback thread. 507 * 508 * Available since API level 28. 509 */ 510 media_status_t AMediaCodec_setAsyncNotifyCallback( 511 AMediaCodec*, 512 AMediaCodecOnAsyncNotifyCallback callback, 513 void *userdata) __INTRODUCED_IN(28); 514 515 /** 516 * Registers a callback to be invoked when an output frame is rendered on the output surface. 517 * 518 * This method can be called in any codec state, but will only have an effect in the 519 * Executing state for codecs that render buffers to the output surface. 520 * 521 * This callback is for informational purposes only: to get precise 522 * render timing samples, and can be significantly delayed and batched. Some frames may have 523 * been rendered even if there was no callback generated. 524 * 525 * When called with null callback, this method unregisters any previously set callback. 526 * 527 * Refer to the definition of AMediaCodecOnFrameRendered on how each 528 * callback function is called and what are specified. 529 * The specified userdata is opaque data which will be passed along 530 * when the callback functions are called. MediaCodec does not look at or alter the 531 * value of userdata. Often it is a pointer to a client-owned object, 532 * and client manages the lifecycle of the object in that case. 533 * 534 * Once the callback is unregistered or the codec is reset / released, the 535 * previously registered callback will not be called. 536 * 537 * All callbacks are fired on one NDK internal thread. 538 * AMediaCodec_setOnFrameRenderedCallback should not be called on the callback thread. 539 * No heavy duty task should be performed on callback thread. 540 * 541 * Available since Android T. 542 */ 543 media_status_t AMediaCodec_setOnFrameRenderedCallback( 544 AMediaCodec*, 545 AMediaCodecOnFrameRendered callback, 546 void *userdata) __INTRODUCED_IN(__ANDROID_API_T__); 547 548 /** 549 * Release the crypto if applicable. 550 * 551 * Available since API level 28. 552 */ 553 media_status_t AMediaCodec_releaseCrypto(AMediaCodec*) __INTRODUCED_IN(28); 554 555 /** 556 * Call this after AMediaCodec_configure() returns successfully to get the input 557 * format accepted by the codec. Do this to determine what optional configuration 558 * parameters were supported by the codec. 559 * The caller must free the returned format. 560 * 561 * Available since API level 28. 562 */ 563 AMediaFormat* AMediaCodec_getInputFormat(AMediaCodec*) __INTRODUCED_IN(28); 564 565 /** 566 * Returns true if the codec cannot proceed further, but can be recovered by stopping, 567 * configuring, and starting again. 568 * 569 * Available since API level 28. 570 */ 571 bool AMediaCodecActionCode_isRecoverable(int32_t actionCode) __INTRODUCED_IN(28); 572 573 /** 574 * Returns true if the codec error is a transient issue, perhaps due to 575 * resource constraints, and that the method (or encoding/decoding) may be 576 * retried at a later time. 577 * 578 * Available since API level 28. 579 */ 580 bool AMediaCodecActionCode_isTransient(int32_t actionCode) __INTRODUCED_IN(28); 581 582 typedef enum { 583 AMEDIACODECRYPTOINFO_MODE_CLEAR = 0, 584 AMEDIACODECRYPTOINFO_MODE_AES_CTR = 1, 585 AMEDIACODECRYPTOINFO_MODE_AES_WV = 2, 586 AMEDIACODECRYPTOINFO_MODE_AES_CBC = 3 587 } cryptoinfo_mode_t; 588 589 typedef struct { 590 int32_t encryptBlocks; 591 int32_t skipBlocks; 592 } cryptoinfo_pattern_t; 593 594 /** 595 * Create an AMediaCodecCryptoInfo from scratch. Use this if you need to use custom 596 * crypto info, rather than one obtained from AMediaExtractor. 597 * 598 * AMediaCodecCryptoInfo describes the structure of an (at least 599 * partially) encrypted input sample. 600 * A buffer's data is considered to be partitioned into "subsamples", 601 * each subsample starts with a (potentially empty) run of plain, 602 * unencrypted bytes followed by a (also potentially empty) run of 603 * encrypted bytes. 604 * numBytesOfClearData can be null to indicate that all data is encrypted. 605 * This information encapsulates per-sample metadata as outlined in 606 * ISO/IEC FDIS 23001-7:2011 "Common encryption in ISO base media file format files". 607 * 608 * Available since API level 21. 609 */ 610 AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new( 611 int numsubsamples, 612 uint8_t key[16], 613 uint8_t iv[16], 614 cryptoinfo_mode_t mode, 615 size_t *clearbytes, 616 size_t *encryptedbytes) __INTRODUCED_IN(21); 617 618 /** 619 * Delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or 620 * obtained from AMediaExtractor. 621 * 622 * Available since API level 21. 623 */ 624 media_status_t AMediaCodecCryptoInfo_delete(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); 625 626 /** 627 * Set the crypto pattern on an AMediaCryptoInfo object. 628 * 629 * Available since API level 21. 630 */ 631 void AMediaCodecCryptoInfo_setPattern( 632 AMediaCodecCryptoInfo *info, 633 cryptoinfo_pattern_t *pattern) __INTRODUCED_IN(21); 634 635 /** 636 * The number of subsamples that make up the buffer's contents. 637 * 638 * Available since API level 21. 639 */ 640 size_t AMediaCodecCryptoInfo_getNumSubSamples(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); 641 642 /** 643 * A 16-byte opaque key. 644 * 645 * Available since API level 21. 646 */ 647 media_status_t AMediaCodecCryptoInfo_getKey(AMediaCodecCryptoInfo*, uint8_t *dst) __INTRODUCED_IN(21); 648 649 /** 650 * A 16-byte initialization vector. 651 * 652 * Available since API level 21. 653 */ 654 media_status_t AMediaCodecCryptoInfo_getIV(AMediaCodecCryptoInfo*, uint8_t *dst) __INTRODUCED_IN(21); 655 656 /** 657 * The type of encryption that has been applied, 658 * one of AMEDIACODECRYPTOINFO_MODE_CLEAR or AMEDIACODECRYPTOINFO_MODE_AES_CTR. 659 * 660 * Available since API level 21. 661 */ 662 cryptoinfo_mode_t AMediaCodecCryptoInfo_getMode(AMediaCodecCryptoInfo*) __INTRODUCED_IN(21); 663 664 /** 665 * The number of leading unencrypted bytes in each subsample. 666 * 667 * Available since API level 21. 668 */ 669 media_status_t AMediaCodecCryptoInfo_getClearBytes(AMediaCodecCryptoInfo*, size_t *dst) __INTRODUCED_IN(21); 670 671 /** 672 * The number of trailing encrypted bytes in each subsample. 673 * 674 * Available since API level 21. 675 */ 676 media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo*, size_t *dst) __INTRODUCED_IN(21); 677 678 extern const char* AMEDIACODEC_KEY_HDR10_PLUS_INFO __INTRODUCED_IN(31); 679 extern const char* AMEDIACODEC_KEY_LOW_LATENCY __INTRODUCED_IN(31); 680 extern const char* AMEDIACODEC_KEY_OFFSET_TIME __INTRODUCED_IN(31); 681 extern const char* AMEDIACODEC_KEY_REQUEST_SYNC_FRAME __INTRODUCED_IN(31); 682 extern const char* AMEDIACODEC_KEY_SUSPEND __INTRODUCED_IN(31); 683 extern const char* AMEDIACODEC_KEY_SUSPEND_TIME __INTRODUCED_IN(31); 684 extern const char* AMEDIACODEC_KEY_VIDEO_BITRATE __INTRODUCED_IN(31); 685 686 __END_DECLS 687 688 #endif //_NDK_MEDIA_CODEC_H 689 690 /** @} */ 691