【问题标题】:How to detect other VOIP call (iOS)?如何检测其他 VOIP 通话(iOS)?
【发布时间】:2017-10-19 10:14:52
【问题描述】:

我正在开发一个应用程序,该应用程序允许使用在 iOS 上利用 webRTC 的 SDK 进行视频通话。

预期的功能是,如果在我的应用程序实例化呼叫之后实例化另一个呼叫,我希望我的应用程序在我的呼叫中双向静音,直到该呼叫结束,在这种情况下恢复音频。

我遇到了一个问题,我想检测其他拨打 VOIP 电话的电话(例如微信和 Facebook Messenger)。

在微信的情况下,我已经解决了这个漏洞,它会中断共享音频会话(AVAudioSession)。处理这个的代码如下:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector
     (audioSessionInterrupted:)
... 

name:AVAudioSessionInterruptionNotification object:nil];
- (void) audioSessionInterrupted:(NSNotification*)notification
{
    if(notification.name == AVAudioSessionInterruptionNotification)
    {
        NSDictionary* userInfo = notification.userInfo;
        int result = userInfo[AVAudioSessionInterruptionTypeKey];
        if(result == AVAudioSessionInterruptionTypeBegan)
        {
            [[AVAudioSession sharedInstance] setActive:NO error:nil];
            [self setAudioEnabled:NO];
        }
        else if (result == AVAudioSessionInterruptionTypeEnded)
        {
            [[AVAudioSession sharedInstance] setActive:YES error:nil];
            [self setAudioEnabled:YES];

        }
    }
}

但是,对于 Facebook Messenger,从不调用此方法。我由此推测,微信可能要求独占访问共享音频会话(从而导致与我的应用程序的音频会话中断),而 Facebook Messenger 选择混合其音频,或者在实例化呼叫时使用单独的音频会话.

我的问题是是否存在另一种检测其他 VOIP 呼叫的方法,可能使用 CallKit 框架?我的应用程序使用 CallKit 来提示用户来电,并在 iOS 电话日志中记录来电/去电。

【问题讨论】:

    标签: ios objective-c webrtc voip callkit


    【解决方案1】:

    我建议检查所有当前的本地调用。通过 CallKit 注册的所有调用也被视为本机调用,并从 CoreTelephony 触发对此对象的调用:

    CTCallCenter *callCenter = [[CTCallCenter alloc] init];
    callCenter.callEventHandler = ^(CTCall* call) {
        //Native call changes are triggered here
    };
    

    对于检测来自不支持 CallKit 的应用程序的 VOIP 呼叫,这更难。一种可能是监听 AVAudioUnit 的变化。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-28
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多