1# native_audiostreambuilder.h 2 3## Overview 4 5The file declares the functions related to an audio stream builder. 6 7You can use the functions to create and destroy an audio stream builder, set audio stream attributes, and set callbacks. 8 9**File to include**: <ohaudio/native_audiostreambuilder.h> 10 11**Library**: libohaudio.so 12 13**System capability**: SystemCapability.Multimedia.Audio.Core 14 15**Since**: 10 16 17**Related module**: [OHAudio](capi-ohaudio.md) 18 19## Summary 20 21### Functions 22 23| Name| Description| 24| -- | -- | 25| [OH_AudioStream_Result OH_AudioStreamBuilder_Create(OH_AudioStreamBuilder** builder, OH_AudioStream_Type type)](#oh_audiostreambuilder_create) | Creates an audio stream builder, which can be an audio renderer or capturer.<br>You need to call [OH_AudioStreamBuilder_Destroy](#oh_audiostreambuilder_destroy) to destroy the builder when it is no longer required.| 26| [OH_AudioStream_Result OH_AudioStreamBuilder_Destroy(OH_AudioStreamBuilder* builder)](#oh_audiostreambuilder_destroy) | Destroys an audio stream builder.<br>You need to call this function to destroy the builder when it is no longer required.| 27| [OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate(OH_AudioStreamBuilder* builder, int32_t rate)](#oh_audiostreambuilder_setsamplingrate) | Sets the sampling rate of an audio stream.| 28| [OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount(OH_AudioStreamBuilder* builder, int32_t channelCount)](#oh_audiostreambuilder_setchannelcount) | Sets the number of channels for an audio stream.| 29| [OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat(OH_AudioStreamBuilder* builder,OH_AudioStream_SampleFormat format)](#oh_audiostreambuilder_setsampleformat) | Sets the sampling format of an audio stream.| 30| [OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType(OH_AudioStreamBuilder* builder,OH_AudioStream_EncodingType encodingType)](#oh_audiostreambuilder_setencodingtype) | Sets the encoding type of an audio stream.| 31| [OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode(OH_AudioStreamBuilder* builder,OH_AudioStream_LatencyMode latencyMode)](#oh_audiostreambuilder_setlatencymode) | Sets the latency mode of an audio stream.| 32| [OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelLayout(OH_AudioStreamBuilder* builder,OH_AudioChannelLayout channelLayout)](#oh_audiostreambuilder_setchannellayout) | Sets the channel layout for an audio stream.| 33| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo(OH_AudioStreamBuilder* builder,OH_AudioStream_Usage usage)](#oh_audiostreambuilder_setrendererinfo) | Sets the usage scenario of an audio renderer.| 34| [OH_AudioStream_Result OH_AudioStreamBuilder_SetVolumeMode(OH_AudioStreamBuilder* builder,OH_AudioStream_VolumeMode volumeMode)](#oh_audiostreambuilder_setvolumemode) | Sets the volume mode for an audio stream.| 35| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo(OH_AudioStreamBuilder* builder,OH_AudioStream_SourceType sourceType)](#oh_audiostreambuilder_setcapturerinfo) | Sets the usage scenario of an audio capturer.| 36| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_Callbacks callbacks, void* userData)](#oh_audiostreambuilder_setrenderercallback) | Sets callbacks for an audio renderer.| 37| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OutputDeviceChangeCallback callback, void* userData)](#oh_audiostreambuilder_setrendereroutputdevicechangecallback) | Sets the callback for audio renderer device change events.| 38| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererPrivacy(OH_AudioStreamBuilder* builder,OH_AudioStream_PrivacyType privacy)](#oh_audiostreambuilder_setrendererprivacy) | Sets the privacy type for the audio stream being played. The privacy type specifies whether the audio stream can be recorded by other applications.| 39| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_Callbacks callbacks, void* userData)](#oh_audiostreambuilder_setcapturercallback) | Sets callbacks for an audio capturer.| 40| [OH_AudioStream_Result OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_WriteDataWithMetadataCallback callback, void* userData)](#oh_audiostreambuilder_setwritedatawithmetadatacallback) | Sets the callback used to write both audio data and metadata.| 41| [OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuilder* builder,OH_AudioRenderer** audioRenderer)](#oh_audiostreambuilder_generaterenderer) | Creates an audio renderer instance.| 42| [OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder* builder,OH_AudioCapturer** audioCapturer)](#oh_audiostreambuilder_generatecapturer) | Creates an audio capturer instance.| 43| [OH_AudioStream_Result OH_AudioStreamBuilder_SetFrameSizeInCallback(OH_AudioStreamBuilder* builder,int32_t frameSize)](#oh_audiostreambuilder_setframesizeincallback) | Sets the frame size for each callback during playback. The frame size must be at least equal to the size of the data processed by the audio hardware at a time and less than half of the internal buffer capacity.| 44| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInterruptMode(OH_AudioStreamBuilder* builder,OH_AudioInterrupt_Mode mode)](#oh_audiostreambuilder_setrendererinterruptmode) | Sets the interrupt mode of the stream client.| 45| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererWriteDataCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnWriteDataCallback callback, void* userData)](#oh_audiostreambuilder_setrendererwritedatacallback) | Sets the callback used to write audio data.<br>This function is similar to [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback). If both the functions are used, only the last callback takes effect.| 46| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererWriteDataCallbackAdvanced(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnWriteDataCallbackAdvanced callback, void* userData)](#oh_audiostreambuilder_setrendererwritedatacallbackadvanced) | Sets the callback used to write audio data.<br>This function is similar to [OH_AudioStreamBuilder_SetRendererWriteDataCallback](#oh_audiostreambuilder_setrendererwritedatacallback).<br>If both the functions are used, only the last callback takes effect.<br>Unlike **OH_AudioStreamBuilder_SetRendererWriteDataCallback**, **OH_AudioStreamBuilder_SetRendererWriteDataCallbackAdvanced** allows an application to pass variable-length audio data and notify the system of the length of the data written.| 47| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInterruptCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnInterruptCallback callback, void* userData)](#oh_audiostreambuilder_setrendererinterruptcallback) | Sets the callback for interruption events of an audio renderer.<br>This function is similar to [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback). If both the functions are used, only the last callback takes effect.| 48| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererErrorCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnErrorCallback callback, void* userData)](#oh_audiostreambuilder_setrenderererrorcallback) | Sets the callback for error events of an audio renderer.<br>This function is similar to [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback). If both the functions are used, only the last callback takes effect.| 49| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerReadDataCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnReadDataCallback callback, void* userData)](#oh_audiostreambuilder_setcapturerreaddatacallback) | Sets the callback used to read data for an audio capturer.<br>This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect.| 50| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnDeviceChangeCallback callback, void* userData)](#oh_audiostreambuilder_setcapturerdevicechangecallback) | Sets the callback for audio capturer device change events.<br>This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect.| 51| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInterruptCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnInterruptCallback callback, void* userData)](#oh_audiostreambuilder_setcapturerinterruptcallback) | Sets the callback for interruption events of an audio capturer.<br>This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect.| 52| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerErrorCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnErrorCallback callback, void* userData)](#oh_audiostreambuilder_setcapturererrorcallback) | Sets the callback for error events of an audio capturer.<br>This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect.| 53| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerWillMuteWhenInterrupted(OH_AudioStreamBuilder* builder,bool muteWhenInterrupted)](#oh_audiostreambuilder_setcapturerwillmutewheninterrupted) | Sets whether to mute the audio input stream when an audio interruption occurs.| 54| [OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererFastStatusChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnFastStatusChange callback, void* userData)](#oh_audiostreambuilder_setrendererfaststatuschangecallback) | Sets a callback for low-latency status changes during audio playback.| 55| [OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerFastStatusChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnFastStatusChange callback, void* userData)](#oh_audiostreambuilder_setcapturerfaststatuschangecallback) | Sets a callback for low-latency status changes during audio recording.| 56 57## Function Description 58 59### OH_AudioStreamBuilder_Create() 60 61``` 62OH_AudioStream_Result OH_AudioStreamBuilder_Create(OH_AudioStreamBuilder** builder, OH_AudioStream_Type type) 63``` 64 65**Description** 66 67Creates an audio stream builder, which can be an audio renderer or capturer. 68 69You need to call [OH_AudioStreamBuilder_Destroy](#oh_audiostreambuilder_destroy) to destroy the builder when it is no longer required. 70 71**Since**: 10 72 73 74**Parameters** 75 76| Name| Description| 77| -- | -- | 78| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)** builder | Double pointer to the audio stream builder created.| 79| [OH_AudioStream_Type](capi-native-audiostream-base-h.md#oh_audiostream_type) type | Type of the audio stream builder, which can be AUDIOSTREAM_TYPE_RENDERER or AUDIOSTREAM_TYPE_CAPTURER.| 80 81**Returns** 82 83| Type| Description| 84| -- | -- | 85| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.| 86 87### OH_AudioStreamBuilder_Destroy() 88 89``` 90OH_AudioStream_Result OH_AudioStreamBuilder_Destroy(OH_AudioStreamBuilder* builder) 91``` 92 93**Description** 94 95Destroys an audio stream builder. 96 97You need to call this function to destroy the builder when it is no longer required. 98 99**Since**: 10 100 101 102**Parameters** 103 104| Name| Description| 105| -- | -- | 106| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 107 108**Returns** 109 110| Type| Description| 111| -- | -- | 112| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is nullptr.<br>**AUDIOSTREAM_ERROR_ILLEGAL_STATE**: The execution status is abnormal. | 113 114### OH_AudioStreamBuilder_SetSamplingRate() 115 116``` 117OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate(OH_AudioStreamBuilder* builder, int32_t rate) 118``` 119 120**Description** 121 122Sets the sampling rate of an audio stream. 123 124**Since**: 10 125 126 127**Parameters** 128 129| Name| Description| 130| -- | -- | 131| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 132| int32_t rate | Sampling rate.| 133 134**Returns** 135 136| Type| Description| 137| -- | -- | 138| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **rate** parameter is invalid. | 139 140### OH_AudioStreamBuilder_SetChannelCount() 141 142``` 143OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount(OH_AudioStreamBuilder* builder, int32_t channelCount) 144``` 145 146**Description** 147 148Sets the number of channels for an audio stream. 149 150**Since**: 10 151 152 153**Parameters** 154 155| Name| Description| 156| -- | -- | 157| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 158| int32_t channelCount | Number of channels.| 159 160**Returns** 161 162| Type| Description| 163| -- | -- | 164| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **channelCount** parameter is invalid.| 165 166### OH_AudioStreamBuilder_SetSampleFormat() 167 168``` 169OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat(OH_AudioStreamBuilder* builder,OH_AudioStream_SampleFormat format) 170``` 171 172**Description** 173 174Sets the sampling format of an audio stream. 175 176**Since**: 10 177 178 179**Parameters** 180 181| Name| Description| 182| -- | -- | 183| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 184| [OH_AudioStream_SampleFormat](capi-native-audiostream-base-h.md#oh_audiostream_sampleformat) format | Sampling format.| 185 186**Returns** 187 188| Type| Description| 189| -- | -- | 190| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is nullptr.| 191 192### OH_AudioStreamBuilder_SetEncodingType() 193 194``` 195OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType(OH_AudioStreamBuilder* builder,OH_AudioStream_EncodingType encodingType) 196``` 197 198**Description** 199 200Sets the encoding type of an audio stream. 201 202**Since**: 10 203 204 205**Parameters** 206 207| Name| Description| 208| -- | -- | 209| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 210| [OH_AudioStream_EncodingType](capi-native-audiostream-base-h.md#oh_audiostream_encodingtype) encodingType | Encoding type.| 211 212**Returns** 213 214| Type| Description| 215| -- | -- | 216| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is nullptr.| 217 218### OH_AudioStreamBuilder_SetLatencyMode() 219 220``` 221OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode(OH_AudioStreamBuilder* builder,OH_AudioStream_LatencyMode latencyMode) 222``` 223 224**Description** 225 226Sets the latency mode of an audio stream. 227 228**Since**: 10 229 230 231**Parameters** 232 233| Name| Description| 234| -- | -- | 235| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 236| [OH_AudioStream_LatencyMode](capi-native-audiostream-base-h.md#oh_audiostream_latencymode) latencyMode | Latency mode.| 237 238**Returns** 239 240| Type| Description| 241| -- | -- | 242| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is nullptr.| 243 244### OH_AudioStreamBuilder_SetChannelLayout() 245 246``` 247OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelLayout(OH_AudioStreamBuilder* builder,OH_AudioChannelLayout channelLayout) 248``` 249 250**Description** 251 252Sets the channel layout for an audio stream. 253 254**Since**: 12 255 256 257**Parameters** 258 259| Name| Description| 260| -- | -- | 261| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 262| [OH_AudioChannelLayout](../apis-avcodec-kit/_core.md#oh_audiochannellayout-1) channelLayout | Channel layout.| 263 264**Returns** 265 266| Type| Description| 267| -- | -- | 268| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is nullptr.| 269 270### OH_AudioStreamBuilder_SetRendererInfo() 271 272``` 273OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo(OH_AudioStreamBuilder* builder,OH_AudioStream_Usage usage) 274``` 275 276**Description** 277 278Sets the usage scenario of an audio renderer. 279 280**Since**: 10 281 282 283**Parameters** 284 285| Name| Description| 286| -- | -- | 287| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 288| [OH_AudioStream_Usage](capi-native-audiostream-base-h.md#oh_audiostream_usage) usage | Usage scenario of the audio renderer.| 289 290**Returns** 291 292| Type| Description| 293| -- | -- | 294| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **usage** parameter is invalid.| 295 296### OH_AudioStreamBuilder_SetVolumeMode() 297 298``` 299OH_AudioStream_Result OH_AudioStreamBuilder_SetVolumeMode(OH_AudioStreamBuilder* builder,OH_AudioStream_VolumeMode volumeMode) 300``` 301 302**Description** 303 304Sets the volume mode for an audio stream. 305 306**Since**: 18 307 308 309**Parameters** 310 311| Name| Description| 312| -- | -- | 313| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 314| [OH_AudioStream_VolumeMode](capi-native-audiostream-base-h.md#oh_audiostream_volumemode) volumeMode | Volume mode of the audio stream.| 315 316**Returns** 317 318| Type| Description| 319| -- | -- | 320| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **volumeMode** parameter is invalid.| 321 322### OH_AudioStreamBuilder_SetCapturerInfo() 323 324``` 325OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo(OH_AudioStreamBuilder* builder,OH_AudioStream_SourceType sourceType) 326``` 327 328**Description** 329 330Sets the usage scenario of an audio capturer. 331 332**Since**: 10 333 334 335**Parameters** 336 337| Name| Description| 338| -- | -- | 339| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 340| [OH_AudioStream_SourceType](capi-native-audiostream-base-h.md#oh_audiostream_sourcetype) sourceType | Usage scenario of the audio capturer.| 341 342**Returns** 343 344| Type| Description| 345| -- | -- | 346| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **sourceType** parameter is invalid.| 347 348### OH_AudioStreamBuilder_SetRendererCallback() 349 350``` 351OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_Callbacks callbacks, void* userData) 352``` 353 354**Description** 355 356Sets callbacks for an audio renderer. 357 358**Since**: 10 359 360**Deprecated from**: 20 361 362**Substitute** 363 364Use the following APIs for substitute: 365 366[OH_AudioStreamBuilder_SetRendererWriteDataCallback](#oh_audiostreambuilder_setrendererwritedatacallback), [OH_AudioStreamBuilder_SetRendererInterruptCallback](#oh_audiostreambuilder_setrendererinterruptcallback), [OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback](#oh_audiostreambuilder_setrendereroutputdevicechangecallback), and [OH_AudioStreamBuilder_SetRendererErrorCallback](#oh_audiostreambuilder_setrenderererrorcallback) 367 368 369**Parameters** 370 371| Name| Description| 372| -- | -- | 373| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 374| [OH_AudioRenderer_Callbacks](capi-ohaudio-oh-audiorenderer-callbacks-struct.md) callbacks | Callbacks that will be used to process events related to audio output streams.| 375| void* userData | Pointer to the application data passed through the callbacks.| 376 377**Returns** 378 379| Type| Description| 380| -- | -- | 381| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.| 382 383### OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback() 384 385``` 386OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OutputDeviceChangeCallback callback, void* userData) 387``` 388 389**Description** 390 391Sets the callback for audio renderer device change events. 392 393**Since**: 11 394 395 396**Parameters** 397 398| Name| Description| 399| -- | -- | 400| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 401| [OH_AudioRenderer_OutputDeviceChangeCallback](capi-native-audiostream-base-h.md#oh_audiorenderer_outputdevicechangecallback) callback | Callback that will be used to process events related to audio renderer device changes.| 402| void* userData | Pointer to the application data passed through the callback.| 403 404**Returns** 405 406| Type| Description| 407| -- | -- | 408| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.| 409 410### OH_AudioStreamBuilder_SetRendererPrivacy() 411 412``` 413OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererPrivacy(OH_AudioStreamBuilder* builder,OH_AudioStream_PrivacyType privacy) 414``` 415 416**Description** 417 418Sets the privacy type for the audio stream being played. The privacy type specifies whether the audio stream can be recorded by other applications. 419 420**Since**: 12 421 422 423**Parameters** 424 425| Name| Description| 426| -- | -- | 427| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 428| [OH_AudioStream_PrivacyType](capi-native-audiostream-base-h.md#oh_audiostream_privacytype) privacy | Privacy type, which specifies whether the audio stream can be recorded by other applications.| 429 430**Returns** 431 432| Type| Description| 433| -- | -- | 434| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.| 435 436### OH_AudioStreamBuilder_SetCapturerCallback() 437 438``` 439OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_Callbacks callbacks, void* userData) 440``` 441 442**Description** 443 444Sets callbacks for an audio capturer. 445 446**Since**: 10 447 448**Deprecated from**: 20 449 450**Substitute** 451 452Use the following APIs for substitute: 453 454[OH_AudioStreamBuilder_SetCapturerReadDataCallback](#oh_audiostreambuilder_setcapturerreaddatacallback), [OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback](#oh_audiostreambuilder_setcapturerdevicechangecallback), [OH_AudioStreamBuilder_SetCapturerInterruptCallback](#oh_audiostreambuilder_setcapturerinterruptcallback), and [OH_AudioStreamBuilder_SetCapturerErrorCallback](#oh_audiostreambuilder_setcapturererrorcallback) 455 456 457**Parameters** 458 459| Name| Description| 460| -- | -- | 461| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 462| [OH_AudioCapturer_Callbacks](capi-ohaudio-oh-audiocapturer-callbacks-struct.md) callbacks | Callbacks that will be used to process events related to audio input streams.| 463| void* userData | Pointer to the application data passed through the callbacks.| 464 465**Returns** 466 467| Type| Description| 468| -- | -- | 469| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.| 470 471### OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback() 472 473``` 474OH_AudioStream_Result OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_WriteDataWithMetadataCallback callback, void* userData) 475``` 476 477**Description** 478 479Sets the callback used to write both audio data and metadata. 480 481**Since**: 12 482 483 484**Parameters** 485 486| Name| Description| 487| -- | -- | 488| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 489| [OH_AudioRenderer_WriteDataWithMetadataCallback](capi-native-audiostream-base-h.md#oh_audiorenderer_writedatawithmetadatacallback) callback | Callback used to write both audio data and metadata.| 490| void* userData | Pointer to the application data passed through the callback.| 491 492**Returns** 493 494| Type| Description| 495| -- | -- | 496| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.| 497 498### OH_AudioStreamBuilder_GenerateRenderer() 499 500``` 501OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuilder* builder,OH_AudioRenderer** audioRenderer) 502``` 503 504**Description** 505 506Creates an audio renderer instance. 507 508**Since**: 10 509 510 511**Parameters** 512 513| Name| Description| 514| -- | -- | 515| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 516| [OH_AudioRenderer](capi-ohaudio-oh-audiorendererstruct.md)** audioRenderer | Double pointer to the audio renderer instance created.| 517 518**Returns** 519 520| Type| Description| 521| -- | -- | 522| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.<br>3. The OHAudioRenderer instance fails to be created.| 523 524### OH_AudioStreamBuilder_GenerateCapturer() 525 526``` 527OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder* builder,OH_AudioCapturer** audioCapturer) 528``` 529 530**Description** 531 532Creates an audio capturer instance. 533 534**Since**: 10 535 536 537**Parameters** 538 539| Name| Description| 540| -- | -- | 541| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 542| [OH_AudioCapturer](capi-ohaudio-oh-audiocapturerstruct.md)** audioCapturer | Double pointer to the audio capturer instance created.| 543 544**Returns** 545 546| Type| Description| 547| -- | -- | 548| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.<br>3. The OHAudioCapturer instance fails to be created.| 549 550### OH_AudioStreamBuilder_SetFrameSizeInCallback() 551 552``` 553OH_AudioStream_Result OH_AudioStreamBuilder_SetFrameSizeInCallback(OH_AudioStreamBuilder* builder,int32_t frameSize) 554``` 555 556**Description** 557 558Sets the frame size for each callback during playback. The frame size must be at least equal to the size of the data processed by the audio hardware at a time and less than half of the internal buffer capacity. 559 560In the case of low-latency playback, **frameSize** can be set to the frame length corresponding to the audio that lasts for 5 ms, 10 ms, 15 ms, or 20 ms. 561 562In the case of common playback, **frameSize** can be set to the frame length corresponding to the audio that lasts for 20 ms to 100 ms. 563 564**Since**: 11 565 566 567**Parameters** 568 569| Name| Description| 570| -- | -- | 571| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 572| int32_t frameSize | Frame size.| 573 574**Returns** 575 576| Type| Description| 577| -- | -- | 578| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: The **builder** parameter is nullptr.| 579 580### OH_AudioStreamBuilder_SetRendererInterruptMode() 581 582``` 583OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInterruptMode(OH_AudioStreamBuilder* builder,OH_AudioInterrupt_Mode mode) 584``` 585 586**Description** 587 588Sets the interrupt mode of the stream client. 589 590**Since**: 12 591 592 593**Parameters** 594 595| Name| Description| 596| -- | -- | 597| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 598| [OH_AudioInterrupt_Mode](capi-native-audiostream-base-h.md#oh_audiointerrupt_mode) mode | Audio interruption mode.| 599 600**Returns** 601 602| Type| Description| 603| -- | -- | 604| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **mode** parameter is invalid.<br>3. The **StreamType** parameter is invalid.| 605 606### OH_AudioStreamBuilder_SetRendererWriteDataCallback() 607 608``` 609OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererWriteDataCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnWriteDataCallback callback, void* userData) 610``` 611 612**Description** 613 614Sets the callback used to write audio data. 615 616This function is similar to [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback). If both the functions are used, only the last callback takes effect. 617 618**Since**: 12 619 620 621**Parameters** 622 623| Name| Description| 624| -- | -- | 625| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 626| [OH_AudioRenderer_OnWriteDataCallback](capi-native-audiostream-base-h.md#oh_audiorenderer_onwritedatacallback) callback | Callback to be used to write audio data.| 627| void* userData | Pointer to the application data passed through the callback.| 628 629**Returns** 630 631| Type| Description| 632| -- | -- | 633| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**:<br>1. The **builder** parameter is nullptr.<br>2. The **StreamType** parameter is invalid.| 634 635### OH_AudioStreamBuilder_SetRendererWriteDataCallbackAdvanced() 636 637``` 638OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererWriteDataCallbackAdvanced(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnWriteDataCallbackAdvanced callback, void* userData) 639``` 640 641**Description** 642 643Sets the callback used to write audio data. 644 645This function is similar to [OH_AudioStreamBuilder_SetRendererWriteDataCallback](#oh_audiostreambuilder_setrendererwritedatacallback). 646 647If both the functions are used, only the last callback takes effect. 648 649Unlike **OH_AudioStreamBuilder_SetRendererWriteDataCallback**, **OH_AudioStreamBuilder_SetRendererWriteDataCallbackAdvanced** allows an application to pass variable-length audio data and notify the system of the length of the data written. 650 651**Since**: 20 652 653 654**Parameters** 655 656| Name| Description| 657| -- | -- | 658| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 659| [OH_AudioRenderer_OnWriteDataCallbackAdvanced](capi-native-audiostream-base-h.md#oh_audiorenderer_onwritedatacallbackadvanced) callback | Callback to be used to write audio data.| 660| void* userData | Pointer to the application data passed through the callback.| 661 662**Returns** 663 664| Type| Description| 665| -- | -- | 666| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: An input parameter is invalid. For example, the **builder** parameter is nullptr.| 667 668### OH_AudioStreamBuilder_SetRendererInterruptCallback() 669 670``` 671OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInterruptCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnInterruptCallback callback, void* userData) 672``` 673 674**Description** 675 676Sets the callback for interruption events of an audio renderer. 677 678This function is similar to [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback). If both the functions are used, only the last callback takes effect. 679 680**Since**: 20 681 682 683**Parameters** 684 685| Name| Description| 686| -- | -- | 687| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 688| [OH_AudioRenderer_OnInterruptCallback](capi-native-audiorenderer-h.md#oh_audiorenderer_oninterruptcallback) callback | Callback used to receive interruption events.| 689| void* userData | Pointer to the application data struct that will be passed to the callback.| 690 691**Returns** 692 693| Type| Description| 694| -- | -- | 695| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 696 697### OH_AudioStreamBuilder_SetRendererErrorCallback() 698 699``` 700OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererErrorCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnErrorCallback callback, void* userData) 701``` 702 703**Description** 704 705Sets the callback for error events of an audio renderer. 706 707This function is similar to [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback). If both the functions are used, only the last callback takes effect. 708 709**Since**: 20 710 711 712**Parameters** 713 714| Name| Description| 715| -- | -- | 716| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 717| [OH_AudioRenderer_OnErrorCallback](capi-native-audiorenderer-h.md#oh_audiorenderer_onerrorcallback) callback | Callback used to receive error events.| 718| void* userData | Pointer to the application data struct that will be passed to the callback.| 719 720**Returns** 721 722| Type| Description| 723| -- | -- | 724| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 725 726### OH_AudioStreamBuilder_SetCapturerReadDataCallback() 727 728``` 729OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerReadDataCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnReadDataCallback callback, void* userData) 730``` 731 732**Description** 733 734Sets the callback used to read data for an audio capturer. 735 736This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect. 737 738**Since**: 20 739 740 741**Parameters** 742 743| Name| Description| 744| -- | -- | 745| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 746| [OH_AudioCapturer_OnReadDataCallback](capi-native-audiocapturer-h.md#oh_audiocapturer_onreaddatacallback) callback | Callback used to receive data read events.| 747| void* userData | Pointer to the application data struct that will be passed to the callback.| 748 749**Returns** 750 751| Type| Description| 752| -- | -- | 753| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 754 755### OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback() 756 757``` 758OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnDeviceChangeCallback callback, void* userData) 759``` 760 761**Description** 762 763Sets the callback for audio capturer device change events. 764 765This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect. 766 767**Since**: 20 768 769 770**Parameters** 771 772| Name| Description| 773| -- | -- | 774| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 775| [OH_AudioCapturer_OnDeviceChangeCallback](capi-native-audiocapturer-h.md#oh_audiocapturer_ondevicechangecallback) callback | Callback used to receive device change events.| 776| void* userData | Pointer to the application data struct that will be passed to the callback.| 777 778**Returns** 779 780| Type| Description| 781| -- | -- | 782| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 783 784### OH_AudioStreamBuilder_SetCapturerInterruptCallback() 785 786``` 787OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInterruptCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnInterruptCallback callback, void* userData) 788``` 789 790**Description** 791 792Sets the callback for interruption events of an audio capturer. 793 794This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect. 795 796**Since**: 20 797 798 799**Parameters** 800 801| Name| Description| 802| -- | -- | 803| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 804| [OH_AudioCapturer_OnInterruptCallback](capi-native-audiocapturer-h.md#oh_audiocapturer_oninterruptcallback) callback | Callback used to receive interruption events.| 805| void* userData | Pointer to the application data struct that will be passed to the callback.| 806 807**Returns** 808 809| Type| Description| 810| -- | -- | 811| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 812 813### OH_AudioStreamBuilder_SetCapturerErrorCallback() 814 815``` 816OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerErrorCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnErrorCallback callback, void* userData) 817``` 818 819**Description** 820 821Sets the callback for error events of an audio capturer. 822 823This function is similar to [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback). If both the functions are used, only the last callback takes effect. 824 825**Since**: 20 826 827 828**Parameters** 829 830| Name| Description| 831| -- | -- | 832| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 833| [OH_AudioCapturer_OnErrorCallback](capi-native-audiocapturer-h.md#oh_audiocapturer_onerrorcallback) callback | Callback used to receive error events.| 834| void* userData | Pointer to the application data struct that will be passed to the callback.| 835 836**Returns** 837 838| Type| Description| 839| -- | -- | 840| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 841 842### OH_AudioStreamBuilder_SetCapturerWillMuteWhenInterrupted() 843 844``` 845OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerWillMuteWhenInterrupted(OH_AudioStreamBuilder* builder,bool muteWhenInterrupted) 846``` 847 848**Description** 849 850Sets whether to mute the audio input stream when an audio interruption occurs. 851 852**Since**: 20 853 854 855**Parameters** 856 857| Name| Description| 858| -- | -- | 859| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 860| bool muteWhenInterrupted | Whether to mute the audio stream when an audio interruption occurs. The value **true** means to mute the stream.| 861 862**Returns** 863 864| Type| Description| 865| -- | -- | 866| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 867 868### OH_AudioStreamBuilder_SetRendererFastStatusChangeCallback() 869 870``` 871OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererFastStatusChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioRenderer_OnFastStatusChange callback, void* userData) 872``` 873 874**Description** 875 876Sets a callback for low-latency status changes during audio playback. 877 878**Since**: 20 879 880 881**Parameters** 882 883| Name| Description| 884| -- | -- | 885| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 886| [OH_AudioRenderer_OnFastStatusChange](capi-native-audiorenderer-h.md#oh_audiorenderer_onfaststatuschange) callback | Callback invoked for low-latency status changes during audio playback.| 887| void* userData | Pointer to the application data struct that will be passed to the callback.| 888 889**Returns** 890 891| Type| Description| 892| -- | -- | 893| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 894 895### OH_AudioStreamBuilder_SetCapturerFastStatusChangeCallback() 896 897``` 898OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerFastStatusChangeCallback(OH_AudioStreamBuilder* builder,OH_AudioCapturer_OnFastStatusChange callback, void* userData) 899``` 900 901**Description** 902 903Sets a callback for low-latency status changes during audio recording. 904 905**Since**: 20 906 907 908**Parameters** 909 910| Name| Description| 911| -- | -- | 912| [OH_AudioStreamBuilder](capi-ohaudio-oh-audiostreambuilderstruct.md)* builder | Pointer to an audio stream builder instance, which is created by calling [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create).| 913| [OH_AudioCapturer_OnFastStatusChange](capi-native-audiocapturer-h.md#oh_audiocapturer_onfaststatuschange) callback | Callback invoked for low-latency status changes during audio recording.| 914| void* userData | Pointer to the application data struct that will be passed to the callback.| 915 916**Returns** 917 918| Type| Description| 919| -- | -- | 920| [OH_AudioStream_Result](capi-native-audiostream-base-h.md#oh_audiostream_result) | **AUDIOSTREAM_SUCCESS**: The function is executed successfully.<br>**AUDIOSTREAM_ERROR_INVALID_PARAM**: A parameter is invalid. For example, the **builder** parameter is nullptr.| 921