Audio Mixer
startLocalAudioMixer
Starts local audio mixing.
virtual int startLocalAudioMixer(const LocalAudioMixerConfiguration& config) = 0;
This method supports merging multiple audio streams locally into one audio stream, such as combining audio from the local microphone, media player, sound card, and remote users into one stream and publishing it to the channel.
- If you want to mix locally captured audio streams, set
publishMixedAudioTrackto true in ChannelMediaOptions, and then publish the mixed audio stream to the channel. - If you want to mix remote audio streams, ensure that the remote audio streams have been published in the channel and that you have subscribed to the streams to be mixed.
Note: To ensure audio quality, it is recommended not to mix more than 10 audio streams.
Scenario
You can enable this feature in the following scenarios:
- When using local video mixing, you can simultaneously capture and publish the audio stream associated with the mixed video stream.
- In live streaming scenarios, users can receive audio streams in the channel, mix multiple audio streams locally, and forward the mixed stream to other channels.
- In online classrooms, teachers can mix the audio from interactions with students locally and forward it to other channels.
Timing
You can call this method before or after joining a channel.
Parameters
- config
- The configuration parameters for local audio mixing. See LocalAudioMixerConfiguration.
Return Values
- 0: Success.
- < 0: Failure.
- -7: The IRtcEngine object has not been initialized. Please initialize the IRtcEngine object before calling this method.
stopLocalAudioMixer
Stops local audio mixing.
virtual int stopLocalAudioMixer() = 0;
After calling startLocalAudioMixer, you can call this method to stop local audio mixing.
Timing
Call this method after calling startLocalAudioMixer.
Return Values
- 0: Success.
- < 0: Failure.
- -7: The IRtcEngine object is not initialized. Please initialize the IRtcEngine object before calling this method.
updateLocalAudioMixerConfiguration
Updates the local audio mixing configuration.
virtual int updateLocalAudioMixerConfiguration(const LocalAudioMixerConfiguration& config) = 0;
After calling startLocalAudioMixer, if you need to update the local audio mixing configuration, you can call this method.
Note: To ensure audio quality, it is recommended not to mix more than 10 audio streams.
Timing
Call this method after calling startLocalAudioMixer.
Parameters
- config
- Local audio mixing configuration. See LocalAudioMixerConfiguration.
Return Values
- 0: Success.
- < 0: Failure.
- -7: The IRtcEngine object has not been initialized. Please initialize the IRtcEngine object before calling this method.