1e41f4b71Sopenharmony_ci# AudioDecoder
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciThe AudioDecoder module provides the functions for audio decoding.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci**Since**: 9
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci**Deprecated from**: 11
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci**Development suggestions**: All APIs of the current module have been deprecated. You can use [AudioCodec](_audio_codec.md) instead. For details about the API mappings before and after the deprecation, see the API reference.
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## Summary
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci### Files
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| Name| Description| 
23e41f4b71Sopenharmony_ci| -------- | -------- |
24e41f4b71Sopenharmony_ci| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding.| 
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci### Functions
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci| Name| Description| 
30e41f4b71Sopenharmony_ci| -------- | -------- |
31e41f4b71Sopenharmony_ci| OH_AVCodec \* [OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type.| 
32e41f4b71Sopenharmony_ci| OH_AVCodec \* [OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on a decoder name.| 
33e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the decoder instance.| 
34e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder.| 
35e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_Configure](#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container.| 
36e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder.| 
37e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder after it is prepared successfully.| 
38e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder.| 
39e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder.| 
40e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_Reset](#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** to configure the decoder again.| 
41e41f4b71Sopenharmony_ci| OH_AVFormat \* [OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of an audio decoder.| 
42e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder.| 
43e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder.| 
44e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder.| 
45e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_AudioDecoder_IsValid](#oh_audiodecoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether an audio decoder instance is valid. This function is used to check the decoder validity when the background recovers from a fault or an application is switched from the background.| 
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci## Function Description
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci### OH_AudioDecoder_Configure()
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci```
54e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_Configure (OH_AVCodec *codec, OH_AVFormat *format)
55e41f4b71Sopenharmony_ci```
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci**Description**
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ciConfigures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ciThis function must be called prior to **Prepare**.
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**Since**: 9
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci**Deprecated from**: 11
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_Configure](_audio_codec.md#oh_audiocodec_configure)
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**Parameters**
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci| Name| Description| 
74e41f4b71Sopenharmony_ci| -------- | -------- |
75e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
76e41f4b71Sopenharmony_ci| format | Pointer to the **OH_AVFormat** instance, which provides the description information about the audio track to be decoded.| 
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci**Returns**
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci### OH_AudioDecoder_CreateByMime()
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci```
86e41f4b71Sopenharmony_ciOH_AVCodec* OH_AudioDecoder_CreateByMime (const char *mime)
87e41f4b71Sopenharmony_ci```
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci**Description**
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ciCreates an audio decoder instance based on a MIME type. This function is recommended in most cases.
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci**Since**: 9
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci**Deprecated from**: 11
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_CreateByMime](_audio_codec.md#oh_audiocodec_createbymime)
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**Parameters**
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci| Name| Description| 
104e41f4b71Sopenharmony_ci| -------- | -------- |
105e41f4b71Sopenharmony_ci| mime | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).| 
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci**Returns**
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ciReturns the pointer to an **OH_AVCodec** instance.
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci### OH_AudioDecoder_CreateByName()
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci```
115e41f4b71Sopenharmony_ciOH_AVCodec* OH_AudioDecoder_CreateByName (const char *name)
116e41f4b71Sopenharmony_ci```
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**Description**
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ciCreates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci**Since**: 9
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci**Deprecated from**: 11
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_CreateByName](_audio_codec.md#oh_audiocodec_createbyname)
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci**Parameters**
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci| Name| Description| 
133e41f4b71Sopenharmony_ci| -------- | -------- |
134e41f4b71Sopenharmony_ci| name | Pointer to an audio decoder name.| 
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci**Returns**
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ciReturns the pointer to an **OH_AVCodec** instance.
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci### OH_AudioDecoder_Destroy()
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci```
144e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_Destroy (OH_AVCodec *codec)
145e41f4b71Sopenharmony_ci```
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**Description**
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ciClears the internal resources of an audio decoder and destroys the decoder instance.
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci**Since**: 9
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci**Deprecated from**: 11
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_Destroy](_audio_codec.md#oh_audiocodec_destroy)
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci**Parameters**
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci| Name| Description| 
162e41f4b71Sopenharmony_ci| -------- | -------- |
163e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci**Returns**
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci### OH_AudioDecoder_Flush()
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci```
173e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_Flush (OH_AVCodec *codec)
174e41f4b71Sopenharmony_ci```
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci**Description**
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ciClears the input and output data in the internal buffer of an audio decoder.
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ciThis function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required.
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**Since**: 9
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**Deprecated from**: 11
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_Flush](_audio_codec.md#oh_audiocodec_flush)
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci**Parameters**
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci| Name| Description| 
193e41f4b71Sopenharmony_ci| -------- | -------- |
194e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci**Returns**
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci### OH_AudioDecoder_FreeOutputData()
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci```
204e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_FreeOutputData (OH_AVCodec *codec, uint32_t index)
205e41f4b71Sopenharmony_ci```
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci**Description**
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ciFrees an output buffer of an audio decoder.
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci**Since**: 9
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ci**Deprecated from**: 11
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_FreeOutputBuffer](_audio_codec.md#oh_audiocodec_freeoutputbuffer)
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci**Parameters**
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci| Name| Description| 
222e41f4b71Sopenharmony_ci| -------- | -------- |
223e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
224e41f4b71Sopenharmony_ci| index | Index of the output buffer.| 
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**Returns**
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci### OH_AudioDecoder_GetOutputDescription()
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci```
234e41f4b71Sopenharmony_ciOH_AVFormat* OH_AudioDecoder_GetOutputDescription (OH_AVCodec *codec)
235e41f4b71Sopenharmony_ci```
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci**Description**
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ciObtains the description information about the output data of an audio decoder.
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ciThe caller must manually release the **OH_AVFormat** instance in the return value.
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci**Since**: 9
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci**Deprecated from**: 11
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_GetOutputDescription](_audio_codec.md#oh_audiocodec_getoutputdescription)
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci**Parameters**
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci| Name| Description| 
254e41f4b71Sopenharmony_ci| -------- | -------- |
255e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci**Returns**
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ciReturns the handle to an **OH_AVFormat** instance. The lifecycle of this instance is refreshed when **GetOutputDescription** is called again and destroyed when the **OH_AVCodec** instance is destroyed.
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci### OH_AudioDecoder_IsValid()
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci```
265e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_IsValid (OH_AVCodec *codec, bool *isValid)
266e41f4b71Sopenharmony_ci```
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci**Description**
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ciChecks whether an audio decoder instance is valid. This function is used to check the decoder validity when the background recovers from a fault or an application is switched from the background.
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci**Since**: 10
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci**Deprecated from**: 11
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_IsValid](_audio_codec.md#oh_audiocodec_isvalid)
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci**Parameters**
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci| Name| Description| 
283e41f4b71Sopenharmony_ci| -------- | -------- |
284e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
285e41f4b71Sopenharmony_ci| isValid | Pointer to an instance of the Boolean type. The value **true** means that the decoder instance is valid and **false** means the opposite.| 
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci**Returns**
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci### OH_AudioDecoder_Prepare()
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci```
295e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_Prepare (OH_AVCodec *codec)
296e41f4b71Sopenharmony_ci```
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci**Description**
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ciPrepares internal resources for an audio decoder. This function must be called after **Configure**.
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci**Since**: 9
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci**Deprecated from**: 11
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_Prepare](_audio_codec.md#oh_audiocodec_prepare)
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**Parameters**
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci| Name| Description| 
313e41f4b71Sopenharmony_ci| -------- | -------- |
314e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci**Returns**
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci### OH_AudioDecoder_PushInputData()
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci```
324e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_PushInputData (OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr)
325e41f4b71Sopenharmony_ci```
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci**Description**
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ciPushes the input buffer filled with data to an audio decoder.
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ciThe [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports the available input buffer and the index. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback.
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ciIn addition, some decoders require the input of specific data to initialize the decoding process.
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**Since**: 9
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**Deprecated from**: 11
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_PushInputBuffer](_audio_codec.md#oh_audiocodec_pushinputbuffer)
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci**Parameters**
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci| Name| Description| 
346e41f4b71Sopenharmony_ci| -------- | -------- |
347e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
348e41f4b71Sopenharmony_ci| index | Index of the input buffer.| 
349e41f4b71Sopenharmony_ci| attr | Description information about the data in the buffer.| 
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci**Returns**
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci### OH_AudioDecoder_Reset()
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ci```
359e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_Reset (OH_AVCodec *codec)
360e41f4b71Sopenharmony_ci```
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci**Description**
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ciResets an audio decoder. To continue decoding, you must call **Configure** to configure the decoder again.
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci**Since**: 9
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci**Deprecated from**: 11
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_Reset](_audio_codec.md#oh_audiocodec_reset)
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci**Parameters**
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci| Name| Description| 
377e41f4b71Sopenharmony_ci| -------- | -------- |
378e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**Returns**
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci### OH_AudioDecoder_SetCallback()
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci```
388e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_SetCallback (OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData)
389e41f4b71Sopenharmony_ci```
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci**Description**
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ciSets an asynchronous callback so that your application can respond to events generated by an audio decoder. This function must be called prior to **Prepare**.
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**Since**: 9
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**Deprecated from**: 11
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_RegisterCallback](_audio_codec.md#oh_audiocodec_registercallback)
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci**Parameters**
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci| Name| Description| 
406e41f4b71Sopenharmony_ci| -------- | -------- |
407e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
408e41f4b71Sopenharmony_ci| callback | Callback function to set. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| 
409e41f4b71Sopenharmony_ci| userData | User-specific data.| 
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci**Returns**
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci### OH_AudioDecoder_SetParameter()
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci```
419e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_SetParameter (OH_AVCodec *codec, OH_AVFormat *format)
420e41f4b71Sopenharmony_ci```
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci**Description**
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ciSets dynamic parameters for an audio decoder.
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ciThis function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci**Since**: 9
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**Deprecated from**: 11
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_SetParameter](_audio_codec.md#oh_audiocodec_setparameter)
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci**Parameters**
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci| Name| Description| 
439e41f4b71Sopenharmony_ci| -------- | -------- |
440e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
441e41f4b71Sopenharmony_ci| format | Handle to an **OH_AVFormat** instance.| 
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci**Returns**
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci### OH_AudioDecoder_Start()
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci```
451e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_Start (OH_AVCodec *codec)
452e41f4b71Sopenharmony_ci```
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci**Description**
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ciStarts an audio decoder after it is prepared successfully. After being started, the decoder starts to report the **OH_AVCodecOnNeedInputData** event.
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**Since**: 9
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci**Deprecated from**: 11
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_Start](_audio_codec.md#oh_audiocodec_start)
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci**Parameters**
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci| Name| Description| 
469e41f4b71Sopenharmony_ci| -------- | -------- |
470e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci**Returns**
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ci### OH_AudioDecoder_Stop()
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ci```
480e41f4b71Sopenharmony_ciOH_AVErrCode OH_AudioDecoder_Stop (OH_AVCodec *codec)
481e41f4b71Sopenharmony_ci```
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ci**Description**
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ciStops an audio decoder.
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ciAfter the decoder is stopped, you can call **Start** to start it again. If you have passed specific data in the previous **Start** for the decoder, you must pass it again.
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.AudioDecoder
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ci**Since**: 9
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ci**Deprecated from**: 11
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci**Substitute API**: [OH_AudioCodec_Stop](_audio_codec.md#oh_audiocodec_stop)
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci**Parameters**
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ci| Name| Description| 
500e41f4b71Sopenharmony_ci| -------- | -------- |
501e41f4b71Sopenharmony_ci| codec | Pointer to an **OH_AVCodec** instance.| 
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci**Returns**
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ciReturns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
506