会议再开始时,会重置音频配置
AudioReceiveStream::Start()
AudioState::AddReceivingStream(webrtc::AudioReceiveStream* stream)
AudioDeviceModuleIOS::InitPlayout()
AudioDeviceIOS::InitPlayout()
AudioDeviceIOS::InitPlayOrRecord()
准备播放或记录,如果音频会话可以配置,然后初始化音频单元。
AudioDeviceIOS::ConfigureAudioSession()
(instancetype)sharedInstance
(instancetype)init //webrtc\src\sdk\objc\components\audio\RTCAudioSessionConfiguration.m
(instancetype)initWithAudioSession:(id)audioSession
(void)handleRouteChangeNotification:(NSNotification *)notification
handleRouteChangeNotification监听音频输入输出路由变化
configureWebRTCSession
setConfiguration //这边配置音频会话
配置参数是固定的
Category AVAudioSessionCategoryPlayAndRecord
mode AVAudioSessionModeVoiceChat
Options AVAudioSessionCategoryOptionAllowBluetooth
AVAudioSessionModeVoiceChat 会隐式采用outport为Receiver(AVAudioSessionPortBuiltInReceiver)
AVAudioSessionCategoryOptionDefaultToSpeaker 当使用此选项,没有其他音频路由(如耳机)是可用的,会话音频将播放通过该设备的内置扬声器。当不使用此选项,并且没有其他的音频输出是可用或选择,音频将播放通过听筒输出
思路:
1.修改webrtc内默认配置,将options配置为AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker
(instancetype)init //webrtc\src\sdk\objc\components\audio\RTCAudioSessionConfiguration.m 该处修改默认配置
_categoryOptions = AVAudioSessionCategoryOptionAllowBluetooth;改为
_categoryOptions = AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker;
2.在webrtc外重新配置options,添加默认输出至扬声器的代码