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.

2
  • 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 4, 2014 at 9: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 4, 2014 at 9:45

3 Answers 3

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

1
  • In my case, I had to wait for about 2 seconds before I could set audio session to active state after interruption has ended. Jun 19, 2015 at 8:37
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

0
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.