-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Feature request
Hi, hope you guys are having a great week. We are using react-native-daily-js for our excercise app. Which has a feature to always keep music playing in background, even when people are talking. But iOS dims the music so much that it almost fades out, especially when multiple people are talking. We achieved no ducking on most devices by forcing AV AudioSession mode to VideoRecording which does not duck music by patching the react native webrtc to always use VideoRecording AV mode.
But it still ducks sometimes on iPhone 13. And by monitoring logs we can confirm that AV audio mode is not reset back to voiceChat or videoChat apart from one exception, when we connect a bluetooth device then AV mode is reset to voiceChat. Probably webRTC is changing it internally. Any recommendations to make this more stable and overcome bluetooth case will be helpful for us. As our app is mature and we cannot switch video call sdk at this point. Thank you!
Here is the patch we applied:
diff --git a/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+Daily.m b/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+Daily.m
index 5cd10e9..b59e238 100644
--- a/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+Daily.m
+++ b/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+Daily.m
@@ -154,17 +154,15 @@ - (void)applyAudioMode:(NSString *)audioMode toSession:(RTCAudioSession *)audioS
return;
}
- // Ducking other apps' audio implicitly enables allowing mixing audio with
- // other apps, which allows this app to stay alive in the backgrounnd during
- // a call (assuming it has the voip background mode set).
- // Always use mixWithOthers with playAndRecord category and default mode
- // This prevents audio ducking and allows music mixing during calls
AVAudioSessionCategoryOptions categoryOptions = (AVAudioSessionCategoryOptionAllowBluetooth |
AVAudioSessionCategoryOptionMixWithOthers);
if ([audioMode isEqualToString:AUDIO_MODE_VIDEO_CALL]) {
categoryOptions |= AVAudioSessionCategoryOptionDefaultToSpeaker;
}
- NSString *mode = ([audioMode isEqualToString:AUDIO_MODE_VIDEO_CALL] ?
-
AVAudioSessionModeVideoChat : -
AVAudioSessionModeVoiceChat);
- // Always use default mode instead of videoChat/voiceChat to prevent audio ducking
- NSString *mode = AVAudioSessionModeVideoRecording;
[self configureAudioSession:AVAudioSession.sharedInstance audioMode:mode categoryOptions:categoryOptions];
}
diff --git a/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+DailyDevicesManager.m b/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+DailyDevicesManager.m
index 07abec1..efb9cc2 100644
--- a/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+DailyDevicesManager.m
+++ b/node_modules/@daily-co/react-native-webrtc/ios/RCTWebRTC/WebRTCModule+DailyDevicesManager.m
@@ -183,7 +183,7 @@ - (BOOL)isBuiltInMic:(NSString*)portType {
// we are not able to see the bluetooth devices on the list
AVAudioSessionCategoryOptions categoryOptions = (AVAudioSessionCategoryOptionAllowBluetooth |
AVAudioSessionCategoryOptionMixWithOthers);
- NSString *mode = AVAudioSessionModeVoiceChat;
-
NSString *mode = AVAudioSessionModeVideoRecording;
// Earpiece: is default route for a call.
// Speaker: the speaker is the default output audio for like music, video, ring tone.
@@ -193,7 +193,7 @@ - (BOOL)isBuiltInMic:(NSString*)portType {
if([SPEAKERPHONE_DEVICE_ID isEqualToString: deviceId]){
NSLog(@"[Daily] configuring output to SPEAKER");
categoryOptions |= AVAudioSessionCategoryOptionDefaultToSpeaker;
-
mode = AVAudioSessionModeVideoChat;
-
mode = AVAudioSessionModeVideoRecording;}
AVAudioSession *audioSession = AVAudioSession.sharedInstance;