Sip.js: Mobile Support

Created on 5 Jun 2014  ·  26Comments  ·  Source: onsip/SIP.js

This is a general issue for discussing mobile support for SIP.js. See https://github.com/alongubkin/phonertc/issues/7

enhancement question

Most helpful comment

I also ended up writing a custom SDH to carefully interface SIP.[email protected] with the provided cordova/iOS WebRTC implementation. It allowed my to solve an issue where cordova was complaining about the argument to RTCPeerConnection.setLocalDescription() & setRemoteDescription().

And have made it available as a publicly accessible npm library:
https://github.com/WesUnwin/cordova-ios-session-description-handler

This may also be a useful example of how to write custom SDHs (in addition to the default SDH inside the SIP.js library which I also found to be a useful starting point). Hope this helps anyone!

All 26 comments

Thanks for opening this Joseph. The use case is a cross platform app (Web, iOS, Android) that supports SIP calling. I've been working on a Phonegap plugin for PJSip, but its adding an extra layer of complexity that could be removed if we could get WebRTC working on iOS & Android.

Do you think something like PhoneRTC is worth pursuing for this use case?

Take a look here at my response here: https://github.com/alongubkin/phonertc/issues/7

I do not think that PhoneRTC in it's current state would work with SIP.js. What it does provide though is a good starting point at where mobile development is at.

For iOS I was able to recompile the WebRTC libraries (with SSL) and now I am working on creating an Obj-C layer to expose the needed WebRTC functions to SIP.js. My goal here would be to get SIP.js and iOS to be able to make WebRTC audio calls.

Once the audio functionality is solid, then I would begin working on adding video. My idea for video is to have a function that takes the id of an element on the page and pass that to Obj-C. Then have the native code find that element on the page and place a native video element over it. I think would probably create the best user experience. I am still open to other ideas on how to handle the video.

@lylepratt, I just wanted to mention that although iOS support is in the works, you can have Android support simply by visiting the app website. Take a look at the SIP.js Demo Phone for a basic example. If you'd really like to have an Android app, you can use Crosswalk to bundle your web app together with a WebRTC-enabled WebView.

@lylepratt, Here's a basic tutorial for using Crosswalk with SIP.js, if you're interested in that.

If you'd like to integrate Cordova plugins into your app, you can use Crosswalk Cordova to bring WebRTC functionality to Android apps generated by Cordova. After starting with Crosswalk Cordova's HelloWorld template, I was able to build the SIP.js Demo Phone app by replacing the assets/www directory with the demo phone assets and adding the following permissions to the AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

Thanks for the info Joseph. Unfortunately we can only pursue something that
works on iOS as well.

Based on these discussions, It looks like we're going to have to continue
with a PJSip plugin in order to do that in a reasonable amount of time.

Maybe we can make the plugin conform to the SIP.js API.
On Jun 11, 2014 2:26 PM, "Joseph Frazier" [email protected] wrote:

@lylepratt https://github.com/lylepratt, Here's a basic tutorial
http://sipjs.com/guides/mobile/android-native/ for using Crosswalk with
SIP.js, if you're interested in that.

If you'd like to integrate Cordova plugins into your app, you can use Crosswalk
Cordova https://crosswalk-project.org/#documentation/cordova to bring
WebRTC functionality to Android apps generated by Cordova. After starting
with Crosswalk Cordova's HelloWorld template
https://crosswalk-project.org/#documentation/cordova/develop_an_application,
I was able to build the SIP.js Demo Phone http://sipjs.com/demo-phone/
app by replacing the assets/www directory with the demo phone assets
https://github.com/onsip/sipjs-examples/tree/6d260bfd8e3e1655a881ad1cad446ed2672d6611/demo-phone
and adding the following permissions to the AndroidManifest.xml:




Reply to this email directly or view it on GitHub
https://github.com/onsip/SIP.js/issues/31#issuecomment-45802303.

I think I have a good sense of what needs to be done for SIP.js to use the PhoneRTC plugin for handling audio calls on iOS, so I'm planning to start working on a proof-of-concept tonight, as I'm personally interested in demonstrating this use case.

The general idea is to that iOS apps that use SIP.js would not use the default SIP.WebRTC.MediaHandler (that depends on JS having direct access to the PeerConnection, which we've seen isn't yet particularly feasible on iOS), but would provide a custom MediaHandler whose methods call into the PhoneRTC plugin.

We'd love for you to consider using SIP.js for your app, so I'll be sure to keep you posted on how my experiment goes.

@joseph-onsip, per our discussion it was my understanding that the changes you were making are javascript application level changes. The custom media handler should be compatible with any platform implementing the phoneRTC api, and is not limited to iOS.

Thats great news. I would love to experiment with your POC this weekend if you make any progress.

Alright, I have made a bit of progress. Here's an app that can make calls to a WebRTC-enabled SIP endpoint running in a desktop browser (I tested with the SIP.js Demo Phone in Chrome).

Currently, it only works on Android, because that's what I'm developing against and I had to make a small change to the phonertc plugin. If the same change is made to the iOS plugin code, I'd expect this app to work on that platform as well, barring any platform-specific differences in WebRTC implementation.

Wow. From looking at your code, getting it to work seemed fairly simple. You just overrode mediaHandlerFactory with PhoneRTCMediaHandler (along with your change to the PhoneRTC Plugin) and it "just worked"?

Edit: At first I thought that the PhoneRTCMediaHandler was included in PhoneRTC, but I now realize that you wrote that and this all makes much more sense.

it "just worked"?

Well, I've only been able to get audio flowing between Android and Chrome (and, at the moment, only to Chrome, but I swear it was working when I last commented. I think it's that the app on my phone isn't properly playing back the stream, so I'm looking into modifying the plugin to get it working consistently), but yes, we've tried to make SIP.js very configurable in this regard. I was heavily involved in the refactor that made this sort of thing possible, which is one of the reasons I'm interested in getting together a working example of it.

I think it's that the app on my phone isn't properly playing back the stream

Ugh, this turned out to be a WebRTC issue on my laptop. Rebooting fixed it.

Also, I was able to get two-way audio on a call _from_ Chrome _to_ Android (I had only gotten the other direction working previously). I just had to make sure Chrome was offering only audio and not also video.

I still haven't been able to call Firefox, so I made an issue for it.

Android L has built in WebRTC support.
We have created an iOS Cordova Plugin.
Guides are available on sipjs.com.

Any plans to port it to phonertc 2?

@thomasquintana is working on porting it over to phonertc 2.0. It is almost finished.

@alongubkin Tying up the loose ends now...look for a pull-request soon.
Fork: https://github.com/BetterVoice/phonertc

@egreenmachine Here is an updated version of the media handler that works with the above fork (or will in a little bit). Also supports multiple sessions:
https://github.com/BetterVoice/PhoneRTCMediaHandler

Since information across other sources seems to be a bit scattered and this was recently modified, what is the recommended way for mobile integration right now @egreenmachine?

I do not have much to report here, as you can probably tell from me removing the milestone. I can say that internally we are working on a mobile app using NativeScript and backed by SIP.js. I am hopeful that there might be some public facing results from that will allow SIP.js users to do the same in a simple manner. However, it is still too early to tell for sure. That being said, it is definitely possible to use the native WebRTC drivers, SIP.js, and NativeScript to make a mobile app. Once I have more to share I will update this issue.

@cybrox SIP.Js version 0.7.8 can works on cordova with crosswalk on Android and iosrtc on iOS, the SIP.Js 0.9.2 however got some errors on RTC stuff.

@egreenmachine please work on the react native too, thank you :)

@greenmachine curious on you guys effort with getting sipjs with nativescript. im running sipjs 0.7.8 with a cordova app but since sipjs isnt supporting cordova anymore on the lookout for potential replacement.

if you dont mind sharing the approach you guys use with nativescript? are you guys using the native webrtc ?

@andrewvmail We ended up using native WebRTC and creating a custom SDH to interface with that. While I make it sound simple, it was far from that. At this point I do not think that we are going to make the implementation public. It is pretty difficult to get running and we expect the time we would have to commit to support it publicly too high. Additionally, it works for our app but it is a pretty specific implementation. We would have to do work to make it generic and we expect that people would run into issues trying to use it out the box. From the community activity we see it appears that most people want something that works out of the box with just some simple configuration parameters. This would not really be that.

For mobile, our target support is going to be the major mobile browsers. This would be Chrome on Android and Safari on iOS. If people would like to submit a PR back for SDH that they create for other environments, we would welcome it.

I hope that this clears up some of the cloud around mobile. Please reach out if you have any other questions or comments.

I also ended up writing a custom SDH to carefully interface SIP.[email protected] with the provided cordova/iOS WebRTC implementation. It allowed my to solve an issue where cordova was complaining about the argument to RTCPeerConnection.setLocalDescription() & setRemoteDescription().

And have made it available as a publicly accessible npm library:
https://github.com/WesUnwin/cordova-ios-session-description-handler

This may also be a useful example of how to write custom SDHs (in addition to the default SDH inside the SIP.js library which I also found to be a useful starting point). Hope this helps anyone!

Any new updates on this?

I noticed:

“The bulk of SIP.js no longer cares about the media and what it’s doing, which opens up some exciting possibilities, like running it in a non-web browser, NativeScript on a phone, or Node.js on a desktop app,” notes James Criscuolo, Director of Software Engineering at OnSIP.

Ref: https://www.onsip.com/voip-news/onsip-news/sipjs-v0.8.0-supports-all-major-browsers-and-renegotiation

Is Nativescript supported?

We have built the OnSIP mobile app using Nativescript. That being said - getting the WebRTC libraries to run in Nativescript is not for beginners. Some users have reported success with react native and that may be path of least resistance.

Hello, can you support Baidu browser(china)? Can register, can also send information, can not dial

Was this page helpful?
0 / 5 - 0 ratings