1/* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef NATIVE_AVCODEC_BASE_H 17#define NATIVE_AVCODEC_BASE_H 18 19#include <stdint.h> 20#include <stdio.h> 21#include "native_avbuffer.h" 22#include "native_avmemory.h" 23 24#ifdef __cplusplus 25extern "C" { 26#endif 27 28typedef struct NativeWindow OHNativeWindow; 29typedef struct OH_AVCodec OH_AVCodec; 30 31/** 32 * @brief When an error occurs in the running of the OH_AVCodec instance, the function pointer will be called 33 * to report specific error information. 34 * @syscap SystemCapability.Multimedia.Media.CodecBase 35 * @param codec OH_AVCodec instance 36 * @param errorCode specific error code 37 * @param userData User specific data 38 * @since 9 39 * @version 1.0 40 */ 41typedef void (*OH_AVCodecOnError)(OH_AVCodec *codec, int32_t errorCode, void *userData); 42 43/** 44 * @brief When the output stream changes, the function pointer will be called to report the new stream description 45 * information. It should be noted that the life cycle of the OH_AVFormat pointer 46 * is only valid when the function pointer is called, and it is forbidden to continue to access after the call ends. 47 * @syscap SystemCapability.Multimedia.Media.CodecBase 48 * @param codec OH_AVCodec instance 49 * @param format New output stream description information 50 * @param userData User specific data 51 * @since 9 52 * @version 1.0 53 */ 54typedef void (*OH_AVCodecOnStreamChanged)(OH_AVCodec *codec, OH_AVFormat *format, void *userData); 55 56/** 57 * @brief When OH_AVCodec needs new input data during the running process, 58 * the function pointer will be called and carry an available Buffer to fill in the new input data. 59 * @syscap SystemCapability.Multimedia.Media.CodecBase 60 * @param codec OH_AVCodec instance 61 * @param index The index corresponding to the newly available input buffer. 62 * @param data New available input buffer. 63 * @param userData User specific data 64 * @deprecated since 11 65 * @useinstead OH_AVCodecOnNeedInputBuffer 66 * @since 9 67 * @version 1.0 68 */ 69typedef void (*OH_AVCodecOnNeedInputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData); 70 71/** 72 * @brief When new output data is generated during the operation of OH_AVCodec, the function pointer will be 73 * called and carry a Buffer containing the new output data. It should be noted that the life cycle of the 74 * OH_AVCodecBufferAttr pointer is only valid when the function pointer is called. , which prohibits continued 75 * access after the call ends. 76 * @syscap SystemCapability.Multimedia.Media.CodecBase 77 * @param codec OH_AVCodec instance 78 * @param index The index corresponding to the new output Buffer. 79 * @param data Buffer containing the new output data 80 * @param attr The description of the new output Buffer, please refer to {@link OH_AVCodecBufferAttr} 81 * @param userData specified data 82 * @deprecated since 11 83 * @useinstead OH_AVCodecOnNewOutputBuffer 84 * @since 9 85 * @version 1.0 86 */ 87typedef void (*OH_AVCodecOnNewOutputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, 88 OH_AVCodecBufferAttr *attr, void *userData); 89 90/** 91 * @brief When OH_AVCodec needs new input data during the running process, 92 * the function pointer will be called and carry an available Buffer to fill in the new input data. 93 * @syscap SystemCapability.Multimedia.Media.CodecBase 94 * @param codec OH_AVCodec instance 95 * @param index The index corresponding to the newly available input buffer. 96 * @param buffer New available input buffer. 97 * @param userData User specific data 98 * @since 11 99 */ 100typedef void (*OH_AVCodecOnNeedInputBuffer)(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData); 101 102/** 103 * @brief When new output data is generated during the operation of OH_AVCodec, the function pointer will be 104 * called and carry a Buffer containing the new output data. 105 * @syscap SystemCapability.Multimedia.Media.CodecBase 106 * @param codec OH_AVCodec instance 107 * @param index The index corresponding to the new output Buffer. 108 * @param buffer Buffer containing the new output buffer. 109 * @param userData specified data 110 * @since 11 111 */ 112typedef void (*OH_AVCodecOnNewOutputBuffer)(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData); 113 114/** 115 * @brief A collection of all asynchronous callback function pointers in OH_AVCodec. Register an instance of this 116 * structure to the OH_AVCodec instance, and process the information reported through the callback to ensure the 117 * normal operation of OH_AVCodec. 118 * @syscap SystemCapability.Multimedia.Media.CodecBase 119 * @param onError Monitor OH_AVCodec operation errors, refer to {@link OH_AVCodecOnError} 120 * @param onStreamChanged Monitor codec stream information, refer to {@link OH_AVCodecOnStreamChanged} 121 * @param onNeedInputData Monitoring codec requires input data, refer to {@link OH_AVCodecOnNeedInputData} 122 * @param onNeedOutputData Monitor codec to generate output data, refer to {@link OH_AVCodecOnNewOutputData} 123 * @deprecated since 11 124 * @useinstead OH_AVCodecCallback 125 * @since 9 126 * @version 1.0 127 */ 128typedef struct OH_AVCodecAsyncCallback { 129 OH_AVCodecOnError onError; 130 OH_AVCodecOnStreamChanged onStreamChanged; 131 OH_AVCodecOnNeedInputData onNeedInputData; 132 OH_AVCodecOnNewOutputData onNeedOutputData; 133} OH_AVCodecAsyncCallback; 134 135/** 136 * @brief A collection of all asynchronous callback function pointers in OH_AVCodec. Register an instance of this 137 * structure to the OH_AVCodec instance, and process the information reported through the callback to ensure the 138 * normal operation of OH_AVCodec. 139 * @syscap SystemCapability.Multimedia.Media.CodecBase 140 * @param onError Monitor OH_AVCodec operation errors, refer to {@link OH_AVCodecOnError} 141 * @param onStreamChanged Monitor codec stream information, refer to {@link OH_AVCodecOnStreamChanged} 142 * @param onNeedInputBuffer Monitoring codec requires input buffer, refer to {@link OH_AVCodecOnNeedInputBuffer} 143 * @param onNewOutputBuffer Monitor codec to generate output buffer, refer to {@link OH_AVCodecOnNewOutputBuffer} 144 * @since 11 145 */ 146typedef struct OH_AVCodecCallback { 147 OH_AVCodecOnError onError; 148 OH_AVCodecOnStreamChanged onStreamChanged; 149 OH_AVCodecOnNeedInputBuffer onNeedInputBuffer; 150 OH_AVCodecOnNewOutputBuffer onNewOutputBuffer; 151} OH_AVCodecCallback; 152 153/** 154 * @brief The function pointer will be called to get sequenced media data. 155 * @syscap SystemCapability.Multimedia.Media.CodecBase 156 * @param data The buffer to fill. 157 * @param length Length of data to read. 158 * @param offset Start offset to read. 159 * @return Actual length of data read to the buffer. 160 * @since 12 161 */ 162typedef int32_t (*OH_AVDataSourceReadAt)(OH_AVBuffer *data, int32_t length, int64_t offset); 163 164/** 165 * @brief User customized data source. 166 * @syscap SystemCapability.Multimedia.Media.CodecBase 167 * @since 12 168 */ 169typedef struct OH_AVDataSource { 170 /** 171 * @brief Total size of the data source. 172 * @syscap SystemCapability.Multimedia.Media.CodecBase 173 * @since 12 174 */ 175 int64_t size; 176 /** 177 * @brief Data callback of the data source. 178 * @syscap SystemCapability.Multimedia.Media.CodecBase 179 * @since 12 180 */ 181 OH_AVDataSourceReadAt readAt; 182} OH_AVDataSource; 183 184/** 185 * @brief Enumerates the MIME types of audio and video codecs 186 * @syscap SystemCapability.Multimedia.Media.CodecBase 187 * @since 9 188 * @version 1.0 189 */ 190extern const char *OH_AVCODEC_MIMETYPE_VIDEO_AVC; 191extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AAC; 192 193/** 194 * @brief Enumerates the MIME types of audio and video codecs 195 * @syscap SystemCapability.Multimedia.Media.CodecBase 196 * @since 10 197 */ 198extern const char *OH_AVCODEC_MIMETYPE_AUDIO_FLAC; 199extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VORBIS; 200extern const char *OH_AVCODEC_MIMETYPE_AUDIO_MPEG; 201extern const char *OH_AVCODEC_MIMETYPE_VIDEO_HEVC; 202 203/** 204 * @brief Enumerates the types of audio and video muxer 205 * @syscap SystemCapability.Multimedia.Media.CodecBase 206 * @deprecated since 11 207 * @since 10 208 */ 209extern const char *OH_AVCODEC_MIMETYPE_VIDEO_MPEG4; 210 211/** 212 * @brief Enumerates the types of audio and video muxer 213 * @syscap SystemCapability.Multimedia.Media.CodecBase 214 * @since 10 215 */ 216extern const char *OH_AVCODEC_MIMETYPE_IMAGE_JPG; 217extern const char *OH_AVCODEC_MIMETYPE_IMAGE_PNG; 218extern const char *OH_AVCODEC_MIMETYPE_IMAGE_BMP; 219 220/** 221 * @brief Enumerates the MIME types of audio codecs 222 * @syscap SystemCapability.Multimedia.Media.CodecBase 223 * @since 11 224 */ 225extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VIVID; 226extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_NB; 227extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_WB; 228extern const char *OH_AVCODEC_MIMETYPE_AUDIO_OPUS; 229extern const char *OH_AVCODEC_MIMETYPE_AUDIO_G711MU; 230 231/** 232 * @brief Enumerates the MIME type of audio low bitrate voice codec. 233 * 234 * @syscap SystemCapability.Multimedia.Media.CodecBase 235 * @since 12 236 */ 237extern const char *OH_AVCODEC_MIMETYPE_AUDIO_LBVC; 238 239/** 240 * @brief Enumerates the MIME type of audio ape codec. 241 * 242 * @syscap SystemCapability.Multimedia.Media.CodecBase 243 * @since 12 244 */ 245extern const char *OH_AVCODEC_MIMETYPE_AUDIO_APE; 246 247/** 248 * @brief Enumerates the MIME type of versatile video coding. 249 * 250 * @syscap SystemCapability.Multimedia.Media.CodecBase 251 * @since 12 252 */ 253extern const char *OH_AVCODEC_MIMETYPE_VIDEO_VVC; 254 255/** 256 * @brief Enumerates the MIME type of subtitle. 257 * 258 * @syscap SystemCapability.Multimedia.Media.CodecBase 259 * @since 12 260 */ 261extern const char *OH_AVCODEC_MIMETYPE_SUBTITLE_SRT; 262 263/** 264 * @brief Enumerates the mime type of subtitle webvtt. 265 * 266 * @syscap SystemCapability.Multimedia.Media.CodecBase 267 * @since 12 268 */ 269extern const char *OH_AVCODEC_MIMETYPE_SUBTITLE_WEBVTT; 270 271/** 272 * @brief The extra data's key of surface Buffer 273 * @syscap SystemCapability.Multimedia.Media.CodecBase 274 * @since 9 275 * @version 1.0 276 */ 277/* Key for timeStamp in surface's extraData, value type is int64 */ 278extern const char *OH_ED_KEY_TIME_STAMP; 279/* Key for endOfStream in surface's extraData, value type is bool */ 280extern const char *OH_ED_KEY_EOS; 281 282/** 283 * @brief Provides the uniform key for storing the media description. 284 * @syscap SystemCapability.Multimedia.Media.CodecBase 285 * @since 9 286 * @version 1.0 287 */ 288/* Key for track type, value type is int32_t, see @OH_MediaType. */ 289extern const char *OH_MD_KEY_TRACK_TYPE; 290/* Key for codec mime type, value type is string. */ 291extern const char *OH_MD_KEY_CODEC_MIME; 292/* Key for file duration, value type is int64_t. */ 293extern const char *OH_MD_KEY_DURATION; 294/* Key for bitrate, value type is int64_t. */ 295extern const char *OH_MD_KEY_BITRATE; 296/* Key for max input size, value type is int32_t */ 297extern const char *OH_MD_KEY_MAX_INPUT_SIZE; 298/* Key for video width, value type is int32_t */ 299extern const char *OH_MD_KEY_WIDTH; 300/* Key for video height, value type is int32_t */ 301extern const char *OH_MD_KEY_HEIGHT; 302/* Key for video pixel format, value type is int32_t, see @OH_AVPixelFormat */ 303extern const char *OH_MD_KEY_PIXEL_FORMAT; 304/* key for audio raw format, value type is int32_t , see @OH_BitsPerSample */ 305extern const char *OH_MD_KEY_AUDIO_SAMPLE_FORMAT; 306/* Key for video frame rate, value type is double. */ 307extern const char *OH_MD_KEY_FRAME_RATE; 308/* video encode bitrate mode, the value type is int32_t, see @OH_VideoEncodeBitrateMode */ 309extern const char *OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE; 310/* encode profile, the value type is int32_t. see @OH_AVCProfile, OH_HEVCProfile, OH_AACProfile. */ 311extern const char *OH_MD_KEY_PROFILE; 312/* Key for audio channel count, value type is int32_t */ 313extern const char *OH_MD_KEY_AUD_CHANNEL_COUNT; 314/* Key for audio sample rate, value type is int32_t */ 315extern const char *OH_MD_KEY_AUD_SAMPLE_RATE; 316/** 317 * @brief Key for the interval of key frame. value type is int32_t, the unit is milliseconds. A negative value means no 318 * key frames are requested after the first frame. A zero value means a stream containing all key frames is requested. 319 * 320 * @syscap SystemCapability.Multimedia.Media.CodecBase 321 * @since 9 322 */ 323extern const char *OH_MD_KEY_I_FRAME_INTERVAL; 324/* Key of the surface rotation angle. value type is int32_t: should be {0, 90, 180, 270}, default is 0. */ 325extern const char *OH_MD_KEY_ROTATION; 326 327/** 328 * @brief Provides the uniform key for storing the media description. 329 * @syscap SystemCapability.Multimedia.Media.CodecBase 330 * @since 10 331 */ 332/* Key for video YUV value range flag, value type is bool, true for full range, false for limited range */ 333extern const char *OH_MD_KEY_RANGE_FLAG; 334/* Key for video color primaries, value type is int32_t, see @OH_ColorPrimary */ 335extern const char *OH_MD_KEY_COLOR_PRIMARIES; 336/* Key for video transfer characteristics, value type is int32_t, see @OH_TransferCharacteristic */ 337extern const char *OH_MD_KEY_TRANSFER_CHARACTERISTICS; 338/* Key for video matrix coefficients, value type is int32_t, see @OH_MatrixCoefficient */ 339extern const char *OH_MD_KEY_MATRIX_COEFFICIENTS; 340/* Key for the request an I-Frame immediately, value type is bool */ 341extern const char *OH_MD_KEY_REQUEST_I_FRAME; 342/* Key for the desired encoding quality, value type is int32_t, this key is only 343 * supported for encoders that are configured in constant quality mode */ 344extern const char *OH_MD_KEY_QUALITY; 345/* Key of the codec specific data. value type is a uint8_t pointer */ 346extern const char *OH_MD_KEY_CODEC_CONFIG; 347/* source format Key for title, value type is string */ 348extern const char *OH_MD_KEY_TITLE; 349/* source format Key for artist, value type is string */ 350extern const char *OH_MD_KEY_ARTIST; 351/* source format Key for album, value type is string */ 352extern const char *OH_MD_KEY_ALBUM; 353/* source format Key for album artist, value type is string */ 354extern const char *OH_MD_KEY_ALBUM_ARTIST; 355/* source format Key for date, value type is string */ 356extern const char *OH_MD_KEY_DATE; 357/* source format Key for comment, value type is string */ 358extern const char *OH_MD_KEY_COMMENT; 359/* source format Key for genre, value type is string */ 360extern const char *OH_MD_KEY_GENRE; 361/* source format Key for copyright, value type is string */ 362extern const char *OH_MD_KEY_COPYRIGHT; 363/* source format Key for language, value type is string */ 364extern const char *OH_MD_KEY_LANGUAGE; 365/* source format Key for description, value type is string */ 366extern const char *OH_MD_KEY_DESCRIPTION; 367/* source format Key for lyrics, value type is string */ 368extern const char *OH_MD_KEY_LYRICS; 369/* source format Key for track count, value type is int32_t */ 370extern const char *OH_MD_KEY_TRACK_COUNT; 371/* Key for the desired encoding channel layout, value type is int64_t, this key is only supported for encoders */ 372extern const char *OH_MD_KEY_CHANNEL_LAYOUT; 373/* Key for bits per coded sample, value type is int32_t, supported for flac encoder, see @OH_BitsPerSample */ 374extern const char *OH_MD_KEY_BITS_PER_CODED_SAMPLE; 375/* Key for the aac format, value type is int32_t, supported for aac decoder */ 376extern const char *OH_MD_KEY_AAC_IS_ADTS; 377/* Key for aac sbr mode, value type is int32_t, supported for aac encoder */ 378extern const char *OH_MD_KEY_SBR; 379/* Key for flac compliance level, value type is int32_t */ 380extern const char *OH_MD_KEY_COMPLIANCE_LEVEL; 381/* Key for vorbis identification header, value type is a uint8_t pointer, supported only for vorbis decoder */ 382extern const char *OH_MD_KEY_IDENTIFICATION_HEADER; 383/* Key for vorbis setup header, value type is a uint8_t pointer, supported only for vorbis decoder */ 384extern const char *OH_MD_KEY_SETUP_HEADER; 385/* Key for video scale type, value type is int32_t, see @OH_ScalingMode */ 386extern const char *OH_MD_KEY_SCALING_MODE; 387/* Key for max input buffer count, value type is int32_t */ 388extern const char *OH_MD_MAX_INPUT_BUFFER_COUNT; 389/* Key for max output buffer count, value type is int32_t */ 390extern const char *OH_MD_MAX_OUTPUT_BUFFER_COUNT; 391 392/** 393 * @brief Provides the uniform key for storing the media description. 394 * @syscap SystemCapability.Multimedia.Media.CodecBase 395 * @since 11 396 */ 397/* Key for audio codec compression level, value type is int32_t */ 398extern const char *OH_MD_KEY_AUDIO_COMPRESSION_LEVEL; 399/* Key of the video is hdr vivid. value type is bool */ 400extern const char *OH_MD_KEY_VIDEO_IS_HDR_VIVID; 401/* Key for number of audio objects. value type is int32_t */ 402extern const char *OH_MD_KEY_AUDIO_OBJECT_NUMBER; 403/* Key for meta data of audio vivid. value type is a uint8_t pointer */ 404extern const char *OH_MD_KEY_AUDIO_VIVID_METADATA; 405 406/** 407 * @brief Key for querying the maximum long-term reference count of video encoder, value type is int32_t. 408 * You should query the count through interface {@link OH_AVCapability_GetFeatureProperties} 409 * with enum {@link VIDEO_ENCODER_LONG_TERM_REFERENCE}. 410 * 411 * @syscap SystemCapability.Multimedia.Media.CodecBase 412 * @since 12 413 */ 414extern const char *OH_FEATURE_PROPERTY_KEY_VIDEO_ENCODER_MAX_LTR_FRAME_COUNT; 415/** 416 * @brief Key for enable the temporal scalability mode, value type is int32_t (0 or 1): 1 is enabled, 0 otherwise. 417 * The default value is 0. To query supported, you should use the interface {@link OH_AVCapability_IsFeatureSupported} 418 * with enum {@link VIDEO_ENCODER_TEMPORAL_SCALABILITY}. This is an optional key that applies only to video encoder. 419 * It is used in configure. 420 * 421 * @syscap SystemCapability.Multimedia.Media.CodecBase 422 * @since 12 423 */ 424extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_TEMPORAL_SCALABILITY; 425/** 426 * @brief Key for describing the temporal group of picture size, value type is int32_t. It takes effect only when 427 * temporal level scale is enable. This is an optional key that applies only to video encoder. It is used in configure. 428 * 429 * @syscap SystemCapability.Multimedia.Media.CodecBase 430 * @since 12 431 */ 432extern const char *OH_MD_KEY_VIDEO_ENCODER_TEMPORAL_GOP_SIZE; 433/** 434 * @brief Key for describing the reference mode in temporal group of picture, value type is int32_t, see enum 435 * {@link OH_TemporalGopReferenceMode}. It takes effect only when temporal level sacle is enabled. 436 * This is an optional key that applies only to video encoder. It is used in configure. 437 * 438 * @syscap SystemCapability.Multimedia.Media.CodecBase 439 * @since 12 440 */ 441extern const char *OH_MD_KEY_VIDEO_ENCODER_TEMPORAL_GOP_REFERENCE_MODE; 442/** 443 * @brief Key for describing the count of used long-term reference frames, value type is int32_t, must be within the 444 * supported range. To get supported range, you should query wthether the capability is supported through the interface 445 * {@link OH_AVCapability_GetFeatureProperties} with enum {@link VIDEO_ENCODER_LONG_TERM_REFERENCE}, otherwise, not set 446 * the key. This is an optional key that applies only to video encoder. It is used in configure. 447 * 448 * @syscap SystemCapability.Multimedia.Media.CodecBase 449 * @since 12 450 */ 451extern const char *OH_MD_KEY_VIDEO_ENCODER_LTR_FRAME_COUNT; 452/** 453 * @brief Key for describing mark this frame as a long term reference frame, value type is int32_t (0 or 1): 1 is mark, 454 * 0 otherwise. It takes effect only when the number of used long term reference frames is configured. This is an 455 * optional key that applies only to video encoder input loop. It takes effect immediately. 456 * 457 * @syscap SystemCapability.Multimedia.Media.CodecBase 458 * @since 12 459 */ 460extern const char *OH_MD_KEY_VIDEO_ENCODER_PER_FRAME_MARK_LTR; 461/** 462 * @brief Key for describing the long term reference frame poc referenced by this frame, value type is int32_t. This is 463 * an optional key that applies only to video encoder input loop. It takes effect immediately. 464 * 465 * @syscap SystemCapability.Multimedia.Media.CodecBase 466 * @since 12 467 */ 468extern const char *OH_MD_KEY_VIDEO_ENCODER_PER_FRAME_USE_LTR; 469/** 470 * @brief Key for indicating this frame is a long-term reference frame, value type is int32_t (0 or 1): 1 is LTR, 471 * 0 otherwise. This is an optional key that applies only to video encoder output loop. 472 * It indicates the attribute of the frame. 473 * 474 * @syscap SystemCapability.Multimedia.Media.CodecBase 475 * @since 12 476 */ 477extern const char *OH_MD_KEY_VIDEO_PER_FRAME_IS_LTR; 478/** 479 * @brief Key for describing the frame poc, value type is int32_t. This is an optional key that applies only to video 480 * encoder output loop. It indicates the attribute of the frame. 481 * 482 * @syscap SystemCapability.Multimedia.Media.CodecBase 483 * @since 12 484 */ 485extern const char *OH_MD_KEY_VIDEO_PER_FRAME_POC; 486/** 487 * @brief Key for describing the top-coordinate (y) of the crop rectangle, value type is int32_t. This is the top-most 488 * row included in the crop frame, where row indices start at 0. 489 * 490 * @syscap SystemCapability.Multimedia.Media.CodecBase 491 * @since 12 492 */ 493extern const char *OH_MD_KEY_VIDEO_CROP_TOP; 494/** 495 * @brief Key for describing the bottom-coordinate (y) of the crop rectangle, value type is int32_t. This is the 496 * bottom-most row included in the crop frame, where row indices start at 0. 497 * 498 * @syscap SystemCapability.Multimedia.Media.CodecBase 499 * @since 12 500 */ 501extern const char *OH_MD_KEY_VIDEO_CROP_BOTTOM; 502/** 503 * @brief Key for describing the left-coordinate (x) of the crop rectangle, value type is int32_t. 504 * This is the left-most column included in the crop frame, where column indices start at 0. 505 * 506 * @syscap SystemCapability.Multimedia.Media.CodecBase 507 * @since 12 508 */ 509extern const char *OH_MD_KEY_VIDEO_CROP_LEFT; 510/** 511 * @brief Key for describing the right-coordinate (x) of the crop rectangle, value type is int32_t. This is the 512 * right-most column included in the crop frame, where column indices start at 0. 513 * 514 * @syscap SystemCapability.Multimedia.Media.CodecBase 515 * @since 12 516 */ 517extern const char *OH_MD_KEY_VIDEO_CROP_RIGHT; 518/** 519 * @brief Key for describing the stride of the video buffer layout, value type is int32_t. Stride (or row increment) is 520 * the difference between the index of a pixel and that of the pixel directly underneath. For YUV 420 formats, the 521 * stride corresponds to the Y plane; the stride of the U and V planes can be calculated based on the color format, 522 * though it is generally undefined and depends on the device and release. 523 * 524 * @syscap SystemCapability.Multimedia.Media.CodecBase 525 * @since 12 526 */ 527extern const char *OH_MD_KEY_VIDEO_STRIDE; 528/** 529 * @brief Key for describing the plane height of a multi-planar (YUV) video buffer layout, value type is int32_t. 530 * Slice height (or plane height/vertical stride) is the number of rows that must be skipped to get from 531 * the top of the Y plane to the top of the U plane in the buffer. In essence the offset of the U plane 532 * is sliceHeight * stride. The height of the U/V planes can be calculated based on the color format, 533 * though it is generally undefined and depends on the device and release. 534 * 535 * @syscap SystemCapability.Multimedia.Media.CodecBase 536 * @since 12 537 */ 538extern const char *OH_MD_KEY_VIDEO_SLICE_HEIGHT; 539/** 540 * @brief Key for describing the valid picture width of the video, value type is int32_t. 541 * Get the value from an OH_AVFormat instance, which obtained by calling {@link OH_VideoDecoder_GetOutputDescription} 542 * or {@link OH_AVCodecOnStreamChanged}. 543 * 544 * @syscap SystemCapability.Multimedia.Media.CodecBase 545 * @since 12 546 */ 547extern const char *OH_MD_KEY_VIDEO_PIC_WIDTH; 548/** 549 * @brief Key for describing the valid picture height of the video, value type is int32_t. 550 * Get the value from an OH_AVFormat instance, which obtained by calling {@link OH_VideoDecoder_GetOutputDescription} 551 * or {@link OH_AVCodecOnStreamChanged}. 552 * 553 * @syscap SystemCapability.Multimedia.Media.CodecBase 554 * @since 12 555 */ 556extern const char *OH_MD_KEY_VIDEO_PIC_HEIGHT; 557/** 558 * @brief Key to enable the low latency mode, value type is int32_t (0 or 1):1 is enabled, 0 otherwise. 559 * If enabled, the video encoder or video decoder doesn't hold input and output data more than required by 560 * the codec standards. This is an optional key that applies only to video encoder or video decoder. 561 * It is used in configure. 562 * 563 * @syscap SystemCapability.Multimedia.Media.CodecBase 564 * @since 12 565 */ 566extern const char *OH_MD_KEY_VIDEO_ENABLE_LOW_LATENCY; 567/** 568 * @brief Key for describing the maximum quantization parameter allowed for video encoder, value type is int32_t. 569 * It is used in configure/setparameter or takes effect immediately with the frame. 570 * 571 * @syscap SystemCapability.Multimedia.Media.CodecBase 572 * @since 12 573 */ 574extern const char *OH_MD_KEY_VIDEO_ENCODER_QP_MAX; 575/** 576 * @brief Key for describing the minimum quantization parameter allowed for video encoder, value type is int32_t. 577 * It is used in configure/setparameter or takes effect immediately with the frame. 578 * 579 * @syscap SystemCapability.Multimedia.Media.CodecBase 580 * @since 12 581 */ 582extern const char *OH_MD_KEY_VIDEO_ENCODER_QP_MIN; 583/** 584 * @brief Key for describing the video frame averge quantization parameter, value type is int32_t. 585 * This is a part of a video encoder statistics export feature. This value is emitted from video encoder for a video 586 * frame. 587 * 588 * @syscap SystemCapability.Multimedia.Media.CodecBase 589 * @since 12 590 */ 591extern const char *OH_MD_KEY_VIDEO_ENCODER_QP_AVERAGE; 592/** 593 * @brief Key for describing video frame mean squared error, value type is double. 594 * This is a part of a video encoder statistics export feature. This value is emitted from video encoder for a video 595 * frame. 596 * 597 * @syscap SystemCapability.Multimedia.Media.CodecBase 598 * @since 12 599 */ 600extern const char *OH_MD_KEY_VIDEO_ENCODER_MSE; 601/** 602 * @brief Key for decoding timestamp of the buffer in microseconds, value type is int64_t. 603 * 604 * @syscap SystemCapability.Multimedia.Media.CodecBase 605 * @since 12 606 */ 607extern const char *OH_MD_KEY_DECODING_TIMESTAMP; 608/** 609 * @brief Key for duration of the buffer in microseconds, value type is int64_t. 610 * 611 * @syscap SystemCapability.Multimedia.Media.CodecBase 612 * @since 12 613 */ 614extern const char *OH_MD_KEY_BUFFER_DURATION; 615/** 616 * @brief Key for sample aspect ratio, value type is double. 617 * 618 * @syscap SystemCapability.Multimedia.Media.CodecBase 619 * @since 12 620 */ 621extern const char *OH_MD_KEY_VIDEO_SAR; 622/** 623 * @brief Key for start time of file, value type is int64_t. 624 * 625 * @syscap SystemCapability.Multimedia.Media.CodecBase 626 * @since 12 627 */ 628extern const char *OH_MD_KEY_START_TIME; 629/** 630 * @brief Key for start time of track, value type is int64_t. 631 * 632 * @syscap SystemCapability.Multimedia.Media.CodecBase 633 * @since 12 634 */ 635extern const char *OH_MD_KEY_TRACK_START_TIME; 636/** 637 * @brief Key for setting the output color space of video decoder. The value type is int32_t. 638 * The supported value is {@link OH_COLORSPACE_BT709_LIMIT}, see {@link OH_NativeBuffer_ColorSpace}. It is used in 639 * {@link OH_VideoDecoder_Configure}. If the color space conversion capability is supported and this key is configured, 640 * the video decoder will automatically transcode an HDR Vivid video to an SDR video with color space BT709. 641 * If color space conversion capability is not supported, {@link OH_VideoDecoder_Configure} returns 642 * {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION}. 643 * If the input video is not an HDR vivid video, an error {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION} will 644 * be reported by callback function {@link OH_AVCodecOnError}. 645 * 646 * @syscap SystemCapability.Multimedia.Media.CodecBase 647 * @since 12 648 */ 649extern const char *OH_MD_KEY_VIDEO_DECODER_OUTPUT_COLOR_SPACE; 650/** 651 * @brief Key for describing if enable VRR or not, value type is int32_t (0 or 1): 1 is enabled, 0 otherwise. 652 * This is an optional key that applies only to video decoder. It is used in configure. 653 * 654 * @syscap SystemCapability.Multimedia.Media.CodecBase 655 * @since 14 656 */ 657extern const char *OH_MD_KEY_VIDEO_DECODER_ENABLE_VRR; 658 659/** 660 * @brief Media type. 661 * @syscap SystemCapability.Multimedia.Media.CodecBase 662 * @since 9 663 * @version 1.0 664 */ 665typedef enum OH_MediaType { 666 /* track is audio. */ 667 MEDIA_TYPE_AUD = 0, 668 /* track is video. */ 669 MEDIA_TYPE_VID = 1, 670 /** track is subtitle. 671 * @since 12 672 */ 673 MEDIA_TYPE_SUBTITLE = 2, 674} OH_MediaType; 675 676/** 677 * @brief AAC Profile 678 * @syscap SystemCapability.Multimedia.Media.CodecBase 679 * @since 9 680 * @version 1.0 681 */ 682typedef enum OH_AACProfile { 683 AAC_PROFILE_LC = 0, 684} OH_AACProfile; 685 686/** 687 * @brief AVC Profile 688 * @syscap SystemCapability.Multimedia.Media.CodecBase 689 * @since 9 690 * @version 1.0 691 */ 692typedef enum OH_AVCProfile { 693 AVC_PROFILE_BASELINE = 0, 694 AVC_PROFILE_HIGH = 4, 695 AVC_PROFILE_MAIN = 8, 696} OH_AVCProfile; 697 698/** 699 * @brief HEVC Profile 700 * @syscap SystemCapability.Multimedia.Media.CodecBase 701 * @since 10 702 */ 703typedef enum OH_HEVCProfile { 704 HEVC_PROFILE_MAIN = 0, 705 HEVC_PROFILE_MAIN_10 = 1, 706 HEVC_PROFILE_MAIN_STILL = 2, 707 HEVC_PROFILE_MAIN_10_HDR10 = 3, 708 HEVC_PROFILE_MAIN_10_HDR10_PLUS = 4, 709} OH_HEVCProfile; 710 711/** 712 * @brief Enumerates the muxer output file format 713 * @syscap SystemCapability.Multimedia.Media.CodecBase 714 * @since 10 715 */ 716typedef enum OH_AVOutputFormat { 717 AV_OUTPUT_FORMAT_DEFAULT = 0, 718 AV_OUTPUT_FORMAT_MPEG_4 = 2, 719 AV_OUTPUT_FORMAT_M4A = 6, 720 /** 721 * The muxer output amr file format. 722 * @since 12 723 */ 724 AV_OUTPUT_FORMAT_AMR = 8, 725 /** 726 * The muxer output mp3 file format. 727 * @since 12 728 */ 729 AV_OUTPUT_FORMAT_MP3 = 9, 730 /** 731 * The muxer output wav file format. 732 * @since 12 733 */ 734 AV_OUTPUT_FORMAT_WAV = 10, 735} OH_AVOutputFormat; 736 737/** 738 * @brief Seek Mode 739 * @syscap SystemCapability.Multimedia.Media.CodecBase 740 * @since 10 741 */ 742typedef enum OH_AVSeekMode { 743 /* seek to sync sample after the time */ 744 SEEK_MODE_NEXT_SYNC = 0, 745 /* seek to sync sample before the time */ 746 SEEK_MODE_PREVIOUS_SYNC, 747 /* seek to sync sample closest to time */ 748 SEEK_MODE_CLOSEST_SYNC, 749} OH_AVSeekMode; 750 751/** 752 * @brief Scaling Mode 753 * @syscap SystemCapability.Multimedia.Media.CodecBase 754 * @since 10 755 */ 756typedef enum OH_ScalingMode { 757 SCALING_MODE_SCALE_TO_WINDOW = 1, 758 SCALING_MODE_SCALE_CROP = 2, 759} OH_ScalingMode; 760 761/** 762 * @brief enum Audio Bits Per Coded Sample 763 * @syscap SystemCapability.Multimedia.Media.CodecBase 764 * @since 10 765 */ 766typedef enum OH_BitsPerSample { 767 SAMPLE_U8 = 0, 768 SAMPLE_S16LE = 1, 769 SAMPLE_S24LE = 2, 770 SAMPLE_S32LE = 3, 771 SAMPLE_F32LE = 4, 772 SAMPLE_U8P = 5, 773 SAMPLE_S16P = 6, 774 SAMPLE_S24P = 7, 775 SAMPLE_S32P = 8, 776 SAMPLE_F32P = 9, 777 INVALID_WIDTH = -1 778} OH_BitsPerSample; 779 780/** 781 * @brief Color Primary 782 * @syscap SystemCapability.Multimedia.Media.CodecBase 783 * @since 10 784 */ 785typedef enum OH_ColorPrimary { 786 COLOR_PRIMARY_BT709 = 1, 787 COLOR_PRIMARY_UNSPECIFIED = 2, 788 COLOR_PRIMARY_BT470_M = 4, 789 COLOR_PRIMARY_BT601_625 = 5, 790 COLOR_PRIMARY_BT601_525 = 6, 791 COLOR_PRIMARY_SMPTE_ST240 = 7, 792 COLOR_PRIMARY_GENERIC_FILM = 8, 793 COLOR_PRIMARY_BT2020 = 9, 794 COLOR_PRIMARY_SMPTE_ST428 = 10, 795 COLOR_PRIMARY_P3DCI = 11, 796 COLOR_PRIMARY_P3D65 = 12, 797} OH_ColorPrimary; 798 799/** 800 * @brief Transfer Characteristic 801 * @syscap SystemCapability.Multimedia.Media.CodecBase 802 * @since 10 803 */ 804typedef enum OH_TransferCharacteristic { 805 TRANSFER_CHARACTERISTIC_BT709 = 1, 806 TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2, 807 TRANSFER_CHARACTERISTIC_GAMMA_2_2 = 4, 808 TRANSFER_CHARACTERISTIC_GAMMA_2_8 = 5, 809 TRANSFER_CHARACTERISTIC_BT601 = 6, 810 TRANSFER_CHARACTERISTIC_SMPTE_ST240 = 7, 811 TRANSFER_CHARACTERISTIC_LINEAR = 8, 812 TRANSFER_CHARACTERISTIC_LOG = 9, 813 TRANSFER_CHARACTERISTIC_LOG_SQRT = 10, 814 TRANSFER_CHARACTERISTIC_IEC_61966_2_4 = 11, 815 TRANSFER_CHARACTERISTIC_BT1361 = 12, 816 TRANSFER_CHARACTERISTIC_IEC_61966_2_1 = 13, 817 TRANSFER_CHARACTERISTIC_BT2020_10BIT = 14, 818 TRANSFER_CHARACTERISTIC_BT2020_12BIT = 15, 819 TRANSFER_CHARACTERISTIC_PQ = 16, 820 TRANSFER_CHARACTERISTIC_SMPTE_ST428 = 17, 821 TRANSFER_CHARACTERISTIC_HLG = 18, 822} OH_TransferCharacteristic; 823 824/** 825 * @brief Matrix Coefficient 826 * @syscap SystemCapability.Multimedia.Media.CodecBase 827 * @since 10 828 */ 829typedef enum OH_MatrixCoefficient { 830 MATRIX_COEFFICIENT_IDENTITY = 0, 831 MATRIX_COEFFICIENT_BT709 = 1, 832 MATRIX_COEFFICIENT_UNSPECIFIED = 2, 833 MATRIX_COEFFICIENT_FCC = 4, 834 MATRIX_COEFFICIENT_BT601_625 = 5, 835 MATRIX_COEFFICIENT_BT601_525 = 6, 836 MATRIX_COEFFICIENT_SMPTE_ST240 = 7, 837 MATRIX_COEFFICIENT_YCGCO = 8, 838 MATRIX_COEFFICIENT_BT2020_NCL = 9, 839 MATRIX_COEFFICIENT_BT2020_CL = 10, 840 MATRIX_COEFFICIENT_SMPTE_ST2085 = 11, 841 MATRIX_COEFFICIENT_CHROMATICITY_NCL = 12, 842 MATRIX_COEFFICIENT_CHROMATICITY_CL = 13, 843 MATRIX_COEFFICIENT_ICTCP = 14, 844} OH_MatrixCoefficient; 845 846/** 847 * @brief AVC Level. 848 * 849 * @syscap SystemCapability.Multimedia.Media.CodecBase 850 * @since 12 851 */ 852typedef enum OH_AVCLevel { 853 AVC_LEVEL_1 = 0, 854 AVC_LEVEL_1b = 1, 855 AVC_LEVEL_11 = 2, 856 AVC_LEVEL_12 = 3, 857 AVC_LEVEL_13 = 4, 858 AVC_LEVEL_2 = 5, 859 AVC_LEVEL_21 = 6, 860 AVC_LEVEL_22 = 7, 861 AVC_LEVEL_3 = 8, 862 AVC_LEVEL_31 = 9, 863 AVC_LEVEL_32 = 10, 864 AVC_LEVEL_4 = 11, 865 AVC_LEVEL_41 = 12, 866 AVC_LEVEL_42 = 13, 867 AVC_LEVEL_5 = 14, 868 AVC_LEVEL_51 = 15, 869 AVC_LEVEL_52 = 16, 870 AVC_LEVEL_6 = 17, 871 AVC_LEVEL_61 = 18, 872 AVC_LEVEL_62 = 19, 873} OH_AVCLevel; 874 875/** 876 * @brief HEVC Level. 877 * 878 * @syscap SystemCapability.Multimedia.Media.CodecBase 879 * @since 12 880 */ 881typedef enum OH_HEVCLevel { 882 HEVC_LEVEL_1 = 0, 883 HEVC_LEVEL_2 = 1, 884 HEVC_LEVEL_21 = 2, 885 HEVC_LEVEL_3 = 3, 886 HEVC_LEVEL_31 = 4, 887 HEVC_LEVEL_4 = 5, 888 HEVC_LEVEL_41 = 6, 889 HEVC_LEVEL_5 = 7, 890 HEVC_LEVEL_51 = 8, 891 HEVC_LEVEL_52 = 9, 892 HEVC_LEVEL_6 = 10, 893 HEVC_LEVEL_61 = 11, 894 HEVC_LEVEL_62 = 12, 895} OH_HEVCLevel; 896 897/** 898 * @brief The reference mode in temporal group of picture. 899 * 900 * @syscap SystemCapability.Multimedia.Media.CodecBase 901 * @since 12 902 */ 903typedef enum OH_TemporalGopReferenceMode { 904 /** Refer to latest short-term reference frame. */ 905 ADJACENT_REFERENCE = 0, 906 /** Refer to latest long-term reference frame. */ 907 JUMP_REFERENCE = 1, 908 /** Uniformly scaled reference structure, which has even distribution of video frames after drop the highest 909 * enhance layer. The temporal group of pictures must be power of 2. */ 910 UNIFORMLY_SCALED_REFERENCE = 2, 911} OH_TemporalGopReferenceMode; 912 913#ifdef __cplusplus 914} 915#endif 916 917#endif // NATIVE_AVCODEC_BASE_H 918