Incoming calls with SIP and WebRTC

2019-03-27 06:18发布

I'm looking into implementing a browser-based VOIP solution that uses SIP and WebRTC and that connects to the PTSN. Basically, users give me their SIP credentials and I use WebRTC to acccess their microphone and speakers. On the page, I plan to run an SIP client.

How do I implement the incoming calls coming from the PTSN? Do I need some sort of listener that connects to the SIP server of the user?

I know this is a broad question but after doing some research online, I'm still somewhat confused about the SIP implementation of incoming calls.

标签: sip voip webrtc
4条回答
劫难
2楼-- · 2019-03-27 07:02

In theory, you can deploy a SIP server using an open source softswitch (FreeSWITCH, Asterisk) project and purchase "SIP trunking" service to obtain phone numbers and route calls to/from the PSTN. Then, you can configure a WebRTC SIP client to use your server. There are open source JavaScript libraries (SIP.js, JsSIP, sipML5).

That may be your best choice if you are working in small scale and quite used to running telecom infrastructure & purchasing trunking. In practice, running PSTN to WebRTC calls can be tough— lots of quality concerns. I also don't know at what scale you are looking to build your app, but over 100 simultaneous connections to your SIP server, and you'll need to deal with scaling. If you want a hosted solution to cut out the telecom hassle, you can use SIP.js and sign up for OnSIP (company supporting SIP.js), which is a pay-as-you-go service that will allow you to purchase phone numbers and just get coding your client. SIP.js user agent construction looks like this:

var userAgent = new SIP.UA({
  uri: 'bob@example.onsip.com',
  wsServers: ['wss://sip-ws.example.com'],
  authorizationUser: sipUsername,
  password: sipPassword
});

If you chose OnSIP (hosted), those credentials are provided by the service and register with OnSIP. If you choose to deploy your own SIP servers, you would change out accordingly.

查看更多
一夜七次
3楼-- · 2019-03-27 07:15

Maybe a refresh for this is worth the effort.

WebRTC is implemented now in Firefox and Chrome (and missing from IE, Edge and Safari).

For legacy SIP to WebRTC some conversions are needed. With WebRTC you can use anything for signaling usually over WebSocket. You can implement your proprietary protocol, however if you are looking for SIP compatibility then the most natural fit is the WebSocket to SIP protocol.

WebRTC encodes media in DTLS/SRTP so you will have to decode that also in clear RTP. This means that on the server side either you will use a softswitch with WebRTC support built-in or a WebRTC to SIP gateway. Make sure to select a softswitch/gateway with full media transcoding support. WebRTC currently supports G.711, G.722 and Opus. For legacy SIP network your server usually just selects G.711 and everything is perfect. In some circumstances you might have to convert the media to the other popular codec's such as G.729, G.723 or GSM.

Usually you have the following protocol coversions:

  • Signaling (this is simple): SIP over WebSocket in TLS -> clear SIP over UDP/TCP
  • Media (this is more complicated): DTLS/SRTP encoded RTP with PCMU -> clear RTP with PCMU

Softswitch with WebRTC support:

WebRTC to SIP gateways:

SIP (RFC 7118) capable WebRTC clients:

Also you should deploy and use your own STUN and TURN servers (some of the server/gateways have these built-in, otherwise use coturn rfc5766-turn-server).

Once the server side is up and running, you can easily create your custom client side solution based on the above webrtc clients since each of them has a simple to use JavaScript API.

查看更多
仙女界的扛把子
4楼-- · 2019-03-27 07:15

solution for your problem is:

  • Webrtc its self work as rtpengine.so using sip credential you can register your self with wss or ws to sip server.then you can make call to other sip user or outbound.
  • call will hit the sip server from there sip server decide weather its inbound call or outbound
查看更多
三岁会撩人
5楼-- · 2019-03-27 07:21

You need a server that implements a SIP-WebRTC gateway. The gateway will be able to receive incoming calls from a SIP provider (which itself will be acting as a SIP-PSTN gateway by converting ISDN-SIP, SS7-SIP etc) via SIP and then forward the call to your browser based clients using WebRTC.

Put another way your server needs to be a combination of a SIP server and a HTTP server and the HTTP server needs to support web sockets and the WebRTC API.

If you haven't already take a look at the Phono SDK it's a good starting point.

Update:

Things have moved on a little bit since I last looked at WebRTC. There now do seem to be some SIP in javascript implementations around that leverage the new WebRTC APIs for the media side of things. A browser application using a SIP-javascript stack would not need any additional servers and could connect directly to an existing SIP server. One example I found is sip-js but I believe there are others around as well.

查看更多
登录 后发表回答