Real-time / Web
WebRTC (Web Real-Time Communications)
WebRTC is a browser-native API and protocol stack for peer-to-peer audio, video, and data transfer. It runs in every modern browser without plugins and is the foundation for browser-based softphones and voice agents.
Stack overview
WebRTC bundles four protocol families:
- Signaling: typically SIP-over-WebSocket (RFC 7118) or a custom HTTP/WS API. The browser exchanges SDP offers/answers.
- NAT traversal: ICE (RFC 8445), STUN, TURN.
- Media: SRTP (encrypted RTP) keyed via DTLS-SRTP.
- Codecs: Opus (audio), VP8/VP9/H.264/AV1 (video), G.711 (PSTN interop).
Browser API
const pc = new RTCPeerConnection({ iceServers: [ { urls: "stun:stun.didhub.io:3478" }, { urls: "turn:turn.didhub.io:443?transport=tcp", username: "u", credential: "p" }, ], }); const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); stream.getTracks().forEach(t => pc.addTrack(t, stream)); const offer = await pc.createOffer(); await pc.setLocalDescription(offer); // Send offer.sdp to your signaling server (SIP WSS or custom)
WebRTC to PSTN interop
WebRTC alone cannot reach the PSTN — you need a SIP gateway that bridges WebRTC media (DTLS-SRTP, Opus) to traditional SIP/RTP (G.711). DIDHub provides this bridge as part of every SIP trunk: just send your INVITE over WSS and the carrier handles transcoding.
Related terms
Ready to get a number?
Pick a DID in 130+ countries from $1.99/month. Activates instantly on most numbers.