4

I am trying to integrate Asterisk with webRTC. There was a query posted here but it barely provides any solution.

I already have a basic webRTC infrastructure in place which I have tested for proof-of-concept. I use socket.io for signalling, COTURN for STUN/TURN with node.js and supporting modules for my web server. I use MySQL for session persistence. My asterisk installation works fine with SIP phones and a PRI card for my PSTN interface. My Asterisk, webserver and other supporting servers run on the same box.

There are instructions on Asterisk here and on sipjs here (and other similar products site) to integrate Asterisk with WebRTC. From my reading there, it appears that Asterisk has a builtin webserver for wss support, uses pjproject for ICE, TURN/STUN servers, among other things. I see that taking the approach here would mean duplicating the infrastructure.

I would like to implement an audio gateway from WebRTC to a SIP or DAHDI channel. This is essentially an audio call to a PSTN number or a SIP end-point from the browser. The way I see it is that with what I have in place, I will need the following:

  • A codec transcoder for audio (Browser codec to Asterisk codec), possibly Kurento.
  • Some way to convert a WebRTC SDP to an Asterisk SDP.
  • Some way to "register" a logical webRTC peer to the SIP proxy(Asterisk).
  • Some intermediate module for Asterisk to think of a WebRTC peer as a SIP end point.
  • Anything else?

I think this must have been implemented before. I am unable to find any solution or discussion in this direction.

Am I on the wrong track? Am I reinventing the wheel? Any guidance will be most appreciated.

Community
  • 1
  • 1
Sunny
  • 9,245
  • 10
  • 49
  • 79
  • This is not a programming question, my comments: Asterisk itself performs a lot of media transcoding and "SDP conversion". WebRTC is just the API, the transport is commonly WSS, there is JS scripts as sipjs, sipml5 which implements client SIP stack and use WSS as transport, hence Asterisk see it as SIP endpoint (Just different transport) – gogasca Apr 12 '16 at 23:34

1 Answers1

4

There is nothing to be "implemented" here. All the listed points are already implemented in Asterisk.

The links you mentioned discusses mostly old versions of Asterisk. I recommend to use a recent guide for WebRTC on Asterisk 13.

A codec transcoder for audio (Browser codec to Asterisk codec), possibly Kurento.

Transcoding is built-in Asterisk by default. However WebRTC has support also for G.711 (PCMU and PCMA) so most probably you never have to transcode.

Some way to convert a WebRTC SDP to an Asterisk SDP.

This is already handled by Asterisk and all the popular WebRTC SIP clients (sip.js, webphone, sipml5) using RFC 7118 (WebSocket for SIP protocol). Instead of using socket.io with your custom protocol, I would highly recommend to use this. (Socket.io is using websocket anyway in all modern browsers and when webrtc is not available webrtc will be missing too)

Some way to "register" a logical webRTC peer to the SIP proxy(Asterisk).

This is like the usual SIP REGISTER on websocket mentioned above

Some intermediate module for Asterisk to think of a WebRTC peer as a SIP end point.

Nothing extra is needed for this. Follow the guide which I have mentioned above to setup a WebRTC externsion (it is like other SIP extension and WebRTC can talk with SIP once configured).

Note that most probably you don't even need TURN and STUN for this if your Asterisk has a public static IP. (Except some basic STUN which is part of the ICE protocol and already built in Asterisk)

Istvan
  • 1,591
  • 1
  • 13
  • 19
  • Certainly helpful. Will look into your answer in detail and the newer guide referenced by you and most likey accept your answer after reviewing. Upvoted now. Thanks a lot. – Sunny Apr 13 '16 at 16:39
  • **The architecture in the links do not leverage existing support. A WebRTC API embedded in a node server is a better approach with the embedded webRTC peer tied to a SIP end point. Then Asterisk will not need support for websockets or ICE - if provided in the app server. Doubts: **If the client is behind a type of NAT that requires relaying, even if the Asterisk server is on a public address, would I not need TURN? ** Regarding support for G.711 in browsers and Asterisk, basic as it may be, I did not know. Thanks. **Reading your links I feel that there is no need for SDP conversion. Right? – Sunny Apr 14 '16 at 12:06
  • Accepted your answer because it certainly works or answers my questions. I am just thinking of an alternate approach... may be along the lines [here](http://stackoverflow.com/questions/18872712/node-js-webrtc-client) – Sunny Apr 14 '16 at 12:09
  • 1
    -If you already have asterisk then why to use other NodeJS app server for signaling? -Also please note that 90% of all these is about media handling (signaling only needs a simple websocket wrapper) -If the server is on the public internet then you don't need TURN as the server can route the media for you when needed -SDP conversion is not necessary for WebRTC to WebRTC calls but usually needed for WebRTC to SIP calls as it contains many details not required for SIP and also it needs to be stripped down if your SIP signaling is over UDP because of the max UDP packet size limit – Istvan Apr 15 '16 at 06:35
  • We already have node http, TURN and other servers for WebRTC apps. We use socket.io: signalling for WebRTC, fileupload status, chat, etc. We use Asterisk as company's PBX with a E1 to PSTN. We just need to make a simple PSTN call from a web page, thru Asterisk - using WebRTC for media. We have authentication module... which should map user into a SIP account without specifying SIP account/password in the webpage. I see no need to build Asterisk with WebRTC or websockets. If I get node_webrtc & jssip in node to work, I will have a solution - I think. THANKS for all the info. – Sunny Apr 15 '16 at 07:23