• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AudioDecoder
2
3## Overview
4
5The **AudioDecoder** module provides the functions for audio decoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether your device supports this module.
6
7\@syscap SystemCapability.Multimedia.Media.AudioDecoder
8
9**Since**
10
119
12
13## Summary
14
15### Files
16
17| Name                                                                | Description                                                                                                       |
18| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
19| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md)    | Declares the native APIs used for audio decoding.<br>**File to include**: <multimedia/player_framework/native_avcodec_audiodecoder.h><br>**Library**: libnative_media_adec.so|
20| [avcodec_audio_channel_layout.h](avcodec__audio__channel__layout_8h.md) | Declares the enums used for audio codec.<br>**File to include**: <multimedia/player_framework/avcodec_audio_channel_layout.h><br>**Library**: libnative_media_codecbase.so                  |
21
22### Enums
23
24| Name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Description                                                                 |
25| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
26| [AudioChannelSet](#audiochannelset) : uint64_t {<br>**FRONT_LEFT** = 1ULL &lt;&lt; 0U, <br>**FRONT_RIGHT** = 1ULL &lt;&lt; 1U, <br>**FRONT_CENTER** = 1ULL &lt;&lt; 2U, <br>**LOW_FREQUENCY** = 1ULL &lt;&lt; 3U,<br>**BACK_LEFT** = 1ULL &lt;&lt; 4U, <br>**BACK_RIGHT** = 1ULL &lt;&lt; 5U, <br>**FRONT_LEFT_OF_CENTER** = 1ULL &lt;&lt; 6U, <br>**FRONT_RIGHT_OF_CENTER** = 1ULL &lt;&lt; 7U,<br>**BACK_CENTER** = 1ULL &lt;&lt; 8U, <br>**SIDE_LEFT** = 1ULL &lt;&lt; 9U, <br>**SIDE_RIGHT** = 1ULL &lt;&lt; 10U, <br>**TOP_CENTER** = 1ULL &lt;&lt; 11U,<br>**TOP_FRONT_LEFT** = 1ULL &lt;&lt; 12U, <br>**TOP_FRONT_CENTER** = 1ULL &lt;&lt; 13U, <br>**TOP_FRONT_RIGHT** = 1ULL &lt;&lt; 14U, <br>**TOP_BACK_LEFT** = 1ULL &lt;&lt; 15U,<br>**TOP_BACK_CENTER** = 1ULL &lt;&lt; 16U, <br>**TOP_BACK_RIGHT** = 1ULL &lt;&lt; 17U, <br>**STEREO_LEFT** = 1ULL &lt;&lt; 29U, <br>**STEREO_RIGHT** = 1ULL &lt;&lt; 30U,<br>**WIDE_LEFT** = 1ULL &lt;&lt; 31U, <br>**WIDE_RIGHT** = 1ULL &lt;&lt; 32U, <br>**SURROUND_DIRECT_LEFT** = 1ULL &lt;&lt; 33U, <br>**SURROUND_DIRECT_RIGHT** = 1ULL &lt;&lt; 34U,<br>**LOW_FREQUENCY_2** = 1ULL &lt;&lt; 35U, <br>**TOP_SIDE_LEFT** = 1ULL &lt;&lt; 36U, <br>**TOP_SIDE_RIGHT** = 1ULL &lt;&lt; 37U, <br>**BOTTOM_FRONT_CENTER** = 1ULL &lt;&lt; 38U,<br>**BOTTOM_FRONT_LEFT** = 1ULL &lt;&lt; 39U, <br>**BOTTOM_FRONT_RIGHT** = 1ULL &lt;&lt; 40U, <br>**AMBISONICS_ACN0** = 1ULL &lt;&lt; 41U, <br>**AMBISONICS_ACN1** = 1ULL &lt;&lt; 42U,<br>**AMBISONICS_ACN2** = 1ULL &lt;&lt; 43U, <br>**AMBISONICS_ACN3** = 1ULL &lt;&lt; 44U, <br>**AMBISONICS_W** = AMBISONICS_ACN0, <br>**AMBISONICS_Y** = AMBISONICS_ACN1,<br>**AMBISONICS_Z** = AMBISONICS_ACN2, <br>**AMBISONICS_X** = AMBISONICS_ACN3, <br>**AMBISONICS_ACN4** = 1ULL &lt;&lt; 45U, <br>**AMBISONICS_ACN5** = 1ULL &lt;&lt; 46U,<br>**AMBISONICS_ACN6** = 1ULL &lt;&lt; 47U, <br>**AMBISONICS_ACN7** = 1ULL &lt;&lt; 48U, <br>**AMBISONICS_ACN8** = 1ULL &lt;&lt; 49U, <br>**AMBISONICS_ACN9** = 1ULL &lt;&lt; 50U,<br>**AMBISONICS_ACN10** = 1ULL &lt;&lt; 51U, <br>**AMBISONICS_ACN11** = 1ULL &lt;&lt; 52U, <br>**AMBISONICS_ACN12** = 1ULL &lt;&lt; 53U, <br>**AMBISONICS_ACN13** = 1ULL &lt;&lt; 54U, <br>**AMBISONICS_ACN14** = 1ULL &lt;&lt; 55U, <br>**AMBISONICS_ACN15** = 1ULL &lt;&lt; 56U}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Enumerates the audio channel numbers. Each channel number is mapped to a variable of int64.                   |
27| [AudioChannelLayout](#audiochannellayout) : uint64_t {<br>**UNKNOWN_CHANNEL_LAYOUT** = 0, <br>**MONO** = (AudioChannelSet::FRONT_CENTER), <br>**STEREO** = (AudioChannelSet::FRONT_LEFT \| AudioChannelSet::FRONT_RIGHT), <br>**CH_2POINT1** = (STEREO \| AudioChannelSet::LOW_FREQUENCY),<br>**CH_2_1** = (STEREO \| AudioChannelSet::BACK_CENTER), <br>**SURROUND** = (STEREO \| AudioChannelSet::FRONT_CENTER), <br>**CH_3POINT1** = (SURROUND \| AudioChannelSet::LOW_FREQUENCY), <br>**CH_4POINT0** = (SURROUND \| AudioChannelSet::BACK_CENTER),<br>**CH_4POINT1** = (CH_4POINT0 \| AudioChannelSet::LOW_FREQUENCY), <br>**CH_2_2** = (STEREO \| AudioChannelSet::SIDE_LEFT \| AudioChannelSet::SIDE_RIGHT), <br>**QUAD** = (STEREO \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), <br>**CH_5POINT0** = (SURROUND \| AudioChannelSet::SIDE_LEFT \| AudioChannelSet::SIDE_RIGHT),<br>**CH_5POINT1** = (CH_5POINT0 \| AudioChannelSet::LOW_FREQUENCY), <br>**CH_5POINT0_BACK** = (SURROUND \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), <br>**CH_5POINT1_BACK** = (CH_5POINT0_BACK \| AudioChannelSet::LOW_FREQUENCY), <br>**CH_6POINT0** = (CH_5POINT0 \| AudioChannelSet::BACK_CENTER),<br>**CH_6POINT0_FRONT** = (CH_2_2 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), <br>**HEXAGONAL** = (CH_5POINT0_BACK \| AudioChannelSet::BACK_CENTER), <br>**CH_6POINT1** = (CH_5POINT1 \| AudioChannelSet::BACK_CENTER), <br>**CH_6POINT1_BACK** = (CH_5POINT1_BACK \| AudioChannelSet::BACK_CENTER),<br>**CH_6POINT1_FRONT** = (CH_6POINT0_FRONT \| AudioChannelSet::LOW_FREQUENCY), <br>**CH_7POINT0** = (CH_5POINT0 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), <br>**CH_7POINT0_FRONT** = (CH_5POINT0 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), <br>**CH_7POINT1** = (CH_5POINT1 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT),<br>**CH_7POINT1_WIDE** = (CH_5POINT1 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), <br>**CH_7POINT1_WIDE_BACK**, <br>**CH_3POINT1POINT2** = (CH_3POINT1 \| AudioChannelSet::TOP_FRONT_LEFT \| AudioChannelSet::TOP_FRONT_RIGHT), <br>**CH_5POINT1POINT2** = (CH_5POINT1 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT),<br>**CH_5POINT1POINT4**, <br>**CH_7POINT1POINT2** = (CH_7POINT1 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT), <br>**CH_7POINT1POINT4**, <br>**CH_9POINT1POINT4** = (CH_7POINT1POINT4 \| AudioChannelSet::WIDE_LEFT \| AudioChannelSet::WIDE_RIGHT),<br>**CH_9POINT1POINT6** = (CH_9POINT1POINT4 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT), <br>**CH_10POINT2**, <br>**CH_22POINT2**, <br>**OCTAGONAL** = (CH_5POINT0 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_CENTER \| AudioChannelSet::BACK_RIGHT),<br>**HEXADECAGONAL**, <br>**STEREO_DOWNMIX** = (AudioChannelSet::STEREO_LEFT \| AudioChannelSet::STEREO_RIGHT), <br>**HOA_FIRST**, <br>**HOA_SECOND** <br>**HOA_THIRD**} | Enumerates the types of the audio channel numbers. The output format of the decoder is represented as the channel type of the codec.|
28
29### Functions
30
31| Name                                                                                                                                         | Description                                                                                                |
32| --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
33| \*[OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime)                                                 | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.                                        |
34| \*[OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name)                                                 | Creates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.                      |
35| [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec)                                                            | Clears the internal resources of an audio decoder and destroys the decoder instance.                                                                |
36| [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder.                                      |
37| [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.                                          |
38| [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec)                                                            | Prepares internal resources for an audio decoder. This function must be called after **Configure**.                                       |
39| [OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec)                                                                | Starts an audio decoder. This function can be called only after the decoder is prepared successfully.                                                                 |
40| [OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec)                                                                  | Stops an audio decoder.                                                                                        |
41| [OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec)                                                                | Clears the input and output data in the internal buffer of an audio decoder.                                                                  |
42| [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.                              |
43| \*[OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec)                                | Obtains the description information about the output data of an audio decoder. For details, see **OH_AVFormat**.                                 |
44| [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format)                            | Sets dynamic parameters for an audio decoder. This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.|
45| [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr)     | Pushes the input buffer filled with data to an audio decoder.                                                          |
46| [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index)                              | Frees an output buffer of an audio decoder.                                                                  |
47| [OH_AudioDecoder_IsValid](#oh_audiodecoder_isvalid) (OH_AVCodec \*codec, bool \*isValid)                                            | Checks whether an audio decoder instance is valid.                                                                        |
48
49## Enum Description
50
51### AudioChannelLayout
52
53```
54enum AudioChannelLayout : uint64_t
55```
56
57**Description**
58
59Enumerates the types of the audio channel numbers. The output format of the decoder is represented as the channel type of the codec.
60
61\@syscap SystemCapability.Multimedia.Media.CodecBase
62
63**Since**
64
6510
66
67### AudioChannelSet
68
69```
70enum AudioChannelSet : uint64_t
71```
72
73**Description**
74
75Enumerates the audio channel numbers. Each channel number is mapped to a variable of int64.
76
77\@syscap SystemCapability.Multimedia.Media.CodecBase
78
79**Since**
80
8110
82
83| Value          | Description                  |
84| ---------------- | ---------------------- |
85| AMBISONICS_ACN1  | Channel 0 for the zero-order stereo.    |
86| AMBISONICS_ACN2  | Channel 1 for the first-order stereo.    |
87| AMBISONICS_ACN3  | Channel 2 for the first-order stereo.    |
88| AMBISONICS_W     | Channel 3 for the first-order stereo.    |
89| AMBISONICS_Y     | Equivalent to channel 0 for the zero-order stereo.|
90| AMBISONICS_Z     | Equivalent to channel 1 for the first-order stereo.|
91| AMBISONICS_X     | Equivalent to channel 2 for the first-order stereo.|
92| AMBISONICS_ACN4  | Equivalent to channel 3 for the first-order stereo.|
93| AMBISONICS_ACN5  | Channel 4 for the second-order stereo.    |
94| AMBISONICS_ACN6  | Channel 5 for the second-order stereo.    |
95| AMBISONICS_ACN7  | Channel 6 for the second-order stereo.    |
96| AMBISONICS_ACN8  | Channel 7 for the second-order stereo.    |
97| AMBISONICS_ACN9  | Channel 8 for the second-order stereo.    |
98| AMBISONICS_ACN10 | Channel 9 for the third-order stereo.    |
99| AMBISONICS_ACN11 | Channel 10 for the third-order stereo.   |
100| AMBISONICS_ACN12 | Channel 11 for the third-order stereo.   |
101| AMBISONICS_ACN13 | Channel 12 for the third-order stereo.   |
102| AMBISONICS_ACN14 | Channel 13 for the third-order stereo.   |
103| AMBISONICS_ACN15 | Channel 14 for the third-order stereo.   |
104
105## Function Description
106
107### OH_AudioDecoder_Configure()
108
109```
110OH_AVErrCode OH_AudioDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format )
111```
112
113**Description**
114
115Configures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container.
116
117This function must be called prior to **Prepare**.
118
119\@syscap SystemCapability.Multimedia.Media.AudioDecoder
120
121**Parameters**
122
123| Name  | Description                                               |
124| ------ | --------------------------------------------------- |
125| codec  | Pointer to an **OH_AVCodec** instance.                         |
126| format | Pointer to the **OH_AVFormat** instance, which provides the description information about the audio track to be decoded.|
127
128**Returns**
129
130Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
131
132**Since**
133
1349
135
136### OH_AudioDecoder_CreateByMime()
137
138```
139OH_AVCodec* OH_AudioDecoder_CreateByMime (const char * mime)
140```
141
142**Description**
143
144Creates an audio decoder instance based on a MIME type. This function is recommended in most cases.
145
146\@syscap SystemCapability.Multimedia.Media.AudioDecoder
147
148**Parameters**
149
150| Name| Description                                                   |
151| ---- | ------------------------------------------------------- |
152| mime | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).|
153
154**Returns**
155
156Returns the pointer to an **OH_AVCodec** instance.
157
158**Since**
159
1609
161
162### OH_AudioDecoder_CreateByName()
163
164```
165OH_AVCodec* OH_AudioDecoder_CreateByName (const char * name)
166```
167
168**Description**
169
170Creates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.
171
172\@syscap SystemCapability.Multimedia.Media.AudioDecoder
173
174**Parameters**
175
176| Name| Description            |
177| ---- | ---------------- |
178| name | Pointer to an audio decoder name.|
179
180**Returns**
181
182Returns the pointer to an **OH_AVCodec** instance.
183
184**Since**
185
1869
187
188### OH_AudioDecoder_Destroy()
189
190```
191OH_AVErrCode OH_AudioDecoder_Destroy (OH_AVCodec * codec)
192```
193
194**Description**
195
196Clears the internal resources of an audio decoder and destroys the decoder instance.
197
198\@syscap SystemCapability.Multimedia.Media.AudioDecoder
199
200**Parameters**
201
202| Name | Description                      |
203| ----- | -------------------------- |
204| codec | Pointer to an **OH_AVCodec** instance.|
205
206**Returns**
207
208Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
209
210**Since**
211
2129
213
214### OH_AudioDecoder_Flush()
215
216```
217OH_AVErrCode OH_AudioDecoder_Flush (OH_AVCodec * codec)
218```
219
220**Description**
221
222Clears the input and output data in the internal buffer of an audio decoder.
223
224This 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.
225
226\@syscap SystemCapability.Multimedia.Media.AudioDecoder
227
228**Parameters**
229
230| Name | Description                      |
231| ----- | -------------------------- |
232| codec | Pointer to an **OH_AVCodec** instance.|
233
234**Returns**
235
236Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
237
238**Since**
239
2409
241
242### OH_AudioDecoder_FreeOutputData()
243
244```
245OH_AVErrCode OH_AudioDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index )
246```
247
248**Description**
249
250Frees an output buffer of an audio decoder.
251
252\@syscap SystemCapability.Multimedia.Media.AudioDecoder
253
254**Parameters**
255
256| Name | Description                          |
257| ----- | ------------------------------ |
258| codec | Pointer to an **OH_AVCodec** instance.    |
259| index | Index of the output buffer.|
260
261**Returns**
262
263Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
264
265**Since**
266
2679
268
269### OH_AudioDecoder_GetOutputDescription()
270
271```
272OH_AVFormat* OH_AudioDecoder_GetOutputDescription (OH_AVCodec * codec)
273```
274
275**Description**
276
277Obtains the description information about the output data of an audio decoder. For details, see **OH_AVFormat**. The caller must manually release the **OH_AVFormat** instance in the return value.
278
279\@syscap SystemCapability.Multimedia.Media.AudioDecoder
280
281**Parameters**
282
283| Name | Description                      |
284| ----- | -------------------------- |
285| codec | Pointer to an **OH_AVCodec** instance.|
286
287**Returns**
288
289Returns 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.
290
291**Since**
292
2939
294
295### OH_AudioDecoder_IsValid()
296
297```
298OH_AVErrCode OH_AudioDecoder_IsValid (OH_AVCodec * codec, bool * isValid )
299```
300
301**Description**
302
303Checks whether an audio decoder instance is valid.
304
305\@syscap SystemCapability.Multimedia.Media.AudioDecoder
306
307**Parameters**
308
309| Name   | Description                                                             |
310| ------- | ----------------------------------------------------------------- |
311| codec   | Pointer to an **OH_AVCodec** instance.                                       |
312| isValid | Pointer to an instance of the Boolean type. The value **true** means that the decoder instance is valid and **false** means the opposite.|
313
314**Returns**
315
316Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
317
318**Since**
319
32010
321
322### OH_AudioDecoder_Prepare()
323
324```
325OH_AVErrCode OH_AudioDecoder_Prepare (OH_AVCodec * codec)
326```
327
328**Description**
329
330Prepares internal resources for an audio decoder. This function must be called after **Configure**.
331
332\@syscap SystemCapability.Multimedia.Media.AudioDecoder
333
334**Parameters**
335
336| Name | Description                      |
337| ----- | -------------------------- |
338| codec | Pointer to an **OH_AVCodec** instance.|
339
340**Returns**
341
342Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
343
344**Since**
345
3469
347
348### OH_AudioDecoder_PushInputData()
349
350```
351OH_AVErrCode OH_AudioDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr )
352```
353
354**Description**
355
356Pushes the input buffer filled with data to an audio decoder.
357
358The **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** callback. In addition, some decoders require the input of specific data to initialize the decoding process.
359
360\@syscap SystemCapability.Multimedia.Media.AudioDecoder
361
362**Parameters**
363
364| Name | Description                          |
365| ----- | ------------------------------ |
366| codec | Pointer to an **OH_AVCodec** instance.    |
367| index | Index of the input buffer.|
368| attr  | Description information about the data in the buffer.|
369
370**Returns**
371
372Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
373
374**Since**
375
3769
377
378### OH_AudioDecoder_Reset()
379
380```
381OH_AVErrCode OH_AudioDecoder_Reset (OH_AVCodec * codec)
382```
383
384**Description**
385
386Resets an audio decoder. To continue decoding, you must call **Configure** to configure the decoder again.
387
388\@syscap SystemCapability.Multimedia.Media.AudioDecoder
389
390**Parameters**
391
392| Name | Description                      |
393| ----- | -------------------------- |
394| codec | Pointer to an **OH_AVCodec** instance.|
395
396**Returns**
397
398Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
399
400**Since**
401
4029
403
404### OH_AudioDecoder_SetCallback()
405
406```
407OH_AVErrCode OH_AudioDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData )
408```
409
410**Description**
411
412Sets an asynchronous callback so that your application can respond to events generated by an audio decoder.
413
414This function must be called prior to **Prepare**.
415
416\@syscap SystemCapability.Multimedia.Media.AudioDecoder
417
418**Parameters**
419
420| Name    | Description                                                         |
421| -------- | ------------------------------------------------------------- |
422| codec    | Pointer to an **OH_AVCodec** instance.                                   |
423| callback | Callback function to set. For details, see **OH_AVCodecAsyncCallback**.|
424| userData | User-specific data.                                               |
425
426**Returns**
427
428Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
429
430**Since**
431
4329
433
434### OH_AudioDecoder_SetParameter()
435
436```
437OH_AVErrCode OH_AudioDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format )
438```
439
440**Description**
441
442Sets dynamic parameters for an audio decoder.
443
444This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.
445
446\@syscap SystemCapability.Multimedia.Media.AudioDecoder
447
448**Parameters**
449
450| Name  | Description                      |
451| ------ | -------------------------- |
452| codec  | Pointer to an **OH_AVCodec** instance.|
453| format | Handle to an **OH_AVFormat** instance.     |
454
455**Returns**
456
457Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
458
459**Since**
460
4619
462
463### OH_AudioDecoder_Start()
464
465```
466OH_AVErrCode OH_AudioDecoder_Start (OH_AVCodec * codec)
467```
468
469**Description**
470
471Starts an audio decoder. This function can be called only after the decoder is prepared successfully.
472
473After being started, the decoder starts to report the **OH_AVCodecOnNeedInputData** event.
474
475\@syscap SystemCapability.Multimedia.Media.AudioDecoder
476
477**Parameters**
478
479| Name | Description                      |
480| ----- | -------------------------- |
481| codec | Pointer to an **OH_AVCodec** instance.|
482
483**Returns**
484
485Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
486
487**Since**
488
4899
490
491### OH_AudioDecoder_Stop()
492
493```
494OH_AVErrCode OH_AudioDecoder_Stop (OH_AVCodec * codec)
495```
496
497**Description**
498
499Stops an audio decoder.
500
501After 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.
502
503\@syscap SystemCapability.Multimedia.Media.AudioDecoder
504
505**Parameters**
506
507| Name | Description                      |
508| ----- | -------------------------- |
509| codec | Pointer to an **OH_AVCodec** instance.|
510
511**Returns**
512
513Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise.
514
515**Since**
516
5179
518