3

I am using PJSIP (with the help of PJSUA) to implement some VoIP functionality in my app. 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. 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. 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.). I would really appreciate any possible info or maybe something I'm missing. Thank you all in advance.

Mepla
  • 438
  • 4
  • 16
  • with hold & reinvite you mean... do you keep the socket open and just pause your media? OR do you really reopen the socket? – Daij-Djan May 04 '14 at 09:17
  • 1
    @Daij-Djan: Well Im using PJSUA which gives me 2 methods `pjsua_call_set_hold(pjsua_call_id call_id, const pjsua_msg_data *msg_data);` and `pjsua_call_reinvite(pjsua_call_id call_id, unsigned options, const pjsua_msg_data *msg_data);` – Mepla May 04 '14 at 09:45
  • dont know pjsua - sorry – Daij-Djan May 04 '14 at 09:48
  • @Daij-Djan: Thanks for your response anyways. ;) – Mepla May 04 '14 at 09:51
  • @Mepla how you solved this issue, for me also same issue currently facing, any solution did you found, if so please let me know, thanks! – Anilkumar iOS - ReactNative Jun 26 '15 at 07:13
  • @Mepla : Please help : How you are showing VOIP incoming call notification when app is in background (http://stackoverflow.com/questions/41845576/ios-10-how-to-show-incoming-voip-call-notification-when-app-is-in-background?noredirect=1#comment71090798_41845576) – Abhishek Thapliyal Jan 31 '17 at 11:40

3 Answers3

8

As this wiki:

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. 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. If not then use the following to receive interruptions:

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

  • forcefully shutdown the sound device when interruption begins. Use pjsua_set_no_snd_dev() for pjsua, or AudDevManager.setNoDev() for 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

The parameters needed to send to pjsua_set_snd_dev() can be extracted using the method pjsua_get_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

paresh
  • 1,174
  • 9
  • 13
  • Thank you very much, That is actually what solved my problem at the time, but due to high load of work, I wasn't able to add it here as an answer, once again thank you for your reply, I hope other people using PJSIP could benefit from it. – Mepla Sep 13 '14 at 05:32
  • In my case, I had to wait for about 2 seconds before I could set audio session to active state after interruption has ended. – Sihad Begovic Jun 19 '15 at 08:37
  • how to implement this, i dint understand, could you please give more info about this, currently i am facing this interruption. thanks! – Anilkumar iOS - ReactNative Jun 25 '15 at 08:54
0

I did same as in whenever application in inActive - I call set hold and 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)

here is the problem ,that how to use pjsua_get_snd_dev(int *capture_dev, int *playback_dev) function.

I get the error that possible re-registering same thread

Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
sambhav
  • 39
  • 4
0

For Android developers: we say, you have ongoing SIP call and you receive GSM call. 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. Before you hold the call you should close audio with AudDevManager.setNoDev(). When you are ready to send a SIP re-invite, you should then call AudDevManager.setPlaybackDev() and then AudDevManager.setCaptureDev(). That should solve the audio problem.