简体   繁体   English

传入的蜂窝呼叫在我的iOS应用程序中中断VoIP呼叫

[英]Incoming cellular call interrupting a VoIP call in my iOS App

I am using PJSIP (with the help of PJSUA) to implement some VoIP functionality in my app. 我正在使用PJSIP(在PJSUA的帮助下)在我的应用程序中实现一些VoIP功能。 When a VoIP call in my app is in progress, I can easily hold the call and then unhold it with no problems at all, everything is fine. 当我的应用程序中的VoIP呼叫正在进行中时,我可以轻松地保持呼叫,然后完全没有问题,一切都很好。 I have used CoreTelephony to identify an incoming cellular (normal) call, when a call comes I hold my VoIP call in applicationWillResignActive and when that ends I unhold (reinvite) my VoIP call in applicationDidBecomeActive . 我已经使用CoreTelephony识别的话蜂窝(正常)调用,当有电话打进来我认为我的VoIP呼叫在applicationWillResignActive和时结束我取消保留(重新邀请)在我的VoIP呼叫applicationDidBecomeActive Everything seems to be working fine (Since I have logs almost everywhere) but my call after coming back from cellular call has no longer any media transmitting, so the call is going on but I can hear no sound on any end. 一切似乎工作正常(因为我几乎到处都有日志)但是从蜂窝电话回来后我的电话已经不再有任何媒体传输,所以电话正在进行,但我听不到任何声音。 After 30 seconds I get disconnected (I configured a 30 seconds timeout for not having a media on my server which gets called here.). 30秒后我断开连接(我配置了30秒超时,因为我的服务器上没有媒体,这里会调用它。)。 I would really appreciate any possible info or maybe something I'm missing. 我真的很感激任何可能的信息或者我可能缺少的东西。 Thank you all in advance. 谢谢大家。

As this wiki: 作为这个维基:

http://trac.pjsip.org/repos/wiki/Getting-Started/iPhone?format=pdf http://trac.pjsip.org/repos/wiki/Getting-Started/iPhone?format=pdf

of pjsip explains, with iOS7 onwards pjsua is using high level APIs of AVAudioSession to manage opening and closing of sound streams which doesn't allow the older methods of (automatically) reconnecting your media streams after GSM call (or any other sound) interruptions. pjsip解释说,iOS7以后pjsua正在使用AVAudioSession的高级API来管理声音流的打开和关闭,这不允许在GSM呼叫(或任何其他声音)中断之后(自动)重新连接媒体流的旧方法。 So to make it work you need to do following: 为了使其工作,您需要执行以下操作:

  • Your application should be configured to receive interruption events, which will already be the case if you are using sound or VOIP as your UIBackgroundModes. 您的应用程序应配置为接收中断事件,如果您使用声音或VOIP作为UIBackgroundModes,则已经是这种情况。 If not then use the following to receive interruptions: 如果没有,请使用以下内容接收中断:

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

  • forcefully shutdown the sound device when interruption begins. 在中断开始时强制关闭声音设备。 Use pjsua_set_no_snd_dev() for pjsua, or AudDevManager.setNoDev() for pjsua2 使用pjsua_set_no_snd_dev()用于pjsua,或AudDevManager.setNoDev()用于pjsua2

  • When interruption ends set your AVAudioSession to active and then restart the sound device using pjsua_set_snd_dev() for pjsua, or AudDevManager.setPlaybackDev()+setCaptureDev() for pjsua2 中断结束时将AVAudioSession设置为活动状态,然后使用pjsua_set_snd_dev()为pjsua重启声音设备,或者为pjsua2使用AudDevManager.setPlaybackDev()+setCaptureDev()

The parameters needed to send to pjsua_set_snd_dev() can be extracted using the method pjsua_get_snd_dev() . 可以使用方法pjsua_get_snd_dev()提取发送到pjsua_set_snd_dev()所需的参数。

One thing to keep in mind here is that once you shutdown the device forcefully it will not start automatically (even if a new call starts) unless you call pjsua_set_snd_dev() to restart it again 这里要记住的一件事是,一旦你强行关闭设备它就不会自动启动(即使新的呼叫开始),除非你再次调用pjsua_set_snd_dev()重新启动它

I did same as in whenever application in inActive - I call set hold and pjsua_set_no_snd_dev 我和inActive中的应用程序一样 - 我调用set hold和pjsua_set_no_snd_dev

I guess that works fine. 我想这样可行。

But when application become active again, I call re-invite and pjsua_set_snd_dev(0,0) 但是当应用程序再次变为活动状态时,我会调用re-invite和pjsua_set_snd_dev(0,0)

here is the problem ,that how to use pjsua_get_snd_dev(int *capture_dev, int *playback_dev) function. 这是问题所在,即如何使用pjsua_get_snd_dev(int * capture_dev,int * playback_dev)函数。

I get the error that possible re-registering same thread 我得到可能重新注册相同线程的错误

For Android developers: we say, you have ongoing SIP call and you receive GSM call. 对于Android开发者:我们说,您正在进行SIP呼叫并且您接收GSM呼叫。 You have to create your own receiver which is going to listen for phone call states. 你必须创建自己的接收器,它将听取电话呼叫状态。 One should hold SIP call on incoming GSM and send SIP re-invite on disconnection. 一个人应该在接收的GSM上保持SIP呼叫并在断开连接时发送SIP重新邀请。 Before you hold the call you should close audio with AudDevManager.setNoDev() . 在您保持呼叫之前,您应该使用AudDevManager.setNoDev()关闭音频。 When you are ready to send a SIP re-invite, you should then call AudDevManager.setPlaybackDev() and then AudDevManager.setCaptureDev() . 当您准备发送SIP重新邀请时,您应该调用AudDevManager.setPlaybackDev() ,然后AudDevManager.setCaptureDev() That should solve the audio problem. 这应该解决音频问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM