• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Core
2
3
4## Overview
5
6The Core module provides the basic backbone capabilities for the media system, including functions related to the memory, error code, and media data 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| [media_types.h](media__types_8h.md) | Declares the common media types.|
21| [native_audio_channel_layout.h](native__audio__channel__layout_8h.md) | Declares the functions related to the speaker layout during recording and playback.|
22| [native_avbuffer.h](native__avbuffer_8h.md) | Declares the functions of the media struct AVBuffer.|
23| [native_avbuffer_info.h](native__avbuffer__info_8h.md) | Declares the attribute definition of the media struct AVBuffer.|
24| [native_averrors.h](native__averrors_8h.md) | Declares the error codes used by the media system.|
25| [native_avformat.h](native__avformat_8h.md) | Declares the functions and enums related to OH_AVFormat.|
26| [native_avmemory.h](native__avmemory_8h.md) | Declares the attribute definition of the media struct AVMemory.|
27
28
29### Structs
30
31| Name| Description|
32| -------- | -------- |
33| struct  [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Describes the description information about the buffer of an OH_AVCodec instance. |
34
35
36### Types
37
38| Name| Description|
39| -------- | -------- |
40| typedef enum [OH_Core_HdrType](#oh_core_hdrtype) [OH_Core_HdrType](#oh_core_hdrtype) | Defines an enum for the HDR types.|
41| typedef enum [OH_AudioChannelSet](#oh_audiochannelset-1) [OH_AudioChannelSet](#oh_audiochannelset) | Defines an enum for the audio channels.|
42| typedef enum [OH_AmbAttributeSet](#oh_ambattributeset-1) [OH_AmbAttributeSet](#oh_ambattributeset) | Defines an enum for the Hi-Fi stereo reverberation settings.|
43| typedef enum [OH_AudioChannelLayout](#oh_audiochannellayout-1) [OH_AudioChannelLayout](#oh_audiochannellayout) | Defines an enum for the layouts of audio channels.|
44| typedef struct [OH_AVBuffer](#oh_avbuffer) [OH_AVBuffer](#oh_avbuffer) | Defines a struct that describes a native object for the media memory interface.|
45| typedef struct [OH_NativeBuffer](#oh_nativebuffer) [OH_NativeBuffer](#oh_nativebuffer) | Defines a struct that describes a native object for the graphics memory interface.|
46| 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.|
47| 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.|
48| typedef enum [OH_AVErrCode](#oh_averrcode-1) [OH_AVErrCode](#oh_averrcode) | Defines an enum for the error codes used by the media system.|
49| typedef struct [OH_AVFormat](#oh_avformat) [OH_AVFormat](#oh_avformat) | Defines a struct for a native object for the OH_AVFormat interface.|
50| typedef enum [OH_AVPixelFormat](#oh_avpixelformat-1) [OH_AVPixelFormat](#oh_avpixelformat) | Defines an enum for the video pixel formats.|
51| 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.|
52
53
54### Enums
55
56| Name| Description|
57| -------- | -------- |
58| [OH_Core_HdrType](#oh_core_hdrtype-1) {<br> OH_CORE_HDR_TYPE_NONE = 0, <br>OH_CORE_HDR_TYPE_VIVID = 1 } | Enumerates the HDR types.|
59| [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 channels.|
60| [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.|
61| [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.|
62| [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. |
63| [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_UNSUPPORTED_FORMAT = 11,<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>AV_ERR_IO_CANNOT_FIND_HOST = 5411001,<br>AV_ERR_IO_CONNECTION_TIMEOUT = 5411002,<br>AV_ERR_IO_NETWORK_ABNORMAL = 5411003,<br>AV_ERR_IO_NETWORK_UNAVAILABLE = 5411004,<br>AV_ERR_IO_NO_PERMISSION = 5411005,<br>AV_ERR_IO_NETWORK_ACCESS_DENIED = 5411006,<br>AV_ERR_IO_RESOURCE_NOT_FOUND = 5411007,<br>AV_ERR_IO_SSL_CLIENT_CERT_NEEDED = 5411008,<br>AV_ERR_IO_SSL_CONNECT_FAIL = 5411009,<br>AV_ERR_IO_SSL_SERVER_CERT_UNTRUSTED = 5411010,<br>AV_ERR_IO_UNSUPPORTED_REQUEST = 5411011,<br>AV_ERR_STREAM_CHANGED = 5410005,<br>AV_ERR_TRY_AGAIN_LATER  = 5410006<br>} | Enumerates the error codes used by the media system. |
64| [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>AV_PIXEL_FORMAT_RGBA1010102 = 6<br>} | Enumerates the video pixel formats.|
65
66
67### Functions
68
69| Name| Description|
70| -------- | -------- |
71| [OH_AVBuffer](#oh_avbuffer) \* [OH_AVBuffer_Create](#oh_avbuffer_create) (int32_t capacity) | Creates an OH_AVBuffer instance. You must call [OH_AVBuffer_Destroy](#oh_avbuffer_destroy) to manually release the OH_AVBuffer instance returned.|
72| [OH_AVErrCode](#oh_averrcode) [OH_AVBuffer_Destroy](#oh_avbuffer_destroy) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Releases an OH_AVBuffer instance.|
73| [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.|
74| [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.|
75| [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.|
76| [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.|
77| uint8_t \* [OH_AVBuffer_GetAddr](#oh_avbuffer_getaddr) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Obtains the virtual address of a data buffer.|
78| int32_t [OH_AVBuffer_GetCapacity](#oh_avbuffer_getcapacity) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Obtains the capacity (in bytes) of a buffer.|
79| [OH_NativeBuffer](#oh_nativebuffer) \* [OH_AVBuffer_GetNativeBuffer](#oh_avbuffer_getnativebuffer) ([OH_AVBuffer](#oh_avbuffer) \*buffer) | Obtains the pointer to an OH_NativeBuffer instance.|
80| struct [OH_AVFormat](#oh_avformat) \* [OH_AVFormat_Create](#oh_avformat_create) (void) | Create an OH_AVFormat instance for reading and writing data.|
81| 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.|
82| 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.|
83| void [OH_AVFormat_Destroy](#oh_avformat_destroy) (struct [OH_AVFormat](#oh_avformat) \*format) | Destroys an OH_AVFormat instance.|
84| bool [OH_AVFormat_Copy](#oh_avformat_copy) (struct [OH_AVFormat](#oh_avformat) \*to, struct [OH_AVFormat](#oh_avformat) \*from) | Copies an OH_AVFormat instance.|
85| 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 in an OH_AVFormat instance.|
86| 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 in an OH_AVFormat instance.|
87| 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 in an OH_AVFormat instance.|
88| 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 in an OH_AVFormat instance.|
89| 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 in an OH_AVFormat instance.|
90| 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.|
91| bool [OH_AVFormat_SetIntBuffer](#oh_avformat_setintbuffer) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, const int32_t \*addr, size_t size) | Writes data blocks of the int32_t type with a specified length to an OH_AVFormat instance.|
92| 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 in an OH_AVFormat instance.|
93| 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 in an OH_AVFormat instance.|
94| 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 in an OH_AVFormat instance.|
95| 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 in an OH_AVFormat instance.|
96| 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 in an OH_AVFormat instance.|
97| 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.|
98| bool [OH_AVFormat_GetIntBuffer](#oh_avformat_getintbuffer) (struct [OH_AVFormat](#oh_avformat) \*format, const char \*key, int32_t \*\*addr, size_t \*size) | Reads an array of int32_t data from an OH_AVFormat instance.|
99| 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 instance.|
100| [OH_AVMemory](#oh_avmemory) \* [OH_AVMemory_Create](#oh_avmemory_create) (int32_t size) | Creates an OH_AVMemory instance. (It is deprecated from API version 11.)|
101| uint8_t \* [OH_AVMemory_GetAddr](#oh_avmemory_getaddr) (struct [OH_AVMemory](#oh_avmemory) \*mem) | Obtains the virtual memory address. (It is deprecated from API version 11.)|
102| int32_t [OH_AVMemory_GetSize](#oh_avmemory_getsize) (struct [OH_AVMemory](#oh_avmemory) \*mem) | Obtains the memory length. (It is deprecated from API version 11.)|
103| [OH_AVErrCode](#oh_averrcode) [OH_AVMemory_Destroy](#oh_avmemory_destroy) (struct [OH_AVMemory](#oh_avmemory) \*mem) | Releases an OH_AVMemory instance. (It is deprecated from API version 11.)|
104
105
106## Type Description
107
108
109### OH_AmbAttributeSet
110
111```
112typedef enum OH_AmbAttributeSet OH_AmbAttributeSet
113```
114
115**Description**
116
117Defines an enum for the Hi-Fi stereo reverberation settings.
118
119int64_t integers are used to indicate the Hi-Fi stereo reverberation attributes.
120
121**System capability**: SystemCapability.Multimedia.Media.Core
122
123**Since**: 11
124
125
126### OH_AudioChannelLayout
127
128```
129typedef enum OH_AudioChannelLayout OH_AudioChannelLayout
130```
131
132**Description**
133
134Defines an enum for the audio channel layouts.
135
136int64_t integers are used to indicate the appearance and sequence of speakers during recording or playback.
137
138**System capability**: SystemCapability.Multimedia.Media.Core
139
140**Since**: 11
141
142
143### OH_AudioChannelSet
144
145```
146typedef enum OH_AudioChannelSet OH_AudioChannelSet
147```
148
149**Description**
150
151Defines an enum for the audio channels.
152
153Each channel is mapped to a variable of int64_t.
154
155**System capability**: SystemCapability.Multimedia.Media.Core
156
157**Since**: 11
158
159
160### OH_AVBuffer
161
162```
163typedef struct OH_AVBuffer OH_AVBuffer
164```
165**Description**
166
167Defines a struct that describes a native object for the media memory interface.
168
169**Since**: 11
170
171
172### OH_AVCodecBufferAttr
173
174```
175typedef struct OH_AVCodecBufferAttr OH_AVCodecBufferAttr
176```
177
178**Description**
179
180Defines the description information about the buffer of an OH_AVCodec instance.
181
182**System capability**: SystemCapability.Multimedia.Media.Core
183
184**Since**: 9
185
186
187### OH_AVCodecBufferFlags
188
189```
190typedef enum OH_AVCodecBufferFlags OH_AVCodecBufferFlags
191```
192
193**Description**
194
195Defines an enum for the flags for the buffer of an OH_AVCodec instance.
196
197**System capability**: SystemCapability.Multimedia.Media.Core
198
199**Since**: 9
200
201
202### OH_AVErrCode
203
204```
205typedef enum OH_AVErrCode OH_AVErrCode
206```
207
208**Description**
209
210Defines an enum for the error codes used by the media system.
211
212**System capability**: SystemCapability.Multimedia.Media.Core
213
214**Since**: 9
215
216
217### OH_AVFormat
218
219```
220typedef struct OH_AVFormat OH_AVFormat
221```
222**Description**
223
224Defines a struct for a native object for the **OH_AVFormat** interface.
225
226**Since**: 9
227
228
229### OH_AVMemory
230
231```
232typedef struct OH_AVMemory OH_AVMemory
233```
234**Description**
235
236Defines a struct that describes a native object for the audio and video memory interface.
237
238**Since**: 9
239
240
241### OH_AVPixelFormat
242
243```
244typedef enum OH_AVPixelFormat OH_AVPixelFormat
245```
246
247**Description**
248
249Defines an enum for the video pixel formats.
250
251**System capability**: SystemCapability.Multimedia.Media.Core
252
253**Since**: 9
254
255
256### OH_NativeBuffer
257
258```
259typedef struct OH_NativeBuffer OH_NativeBuffer
260```
261**Description**
262
263Defines a struct that describes a native object for the graphics memory interface.
264
265**Since**: 11
266
267
268### OH_Core_HdrType
269
270```
271typedef enum OH_Core_HdrType OH_Core_HdrType
272```
273
274**Description**
275
276Defines an enum for the HDR types.
277
278**System capability**: SystemCapability.Multimedia.Media.Core
279
280**Since**: 18
281
282
283## Enum Description
284
285
286### OH_AmbAttributeSet
287
288```
289enum OH_AmbAttributeSet
290```
291
292**Description**
293
294Enumerates the Hi-Fi stereo reverberation settings.
295
296int64_t integers are used to indicate the Hi-Fi stereo reverberation attributes.
297
298**System capability**: SystemCapability.Multimedia.Media.Core
299
300**Since**: 11
301
302| Value| Description|
303| -------- | -------- |
304| AMB_ORD_1 | First-order Hi-Fi stereo reverberation.|
305| AMB_ORD_2 | Second-order Hi-Fi stereo reverberation.|
306| AMB_ORD_3 | Third-order Hi-Fi stereo reverberation.|
307| AMB_COM_ACN | Hi-Fi stereo reverberation with ACN channel sorting.|
308| AMB_COM_FUMA | Hi-Fi stereo reverberation with FUMA channel sorting.|
309| AMB_NOR_N3D | N3D normalized Hi-Fi stereo reverberation.|
310| AMB_NOR_SN3D | SN3D normalized Hi-Fi stereo reverberation.|
311| AMB_MODE | Audio channel layout for Hi-Fi stereo reverberation.|
312
313
314### OH_AudioChannelLayout
315
316```
317enum OH_AudioChannelLayout
318```
319
320**Description**
321
322Enumerates the layouts of audio channels.
323
324int64_t integers are used to indicate the appearance and sequence of speakers during recording or playback.
325
326**System capability**: SystemCapability.Multimedia.Media.Core
327
328**Since**: 11
329
330| Value| Description|
331| -------- | -------- |
332| CH_LAYOUT_UNKNOWN | Unknown.|
333| CH_LAYOUT_MONO | Mono layout; 1 audio channel in total.|
334| CH_LAYOUT_STEREO | Stereo layout; 2 audio channels in total.|
335| CH_LAYOUT_STEREO_DOWNMIX | Stereo downmix layout; 2 audio channels in total.|
336| CH_LAYOUT_2POINT1 | 2.1 layout; 3 audio channels in total.|
337| CH_LAYOUT_3POINT0 | 3.0 layout; 3 audio channels in total.|
338| CH_LAYOUT_SURROUND | Surround; 3 audio channels in total.|
339| CH_LAYOUT_3POINT1 | 3.1 layout; 4 audio channels in total.|
340| CH_LAYOUT_4POINT0 | 4.0 layout; 4 audio channels in total.|
341| CH_LAYOUT_QUAD_SIDE | Quad side layout; 4 audio channels in total.|
342| CH_LAYOUT_QUAD | Quad layout; 4 audio channels in total.|
343| CH_LAYOUT_2POINT0POINT2 | 2.0.2 layout; 4 audio channels in total.|
344| CH_LAYOUT_AMB_ORDER1_ACN_N3D | First-order FOA layout in ACN_N3D (ITU standards); 4 audio channels in total.|
345| CH_LAYOUT_AMB_ORDER1_ACN_SN3D | First-order FOA layout in ACN_SN3D (ITU standards); 4 audio channels in total.|
346| CH_LAYOUT_AMB_ORDER1_FUMA | First-order FOA layout in FUMA (ITU standards); 4 audio channels in total.|
347| CH_LAYOUT_4POINT1 | 4.1 layout; 5 audio channels in total.|
348| CH_LAYOUT_5POINT0 | 5.0 layout; 5 audio channels in total.|
349| CH_LAYOUT_5POINT0_BACK | 5.0 rear layout; 5 audio channels in total.|
350| CH_LAYOUT_2POINT1POINT2 | 2.1.2 layout; 5 audio channels in total.|
351| CH_LAYOUT_3POINT0POINT2 | 3.0.2 layout; 5 audio channels in total.|
352| CH_LAYOUT_5POINT1 | 5.1 layout; 6 audio channels in total.|
353| CH_LAYOUT_5POINT1_BACK | 5.1 rear layout; 6 audio channels in total.|
354| CH_LAYOUT_6POINT0 | 6.0 layout; 6 audio channels in total.|
355| CH_LAYOUT_3POINT1POINT2 | 3.1.2 layout; 6 audio channels in total.|
356| CH_LAYOUT_6POINT0_FRONT | 6.0 front layout; 6 audio channels in total.|
357| CH_LAYOUT_HEXAGONAL | Hexagonal layout; 6 audio channels in total.|
358| CH_LAYOUT_6POINT1 | 6.1 layout; 7 audio channels in total.|
359| CH_LAYOUT_6POINT1_BACK | 6.1 rear layout; 7 audio channels in total.|
360| CH_LAYOUT_6POINT1_FRONT | 6.1 front layout; 7 audio channels in total.|
361| CH_LAYOUT_7POINT0 | 7.0 layout; 7 audio channels in total.|
362| CH_LAYOUT_7POINT0_FRONT | 7.0 front layout; 7 audio channels in total.|
363| CH_LAYOUT_7POINT1 | 7.1 layout; 8 audio channels in total.|
364| CH_LAYOUT_OCTAGONAL | Octagonal layout; 8 audio channels in total.|
365| CH_LAYOUT_5POINT1POINT2 | 5.1.2 layout; 8 audio channels in total.|
366| CH_LAYOUT_7POINT1_WIDE | 7.1 wide layout; 8 audio channels in total.|
367| CH_LAYOUT_7POINT1_WIDE_BACK | 7.1 rear wide layout; 8 audio channels in total.|
368| CH_LAYOUT_AMB_ORDER2_ACN_N3D | Second-order HOA layout in ACN_N3D (ITU standards); 9 audio channels in total.|
369| CH_LAYOUT_AMB_ORDER2_ACN_SN3D | Second-order HOA layout in ACN_SN3D (ITU standards); 9 audio channels in total.|
370| CH_LAYOUT_AMB_ORDER2_FUMA | Second-order HOA layout in FUMA (ITU standards); 9 audio channels in total.|
371| CH_LAYOUT_5POINT1POINT4 | 5.1.4 layout; 10 audio channels in total.|
372| CH_LAYOUT_7POINT1POINT2 | 7.1.2 layout; 10 audio channels in total.|
373| CH_LAYOUT_7POINT1POINT4 | 7.1.4 layout; 12 audio channels in total.|
374| CH_LAYOUT_10POINT2 | 10.2 layout; 12 audio channels in total.|
375| CH_LAYOUT_9POINT1POINT4 | 9.1.4 layout; 14 audio channels in total.|
376| CH_LAYOUT_9POINT1POINT6 | 9.1.6 layout; 16 audio channels in total.|
377| CH_LAYOUT_HEXADECAGONAL | Hexadecagonal layout; 16 audio channels in total.|
378| CH_LAYOUT_AMB_ORDER3_ACN_N3D | Third-order HOA layout in ACN_N3D (ITU standards); 16 audio channels in total.|
379| CH_LAYOUT_AMB_ORDER3_ACN_SN3D | Third-order HOA layout in ACN_SN3D (ITU standards); 16 audio channels in total.|
380| CH_LAYOUT_AMB_ORDER3_FUMA | Third-order HOA layout in FUMA (ITU standards); 16 audio channels in total.|
381| CH_LAYOUT_22POINT2 | 22.2 layout; 24 audio channels in total.|
382
383
384### OH_AudioChannelSet
385
386```
387enum OH_AudioChannelSet
388```
389
390**Description**
391
392Enumerates the audio channels.
393
394Each channel is mapped to a variable of int64_t.
395
396**System capability**: SystemCapability.Multimedia.Media.Core
397
398**Since**: 11
399
400| Value| Description|
401| -------- | -------- |
402| CH_SET_FRONT_LEFT | Front left channel.|
403| CH_SET_FRONT_RIGHT | Front right channel.|
404| CH_SET_FRONT_CENTER | Front center channel.|
405| CH_SET_LOW_FREQUENCY | Low-frequency channel.|
406| CH_SET_BACK_LEFT | Rear left channel.|
407| CH_SET_BACK_RIGHT | Rear right channel.|
408| CH_SET_FRONT_LEFT_OF_CENTER | Front left center channel.|
409| CH_SET_FRONT_RIGHT_OF_CENTER | Front right center channel.|
410| CH_SET_BACK_CENTER | Rear center channel.|
411| CH_SET_SIDE_LEFT | Left channel.|
412| CH_SET_SIDE_RIGHT | Right channel.|
413| CH_SET_TOP_CENTER | Top center channel.|
414| CH_SET_TOP_FRONT_LEFT | Top left front channel.|
415| CH_SET_TOP_FRONT_CENTER | Top center front channel.|
416| CH_SET_TOP_FRONT_RIGHT | Top right front channel.|
417| CH_SET_TOP_BACK_LEFT | Top left rear channel.|
418| CH_SET_TOP_BACK_CENTER | Top center rear channel.|
419| CH_SET_TOP_BACK_RIGHT | Top right rear channel.|
420| CH_SET_STEREO_LEFT | Stereo left channel.|
421| CH_SET_STEREO_RIGHT | Stereo right channel.|
422| CH_SET_WIDE_LEFT | Wide left channel.|
423| CH_SET_WIDE_RIGHT | Wide right channel.|
424| CH_SET_SURROUND_DIRECT_LEFT | Left surround channel.|
425| CH_SET_SURROUND_DIRECT_RIGHT | Right surround channel.|
426| CH_SET_LOW_FREQUENCY_2 | Low-frequency channel 2.|
427| CH_SET_TOP_SIDE_LEFT | Top left channel.|
428| CH_SET_TOP_SIDE_RIGHT | Top right channel.|
429| CH_SET_BOTTOM_FRONT_CENTER | Bottom center front channel.|
430| CH_SET_BOTTOM_FRONT_LEFT | Bottom left front channel.|
431| CH_SET_BOTTOM_FRONT_RIGHT | Bottom right front channel.|
432
433
434### OH_AVCodecBufferFlags
435
436```
437enum OH_AVCodecBufferFlags
438```
439
440**Description**
441
442Enumerates the flags for the buffer of an OH_AVCodec instance.
443
444**System capability**: SystemCapability.Multimedia.Media.Core
445
446**Since**: 9
447
448| Value| Description|
449| -------- | -------- |
450| AVCODEC_BUFFER_FLAGS_NONE | Common frame.|
451| AVCODEC_BUFFER_FLAGS_EOS | The buffer is an end-of-stream frame.|
452| AVCODEC_BUFFER_FLAGS_SYNC_FRAME | The buffer contains key frames.|
453| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME | The data in the buffer is only part of the frame.|
454| AVCODEC_BUFFER_FLAGS_CODEC_DATA | The buffer contains codec-specific data.|
455| AVCODEC_BUFFER_FLAGS_DISCARD  | The decoding process depends on the buffer, and the decoded data can be discarded.<br>**Since**: 12|
456| AVCODEC_BUFFER_FLAGS_DISPOSABLE  | The buffer can be disposed directly.<br>**Since**: 12|
457
458
459### OH_AVErrCode
460
461```
462enum OH_AVErrCode
463```
464
465**Description**
466
467Enumerates the error codes used by the media system.
468
469**System capability**: SystemCapability.Multimedia.Media.Core
470
471**Since**: 9
472
473| Value| Description|
474| -------- | -------- |
475| AV_ERR_OK  | Operation successful.  |
476| AV_ERR_NO_MEMORY  | No memory.  |
477| AV_ERR_OPERATE_NOT_PERMIT  | Operation not allowed.  |
478| AV_ERR_INVALID_VAL  | Invalid value.  |
479| AV_ERR_IO  | I/O error.  |
480| AV_ERR_TIMEOUT  | Timeout.  |
481| AV_ERR_UNKNOWN  | Unknown error.  |
482| AV_ERR_SERVICE_DIED  | Unavailable service.  |
483| AV_ERR_INVALID_STATE  | Unsupported operation in this state.  |
484| AV_ERR_UNSUPPORT  | Unsupported feature.  |
485| AV_ERR_UNSUPPORTED_FORMAT | Coding format not supported.<br>**Since**: 18|
486| AV_ERR_EXTEND_START  | Initial value for extended error codes.  |
487| AV_ERR_DRM_BASE  | DRM start error code.<br>**Since**: 12|
488| AV_ERR_DRM_DECRYPT_FAILED  | DRM decryption fails.<br>**Since**: 12|
489| AV_ERR_VIDEO_BASE   | Video start error code.<br>**Since**: 12|
490| AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION   | Color Space Conversion (CSC) is not supported.<br>**Since**: 12|
491| AV_ERR_IO_CANNOT_FIND_HOST   | The host is not found. The possible cause is that the server address is incorrect.<br>**Since**: 14|
492| AV_ERR_IO_CONNECTION_TIMEOUT   | Network connection times out.<br>**Since**: 14|
493| AV_ERR_IO_NETWORK_ABNORMAL   | The connection fails due to a network error.<br>**Since**: 14|
494| AV_ERR_IO_NETWORK_UNAVAILABLE   | The connection fails due to network unavailability.<br>**Since**: 14|
495| AV_ERR_IO_NO_PERMISSION   | No network access permission.<br>**Since**: 14|
496| AV_ERR_IO_NETWORK_ACCESS_DENIED   | The client request parameter is incorrect or exceeds the processing capability.<br>**Since**: 14|
497| AV_ERR_IO_RESOURCE_NOT_FOUND   | No network resource is available.<br>**Since**: 14|
498| AV_ERR_IO_SSL_CLIENT_CERT_NEEDED   | Server authentication fails because the client certificate is not carried, is invalid, or has expired.<br>**Since**: 14|
499| AV_ERR_IO_SSL_CONNECT_FAIL   | Client authentication fails because the server certificate is not carried, is invalid, or has expired.<br>**Since**: 14|
500| AV_ERR_IO_SSL_SERVER_CERT_UNTRUSTED   | The SSL server certificate is untrusted.<br>**Since**: 14|
501| AV_ERR_IO_UNSUPPORTED_REQUEST   | The network protocol does not support the request.<br>**Since**: 14|
502| AV_ERR_STREAM_CHANGED | The stream format changes in synchronous mode. You can call [OH_VideoEncoder_GetOutputDescription](_video_encoder.md#oh_videoencoder_getoutputdescription) (video encoding), [OH_VideoDecoder_GetOutputDescription](_video_decoder.md#oh_videodecoder_getoutputdescription) (video decoding), or [OH_AudioCodec_GetOutputDescription](_audio_codec.md#oh_audiocodec_getoutputdescription) (audio encoding and decoding) to obtain the new stream configuration.<br>**Since**: 20|
503| AV_ERR_TRY_AGAIN_LATER  | The temporary buffer query fails in synchronous mode. You are advised to wait for a short period of time and try again.<br>**Since**: 20|
504
505### OH_AVPixelFormat
506
507```
508enum OH_AVPixelFormat
509```
510
511**Description**
512
513Enumerates the video pixel formats.
514
515**System capability**: SystemCapability.Multimedia.Media.Core
516
517**Since**: 9
518
519| Value| Description|
520| -------- | -------- |
521| AV_PIXEL_FORMAT_YUVI420 | YUV 420 Planar.|
522| AV_PIXEL_FORMAT_NV12 | NV12. YUV 420 semi-planar.|
523| AV_PIXEL_FORMAT_NV21 | NV21. YVU 420 semi-planar.|
524| AV_PIXEL_FORMAT_SURFACE_FORMAT | Pixel format obtained from the surface. This value takes effect only in surface mode.|
525| AV_PIXEL_FORMAT_RGBA | RGBA8888.|
526| AV_PIXEL_FORMAT_RGBA1010102 | RGBA1010102.<br>**Since**: 20|
527
528
529### OH_Core_HdrType
530
531```
532enum OH_Core_HdrType
533```
534
535**Description**
536
537Enumerates the HDR types.
538
539**System capability**: SystemCapability.Multimedia.Media.Core
540
541**Since**: 18
542
543| Value| Description|
544| -------- | -------- |
545| OH_CORE_HDR_TYPE_NONE | Non-HDR type.|
546| OH_CORE_HDR_TYPE_VIVID | HDR Vivid type.|
547
548
549## Function Description
550
551
552### OH_AVBuffer_Create()
553
554```
555OH_AVBuffer* OH_AVBuffer_Create (int32_t capacity)
556```
557
558**Description**
559
560Creates an OH_AVBuffer instance. You must call [OH_AVBuffer_Destroy](#oh_avbuffer_destroy) to manually release the OH_AVBuffer instance returned.
561
562**System capability**: SystemCapability.Multimedia.Media.Core
563
564**Since**: 11
565
566**Parameters**
567
568| Name| Description|
569| -------- | -------- |
570| capacity | Size of the created memory, in bytes.|
571
572**Returns**
573
574Pointer to the OH_AVBuffer instance created. If the operation fails, NULL is returned.
575
576The possible causes of an operation failure are as follows:
577
5781. The value of **capacity** is less than or equal to 0.
5792. An internal error occurs, or the system does not have resources.
580
581
582### OH_AVBuffer_Destroy()
583
584```
585OH_AVErrCode OH_AVBuffer_Destroy (OH_AVBuffer *buffer)
586```
587
588**Description**
589
590Releases an OH_AVBuffer instance. A buffer cannot be destroyed repeatedly.
591
592**System capability**: SystemCapability.Multimedia.Media.Core
593
594**Since**: 11
595
596**Parameters**
597
598| Name| Description|
599| -------- | -------- |
600| buffer | Pointer to an OH_AVBuffer instance.|
601
602**Returns**
603
604One of the following result codes:
605
606**AV_ERR_OK**: The operation is successful.
607
608**AV_ERR_INVALID_VAL**: The value of **buffer** is nullptr or fails parameter structure verification.
609
610**AV_ERR_OPERATE_NOT_PERMIT**: The input buffer is not created by the user.
611
612
613### OH_AVBuffer_GetAddr()
614
615```
616uint8_t* OH_AVBuffer_GetAddr (OH_AVBuffer *buffer)
617```
618
619**Description**
620
621Obtains the virtual address of a data buffer.
622
623The capability to obtain virtual addresses varies in scenarios, as described in the table below.
624
625**Encoding**
626| Mode| Data Filling Mode|  Capability to Obtain Virtual Addresses|
627| --------------- | -------- | -------- |
628| Surface| OnNeedInputBuffer input | Not supported|
629| Surface| OnNewOutputBuffer output | Supported|
630| Buffer | OnNeedInputBuffer input | Supported|
631| Buffer | OnNewOutputBuffer output | Supported|
632
633**Decoding**
634| Mode| Data Filling Mode|  Capability to Obtain Virtual Addresses|
635| --------------- | -------- | -------- |
636| Surface| OnNeedInputBuffer input | Supported|
637| Surface| OnNewOutputBuffer output | Not supported|
638| Buffer | OnNeedInputBuffer input | Supported|
639| Buffer | OnNewOutputBuffer output | Supported|
640
641**System capability**: SystemCapability.Multimedia.Media.Core
642
643**Since**: 11
644
645**Parameters**
646
647| Name| Description|
648| -------- | -------- |
649| buffer | Pointer to an OH_AVBuffer instance.|
650
651**Returns**
652
653Virtual address. If the operation fails, NULL is returned.
654
655The possible causes of an operation failure are as follows:
656
6571. The value of **buffer** is nullptr.
6582. The value of **OH_AVBuffer** fails parameter structure verification.
6593. An internal error occurred.
660
661
662### OH_AVBuffer_GetBufferAttr()
663
664```
665OH_AVErrCode OH_AVBuffer_GetBufferAttr (OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr)
666```
667
668**Description**
669
670Obtains the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer.
671
672**System capability**: SystemCapability.Multimedia.Media.Core
673
674**Since**: 11
675
676**Parameters**
677
678| Name| Description|
679| -------- | -------- |
680| buffer | Pointer to an OH_AVBuffer instance.|
681| attr | Pointer to an [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) instance.|
682
683**Returns**
684
685One of the following result codes:
686
687**AV_ERR_OK**: The operation is successful.
688
689**AV_ERR_INVALID_VAL**: The operation fails.
690
691    Possible causes are as follows:
692    1. The value of **buffer** or **attr** is nullptr.
693    2. The value of **buffer** fails parameter structure verification.
694
695
696### OH_AVBuffer_GetCapacity()
697
698```
699int32_t OH_AVBuffer_GetCapacity (OH_AVBuffer *buffer)
700```
701
702**Description**
703
704Obtains the capacity (in bytes) of a buffer.
705
706**System capability**: SystemCapability.Multimedia.Media.Core
707
708**Since**: 11
709
710**Parameters**
711
712| Name| Description|
713| -------- | -------- |
714| buffer | Pointer to an OH_AVBuffer instance.|
715
716**Returns**
717
718Capacity. If the operation fails, **-1** is returned.
719
720The possible causes of an operation failure are as follows:
721
7221. The value of **buffer** is nullptr.
7232. The value of **OH_AVBuffer** fails parameter structure verification.
7243. An internal error occurred.
725
726
727### OH_AVBuffer_GetNativeBuffer()
728
729```
730OH_NativeBuffer* OH_AVBuffer_GetNativeBuffer (OH_AVBuffer *buffer)
731```
732
733**Description**
734
735Obtains the pointer to an OH_NativeBuffer instance. You must call [OH_NativeBuffer_Unreference](../apis-arkgraphics2d/capi-native-buffer-h.md#oh_nativebuffer_unreference) to manually release the OH_NativeBuffer instance returned.
736
737**System capability**: SystemCapability.Multimedia.Media.Core
738
739**Since**: 11
740
741**Parameters**
742
743| Name| Description|
744| -------- | -------- |
745| buffer | Pointer to an OH_AVBuffer instance.|
746
747**Returns**
748
749Pointer to the OH_NativeBuffer instance created. If the operation fails, NULL is returned.
750
751The possible causes of an operation failure are as follows:
752
7531. The value of **buffer** is nullptr.
7542. The value of **OH_AVBuffer** fails parameter structure verification.
7553. An internal error occurred.
756
757
758### OH_AVBuffer_GetParameter()
759
760```
761OH_AVFormat* OH_AVBuffer_GetParameter (OH_AVBuffer *buffer)
762```
763
764**Description**
765
766Obtains parameters except basic attributes of a buffer. The information is carried in an OH_AVFormat instance. You must call [OH_AVFormat_Destroy](#oh_avformat_destroy) to manually release the OH_AVFormat instance returned.
767
768**System capability**: SystemCapability.Multimedia.Media.Core
769
770**Since**: 11
771
772**Parameters**
773
774| Name| Description|
775| -------- | -------- |
776| buffer | Pointer to an OH_AVBuffer instance.|
777
778**Returns**
779
780Pointer to the OH_AVFormat instance created. If the operation is fails, NULL is returned.
781
782The possible causes of an operation failure are as follows:
783
7841. The value of **buffer** is nullptr.
7852. The meta of the buffer is nullptr.
7863. The value of **buffer** fails parameter structure verification.
787
788
789### OH_AVBuffer_SetBufferAttr()
790
791```
792OH_AVErrCode OH_AVBuffer_SetBufferAttr (OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr)
793```
794
795**Description**
796
797Sets the basic attributes, including **pts**, **size**, **offset**, and **flags**, of a buffer.
798
799**System capability**: SystemCapability.Multimedia.Media.Core
800
801**Since**: 11
802
803**Parameters**
804
805| Name| Description|
806| -------- | -------- |
807| buffer | Pointer to an OH_AVBuffer instance.|
808| attr | Pointer to an [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) instance.|
809
810**Returns**
811
812One of the following result codes:
813
814**AV_ERR_OK**: The operation is successful.
815
816**AV_ERR_INVALID_VAL**: The operation fails.
817
818    Possible causes are as follows:
819    1. The value of **buffer** or **attr** is nullptr.
820    2. The value of **buffer** fails parameter structure verification.
821    3. The memory size or offset of the buffer is invalid.
822
823
824### OH_AVBuffer_SetParameter()
825
826```
827OH_AVErrCode OH_AVBuffer_SetParameter (OH_AVBuffer *buffer, const OH_AVFormat *format)
828```
829
830**Description**
831
832Sets parameters except basic attributes of a buffer. The information is carried in an OH_AVFormat instance.
833
834**System capability**: SystemCapability.Multimedia.Media.Core
835
836**Since**: 11
837
838**Parameters**
839
840| Name| Description|
841| -------- | -------- |
842| buffer | Pointer to an OH_AVBuffer instance.|
843| format | Pointer to an OH_AVFormat instance.|
844
845**Returns**
846
847One of the following result codes:
848
849**AV_ERR_OK**: The operation is successful.
850
851**AV_ERR_INVALID_VAL**: The operation fails.
852
853    Possible causes are as follows:
854    1. The value of **buffer** or **format** is nullptr.
855    2. The meta of the buffer is nullptr.
856    3. The value of **buffer** fails parameter structure verification.
857
858
859### OH_AVFormat_Copy()
860
861```
862bool OH_AVFormat_Copy (struct OH_AVFormat *to, struct OH_AVFormat *from)
863```
864
865**Description**
866
867Copies an OH_AVFormat instance.
868
869**System capability**: SystemCapability.Multimedia.Media.Core
870
871**Since**: 9
872
873**Parameters**
874
875| Name| Description|
876| -------- | -------- |
877| to | Pointer to the OH_AVFormat instance to which the data will be copied.|
878| from | Pointer to the OH_AVFormat instance from which the data will be copied.|
879
880**Returns**
881
882**TRUE** if the operation is successful; **FALSE** otherwise.
883
884The possible causes of an operation failure are as follows:
885
8861. The input parameter is nullptr.
8872. The value of **OH_AVFormat** fails parameter structure verification.
888
889
890### OH_AVFormat_Create()
891
892```
893struct OH_AVFormat* OH_AVFormat_Create (void)
894```
895
896**Description**
897
898Create an OH_AVFormat instance for reading and writing data.
899
900**System capability**: SystemCapability.Multimedia.Media.Core
901
902**Since**: 9
903
904**Returns**
905
906Pointer to an OH_AVFormat instance. If system resources are insufficient, NULL is returned.
907
908
909### OH_AVFormat_CreateAudioFormat()
910
911```
912struct OH_AVFormat* OH_AVFormat_CreateAudioFormat (const char *mimeType, int32_t sampleRate, int32_t channelCount)
913```
914
915**Description**
916
917Creates an audio OH_AVFormat instance with specified parameters for reading and writing data.
918
919**System capability**: SystemCapability.Multimedia.Media.Core
920
921**Since**: 10
922
923**Parameters**
924
925| Name| Description|
926| -------- | -------- |
927| mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).|
928| sampleRate | Sampling rate, in Hz.|
929| channelCount | Number of audio channels. For example, 1 indicates mono and 2 indicates stereo.|
930
931**Returns**
932
933Pointer to an OH_AVFormat instance. If the passed-in value of **mimeType** is NULL or system resources are insufficient, NULL is returned.
934
935
936### OH_AVFormat_CreateVideoFormat()
937
938```
939struct OH_AVFormat* OH_AVFormat_CreateVideoFormat (const char *mimeType, int32_t width, int32_t height)
940```
941
942**Description**
943
944Creates a video OH_AVFormat instance with specified parameters for reading and writing data.
945
946**System capability**: SystemCapability.Multimedia.Media.Core
947
948**Since**: 10
949
950**Parameters**
951
952| Name| Description|
953| -------- | -------- |
954| mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).|
955| width | Image width, in pixels.|
956| height | Image height, in pixels.|
957
958**Returns**
959
960Pointer to an OH_AVFormat instance. If the passed-in value of **mimeType** is NULL or system resources are insufficient, NULL is returned.
961
962
963### OH_AVFormat_Destroy()
964
965```
966void OH_AVFormat_Destroy (struct OH_AVFormat *format)
967```
968
969**Description**
970
971Destroys an OH_AVFormat instance. The instance cannot be destroyed repeatedly.
972
973**System capability**: SystemCapability.Multimedia.Media.Core
974
975**Since**: 9
976
977**Parameters**
978
979| Name| Description|
980| -------- | -------- |
981| format | Pointer to an OH_AVFormat instance.|
982
983**Returns**
984
985No return value.
986
987### OH_AVFormat_DumpInfo()
988
989```
990const char* OH_AVFormat_DumpInfo (struct OH_AVFormat *format)
991```
992
993**Description**
994
995Returns a string consisting of key-value pairs contained in an OH_AVFormat instance. A string of up to 1024 bytes can be returned. The string pointer is released when the OH_AVFormat instance is destroyed.
996
997**System capability**: SystemCapability.Multimedia.Media.Core
998
999**Since**: 9
1000
1001**Parameters**
1002
1003| Name| Description|
1004| -------- | -------- |
1005| format | Pointer to an OH_AVFormat instance.|
1006
1007**Returns**
1008
1009Pointer to a collection of strings, in the format of key-value pairs. If the passed-in value of **format** is NULL or system resources are insufficient, NULL is returned.
1010
1011
1012### OH_AVFormat_GetBuffer()
1013
1014```
1015bool OH_AVFormat_GetBuffer (struct OH_AVFormat *format, const char *key, uint8_t ** addr, size_t *size)
1016```
1017
1018**Description**
1019
1020Reads data blocks of a specified length from an OH_AVFormat instance.
1021
1022**System capability**: SystemCapability.Multimedia.Media.Core
1023
1024**Since**: 9
1025
1026**Parameters**
1027
1028| Name| Description|
1029| -------- | -------- |
1030| format | Pointer to an OH_AVFormat instance.|
1031| key | Pointer to the key of the data to read.|
1032| 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.|
1033| size | Pointer to the size of the data read.|
1034
1035**Returns**
1036
1037**TRUE** if the operation is successful; **FALSE** otherwise.
1038
1039The possible causes of an operation failure are as follows:
1040
10411. The value of **format** is nullptr.
10422. The value of **format** fails parameter structure verification.
10433. The value of **key** is nullptr.
10444. The value of **addr** is nullptr.
10455. The value of **size** is nullptr.
10466. The obtained key does not exist or is not set.
1047
1048### OH_AVFormat_GetIntBuffer()
1049
1050```
1051bool OH_AVFormat_GetIntBuffer(struct OH_AVFormat *format, const char *key, int32_t **addr, size_t *size)
1052```
1053
1054**Description**
1055
1056Reads an array of int32_t data from an OH_AVFormat instance.
1057Note that the buffer lifecycle is bound to the OH_AVFormat instance. The buffer becomes invalid automatically when the OH_AVFormat instance is destroyed. To keep the data for an extended period, explicitly copy the data to newly allocated memory.
1058
1059**System capability**: SystemCapability.Multimedia.Media.Core
1060
1061**Since**: 20
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| addr | Double pointer to the memory where the data is stored.|
1070| size | Pointer to the number of elements read.|
1071
1072**Returns**
1073
1074**TRUE** if the operation is successful; **FALSE** otherwise.
1075
1076The possible causes of an operation failure are as follows:
1077
10781. The value of **format** is nullptr.
10792. The value of **format** fails parameter structure verification.
10803. The value of **key** is nullptr.
10814. The value of **addr** is nullptr.
10825. The value of **size** is nullptr.
1083
1084### OH_AVFormat_GetDoubleValue()
1085
1086```
1087bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat *format, const char *key, double *out)
1088```
1089
1090**Description**
1091
1092Obtains the value of the double type of a [key](_codec_base.md#media-data-key-value-pairs) in an OH_AVFormat instance.
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
1108**TRUE** if the operation is successful; **FALSE** otherwise.
1109
1110The possible causes of an operation failure are as follows:
1111
11121. The value of **format** is nullptr.
11132. The value of **format** fails parameter structure verification.
11143. The value of **key** is nullptr.
11154. The value of **out** is nullptr.
11165. The obtained key does not exist or is not set.
1117
1118
1119### OH_AVFormat_GetFloatValue()
1120
1121```
1122bool OH_AVFormat_GetFloatValue (struct OH_AVFormat *format, const char *key, float *out)
1123```
1124
1125**Description**
1126
1127Obtains the value of the float type of a [key](_codec_base.md#media-data-key-value-pairs) in an OH_AVFormat instance.
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 | Pointer to the value of the data read.|
1140
1141**Returns**
1142
1143**TRUE** if the operation is successful; **FALSE** otherwise.
1144
1145The possible causes of an operation failure are as follows:
1146
11471. The value of **format** is nullptr.
11482. The value of **format** fails parameter structure verification.
11493. The value of **key** is nullptr.
11504. The value of **out** is nullptr.
11515. The obtained key does not exist or is not set.
1152
1153
1154### OH_AVFormat_GetIntValue()
1155
1156```
1157bool OH_AVFormat_GetIntValue (struct OH_AVFormat *format, const char *key, int32_t *out)
1158```
1159
1160**Description**
1161
1162Obtains the value of the int type of a [key](_codec_base.md#media-data-key-value-pairs) in an OH_AVFormat instance.
1163
1164**System capability**: SystemCapability.Multimedia.Media.Core
1165
1166**Since**: 9
1167
1168**Parameters**
1169
1170| Name| Description|
1171| -------- | -------- |
1172| format | Pointer to an OH_AVFormat instance.|
1173| key | Pointer to the key of the data to read.|
1174| out | Pointer to the value of the data read.|
1175
1176**Returns**
1177
1178**TRUE** if the operation is successful; **FALSE** otherwise.
1179
1180The possible causes of an operation failure are as follows:
1181
11821. The value of **format** is nullptr.
11832. The value of **format** fails parameter structure verification.
11843. The value of **key** is nullptr.
11854. The value of **out** is nullptr.
11865. The obtained key does not exist or is not set.
1187
1188
1189### OH_AVFormat_GetLongValue()
1190
1191```
1192bool OH_AVFormat_GetLongValue (struct OH_AVFormat *format, const char *key, int64_t *out)
1193```
1194
1195**Description**
1196
1197Obtains the value of the long type of a [key](_codec_base.md#media-data-key-value-pairs) in an OH_AVFormat instance.
1198
1199**System capability**: SystemCapability.Multimedia.Media.Core
1200
1201**Since**: 9
1202
1203**Parameters**
1204
1205| Name| Description|
1206| -------- | -------- |
1207| format | Pointer to an OH_AVFormat instance.|
1208| key | Pointer to the key of the data to read.|
1209| out | Pointer to the value of the data read.|
1210
1211**Returns**
1212
1213**TRUE** if the operation is successful; **FALSE** otherwise.
1214
1215The possible causes of an operation failure are as follows:
1216
12171. The value of **format** is nullptr.
12182. The value of **format** fails parameter structure verification.
12193. The value of **key** is nullptr.
12204. The value of **out** is nullptr.
12215. The obtained key does not exist or is not set.
1222
1223
1224### OH_AVFormat_GetStringValue()
1225
1226```
1227bool OH_AVFormat_GetStringValue (struct OH_AVFormat *format, const char *key, const char ** out)
1228```
1229
1230**Description**
1231
1232Obtains the value of the string type of a [key](_codec_base.md#media-data-key-value-pairs) in an OH_AVFormat instance.
1233
1234**System capability**: SystemCapability.Multimedia.Media.Core
1235
1236**Since**: 9
1237
1238**Parameters**
1239
1240| Name| Description|
1241| -------- | -------- |
1242| format | Pointer to an OH_AVFormat instance.|
1243| key | Pointer to the key of the data to read.|
1244| out | Double pointer to the string read. The lifecycle of the **out** data matches the string in **format**. To keep the **out** data for an extended period of time, you must copy it to the memory. The maximum length of the output string is 256 bytes. If the length exceeds 256 bytes, **false** is returned.|
1245
1246**Returns**
1247
1248**TRUE** if the operation is successful; **FALSE** otherwise.
1249
1250The possible causes of an operation failure are as follows:
1251
12521. The value of **format** is nullptr.
12532. The value of **format** fails parameter structure verification.
12543. The value of **key** is nullptr.
12554. The value of **out** is nullptr.
12565. The system resources are insufficient.
12576. The obtained key does not exist or is not set.
12587. The length of the **out** data exceeds 256 bytes.
1259
1260
1261### OH_AVFormat_SetBuffer()
1262
1263```
1264bool OH_AVFormat_SetBuffer (struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size)
1265```
1266
1267**Description**
1268
1269Writes 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).
1270
1271**System capability**: SystemCapability.Multimedia.Media.Core
1272
1273**Since**: 9
1274
1275**Parameters**
1276
1277| Name| Description|
1278| -------- | -------- |
1279| format | Pointer to an OH_AVFormat instance.|
1280| key | Pointer to the key of the data to write.|
1281| addr | Pointer to the address to which data is written. The lifecycle is managed by the developer.|
1282| size | Length of the data written, in MB. The value range is (0, 1].|
1283
1284**Returns**
1285
1286**TRUE** if the operation is successful; **FALSE** otherwise.
1287
1288The possible causes of an operation failure are as follows:
1289
12901. The value of **format** is nullptr.
12912. The value of **format** fails parameter structure verification.
12923. The value of **key** is nullptr.
12934. The value of **addr** is nullptr.
12945. The size is 0 or exceeds the upper limit (1 MB).
12956. The value type corresponding to the key is incorrect.
1296
1297
1298### OH_AVFormat_SetDoubleValue()
1299
1300```
1301bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat *format, const char *key, double value)
1302```
1303
1304**Description**
1305
1306Assigns a value of the double type to a [key](_codec_base.md#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).
1307
1308**System capability**: SystemCapability.Multimedia.Media.Core
1309
1310**Since**: 9
1311
1312**Parameters**
1313
1314| Name| Description|
1315| -------- | -------- |
1316| format | Pointer to an OH_AVFormat instance.|
1317| key | Pointer to the key of the data to write.|
1318| value | Value of the data to write.|
1319
1320**Returns**
1321
1322**TRUE** if the operation is successful; **FALSE** otherwise.
1323
1324The possible causes of an operation failure are as follows:
1325
13261. The value of **format** is nullptr.
13272. The value of **format** fails parameter structure verification.
13283. The value of **key** is nullptr.
13294. The value type corresponding to the key is incorrect.
1330
1331
1332### OH_AVFormat_SetFloatValue()
1333
1334```
1335bool OH_AVFormat_SetFloatValue (struct OH_AVFormat *format, const char *key, float value)
1336```
1337
1338**Description**
1339
1340Assigns a value of the float type to a [key](_codec_base.md#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).
1341
1342**System capability**: SystemCapability.Multimedia.Media.Core
1343
1344**Since**: 9
1345
1346**Parameters**
1347
1348| Name| Description|
1349| -------- | -------- |
1350| format | Pointer to an OH_AVFormat instance.|
1351| key | Pointer to the key of the data to write.|
1352| value | Value of the data to write.|
1353
1354**Returns**
1355
1356**TRUE** if the operation is successful; **FALSE** otherwise.
1357
1358The possible causes of an operation failure are as follows:
1359
13601. The value of **format** is nullptr.
13612. The value of **format** fails parameter structure verification.
13623. The value of **key** is nullptr.
13634. The value type corresponding to the key is incorrect.
1364
1365### OH_AVFormat_SetIntValue()
1366
1367```
1368bool OH_AVFormat_SetIntValue (struct OH_AVFormat *format, const char *key, int32_t value)
1369```
1370
1371**Description**
1372
1373Assigns a value of the int type to a [key](_codec_base.md#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).
1374
1375**System capability**: SystemCapability.Multimedia.Media.Core
1376
1377**Since**: 9
1378
1379**Parameters**
1380
1381| Name| Description|
1382| -------- | -------- |
1383| format | Pointer to an OH_AVFormat instance.|
1384| key | Pointer to the key of the data to write.|
1385| value | Value of the data to write.|
1386
1387**Returns**
1388
1389**TRUE** if the operation is successful; **FALSE** otherwise.
1390
1391The possible causes of an operation failure are as follows:
1392
13931. The value of **format** is nullptr.
13942. The value of **format** fails parameter structure verification.
13953. The value of **key** is nullptr.
13964. The value type corresponding to the key is incorrect.
1397
1398
1399### OH_AVFormat_SetLongValue()
1400
1401```
1402bool OH_AVFormat_SetLongValue (struct OH_AVFormat *format, const char *key, int64_t value)
1403```
1404
1405**Description**
1406
1407Assigns a value of the long type to a [key](_codec_base.md#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).
1408
1409**System capability**: SystemCapability.Multimedia.Media.Core
1410
1411**Since**: 9
1412
1413**Parameters**
1414
1415| Name| Description|
1416| -------- | -------- |
1417| format | Pointer to an OH_AVFormat instance.|
1418| key | Pointer to the key of the data to write.|
1419| value | Value of the data to write.|
1420
1421**Returns**
1422
1423**TRUE** if the operation is successful; **FALSE** otherwise.
1424
1425The possible causes of an operation failure are as follows:
1426
14271. The value of **format** is nullptr.
14282. The value of **format** fails parameter structure verification.
14293. The value of **key** is nullptr.
14304. The value type corresponding to the key is incorrect.
1431
1432
1433### OH_AVFormat_SetStringValue()
1434
1435```
1436bool OH_AVFormat_SetStringValue (struct OH_AVFormat *format, const char *key, const char *value)
1437```
1438
1439**Description**
1440
1441Assigns a value of the string type to a [key](_codec_base.md#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).
1442
1443**System capability**: SystemCapability.Multimedia.Media.Core
1444
1445**Since**: 9
1446
1447**Parameters**
1448
1449| Name| Description|
1450| -------- | -------- |
1451| format | Pointer to an OH_AVFormat instance.|
1452| key | Pointer to the key of the data to write.|
1453| value | Pointer to the data to be written to the string. The length should not exceed 256 bytes.|
1454
1455**Returns**
1456
1457**TRUE** if the operation is successful; **FALSE** otherwise.
1458
1459The possible causes of an operation failure are as follows:
1460
14611. The value of **format** is nullptr.
14622. The value of **format** fails parameter structure verification.
14633. The value of **key** is nullptr.
14644. The value of **value** is nullptr.
14655. The value type corresponding to the key is incorrect.
1466
1467
1468### OH_AVMemory_Create()
1469
1470```
1471OH_AVMemory* OH_AVMemory_Create (int32_t size)
1472```
1473
1474**Description**
1475
1476Creates an OH_AVMemory instance.
1477
1478**System capability**: SystemCapability.Multimedia.Media.Core
1479
1480**Since**: 10
1481
1482**Deprecated from**: 11
1483
1484**Substitute**: [OH_AVBuffer_Create](#oh_avbuffer_create)
1485
1486**Parameters**
1487
1488| Name| Description|
1489| -------- | -------- |
1490| size | Size of the created memory, in bytes.|
1491
1492**Returns**
1493
1494Pointer to the OH_AVMemory instance created. If the operation fails, NULL is returned. The instance must be released by calling **OH_AVMemory_Destroy** when it is no longer required.
1495
1496
1497### OH_AVMemory_Destroy()
1498
1499```
1500OH_AVErrCode OH_AVMemory_Destroy (struct OH_AVMemory *mem)
1501```
1502
1503**Description**
1504
1505Releases an OH_AVMemory instance.
1506
1507**System capability**: SystemCapability.Multimedia.Media.Core
1508
1509**Since**: 10
1510
1511**Deprecated from**: 11
1512
1513**Substitute**: [OH_AVBuffer_Destroy](#oh_avbuffer_destroy)
1514
1515**Parameters**
1516
1517| Name| Description|
1518| -------- | -------- |
1519| mem | Pointer to an OH_AVMemory instance.|
1520
1521**Returns**
1522
1523**AV_ERR_OK**. If the operation fails, an error code defined in [OH_AVErrCode](#oh_averrcode-1) is returned.
1524
1525
1526### OH_AVMemory_GetAddr()
1527
1528```
1529uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory *mem)
1530```
1531
1532**Description**
1533
1534Obtains the virtual memory address.
1535
1536**System capability**: SystemCapability.Multimedia.Media.Core
1537
1538**Since**: 9
1539
1540**Deprecated from**: 11
1541
1542**Substitute**: [OH_AVBuffer_GetAddr](#oh_avbuffer_getaddr)
1543
1544**Parameters**
1545
1546| Name| Description|
1547| -------- | -------- |
1548| mem | Pointer to an OH_AVMemory instance.|
1549
1550**Returns**
1551
1552Pointer to the virtual memory address. If the memory is invalid, NULL is returned.
1553
1554The possible causes of an operation failure are as follows:
1555
15561. The value of **mem** is nullptr.
15572. The value of **mem** fails parameter structure verification.
15583. The memory in the passed-in value of **mem** is nullptr.
1559
1560
1561### OH_AVMemory_GetSize()
1562
1563```
1564int32_t OH_AVMemory_GetSize (struct OH_AVMemory *mem)
1565```
1566
1567**Description**
1568
1569Obtains the memory length.
1570
1571**System capability**: SystemCapability.Multimedia.Media.Core
1572
1573**Since**: 9
1574
1575**Deprecated from**: 11
1576
1577**Substitute**: [OH_AVBuffer_GetCapacity](#oh_avbuffer_getcapacity)
1578
1579**Parameters**
1580
1581| Name| Description|
1582| -------- | -------- |
1583| mem | Pointer to an OH_AVMemory instance.|
1584
1585**Returns**
1586
1587Memory size. If the memory is invalid, **-1** is returned.
1588
1589The possible causes of an operation failure are as follows:
1590
15911. The value of **mem** is nullptr.
15922. The value of **mem** fails parameter structure verification.
15933. The memory in the passed-in value of **mem** is nullptr.
1594
1595### OH_AVFormat_SetIntBuffer()
1596
1597```
1598bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size)
1599```
1600
1601**Description**
1602
1603Writes data blocks of the int32_t type with a specified length to an OH_AVFormat instance.
1604
1605**System capability**: SystemCapability.Multimedia.Media.Core
1606
1607**Since**: 20
1608
1609**Parameters**
1610
1611| Name| Description|
1612| -------- | -------- |
1613| format | Pointer to an OH_AVFormat instance.|
1614| key | Pointer to the key of the data to write.|
1615| addr | Pointer to the address to which data is written. The lifecycle is managed by the developer.|
1616| size | Length of the data to write, in units of elements, not bytes.|
1617
1618**Returns**
1619
1620**TRUE** if the operation is successful; **FALSE** otherwise.
1621
1622The possible causes of an operation failure are as follows:
1623
16241. The value of **format** is nullptr.
16252. The value of **format** fails parameter structure verification.
16263. The value of **key** is nullptr.
16274. The value of **addr** is nullptr.
16285. The value of **size** is **0**.
1629
1630<!--no_check-->