Video, voice and data sent straight between two browsers.
WebRTC (Web Real-Time Communication) lets two browsers send video, voice and data directly to each other, without sending it all through your server.
With normal web apps, everything goes through a server. For a video call that is slow and expensive. WebRTC lets the two browsers connect peer to peer.
Video is heavy. Sending it all through your servers means high cost and extra delay. WebRTC fixes this:
| Piece | Job in easy words |
|---|---|
| Signalling | How the two peers swap setup notes. WebRTC does NOT define it. You build it, often with WebSockets |
| SDP | The text note: 'here are my codecs, media and security fingerprint' |
| ICE | The process that tries many network routes and picks the best one |
| STUN | A small server that tells a browser its public address |
| TURN | A relay server used when a direct link is impossible |
| DTLS | Handshake that agrees on encryption keys |
| SRTP | Encrypted audio and video packets |
| Data channel (SCTP) | A direct pipe for any data, reliable or not |
| Codec | How audio and video are compressed (for example Opus, VP8, H.264) |
Most devices sit behind a router (NAT) and have a private address like 192.168.1.5. The outside world cannot connect to it directly. STUN and ICE work out a public address and open a path. If both sides are behind strict (symmetric) NAT, a direct path often cannot be made, and TURN relays the media.
getUserMedia and add the tracks to an RTCPeerConnection.iceServers. Always include TURN for production.createOffer, setLocalDescription, send it. Callee: setRemoteDescription, createAnswer, send it back.onicecandidate) and add the ones you receive.<video> element (ontrack).A mesh (everyone connects to everyone) works for about 3 to 4 people. After that, upload bandwidth explodes. Larger calls use a media server:
| Design | How | Good for |
|---|---|---|
| Mesh | Every peer connects to every other peer | 2 to 4 people, no media server |
| SFU (Selective Forwarding Unit) | Each person uploads once to a server, which forwards streams to the others | Meetings, webinars. The most common choice |
| MCU (Multipoint Control Unit) | Server mixes all video into one stream | Weak devices, but heavy server cost |
| Term | Meaning in easy words |
|---|---|
| Peer | One of the two ends of a direct connection |
| Signalling | Passing setup messages so peers can find each other. You build it |
| SDP | Session Description Protocol: the text that describes media and security |
| Offer / Answer | The two SDP messages used to agree on a call |
| ICE candidate | One possible network route to a peer |
| STUN | Tells a device its public IP and port |
| TURN | A relay server that forwards media when direct fails |
| NAT | A router feature that hides private addresses behind one public address |
| DTLS / SRTP | Encryption for keys, and for audio and video |
| Data channel | A direct peer-to-peer pipe for arbitrary data |
| SFU | A server that forwards video streams to many people |
| WebSockets | WebRTC | |
|---|---|---|
| Path | Client to server to client | Peer to peer (or via a relay) |
| Best for | Chat, signals, app events | Live audio, video, direct data |
| Transport | TCP | Mostly UDP |
| Server role | Carries every message | Only helps set up (and relays if needed) |
| Setup | Easy | Complex |