1# Core 2 3 4## Overview 5 6The Core module provides the basic backbone capabilities for the media framework, including functions related to the memory, error code, and media struct. 7 8**System capability**: SystemCapability.Multimedia.Media.Core 9 10**Since**: 9 11 12 13## Summary 14 15 16### Files 17 18| Name| Description| 19| -------- | -------- | 20| [native_audio_channel_layout.h](native__audio__channel__layout_8h.md) | Declares the functions related to the speaker layout during recording and playback.| 21| [native_avbuffer.h](native__avbuffer_8h.md) | Declares the functions of the media struct **AVBuffer**.| 22| [native_avbuffer_info.h](native__avbuffer__info_8h.md) | Declares the attribute definition of the media struct **AVBuffer**.| 23| [native_averrors.h](native__averrors_8h.md) | Declares the error codes used by the media framework.| 24| [native_avformat.h](native__avformat_8h.md) | Declares the functions and enums related to **OH_AVFormat**.| 25| [native_avmemory.h](native__avmemory_8h.md) | Declares the attribute definition of the media struct **AVMemory**.| 26 27 28### Structs 29 30| Name| Description| 31| -------- | -------- | 32| struct [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Describes the description information about the buffer of an **OH_AVCodec** instance. | 33 34 35### Types 36 37| Name| Description| 38| -------- | -------- | 39| typedef enum [OH_AudioChannelSet](#oh_audiochannelset-1) [OH_AudioChannelSet](#oh_audiochannelset) | Defines an enum for the audio channel sets.| 40| typedef enum [OH_AmbAttributeSet](#oh_ambattributeset-1) [OH_AmbAttributeSet](#oh_ambattributeset) | Defines an enum for the Hi-Fi stereo reverberation settings.| 41| typedef enum [OH_AudioChannelLayout](#oh_audiochannellayout-1) [OH_AudioChannelLayout](#oh_audiochannellayout) | Defines an enum for the audio channel layouts.| 42| typedef struct [OH_AVBuffer](#oh_avbuffer) [OH_AVBuffer](#oh_avbuffer) | Defines a struct that describes a native object for the media memory interface.| 43| typedef struct [OH_NativeBuffer](#oh_nativebuffer) [OH_NativeBuffer](#oh_nativebuffer) | Defines a struct that describes a native object for the graphics memory interface.| 44| typedef enum [OH_AVCodecBufferFlags](#oh_avcodecbufferflags-1) [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Defines an enum for the flags for the buffer of an **OH_AVCodec** instance.| 45| typedef struct [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the description information about the buffer of an **OH_AVCodec** instance.| 46| typedef enum [OH_AVErrCode](#oh_averrcode-1) [OH_AVErrCode](#oh_averrcode) | Defines an enum for the error codes used by the media framework.| 47| typedef struct [OH_AVFormat](#oh_avformat) [OH_AVFormat](#oh_avformat) | Defines a struct for a native object for the **OH_AVFormat** interface.| 48| typedef enum [OH_AVPixelFormat](#oh_avpixelformat-1) [OH_AVPixelFormat](#oh_avpixelformat) | Defines an enum for the video pixel formats.| 49| typedef struct [OH_AVMemory](#oh_avmemory) [OH_AVMemory](#oh_avmemory) | Defines a struct that describes a native object for the audio and video memory interface.| 50 51 52### Enums 53 54| Name| Description| 55| -------- | -------- | 56| [OH_AudioChannelSet](#oh_audiochannelset-1) {<br>CH_SET_FRONT_LEFT = 1ULL << 0U,<br>CH_SET_FRONT_RIGHT = 1ULL << 1U,<br>CH_SET_FRONT_CENTER = 1ULL << 2U,<br>CH_SET_LOW_FREQUENCY = 1ULL << 3U,<br>CH_SET_BACK_LEFT = 1ULL << 4U,<br>CH_SET_BACK_RIGHT = 1ULL << 5U,<br>CH_SET_FRONT_LEFT_OF_CENTER = 1ULL << 6U,<br>CH_SET_FRONT_RIGHT_OF_CENTER = 1ULL << 7U,<br>CH_SET_BACK_CENTER = 1ULL << 8U,<br>CH_SET_SIDE_LEFT = 1ULL << 9U,<br>CH_SET_SIDE_RIGHT = 1ULL << 10U,<br>CH_SET_TOP_CENTER = 1ULL << 11U,<br>CH_SET_TOP_FRONT_LEFT = 1ULL << 12U,<br>CH_SET_TOP_FRONT_CENTER = 1ULL << 13U,<br>CH_SET_TOP_FRONT_RIGHT = 1ULL << 14U,<br>CH_SET_TOP_BACK_LEFT = 1ULL << 15U,<br>CH_SET_TOP_BACK_CENTER = 1ULL << 16U,<br>CH_SET_TOP_BACK_RIGHT = 1ULL << 17U,<br>CH_SET_STEREO_LEFT = 1ULL << 29U,<br>CH_SET_STEREO_RIGHT = 1ULL << 30U,<br>CH_SET_WIDE_LEFT = 1ULL << 31U,<br>CH_SET_WIDE_RIGHT = 1ULL << 32U,<br>CH_SET_SURROUND_DIRECT_LEFT = 1ULL << 33U,<br>CH_SET_SURROUND_DIRECT_RIGHT = 1ULL << 34U,<br>CH_SET_LOW_FREQUENCY_2 = 1ULL << 35U,<br>CH_SET_TOP_SIDE_LEFT = 1ULL << 36U,<br>CH_SET_TOP_SIDE_RIGHT = 1ULL << 37U,<br>CH_SET_BOTTOM_FRONT_CENTER = 1ULL << 38U,<br>CH_SET_BOTTOM_FRONT_LEFT = 1ULL << 39U,<br>CH_SET_BOTTOM_FRONT_RIGHT = 1ULL << 40U<br>} | Enumerates the audio channel sets.| 57| [OH_AmbAttributeSet](#oh_ambattributeset-1) {<br>AMB_ORD_1 = 1ULL << 0U,<br>AMB_ORD_2 = 2ULL << 0U,<br>AMB_ORD_3 = 3ULL << 0U,<br>AMB_COM_ACN = 0ULL << 8U,<br>AMB_COM_FUMA = 1ULL << 8U,<br>AMB_NOR_N3D = 0ULL << 12U,<br>AMB_NOR_SN3D = 1ULL << 12U,<br>AMB_MODE = 1ULL << 44U<br>} | Enumerates the Hi-Fi stereo reverberation settings.| 58| [OH_AudioChannelLayout](#oh_audiochannellayout-1) {<br>CH_LAYOUT_UNKNOWN = 0ULL,<br>CH_LAYOUT_MONO = CH_SET_FRONT_CENTER,<br>CH_LAYOUT_STEREO = CH_SET_FRONT_LEFT \| CH_SET_FRONT_RIGHT,<br>CH_LAYOUT_STEREO_DOWNMIX = CH_SET_STEREO_LEFT \| CH_SET_STEREO_RIGHT,<br>CH_LAYOUT_2POINT1 = CH_LAYOUT_STEREO \| CH_SET_LOW_FREQUENCY,<br>CH_LAYOUT_3POINT0 = CH_LAYOUT_STEREO \| CH_SET_BACK_CENTER,<br>CH_LAYOUT_SURROUND = CH_LAYOUT_STEREO \| CH_SET_FRONT_CENTER,<br>CH_LAYOUT_3POINT1 = CH_LAYOUT_SURROUND \| CH_SET_LOW_FREQUENCY,<br>CH_LAYOUT_4POINT0 = CH_LAYOUT_SURROUND \| CH_SET_BACK_CENTER,<br>CH_LAYOUT_QUAD_SIDE = CH_LAYOUT_STEREO \| CH_SET_SIDE_LEFT \| CH_SET_SIDE_RIGHT,<br>CH_LAYOUT_QUAD = CH_LAYOUT_STEREO \| CH_SET_BACK_LEFT \| CH_SET_BACK_RIGHT,<br>CH_LAYOUT_2POINT0POINT2 = CH_LAYOUT_STEREO \| CH_SET_TOP_SIDE_LEFT \| CH_SET_TOP_SIDE_RIGHT,<br>CH_LAYOUT_AMB_ORDER1_ACN_N3D = AMB_MODE \| AMB_ORD_1 \| AMB_COM_ACN \| AMB_NOR_N3D, CH_LAYOUT_AMB_ORDER1_ACN_SN3D = AMB_MODE \| AMB_ORD_1 \| AMB_COM_ACN \| AMB_NOR_SN3D,<br>CH_LAYOUT_AMB_ORDER1_FUMA = AMB_MODE \| AMB_ORD_1 \| AMB_COM_FUMA,<br>CH_LAYOUT_4POINT1 = CH_LAYOUT_4POINT0 \| CH_SET_LOW_FREQUENCY,<br>CH_LAYOUT_5POINT0 = CH_LAYOUT_SURROUND \| CH_SET_SIDE_LEFT \| CH_SET_SIDE_RIGHT,<br>CH_LAYOUT_5POINT0_BACK = CH_LAYOUT_SURROUND \| CH_SET_BACK_LEFT \| CH_SET_BACK_RIGHT,<br>CH_LAYOUT_2POINT1POINT2 = CH_LAYOUT_2POINT0POINT2 \| CH_SET_LOW_FREQUENCY,<br>CH_LAYOUT_3POINT0POINT2 = CH_LAYOUT_2POINT0POINT2 \| CH_SET_FRONT_CENTER,<br>CH_LAYOUT_5POINT1 = CH_LAYOUT_5POINT0 \| CH_SET_LOW_FREQUENCY,<br>CH_LAYOUT_5POINT1_BACK = CH_LAYOUT_5POINT0_BACK \| CH_SET_LOW_FREQUENCY,<br>CH_LAYOUT_6POINT0 = CH_LAYOUT_5POINT0 \| CH_SET_BACK_CENTER,<br>CH_LAYOUT_3POINT1POINT2 = CH_LAYOUT_3POINT1 \| CH_SET_TOP_FRONT_LEFT \| CH_SET_TOP_FRONT_RIGHT,<br>CH_LAYOUT_6POINT0_FRONT = CH_LAYOUT_QUAD_SIDE \| CH_SET_FRONT_LEFT_OF_CENTER \| CH_SET_FRONT_RIGHT_OF_CENTER,<br>CH_LAYOUT_HEXAGONAL = CH_LAYOUT_5POINT0_BACK \| CH_SET_BACK_CENTER,<br>CH_LAYOUT_6POINT1 = CH_LAYOUT_5POINT1 \| CH_SET_BACK_CENTER,<br>CH_LAYOUT_6POINT1_BACK = CH_LAYOUT_5POINT1_BACK \| CH_SET_BACK_CENTER,<br>CH_LAYOUT_6POINT1_FRONT = CH_LAYOUT_6POINT0_FRONT \| CH_SET_LOW_FREQUENCY,<br>CH_LAYOUT_7POINT0 = CH_LAYOUT_5POINT0 \| CH_SET_BACK_LEFT \| CH_SET_BACK_RIGHT,<br>CH_LAYOUT_7POINT0_FRONT = CH_LAYOUT_5POINT0 \| CH_SET_FRONT_LEFT_OF_CENTER \| CH_SET_FRONT_RIGHT_OF_CENTER,<br>CH_LAYOUT_7POINT1 = CH_LAYOUT_5POINT1 \| CH_SET_BACK_LEFT \| CH_SET_BACK_RIGHT,<br>CH_LAYOUT_OCTAGONAL = CH_LAYOUT_5POINT0 \| CH_SET_BACK_LEFT \| CH_SET_BACK_CENTER \| CH_SET_BACK_RIGHT,<br>CH_LAYOUT_5POINT1POINT2 = CH_LAYOUT_5POINT1 \| CH_SET_TOP_SIDE_LEFT \| CH_SET_TOP_SIDE_RIGHT,<br>CH_LAYOUT_7POINT1_WIDE = CH_LAYOUT_5POINT1 \| CH_SET_FRONT_LEFT_OF_CENTER \| CH_SET_FRONT_RIGHT_OF_CENTER,<br>CH_LAYOUT_7POINT1_WIDE_BACK = CH_LAYOUT_5POINT1_BACK \| CH_SET_FRONT_LEFT_OF_CENTER \| CH_SET_FRONT_RIGHT_OF_CENTER,<br>CH_LAYOUT_AMB_ORDER2_ACN_N3D = AMB_MODE \| AMB_ORD_2 \| AMB_COM_ACN \| AMB_NOR_N3D,<br>CH_LAYOUT_AMB_ORDER2_ACN_SN3D = AMB_MODE \| AMB_ORD_2 \| AMB_COM_ACN \| AMB_NOR_SN3D,<br>CH_LAYOUT_AMB_ORDER2_FUMA = AMB_MODE \| AMB_ORD_2 \| AMB_COM_FUMA,<br>CH_LAYOUT_5POINT1POINT4,<br>CH_LAYOUT_7POINT1POINT2 = CH_LAYOUT_7POINT1 \| CH_SET_TOP_SIDE_LEFT \| CH_SET_TOP_SIDE_RIGHT,<br>CH_LAYOUT_7POINT1POINT4,<br>CH_LAYOUT_10POINT2,<br>CH_LAYOUT_9POINT1POINT4 = CH_LAYOUT_7POINT1POINT4 \| CH_SET_WIDE_LEFT \| CH_SET_WIDE_RIGHT,<br>CH_LAYOUT_9POINT1POINT6 = CH_LAYOUT_9POINT1POINT4 \| CH_SET_TOP_SIDE_LEFT \| CH_SET_TOP_SIDE_RIGHT,<br>CH_LAYOUT_HEXADECAGONAL,<br>CH_LAYOUT_AMB_ORDER3_ACN_N3D = AMB_MODE \| AMB_ORD_3 \| AMB_COM_ACN \| AMB_NOR_N3D,<br>CH_LAYOUT_AMB_ORDER3_ACN_SN3D = AMB_MODE \| AMB_ORD_3 \| AMB_COM_ACN \| AMB_NOR_SN3D,<br>CH_LAYOUT_AMB_ORDER3_FUMA = AMB_MODE \| AMB_ORD_3 \| AMB_COM_FUMA,<br>CH_LAYOUT_22POINT2<br>} | Enumerates the audio channel layouts.| 59| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags-1) {<br>AVCODEC_BUFFER_FLAGS_NONE = 0,<br>AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2,<br>AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3, <br>AVCODEC_BUFFER_FLAGS_DISCARD = 1 << 4, <br>AVCODEC_BUFFER_FLAGS_DISPOSABLE = 1 << 5<br>} | Enumerates the flags for the buffer of an **OH_AVCodec** instance. | 60| [OH_AVErrCode](#oh_averrcode-1) {<br>AV_ERR_OK = 0,<br>AV_ERR_NO_MEMORY = 1,<br>AV_ERR_OPERATE_NOT_PERMIT = 2,<br>AV_ERR_INVALID_VAL = 3,<br>AV_ERR_IO = 4,<br>AV_ERR_TIMEOUT = 5,<br>AV_ERR_UNKNOWN = 6,<br>AV_ERR_SERVICE_DIED = 7,<br>AV_ERR_INVALID_STATE = 8,<br>AV_ERR_UNSUPPORT = 9,<br>AV_ERR_EXTEND_START = 100,<br>AV_ERR_DRM_BASE = 200,<br>AV_ERR_DRM_DECRYPT_FAILED = 201,<br>AV_ERR_VIDEO_BASE = 300,<br>AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION = 301<br>} | Enumerates the error codes used by the media framework. | 61| [OH_AVPixelFormat](#oh_avpixelformat-1) {<br>AV_PIXEL_FORMAT_YUVI420 = 1,<br>AV_PIXEL_FORMAT_NV12 = 2,<br>AV_PIXEL_FORMAT_NV21 = 3,<br>AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,<br>AV_PIXEL_FORMAT_RGBA = 5<br>} | Enumerates the video pixel formats.| 62 63 64### Functions 65 66| Name| Description| 67| -------- | -------- | 68| [OH_AVBuffer](#oh_avbuffer) \* [OH_AVBuffer_Create](#oh_avbuffer_create) (int32_t capacity) | Creates an **OH_AVBuffer** instance. The caller must call [OH_AVBuffer_Destroy](#oh_avbuffer_destroy) to manually release the **OH_AVBuffer** instance returned.| 69| [OH_AVErrCode](#oh_averrcode) [OH_AVBuffer_Destroy](#oh_avbuffer_destroy) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Releases an **OH_AVBuffer** instance.| 70| [OH_AVErrCode](#oh_averrcode) [OH_AVBuffer_GetBufferAttr](#oh_avbuffer_getbufferattr) ([OH_AVBuffer](#oh_avbuffer) \*buffer, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr) | Obtains the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer.| 71| [OH_AVErrCode](#oh_averrcode) [OH_AVBuffer_SetBufferAttr](#oh_avbuffer_setbufferattr) ([OH_AVBuffer](#oh_avbuffer) \*buffer, const [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr) | Sets the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer.| 72| [OH_AVFormat](#oh_avformat) \* [OH_AVBuffer_GetParameter](#oh_avbuffer_getparameter) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Obtains parameters except basic attributes of a buffer. The information is carried in an **OH_AVFormat** instance.| 73| [OH_AVErrCode](#oh_averrcode) [OH_AVBuffer_SetParameter](#oh_avbuffer_setparameter) ([OH_AVBuffer](#oh_avbuffer) \*buffer, const [OH_AVFormat](#oh_avformat) \*format) | Sets parameters except basic attributes of a buffer. The information is carried in an **OH_AVFormat** instance.| 74| uint8_t \* [OH_AVBuffer_GetAddr](#oh_avbuffer_getaddr) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Obtains the virtual address of a data buffer.| 75| int32_t [OH_AVBuffer_GetCapacity](#oh_avbuffer_getcapacity) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Obtains the capacity (in bytes) of a buffer.| 76| [OH_NativeBuffer](#oh_nativebuffer) \* [OH_AVBuffer_GetNativeBuffer](#oh_avbuffer_getnativebuffer) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Obtains the pointer to an **OH_NativeBuffer** instance.| 77| struct [OH_AVFormat](#oh_avformat) \* [OH_AVFormat_Create](#oh_avformat_create) (void) | Create an **OH_AVFormat** instance for reading and writing data.| 78| struct [OH_AVFormat](#oh_avformat) \* [OH_AVFormat_CreateAudioFormat](#oh_avformat_createaudioformat) (const char \*mimeType, int32_t sampleRate, int32_t channelCount) | Creates an audio **OH_AVFormat** instance with specified parameters for reading and writing data.| 79| struct [OH_AVFormat](#oh_avformat) \* [OH_AVFormat_CreateVideoFormat](#oh_avformat_createvideoformat) (const char \*mimeType, int32_t width, int32_t height) | Creates a video **OH_AVFormat** instance with specified parameters for reading and writing data.| 80| void [OH_AVFormat_Destroy](#oh_avformat_destroy) (struct [OH_AVFormat](#oh_avformat) \*format) | Destroys an **OH_AVFormat** instance.| 81| bool [OH_AVFormat_Copy](#oh_avformat_copy) (struct [OH_AVFormat](#oh_avformat) \*to, struct [OH_AVFormat](#oh_avformat) \*from) | Copies an **OH_AVFormat** instance.| 82| bool [OH_AVFormat_SetIntValue](#oh_avformat_setintvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, int32_t value) | Assigns a value of the int type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance.| 83| bool [OH_AVFormat_SetLongValue](#oh_avformat_setlongvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, int64_t value) | Assigns a value of the long type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance.| 84| bool [OH_AVFormat_SetFloatValue](#oh_avformat_setfloatvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, float value) | Assigns a value of the float type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance.| 85| bool [OH_AVFormat_SetDoubleValue](#oh_avformat_setdoublevalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, double value) | Assigns a value of the double type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance.| 86| bool [OH_AVFormat_SetStringValue](#oh_avformat_setstringvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, const char \*value) | Assigns a value of the string type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance.| 87| bool [OH_AVFormat_SetBuffer](#oh_avformat_setbuffer) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data blocks of a specified length to an **OH_AVFormat** instance.| 88| bool [OH_AVFormat_GetIntValue](#oh_avformat_getintvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, int32_t \*out) | Obtains the value of the int type of a key contained in an **OH_AVFormat**.| 89| bool [OH_AVFormat_GetLongValue](#oh_avformat_getlongvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, int64_t \*out) | Obtains the value of the long type of a key contained in an **OH_AVFormat**.| 90| bool [OH_AVFormat_GetFloatValue](#oh_avformat_getfloatvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, float \*out) | Obtains the value of the float type of a key contained in an **OH_AVFormat**.| 91| bool [OH_AVFormat_GetDoubleValue](#oh_avformat_getdoublevalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, double \*out) | Obtains the value of the double type of a key contained in an **OH_AVFormat**.| 92| bool [OH_AVFormat_GetStringValue](#oh_avformat_getstringvalue) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, const char \*\*out) | Obtains the value of the string type of a key contained in an **OH_AVFormat**.| 93| bool [OH_AVFormat_GetBuffer](#oh_avformat_getbuffer) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data blocks of a specified length from an **OH_AVFormat** instance.| 94| const char \* [OH_AVFormat_DumpInfo](#oh_avformat_dumpinfo) (struct [OH_AVFormat](#oh_avformat) \*format) | Returns a string consisting of key-value pairs contained in an **OH_AVFormat**.| 95| [OH_AVMemory](#oh_avmemory) \* [OH_AVMemory_Create](#oh_avmemory_create) (int32_t size) | Creates an **OH_AVMemory** instance. (This function is deprecated in API version 11.)| 96| uint8_t \* [OH_AVMemory_GetAddr](#oh_avmemory_getaddr) (struct [OH_AVMemory](#oh_avmemory) \*mem) | Obtains the virtual memory address. (This function is deprecated in API version 11.)| 97| int32_t [OH_AVMemory_GetSize](#oh_avmemory_getsize) (struct [OH_AVMemory](#oh_avmemory) \*mem) | Obtains the memory length. (This function is deprecated in API version 11.)| 98| [OH_AVErrCode](#oh_averrcode) [OH_AVMemory_Destroy](#oh_avmemory_destroy) (struct [OH_AVMemory](#oh_avmemory) \*mem) | Releases an **OH_AVMemory** instance. (This function is deprecated in API version 11.)| 99 100 101## Type Description 102 103 104### OH_AmbAttributeSet 105 106``` 107typedef enum OH_AmbAttributeSet OH_AmbAttributeSet 108``` 109 110**Description** 111 112Defines an enum for the Hi-Fi stereo reverberation settings. 113 114Int64 integers are used to indicate the Hi-Fi stereo reverberation attributes. 115 116**System capability**: SystemCapability.Multimedia.Media.Core 117 118**Since**: 11 119 120 121### OH_AudioChannelLayout 122 123``` 124typedef enum OH_AudioChannelLayout OH_AudioChannelLayout 125``` 126 127**Description** 128 129Defines an enum for the audio channel layouts. 130 131Int64 integers are used to indicate the appearance and sequence of speakers during recording or playback. 132 133**System capability**: SystemCapability.Multimedia.Media.Core 134 135**Since**: 11 136 137 138### OH_AudioChannelSet 139 140``` 141typedef enum OH_AudioChannelSet OH_AudioChannelSet 142``` 143 144**Description** 145 146Defines an enum for the audio channel sets. 147 148Each audio channel is mapped to an int64 variable. 149 150**System capability**: SystemCapability.Multimedia.Media.Core 151 152**Since**: 11 153 154 155### OH_AVBuffer 156 157``` 158typedef struct OH_AVBuffer OH_AVBuffer 159``` 160**Description** 161 162Defines a struct that describes a native object for the media memory interface. 163 164**Since**: 11 165 166 167### OH_AVCodecBufferAttr 168 169``` 170typedef struct OH_AVCodecBufferAttr OH_AVCodecBufferAttr 171``` 172 173**Description** 174 175Defines the description information about the buffer of an **OH_AVCodec** instance. 176 177**System capability**: SystemCapability.Multimedia.Media.Core 178 179**Since**: 9 180 181 182### OH_AVCodecBufferFlags 183 184``` 185typedef enum OH_AVCodecBufferFlags OH_AVCodecBufferFlags 186``` 187 188**Description** 189 190Defines an enum for the flags for the buffer of an **OH_AVCodec** instance. 191 192**System capability**: SystemCapability.Multimedia.Media.Core 193 194**Since**: 9 195 196 197### OH_AVErrCode 198 199``` 200typedef enum OH_AVErrCode OH_AVErrCode 201``` 202 203**Description** 204 205Defines an enum for the error codes used by the media framework. 206 207**System capability**: SystemCapability.Multimedia.Media.Core 208 209**Since**: 9 210 211 212### OH_AVFormat 213 214``` 215typedef struct OH_AVFormat OH_AVFormat 216``` 217**Description** 218 219Defines a struct for a native object for the **OH_AVFormat** interface. 220 221**Since**: 9 222 223 224### OH_AVMemory 225 226``` 227typedef struct OH_AVMemory OH_AVMemory 228``` 229**Description** 230 231Defines a struct that describes a native object for the audio and video memory interface. 232 233**Since**: 9 234 235 236### OH_AVPixelFormat 237 238``` 239typedef enum OH_AVPixelFormat OH_AVPixelFormat 240``` 241 242**Description** 243 244Defines an enum for the video pixel formats. 245 246**System capability**: SystemCapability.Multimedia.Media.Core 247 248**Since**: 9 249 250 251### OH_NativeBuffer 252 253``` 254typedef struct OH_NativeBuffer OH_NativeBuffer 255``` 256**Description** 257 258Defines a struct that describes a native object for the graphics memory interface. 259 260**Since**: 11 261 262 263## Enum Description 264 265 266### OH_AmbAttributeSet 267 268``` 269enum OH_AmbAttributeSet 270``` 271 272**Description** 273 274Enumerates the Hi-Fi stereo reverberation settings. 275 276Int64 integers are used to indicate the Hi-Fi stereo reverberation attributes. 277 278**System capability**: SystemCapability.Multimedia.Media.Core 279 280**Since**: 11 281 282| Value| Description| 283| -------- | -------- | 284| AMB_ORD_1 | First-order Hi-Fi stereo reverberation.| 285| AMB_ORD_2 | Second-order Hi-Fi stereo reverberation.| 286| AMB_ORD_3 | Third-order Hi-Fi stereo reverberation.| 287| AMB_COM_ACN | Hi-Fi stereo reverberation with ACN channel sorting.| 288| AMB_COM_FUMA | Hi-Fi stereo reverberation with FUMA channel sorting.| 289| AMB_NOR_N3D | N3D normalized Hi-Fi stereo reverberation.| 290| AMB_NOR_SN3D | SN3D normalized Hi-Fi stereo reverberation.| 291| AMB_MODE | Audio channel layout for Hi-Fi stereo reverberation.| 292 293 294### OH_AudioChannelLayout 295 296``` 297enum OH_AudioChannelLayout 298``` 299 300**Description** 301 302Enumerates the audio channel layouts. 303 304Int64 integers are used to indicate the appearance and sequence of speakers during recording or playback. 305 306**System capability**: SystemCapability.Multimedia.Media.Core 307 308**Since**: 11 309 310| Value| Description| 311| -------- | -------- | 312| CH_LAYOUT_UNKNOWN | Unknown.| 313| CH_LAYOUT_MONO | Mono layout; 1 audio channel in total.| 314| CH_LAYOUT_STEREO | Stereo layout; 2 audio channels in total.| 315| CH_LAYOUT_STEREO_DOWNMIX | Stereo downmix layout; 2 audio channels in total.| 316| CH_LAYOUT_2POINT1 | 2.1 layout; 3 audio channels in total.| 317| CH_LAYOUT_3POINT0 | 3.0 layout; 3 audio channels in total.| 318| CH_LAYOUT_SURROUND | Surround; 3 audio channels in total.| 319| CH_LAYOUT_3POINT1 | 3.1 layout; 4 audio channels in total.| 320| CH_LAYOUT_4POINT0 | 4.0 layout; 4 audio channels in total.| 321| CH_LAYOUT_QUAD_SIDE | Quad side layout; 4 audio channels in total.| 322| CH_LAYOUT_QUAD | Quad layout; 4 audio channels in total.| 323| CH_LAYOUT_2POINT0POINT2 | 2.0.2 layout; 4 audio channels in total.| 324| CH_LAYOUT_AMB_ORDER1_ACN_N3D | First-order FOA layout in ACN_N3D (ITU standards); 4 audio channels in total| 325| CH_LAYOUT_AMB_ORDER1_ACN_SN3D | First-order FOA layout in ACN_SN3D (ITU standards); 4 audio channels in total| 326| CH_LAYOUT_AMB_ORDER1_FUMA | First-order FOA layout in FUMA (ITU standards); 4 audio channels in total| 327| CH_LAYOUT_4POINT1 | 4.1 layout; 5 audio channels in total.| 328| CH_LAYOUT_5POINT0 | 5.0 layout; 5 audio channels in total.| 329| CH_LAYOUT_5POINT0_BACK | 5.0 rear layout; 5 audio channels in total.| 330| CH_LAYOUT_2POINT1POINT2 | 2.1.2 layout; 5 audio channels in total.| 331| CH_LAYOUT_3POINT0POINT2 | 3.0.2 layout; 5 audio channels in total.| 332| CH_LAYOUT_5POINT1 | 5.1 layout; 6 audio channels in total.| 333| CH_LAYOUT_5POINT1_BACK | 5.1 rear layout; 6 audio channels in total.| 334| CH_LAYOUT_6POINT0 | 6.0 layout; 6 audio channels in total.| 335| CH_LAYOUT_3POINT1POINT2 | 3.1.2 layout; 6 audio channels in total.| 336| CH_LAYOUT_6POINT0_FRONT | 6.0 front layout; 6 audio channels in total.| 337| CH_LAYOUT_HEXAGONAL | Hexagonal layout; 6 audio channels in total.| 338| CH_LAYOUT_6POINT1 | 6.1 layout; 7 audio channels in total.| 339| CH_LAYOUT_6POINT1_BACK | 6.1 rear layout; 7 audio channels in total.| 340| CH_LAYOUT_6POINT1_FRONT | 6.1 front layout; 7 audio channels in total.| 341| CH_LAYOUT_7POINT0 | 7.0 layout; 7 audio channels in total.| 342| CH_LAYOUT_7POINT0_FRONT | 7.0 front layout; 7 audio channels in total.| 343| CH_LAYOUT_7POINT1 | 7.1 layout; 8 audio channels in total.| 344| CH_LAYOUT_OCTAGONAL | Octagonal layout; 8 audio channels in total.| 345| CH_LAYOUT_5POINT1POINT2 | 5.1.2 layout; 8 audio channels in total.| 346| CH_LAYOUT_7POINT1_WIDE | 7.1 wide layout; 8 audio channels in total.| 347| CH_LAYOUT_7POINT1_WIDE_BACK | 7.1 rear wide layout; 8 audio channels in total.| 348| CH_LAYOUT_AMB_ORDER2_ACN_N3D | Second-order HOA layout in ACN_N3D (ITU standards); 9 audio channels in total| 349| CH_LAYOUT_AMB_ORDER2_ACN_SN3D | Second-order HOA layout in ACN_SN3D (ITU standards); 9 audio channels in total| 350| CH_LAYOUT_AMB_ORDER2_FUMA | Second-order HOA layout in FUMA (ITU standards); 9 audio channels in total| 351| CH_LAYOUT_5POINT1POINT4 | 5.1.4 layout; 10 audio channels in total.| 352| CH_LAYOUT_7POINT1POINT2 | 7.1.2 layout; 10 audio channels in total.| 353| CH_LAYOUT_7POINT1POINT4 | 7.1.4 layout; 12 audio channels in total.| 354| CH_LAYOUT_10POINT2 | 10.2 layout; 12 audio channels in total.| 355| CH_LAYOUT_9POINT1POINT4 | 9.1.4 layout; 14 audio channels in total.| 356| CH_LAYOUT_9POINT1POINT6 | 9.1.6 layout; 16 audio channels in total.| 357| CH_LAYOUT_HEXADECAGONAL | Hexadecagonal layout; 16 audio channels in total.| 358| CH_LAYOUT_AMB_ORDER3_ACN_N3D | Third-order HOA layout in ACN_N3D (ITU standards); 16 audio channels in total| 359| CH_LAYOUT_AMB_ORDER3_ACN_SN3D | Third-order HOA layout in ACN_SN3D (ITU standards); 16 audio channels in total| 360| CH_LAYOUT_AMB_ORDER3_FUMA | Third-order HOA layout in FUMA (ITU standards); 16 audio channels in total| 361| CH_LAYOUT_22POINT2 | 22.2 layout; 24 audio channels in total.| 362 363 364### OH_AudioChannelSet 365 366``` 367enum OH_AudioChannelSet 368``` 369 370**Description** 371 372Enumerates the audio channel sets. 373 374Each audio channel is mapped to an int64 variable. 375 376**System capability**: SystemCapability.Multimedia.Media.Core 377 378**Since**: 11 379 380| Value| Description| 381| -------- | -------- | 382| CH_SET_FRONT_LEFT | Front left channel.| 383| CH_SET_FRONT_RIGHT | Front right channel| 384| CH_SET_FRONT_CENTER | Front center channel.| 385| CH_SET_LOW_FREQUENCY | Low-frequency channel.| 386| CH_SET_BACK_LEFT | Rear left channel.| 387| CH_SET_BACK_RIGHT | Rear right channel| 388| CH_SET_FRONT_LEFT_OF_CENTER | Front left center channel.| 389| CH_SET_FRONT_RIGHT_OF_CENTER | Front right center channel.| 390| CH_SET_BACK_CENTER | Rear center channel.| 391| CH_SET_SIDE_LEFT | Left channel.| 392| CH_SET_SIDE_RIGHT | Right channel.| 393| CH_SET_TOP_CENTER | Top center channel.| 394| CH_SET_TOP_FRONT_LEFT | Top left front channel.| 395| CH_SET_TOP_FRONT_CENTER | Top center front channel.| 396| CH_SET_TOP_FRONT_RIGHT | Top right front channel.| 397| CH_SET_TOP_BACK_LEFT | Top left rear channel.| 398| CH_SET_TOP_BACK_CENTER | Top center rear channel.| 399| CH_SET_TOP_BACK_RIGHT | Top right rear channel.| 400| CH_SET_STEREO_LEFT | Stereo left channel.| 401| CH_SET_STEREO_RIGHT | Stereo right channel.| 402| CH_SET_WIDE_LEFT | Wide left channel.| 403| CH_SET_WIDE_RIGHT | Wide right channel.| 404| CH_SET_SURROUND_DIRECT_LEFT | Left surround channel.| 405| CH_SET_SURROUND_DIRECT_RIGHT | Right surround channel.| 406| CH_SET_LOW_FREQUENCY_2 | Low-frequency channel 2.| 407| CH_SET_TOP_SIDE_LEFT | Top left channel.| 408| CH_SET_TOP_SIDE_RIGHT | Top right channel.| 409| CH_SET_BOTTOM_FRONT_CENTER | Bottom center front channel.| 410| CH_SET_BOTTOM_FRONT_LEFT | Bottom left front channel.| 411| CH_SET_BOTTOM_FRONT_RIGHT | Bottom right front channel.| 412 413 414### OH_AVCodecBufferFlags 415 416``` 417enum OH_AVCodecBufferFlags 418``` 419 420**Description** 421 422Enumerates the flags for the buffer of an **OH_AVCodec** instance. 423 424**System capability**: SystemCapability.Multimedia.Media.Core 425 426**Since**: 9 427 428| Value| Description| 429| -------- | -------- | 430| AVCODEC_BUFFER_FLAGS_NONE | Common frame.| 431| AVCODEC_BUFFER_FLAGS_EOS | The buffer is an end-of-stream frame.| 432| AVCODEC_BUFFER_FLAGS_SYNC_FRAME | The buffer contains key frames.| 433| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME | The data in the buffer is only part of the frame.| 434| AVCODEC_BUFFER_FLAGS_CODEC_DATA | The buffer contains codec-specific data.| 435| AVCODEC_BUFFER_FLAGS_DISCARD | The decoding process depends on the buffer, and the decoded data can be discarded.<br>**Since**: 12| 436| AVCODEC_BUFFER_FLAGS_DISPOSABLE | The buffer can be disposed directly.<br>**Since**: 12| 437 438 439### OH_AVErrCode 440 441``` 442enum OH_AVErrCode 443``` 444 445**Description** 446 447Enumerates the error codes used by the media framework. 448 449**System capability**: SystemCapability.Multimedia.Media.Core 450 451**Since**: 9 452 453| Value| Description| 454| -------- | -------- | 455| AV_ERR_OK | Operation successful. | 456| AV_ERR_NO_MEMORY | No memory. | 457| AV_ERR_OPERATE_NOT_PERMIT | Operation not allowed. | 458| AV_ERR_INVALID_VAL | Invalid value. | 459| AV_ERR_IO | I/O error. | 460| AV_ERR_TIMEOUT | Timeout. | 461| AV_ERR_UNKNOWN | Unknown error. | 462| AV_ERR_SERVICE_DIED | Unavailable service. | 463| AV_ERR_INVALID_STATE | Unsupported operation in this state. | 464| AV_ERR_UNSUPPORT | Unsupported feature. | 465| AV_ERR_EXTEND_START | Initial value for extended error codes. | 466| AV_ERR_DRM_BASE | DRM start error code.<br>**Since**: 12| 467| AV_ERR_DRM_DECRYPT_FAILED | DRM decryption failed.<br>**Since**: 12| 468| AV_ERR_VIDEO_BASE | Video start error code.<br>**Since**: 12| 469| AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION | Color Space Conversion (CSC) is not supported.<br>**Since**: 12| 470 471### OH_AVPixelFormat 472 473``` 474enum OH_AVPixelFormat 475``` 476 477**Description** 478 479Enumerates the video pixel formats. 480 481**System capability**: SystemCapability.Multimedia.Media.Core 482 483**Since**: 9 484 485| Value| Description| 486| -------- | -------- | 487| AV_PIXEL_FORMAT_YUVI420 | YUV 420 Planar.| 488| AV_PIXEL_FORMAT_NV12 | NV12. YUV 420 semi-planar.| 489| AV_PIXEL_FORMAT_NV21 | NV21. YUV 420 semi-planar.| 490| AV_PIXEL_FORMAT_SURFACE_FORMAT | Pixel format obtained from the surface.| 491| AV_PIXEL_FORMAT_RGBA | RGBA8888.| 492 493 494## Function Description 495 496 497### OH_AVBuffer_Create() 498 499``` 500OH_AVBuffer* OH_AVBuffer_Create (int32_t capacity) 501``` 502 503**Description** 504 505Creates an **OH_AVBuffer** instance. The caller must call [OH_AVBuffer_Destroy](#oh_avbuffer_destroy) to manually release the **OH_AVBuffer** instance returned. 506 507**System capability**: SystemCapability.Multimedia.Media.Core 508 509**Since**: 11 510 511**Parameters** 512 513| Name| Description| 514| -------- | -------- | 515| capacity | Size of the created memory, in bytes.| 516 517**Returns** 518 519Returns the pointer to the **OH_AVBuffer** instance created if the operation is successful; returns NULL otherwise. 520 521The possible causes of an operation failure are as follows: 522 5231. The value of **capacity** is less than or equal to 0. 5242. An internal error occurs, or the system does not have resources. 525 526 527### OH_AVBuffer_Destroy() 528 529``` 530OH_AVErrCode OH_AVBuffer_Destroy (OH_AVBuffer *buffer) 531``` 532 533**Description** 534 535Releases an **OH_AVBuffer** instance. A buffer cannot be destroyed repeatedly. 536 537**System capability**: SystemCapability.Multimedia.Media.Core 538 539**Since**: 11 540 541**Parameters** 542 543| Name| Description| 544| -------- | -------- | 545| buffer | Pointer to an **OH_AVBuffer** instance.| 546 547**Returns** 548 549Returns any of the following result code: 550 551**AV_ERR_OK**: The operation is successful. 552 553**AV_ERR_INVALID_VAL**: The passed-in value of **buffer** is a null pointer or fails parameter structure verification. 554 555**AV_ERR_OPERATE_NOT_PERMIT**: The input buffer is not created by the user. 556 557 558### OH_AVBuffer_GetAddr() 559 560``` 561uint8_t* OH_AVBuffer_GetAddr (OH_AVBuffer *buffer) 562``` 563 564**Description** 565 566Obtains the virtual address of a data buffer. 567 568The capability to obtain virtual addresses varies in scenarios, as described in the table below. 569 570**Encoding** 571| Mode| Data Filling Mode| Capability to Obtain Virtual Addresses| 572| --------------- | -------- | -------- | 573| Surface| OnNeedInputBuffer input | Not supported| 574| Surface| OnNewOutputBuffer output | Supported| 575| Buffer | OnNeedInputBuffer input | Supported| 576| Buffer | OnNewOutputBuffer output | Supported| 577 578**Decoding** 579| Mode| Data Filling Mode| Capability to Obtain Virtual Addresses| 580| --------------- | -------- | -------- | 581| Surface| OnNeedInputBuffer input | Supported| 582| Surface| OnNewOutputBuffer output | Not supported| 583| Buffer | OnNeedInputBuffer input | Supported| 584| Buffer | OnNewOutputBuffer output | Supported| 585 586**System capability**: SystemCapability.Multimedia.Media.Core 587 588**Since**: 11 589 590**Parameters** 591 592| Name| Description| 593| -------- | -------- | 594| buffer | Pointer to an **OH_AVBuffer** instance.| 595 596**Returns** 597 598Returns the virtual address if the operation is successful; returns NULL otherwise. 599 600The possible causes of an operation failure are as follows: 601 6021. The passed-in value of **buffer** is a null pointer. 6032. The passed-in value of **OH_AVBuffer** fails parameter structure verification. 6043. An internal error occurred. 605 606 607### OH_AVBuffer_GetBufferAttr() 608 609``` 610OH_AVErrCode OH_AVBuffer_GetBufferAttr (OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr) 611``` 612 613**Description** 614 615Obtains the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer. 616 617**System capability**: SystemCapability.Multimedia.Media.Core 618 619**Since**: 11 620 621**Parameters** 622 623| Name| Description| 624| -------- | -------- | 625| buffer | Pointer to an **OH_AVBuffer** instance.| 626| attr | Pointer to an [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) instance.| 627 628**Returns** 629 630Returns any of the following result code: 631 632**AV_ERR_OK**: The operation is successful. 633 634**AV_ERR_INVALID_VAL**: The operation fails. 635 636 Possible causes are as follows: 637 1. The passed-in value of **buffer** or **attr** is a null pointer. 638 2. The passed-in value of **buffer** fails parameter structure verification. 639 640 641### OH_AVBuffer_GetCapacity() 642 643``` 644int32_t OH_AVBuffer_GetCapacity (OH_AVBuffer *buffer) 645``` 646 647**Description** 648 649Obtains the capacity (in bytes) of a buffer. 650 651**System capability**: SystemCapability.Multimedia.Media.Core 652 653**Since**: 11 654 655**Parameters** 656 657| Name| Description| 658| -------- | -------- | 659| buffer | Pointer to an **OH_AVBuffer** instance.| 660 661**Returns** 662 663Returns the capacity if the operation is successful; returns **-1** otherwise. 664 665The possible causes of an operation failure are as follows: 666 6671. The passed-in value of **buffer** is a null pointer. 6682. The passed-in value of **OH_AVBuffer** fails parameter structure verification. 6693. An internal error occurred. 670 671 672### OH_AVBuffer_GetNativeBuffer() 673 674``` 675OH_NativeBuffer* OH_AVBuffer_GetNativeBuffer (OH_AVBuffer *buffer) 676``` 677 678**Description** 679 680Obtains the pointer to an **OH_NativeBuffer** instance. The caller must call [OH_NativeBuffer_Unreference](../apis-arkgraphics2d/_o_h___native_buffer.md#oh_nativebuffer_unreference) to manually release the **OH_NativeBuffer** instance returned. 681 682**System capability**: SystemCapability.Multimedia.Media.Core 683 684**Since**: 11 685 686**Parameters** 687 688| Name| Description| 689| -------- | -------- | 690| buffer | Pointer to an **OH_AVBuffer** instance.| 691 692**Returns** 693 694Returns the pointer to the **OH_NativeBuffer** instance created if the operation is successful; returns NULL otherwise. 695 696The possible causes of an operation failure are as follows: 697 6981. The passed-in value of **buffer** is a null pointer. 6992. The passed-in value of **OH_AVBuffer** fails parameter structure verification. 7003. An internal error occurred. 701 702 703### OH_AVBuffer_GetParameter() 704 705``` 706OH_AVFormat* OH_AVBuffer_GetParameter (OH_AVBuffer *buffer) 707``` 708 709**Description** 710 711Obtains parameters except basic attributes of a buffer. The information is carried in an **OH_AVFormat** instance. The caller must call [OH_AVFormat_Destroy](#oh_avformat_destroy) to manually release the **OH_AVFormat** instance returned. 712 713**System capability**: SystemCapability.Multimedia.Media.Core 714 715**Since**: 11 716 717**Parameters** 718 719| Name| Description| 720| -------- | -------- | 721| buffer | Pointer to an **OH_AVBuffer** instance.| 722 723**Returns** 724 725Returns any of the following result code: 726 727**AV_ERR_OK**: The operation is successful. 728 729**AV_ERR_INVALID_VAL**: The operation fails. 730 731 Possible causes are as follows: 732 1. The passed-in value of **buffer** is a null pointer. 733 2. The meta of the buffer is a null pointer. 734 3. The passed-in value of **buffer** fails parameter structure verification. 735 736 737### OH_AVBuffer_SetBufferAttr() 738 739``` 740OH_AVErrCode OH_AVBuffer_SetBufferAttr (OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr) 741``` 742 743**Description** 744 745Sets the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer. 746 747**System capability**: SystemCapability.Multimedia.Media.Core 748 749**Since**: 11 750 751**Parameters** 752 753| Name| Description| 754| -------- | -------- | 755| buffer | Pointer to an **OH_AVBuffer** instance.| 756| attr | Pointer to an [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) instance.| 757 758**Returns** 759 760Returns any of the following result code: 761 762**AV_ERR_OK**: The operation is successful. 763 764**AV_ERR_INVALID_VAL**: The operation fails. 765 766 Possible causes are as follows: 767 1. The passed-in value of **buffer** or **attr** is a null pointer. 768 2. The passed-in value of **buffer** fails parameter structure verification. 769 3. The memory size or offset of the buffer is invalid. 770 771 772### OH_AVBuffer_SetParameter() 773 774``` 775OH_AVErrCode OH_AVBuffer_SetParameter (OH_AVBuffer *buffer, const OH_AVFormat *format) 776``` 777 778**Description** 779 780Sets parameters except basic attributes of a buffer. The information is carried in an **OH_AVFormat** instance. 781 782**System capability**: SystemCapability.Multimedia.Media.Core 783 784**Since**: 11 785 786**Parameters** 787 788| Name| Description| 789| -------- | -------- | 790| buffer | Pointer to an **OH_AVBuffer** instance.| 791| format | Pointer to an **OH_AVFormat** instance.| 792 793**Returns** 794 795Returns any of the following result code: 796 797**AV_ERR_OK**: The operation is successful. 798 799**AV_ERR_INVALID_VAL**: The operation fails. 800 801 Possible causes are as follows: 802 1. The passed-in value of **buffer** or **format** is a null pointer. 803 2. The meta of the buffer is a null pointer. 804 3. The passed-in value of **buffer** fails parameter structure verification. 805 806 807### OH_AVFormat_Copy() 808 809``` 810bool OH_AVFormat_Copy (struct OH_AVFormat *to, struct OH_AVFormat *from) 811``` 812 813**Description** 814 815Copies an **OH_AVFormat** instance. 816 817**System capability**: SystemCapability.Multimedia.Media.Core 818 819**Since**: 9 820 821**Parameters** 822 823| Name| Description| 824| -------- | -------- | 825| to | Pointer to the **OH_AVFormat** instance to which the data will be copied.| 826| from | Pointer to the **OH_AVFormat** instance from which the data will be copied.| 827 828**Returns** 829 830Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 831 832The possible causes of an operation failure are as follows: 833 8341. The input parameter is a null pointer. 8352. The passed-in value of **OH_AVFormat** fails parameter structure verification. 836 837 838### OH_AVFormat_Create() 839 840``` 841struct OH_AVFormat* OH_AVFormat_Create (void) 842``` 843 844**Description** 845 846Create an **OH_AVFormat** instance for reading and writing data. 847 848**System capability**: SystemCapability.Multimedia.Media.Core 849 850**Since**: 9 851 852**Returns** 853 854Returns the pointer to an **OH_AVFormat** instance; returns NULL if system resources are insufficient. 855 856 857### OH_AVFormat_CreateAudioFormat() 858 859``` 860struct OH_AVFormat* OH_AVFormat_CreateAudioFormat (const char *mimeType, int32_t sampleRate, int32_t channelCount) 861``` 862 863**Description** 864 865Creates an audio **OH_AVFormat** instance with specified parameters for reading and writing data. 866 867**System capability**: SystemCapability.Multimedia.Media.Core 868 869**Since**: 10 870 871**Parameters** 872 873| Name| Description| 874| -------- | -------- | 875| mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).| 876| sampleRate | Sampling rate, in Hz.| 877| channelCount | Number of audio channels. For example, 1 indicates mono and 2 indicates stereo.| 878 879**Returns** 880 881Returns the pointer to an **OH_AVFormat** instance; returns NULL if the passed-in value of **mimeType** is NULL or system resources are insufficient. 882 883 884### OH_AVFormat_CreateVideoFormat() 885 886``` 887struct OH_AVFormat* OH_AVFormat_CreateVideoFormat (const char *mimeType, int32_t width, int32_t height) 888``` 889 890**Description** 891 892Creates a video **OH_AVFormat** instance with specified parameters for reading and writing data. 893 894**System capability**: SystemCapability.Multimedia.Media.Core 895 896**Since**: 10 897 898**Parameters** 899 900| Name| Description| 901| -------- | -------- | 902| mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).| 903| width | Luminance width, in pixels.| 904| height | Luminance height, in pixels.| 905 906**Returns** 907 908Returns the pointer to an **OH_AVFormat** instance; returns NULL if the passed-in value of **mimeType** is NULL or system resources are insufficient. 909 910 911### OH_AVFormat_Destroy() 912 913``` 914void OH_AVFormat_Destroy (struct OH_AVFormat *format) 915``` 916 917**Description** 918 919Destroys an **OH_AVFormat** instance. The instance cannot be destroyed repeatedly. 920 921**System capability**: SystemCapability.Multimedia.Media.Core 922 923**Since**: 9 924 925**Parameters** 926 927| Name| Description| 928| -------- | -------- | 929| format | Pointer to an **OH_AVFormat** instance.| 930 931**Returns** 932 933No return value. 934 935### OH_AVFormat_DumpInfo() 936 937``` 938const char* OH_AVFormat_DumpInfo (struct OH_AVFormat *format) 939``` 940 941**Description** 942 943Returns a string consisting of key-value pairs contained in an **OH_AVFormat**. A string of up to 1024 bytes can be returned. The string pointer is released when the **OH_AVFormat** instance is destroyed. 944 945**System capability**: SystemCapability.Multimedia.Media.Core 946 947**Since**: 9 948 949**Parameters** 950 951| Name| Description| 952| -------- | -------- | 953| format | Pointer to an **OH_AVFormat** instance.| 954 955**Returns** 956 957Returns the pointer to a collection of strings, in the format of key-value pairs; returns NULL if the passed-in value of **format** is NULL or system resources are insufficient. 958 959 960### OH_AVFormat_GetBuffer() 961 962``` 963bool OH_AVFormat_GetBuffer (struct OH_AVFormat *format, const char *key, uint8_t ** addr, size_t *size) 964``` 965 966**Description** 967 968Reads data blocks of a specified length from an **OH_AVFormat** instance. 969 970**System capability**: SystemCapability.Multimedia.Media.Core 971 972**Since**: 9 973 974**Parameters** 975 976| Name| Description| 977| -------- | -------- | 978| format | Pointer to an **OH_AVFormat** instance.| 979| key | Pointer to the key of the data to read.| 980| addr | Double pointer to the address where the data read is stored. The data read is destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory.| 981| size | Pointer to the size of the data read.| 982 983**Returns** 984 985Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 986 987The possible causes of an operation failure are as follows: 988 9891. The passed-in value of **format** is a null pointer. 9902. The passed-in value of **format** fails parameter structure verification. 9913. The passed-in value of **key** is a null pointer. 9924. The passed-in value of **addr** is a null pointer. 9935. The passed-in value of **size** is a null pointer. 9946. The obtained key does not exist or is not set. 995 996 997### OH_AVFormat_GetDoubleValue() 998 999``` 1000bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat *format, const char *key, double *out) 1001``` 1002 1003**Description** 1004 1005Obtains the value of the double type of a key contained in an **OH_AVFormat**. 1006 1007**System capability**: SystemCapability.Multimedia.Media.Core 1008 1009**Since**: 9 1010 1011**Parameters** 1012 1013| Name| Description| 1014| -------- | -------- | 1015| format | Pointer to an **OH_AVFormat** instance.| 1016| key | Pointer to the key of the data to read.| 1017| out | Pointer to the value of the data read.| 1018 1019**Returns** 1020 1021Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1022 1023The possible causes of an operation failure are as follows: 1024 10251. The passed-in value of **format** is a null pointer. 10262. The passed-in value of **format** fails parameter structure verification. 10273. The passed-in value of **key** is a null pointer. 10284. The passed-in value of **out** is a null pointer. 10295. The obtained key does not exist or is not set. 1030 1031 1032### OH_AVFormat_GetFloatValue() 1033 1034``` 1035bool OH_AVFormat_GetFloatValue (struct OH_AVFormat *format, const char *key, float *out) 1036``` 1037 1038**Description** 1039 1040Obtains the value of the float type of a key contained in an **OH_AVFormat**. 1041 1042**System capability**: SystemCapability.Multimedia.Media.Core 1043 1044**Since**: 9 1045 1046**Parameters** 1047 1048| Name| Description| 1049| -------- | -------- | 1050| format | Pointer to an **OH_AVFormat** instance.| 1051| key | Pointer to the key of the data to read.| 1052| out | Pointer to the value of the data read.| 1053 1054**Returns** 1055 1056Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1057 1058The possible causes of an operation failure are as follows: 1059 10601. The passed-in value of **format** is a null pointer. 10612. The passed-in value of **format** fails parameter structure verification. 10623. The passed-in value of **key** is a null pointer. 10634. The passed-in value of **out** is a null pointer. 10645. The obtained key does not exist or is not set. 1065 1066 1067### OH_AVFormat_GetIntValue() 1068 1069``` 1070bool OH_AVFormat_GetIntValue (struct OH_AVFormat *format, const char *key, int32_t *out) 1071``` 1072 1073**Description** 1074 1075Obtains the value of the int type of a key contained in an **OH_AVFormat**. 1076 1077**System capability**: SystemCapability.Multimedia.Media.Core 1078 1079**Since**: 9 1080 1081**Parameters** 1082 1083| Name| Description| 1084| -------- | -------- | 1085| format | Pointer to an **OH_AVFormat** instance.| 1086| key | Pointer to the key of the data to read.| 1087| out | Pointer to the value of the data read.| 1088 1089**Returns** 1090 1091Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1092 1093The possible causes of an operation failure are as follows: 1094 10951. The passed-in value of **format** is a null pointer. 10962. The passed-in value of **format** fails parameter structure verification. 10973. The passed-in value of **key** is a null pointer. 10984. The passed-in value of **out** is a null pointer. 10995. The obtained key does not exist or is not set. 1100 1101 1102### OH_AVFormat_GetLongValue() 1103 1104``` 1105bool OH_AVFormat_GetLongValue (struct OH_AVFormat *format, const char *key, int64_t *out) 1106``` 1107 1108**Description** 1109 1110Obtains the value of the long type of a key contained in an **OH_AVFormat**. 1111 1112**System capability**: SystemCapability.Multimedia.Media.Core 1113 1114**Since**: 9 1115 1116**Parameters** 1117 1118| Name| Description| 1119| -------- | -------- | 1120| format | Pointer to an **OH_AVFormat** instance.| 1121| key | Pointer to the key of the data to read.| 1122| out | Pointer to the value of the data read.| 1123 1124**Returns** 1125 1126Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1127 1128The possible causes of an operation failure are as follows: 1129 11301. The passed-in value of **format** is a null pointer. 11312. The passed-in value of **format** fails parameter structure verification. 11323. The passed-in value of **key** is a null pointer. 11334. The passed-in value of **out** is a null pointer. 11345. The obtained key does not exist or is not set. 1135 1136 1137### OH_AVFormat_GetStringValue() 1138 1139``` 1140bool OH_AVFormat_GetStringValue (struct OH_AVFormat *format, const char *key, const char ** out) 1141``` 1142 1143**Description** 1144 1145Obtains the value of the string type of a key contained in an **OH_AVFormat**. 1146 1147**System capability**: SystemCapability.Multimedia.Media.Core 1148 1149**Since**: 9 1150 1151**Parameters** 1152 1153| Name| Description| 1154| -------- | -------- | 1155| format | Pointer to an **OH_AVFormat** instance.| 1156| key | Pointer to the key of the data to read.| 1157| out | Double-pointer to the string obtained. The lifecycle of the data of **out** corresponds to that of the string in the **OH_AVFormat** instance. The maximum length of the output string is 256 bytes. To hold the data for an extended period of time, copy it to the memory.| 1158 1159**Returns** 1160 1161Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1162 1163The possible causes of an operation failure are as follows: 1164 11651. The passed-in value of **format** is a null pointer. 11662. The passed-in value of **format** fails parameter structure verification. 11673. The passed-in value of **key** is a null pointer. 11684. The passed-in value of **out** is a null pointer. 11695. The system resources are insufficient. 11706. The obtained key does not exist or is not set. 1171 1172 1173### OH_AVFormat_SetBuffer() 1174 1175``` 1176bool OH_AVFormat_SetBuffer (struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size) 1177``` 1178 1179**Description** 1180 1181Writes data blocks of a specified length to an **OH_AVFormat** instance. This function can be used to set only parameters of the buffer type. For details, see [CodecBase](_codec_base.md). 1182 1183**System capability**: SystemCapability.Multimedia.Media.Core 1184 1185**Since**: 9 1186 1187**Parameters** 1188 1189| Name| Description| 1190| -------- | -------- | 1191| format | Pointer to an **OH_AVFormat** instance.| 1192| key | Pointer to the key of the data to write.| 1193| addr | Double-pointer to the address to which data is written. The lifecycle is managed by the developer.| 1194| size | Length of the data written, in MB. The value range is (0, 1).| 1195 1196**Returns** 1197 1198Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1199 1200The possible causes of an operation failure are as follows: 1201 12021. The passed-in value of **format** is a null pointer. 12032. The passed-in value of **format** fails parameter structure verification. 12043. The passed-in value of **key** is a null pointer. 12054. The passed-in value of **addr** is a null pointer. 12065. The size is 0 or exceeds the upper limit (1 MB). 12076. The value type corresponding to the key is incorrect. 1208 1209 1210### OH_AVFormat_SetDoubleValue() 1211 1212``` 1213bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat *format, const char *key, double value) 1214``` 1215 1216**Description** 1217 1218Assigns a value of the double type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance. This function can be used to set only parameters of the double type. For details, see [CodecBase](_codec_base.md). 1219 1220**System capability**: SystemCapability.Multimedia.Media.Core 1221 1222**Since**: 9 1223 1224**Parameters** 1225 1226| Name| Description| 1227| -------- | -------- | 1228| format | Pointer to an **OH_AVFormat** instance.| 1229| key | Pointer to the key of the data to write.| 1230| value | Value of the data to write.| 1231 1232**Returns** 1233 1234Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1235 1236The possible causes of an operation failure are as follows: 1237 12381. The passed-in value of **format** is a null pointer. 12392. The passed-in value of **format** fails parameter structure verification. 12403. The passed-in value of **key** is a null pointer. 12414. The value type corresponding to the key is incorrect. 1242 1243 1244### OH_AVFormat_SetFloatValue() 1245 1246``` 1247bool OH_AVFormat_SetFloatValue (struct OH_AVFormat *format, const char *key, float value) 1248``` 1249 1250**Description** 1251 1252Assigns a value of the float type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance. This function can be used to set only parameters of the float type. For details, see [CodecBase](_codec_base.md). 1253 1254**System capability**: SystemCapability.Multimedia.Media.Core 1255 1256**Since**: 9 1257 1258**Parameters** 1259 1260| Name| Description| 1261| -------- | -------- | 1262| format | Pointer to an **OH_AVFormat** instance.| 1263| key | Pointer to the key of the data to write.| 1264| value | Value of the data to write.| 1265 1266**Returns** 1267 1268Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1269 1270The possible causes of an operation failure are as follows: 1271 12721. The passed-in value of **format** is a null pointer. 12732. The passed-in value of **format** fails parameter structure verification. 12743. The passed-in value of **key** is a null pointer. 12754. The value type corresponding to the key is incorrect. 1276 1277### OH_AVFormat_SetIntValue() 1278 1279``` 1280bool OH_AVFormat_SetIntValue (struct OH_AVFormat *format, const char *key, int32_t value) 1281``` 1282 1283**Description** 1284 1285Assigns a value of the int type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance. This function can be used to set only parameters of the int type. For details, see [CodecBase](_codec_base.md). 1286 1287**System capability**: SystemCapability.Multimedia.Media.Core 1288 1289**Since**: 9 1290 1291**Parameters** 1292 1293| Name| Description| 1294| -------- | -------- | 1295| format | Pointer to an **OH_AVFormat** instance.| 1296| key | Pointer to the key of the data to write.| 1297| value | Value of the data to write.| 1298 1299**Returns** 1300 1301Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1302 1303The possible causes of an operation failure are as follows: 1304 13051. The passed-in value of **format** is a null pointer. 13062. The passed-in value of **format** fails parameter structure verification. 13073. The passed-in value of **key** is a null pointer. 13084. The value type corresponding to the key is incorrect. 1309 1310 1311### OH_AVFormat_SetLongValue() 1312 1313``` 1314bool OH_AVFormat_SetLongValue (struct OH_AVFormat *format, const char *key, int64_t value) 1315``` 1316 1317**Description** 1318 1319Assigns a value of the long type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance. This function can be used to set only parameters of the long type. For details, see [CodecBase](_codec_base.md). 1320 1321**System capability**: SystemCapability.Multimedia.Media.Core 1322 1323**Since**: 9 1324 1325**Parameters** 1326 1327| Name| Description| 1328| -------- | -------- | 1329| format | Pointer to an **OH_AVFormat** instance.| 1330| key | Pointer to the key of the data to write.| 1331| value | Value of the data to write.| 1332 1333**Returns** 1334 1335Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1336 1337The possible causes of an operation failure are as follows: 1338 13391. The passed-in value of **format** is a null pointer. 13402. The passed-in value of **format** fails parameter structure verification. 13413. The passed-in value of **key** is a null pointer. 13424. The value type corresponding to the key is incorrect. 1343 1344 1345### OH_AVFormat_SetStringValue() 1346 1347``` 1348bool OH_AVFormat_SetStringValue (struct OH_AVFormat *format, const char *key, const char *value) 1349``` 1350 1351**Description** 1352 1353Assigns a value of the string type to a [key](_codec_base#media-data-key-value-pairs) in an **OH_AVFormat** instance. This function can be used to set only parameters of the string type. For details, see [CodecBase](_codec_base.md). 1354 1355**System capability**: SystemCapability.Multimedia.Media.Core 1356 1357**Since**: 9 1358 1359**Parameters** 1360 1361| Name| Description| 1362| -------- | -------- | 1363| format | Pointer to an **OH_AVFormat** instance.| 1364| key | Pointer to the key of the data to write.| 1365| value | Pointer to the string to write. If the length exceeds 256 bytes, the system truncates the data.| 1366 1367**Returns** 1368 1369Returns **TRUE** if the operation is successful; returns **FALSE** otherwise. 1370 1371The possible causes of an operation failure are as follows: 1372 13731. The passed-in value of **format** is a null pointer. 13742. The passed-in value of **format** fails parameter structure verification. 13753. The passed-in value of **key** is a null pointer. 13764. The passed-in value of **value** is a null pointer. 13775. The value type corresponding to the key is incorrect. 1378 1379 1380### OH_AVMemory_Create() 1381 1382``` 1383OH_AVMemory* OH_AVMemory_Create (int32_t size) 1384``` 1385 1386**Description** 1387 1388Creates an **OH_AVMemory** instance. 1389 1390**System capability**: SystemCapability.Multimedia.Media.Core 1391 1392**Since**: 10 1393 1394**Deprecated from**: 11 1395 1396**Substitute**: [OH_AVBuffer_Create](#oh_avbuffer_create) 1397 1398**Parameters** 1399 1400| Name| Description| 1401| -------- | -------- | 1402| size | Size of the created memory, in bytes.| 1403 1404**Returns** 1405 1406Returns the pointer to the **OH_AVMemory** instance created if the operation is successful; returns NULL otherwise. The instance must be released by calling **OH_AVMemory_Destroy** when it is no longer required. 1407 1408 1409### OH_AVMemory_Destroy() 1410 1411``` 1412OH_AVErrCode OH_AVMemory_Destroy (struct OH_AVMemory *mem) 1413``` 1414 1415**Description** 1416 1417Releases an **OH_AVMemory** instance. 1418 1419**System capability**: SystemCapability.Multimedia.Media.Core 1420 1421**Since**: 10 1422 1423**Deprecated from**: 11 1424 1425**Substitute**: [OH_AVBuffer_Destroy](#oh_avbuffer_destroy) 1426 1427**Parameters** 1428 1429| Name| Description| 1430| -------- | -------- | 1431| mem | Pointer to an **OH_AVMemory** instance.| 1432 1433**Returns** 1434 1435Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](#oh_averrcode-1) otherwise. 1436 1437 1438### OH_AVMemory_GetAddr() 1439 1440``` 1441uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory *mem) 1442``` 1443 1444**Description** 1445 1446Obtains the virtual memory address. 1447 1448**System capability**: SystemCapability.Multimedia.Media.Core 1449 1450**Since**: 9 1451 1452**Deprecated from**: 11 1453 1454**Substitute**: [OH_AVBuffer_GetAddr](#oh_avbuffer_getaddr) 1455 1456**Parameters** 1457 1458| Name| Description| 1459| -------- | -------- | 1460| mem | Pointer to an **OH_AVMemory** instance.| 1461 1462**Returns** 1463 1464Returns the pointer to the virtual memory address if the memory is valid; returns NULL otherwise. 1465 1466The possible causes of an operation failure are as follows: 1467 14681. The passed-in value of **mem** is a null pointer. 14692. The passed-in value of **mem** fails parameter structure verification. 14703. The memory in the passed-in value of **mem** is a null pointer. 1471 1472 1473### OH_AVMemory_GetSize() 1474 1475``` 1476int32_t OH_AVMemory_GetSize (struct OH_AVMemory *mem) 1477``` 1478 1479**Description** 1480 1481Obtains the memory length. 1482 1483**System capability**: SystemCapability.Multimedia.Media.Core 1484 1485**Since**: 9 1486 1487**Deprecated from**: 11 1488 1489**Substitute**: [OH_AVBuffer_GetCapacity](#oh_avbuffer_getcapacity) 1490 1491**Parameters** 1492 1493| Name| Description| 1494| -------- | -------- | 1495| mem | Pointer to an **OH_AVMemory** instance.| 1496 1497**Returns** 1498 1499Returns the memory size if the memory is valid; returns **-1** otherwise. 1500 1501The possible causes of an operation failure are as follows: 1502 15031. The passed-in value of **mem** is a null pointer. 15042. The passed-in value of **mem** fails parameter structure verification. 15053. The memory in the passed-in value of **mem** is a null pointer. 1506