Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

WebRTC Glossary: Key Terms for Real-Time Video

· 5 min read · Home Tech

In this article
  1. Core WebRTC Architecture
  2. Signaling and SDP
  3. ICE, STUN, and TURN
  4. Media Streams and Tracks
  5. Codecs and RTP
  6. Common Problems and Troubleshooting
  7. Security and Privacy
  8. Frequently Asked Questions

WebRTC (Web Real-Time Communication) is a free, open-source project that enables video, audio, and data sharing directly between browsers and apps without plugins. This glossary defines the essential terms you need to understand how WebRTC works for real-time video, from signaling and SDP to ICE, STUN, and TURN.

Core WebRTC Architecture

WebRTC is built around a peer-to-peer (P2P) model, meaning media flows directly between two browsers rather than through a central server. The architecture has three main layers:

  • JavaScript API – The developer-facing interface (getUserMedia, RTCPeerConnection, RTCDataChannel) that lets web apps access the camera, microphone, and network.
  • C++ Native Layer – Handles audio/video processing, encryption, and network transport.
  • Network Stack – Manages connectivity, including NAT traversal, packet loss recovery, and bandwidth estimation.

This design means the browser does the heavy lifting; servers are only used for signaling and, when necessary, media relay (TURN).

Signaling and SDP

Before any video flows, the two peers must exchange metadata about their capabilities and preferences. This exchange is called signaling and is not defined by WebRTC—developers choose any transport (WebSocket, HTTP, etc.). The format of the metadata is Session Description Protocol (SDP).

SDP is a text-based description containing:

  • Media types (audio, video, data)
  • Codecs (e.g., VP8, H.264, Opus)
  • Encryption keys (DTLS fingerprints)
  • Network candidates (IP addresses and ports)

Each peer creates an offer and receives an answer. This is the classic offer/answer model. The actual SDP is not human-friendly—it’s a long string of attributes—but it’s the backbone of negotiation.

ICE, STUN, and TURN

Most devices sit behind NATs (Network Address Translators) or firewalls, making direct connections difficult. Interactive Connectivity Establishment (ICE) is the framework WebRTC uses to find the best path between peers.

ICE gathers candidates—potential IP/port combinations—from three sources:

  • Host candidates – The device’s own IP address.
  • Server Reflexive candidates – Obtained from a STUN (Session Traversal Utilities for NAT) server, which reveals the public IP and port as seen from outside.
  • Relay candidates – Provided by a TURN (Traversal Using Relays around NAT) server, which relays media when direct connection fails.

STUN is lightweight and free; TURN is heavier and typically costs money. In practice, most WebRTC apps use STUN first and fall back to TURN only when necessary (e.g., symmetric NATs).

Media Streams and Tracks

In WebRTC, video and audio are handled as MediaStream objects containing one or more MediaStreamTracks. A track represents a single source (e.g., one camera, one microphone). Key terms:

  • getUserMedia – The API that prompts the user for permission and returns a stream from their camera/mic.
  • getDisplayMedia – Captures screen contents, used for screen sharing.
  • Track – Can be enabled/disabled, and its source can be replaced (e.g., switching cameras) without renegotiating.
  • RTCRtpSender / RTCRtpReceiver – Manage the sending/receiving of tracks over the network.

Modern WebRTC uses Unified Plan, where each track gets its own “m-line” in SDP, simplifying negotiation.

Codecs and RTP

Raw video is huge, so it must be compressed. Codecs encode and decode video/audio. Common WebRTC codecs:

  • VP8 – The original mandatory video codec, now optional but widely supported.
  • VP9 – Google’s successor, better compression but higher CPU usage.
  • H.264 – Widely used in hardware, mandatory in many browsers.
  • AV1 – Next-gen, royalty-free, excellent compression but requires recent hardware.
  • Opus – The standard audio codec, handles voice and music well.

Media is sent using Real-time Transport Protocol (RTP), typically over UDP. WebRTC also uses RTCP (RTP Control Protocol) for statistics and feedback, and SRTP (Secure RTP) for encryption.

Common Problems and Troubleshooting

Real-time video is sensitive to network conditions. Common issues and their causes:

  • No video/audio – Usually permission denied, wrong device, or track not added to the connection.
  • Black screen – Camera in use by another app, or track muted.
  • Echo – Often due to speaker volume too high or missing acoustic echo cancellation (AEC).
  • Lag or freezing – Network congestion, high packet loss, or insufficient bandwidth.
  • Connection failure – ICE failure, often because TURN is not configured or STUN is blocked.

Tools like getStats() provide metrics (round-trip time, packet loss, jitter) to diagnose issues. A common misconception is that WebRTC always works P2P; in reality, TURN relay is required for many real-world connections.

Security and Privacy

WebRTC is designed with security in mind:

  • Encryption – All media is encrypted with SRTP, and data channels use DTLS. This is mandatory, not optional.
  • Permissions – Access to camera/mic requires explicit user consent via the browser.
  • Certificate – DTLS uses self-signed certificates generated on the fly; the fingerprint is exchanged during signaling.
  • Privacy – With P2P, media doesn’t pass through a central server, but it may still be relayed via TURN. Also, IP addresses are visible to the other peer unless using a TURN server with anonymization.

Developers must handle signaling data securely to prevent session hijacking.

Frequently Asked Questions

What is the difference between STUN and TURN?

STUN helps a device discover its public IP and port, enabling a direct P2P connection. TURN relays media through a server when a direct connection is impossible (e.g., symmetric NAT). STUN is free and low-latency; TURN is more reliable but costs bandwidth and adds latency.

Is WebRTC truly peer-to-peer?

Yes, media flows directly between browsers in most cases. However, signaling always goes through a server, and if NAT traversal fails, TURN relays media. So it’s P2P “when possible,” but not guaranteed.

What codecs are mandatory in WebRTC?

Historically, VP8 and Opus were mandatory, but as of 2024, browsers support a range. H.264 is mandatory in many browsers for hardware compatibility. The exact set varies by browser and platform.

Can WebRTC work without a TURN server?

Yes, if both peers can establish a direct connection via host or server-reflexive candidates. TURN is only needed for restrictive NATs or firewalls. Many apps use TURN as a fallback to maximize connection success.

How do I choose a WebRTC server?

For signaling, any WebSocket or HTTP server works. For STUN, free public servers exist (e.g., Google’s). For TURN, you need a server with public IP and bandwidth; cloud providers offer TURN services, but you can self-host using open-source software like Coturn.

What is the difference between WebRTC and a regular video call?

WebRTC is a technology that enables real-time communication in browsers without plugins. A “regular” video call (e.g., Zoom) uses similar underlying principles but may use proprietary protocols and dedicated apps. WebRTC is open, standardized, and runs in any modern browser.