5

I want to handle ip change form wifi to 4g and back during an ongoing call using pjsip on ios.
I have followed all the steps form pjsip website: https://trac.pjsip.org/repos/wiki/IPAddressChange and here I have found that the call is disconnected after the pjsua_acc_set_registration(the_acc_id, PJ_FALSE); is sent. Also I don't figure it out how to send the re registration at point 4.

"And finally, once unregistration in 2b) above is complete, re-register (with TCP)."

Any advice, suggestion, link to any resource that will hell me solve the issue is well come.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Alex Terente
  • 12,006
  • 5
  • 51
  • 71

3 Answers3

1

The most simple and reliable way is described in your reference:

The most straightforward solution is of course to restart everything, which means in pjsua terms to call pjsua_destroy() and followed by pjsua_create(), pjsua_init(), and so on.

To detect 4G/WiFi changes, you should use Apple Reachability API, great wrappers are AFNetworkReachabilityManager and Reachability by Tony Million. I used this approach in my own project and it worked flawlessly.

Maxim Pavlov
  • 2,962
  • 1
  • 23
  • 33
  • Thx Maxim, but if you do this and you have an ongoing call the call will be dropped. I have manage to update the transport on IP change in an ongoing call, I will add here how I have implemented when I will find some more time. – Alex Terente Oct 18 '16 at 07:51
  • Call dropping was not a big issue in my case, would be interesting to see your solution to this problem :) – Maxim Pavlov Oct 18 '16 at 08:34
  • Hey what was your solution to this in the end? I am facing the same issue – Florensvb Jun 01 '17 at 11:23
  • @MaximPavlov, when you do it the call drops and the client actually dials to the other side once again? It actually rings on the other side? Or does the call connect automatically? – Michael Kessler Feb 24 '19 at 18:14
  • @MichaelKessler in my case it was simple: there was a conference call on the Freeswitch server and if any participant dropped for some reason, it just needed to call the server once again. I understand that in case of p2p calls things become more complicated. – Maxim Pavlov Mar 05 '19 at 11:28
1

Starting from Version 2.7 there is second approach there:

Approach 2: Selective update

Alternatively there may be a way to allow the stack to continue to run, updating the address information when necessary. This approach will require some specific features to be used, as well as some actions by the application when it detects that the IP address has changed.

The specific configuration and tasks will be explained below. Note we assume that the SIP and media sockets are bound to INADDR_ANY (0.0.0.0) and not to a specific interface IP address (this is the default behavior).

Update for 2.7 or above: application can apply this selective update approach with much simpler way, please check ticket #2041.

birdy
  • 943
  • 13
  • 25
1

In Order to get Internet/IP changes, You can use Apple Reachability API or you can use Reachability by Tony. In Reachability change observer you can compare previous IP address family and current IP address family.

If both are from same family e.g last and new belongs to same ip family IPV4 or IPV6 than

  1. Get the current call info.
  2. Use pjsip method pjsua_call_reinvite() and use the flag PJSUA_CALL_UPDATE_CONTACT.

If both are from different family e.g last belongs to IPV4 and new belongs to IPV6 or vice versa than use below steps.

  1. Send Registration request
  2. Get the current call info.
  3. Use pjsip method pjsua_call_reinvite() and use the flag PJSUA_CALL_UPDATE_CONTACT.