Incoming calls with SIP and WebRTC

I am implementing a browser-based VOIP solution that uses SIP and WebRTC and that connects to PTSN. Mostly users give me their SIP credentials, and I use WebRTC to access their microphone and speakers. On the page, I plan to launch the SIP client.

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

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

+9
webrtc voip sip
source share
4 answers

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

In other words, your server must be a combination of a SIP server and an HTTP server, and the HTTP server needs to support web sockets and the WebRTC API.

If you haven't looked at the Phono SDK yet, this is a good starting point.

Update:

Things have changed a bit since the last time I watched WebRTC. Now it looks like some SIP implementations in javascript implementations cover the new WebRTC APIs for the media side of things. A browser application using the SIP-javascript stack does not need additional servers and can directly connect to an existing SIP server. One example I found is sip-js , but I believe there are others.

+4
source share

Perhaps updating for this is worth the effort.

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

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

WebRTC encodes media in DTLS / SRTP, so you have to decode it in pure RTP as well. This means that on the server side you will use a software switch with built-in WebRTC support or a WebRTC gateway for SIP. Be sure to select a software switch / gateway with full multimedia transcoding support. WebRTC currently supports G.711, G.722, and Opus. For an outdated SIP network, your server usually just selects G.711, and everything is perfect. In some cases, you may need to convert multimedia to other popular codecs, such as G.729, G.723 or GSM.

Usually you have the following protocol coverage:

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

WebRTC-enabled software switch:

WebRTC for SIP gateways:

WebRTC Clients with SIP Support (RFC 7118):

You should also deploy and use your own STUN and TURN servers (some servers / gateways have these built-in functions, otherwise use coturn rfc5766-turn-server ).

After starting and starting the server side, you can easily create your own client solution based on the above webrtc clients, since each of them has an easy-to-use JavaScript API.

+5
source share

In theory, you can deploy a SIP server using open source softswitch software (FreeSWITCH, Asterisk) and purchase the SIP trunking service for receiving phone numbers and routing calls to / from PSTN. You can then configure the SIP WebRTC client to use your server. There are open source JavaScript libraries (SIP.js, JsSIP, sipML5).

This may be your best bet if you work on a small scale and are quite used to launching telecommunications infrastructure and buying trunks. In practice, using PSTN calls for WebRTC can be tough - quality issues. I also do not know at what scale you want to create your application, but there are more than 100 simultaneous connections to your SIP server, and you will need to deal with scaling. If you want a hosting solution to solve the telecommunication problem, you can use SIP.js and sign up for OnSIP (a company supporting SIP.js ), which is a pay-as-you-go service that allows you to purchase phone numbers and simply encode your client. The SIP.js user agent design is as follows:

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

If you selected OnSIP (hosted), these credentials are provided by the service and registered with OnSIP. If you decide to deploy your own SIP servers, you will modify them accordingly.

+3
source share

solution for your problem:

  • Webrtc itself works as rtpengine.so, using sip credentials, you can register yourself using wss or ws to load the server. Then you can make a call to another user or outgoing sip user.
  • the call will hit the sip server, from there the sip server will decide to poll its incoming call or outgoing.
0
source share

All Articles