I am developing a VoIP app that uses WebRTC inside a WKWebView.
Question 1: How can I monitor which audio output device WebRTC is currently using? I want to display this information in the UI for the user .
Question 2: How can I change the current audio output device for WebRTC?
I am using a JS Bridge to Objective-C code, attempting to change the audio device with the following code:
void set_speaker(int n)
{
session = [AVAudioSession sharedInstance];
NSError *err = nil;
if (n == 1) {
[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err];
} else {
[session overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&err];
}
}
However, this approach does not work.
I am testing on an iPhone with iOS 16.7. Is a higher iOS version required?