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 25 extern "C" { 26 #endif 27 28 typedef struct NativeWindow OHNativeWindow; 29 typedef 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 */ 41 typedef 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 */ 54 typedef 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 */ 69 typedef 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 */ 87 typedef 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 */ 100 typedef 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 */ 112 typedef 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 */ 128 typedef 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 */ 146 typedef 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 */ 162 typedef 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 */ 169 typedef 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 */ 190 extern const char *OH_AVCODEC_MIMETYPE_VIDEO_AVC; 191 extern 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 */ 198 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_FLAC; 199 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VORBIS; 200 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_MPEG; 201 extern 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 */ 209 extern 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 */ 216 extern const char *OH_AVCODEC_MIMETYPE_IMAGE_JPG; 217 extern const char *OH_AVCODEC_MIMETYPE_IMAGE_PNG; 218 extern 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 */ 225 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VIVID; 226 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_NB; 227 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_WB; 228 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_OPUS; 229 extern 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 */ 237 extern 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 */ 245 extern 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 */ 253 extern 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 */ 261 extern 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 */ 269 extern 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 */ 278 extern const char *OH_ED_KEY_TIME_STAMP; 279 /* Key for endOfStream in surface's extraData, value type is bool */ 280 extern 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. */ 289 extern const char *OH_MD_KEY_TRACK_TYPE; 290 /* Key for codec mime type, value type is string. */ 291 extern const char *OH_MD_KEY_CODEC_MIME; 292 /* Key for file duration, value type is int64_t. */ 293 extern const char *OH_MD_KEY_DURATION; 294 /* Key for bitrate, value type is int64_t. */ 295 extern const char *OH_MD_KEY_BITRATE; 296 /* Key for max input size, value type is int32_t */ 297 extern const char *OH_MD_KEY_MAX_INPUT_SIZE; 298 /* Key for video width, value type is int32_t */ 299 extern const char *OH_MD_KEY_WIDTH; 300 /* Key for video height, value type is int32_t */ 301 extern const char *OH_MD_KEY_HEIGHT; 302 /* Key for video pixel format, value type is int32_t, see @OH_AVPixelFormat */ 303 extern const char *OH_MD_KEY_PIXEL_FORMAT; 304 /* key for audio raw format, value type is int32_t , see @OH_BitsPerSample */ 305 extern const char *OH_MD_KEY_AUDIO_SAMPLE_FORMAT; 306 /* Key for video frame rate, value type is double. */ 307 extern const char *OH_MD_KEY_FRAME_RATE; 308 /* video encode bitrate mode, the value type is int32_t, see @OH_VideoEncodeBitrateMode */ 309 extern 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. */ 311 extern const char *OH_MD_KEY_PROFILE; 312 /* Key for audio channel count, value type is int32_t */ 313 extern const char *OH_MD_KEY_AUD_CHANNEL_COUNT; 314 /* Key for audio sample rate, value type is int32_t */ 315 extern 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 */ 323 extern 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. */ 325 extern 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 */ 333 extern const char *OH_MD_KEY_RANGE_FLAG; 334 /* Key for video color primaries, value type is int32_t, see @OH_ColorPrimary */ 335 extern const char *OH_MD_KEY_COLOR_PRIMARIES; 336 /* Key for video transfer characteristics, value type is int32_t, see @OH_TransferCharacteristic */ 337 extern const char *OH_MD_KEY_TRANSFER_CHARACTERISTICS; 338 /* Key for video matrix coefficients, value type is int32_t, see @OH_MatrixCoefficient */ 339 extern const char *OH_MD_KEY_MATRIX_COEFFICIENTS; 340 /* Key for the request an I-Frame immediately, value type is bool */ 341 extern 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 */ 344 extern const char *OH_MD_KEY_QUALITY; 345 /* Key of the codec specific data. value type is a uint8_t pointer */ 346 extern const char *OH_MD_KEY_CODEC_CONFIG; 347 /* source format Key for title, value type is string */ 348 extern const char *OH_MD_KEY_TITLE; 349 /* source format Key for artist, value type is string */ 350 extern const char *OH_MD_KEY_ARTIST; 351 /* source format Key for album, value type is string */ 352 extern const char *OH_MD_KEY_ALBUM; 353 /* source format Key for album artist, value type is string */ 354 extern const char *OH_MD_KEY_ALBUM_ARTIST; 355 /* source format Key for date, value type is string */ 356 extern const char *OH_MD_KEY_DATE; 357 /* source format Key for comment, value type is string */ 358 extern const char *OH_MD_KEY_COMMENT; 359 /* source format Key for genre, value type is string */ 360 extern const char *OH_MD_KEY_GENRE; 361 /* source format Key for copyright, value type is string */ 362 extern const char *OH_MD_KEY_COPYRIGHT; 363 /* source format Key for language, value type is string */ 364 extern const char *OH_MD_KEY_LANGUAGE; 365 /* source format Key for description, value type is string */ 366 extern const char *OH_MD_KEY_DESCRIPTION; 367 /* source format Key for lyrics, value type is string */ 368 extern const char *OH_MD_KEY_LYRICS; 369 /* source format Key for track count, value type is int32_t */ 370 extern 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 */ 372 extern 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 */ 374 extern const char *OH_MD_KEY_BITS_PER_CODED_SAMPLE; 375 /* Key for the aac format, value type is int32_t, supported for aac decoder */ 376 extern const char *OH_MD_KEY_AAC_IS_ADTS; 377 /* Key for aac sbr mode, value type is int32_t, supported for aac encoder */ 378 extern const char *OH_MD_KEY_SBR; 379 /* Key for flac compliance level, value type is int32_t */ 380 extern 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 */ 382 extern 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 */ 384 extern const char *OH_MD_KEY_SETUP_HEADER; 385 /* Key for video scale type, value type is int32_t, see @OH_ScalingMode */ 386 extern const char *OH_MD_KEY_SCALING_MODE; 387 /* Key for max input buffer count, value type is int32_t */ 388 extern const char *OH_MD_MAX_INPUT_BUFFER_COUNT; 389 /* Key for max output buffer count, value type is int32_t */ 390 extern 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 */ 398 extern const char *OH_MD_KEY_AUDIO_COMPRESSION_LEVEL; 399 /* Key of the video is hdr vivid. value type is bool */ 400 extern const char *OH_MD_KEY_VIDEO_IS_HDR_VIVID; 401 /* Key for number of audio objects. value type is int32_t */ 402 extern const char *OH_MD_KEY_AUDIO_OBJECT_NUMBER; 403 /* Key for meta data of audio vivid. value type is a uint8_t pointer */ 404 extern 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 */ 414 extern 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 */ 424 extern 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 */ 432 extern 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 */ 441 extern 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 */ 451 extern 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 */ 460 extern 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 */ 468 extern 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 */ 477 extern 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 */ 485 extern 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 */ 493 extern 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 */ 501 extern 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 */ 509 extern 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 */ 517 extern 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 */ 527 extern 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 */ 538 extern 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 */ 547 extern 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 */ 556 extern 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 */ 566 extern 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 */ 574 extern 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 */ 582 extern 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 */ 591 extern 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 */ 600 extern 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 */ 607 extern 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 */ 614 extern 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 */ 621 extern 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 */ 628 extern 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 */ 635 extern 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 */ 649 extern const char *OH_MD_KEY_VIDEO_DECODER_OUTPUT_COLOR_SPACE; 650 651 /** 652 * @brief Media type. 653 * @syscap SystemCapability.Multimedia.Media.CodecBase 654 * @since 9 655 * @version 1.0 656 */ 657 typedef enum OH_MediaType { 658 /* track is audio. */ 659 MEDIA_TYPE_AUD = 0, 660 /* track is video. */ 661 MEDIA_TYPE_VID = 1, 662 /** track is subtitle. 663 * @since 12 664 */ 665 MEDIA_TYPE_SUBTITLE = 2, 666 } OH_MediaType; 667 668 /** 669 * @brief AAC Profile 670 * @syscap SystemCapability.Multimedia.Media.CodecBase 671 * @since 9 672 * @version 1.0 673 */ 674 typedef enum OH_AACProfile { 675 AAC_PROFILE_LC = 0, 676 } OH_AACProfile; 677 678 /** 679 * @brief AVC Profile 680 * @syscap SystemCapability.Multimedia.Media.CodecBase 681 * @since 9 682 * @version 1.0 683 */ 684 typedef enum OH_AVCProfile { 685 AVC_PROFILE_BASELINE = 0, 686 AVC_PROFILE_HIGH = 4, 687 AVC_PROFILE_MAIN = 8, 688 } OH_AVCProfile; 689 690 /** 691 * @brief HEVC Profile 692 * @syscap SystemCapability.Multimedia.Media.CodecBase 693 * @since 10 694 */ 695 typedef enum OH_HEVCProfile { 696 HEVC_PROFILE_MAIN = 0, 697 HEVC_PROFILE_MAIN_10 = 1, 698 HEVC_PROFILE_MAIN_STILL = 2, 699 HEVC_PROFILE_MAIN_10_HDR10 = 3, 700 HEVC_PROFILE_MAIN_10_HDR10_PLUS = 4, 701 } OH_HEVCProfile; 702 703 /** 704 * @brief Enumerates the muxer output file format 705 * @syscap SystemCapability.Multimedia.Media.CodecBase 706 * @since 10 707 */ 708 typedef enum OH_AVOutputFormat { 709 AV_OUTPUT_FORMAT_DEFAULT = 0, 710 AV_OUTPUT_FORMAT_MPEG_4 = 2, 711 AV_OUTPUT_FORMAT_M4A = 6, 712 /** 713 * The muxer output amr file format. 714 * @since 12 715 */ 716 AV_OUTPUT_FORMAT_AMR = 8, 717 /** 718 * The muxer output mp3 file format. 719 * @since 12 720 */ 721 AV_OUTPUT_FORMAT_MP3 = 9, 722 /** 723 * The muxer output wav file format. 724 * @since 12 725 */ 726 AV_OUTPUT_FORMAT_WAV = 10, 727 } OH_AVOutputFormat; 728 729 /** 730 * @brief Seek Mode 731 * @syscap SystemCapability.Multimedia.Media.CodecBase 732 * @since 10 733 */ 734 typedef enum OH_AVSeekMode { 735 /* seek to sync sample after the time */ 736 SEEK_MODE_NEXT_SYNC = 0, 737 /* seek to sync sample before the time */ 738 SEEK_MODE_PREVIOUS_SYNC, 739 /* seek to sync sample closest to time */ 740 SEEK_MODE_CLOSEST_SYNC, 741 } OH_AVSeekMode; 742 743 /** 744 * @brief Scaling Mode 745 * @syscap SystemCapability.Multimedia.Media.CodecBase 746 * @since 10 747 */ 748 typedef enum OH_ScalingMode { 749 SCALING_MODE_SCALE_TO_WINDOW = 1, 750 SCALING_MODE_SCALE_CROP = 2, 751 } OH_ScalingMode; 752 753 /** 754 * @brief enum Audio Bits Per Coded Sample 755 * @syscap SystemCapability.Multimedia.Media.CodecBase 756 * @since 10 757 */ 758 typedef enum OH_BitsPerSample { 759 SAMPLE_U8 = 0, 760 SAMPLE_S16LE = 1, 761 SAMPLE_S24LE = 2, 762 SAMPLE_S32LE = 3, 763 SAMPLE_F32LE = 4, 764 SAMPLE_U8P = 5, 765 SAMPLE_S16P = 6, 766 SAMPLE_S24P = 7, 767 SAMPLE_S32P = 8, 768 SAMPLE_F32P = 9, 769 INVALID_WIDTH = -1 770 } OH_BitsPerSample; 771 772 /** 773 * @brief Color Primary 774 * @syscap SystemCapability.Multimedia.Media.CodecBase 775 * @since 10 776 */ 777 typedef enum OH_ColorPrimary { 778 COLOR_PRIMARY_BT709 = 1, 779 COLOR_PRIMARY_UNSPECIFIED = 2, 780 COLOR_PRIMARY_BT470_M = 4, 781 COLOR_PRIMARY_BT601_625 = 5, 782 COLOR_PRIMARY_BT601_525 = 6, 783 COLOR_PRIMARY_SMPTE_ST240 = 7, 784 COLOR_PRIMARY_GENERIC_FILM = 8, 785 COLOR_PRIMARY_BT2020 = 9, 786 COLOR_PRIMARY_SMPTE_ST428 = 10, 787 COLOR_PRIMARY_P3DCI = 11, 788 COLOR_PRIMARY_P3D65 = 12, 789 } OH_ColorPrimary; 790 791 /** 792 * @brief Transfer Characteristic 793 * @syscap SystemCapability.Multimedia.Media.CodecBase 794 * @since 10 795 */ 796 typedef enum OH_TransferCharacteristic { 797 TRANSFER_CHARACTERISTIC_BT709 = 1, 798 TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2, 799 TRANSFER_CHARACTERISTIC_GAMMA_2_2 = 4, 800 TRANSFER_CHARACTERISTIC_GAMMA_2_8 = 5, 801 TRANSFER_CHARACTERISTIC_BT601 = 6, 802 TRANSFER_CHARACTERISTIC_SMPTE_ST240 = 7, 803 TRANSFER_CHARACTERISTIC_LINEAR = 8, 804 TRANSFER_CHARACTERISTIC_LOG = 9, 805 TRANSFER_CHARACTERISTIC_LOG_SQRT = 10, 806 TRANSFER_CHARACTERISTIC_IEC_61966_2_4 = 11, 807 TRANSFER_CHARACTERISTIC_BT1361 = 12, 808 TRANSFER_CHARACTERISTIC_IEC_61966_2_1 = 13, 809 TRANSFER_CHARACTERISTIC_BT2020_10BIT = 14, 810 TRANSFER_CHARACTERISTIC_BT2020_12BIT = 15, 811 TRANSFER_CHARACTERISTIC_PQ = 16, 812 TRANSFER_CHARACTERISTIC_SMPTE_ST428 = 17, 813 TRANSFER_CHARACTERISTIC_HLG = 18, 814 } OH_TransferCharacteristic; 815 816 /** 817 * @brief Matrix Coefficient 818 * @syscap SystemCapability.Multimedia.Media.CodecBase 819 * @since 10 820 */ 821 typedef enum OH_MatrixCoefficient { 822 MATRIX_COEFFICIENT_IDENTITY = 0, 823 MATRIX_COEFFICIENT_BT709 = 1, 824 MATRIX_COEFFICIENT_UNSPECIFIED = 2, 825 MATRIX_COEFFICIENT_FCC = 4, 826 MATRIX_COEFFICIENT_BT601_625 = 5, 827 MATRIX_COEFFICIENT_BT601_525 = 6, 828 MATRIX_COEFFICIENT_SMPTE_ST240 = 7, 829 MATRIX_COEFFICIENT_YCGCO = 8, 830 MATRIX_COEFFICIENT_BT2020_NCL = 9, 831 MATRIX_COEFFICIENT_BT2020_CL = 10, 832 MATRIX_COEFFICIENT_SMPTE_ST2085 = 11, 833 MATRIX_COEFFICIENT_CHROMATICITY_NCL = 12, 834 MATRIX_COEFFICIENT_CHROMATICITY_CL = 13, 835 MATRIX_COEFFICIENT_ICTCP = 14, 836 } OH_MatrixCoefficient; 837 838 /** 839 * @brief AVC Level. 840 * 841 * @syscap SystemCapability.Multimedia.Media.CodecBase 842 * @since 12 843 */ 844 typedef enum OH_AVCLevel { 845 AVC_LEVEL_1 = 0, 846 AVC_LEVEL_1b = 1, 847 AVC_LEVEL_11 = 2, 848 AVC_LEVEL_12 = 3, 849 AVC_LEVEL_13 = 4, 850 AVC_LEVEL_2 = 5, 851 AVC_LEVEL_21 = 6, 852 AVC_LEVEL_22 = 7, 853 AVC_LEVEL_3 = 8, 854 AVC_LEVEL_31 = 9, 855 AVC_LEVEL_32 = 10, 856 AVC_LEVEL_4 = 11, 857 AVC_LEVEL_41 = 12, 858 AVC_LEVEL_42 = 13, 859 AVC_LEVEL_5 = 14, 860 AVC_LEVEL_51 = 15, 861 AVC_LEVEL_52 = 16, 862 AVC_LEVEL_6 = 17, 863 AVC_LEVEL_61 = 18, 864 AVC_LEVEL_62 = 19, 865 } OH_AVCLevel; 866 867 /** 868 * @brief HEVC Level. 869 * 870 * @syscap SystemCapability.Multimedia.Media.CodecBase 871 * @since 12 872 */ 873 typedef enum OH_HEVCLevel { 874 HEVC_LEVEL_1 = 0, 875 HEVC_LEVEL_2 = 1, 876 HEVC_LEVEL_21 = 2, 877 HEVC_LEVEL_3 = 3, 878 HEVC_LEVEL_31 = 4, 879 HEVC_LEVEL_4 = 5, 880 HEVC_LEVEL_41 = 6, 881 HEVC_LEVEL_5 = 7, 882 HEVC_LEVEL_51 = 8, 883 HEVC_LEVEL_52 = 9, 884 HEVC_LEVEL_6 = 10, 885 HEVC_LEVEL_61 = 11, 886 HEVC_LEVEL_62 = 12, 887 } OH_HEVCLevel; 888 889 /** 890 * @brief The reference mode in temporal group of picture. 891 * 892 * @syscap SystemCapability.Multimedia.Media.CodecBase 893 * @since 12 894 */ 895 typedef enum OH_TemporalGopReferenceMode { 896 /** Refer to latest short-term reference frame. */ 897 ADJACENT_REFERENCE = 0, 898 /** Refer to latest long-term reference frame. */ 899 JUMP_REFERENCE = 1, 900 /** Uniformly scaled reference structure, which has even distribution of video frames after drop the highest 901 * enhance layer. The temporal group of pictures must be power of 2. */ 902 UNIFORMLY_SCALED_REFERENCE = 2, 903 } OH_TemporalGopReferenceMode; 904 905 #ifdef __cplusplus 906 } 907 #endif 908 909 #endif // NATIVE_AVCODEC_BASE_H 910