Case StudyWebRTCKamailioRTPengineFreeSWITCHClick-to-Call

Case Study: WebRTC-SIP Gateway for a VoIP Provider

A VoIP service provider in North America wanted its customers to call from a web browser, with nothing to install: a web softphone for everyday calling, and a click-to-call button its customers could put on their own websites. Browser calls had to reach the provider's existing SIP platform and the phone network. CelloIP designed and built the gateway, and still maintains it. This is how it works.

Kaushik ParmarFounder & VoIP Architect · 12+ years in telecom and VoIP 9 min read
100s
Of concurrent browser calls
Voice + video
From the browser
PSTN
Calls to ordinary phone numbers
1–3 mo
To first production version

Quick answer

What did CelloIP build in this WebRTC gateway project?

CelloIP built a WebRTC-to-SIP gateway for a VoIP service provider in North America, so the provider's customers can make and receive calls from a web browser. Kamailio handles SIP over secure WebSocket from the browser, RTPengine converts encrypted browser media into standard RTP, and the provider's FreeSWITCH platform connects the calls. Customers get a web softphone, a click-to-call widget for websites, video calls and calls to ordinary phone numbers. It handles hundreds of concurrent calls, was built in one to three months, and CelloIP maintains it.

Project summary

Details
ClientVoIP service provider in North America (name confidential)
ProductWebRTC-to-SIP gateway for browser calling
SignallingKamailio: SIP over secure WebSocket, authentication, routing
MediaRTPengine: DTLS-SRTP and ICE in the browser, standard RTP to the platform
Call platformThe provider's FreeSWITCH platform
For usersWeb softphone, click-to-call widget, video calls, calls to phone numbers
ScaleHundreds of concurrent calls
TimelineFirst production version in one to three months
StatusLive, maintained by CelloIP

Desk phones and installed softphones still matter, but more and more customers expect to make calls straight from a browser tab. For a VoIP provider, browser calling also opens a new product: a click-to-call button its business customers can add to their own websites. The provider wanted both, without rebuilding its platform.

The challenge

Browsers and SIP networks speak different dialects. WebRTC uses SIP over secure WebSocket for signalling, and encrypted media negotiated with ICE and DTLS-SRTP. SIP platforms and carriers expect SIP over UDP or TCP and plain RTP. Something has to translate, reliably and at volume.

  • Accept SIP over secure WebSocket from browsers and authenticate users.
  • Convert encrypted browser media to standard RTP for FreeSWITCH, and back.
  • Work across home networks, offices, firewalls and mobile hotspots.
  • Support voice and video, and calls to ordinary phone numbers.
  • Handle hundreds of concurrent calls.
  • Connect to the provider's existing FreeSWITCH platform.

Architecture

WebRTC-to-SIP gateway architecture for a North American VoIP provider: a web softphone and a click-to-call widget send SIP over secure WebSocket to Kamailio, which routes them to the provider's FreeSWITCH platform; browser media uses DTLS-SRTP and RTPengine converts it to RTP for FreeSWITCH; FreeSWITCH connects calls to SIP phones, other browser users and the public phone network
Kamailio handles signalling and RTPengine handles media; the provider's FreeSWITCH platform connects every call.

Web softphone

Calling from the browser for the provider's customers: voice, video and calls to phone numbers.

Click-to-call widget

A call button the provider's business customers place on their websites, so visitors can call them from the page.

Kamailio

Accepts SIP over secure WebSocket, authenticates users and routes calls to FreeSWITCH.

RTPengine

Terminates the browser's encrypted media and ICE, and forwards standard RTP to FreeSWITCH.

FreeSWITCH

The provider's call platform, connecting browser users to SIP phones, other browser users and the phone network.

Splitting signalling and media between Kamailio and RTPengine is a well-proven pattern. Each component does one job, and each can be scaled on its own. Our WebRTC-SIP gateway architecture guide compares the alternatives.

Signalling with Kamailio

TaskHow it's handled
Browser connectionSIP over secure WebSocket (WSS), with TLS certificates browsers trust
AuthenticationUsers authenticate before they can register or call
RegistrationBrowser users register so they can receive calls as well as make them
RoutingCalls are routed to the provider's FreeSWITCH platform
Media controlKamailio instructs RTPengine to handle the media for each call

Kamailio is built to handle very large numbers of SIP messages, which suits browser clients that reconnect often as people close tabs and change networks. Our Kamailio development page covers our wider work with it.

Media with RTPengine

WebRTC media is always encrypted and negotiated with ICE, which most SIP equipment doesn't support. RTPengine bridges the two worlds:

  • On the browser side, it handles ICE and DTLS-SRTP, as WebRTC requires.
  • On the platform side, it sends and receives standard RTP to and from FreeSWITCH.
  • It relays media for users behind restrictive firewalls and NAT.
  • It handles both audio and video streams.

Because media runs through RTPengine rather than the signalling server, media capacity can be increased by adding RTPengine instances without touching Kamailio.

How a browser call flows

Following one call from a browser to an ordinary phone number shows how the pieces fit together:

StepWhat happens
1. ConnectThe web softphone opens a secure WebSocket to Kamailio and registers with the user's credentials
2. DialThe user dials a number; the browser sends a SIP INVITE over the WebSocket, with a WebRTC media offer
3. Prepare mediaKamailio asks RTPengine to handle the call's media, and RTPengine rewrites the offer so FreeSWITCH sees standard RTP
4. RouteKamailio forwards the call to FreeSWITCH, which routes it to the carrier and the phone network
5. TalkEncrypted audio from the browser reaches RTPengine, which decrypts it and sends RTP to FreeSWITCH, and the reverse
6. Hang upEither side ends the call; Kamailio tells RTPengine to release the media session

Incoming calls follow the same path in reverse: FreeSWITCH sends the call to Kamailio, which delivers it over the WebSocket to the user's open browser tab. The click-to-call widget uses the same path to connect a website visitor to the business that added the button.

What customers got

Web softphone

Make and receive calls from a browser tab, on the provider's numbers, with nothing to install.

Click-to-call widget

Business customers add a call button to their websites; visitors call them straight from the page.

Video calls

Video calling from the browser alongside voice.

Calls to phone numbers

Browser users call ordinary phone numbers through the provider's FreeSWITCH platform and carriers.

Built for hundreds of concurrent calls

The gateway handles hundreds of concurrent browser calls. Several design choices make that comfortable:

Separate signalling and media

Kamailio and RTPengine scale independently, so a surge in calls doesn't overload signalling.

Room to grow

More RTPengine instances can be added as media load grows.

Encryption where it's needed

Encryption is handled at the edge, so FreeSWITCH can work with plain RTP as it always has.

Delivery

The first production version was built in one to three months:

StageWhat was built
1. SignallingKamailio with SIP over secure WebSocket, authentication and routing to FreeSWITCH
2. MediaRTPengine for ICE and DTLS-SRTP to RTP, for audio and video
3. Web softphoneBrowser calling for the provider's customers, with video and calls to phone numbers
4. Click-to-callEmbeddable widget for business customers' websites
5. Load testingTesting at hundreds of concurrent calls before launch
6. Launch and supportGo-live, then ongoing maintenance by CelloIP

CelloIP maintains the gateway, including updates as browsers change their WebRTC behaviour, which happens several times a year.

Lessons for anyone adding browser calling

  • Separate signalling and media; it makes scaling and troubleshooting far easier.
  • Keep the existing call platform; translate at the edge instead of replatforming.
  • Test on real networks: home Wi-Fi, offices, firewalls and mobile hotspots.
  • Load-test at your expected peak before launch.
  • Plan for browser updates; WebRTC behaviour changes regularly.

Frequently asked questions

What did CelloIP build?

A gateway that connects web browsers to a VoIP provider's SIP platform. It powers a web softphone and a click-to-call widget, supports voice and video, and lets browser users call ordinary phone numbers. It uses Kamailio for signalling, RTPengine for media and the provider's FreeSWITCH platform for calls.

Who is the client?

A VoIP service provider in North America. Its name is confidential under our agreement.

Why is a gateway needed for WebRTC?

Browsers speak WebRTC: SIP signalling over secure WebSocket, and media encrypted with DTLS-SRTP using ICE. Most SIP platforms and carriers expect SIP over UDP or TCP and plain RTP. The gateway translates between the two so browser users can call anyone on the SIP network.

What do Kamailio and RTPengine each do?

Kamailio accepts SIP over secure WebSocket from browsers, authenticates users and routes calls to FreeSWITCH. RTPengine sits in the media path, terminating the browser's DTLS-SRTP and ICE and forwarding standard RTP to FreeSWITCH, and the reverse for the other direction.

How many calls does it handle?

Hundreds of concurrent calls. Kamailio and RTPengine are both built for high volumes, and more RTPengine instances can be added as media load grows.

How long did it take?

The first production version took one to three months. The gateway is live and CelloIP maintains it.

What would a similar project cost?

As a guide, browser calling or a click-to-call widget connected to an existing PBX or SIP trunk typically costs $8,000–$20,000 over 4–8 weeks. Projects with video, high concurrency or multi-tenant needs are scoped after discovery. Servers and TURN bandwidth are separate running costs.

Work with CelloIP

Adding browser calling to your VoIP platform?

CelloIP builds WebRTC-to-SIP gateways, web softphones and click-to-call widgets on Kamailio, RTPengine, FreeSWITCH and Asterisk, connected to your existing platform. You own the code.