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.
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 | |
|---|---|
| Client | VoIP service provider in North America (name confidential) |
| Product | WebRTC-to-SIP gateway for browser calling |
| Signalling | Kamailio: SIP over secure WebSocket, authentication, routing |
| Media | RTPengine: DTLS-SRTP and ICE in the browser, standard RTP to the platform |
| Call platform | The provider's FreeSWITCH platform |
| For users | Web softphone, click-to-call widget, video calls, calls to phone numbers |
| Scale | Hundreds of concurrent calls |
| Timeline | First production version in one to three months |
| Status | Live, 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
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
| Task | How it's handled |
|---|---|
| Browser connection | SIP over secure WebSocket (WSS), with TLS certificates browsers trust |
| Authentication | Users authenticate before they can register or call |
| Registration | Browser users register so they can receive calls as well as make them |
| Routing | Calls are routed to the provider's FreeSWITCH platform |
| Media control | Kamailio 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:
| Step | What happens |
|---|---|
| 1. Connect | The web softphone opens a secure WebSocket to Kamailio and registers with the user's credentials |
| 2. Dial | The user dials a number; the browser sends a SIP INVITE over the WebSocket, with a WebRTC media offer |
| 3. Prepare media | Kamailio asks RTPengine to handle the call's media, and RTPengine rewrites the offer so FreeSWITCH sees standard RTP |
| 4. Route | Kamailio forwards the call to FreeSWITCH, which routes it to the carrier and the phone network |
| 5. Talk | Encrypted audio from the browser reaches RTPengine, which decrypts it and sends RTP to FreeSWITCH, and the reverse |
| 6. Hang up | Either 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:
| Stage | What was built |
|---|---|
| 1. Signalling | Kamailio with SIP over secure WebSocket, authentication and routing to FreeSWITCH |
| 2. Media | RTPengine for ICE and DTLS-SRTP to RTP, for audio and video |
| 3. Web softphone | Browser calling for the provider's customers, with video and calls to phone numbers |
| 4. Click-to-call | Embeddable widget for business customers' websites |
| 5. Load testing | Testing at hundreds of concurrent calls before launch |
| 6. Launch and support | Go-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.