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 &lt;&lt; 0U,<br>CH_SET_FRONT_RIGHT = 1ULL &lt;&lt; 1U,<br>CH_SET_FRONT_CENTER = 1ULL &lt;&lt; 2U,<br>CH_SET_LOW_FREQUENCY = 1ULL &lt;&lt; 3U,<br>CH_SET_BACK_LEFT = 1ULL &lt;&lt; 4U,<br>CH_SET_BACK_RIGHT = 1ULL &lt;&lt; 5U,<br>CH_SET_FRONT_LEFT_OF_CENTER = 1ULL &lt;&lt; 6U,<br>CH_SET_FRONT_RIGHT_OF_CENTER = 1ULL &lt;&lt; 7U,<br>CH_SET_BACK_CENTER = 1ULL &lt;&lt; 8U,<br>CH_SET_SIDE_LEFT = 1ULL &lt;&lt; 9U,<br>CH_SET_SIDE_RIGHT = 1ULL &lt;&lt; 10U,<br>CH_SET_TOP_CENTER = 1ULL &lt;&lt; 11U,<br>CH_SET_TOP_FRONT_LEFT = 1ULL &lt;&lt; 12U,<br>CH_SET_TOP_FRONT_CENTER = 1ULL &lt;&lt; 13U,<br>CH_SET_TOP_FRONT_RIGHT = 1ULL &lt;&lt; 14U,<br>CH_SET_TOP_BACK_LEFT = 1ULL &lt;&lt; 15U,<br>CH_SET_TOP_BACK_CENTER = 1ULL &lt;&lt; 16U,<br>CH_SET_TOP_BACK_RIGHT = 1ULL &lt;&lt; 17U,<br>CH_SET_STEREO_LEFT = 1ULL &lt;&lt; 29U,<br>CH_SET_STEREO_RIGHT = 1ULL &lt;&lt; 30U,<br>CH_SET_WIDE_LEFT = 1ULL &lt;&lt; 31U,<br>CH_SET_WIDE_RIGHT = 1ULL &lt;&lt; 32U,<br>CH_SET_SURROUND_DIRECT_LEFT = 1ULL &lt;&lt; 33U,<br>CH_SET_SURROUND_DIRECT_RIGHT = 1ULL &lt;&lt; 34U,<br>CH_SET_LOW_FREQUENCY_2 = 1ULL &lt;&lt; 35U,<br>CH_SET_TOP_SIDE_LEFT = 1ULL &lt;&lt; 36U,<br>CH_SET_TOP_SIDE_RIGHT = 1ULL &lt;&lt; 37U,<br>CH_SET_BOTTOM_FRONT_CENTER = 1ULL &lt;&lt; 38U,<br>CH_SET_BOTTOM_FRONT_LEFT = 1ULL &lt;&lt; 39U,<br>CH_SET_BOTTOM_FRONT_RIGHT = 1ULL &lt;&lt; 40U<br>} | Enumerates the audio channel sets.| 
57| [OH_AmbAttributeSet](#oh_ambattributeset-1) {<br>AMB_ORD_1 = 1ULL &lt;&lt; 0U,<br>AMB_ORD_2 = 2ULL &lt;&lt; 0U,<br>AMB_ORD_3 = 3ULL &lt;&lt; 0U,<br>AMB_COM_ACN = 0ULL &lt;&lt; 8U,<br>AMB_COM_FUMA = 1ULL &lt;&lt; 8U,<br>AMB_NOR_N3D = 0ULL &lt;&lt; 12U,<br>AMB_NOR_SN3D = 1ULL &lt;&lt; 12U,<br>AMB_MODE = 1ULL &lt;&lt; 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 &lt;&lt; 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 &lt;&lt; 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 &lt;&lt; 2,<br>AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 &lt;&lt; 3, <br>AVCODEC_BUFFER_FLAGS_DISCARD = 1 &lt;&lt; 4, <br>AVCODEC_BUFFER_FLAGS_DISPOSABLE = 1 &lt;&lt; 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 contained in an **OH_AVFormat**.| 
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 contained in an **OH_AVFormat**.| 
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 contained in an **OH_AVFormat**.| 
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 contained in an **OH_AVFormat**.| 
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 contained in an **OH_AVFormat**.| 
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
568**System capability**: SystemCapability.Multimedia.Media.Core
569
570**Since**: 11
571
572**Parameters**
573
574| Name| Description| 
575| -------- | -------- |
576| buffer | Pointer to an **OH_AVBuffer** instance.| 
577
578**Returns**
579
580Returns the virtual address if the operation is successful; returns NULL otherwise.
581
582The possible causes of an operation failure are as follows:
583
5841. The passed-in value of **buffer** is a null pointer.
5852. The passed-in value of **OH_AVBuffer** fails parameter structure verification.
5863. An internal error occurred.
587
588
589### OH_AVBuffer_GetBufferAttr()
590
591```
592OH_AVErrCode OH_AVBuffer_GetBufferAttr (OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr)
593```
594
595**Description**
596
597Obtains the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer.
598
599**System capability**: SystemCapability.Multimedia.Media.Core
600
601**Since**: 11
602
603**Parameters**
604
605| Name| Description| 
606| -------- | -------- |
607| buffer | Pointer to an **OH_AVBuffer** instance.| 
608| attr | Pointer to an [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) instance.| 
609
610**Returns**
611
612Returns any of the following result code:
613
614**AV_ERR_OK**: The operation is successful.
615
616**AV_ERR_INVALID_VAL**: The operation fails.
617
618    Possible causes are as follows:
619    1. The passed-in value of **buffer** or **attr** is a null pointer.
620    2. The passed-in value of **buffer** fails parameter structure verification.
621
622
623### OH_AVBuffer_GetCapacity()
624
625```
626int32_t OH_AVBuffer_GetCapacity (OH_AVBuffer *buffer)
627```
628
629**Description**
630
631Obtains the capacity (in bytes) of a buffer.
632
633**System capability**: SystemCapability.Multimedia.Media.Core
634
635**Since**: 11
636
637**Parameters**
638
639| Name| Description| 
640| -------- | -------- |
641| buffer | Pointer to an **OH_AVBuffer** instance.| 
642
643**Returns**
644
645Returns the capacity if the operation is successful; returns **-1** otherwise.
646
647The possible causes of an operation failure are as follows:
648
6491. The passed-in value of **buffer** is a null pointer.
6502. The passed-in value of **OH_AVBuffer** fails parameter structure verification.
6513. An internal error occurred.
652
653
654### OH_AVBuffer_GetNativeBuffer()
655
656```
657OH_NativeBuffer* OH_AVBuffer_GetNativeBuffer (OH_AVBuffer *buffer)
658```
659
660**Description**
661
662Obtains 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.
663
664**System capability**: SystemCapability.Multimedia.Media.Core
665
666**Since**: 11
667
668**Parameters**
669
670| Name| Description| 
671| -------- | -------- |
672| buffer | Pointer to an **OH_AVBuffer** instance.| 
673
674**Returns**
675
676Returns the pointer to the **OH_NativeBuffer** instance created if the operation is successful; returns NULL otherwise.
677
678The possible causes of an operation failure are as follows:
679
6801. The passed-in value of **buffer** is a null pointer.
6812. The passed-in value of **OH_AVBuffer** fails parameter structure verification.
6823. An internal error occurred.
683
684
685### OH_AVBuffer_GetParameter()
686
687```
688OH_AVFormat* OH_AVBuffer_GetParameter (OH_AVBuffer *buffer)
689```
690
691**Description**
692
693Obtains 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.
694
695**System capability**: SystemCapability.Multimedia.Media.Core
696
697**Since**: 11
698
699**Parameters**
700
701| Name| Description| 
702| -------- | -------- |
703| buffer | Pointer to an **OH_AVBuffer** instance.| 
704
705**Returns**
706
707Returns any of the following result code:
708
709**AV_ERR_OK**: The operation is successful.
710
711**AV_ERR_INVALID_VAL**: The operation fails.
712
713    Possible causes are as follows:
714    1. The passed-in value of **buffer** is a null pointer.
715    2. The meta of the buffer is a null pointer.
716    3. The passed-in value of **buffer** fails parameter structure verification.
717
718
719### OH_AVBuffer_SetBufferAttr()
720
721```
722OH_AVErrCode OH_AVBuffer_SetBufferAttr (OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr)
723```
724
725**Description**
726
727Sets the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer.
728
729**System capability**: SystemCapability.Multimedia.Media.Core
730
731**Since**: 11
732
733**Parameters**
734
735| Name| Description| 
736| -------- | -------- |
737| buffer | Pointer to an **OH_AVBuffer** instance.| 
738| attr | Pointer to an [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) instance.| 
739
740**Returns**
741
742Returns any of the following result code:
743
744**AV_ERR_OK**: The operation is successful.
745
746**AV_ERR_INVALID_VAL**: The operation fails.
747
748    Possible causes are as follows:
749    1. The passed-in value of **buffer** or **attr** is a null pointer.
750    2. The passed-in value of **buffer** fails parameter structure verification.
751    3. The memory size or offset of the buffer is invalid.
752
753
754### OH_AVBuffer_SetParameter()
755
756```
757OH_AVErrCode OH_AVBuffer_SetParameter (OH_AVBuffer *buffer, const OH_AVFormat *format)
758```
759
760**Description**
761
762Sets parameters except basic attributes of a buffer. The information is carried in an **OH_AVFormat** instance.
763
764**System capability**: SystemCapability.Multimedia.Media.Core
765
766**Since**: 11
767
768**Parameters**
769
770| Name| Description| 
771| -------- | -------- |
772| buffer | Pointer to an **OH_AVBuffer** instance.| 
773| format | Pointer to an **OH_AVFormat** instance.| 
774
775**Returns**
776
777Returns any of the following result code:
778
779**AV_ERR_OK**: The operation is successful.
780
781**AV_ERR_INVALID_VAL**: The operation fails.
782
783    Possible causes are as follows:
784    1. The passed-in value of **buffer** or **format** is a null pointer.
785    2. The meta of the buffer is a null pointer.
786    3. The passed-in value of **buffer** fails parameter structure verification.
787
788
789### OH_AVFormat_Copy()
790
791```
792bool OH_AVFormat_Copy (struct OH_AVFormat *to, struct OH_AVFormat *from)
793```
794
795**Description**
796
797Copies an **OH_AVFormat** instance.
798
799**System capability**: SystemCapability.Multimedia.Media.Core
800
801**Since**: 9
802
803**Parameters**
804
805| Name| Description| 
806| -------- | -------- |
807| to | Pointer to the **OH_AVFormat** instance to which the data will be copied.| 
808| from | Pointer to the **OH_AVFormat** instance from which the data will be copied.| 
809
810**Returns**
811
812Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
813
814The possible causes of an operation failure are as follows:
815
8161. The input parameter is a null pointer.
8172. The passed-in value of **OH_AVFormat** fails parameter structure verification.
818
819
820### OH_AVFormat_Create()
821
822```
823struct OH_AVFormat* OH_AVFormat_Create (void)
824```
825
826**Description**
827
828Create an **OH_AVFormat** instance for reading and writing data.
829
830**System capability**: SystemCapability.Multimedia.Media.Core
831
832**Since**: 9
833
834**Returns**
835
836Returns the pointer to an **OH_AVFormat** instance; returns NULL if system resources are insufficient.
837
838
839### OH_AVFormat_CreateAudioFormat()
840
841```
842struct OH_AVFormat* OH_AVFormat_CreateAudioFormat (const char *mimeType, int32_t sampleRate, int32_t channelCount)
843```
844
845**Description**
846
847Creates an audio **OH_AVFormat** instance with specified parameters for reading and writing data.
848
849**System capability**: SystemCapability.Multimedia.Media.Core
850
851**Since**: 10
852
853**Parameters**
854
855| Name| Description| 
856| -------- | -------- |
857| mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).| 
858| sampleRate | Sampling rate, in Hz.| 
859| channelCount | Number of audio channels. For example, 1 indicates mono and 2 indicates stereo.| 
860
861**Returns**
862
863Returns the pointer to an **OH_AVFormat** instance; returns NULL if the passed-in value of **mimeType** is NULL or system resources are insufficient.
864
865
866### OH_AVFormat_CreateVideoFormat()
867
868```
869struct OH_AVFormat* OH_AVFormat_CreateVideoFormat (const char *mimeType, int32_t width, int32_t height)
870```
871
872**Description**
873
874Creates a video **OH_AVFormat** instance with specified parameters for reading and writing data.
875
876**System capability**: SystemCapability.Multimedia.Media.Core
877
878**Since**: 10
879
880**Parameters**
881
882| Name| Description| 
883| -------- | -------- |
884| mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).| 
885| width | Luminance width, in pixels.| 
886| height | Luminance height, in pixels.| 
887
888**Returns**
889
890Returns the pointer to an **OH_AVFormat** instance; returns NULL if the passed-in value of **mimeType** is NULL or system resources are insufficient.
891
892
893### OH_AVFormat_Destroy()
894
895```
896void OH_AVFormat_Destroy (struct OH_AVFormat *format)
897```
898
899**Description**
900
901Destroys an **OH_AVFormat** instance. The instance cannot be destroyed repeatedly.
902
903**System capability**: SystemCapability.Multimedia.Media.Core
904
905**Since**: 9
906
907**Parameters**
908
909| Name| Description| 
910| -------- | -------- |
911| format | Pointer to an **OH_AVFormat** instance.| 
912
913**Returns**
914
915No return value.
916
917### OH_AVFormat_DumpInfo()
918
919```
920const char* OH_AVFormat_DumpInfo (struct OH_AVFormat *format)
921```
922
923**Description**
924
925Returns 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.
926
927**System capability**: SystemCapability.Multimedia.Media.Core
928
929**Since**: 9
930
931**Parameters**
932
933| Name| Description| 
934| -------- | -------- |
935| format | Pointer to an **OH_AVFormat** instance.| 
936
937**Returns**
938
939Returns 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.
940
941
942### OH_AVFormat_GetBuffer()
943
944```
945bool OH_AVFormat_GetBuffer (struct OH_AVFormat *format, const char *key, uint8_t ** addr, size_t *size)
946```
947
948**Description**
949
950Reads data blocks of a specified length from an **OH_AVFormat** instance.
951
952**System capability**: SystemCapability.Multimedia.Media.Core
953
954**Since**: 9
955
956**Parameters**
957
958| Name| Description| 
959| -------- | -------- |
960| format | Pointer to an **OH_AVFormat** instance.| 
961| key | Pointer to the key of the data to read.| 
962| 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.| 
963| size | Pointer to the size of the data read.| 
964
965**Returns**
966
967Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
968
969The possible causes of an operation failure are as follows:
970
9711. The passed-in value of **format** is a null pointer.
9722. The passed-in value of **format** fails parameter structure verification.
9733. The passed-in value of **key** is a null pointer.
9744. The passed-in value of **addr** is a null pointer.
9755. The passed-in value of **size** is a null pointer.
9766. The obtained key does not exist or is not set.
977
978
979### OH_AVFormat_GetDoubleValue()
980
981```
982bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat *format, const char *key, double *out)
983```
984
985**Description**
986
987Obtains the value of the double type of a key contained in an **OH_AVFormat**.
988
989**System capability**: SystemCapability.Multimedia.Media.Core
990
991**Since**: 9
992
993**Parameters**
994
995| Name| Description| 
996| -------- | -------- |
997| format | Pointer to an **OH_AVFormat** instance.| 
998| key | Pointer to the key of the data to read.| 
999| out | Pointer to the value of the data read.| 
1000
1001**Returns**
1002
1003Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1004
1005The possible causes of an operation failure are as follows:
1006
10071. The passed-in value of **format** is a null pointer.
10082. The passed-in value of **format** fails parameter structure verification.
10093. The passed-in value of **key** is a null pointer.
10104. The passed-in value of **out** is a null pointer.
10115. The obtained key does not exist or is not set.
1012
1013
1014### OH_AVFormat_GetFloatValue()
1015
1016```
1017bool OH_AVFormat_GetFloatValue (struct OH_AVFormat *format, const char *key, float *out)
1018```
1019
1020**Description**
1021
1022Obtains the value of the float type of a key contained in an **OH_AVFormat**.
1023
1024**System capability**: SystemCapability.Multimedia.Media.Core
1025
1026**Since**: 9
1027
1028**Parameters**
1029
1030| Name| Description| 
1031| -------- | -------- |
1032| format | Pointer to an **OH_AVFormat** instance.| 
1033| key | Pointer to the key of the data to read.| 
1034| out | Pointer to the value of the data read.| 
1035
1036**Returns**
1037
1038Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1039
1040The possible causes of an operation failure are as follows:
1041
10421. The passed-in value of **format** is a null pointer.
10432. The passed-in value of **format** fails parameter structure verification.
10443. The passed-in value of **key** is a null pointer.
10454. The passed-in value of **out** is a null pointer.
10465. The obtained key does not exist or is not set.
1047
1048
1049### OH_AVFormat_GetIntValue()
1050
1051```
1052bool OH_AVFormat_GetIntValue (struct OH_AVFormat *format, const char *key, int32_t *out)
1053```
1054
1055**Description**
1056
1057Obtains the value of the int type of a key contained in an **OH_AVFormat**.
1058
1059**System capability**: SystemCapability.Multimedia.Media.Core
1060
1061**Since**: 9
1062
1063**Parameters**
1064
1065| Name| Description| 
1066| -------- | -------- |
1067| format | Pointer to an **OH_AVFormat** instance.| 
1068| key | Pointer to the key of the data to read.| 
1069| out | Pointer to the value of the data read.| 
1070
1071**Returns**
1072
1073Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1074
1075The possible causes of an operation failure are as follows:
1076
10771. The passed-in value of **format** is a null pointer.
10782. The passed-in value of **format** fails parameter structure verification.
10793. The passed-in value of **key** is a null pointer.
10804. The passed-in value of **out** is a null pointer.
10815. The obtained key does not exist or is not set.
1082
1083
1084### OH_AVFormat_GetLongValue()
1085
1086```
1087bool OH_AVFormat_GetLongValue (struct OH_AVFormat *format, const char *key, int64_t *out)
1088```
1089
1090**Description**
1091
1092Obtains the value of the long type of a key contained in an **OH_AVFormat**.
1093
1094**System capability**: SystemCapability.Multimedia.Media.Core
1095
1096**Since**: 9
1097
1098**Parameters**
1099
1100| Name| Description| 
1101| -------- | -------- |
1102| format | Pointer to an **OH_AVFormat** instance.| 
1103| key | Pointer to the key of the data to read.| 
1104| out | Pointer to the value of the data read.| 
1105
1106**Returns**
1107
1108Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1109
1110The possible causes of an operation failure are as follows:
1111
11121. The passed-in value of **format** is a null pointer.
11132. The passed-in value of **format** fails parameter structure verification.
11143. The passed-in value of **key** is a null pointer.
11154. The passed-in value of **out** is a null pointer.
11165. The obtained key does not exist or is not set.
1117
1118
1119### OH_AVFormat_GetStringValue()
1120
1121```
1122bool OH_AVFormat_GetStringValue (struct OH_AVFormat *format, const char *key, const char ** out)
1123```
1124
1125**Description**
1126
1127Obtains the value of the string type of a key contained in an **OH_AVFormat**.
1128
1129**System capability**: SystemCapability.Multimedia.Media.Core
1130
1131**Since**: 9
1132
1133**Parameters**
1134
1135| Name| Description| 
1136| -------- | -------- |
1137| format | Pointer to an **OH_AVFormat** instance.| 
1138| key | Pointer to the key of the data to read.| 
1139| 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.| 
1140
1141**Returns**
1142
1143Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1144
1145The possible causes of an operation failure are as follows:
1146
11471. The passed-in value of **format** is a null pointer.
11482. The passed-in value of **format** fails parameter structure verification.
11493. The passed-in value of **key** is a null pointer.
11504. The passed-in value of **out** is a null pointer.
11515. The system resources are insufficient.
11526. The obtained key does not exist or is not set.
1153
1154
1155### OH_AVFormat_SetBuffer()
1156
1157```
1158bool OH_AVFormat_SetBuffer (struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size)
1159```
1160
1161**Description**
1162
1163Writes 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).
1164
1165**System capability**: SystemCapability.Multimedia.Media.Core
1166
1167**Since**: 9
1168
1169**Parameters**
1170
1171| Name| Description| 
1172| -------- | -------- |
1173| format | Pointer to an **OH_AVFormat** instance.| 
1174| key | Pointer to the key of the data to write.| 
1175| addr | Double-pointer to the address to which data is written. The lifecycle is managed by the developer.| 
1176| size | Length of the data written, in MB. The value range is (0, 1).| 
1177
1178**Returns**
1179
1180Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1181
1182The possible causes of an operation failure are as follows:
1183
11841. The passed-in value of **format** is a null pointer.
11852. The passed-in value of **format** fails parameter structure verification.
11863. The passed-in value of **key** is a null pointer.
11874. The passed-in value of **addr** is a null pointer.
11885. The size is 0 or exceeds the upper limit 1 MB.
11896. The value type corresponding to the key is incorrect.
1190
1191
1192### OH_AVFormat_SetDoubleValue()
1193
1194```
1195bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat *format, const char *key, double value)
1196```
1197
1198**Description**
1199
1200Assigns a value of the double type to a key contained in an **OH_AVFormat**. This function can be used to set only parameters of the double type. For details, see [CodecBase](_codec_base.md).
1201
1202**System capability**: SystemCapability.Multimedia.Media.Core
1203
1204**Since**: 9
1205
1206**Parameters**
1207
1208| Name| Description| 
1209| -------- | -------- |
1210| format | Pointer to an **OH_AVFormat** instance.| 
1211| key | Pointer to the key of the data to write.| 
1212| value | Value of the data to write.| 
1213
1214**Returns**
1215
1216Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1217
1218The possible causes of an operation failure are as follows:
1219
12201. The passed-in value of **format** is a null pointer.
12212. The passed-in value of **format** fails parameter structure verification.
12223. The passed-in value of **key** is a null pointer.
12234. The value type corresponding to the key is incorrect.
1224
1225
1226### OH_AVFormat_SetFloatValue()
1227
1228```
1229bool OH_AVFormat_SetFloatValue (struct OH_AVFormat *format, const char *key, float value)
1230```
1231
1232**Description**
1233
1234Assigns a value of the float type to a key contained in an **OH_AVFormat**. This function can be used to set only parameters of the float type. For details, see [CodecBase](_codec_base.md).
1235
1236**System capability**: SystemCapability.Multimedia.Media.Core
1237
1238**Since**: 9
1239
1240**Parameters**
1241
1242| Name| Description| 
1243| -------- | -------- |
1244| format | Pointer to an **OH_AVFormat** instance.| 
1245| key | Pointer to the key of the data to write.| 
1246| value | Value of the data to write.| 
1247
1248**Returns**
1249
1250Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1251
1252The possible causes of an operation failure are as follows:
1253
12541. The passed-in value of **format** is a null pointer.
12552. The passed-in value of **format** fails parameter structure verification.
12563. The passed-in value of **key** is a null pointer.
12574. The value type corresponding to the key is incorrect.
1258
1259### OH_AVFormat_SetIntValue()
1260
1261```
1262bool OH_AVFormat_SetIntValue (struct OH_AVFormat *format, const char *key, int32_t value)
1263```
1264
1265**Description**
1266
1267Assigns a value of the int type to a key contained in an **OH_AVFormat**. This function can be used to set only parameters of the int type. For details, see [CodecBase](_codec_base.md).
1268
1269**System capability**: SystemCapability.Multimedia.Media.Core
1270
1271**Since**: 9
1272
1273**Parameters**
1274
1275| Name| Description| 
1276| -------- | -------- |
1277| format | Pointer to an **OH_AVFormat** instance.| 
1278| key | Pointer to the key of the data to write.| 
1279| value | Value of the data to write.| 
1280
1281**Returns**
1282
1283Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1284
1285The possible causes of an operation failure are as follows:
1286
12871. The passed-in value of **format** is a null pointer.
12882. The passed-in value of **format** fails parameter structure verification.
12893. The passed-in value of **key** is a null pointer.
12904. The value type corresponding to the key is incorrect.
1291
1292
1293### OH_AVFormat_SetLongValue()
1294
1295```
1296bool OH_AVFormat_SetLongValue (struct OH_AVFormat *format, const char *key, int64_t value)
1297```
1298
1299**Description**
1300
1301Assigns a value of the long type to a key contained in an **OH_AVFormat**. This function can be used to set only parameters of the long type. For details, see [CodecBase](_codec_base.md).
1302
1303**System capability**: SystemCapability.Multimedia.Media.Core
1304
1305**Since**: 9
1306
1307**Parameters**
1308
1309| Name| Description| 
1310| -------- | -------- |
1311| format | Pointer to an **OH_AVFormat** instance.| 
1312| key | Pointer to the key of the data to write.| 
1313| value | Value of the data to write.| 
1314
1315**Returns**
1316
1317Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1318
1319The possible causes of an operation failure are as follows:
1320
13211. The passed-in value of **format** is a null pointer.
13222. The passed-in value of **format** fails parameter structure verification.
13233. The passed-in value of **key** is a null pointer.
13244. The value type corresponding to the key is incorrect.
1325
1326
1327### OH_AVFormat_SetStringValue()
1328
1329```
1330bool OH_AVFormat_SetStringValue (struct OH_AVFormat *format, const char *key, const char *value)
1331```
1332
1333**Description**
1334
1335Assigns a value of the string type to a key contained in an **OH_AVFormat**. This function can be used to set only parameters of the string type. For details, see [CodecBase](_codec_base.md).
1336
1337**System capability**: SystemCapability.Multimedia.Media.Core
1338
1339**Since**: 9
1340
1341**Parameters**
1342
1343| Name| Description| 
1344| -------- | -------- |
1345| format | Pointer to an **OH_AVFormat** instance.| 
1346| key | Pointer to the key of the data to write.| 
1347| value | Pointer to the string to write. If the length exceeds 256 bytes, the system truncates the data.| 
1348
1349**Returns**
1350
1351Returns **TRUE** if the operation is successful; returns **FALSE** otherwise.
1352
1353The possible causes of an operation failure are as follows:
1354
13551. The passed-in value of **format** is a null pointer.
13562. The passed-in value of **format** fails parameter structure verification.
13573. The passed-in value of **key** is a null pointer.
13584. The passed-in value of **value** is a null pointer.
13595. The value type corresponding to the key is incorrect.
1360
1361
1362### OH_AVMemory_Create()
1363
1364```
1365OH_AVMemory* OH_AVMemory_Create (int32_t size)
1366```
1367
1368**Description**
1369
1370Creates an **OH_AVMemory** instance.
1371
1372**System capability**: SystemCapability.Multimedia.Media.Core
1373
1374**Since**: 10
1375
1376**Deprecated from**: 11
1377
1378**Substitute**: [OH_AVBuffer_Create](#oh_avbuffer_create)
1379
1380**Parameters**
1381
1382| Name| Description| 
1383| -------- | -------- |
1384| size | Size of the created memory, in bytes.| 
1385
1386**Returns**
1387
1388Returns 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.
1389
1390
1391### OH_AVMemory_Destroy()
1392
1393```
1394OH_AVErrCode OH_AVMemory_Destroy (struct OH_AVMemory *mem)
1395```
1396
1397**Description**
1398
1399Releases an **OH_AVMemory** instance.
1400
1401**System capability**: SystemCapability.Multimedia.Media.Core
1402
1403**Since**: 10
1404
1405**Deprecated from**: 11
1406
1407**Substitute**: [OH_AVBuffer_Destroy](#oh_avbuffer_destroy)
1408
1409**Parameters**
1410
1411| Name| Description| 
1412| -------- | -------- |
1413| mem | Pointer to an **OH_AVMemory** instance.| 
1414
1415**Returns**
1416
1417Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](#oh_averrcode-1) otherwise.
1418
1419
1420### OH_AVMemory_GetAddr()
1421
1422```
1423uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory *mem)
1424```
1425
1426**Description**
1427
1428Obtains the virtual memory address.
1429
1430**System capability**: SystemCapability.Multimedia.Media.Core
1431
1432**Since**: 9
1433
1434**Deprecated from**: 11
1435
1436**Substitute**: [OH_AVBuffer_GetAddr](#oh_avbuffer_getaddr)
1437
1438**Parameters**
1439
1440| Name| Description| 
1441| -------- | -------- |
1442| mem | Pointer to an **OH_AVMemory** instance.| 
1443
1444**Returns**
1445
1446Returns the pointer to the virtual memory address if the memory is valid; returns NULL otherwise.
1447
1448The possible causes of an operation failure are as follows:
1449
14501. The passed-in value of **mem** is a null pointer.
14512. The passed-in value of **mem** fails parameter structure verification.
14523. The memory in the passed-in value of **mem** is a null pointer.
1453
1454
1455### OH_AVMemory_GetSize()
1456
1457```
1458int32_t OH_AVMemory_GetSize (struct OH_AVMemory *mem)
1459```
1460
1461**Description**
1462
1463Obtains the memory length.
1464
1465**System capability**: SystemCapability.Multimedia.Media.Core
1466
1467**Since**: 9
1468
1469**Deprecated from**: 11
1470
1471**Substitute**: [OH_AVBuffer_GetCapacity](#oh_avbuffer_getcapacity)
1472
1473**Parameters**
1474
1475| Name| Description| 
1476| -------- | -------- |
1477| mem | Pointer to an **OH_AVMemory** instance.| 
1478
1479**Returns**
1480
1481Returns the memory size if the memory is valid; returns **-1** otherwise.
1482
1483The possible causes of an operation failure are as follows:
1484
14851. The passed-in value of **mem** is a null pointer.
14862. The passed-in value of **mem** fails parameter structure verification.
14873. The memory in the passed-in value of **mem** is a null pointer.
1488