Summary
PlatformAudio currently hard-codes the iOS audio session options in LiveKit_ConfigureAudioSessionForVoIP(). Apps that play background audio (music, ambient sound) have no way to opt into ducking or mixing — the session silences all other audio as soon as LiveKit starts.
Proposed API
Add an AudioSessionOptions parameter to the PlatformAudio constructor (or a static configure method) that lets callers supply additional AVAudioSessionCategoryOptions flags before the WebRTC ADM initializes:
// C# API change (example)
public PlatformAudio(AudioSessionOptions options = AudioSessionOptions.Default)
public enum AudioSessionOptions
{
Default = 0,
DuckOthers = 1, // Lower volume of other audio sessions (background audio continues quietly)
MixWithOthers = 2 // Full-volume mix with other audio sessions
}
On the native side, LiveKit_ConfigureAudioSessionForVoIP (or a new LiveKit_ConfigureAudioSessionForVoIPWithOptions(int options)) would pass through the caller's flags:
// Objective-C (LiveKitAudioSession.mm)
void LiveKit_ConfigureAudioSessionForVoIPWithOptions(int additionalOptions) {
AVAudioSessionCategoryOptions opts =
AVAudioSessionCategoryOptionDefaultToSpeaker |
AVAudioSessionCategoryOptionAllowBluetooth |
AVAudioSessionCategoryOptionAllowBluetoothA2DP;
if (additionalOptions & kDuckOthers) opts |= AVAudioSessionCategoryOptionDuckOthers;
if (additionalOptions & kMixWithOthers) opts |= AVAudioSessionCategoryOptionMixWithOthers;
[session setCategory:AVAudioSessionCategoryPlayAndRecord
mode:AVAudioSessionModeVoiceChat
options:opts
error:&error];
...
}
Use case
Apps that play background audio alongside a LiveKit conversation need DuckOthers so the background track continues at reduced volume instead of being silenced entirely. The hard-coded session config makes this impossible without forking the package.
Android equivalent
A similar opt-in for AudioManager.setStreamVolume/AudioFocusRequest ducking behavior would be valuable for Android parity.
Summary
PlatformAudio currently hard-codes the iOS audio session options in LiveKit_ConfigureAudioSessionForVoIP(). Apps that play background audio (music, ambient sound) have no way to opt into ducking or mixing — the session silences all other audio as soon as LiveKit starts.
Proposed API
Add an AudioSessionOptions parameter to the PlatformAudio constructor (or a static configure method) that lets callers supply additional AVAudioSessionCategoryOptions flags before the WebRTC ADM initializes:
// C# API change (example)
public PlatformAudio(AudioSessionOptions options = AudioSessionOptions.Default)
public enum AudioSessionOptions
{
Default = 0,
DuckOthers = 1, // Lower volume of other audio sessions (background audio continues quietly)
MixWithOthers = 2 // Full-volume mix with other audio sessions
}
On the native side, LiveKit_ConfigureAudioSessionForVoIP (or a new LiveKit_ConfigureAudioSessionForVoIPWithOptions(int options)) would pass through the caller's flags:
// Objective-C (LiveKitAudioSession.mm)
void LiveKit_ConfigureAudioSessionForVoIPWithOptions(int additionalOptions) {
AVAudioSessionCategoryOptions opts =
AVAudioSessionCategoryOptionDefaultToSpeaker |
AVAudioSessionCategoryOptionAllowBluetooth |
AVAudioSessionCategoryOptionAllowBluetoothA2DP;
}
Use case
Apps that play background audio alongside a LiveKit conversation need DuckOthers so the background track continues at reduced volume instead of being silenced entirely. The hard-coded session config makes this impossible without forking the package.
Android equivalent
A similar opt-in for AudioManager.setStreamVolume/AudioFocusRequest ducking behavior would be valuable for Android parity.