Audio Mixer

startLocalAudioMixer

Starts local audio mixing.

public abstract int startLocalAudioMixer(LocalAudioMixerConfiguration config);
This method supports merging multiple audio streams locally into one. For example, you can mix the audio captured by the local microphone, media player, sound card, and remote users into one audio stream and publish it to the channel.
  • To mix locally captured audio streams, set publishMixedAudioTrack to true in ChannelMediaOptions, and then publish the mixed audio stream to the channel.
  • To mix remote audio streams, ensure the remote audio streams are already published in the channel and that you have subscribed to the audio streams to be mixed.
Note: To ensure audio quality, it is recommended to mix no 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
Configuration parameters for local audio mixing. See LocalAudioMixerConfiguration.

Return Values

  • 0: Success.
  • < 0: Failure.
    • -7: The RtcEngine object has not been initialized. Please initialize the RtcEngine object before calling this method.

stopLocalAudioMixer

Stops local audio mixing.

public abstract int stopLocalAudioMixer();

After calling startLocalAudioMixer, you can call this method to stop audio mixing.

Timing

Call this method after calling startLocalAudioMixer.

Return Values

  • 0: Success.
  • < 0: Failure.
    • -7: The RtcEngine object has not been initialized. You need to initialize the RtcEngine object before calling this method.

updateLocalAudioMixerConfiguration

Updates local audio mixing configuration.

public abstract int updateLocalAudioMixerConfiguration(LocalAudioMixerConfiguration config);
Note: To ensure audio quality, it is recommended to mix no more than 10 audio streams.

Timing

Call this method after calling startLocalAudioMixer.

Parameters

config
Configuration for local audio mixing. See LocalAudioMixerConfiguration.

Return Values

  • 0: Success.
  • < 0: Failure.
    • -7: The RtcEngine object has not been initialized. Please initialize the RtcEngine object before calling this method.