In the following situations, it is recommended to use the custom audio capture function:
When developers have their own rendering requirements, such as special applications or processing and rendering of the original PCM data that are pulled, it is recommended to use the custom audio rendering function of the SDK.
Audio capturing and rendering can be divided into three scenarios:
Developers should choose the appropriate audio capturing and rendering method based on their own business scenarios.
Before custom audio capture and rendering, please make sure:
// Set the audio source to custom capture and render
ZegoCustomAudioConfig *audioConfig = [[ZegoCustomAudioConfig alloc] init];
audioConfig.sourceType = ZegoAudioSourceTypeCustom;
[[ZegoExpressEngine sharedEngine] enableCustomAudioIO:YES config:audioConfig];
After publishing or playing a stream, turn on the audio capture device and pass the collected audio data to the engine through sendCustomAudioCaptureAACData or sendCustomAudioCapturePCMData.
Use fetchCustomAudioRenderPCMData to get the data to be rendered from the engine, and then use the rendering device to play the audio data.
When is the time to call related interfaces of custom audio capture and rendering?
The call timing of each interface is as follows:
How often do you call related interfaces for custom audio capture and rendering?
The best way is to drive according to the clock of the physical audio device, call sendCustomAudioCaptureAACData and sendCustomAudioCapturePCMData when the physical capture device collects data; call fetchCustomAudioRenderPCMData when the physical rendering device needs data.
If the developer does not have a specific physical device to drive in the actual scenario, it is recommended to call the above interface every 10 ms ~ 20 ms.
When calling fetchCustomAudioRenderPCMData, if the internal data of the SDK is insufficient for "dataLength", how will the SDK handle it?
Under the condition that the "param" is filled in normally, when the data inside the SDK is insufficient for "dataLength", the insufficient remaining length will be filled in according to the mute data.