1# CodecBase 2 3 4## Overview 5 6The **CodecBase** module provides the common structs, character constants, and enums for running **OH_AVCodec** instances. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether your device supports this module. 7 8\@syscap SystemCapability.Multimedia.Media.CodecBase 9 10**Since** 11 129 13 14 15## Summary 16 17 18### Files 19 20| Name| Description| 21| -------- | -------- | 22| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running **OH_AVCodec** instances.<br>**File to include**: <multimedia/player_framework/native_avcodec_base.h><br>**Library**: libnative_media_codecbase.so| 23 24 25### Structs 26 27| Name| Description| 28| -------- | -------- | 29| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the description information about the buffer of an **OH_AVCodec** instance.| 30| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines all the asynchronous callback function pointers of an **OH_AVCodec** instance.| 31 32 33### Types 34 35| Name| Description| 36| -------- | -------- | 37| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Defines an enum that enumerates the flags for the buffer of an **OH_AVCodec** instance.| 38| [OH_AVOutputFormat](#oh_avoutputformat) | Defines an enum that enumerates the output file formats of a muxer.| 39| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines a struct for the description information about the buffer of an **OH_AVCodec** instance.| 40| (\*[OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the pointer to the function that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance.| 41| (\*[OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the pointer to the function that is called to report the new stream description when the output stream changes.| 42| (\*[OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the pointer to the function that is called when new input data is required during the running of an **OH_AVCodec** instance. The function carries a buffer to fill in new input data.| 43| (\*[OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the pointer to the function that is called when new output data is generated during the running of an **OH_AVCodec** instance. The function carries a buffer filled with new output data.| 44| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a struct for all the asynchronous callback function pointers of an **OH_AVCodec** instance.| 45| [OH_MediaType](#oh_mediatype) | Defines an enum that enumerates the media types.| 46| [OH_AVCProfile](#oh_avcprofile) | Defines an enum that enumerates the Advanced Video Coding (AVC) profiles.| 47| [OH_HEVCProfile](#oh_hevcprofile) | Defines an enum that enumerates the High Efficiency Video Coding (HEVC) profiles.| 48| [OH_AACProfile](#oh_aacprofile) | Defines an enum that enumerates the Advanced Audio Coding (AAC) profiles.| 49| [OH_AVSeekMode](#oh_avseekmode) | Defines an enum that enumerates the seek modes.| 50| [OH_ColorPrimary](#oh_colorprimary) | Defines an enum that enumerates the primary colors.| 51| [OH_TransferCharacteristic](#oh_transfercharacteristic) | Defines an enum that enumerates the transfer characteristics.| 52| [OH_MatrixCoefficient](#oh_matrixcoefficient) | Defines an enum that enumerates the matrix coefficients.| 53| [OH_BitsPerSample](#oh_bitspersample) | Defines an enum that enumerates the number of audio bits for each coded sample.| 54 55 56### Enums 57 58| Name| Description| 59| -------- | -------- | 60| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {<br> **AVCODEC_BUFFER_FLAGS_NONE** = 0,<br> **AVCODEC_BUFFER_FLAGS_EOS** = 1 << 0,<br> **AVCODEC_BUFFER_FLAGS_SYNC_FRAME** = 1 << 1,<br> **AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME** = 1 << 2,<br> **AVCODEC_BUFFER_FLAGS_CODEC_DATA** = 1 << 3<br>} | Enumerates the flags for the buffer of an **OH_AVCodec** instance.| 61| [OH_AVOutputFormat](#oh_avoutputformat) {<br> **AV_OUTPUT_FORMAT_DEFAULT** = 0,<br> **AV_OUTPUT_FORMAT_MPEG_4** = 2,<br> **AV_OUTPUT_FORMAT_M4A** = 6<br>} | Enumerates the output file formats of a muxer.| 62| [OH_MediaType](#oh_mediatype) {<br> **MEDIA_TYPE_AUD** = 0,<br> **MEDIA_TYPE_VID** = 1<br>} | Enumerates the media types.| 63| [OH_AVCProfile](#oh_avcprofile) {<br> **AVC_PROFILE_BASELINE** = 0,<br> **AVC_PROFILE_HIGH** = 4,<br> **AVC_PROFILE_MAIN** = 8<br>} | Enumerates the AVC profiles.| 64| [OH_HEVCProfile](#oh_hevcprofile) {<br> **HEVC_PROFILE_MAIN** = 0,<br> **HEVC_PROFILE_MAIN_10** = 1,<br> **HEVC_PROFILE_MAIN_STILL** = 2,<br> **HEVC_PROFILE_MAIN_10_HDR10** = 3,<br> **HEVC_PROFILE_MAIN_10_HDR10_PLUS** = 4<br>} | Enumerates the HEVC profiles.| 65| [OH_AACProfile](#oh_aacprofile) {<br> **AAC_PROFILE_LC** = 0<br>} | Enumerates the AAC profiles.| 66| [OH_AVSeekMode](#oh_avseekmode) {<br> **SEEK_MODE_NEXT_SYNC** = 0,<br> **SEEK_MODE_PREVIOUS_SYNC**,<br> **SEEK_MODE_CLOSEST_SYNC**<br>} | Enumerates the seek modes.| 67| [OH_ColorPrimary](#oh_colorprimary) {<br> **COLOR_PRIMARY_BT709** = 1,<br> **COLOR_PRIMARY_UNSPECIFIED** = 2,<br> **COLOR_PRIMARY_BT470_M** = 4,<br> **COLOR_PRIMARY_BT601_625** = 5,<br> **COLOR_PRIMARY_BT601_525** = 6,<br> **COLOR_PRIMARY_SMPTE_ST240** = 7,<br> **COLOR_PRIMARY_GENERIC_FILM** = 8,<br> **COLOR_PRIMARY_BT2020** = 9,<br> **COLOR_PRIMARY_SMPTE_ST428** = 10,<br> **COLOR_PRIMARY_P3DCI** = 11,<br> **COLOR_PRIMARY_P3D65** = 12<br>} | Enumerates the primary colors.| 68| [OH_TransferCharacteristic](#oh_transfercharacteristic) {<br> **TRANSFER_CHARACTERISTIC_BT709** = 1,<br> **TRANSFER_CHARACTERISTIC_UNSPECIFIED** = 2,<br> **TRANSFER_CHARACTERISTIC_GAMMA_2_2** = 4,<br> **TRANSFER_CHARACTERISTIC_GAMMA_2_8** = 5,<br> **TRANSFER_CHARACTERISTIC_BT601** = 6,<br> **TRANSFER_CHARACTERISTIC_SMPTE_ST240** = 7,<br> **TRANSFER_CHARACTERISTIC_LINEAR** = 8,<br> **TRANSFER_CHARACTERISTIC_LOG** = 9,<br> **TRANSFER_CHARACTERISTIC_LOG_SQRT** = 10,<br> **TRANSFER_CHARACTERISTIC_IEC_61966_2_4** = 11,<br> **TRANSFER_CHARACTERISTIC_BT1361** = 12,<br> **TRANSFER_CHARACTERISTIC_IEC_61966_2_1** = 13,<br> **TRANSFER_CHARACTERISTIC_BT2020_10BIT** = 14,<br> **TRANSFER_CHARACTERISTIC_BT2020_12BIT** = 15,<br> **TRANSFER_CHARACTERISTIC_PQ** = 16,<br> **TRANSFER_CHARACTERISTIC_SMPTE_ST428** = 17,<br> **TRANSFER_CHARACTERISTIC_HLG** = 18<br>} | Enumerates the transfer characteristics.| 69| [OH_MatrixCoefficient](#oh_matrixcoefficient) {<br> **MATRIX_COEFFICIENT_IDENTITY** = 0,<br> **MATRIX_COEFFICIENT_BT709** = 1,<br> **MATRIX_COEFFICIENT_UNSPECIFIED** = 2,<br> **MATRIX_COEFFICIENT_FCC** = 4,<br> **MATRIX_COEFFICIENT_BT601_625** = 5,<br> **MATRIX_COEFFICIENT_BT601_525** = 6,<br> **MATRIX_COEFFICIENT_SMPTE_ST240** = 7,<br> **MATRIX_COEFFICIENT_YCGCO** = 8,<br> **MATRIX_COEFFICIENT_BT2020_NCL** = 9,<br> **MATRIX_COEFFICIENT_BT2020_CL** = 10,<br> **MATRIX_COEFFICIENT_SMPTE_ST2085** = 11,<br> **MATRIX_COEFFICIENT_CHROMATICITY_NCL** = 12,<br> **MATRIX_COEFFICIENT_CHROMATICITY_CL** = 13,<br> **MATRIX_COEFFICIENT_ICTCP** = 14<br>} | Enumerates the matrix coefficients.| 70| [OH_BitsPerSample](#oh_bitspersample) {<br> **SAMPLE_U8** = 0,<br> **SAMPLE_S16LE** = 1,<br> **SAMPLE_S24LE** = 2,<br> **SAMPLE_S32LE** = 3,<br> **SAMPLE_F32LE** = 4,<br> **SAMPLE_U8P** = 5,<br> **SAMPLE_S16P** = 6,<br> **SAMPLE_S24P** = 7,<br> **SAMPLE_S32P** = 8,<br> **SAMPLE_F32P** = 9,<br> **INVALID_WIDTH** = -1<br>} | Enumerates the number of audio bits for each coded sample.| 71 72 73### Variables 74 75| Name| Description| 76| -------- | -------- | 77| [OH_AVCodecBufferAttr::pts](_o_h___a_v_codec_buffer_attr.md#pts) | Defines the display timestamp of the buffer, in microseconds.| 78| [OH_AVCodecBufferAttr::size](_o_h___a_v_codec_buffer_attr.md#size) | Defines the size of data contained in the buffer, in bytes.| 79| [OH_AVCodecBufferAttr::offset](_o_h___a_v_codec_buffer_attr.md#offset) | Defines the offset of valid data in the buffer.| 80| [OH_AVCodecBufferAttr::flags](_o_h___a_v_codec_buffer_attr.md#flags) | Defines the flags of the buffer. It is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags).| 81| [OH_AVCodecAsyncCallback::onError](_o_h___a_v_codec_async_callback.md#onerror) | Defines the callback used to report a codec operation error. For details, see [OH_AVCodecOnError](#oh_avcodeconerror).| 82| [OH_AVCodecAsyncCallback::onStreamChanged](_o_h___a_v_codec_async_callback.md#onstreamchanged) | Defines the callback used to report a codec stream change. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged).| 83| [OH_AVCodecAsyncCallback::onNeedInputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Defines the callback used to report input data required. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata).| 84| [OH_AVCodecAsyncCallback::onNeedOutputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Defines the callback used to report output data generated. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata).| 85| \*[OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the pointer to the Multipurpose Internet Mail Extension (MIME) type for AVC video codec.| 86| \*[OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the pointer to the MIME type for AAC audio codec.| 87| \*[OH_AVCODEC_MIMETYPE_VIDEO_MPEG4](#oh_avcodec_mimetype_video_mpeg4) | Defines the pointer to the MIME type for MPEG4 video codec.| 88| \*[OH_AVCODEC_MIMETYPE_VIDEO_HEVC](#oh_avcodec_mimetype_video_hevc) | Defines the pointer to the MIME type for HEVC video codec.| 89| \*[OH_AVCODEC_MIMETYPE_AUDIO_MPEG](#oh_avcodec_mimetype_audio_mpeg) | Defines the pointer to the MIME type for MPEG audio codec.| 90| \*[OH_AVCODEC_MIMETYPE_IMAGE_JPG](#oh_avcodec_mimetype_image_jpg) | Defines the pointer to the MIME type for JPG image codec.| 91| \*[OH_AVCODEC_MIMETYPE_IMAGE_PNG](#oh_avcodec_mimetype_image_png) | Defines the pointer to the MIME type for PNG image codec.| 92| \*[OH_AVCODEC_MIMETYPE_IMAGE_BMP](#oh_avcodec_mimetype_image_bmp) | Defines the pointer to the MIME type for BMP image codec.| 93| \*[OH_AVCODEC_MIMETYPE_AUDIO_FLAC](#oh_avcodec_mimetype_audio_flac) | Defines the pointer to the MIME type for FLAC audio codec.| 94| \*[OH_AVCODEC_MIMETYPE_AUDIO_VORBIS](#oh_avcodec_mimetype_audio_vorbis) | Defines the pointer to the MIME type for VORBIS audio codec.| 95| \*[OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Defines the pointer to the timestamp in the extra data of the surface. The value type is int64.| 96| \*[OH_ED_KEY_EOS](#oh_ed_key_eos) | Defines the pointer to the end of stream (EOS) in the extra data of the surface. The value type is Boolean.| 97| \*[OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Defines the pointer to a container for storing media descriptions.| 98| \*[OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Define the pointer to the MIME type of codec. The value is a string.| 99| \*[OH_MD_KEY_DURATION](#oh_md_key_duration) | Defines the pointer to the duration. The value type is int64_t.| 100| \*[OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Defines the pointer to the bit rate. The value type is uint32_t. In the case of video encoding, you must set [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode), which specifies the bit rate.| 101| \*[OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Defines the pointer to the maximum input size. The value type is uint32_t.| 102| \*[OH_MD_KEY_WIDTH](#oh_md_key_width) | Defines the pointer to the video width. The value type is uint32_t.| 103| \*[OH_MD_KEY_HEIGHT](#oh_md_key_height) | Defines the pointer to the video height. The value type is uint32_t.| 104| \*[OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Defines the pointer to the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).| 105| \*[OH_MD_KEY_RANGE_FLAG](#oh_md_key_range_flag) | Defines the pointer to the video YUV value range flag. The value type is Boolean.| 106| \*[OH_MD_KEY_COLOR_PRIMARIES](#oh_md_key_color_primaries) | Defines the pointer to the primary color of the video. The value type is int32_t.| 107| \*[OH_MD_KEY_TRANSFER_CHARACTERISTICS](#oh_md_key_transfer_characteristics) | Defines the pointer to the video transfer characteristics. The value type is int32_t.| 108| \*[OH_MD_KEY_MATRIX_COEFFICIENTS](#oh_md_key_matrix_coefficients) | Defines the pointer to the video matrix coefficient. The value type is int32_t.| 109| \*[OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Defines the pointer to the original audio format. The value type is uint32_t.| 110| \*[OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Defines the pointer to the video frame rate. The value is a double-precision floating point number.| 111| \*[OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Defines the pointer to the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).| 112| \*[OH_MD_KEY_PROFILE](#oh_md_key_profile) | Defines the pointer to the encoding template. The value is a number. For details, see [OH_AVCProfile](#oh_avcprofile), [OH_AACProfile](#oh_aacprofile), or [OH_HEVCProfile](#oh_hevcprofile).| 113| \*[OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Defines the pointer to the number of audio channels. The value type is uint32_t.| 114| \*[OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Defines the pointer to the audio sampling rate. The value type is uint32_t.| 115| \*[OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Defines the pointer to the key frame interval, in milliseconds. The value type is int32_t.| 116| \*[OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Defines the pointer to the rotation angle of the surface. The value type is int32_t, and the value range is {0, 90, 180, 270}. The default value is 0.| 117| \*[OH_MD_KEY_CODEC_CONFIG](#oh_md_key_codec_config) | Defines the pointer to the codec-specific data. The value type is uint8_t\*.| 118| \*[OH_MD_KEY_REQUEST_I_FRAME](#oh_md_key_request_i_frame) | Defines the pointer to the request for immediate encoding of I-frames. The value type is Boolean.| 119| \*[OH_MD_KEY_QUALITY](#oh_md_key_quality) | Defines the pointer to the required encoding quality. The value type is uint32_t. This key applies only to encoders configured in constant quality mode.| 120| \*[OH_MD_KEY_CHANNEL_LAYOUT](#oh_md_key_channel_layout) | Defines the pointer to the required encoding channel layout. The value type is int64_t. This key applies only to encoders.| 121| \*[OH_MD_KEY_BITS_PER_CODED_SAMPLE](#oh_md_key_bits_per_coded_sample) | Defines the pointer to the number of bits for each coded sample. The value type is uint32_t. This key applies to FLAC encoders. For details, see **\@OH_BitsPerSample**.| 122| \*[OH_MD_KEY_AAC_IS_ADTS](#oh_md_key_aac_is_adts) | Defines the pointer to the AAC format. The value type is uint32_t. This key applies to AAC decoders.| 123| \*[OH_MD_KEY_SBR](#oh_md_key_sbr) | Defines the pointer to the AAC SBR format. The value type is uint32_t. This key applies to AAC encoders.| 124| \*[OH_MD_KEY_COMPLIANCE_LEVEL](#oh_md_key_compliance_level) | Defines the pointer to the FLAC compliance level. The value type is int32_t.| 125| \*[OH_MD_KEY_IDENTIFICATION_HEADER](#oh_md_key_identification_header) | Defines the pointer to the VORBIS identification header. The value type is uint8_t\*. This key applies only to VORBIS decoders.| 126| \*[OH_MD_KEY_SETUP_HEADER](#oh_md_key_setup_header) | Defines the pointer to the VORBIS setup header. The value type is uint8_t\*. This key applies only to VORBIS decoders.| 127| \*[OH_MD_KEY_TITLE](#oh_md_key_title) | Defines the pointer to the title of the input media. The value is a string.| 128| \*[OH_MD_KEY_ARTIST](#oh_md_key_artist) | Defines the pointer to the artist of the input media. The value is a string.| 129| \*[OH_MD_KEY_ALBUM](#oh_md_key_album) | Defines the pointer to the album of the input media. The value is a string.| 130| \*[OH_MD_KEY_ALBUM_ARTIST](#oh_md_key_album_artist) | Defines the pointer to the album_artist of the input media. The value is a string.| 131| \*[OH_MD_KEY_DATE](#oh_md_key_date) | Defines the pointer to the date of the input media. The value is a string.| 132| \*[OH_MD_KEY_COMMENT](#oh_md_key_comment) | Defines the pointer to the comment of the input media. The value is a string.| 133| \*[OH_MD_KEY_GENRE](#oh_md_key_genre) | Defines the pointer to the genre of the input media. The value is a string.| 134| \*[OH_MD_KEY_COPYRIGHT](#oh_md_key_copyright) | Defines the pointer to the copyright of the input media. The value is a string.| 135| \*[OH_MD_KEY_LANGUAGE](#oh_md_key_language) | Defines the pointer to the language of the input media. The value is a string.| 136| \*[OH_MD_KEY_DESCRIPTION](#oh_md_key_description) | Defines the pointer to the description of the input media. The value is a string.| 137| \*[OH_MD_KEY_LYRICS](#oh_md_key_lyrics) | Defines the pointer to the lyrics of the input media. The value is a string.| 138| \*[OH_MD_KEY_TRACK_COUNT](#oh_md_key_track_count) | Defines the pointer to the track count of the input media. The value type is uint32_t.| 139 140 141## Type Description 142 143 144### OH_AACProfile 145 146 147``` 148typedef enum OH_AACProfile OH_AACProfile 149``` 150 151**Description** 152 153Defines an enum that enumerates the AAC profiles. 154 155\@syscap SystemCapability.Multimedia.Media.CodecBase 156 157 158### OH_AVCodecAsyncCallback 159 160 161``` 162typedef struct OH_AVCodecAsyncCallback OH_AVCodecAsyncCallback 163``` 164 165**Description** 166 167Defines a struct for all the asynchronous callback function pointers of an **OH_AVCodec** instance. To ensure the normal running of **OH_AVCodec**, you must register the instance of this struct with the **OH_AVCodec** instance and process the information reported by the callback function. 168 169\@syscap SystemCapability.Multimedia.Media.CodecBase 170 171**Parameters** 172 173| Name| Description| 174| -------- | -------- | 175| [onError](_o_h___a_v_codec_async_callback.md#onerror) | Callback used to report a codec operation error. For details, see [OH_AVCodecOnError](#oh_avcodeconerror).| 176| [onStreamChanged](_o_h___a_v_codec_async_callback.md#onstreamchanged) | Callback used to report a codec stream change. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged).| 177| [onNeedInputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Callback used to report input data required. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata).| 178| [onNeedOutputData](_o_h___a_v_codec_async_callback.md#onneedoutputdata) | Callback used to report output data generated. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata).| 179 180 181### OH_AVCodecBufferAttr 182 183 184``` 185typedef struct OH_AVCodecBufferAttr OH_AVCodecBufferAttr 186``` 187 188**Description** 189 190Defines a struct for the description information about the buffer of an **OH_AVCodec** instance. 191 192\@syscap SystemCapability.Multimedia.Media.CodecBase 193 194 195### OH_AVCodecBufferFlags 196 197 198``` 199typedef enum OH_AVCodecBufferFlags OH_AVCodecBufferFlags 200``` 201 202**Description** 203 204Defines an enum that enumerates the flags for the buffer of an **OH_AVCodec** instance. 205 206\@syscap SystemCapability.Multimedia.Media.CodecBase 207 208 209### OH_AVCodecOnError 210 211 212``` 213typedef void (*OH_AVCodecOnError) (OH_AVCodec *codec, int32_t errorCode, void *userData) 214``` 215 216**Description** 217 218Defines the pointer to the function that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. 219 220\@syscap SystemCapability.Multimedia.Media.CodecBase 221 222**Parameters** 223 224| Name| Description| 225| -------- | -------- | 226| codec | Pointer to an **OH_AVCodec** instance.| 227| errorCode | Error code.| 228| userData | Pointer to user-specific data.| 229 230 231### OH_AVCodecOnNeedInputData 232 233 234``` 235typedef void (*OH_AVCodecOnNeedInputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData) 236``` 237 238**Description** 239 240Defines the pointer to the function that is called when new input data is required during the running of an **OH_AVCodec** instance. The function carries a buffer to fill in new input data. 241 242\@syscap SystemCapability.Multimedia.Media.CodecBase 243 244**Parameters** 245 246| Name| Description| 247| -------- | -------- | 248| codec | Pointer to an **OH_AVCodec** instance.| 249| index | Index of the new input buffer.| 250| data | Pointer to the data to fill in the new input buffer.| 251| userData | Pointer to user-specific data.| 252 253 254### OH_AVCodecOnNewOutputData 255 256 257``` 258typedef void (*OH_AVCodecOnNewOutputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData) 259``` 260 261**Description** 262 263Defines the pointer to the function that is called when new output data is generated during the running of an **OH_AVCodec** instance. The function carries a buffer filled with new output data. Note that the lifecycle of the pointer to the **OH_AVCodecBufferAttr** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. 264 265\@syscap SystemCapability.Multimedia.Media.CodecBase 266 267**Parameters** 268 269| Name| Description| 270| -------- | -------- | 271| codec | Pointer to an **OH_AVCodec** instance.| 272| index | Index of the new output buffer.| 273| data | Pointer to the data filled in the new output buffer.| 274| attr | Pointer to the description information about the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md).| 275| userData | Pointer to user-specific data.| 276 277 278### OH_AVCodecOnStreamChanged 279 280 281``` 282typedef void (*OH_AVCodecOnStreamChanged) (OH_AVCodec *codec, OH_AVFormat *format, void *userData) 283``` 284 285**Description** 286 287Defines the pointer to the function that is called to report the new stream description when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. 288 289\@syscap SystemCapability.Multimedia.Media.CodecBase 290 291**Parameters** 292 293| Name| Description| 294| -------- | -------- | 295| codec | Pointer to an **OH_AVCodec** instance.| 296| format | Pointer to the description information about the new output stream.| 297| userData | Pointer to user-specific data.| 298 299**format** carries the following fields: 300| Key | Description | 301| ---------------------- | --------------- | 302| OH_MD_KEY_WIDTH | Video output width. | 303| OH_MD_KEY_HEIGHT | Video output height. | 304| OH_MD_KEY_PIXEL_FORMAT | Video output pixel format.| 305 306### OH_AVCProfile 307 308 309``` 310typedef enum OH_AVCProfile OH_AVCProfile 311``` 312 313**Description** 314 315Defines an enum that enumerates the AVC profiles. 316 317\@syscap SystemCapability.Multimedia.Media.CodecBase 318 319 320### OH_AVOutputFormat 321 322 323``` 324typedef enum OH_AVOutputFormat OH_AVOutputFormat 325``` 326 327**Description** 328 329Defines an enum that enumerates the output file formats of a muxer. 330 331 332### OH_AVSeekMode 333 334 335``` 336typedef enum OH_AVSeekMode OH_AVSeekMode 337``` 338 339**Description** 340 341Defines an enum that enumerates the seek modes. 342 343\@syscap SystemCapability.Multimedia.Media.CodecBase 344 345 346### OH_BitsPerSample 347 348 349``` 350typedef enum OH_BitsPerSample OH_BitsPerSample 351``` 352 353**Description** 354 355Defines an enum that enumerates the number of audio bits for each coded sample. 356 357\@syscap SystemCapability.Multimedia.Media.CodecBase 358 359 360### OH_ColorPrimary 361 362 363``` 364typedef enum OH_ColorPrimary OH_ColorPrimary 365``` 366 367**Description** 368 369Defines an enum that enumerates the primary colors. 370 371\@syscap SystemCapability.Multimedia.Media.CodecBase 372 373 374### OH_HEVCProfile 375 376 377``` 378typedef enum OH_HEVCProfile OH_HEVCProfile 379``` 380 381**Description** 382 383Defines an enum that enumerates the HEVC profiles. 384 385\@syscap SystemCapability.Multimedia.Media.CodecBase 386 387 388### OH_MatrixCoefficient 389 390 391``` 392typedef enum OH_MatrixCoefficient OH_MatrixCoefficient 393``` 394 395**Description** 396 397Defines an enum that enumerates the matrix coefficients. 398 399\@syscap SystemCapability.Multimedia.Media.CodecBase 400 401 402### OH_MediaType 403 404 405``` 406typedef enum OH_MediaType OH_MediaType 407``` 408 409**Description** 410 411Defines an enum that enumerates the media types. 412 413\@syscap SystemCapability.Multimedia.Media.CodecBase 414 415 416### OH_TransferCharacteristic 417 418 419``` 420typedef enum OH_TransferCharacteristic OH_TransferCharacteristic 421``` 422 423**Description** 424 425Defines an enum that enumerates the transfer characteristics. 426 427\@syscap SystemCapability.Multimedia.Media.CodecBase 428 429 430## Enum Description 431 432 433### OH_AACProfile 434 435 436``` 437enum OH_AACProfile 438``` 439 440**Description** 441 442Enumerates the AAC profiles. 443 444\@syscap SystemCapability.Multimedia.Media.CodecBase 445 446 447### OH_AVCodecBufferFlags 448 449 450``` 451enum OH_AVCodecBufferFlags 452``` 453 454**Description** 455 456Enumerates the flags for the buffer of an **OH_AVCodec** instance. 457 458\@syscap SystemCapability.Multimedia.Media.CodecBase 459 460 461### OH_AVCProfile 462 463 464``` 465enum OH_AVCProfile 466``` 467 468**Description** 469 470Enumerates the AVC profiles. 471 472\@syscap SystemCapability.Multimedia.Media.CodecBase 473 474 475### OH_AVOutputFormat 476 477 478``` 479enum OH_AVOutputFormat 480``` 481 482**Description** 483 484Enumerates the output file formats of a muxer. 485 486 487### OH_AVSeekMode 488 489 490``` 491enum OH_AVSeekMode 492``` 493 494**Description** 495 496Enumerates the seek modes. 497 498\@syscap SystemCapability.Multimedia.Media.CodecBase 499 500 501### OH_BitsPerSample 502 503 504``` 505enum OH_BitsPerSample 506``` 507 508**Description** 509 510Enumerates the number of audio bits for each coded sample. 511 512\@syscap SystemCapability.Multimedia.Media.CodecBase 513 514 515### OH_ColorPrimary 516 517 518``` 519enum OH_ColorPrimary 520``` 521 522**Description** 523 524Enumerates the primary colors. 525 526\@syscap SystemCapability.Multimedia.Media.CodecBase 527 528 529### OH_HEVCProfile 530 531 532``` 533enum OH_HEVCProfile 534``` 535 536**Description** 537 538Enumerates the HEVC profiles. 539 540\@syscap SystemCapability.Multimedia.Media.CodecBase 541 542 543### OH_MatrixCoefficient 544 545 546``` 547enum OH_MatrixCoefficient 548``` 549 550**Description** 551 552Enumerates the matrix coefficients. 553 554\@syscap SystemCapability.Multimedia.Media.CodecBase 555 556 557### OH_MediaType 558 559 560``` 561enum OH_MediaType 562``` 563 564**Description** 565 566Enumerates the media types. 567 568\@syscap SystemCapability.Multimedia.Media.CodecBase 569 570 571### OH_TransferCharacteristic 572 573 574``` 575enum OH_TransferCharacteristic 576``` 577 578**Description** 579 580Enumerates the transfer characteristics. 581 582\@syscap SystemCapability.Multimedia.Media.CodecBase 583 584 585## Variable Description 586 587 588### OH_AVCODEC_MIMETYPE_AUDIO_AAC 589 590 591``` 592const char* OH_AVCODEC_MIMETYPE_AUDIO_AAC 593``` 594 595**Description** 596 597Defines the pointer to the MIME type for AAC audio codec. 598 599\@syscap SystemCapability.Multimedia.Media.CodecBase 600 601 602### OH_AVCODEC_MIMETYPE_AUDIO_FLAC 603 604 605``` 606const char* OH_AVCODEC_MIMETYPE_AUDIO_FLAC 607``` 608 609**Description** 610 611Defines the pointer to the MIME type for FLAC audio codec. 612 613\@syscap SystemCapability.Multimedia.Media.CodecBase 614 615 616### OH_AVCODEC_MIMETYPE_AUDIO_MPEG 617 618 619``` 620const char* OH_AVCODEC_MIMETYPE_AUDIO_MPEG 621``` 622 623**Description** 624 625Defines the pointer to the MIME type for MPEG audio codec. 626 627\@syscap SystemCapability.Multimedia.Media.CodecBase 628 629 630### OH_AVCODEC_MIMETYPE_AUDIO_VORBIS 631 632 633``` 634const char* OH_AVCODEC_MIMETYPE_AUDIO_VORBIS 635``` 636 637**Description** 638 639Defines the pointer to the MIME type for VORBIS audio codec. 640 641\@syscap SystemCapability.Multimedia.Media.CodecBase 642 643 644### OH_AVCODEC_MIMETYPE_IMAGE_BMP 645 646 647``` 648const char* OH_AVCODEC_MIMETYPE_IMAGE_BMP 649``` 650 651**Description** 652 653Defines the pointer to the MIME type for BMP image codec. 654 655\@syscap SystemCapability.Multimedia.Media.CodecBase 656 657 658### OH_AVCODEC_MIMETYPE_IMAGE_JPG 659 660 661``` 662const char* OH_AVCODEC_MIMETYPE_IMAGE_JPG 663``` 664 665**Description** 666 667Defines the pointer to the MIME type for JPG image codec. 668 669\@syscap SystemCapability.Multimedia.Media.CodecBase 670 671 672### OH_AVCODEC_MIMETYPE_IMAGE_PNG 673 674 675``` 676const char* OH_AVCODEC_MIMETYPE_IMAGE_PNG 677``` 678 679**Description** 680 681Defines the pointer to the MIME type for PNG image codec. 682 683\@syscap SystemCapability.Multimedia.Media.CodecBase 684 685 686### OH_AVCODEC_MIMETYPE_VIDEO_AVC 687 688 689``` 690const char* OH_AVCODEC_MIMETYPE_VIDEO_AVC 691``` 692 693**Description** 694 695Defines the pointer to the MIME type for AVC video codec. 696 697\@syscap SystemCapability.Multimedia.Media.CodecBase 698 699 700### OH_AVCODEC_MIMETYPE_VIDEO_HEVC 701 702 703``` 704const char* OH_AVCODEC_MIMETYPE_VIDEO_HEVC 705``` 706 707**Description** 708 709Defines the pointer to the MIME type for HEVC video codec. 710 711\@syscap SystemCapability.Multimedia.Media.CodecBase 712 713 714### OH_AVCODEC_MIMETYPE_VIDEO_MPEG4 715 716 717``` 718const char* OH_AVCODEC_MIMETYPE_VIDEO_MPEG4 719``` 720 721**Description** 722 723Defines the pointer to the MIME type for MPEG4 video codec. 724 725\@syscap SystemCapability.Multimedia.Media.CodecBase 726 727 728### OH_ED_KEY_EOS 729 730 731``` 732const char* OH_ED_KEY_EOS 733``` 734 735**Description** 736 737Defines the pointer to the EOS in the extra data of the surface. The value type is Boolean. 738 739\@syscap SystemCapability.Multimedia.Media.CodecBase 740 741 742### OH_ED_KEY_TIME_STAMP 743 744 745``` 746const char* OH_ED_KEY_TIME_STAMP 747``` 748 749**Description** 750 751Defines the pointer to the timestamp in the extra data of the surface. The value type is int64. 752 753\@syscap SystemCapability.Multimedia.Media.CodecBase 754 755 756### OH_MD_KEY_AAC_IS_ADTS 757 758 759``` 760const char* OH_MD_KEY_AAC_IS_ADTS 761``` 762 763**Description** 764 765Defines the pointer to the AAC format. The value type is uint32_t. This key applies to AAC decoders. 766 767 768### OH_MD_KEY_ALBUM 769 770 771``` 772const char* OH_MD_KEY_ALBUM 773``` 774 775**Description** 776 777Defines the pointer to the album of the input media. The value is a string. 778 779 780### OH_MD_KEY_ALBUM_ARTIST 781 782 783``` 784const char* OH_MD_KEY_ALBUM_ARTIST 785``` 786 787**Description** 788 789Defines the pointer to the album_artist of the input media. The value is a string. 790 791 792### OH_MD_KEY_ARTIST 793 794 795``` 796const char* OH_MD_KEY_ARTIST 797``` 798 799**Description** 800 801Defines the pointer to the artist of the input media. The value is a string. 802 803 804### OH_MD_KEY_AUD_CHANNEL_COUNT 805 806 807``` 808const char* OH_MD_KEY_AUD_CHANNEL_COUNT 809``` 810 811**Description** 812 813Defines the pointer to the number of audio channels. The value type is uint32_t. 814 815 816### OH_MD_KEY_AUD_SAMPLE_RATE 817 818 819``` 820const char* OH_MD_KEY_AUD_SAMPLE_RATE 821``` 822 823**Description** 824 825Defines the pointer to the audio sampling rate. The value type is uint32_t. 826 827 828### OH_MD_KEY_AUDIO_SAMPLE_FORMAT 829 830 831``` 832const char* OH_MD_KEY_AUDIO_SAMPLE_FORMAT 833``` 834 835**Description** 836 837Defines the pointer to the original audio format. The value type is uint32_t. 838 839 840### OH_MD_KEY_BITRATE 841 842 843``` 844const char* OH_MD_KEY_BITRATE 845``` 846 847**Description** 848 849Defines the pointer to the bit rate. The value type is uint32_t. In the case of video encoding, you must set [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode), which specifies the bit rate. 850 851 852### OH_MD_KEY_BITS_PER_CODED_SAMPLE 853 854 855``` 856const char* OH_MD_KEY_BITS_PER_CODED_SAMPLE 857``` 858 859**Description** 860 861Defines the pointer to the number of bits for each coded sample. The value type is uint32_t. This key applies to FLAC encoders. 862 863 864### OH_MD_KEY_CHANNEL_LAYOUT 865 866 867``` 868const char* OH_MD_KEY_CHANNEL_LAYOUT 869``` 870 871**Description** 872 873Defines the pointer to the required encoding channel layout. The value type is int64_t. This key applies only to encoders. 874 875 876### OH_MD_KEY_CODEC_CONFIG 877 878 879``` 880const char* OH_MD_KEY_CODEC_CONFIG 881``` 882 883**Description** 884 885Defines the pointer to the codec-specific data. The value type is uint8_t\*. 886 887 888### OH_MD_KEY_CODEC_MIME 889 890 891``` 892const char* OH_MD_KEY_CODEC_MIME 893``` 894 895**Description** 896 897Define the pointer to the MIME type of codec. The value is a string. 898 899 900### OH_MD_KEY_COLOR_PRIMARIES 901 902 903``` 904const char* OH_MD_KEY_COLOR_PRIMARIES 905``` 906 907**Description** 908 909Defines the pointer to the primary color of the video. The value type is int32_t. 910 911 912### OH_MD_KEY_COMMENT 913 914 915``` 916const char* OH_MD_KEY_COMMENT 917``` 918 919**Description** 920 921Defines the pointer to the comment of the input media. The value is a string. 922 923 924### OH_MD_KEY_COMPLIANCE_LEVEL 925 926 927``` 928const char* OH_MD_KEY_COMPLIANCE_LEVEL 929``` 930 931**Description** 932 933Defines the pointer to the FLAC compliance level. The value type is int32_t. 934 935 936### OH_MD_KEY_COPYRIGHT 937 938 939``` 940const char* OH_MD_KEY_COPYRIGHT 941``` 942 943**Description** 944 945Defines the pointer to the copyright of the input media. The value is a string. 946 947 948### OH_MD_KEY_DATE 949 950 951``` 952const char* OH_MD_KEY_DATE 953``` 954 955**Description** 956 957Defines the pointer to the date of the input media. The value is a string. 958 959 960### OH_MD_KEY_DESCRIPTION 961 962 963``` 964const char* OH_MD_KEY_DESCRIPTION 965``` 966 967**Description** 968 969Defines the pointer to the description of the input media. The value is a string. 970 971 972### OH_MD_KEY_DURATION 973 974 975``` 976const char* OH_MD_KEY_DURATION 977``` 978 979**Description** 980 981Defines the pointer to the duration. The value type is int64_t. 982 983 984### OH_MD_KEY_FRAME_RATE 985 986 987``` 988const char* OH_MD_KEY_FRAME_RATE 989``` 990 991**Description** 992 993Defines the pointer to the video frame rate. The value is a double-precision floating point number. 994 995 996### OH_MD_KEY_GENRE 997 998 999``` 1000const char* OH_MD_KEY_GENRE 1001``` 1002 1003**Description** 1004 1005Defines the pointer to the genre of the input media. The value is a string. 1006 1007 1008### OH_MD_KEY_HEIGHT 1009 1010 1011``` 1012const char* OH_MD_KEY_HEIGHT 1013``` 1014 1015**Description** 1016 1017Defines the pointer to the video height. The value type is uint32_t. 1018 1019 1020### OH_MD_KEY_I_FRAME_INTERVAL 1021 1022 1023``` 1024const char* OH_MD_KEY_I_FRAME_INTERVAL 1025``` 1026 1027**Description** 1028 1029Defines the pointer to the key frame interval, in milliseconds. The value type is int32_t. 1030 1031 1032### OH_MD_KEY_IDENTIFICATION_HEADER 1033 1034 1035``` 1036const char* OH_MD_KEY_IDENTIFICATION_HEADER 1037``` 1038 1039**Description** 1040 1041Defines the pointer to the VORBIS identification header. The value type is uint8_t\*. This key applies only to VORBIS decoders. 1042 1043 1044### OH_MD_KEY_LANGUAGE 1045 1046 1047``` 1048const char* OH_MD_KEY_LANGUAGE 1049``` 1050 1051**Description** 1052 1053Defines the pointer to the language of the input media. The value is a string. 1054 1055 1056### OH_MD_KEY_LYRICS 1057 1058 1059``` 1060const char* OH_MD_KEY_LYRICS 1061``` 1062 1063**Description** 1064 1065Defines the pointer to the lyrics of the input media. The value is a string. 1066 1067 1068### OH_MD_KEY_MATRIX_COEFFICIENTS 1069 1070 1071``` 1072const char* OH_MD_KEY_MATRIX_COEFFICIENTS 1073``` 1074 1075**Description** 1076 1077Defines the pointer to the video matrix coefficient. The value type is int32_t. 1078 1079 1080### OH_MD_KEY_MAX_INPUT_SIZE 1081 1082 1083``` 1084const char* OH_MD_KEY_MAX_INPUT_SIZE 1085``` 1086 1087**Description** 1088 1089Defines the pointer to the maximum input size. The value type is uint32_t. 1090 1091 1092### OH_MD_KEY_PIXEL_FORMAT 1093 1094 1095``` 1096const char* OH_MD_KEY_PIXEL_FORMAT 1097``` 1098 1099**Description** 1100 1101Defines the pointer to the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). 1102 1103 1104### OH_MD_KEY_PROFILE 1105 1106 1107``` 1108const char* OH_MD_KEY_PROFILE 1109``` 1110 1111**Description** 1112 1113Defines the pointer to the encoding template. The value is a number. For details, see [OH_AVCProfile](#oh_avcprofile), [OH_AACProfile](#oh_aacprofile), or [OH_HEVCProfile](#oh_hevcprofile). 1114 1115 1116### OH_MD_KEY_QUALITY 1117 1118 1119``` 1120const char* OH_MD_KEY_QUALITY 1121``` 1122 1123**Description** 1124 1125Defines the pointer to the required encoding quality. The value type is uint32_t. This key applies only to encoders configured in constant quality mode. 1126 1127 1128### OH_MD_KEY_RANGE_FLAG 1129 1130 1131``` 1132const char* OH_MD_KEY_RANGE_FLAG 1133``` 1134 1135**Description** 1136 1137Defines the pointer to the video YUV value range flag. The value type is Boolean. 1138 1139 1140### OH_MD_KEY_REQUEST_I_FRAME 1141 1142 1143``` 1144const char* OH_MD_KEY_REQUEST_I_FRAME 1145``` 1146 1147**Description** 1148 1149Defines the pointer to the request for immediate encoding of I-frames. The value type is Boolean. 1150 1151 1152### OH_MD_KEY_ROTATION 1153 1154 1155``` 1156const char* OH_MD_KEY_ROTATION 1157``` 1158 1159**Description** 1160 1161Defines the pointer to the rotation angle of the surface. The value type is int32_t, and the value range is {0, 90, 180, 270}. The default value is 0. 1162 1163 1164### OH_MD_KEY_SBR 1165 1166 1167``` 1168const char* OH_MD_KEY_SBR 1169``` 1170 1171**Description** 1172 1173Defines the pointer to the AAC SBR format. The value type is uint32_t. This key applies to AAC encoders. 1174 1175 1176### OH_MD_KEY_SETUP_HEADER 1177 1178 1179``` 1180const char* OH_MD_KEY_SETUP_HEADER 1181``` 1182 1183**Description** 1184 1185Defines the pointer to the VORBIS setup header. The value type is uint8_t\*. This key applies only to VORBIS decoders. 1186 1187 1188### OH_MD_KEY_TITLE 1189 1190 1191``` 1192const char* OH_MD_KEY_TITLE 1193``` 1194 1195**Description** 1196 1197Defines the pointer to the title of the input media. The value is a string. 1198 1199 1200### OH_MD_KEY_TRACK_COUNT 1201 1202 1203``` 1204const char* OH_MD_KEY_TRACK_COUNT 1205``` 1206 1207**Description** 1208 1209Defines the pointer to the track count of the input media. The value type is uint32_t. 1210 1211 1212### OH_MD_KEY_TRACK_TYPE 1213 1214 1215``` 1216const char* OH_MD_KEY_TRACK_TYPE 1217``` 1218 1219**Description** 1220 1221Defines the pointer to a container for storing media descriptions. 1222 1223\@syscap SystemCapability.Multimedia.Media.CodecBase 1224 1225 1226### OH_MD_KEY_TRANSFER_CHARACTERISTICS 1227 1228 1229``` 1230const char* OH_MD_KEY_TRANSFER_CHARACTERISTICS 1231``` 1232 1233**Description** 1234 1235Defines the pointer to the video transfer characteristics. The value type is int32_t. 1236 1237 1238### OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE 1239 1240 1241``` 1242const char* OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE 1243``` 1244 1245**Description** 1246 1247Defines the pointer to the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). 1248 1249 1250### OH_MD_KEY_WIDTH 1251 1252 1253``` 1254const char* OH_MD_KEY_WIDTH 1255``` 1256 1257**Description** 1258 1259Defines the pointer to the video width. The value type is uint32_t. 1260