A custom mediasoup SFU, browser SDK and provider adapter that run video visits side by side with two commercial video APIs.
Our client, a telehealth company that runs video visits through its own web platform, already supported two commercial video (CPaaS) providers. Their web client loads each provider through the same adapter interface, so the applications on top can run a call on either one. The client wanted a third provider: a self-hosted media server built on the open source mediasoup SFU.
The requirement was strict: the new provider had to match the existing two feature for feature, so that patients and clinicians would get the same call experience whichever provider carried their visit. The client planned a phased rollout, starting with a share of call traffic on mediasoup and moving more workflows over time.
Over ten months, four WebRTC.ventures engineers worked as one team with the client’s architects, developers, DevOps engineers and QA team. Via this WebRTC staff augmentation contract, the media server, a browser SDK, and the adapter that connects them to the existing web client was built.

Patients join video visits on whatever network they have, so a large share of our work went into keeping calls alive when that network drops or loses packets. The reconnect layers and the publisher loss throttle are what I'm proudest of. Together they keep calls going through the network problems real users hit, with less frozen video for everyone on the call.
The Needs
Adding a third provider to a live telehealth platform came with a fixed set of requirements:
- A self-hosted SFU built on mediasoup
- Feature parity with two commercial video providers
- Integration with the client’s platform services and message bus
- Reliable calls on poor and unstable networks
- Delivery through the client’s release trains and code freezes
What We Built
mediasoup SFU Media Server with JSON-RPC Signaling
The media node is a Node.js and TypeScript server that runs mediasoup and speaks JSON-RPC 2.0 over WebSocket. Every request passes through the same checks in order: authenticated, authorized, idempotent, joined. Each request carries a client key, and the server caches its result per connection, so a retried request runs at most once. That made it safe for the SDK to queue requests while a socket was down and resend them on reconnect.
The signaling protocol is defined once in JSON Schema. TypeScript types and Zod validators are generated from it, and the server and SDK share the same contract package. That kept both sides in step through dozens of protocol changes.
Browser SDK and Provider Adapter on a CPaaS Abstraction Layer
The SDK provides a room state machine, a reconnecting signaling client, producer and consumer collections, simulcast presets and codec negotiation. The adapter sits next to the two existing provider adapters and matches their behavior: screen sharing, background blur and replacement, data messaging, speaking indicators, monitoring calls and session refresh.
Matching two mature commercial integrations this closely was one of the hardest parts of the project. We built the core first and closed the parity gaps in the final months, alongside a large batch of QA fixes. Chasing parity from day one would have slowed the core work, and this order kept the foundation moving.
Platform Integration for a Self-Hosted Media Server
A NATS client connects each media node to the client’s platform. It reports room and participant lifecycle events, accepts commands to disable a room or disconnect a participant, and reconciles state at startup and on a schedule. Authentication uses JWTs, with the key set cached on disk so a node can boot while the key server is down.
Nodes can be cordoned before maintenance. Existing rooms keep running, new rooms go to other nodes, and clients receive a shutdown notice that says whether a replacement node is available. Prometheus metrics and structured logs cover every node.
mediasoup Reconnect, ICE Restart and Adaptive Video
Patients join video visits from home Wi-Fi, mobile hotspots and laptops that go to sleep mid-call, and keeping those calls alive took a large share of the work on both the server and the client.
- Three layers of reconnect: ICE and transport recovery, a fast reconnect that resumes the session over a new socket, and a full rejoin (transport and websocket).
- Fast detection of dropped participants: a participant who goes silent triggers a check of their media transports, and the server removes them as soon as the media is idle too.
- Adaptive streams: each participant’s network-quality score caps the video layers they receive, with damped recovery so quality does not flip back and forth. The client also requests the layer each video tile needs and pauses hidden tiles. This adaptive rendering logic was later carried over to one of the commercial provider adapters.
- Uplink protection: a bitrate guard pauses outgoing video when the uplink can’t carry it, and a loss throttle lowers the camera’s bitrate while the uplink loses packets, which reduces frozen video for everyone watching.
VP9, AV1 and H264 Codecs on the mediasoup SFU
The media node supports VP9 and AV1 with scalable video coding, and H264 with profiles ranked for hardware encoders. H265 is available behind a configuration flag.
WebRTC Testing with Headless Chrome and Network Emulation
The server has dozens of unit spec files and integration suites that drive a real media node with a headless WebRTC client. With the client’s engineers, we also built an A/V test harness that runs the real web client in headless Chrome against a real media node, using synthetic participants and Chrome’s network emulation to apply packet loss, bandwidth caps and outages mid-call. It can run the same call on a commercial provider for comparison. Every command outputs JSON, so an AI coding agent can turn a bug report into a failing scenario and confirm the fix. Many QA bugs shipped with a harness scenario alongside the fix.
Tech Stack
- mediasoup: open source SFU at the core of the media node
- Node.js and TypeScript: server, SDK and adapter, organized in pnpm workspaces
- Fastify: HTTP and WebSocket server
- JSON-RPC 2.0 over WebSocket: signaling
- JSON Schema and Zod: schema-first protocol with generated TypeScript and Zod types
- NATS: platform message bus
- JWT and JWKS: authentication
- Prometheus and pino: metrics and structured logging
- Vitest and @roamhq/wrtc: unit tests and headless WebRTC integration tests
- Jenkins, Docker Compose and Ansible: CI/CD and deployment
- watchRTC (now CyaraRTC): call telemetry
Let's turn your project into another story of success.
Client:
Under NDA
Type of Application:
Telehealth video platform
How We Helped:
Through WebRTC staff augmentation, four of our engineers joined the client's team for ten months to build a self-hosted mediasoup media server, browser SDK and provider adapter.
Features:
- Self-hosted mediasoup SFU
- Third video provider behind a shared adapter interface
- Feature parity with two commercial providers
- Screen sharing, background blur and replacement
- Data messaging and speaking indicators
- Three-layer automatic reconnect
- Adaptive video by network quality and tile size
- Publisher bitrate protection on weak uplinks
- VP9 and AV1 SVC, H264 simulcast
- Node cordon and drain for smooth rollouts
- Platform message bus integration
- Automated A/V test harness with network emulation
WebRTC Services
WebRTC.ventures is one of the few agencies in the world dedicated to WebRTC development. This dedication and experience is why so many people trust us to help bring live video application dreams to life.
Let’s convert your idea into another story of success!