1# OHAudio 2 3 4## Overview 5 6The **OHAudio** module provides native APIs of the audio module. 7 8\@syscap SystemCapability.Multimedia.Audio.Core 9 10**Since** 11 1210 13 14 15## Summary 16 17 18### Files 19 20| Name| Description| 21| -------- | -------- | 22| [native_audiocapturer.h](native__audiocapturer_8h.md) | Declares the functions related to an audio capturer.<br>**File to include**: <ohaudio/native_audiocapturer.h><br>**Library**: libohaudio.so| 23| [native_audiorenderer.h](native__audiorenderer_8h.md) | Declares the functions related to an audio renderer.<br>**File to include**: <ohaudio/native_audiorenderer.h><br>**Library**: libohaudio.so| 24| [native_audiostream_base.h](native__audiostream__base_8h.md) | Declares the basic data structure of **OHAudio**.<br>**File to include**: <ohaudio/native_audiostream_base.h><br>**Library**: libohaudio.so| 25| [native_audiostreambuilder.h](native__audiostreambuilder_8h.md) | Declares the functions related to the audio stream builder.<br>**File to include**: <ohaudio/native_audiostreambuilder.h><br>**Library**: libohaudio.so| 26 27 28### Structs 29 30| Name| Description| 31| -------- | -------- | 32| [OH_AudioRenderer_Callbacks_Struct](_o_h___audio_renderer___callbacks___struct.md) | Defines a pointer to the callback functions related to an audio renderer.| 33| [OH_AudioCapturer_Callbacks_Struct](_o_h___audio_capturer___callbacks___struct.md) | Defines a pointer to the callback functions related to an audio capturer.| 34 35 36### Types 37 38| Name| Description| 39| -------- | -------- | 40| [OH_AudioStreamBuilder](#oh_audiostreambuilder) | Defines an audio stream builder.| 41| [OH_AudioRenderer](#oh_audiorenderer) | Defines an audio renderer.| 42| [OH_AudioCapturer](#oh_audiocapturer) | Defines an audio capturer.| 43| [OH_AudioRenderer_Callbacks](#oh_audiorenderer_callbacks) | Defines a pointer to the callback functions related to an audio renderer.| 44| [OH_AudioCapturer_Callbacks](#oh_audiocapturer_callbacks) | Defines a pointer to the callback functions related to an audio capturer.| 45 46 47### Enums 48 49| Name| Description| 50| -------- | -------- | 51| [OH_AudioStream_Result](#oh_audiostream_result) { AUDIOSTREAM_SUCCESS, AUDIOSTREAM_ERROR_INVALID_PARAM, AUDIOSTREAM_ERROR_ILLEGAL_STATE, AUDIOSTREAM_ERROR_SYSTEM } | Enumerates the audio stream result codes.| 52| [OH_AudioStream_Type](#oh_audiostream_type) { AUDIOSTREAM_TYPE_RENDERER = 1, AUDIOSTREAM_TYPE_CAPTURER = 2 } | Enumerates the audio stream types.| 53| [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) { AUDIOSTREAM_SAMPLE_U8 = 0, AUDIOSTREAM_SAMPLE_S16LE = 1, AUDIOSTREAM_SAMPLE_S24LE = 2, AUDIOSTREAM_SAMPLE_S32LE = 3 } | Enumerates the sampling formats of audio streams.| 54| [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) { **AUDIOSTREAM_ENCODING_TYPE_RAW** = 0 } | Enumerates the encoding types of audio streams.| 55| [OH_AudioStream_Usage](#oh_audiostream_usage) { **AUDIOSTREAM_USAGE_UNKNOWN** = 0, **AUDIOSTREAM_USAGE_MUSIC** = 1, **AUDIOSTREAM_USAGE_COMMUNICATION** = 2, **AUDIOSTREAM_USAGE_GAME** = 11 } | Enumerates the usage scenarios of audio output streams.| 56| [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) { AUDIOSTREAM_LATENCY_MODE_NORMAL = 0, AUDIOSTREAM_LATENCY_MODE_FAST = 1} | Enumerates the latency modes of audio streams.| 57| [OH_AudioStream_State](#oh_audiostream_state) {<br>AUDIOSTREAM_STATE_INVALID = -1, AUDIOSTREAM_STATE_PREPARED = 1, AUDIOSTREAM_STATE_RUNNING = 2, AUDIOSTREAM_STATE_STOPPED = 3,<br>AUDIOSTREAM_STATE_RELEASED = 4, AUDIOSTREAM_STATE_PAUSED = 5<br>} | Enumerates the audio stream states.| 58| [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) { **AUDIOSTREAM_SOURCE_TYPE_INVALID** = -1, **AUDIOSTREAM_SOURCE_TYPE_MIC**, **AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION** = 1, **AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION** = 7 } | Enumerates the usage scenarios of audio input streams.| 59 60 61### Functions 62 63| Name| Description| 64| -------- | -------- | 65| [OH_AudioCapturer_Release](#oh_audiocapturer_release) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Releases an audio capturer.| 66| [OH_AudioCapturer_Start](#oh_audiocapturer_start) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Starts an audio capturer.| 67| [OH_AudioCapturer_Pause](#oh_audiocapturer_pause) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Pauses an audio capturer.| 68| [OH_AudioCapturer_Stop](#oh_audiocapturer_stop) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Stops an audio capturer.| 69| [OH_AudioCapturer_Flush](#oh_audiocapturer_flush) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Flushes obtained audio data.| 70| [OH_AudioCapturer_GetCurrentState](#oh_audiocapturer_getcurrentstate) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_State](#oh_audiostream_state) \*state) | Obtains the state of an audio capturer.| 71| [OH_AudioCapturer_GetLatencyMode](#oh_audiocapturer_getlatencymode) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio capturer.| 72| [OH_AudioCapturer_GetStreamId](#oh_audiocapturer_getstreamid) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, uint32_t \*streamId) | Obtains the stream ID of an audio capturer.| 73| [OH_AudioCapturer_GetSamplingRate](#oh_audiocapturer_getsamplingrate) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int32_t \*rate) | Obtains the sampling rate of an audio capturer.| 74| [OH_AudioCapturer_GetChannelCount](#oh_audiocapturer_getchannelcount) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int32_t \*channelCount) | Obtains the number of channels for an audio capturer.| 75| [OH_AudioCapturer_GetSampleFormat](#oh_audiocapturer_getsampleformat) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio capturer.| 76| [OH_AudioCapturer_GetEncodingType](#oh_audiocapturer_getencodingtype) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio capturer.| 77| [OH_AudioCapturer_GetCapturerInfo](#oh_audiocapturer_getcapturerinfo) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) \*sourceType) | Obtains the usage scenario of an audio capturer.| 78| [OH_AudioRenderer_Release](#oh_audiorenderer_release) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Releases an audio renderer.| 79| [OH_AudioRenderer_Start](#oh_audiorenderer_start) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Starts an audio renderer.| 80| [OH_AudioRenderer_Pause](#oh_audiorenderer_pause) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Pauses an audio renderer.| 81| [OH_AudioRenderer_Stop](#oh_audiorenderer_stop) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Stops an audio renderer.| 82| [OH_AudioRenderer_Flush](#oh_audiorenderer_flush) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Flushes written audio data.| 83| [OH_AudioRenderer_GetCurrentState](#oh_audiorenderer_getcurrentstate) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_State](#oh_audiostream_state) \*state) | Obtains the state of an audio renderer.| 84| [OH_AudioRenderer_GetSamplingRate](#oh_audiorenderer_getsamplingrate) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int32_t \*rate) | Obtains the sampling rate of an audio renderer.| 85| [OH_AudioRenderer_GetStreamId](#oh_audiorenderer_getstreamid) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, uint32_t \*streamId) | Obtains the stream ID of an audio renderer.| 86| [OH_AudioRenderer_GetChannelCount](#oh_audiorenderer_getchannelcount) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int32_t \*channelCount) | Obtains the number of channels for an audio renderer.| 87| [OH_AudioRenderer_GetSampleFormat](#oh_audiorenderer_getsampleformat) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio renderer.| 88| [OH_AudioRenderer_GetLatencyMode](#oh_audiorenderer_getlatencymode) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio renderer.| 89| [OH_AudioRenderer_GetRendererInfo](#oh_audiorenderer_getrendererinfo) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_Usage](#oh_audiostream_usage) \*usage) | Obtains the usage scenario of an audio renderer.| 90| [OH_AudioRenderer_GetEncodingType](#oh_audiorenderer_getencodingtype) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio renderer.| 91| [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*\*builder, [OH_AudioStream_Type](#oh_audiostream_type) type) | Creates an audio stream builder, which can be an audio renderer or capturer.| 92| [OH_AudioStreamBuilder_Destroy](#oh_audiostreambuilder_destroy) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder) | Destroys an audio stream builder.| 93| [OH_AudioStreamBuilder_SetSamplingRate](#oh_audiostreambuilder_setsamplingrate) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, int32_t rate) | Sets the sampling rate of an audio stream.| 94| [OH_AudioStreamBuilder_SetChannelCount](#oh_audiostreambuilder_setchannelcount) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, int32_t channelCount) | Sets the number of channels for an audio stream.| 95| [OH_AudioStreamBuilder_SetSampleFormat](#oh_audiostreambuilder_setsampleformat) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) format) | Sets the sampling format of an audio stream.| 96| [OH_AudioStreamBuilder_SetEncodingType](#oh_audiostreambuilder_setencodingtype) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) encodingType) | Sets the encoding type of an audio stream.| 97| [OH_AudioStreamBuilder_SetLatencyMode](#oh_audiostreambuilder_setlatencymode) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) latencyMode) | Sets the latency mode of an audio stream.| 98| [OH_AudioStreamBuilder_SetRendererInfo](#oh_audiostreambuilder_setrendererinfo) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_Usage](#oh_audiostream_usage) usage) | Sets the usage scenario of an audio renderer.| 99| [OH_AudioStreamBuilder_SetCapturerInfo](#oh_audiostreambuilder_setcapturerinfo) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) sourceType) | Sets the usage scenario of an audio capturer.| 100| [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer_Callbacks](#oh_audiorenderer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio renderer.| 101| [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioCapturer_Callbacks](#oh_audiocapturer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio capturer.| 102| [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer](#oh_audiorenderer) \*\*audioRenderer) | Creates an audio renderer instance.| 103| [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioCapturer](#oh_audiocapturer) \*\*audioCapturer) | Creates an audio capturer instance.| 104 105 106### Variables 107 108| Name| Description| 109| -------- | -------- | 110| (\*[OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnWriteData](#oh_audiorenderer_onwritedata) )([OH_AudioRenderer](#oh_audiorenderer) \*renderer, void \*userData, void \*buffer, int32_t lenth) | Defines a function pointer to the callback function used to write audio data.| 111| (\*[OH_AudioCapturer_Callbacks_Struct::OH_AudioCapturer_OnReadData](#oh_audiocapturer_onreaddata) )([OH_AudioCapturer](#oh_audiocapturer) \*capturer, void \*userData, void \*buffer, int32_t lenth) | Defines a function pointer to the callback function used to read audio data.| 112 113 114## Type Description 115 116 117### OH_AudioCapturer 118 119 120``` 121typedef struct OH_AudioCapturerStruct OH_AudioCapturer 122``` 123 124**Description** 125 126Defines an audio capturer. 127 128An audio capturer instance is used to capture audio data. 129 130\@syscap SystemCapability.Multimedia.Audio.Core 131 132**Since** 133 13410 135 136 137### OH_AudioCapturer_Callbacks 138 139 140``` 141typedef struct OH_AudioCapturer_Callbacks_Struct OH_AudioCapturer_Callbacks 142``` 143 144**Description** 145 146Defines a pointer to the callback functions related to an audio capturer. 147 148\@syscap SystemCapability.Multimedia.Audio.Core 149 150**Since** 151 15210 153 154 155### OH_AudioRenderer 156 157 158``` 159typedef struct OH_AudioRendererStruct OH_AudioRenderer 160``` 161 162**Description** 163 164Defines an audio renderer. 165 166An audio renderer instance is used to render audio data. 167 168\@syscap SystemCapability.Multimedia.Audio.Core 169 170**Since** 171 17210 173 174 175### OH_AudioRenderer_Callbacks 176 177 178``` 179typedef struct OH_AudioRenderer_Callbacks_Struct OH_AudioRenderer_Callbacks 180``` 181 182**Description** 183 184Defines a pointer to the callback functions related to an audio renderer. 185 186\@syscap SystemCapability.Multimedia.Audio.Core 187 188**Since** 189 19010 191 192 193### OH_AudioStreamBuilder 194 195 196``` 197typedef struct OH_AudioStreamBuilderStruct OH_AudioStreamBuilder 198``` 199 200**Description** 201 202Defines an audio stream builder. 203 204An audio stream builder instance is often used to create an audio stream and set its attributes. 205 206\@syscap SystemCapability.Multimedia.Audio.Core 207 208**Since** 209 21010 211 212 213## Enum Description 214 215 216### OH_AudioStream_EncodingType 217 218 219``` 220enum OH_AudioStream_EncodingType 221``` 222 223**Description** 224 225Enumerates the encoding types of audio streams. 226 227\@syscap SystemCapability.Multimedia.Audio.Core 228 229**Since** 230 23110 232 233 | Value| Description| 234| -------- | -------- | 235| AUDIOSTREAM_ENCODING_TYPE_RAW | PCM encoding.| 236 237 238### OH_AudioStream_LatencyMode 239 240 241``` 242enum OH_AudioStream_LatencyMode 243``` 244 245**Description** 246 247Enumerates the latency modes of audio streams. 248 249\@syscap SystemCapability.Multimedia.Audio.Core 250 251**Since** 252 25310 254 255 | Value| Description| 256| -------- | -------- | 257| AUDIOSTREAM_LATENCY_MODE_NORMAL | Normal latency mode.| 258| AUDIOSTREAM_LATENCY_MODE_FAST | Low latency mode.| 259 260 261### OH_AudioStream_Result 262 263 264``` 265enum OH_AudioStream_Result 266``` 267 268**Description** 269 270Enumerates the audio stream result codes. 271 272\@syscap SystemCapability.Multimedia.Audio.Core 273 274**Since** 275 27610 277 278 | Value| Description| 279| -------- | -------- | 280| AUDIOSTREAM_SUCCESS | Operation successful.| 281| AUDIOSTREAM_ERROR_INVALID_PARAM | Invalid input parameter.| 282| AUDIOSTREAM_ERROR_ILLEGAL_STATE | Invalid state.| 283| AUDIOSTREAM_ERROR_SYSTEM | System error.| 284 285 286### OH_AudioStream_SampleFormat 287 288 289``` 290enum OH_AudioStream_SampleFormat 291``` 292 293**Description** 294 295Enumerates the sampling formats of audio streams. 296 297\@syscap SystemCapability.Multimedia.Audio.Core 298 299**Since** 300 30110 302 303 | Value| Description| 304| -------- | -------- | 305| AUDIOSTREAM_SAMPLE_U8 | Unsigned 8-bit.| 306| AUDIOSTREAM_SAMPLE_S16LE | Short 16-bit little-endian.| 307| AUDIOSTREAM_SAMPLE_S24LE | Short 24-bit little-endian.| 308| AUDIOSTREAM_SAMPLE_S32LE | Short 32-bit little-endian.| 309 310 311### OH_AudioStream_SourceType 312 313 314``` 315enum OH_AudioStream_SourceType 316``` 317 318**Description** 319 320Enumerates the usage scenarios of an audio capturer, that is, the usage scenarios of audio input streams. 321 322\@syscap SystemCapability.Multimedia.Audio.Core 323 324**Since** 325 32610 327 328 | Value| Description| 329| -------- | -------- | 330| AUDIOSTREAM_SOURCE_TYPE_INVALID | Invalid state.| 331| AUDIOSTREAM_SOURCE_TYPE_MIC | Audio recording.| 332| AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION | Voice recognition.| 333| AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION | Voice communication.| 334 335 336### OH_AudioStream_State 337 338 339``` 340enum OH_AudioStream_State 341``` 342 343**Description** 344 345Enumerates the audio stream states. 346 347\@syscap SystemCapability.Multimedia.Audio.Core 348 349**Since** 350 35110 352 353 | Value| Description| 354| -------- | -------- | 355| AUDIOSTREAM_STATE_INVALID | Invalid state.| 356| AUDIOSTREAM_STATE_PREPARED | Prepared.| 357| AUDIOSTREAM_STATE_RUNNING | Running.| 358| AUDIOSTREAM_STATE_STOPPED | Stopped.| 359| AUDIOSTREAM_STATE_RELEASED | Released.| 360| AUDIOSTREAM_STATE_PAUSED | Paused.| 361 362 363### OH_AudioStream_Type 364 365 366``` 367enum OH_AudioStream_Type 368``` 369 370**Description** 371 372Enumerates the audio stream types. 373 374\@syscap SystemCapability.Multimedia.Audio.Core 375 376**Since** 377 37810 379 380 | Value| Description| 381| -------- | -------- | 382| AUDIOSTREAM_TYPE_RENDERER | The audio stream is an output stream.| 383| AUDIOSTREAM_TYPE_CAPTURER | The audio stream is an input stream.| 384 385 386### OH_AudioStream_Usage 387 388 389``` 390enum OH_AudioStream_Usage 391``` 392 393**Description** 394 395Enumerates the usage scenarios of an audio renderer, that is, the usage scenarios of audio output streams. 396 397\@syscap SystemCapability.Multimedia.Audio.Core 398 399**Since** 400 40110 402 403 | Value| Description| 404| -------- | -------- | 405| AUDIOSTREAM_USAGE_UNKNOWN | Undefined.| 406| AUDIOSTREAM_USAGE_MUSIC | Music.| 407| AUDIOSTREAM_USAGE_COMMUNICATION | Voice communication.| 408| AUDIOSTREAM_USAGE_GAME | Gaming.| 409 410 411## Function Description 412 413 414### OH_AudioCapturer_Flush() 415 416 417``` 418OH_AudioStream_Result OH_AudioCapturer_Flush (OH_AudioCapturer * capturer) 419``` 420 421**Description** 422 423Flushes obtained audio data. 424 425**Parameters** 426 427| Name| Description| 428| -------- | -------- | 429| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 430 431**Returns** 432 433Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 434 435**Since** 436 43710 438 439 440### OH_AudioCapturer_GetCapturerInfo() 441 442 443``` 444OH_AudioStream_Result OH_AudioCapturer_GetCapturerInfo (OH_AudioCapturer * capturer, OH_AudioStream_SourceType * sourceType ) 445``` 446 447**Description** 448 449Obtains the usage scenario of an audio capturer. 450 451**Parameters** 452 453| Name| Description| 454| -------- | -------- | 455| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 456| sourceType | Pointer to a variable used to receive the usage scenario.| 457 458**Returns** 459 460Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 461 462**Since** 463 46410 465 466 467### OH_AudioCapturer_GetChannelCount() 468 469 470``` 471OH_AudioStream_Result OH_AudioCapturer_GetChannelCount (OH_AudioCapturer * capturer, int32_t * channelCount ) 472``` 473 474**Description** 475 476Obtains the number of channels for an audio capturer. 477 478**Parameters** 479 480| Name| Description| 481| -------- | -------- | 482| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 483| channelCount | Pointer to a variable used to receive the number of channels.| 484 485**Returns** 486 487Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 488 489**Since** 490 49110 492 493 494### OH_AudioCapturer_GetCurrentState() 495 496 497``` 498OH_AudioStream_Result OH_AudioCapturer_GetCurrentState (OH_AudioCapturer * capturer, OH_AudioStream_State * state ) 499``` 500 501**Description** 502 503Obtains the state of an audio capturer. 504 505**Parameters** 506 507| Name| Description| 508| -------- | -------- | 509| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 510| state | Pointer to a variable used to receive the state.| 511 512**Returns** 513 514Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 515 516**Since** 517 51810 519 520 521### OH_AudioCapturer_GetEncodingType() 522 523 524``` 525OH_AudioStream_Result OH_AudioCapturer_GetEncodingType (OH_AudioCapturer * capturer, OH_AudioStream_EncodingType * encodingType ) 526``` 527 528**Description** 529 530Obtains the encoding type of an audio capturer. 531 532**Parameters** 533 534| Name| Description| 535| -------- | -------- | 536| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 537| encodingType | Pointer to a variable used to receive the encoding type.| 538 539**Returns** 540 541Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 542 543**Since** 544 54510 546 547 548### OH_AudioCapturer_GetLatencyMode() 549 550 551``` 552OH_AudioStream_Result OH_AudioCapturer_GetLatencyMode (OH_AudioCapturer * capturer, OH_AudioStream_LatencyMode * latencyMode ) 553``` 554 555**Description** 556 557Obtains the latency mode of an audio capturer. 558 559**Parameters** 560 561| Name| Description| 562| -------- | -------- | 563| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 564| latencyMode | Pointer to a variable used to receive the latency mode.| 565 566**Returns** 567 568Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 569 570**Since** 571 57210 573 574 575### OH_AudioCapturer_GetSampleFormat() 576 577 578``` 579OH_AudioStream_Result OH_AudioCapturer_GetSampleFormat (OH_AudioCapturer * capturer, OH_AudioStream_SampleFormat * sampleFormat ) 580``` 581 582**Description** 583 584Obtains the sampling format of an audio capturer. 585 586**Parameters** 587 588| Name| Description| 589| -------- | -------- | 590| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 591| sampleFormat | Pointer to a variable used to receive the sampling format.| 592 593**Returns** 594 595Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 596 597**Since** 598 59910 600 601 602### OH_AudioCapturer_GetSamplingRate() 603 604 605``` 606OH_AudioStream_Result OH_AudioCapturer_GetSamplingRate (OH_AudioCapturer * capturer, int32_t * rate ) 607``` 608 609**Description** 610 611Obtains the sampling rate of an audio capturer. 612 613**Parameters** 614 615| Name| Description| 616| -------- | -------- | 617| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 618| rate | Pointer to a variable used to receive the sampling rate.| 619 620**Returns** 621 622Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 623 624**Since** 625 62610 627 628 629### OH_AudioCapturer_GetStreamId() 630 631 632``` 633OH_AudioStream_Result OH_AudioCapturer_GetStreamId (OH_AudioCapturer * capturer, uint32_t * streamId ) 634``` 635 636**Description** 637 638Obtains the stream ID of an audio capturer. 639 640**Parameters** 641 642| Name| Description| 643| -------- | -------- | 644| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 645| streamId | Pointer to a variable used to receive the stream ID.| 646 647**Returns** 648 649Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 650 651**Since** 652 65310 654 655 656### OH_AudioCapturer_Pause() 657 658 659``` 660OH_AudioStream_Result OH_AudioCapturer_Pause (OH_AudioCapturer * capturer) 661``` 662 663**Description** 664 665Pauses an audio capturer. 666 667**Parameters** 668 669| Name| Description| 670| -------- | -------- | 671| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 672 673**Returns** 674 675Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 676 677**Since** 678 67910 680 681 682### OH_AudioCapturer_Release() 683 684 685``` 686OH_AudioStream_Result OH_AudioCapturer_Release (OH_AudioCapturer * capturer) 687``` 688 689**Description** 690 691Releases an audio capturer. 692 693**Parameters** 694 695| Name| Description| 696| -------- | -------- | 697| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 698 699**Returns** 700 701Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 702 703**Since** 704 70510 706 707 708### OH_AudioCapturer_Start() 709 710 711``` 712OH_AudioStream_Result OH_AudioCapturer_Start (OH_AudioCapturer * capturer) 713``` 714 715**Description** 716 717Starts an audio capturer. 718 719**Parameters** 720 721| Name| Description| 722| -------- | -------- | 723| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 724 725**Returns** 726 727Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 728 729**Since** 730 73110 732 733 734### OH_AudioCapturer_Stop() 735 736 737``` 738OH_AudioStream_Result OH_AudioCapturer_Stop (OH_AudioCapturer * capturer) 739``` 740 741**Description** 742 743Stops an audio capturer. 744 745**Parameters** 746 747| Name| Description| 748| -------- | -------- | 749| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| 750 751**Returns** 752 753Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 754 755**Since** 756 75710 758 759 760### OH_AudioRenderer_Flush() 761 762 763``` 764OH_AudioStream_Result OH_AudioRenderer_Flush (OH_AudioRenderer * renderer) 765``` 766 767**Description** 768 769Flushes written audio data. 770 771**Parameters** 772 773| Name| Description| 774| -------- | -------- | 775| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 776 777**Returns** 778 779Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 780 781**Since** 782 78310 784 785 786### OH_AudioRenderer_GetChannelCount() 787 788 789``` 790OH_AudioStream_Result OH_AudioRenderer_GetChannelCount (OH_AudioRenderer * renderer, int32_t * channelCount ) 791``` 792 793**Description** 794 795Obtains the number of channels for an audio renderer. 796 797**Parameters** 798 799| Name| Description| 800| -------- | -------- | 801| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 802| channelCount | Pointer to a variable used to receive the number of channels.| 803 804**Returns** 805 806Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 807 808**Since** 809 81010 811 812 813### OH_AudioRenderer_GetCurrentState() 814 815 816``` 817OH_AudioStream_Result OH_AudioRenderer_GetCurrentState (OH_AudioRenderer * renderer, OH_AudioStream_State * state ) 818``` 819 820**Description** 821 822Obtains the state of an audio renderer. 823 824**Parameters** 825 826| Name| Description| 827| -------- | -------- | 828| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 829| state | Pointer to a variable used to receive the state.| 830 831**Returns** 832 833Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 834 835**Since** 836 83710 838 839 840### OH_AudioRenderer_GetEncodingType() 841 842 843``` 844OH_AudioStream_Result OH_AudioRenderer_GetEncodingType (OH_AudioRenderer * renderer, OH_AudioStream_EncodingType * encodingType ) 845``` 846 847**Description** 848 849Obtains the encoding type of an audio renderer. 850 851**Parameters** 852 853| Name| Description| 854| -------- | -------- | 855| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 856| encodingType | Pointer to a variable used to receive the encoding type.| 857 858**Returns** 859 860Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 861 862**Since** 863 86410 865 866 867### OH_AudioRenderer_GetLatencyMode() 868 869 870``` 871OH_AudioStream_Result OH_AudioRenderer_GetLatencyMode (OH_AudioRenderer * renderer, OH_AudioStream_LatencyMode * latencyMode ) 872``` 873 874**Description** 875 876Obtains the latency mode of an audio renderer. 877 878**Parameters** 879 880| Name| Description| 881| -------- | -------- | 882| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 883| latencyMode | Pointer to a variable used to receive the latency mode.| 884 885**Returns** 886 887Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 888 889**Since** 890 89110 892 893 894### OH_AudioRenderer_GetRendererInfo() 895 896 897``` 898OH_AudioStream_Result OH_AudioRenderer_GetRendererInfo (OH_AudioRenderer * renderer, OH_AudioStream_Usage * usage ) 899``` 900 901**Description** 902 903Obtains the usage scenario of an audio renderer. 904 905**Parameters** 906 907| Name| Description| 908| -------- | -------- | 909| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 910| usage | Pointer to a variable used to receive the usage scenario.| 911 912**Returns** 913 914Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 915 916**Since** 917 91810 919 920 921### OH_AudioRenderer_GetSampleFormat() 922 923 924``` 925OH_AudioStream_Result OH_AudioRenderer_GetSampleFormat (OH_AudioRenderer * renderer, OH_AudioStream_SampleFormat * sampleFormat ) 926``` 927 928**Description** 929 930Obtains the sampling format of an audio renderer. 931 932**Parameters** 933 934| Name| Description| 935| -------- | -------- | 936| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 937| sampleFormat | Pointer to a variable used to receive the sampling format.| 938 939**Returns** 940 941Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 942 943**Since** 944 94510 946 947 948### OH_AudioRenderer_GetSamplingRate() 949 950 951``` 952OH_AudioStream_Result OH_AudioRenderer_GetSamplingRate (OH_AudioRenderer * renderer, int32_t * rate ) 953``` 954 955**Description** 956 957Obtains the sampling rate of an audio renderer. 958 959**Parameters** 960 961| Name| Description| 962| -------- | -------- | 963| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 964| rate | Pointer to a variable used to receive the sampling rate.| 965 966**Returns** 967 968Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 969 970**Since** 971 97210 973 974 975### OH_AudioRenderer_GetStreamId() 976 977 978``` 979OH_AudioStream_Result OH_AudioRenderer_GetStreamId (OH_AudioRenderer * renderer, uint32_t * streamId ) 980``` 981 982**Description** 983 984Obtains the stream ID of an audio renderer. 985 986**Parameters** 987 988| Name| Description| 989| -------- | -------- | 990| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 991| streamId | Pointer to a variable used to receive the stream ID.| 992 993**Returns** 994 995Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 996 997**Since** 998 99910 1000 1001 1002### OH_AudioRenderer_Pause() 1003 1004 1005``` 1006OH_AudioStream_Result OH_AudioRenderer_Pause (OH_AudioRenderer * renderer) 1007``` 1008 1009**Description** 1010 1011Pauses an audio renderer. 1012 1013**Parameters** 1014 1015| Name| Description| 1016| -------- | -------- | 1017| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 1018 1019**Returns** 1020 1021Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1022 1023**Since** 1024 102510 1026 1027 1028### OH_AudioRenderer_Release() 1029 1030 1031``` 1032OH_AudioStream_Result OH_AudioRenderer_Release (OH_AudioRenderer * renderer) 1033``` 1034 1035**Description** 1036 1037Releases an audio renderer. 1038 1039**Parameters** 1040 1041| Name| Description| 1042| -------- | -------- | 1043| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 1044 1045**Returns** 1046 1047Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1048 1049**Since** 1050 105110 1052 1053 1054### OH_AudioRenderer_Start() 1055 1056 1057``` 1058OH_AudioStream_Result OH_AudioRenderer_Start (OH_AudioRenderer * renderer) 1059``` 1060 1061**Description** 1062 1063Starts an audio renderer. 1064 1065**Parameters** 1066 1067| Name| Description| 1068| -------- | -------- | 1069| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 1070 1071**Returns** 1072 1073Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1074 1075**Since** 1076 107710 1078 1079 1080### OH_AudioRenderer_Stop() 1081 1082 1083``` 1084OH_AudioStream_Result OH_AudioRenderer_Stop (OH_AudioRenderer * renderer) 1085``` 1086 1087**Description** 1088 1089Stops an audio renderer. 1090 1091**Parameters** 1092 1093| Name| Description| 1094| -------- | -------- | 1095| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| 1096 1097**Returns** 1098 1099Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1100 1101**Since** 1102 110310 1104 1105 1106### OH_AudioStreamBuilder_Create() 1107 1108 1109``` 1110OH_AudioStream_Result OH_AudioStreamBuilder_Create (OH_AudioStreamBuilder ** builder, OH_AudioStream_Type type ) 1111``` 1112 1113**Description** 1114 1115Creates an audio stream builder, which can be an audio renderer or capturer. 1116 1117You need to call **OH_AudioStreamBuilder_Destroy()** to destroy the builder when it is no longer required. 1118 1119**Parameters** 1120 1121| Name| Description| 1122| -------- | -------- | 1123| builder | Double pointer to the audio stream builder created.| 1124| type | Type of the audio stream builder, which can be **AUDIOSTREAM_TYPE_RENDERER** or **AUDIOSTREAM_TYPE_CAPTURER**.| 1125 1126**Returns** 1127 1128Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1129 1130**Since** 1131 113210 1133 1134 1135### OH_AudioStreamBuilder_Destroy() 1136 1137 1138``` 1139OH_AudioStream_Result OH_AudioStreamBuilder_Destroy (OH_AudioStreamBuilder * builder) 1140``` 1141 1142**Description** 1143 1144Destroys an audio stream builder when it is no longer required. 1145 1146**Parameters** 1147 1148| Name| Description| 1149| -------- | -------- | 1150| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1151 1152**Returns** 1153 1154Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1155 1156**Since** 1157 115810 1159 1160 1161### OH_AudioStreamBuilder_GenerateCapturer() 1162 1163 1164``` 1165OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer (OH_AudioStreamBuilder * builder, OH_AudioCapturer ** audioCapturer ) 1166``` 1167 1168**Description** 1169 1170Creates an audio capturer instance. 1171 1172**Parameters** 1173 1174| Name| Description| 1175| -------- | -------- | 1176| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1177| audioCapturer | Double pointer to the audio capturer instance created.| 1178 1179**Returns** 1180 1181Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1182 1183**Since** 1184 118510 1186 1187 1188### OH_AudioStreamBuilder_GenerateRenderer() 1189 1190 1191``` 1192OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer (OH_AudioStreamBuilder * builder, OH_AudioRenderer ** audioRenderer ) 1193``` 1194 1195**Description** 1196 1197Creates an audio renderer instance. 1198 1199**Parameters** 1200 1201| Name| Description| 1202| -------- | -------- | 1203| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1204| audioRenderer | Double pointer to the audio renderer instance created.| 1205 1206**Returns** 1207 1208Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1209 1210**Since** 1211 121210 1213 1214 1215### OH_AudioStreamBuilder_SetCapturerCallback() 1216 1217 1218``` 1219OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback (OH_AudioStreamBuilder * builder, OH_AudioCapturer_Callbacks callbacks, void * userData ) 1220``` 1221 1222**Description** 1223 1224Sets callbacks for an audio capturer. 1225 1226**Parameters** 1227 1228| Name| Description| 1229| -------- | -------- | 1230| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1231| callbacks | Callback functions that will be used to process events related to input audio streams.| 1232| userData | Pointer to the application data passed through the callback functions.| 1233 1234**Returns** 1235 1236Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1237 1238**Since** 1239 124010 1241 1242 1243### OH_AudioStreamBuilder_SetCapturerInfo() 1244 1245 1246``` 1247OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo (OH_AudioStreamBuilder * builder, OH_AudioStream_SourceType sourceType ) 1248``` 1249 1250**Description** 1251 1252Sets the usage scenario of an audio capturer. 1253 1254**Parameters** 1255 1256| Name| Description| 1257| -------- | -------- | 1258| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1259| sourceType | Usage scenario of the audio capturer.| 1260 1261**Returns** 1262 1263Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1264 1265**Since** 1266 126710 1268 1269 1270### OH_AudioStreamBuilder_SetChannelCount() 1271 1272 1273``` 1274OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount (OH_AudioStreamBuilder * builder, int32_t channelCount ) 1275``` 1276 1277**Description** 1278 1279Sets the number of channels for an audio stream. 1280 1281**Parameters** 1282 1283| Name| Description| 1284| -------- | -------- | 1285| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1286| channelCount | Number of channels.| 1287 1288**Returns** 1289 1290Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1291 1292**Since** 1293 129410 1295 1296 1297### OH_AudioStreamBuilder_SetEncodingType() 1298 1299 1300``` 1301OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType (OH_AudioStreamBuilder * builder, OH_AudioStream_EncodingType encodingType ) 1302``` 1303 1304**Description** 1305 1306Sets the encoding type of an audio stream. 1307 1308**Parameters** 1309 1310| Name| Description| 1311| -------- | -------- | 1312| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1313| encodingType | Encoding type, which can be **AUDIOSTREAM_ENCODING_PCM**.| 1314 1315**Returns** 1316 1317Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1318 1319**Since** 1320 132110 1322 1323 1324### OH_AudioStreamBuilder_SetLatencyMode() 1325 1326 1327``` 1328OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode (OH_AudioStreamBuilder * builder, OH_AudioStream_LatencyMode latencyMode ) 1329``` 1330 1331**Description** 1332 1333Sets the latency mode of an audio stream. 1334 1335**Parameters** 1336 1337| Name| Description| 1338| -------- | -------- | 1339| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1340| latencyMode | Latency mode.| 1341 1342**Returns** 1343 1344Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1345 1346**Since** 1347 134810 1349 1350 1351### OH_AudioStreamBuilder_SetRendererCallback() 1352 1353 1354``` 1355OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback (OH_AudioStreamBuilder * builder, OH_AudioRenderer_Callbacks callbacks, void * userData ) 1356``` 1357 1358**Description** 1359 1360Sets callbacks for an audio renderer. 1361 1362**Parameters** 1363 1364| Name| Description| 1365| -------- | -------- | 1366| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1367| callbacks | Callback functions that will be used to process events related to output audio streams.| 1368| userData | Pointer to the application data passed through the callback functions.| 1369 1370**Returns** 1371 1372Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1373 1374**Since** 1375 137610 1377 1378 1379### OH_AudioStreamBuilder_SetRendererInfo() 1380 1381 1382``` 1383OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo (OH_AudioStreamBuilder * builder, OH_AudioStream_Usage usage ) 1384``` 1385 1386**Description** 1387 1388Sets the usage scenario of an audio renderer. 1389 1390**Parameters** 1391 1392| Name| Description| 1393| -------- | -------- | 1394| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1395| usage | Usage scenario of the audio renderer.| 1396 1397**Returns** 1398 1399Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1400 1401**Since** 1402 140310 1404 1405 1406### OH_AudioStreamBuilder_SetSampleFormat() 1407 1408 1409``` 1410OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat (OH_AudioStreamBuilder * builder, OH_AudioStream_SampleFormat format ) 1411``` 1412 1413**Description** 1414 1415Sets the sampling format of an audio stream. 1416 1417**Parameters** 1418 1419| Name| Description| 1420| -------- | -------- | 1421| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1422| format | Sampling format.| 1423 1424**Returns** 1425 1426Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1427 1428**Since** 1429 143010 1431 1432 1433### OH_AudioStreamBuilder_SetSamplingRate() 1434 1435 1436``` 1437OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate (OH_AudioStreamBuilder * builder, int32_t rate ) 1438``` 1439 1440**Description** 1441 1442Sets the sampling rate of an audio stream. 1443 1444**Parameters** 1445 1446| Name| Description| 1447| -------- | -------- | 1448| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| 1449| channelCount | Sampling rate.| 1450 1451**Returns** 1452 1453Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. 1454 1455**Since** 1456 145710 1458 1459 1460## Variable Description 1461 1462 1463### OH_AudioCapturer_OnReadData 1464 1465 1466``` 1467int32_t(* OH_AudioCapturer_Callbacks_Struct::OH_AudioCapturer_OnReadData) (OH_AudioCapturer *capturer, void *userData, void *buffer, int32_t lenth) 1468``` 1469 1470**Description** 1471 1472Defines a function pointer to the callback function used to read audio data. 1473 1474**Since** 1475 147610 1477 1478 1479### OH_AudioRenderer_OnWriteData 1480 1481 1482``` 1483int32_t(* OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnWriteData) (OH_AudioRenderer *renderer, void *userData, void *buffer, int32_t lenth) 1484``` 1485 1486**Description** 1487 1488Defines a function pointer to the callback function used to write audio data. 1489 1490**Since** 1491 149210 1493