静音麦克风 voip

Mute microphone voip

我将 twilio SDK 用于 voip,我想将 "my" 麦克风静音并在按下按钮时将其静音。

这一点我试过了:

 [[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
                                             error:nil];

[[AVAudioSession sharedInstance] setActive:NO error:nil];

他们两个我都得到了这个错误

Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.

并且由于错误,我无法重新启动音频会话/"stream":

 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
    [[AVAudioSession sharedInstance] setActive:YES error:nil];

有什么线索吗?

要静音 "yourself",您可以直接在您的连接中使用静音 属性。 twilio SDK 会完成剩下的工作。

//the mute stated can be applied if the state is not TCConnectionStateConnected
        if(self.connection.state == TCConnectionStateConnected){
            self.connection.muted = !self.connection.isMuted;
        }