Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 36 ยท Getting Started

What Is WebRTC?

Learn what WebRTC is, what it can do (video calls, voice, file transfer, games), how it differs from WebSockets and HTTP, and what this course will teach.

WebRTC stands for Web Real-Time Communication. It is a set of browser APIs and network protocols that let two browsers (or a browser and a server) exchange audio, video and arbitrary data with very low delay, usually directly, without sending every packet through your web server. When you join a video meeting in a browser tab, share your screen, or play a browser game with a friend, WebRTC is often doing the work.

Before WebRTC, real-time audio and video in a browser needed plug-ins such as Flash. Today every major browser ships WebRTC, and it is also available in mobile apps and server libraries. This first lesson explains what WebRTC is made of, what problems it solves, and how this course is organized.

What runs on this site. The browser examples in this course run in a sandboxed preview. Two RTCPeerConnection objects inside the same page can really connect to each other and exchange data, audio and video frames, so most examples are live. What the preview cannot do: it has no camera or microphone permission, and it cannot reach another computer. Anything that needs a camera, a second device or a server (signalling servers, STUN/TURN, media servers) is shown as read-only code with clearly labelled stand-ins. Each lesson says which is which.

What WebRTC gives you

WebRTC bundles four abilities:

  1. Capture media from a camera, a microphone or the screen (getUserMedia, getDisplayMedia).
  2. Connect two endpoints through firewalls and NATs (RTCPeerConnection, ICE).
  3. Send media with adaptive quality, echo cancellation, jitter buffering and encryption (RTP/SRTP, codecs such as VP8, VP9, AV1, H.264 and Opus).
  4. Send data peer to peer, reliably or unreliably, with low latency (RTCDataChannel).

All of this is encrypted by default. There is no unencrypted mode in a browser: media is protected with SRTP and data with DTLS, a topic we return to in the security chapter.

Typical uses

  • Video and voice calls: meetings, telehealth, tutoring, customer support widgets.
  • Live streaming with sub-second delay, such as auctions, interactive broadcasts and cloud gaming.
  • Peer-to-peer file transfer without uploading to a server first.
  • Multiplayer games that need fast, possibly lossy messages (a position update that arrives late is worthless).
  • Remote control of devices, drones and cameras, where latency matters more than perfect picture quality.
  • Collaboration: shared cursors, whiteboards and document sync.

WebRTC versus HTTP and WebSockets

HTTP is request and response: the client asks, the server answers. WebSockets keep one long-lived TCP connection open between a browser and a server so either side can send messages at any time. Both go through a server and both run on TCP, which guarantees ordered delivery by re-sending lost packets. That is wonderful for a chat message and terrible for live video, because waiting for a lost frame makes everything after it late.

WebRTC runs mostly on UDP. A lost packet is simply gone, and the application decides what to do (hide it, ask for a new key frame, lower the quality). WebRTC also connects peers directly when it can.

Question HTTP WebSocket WebRTC
Who talks to whom? Client to server Client to server Peer to peer (or via a media server)
Transport TCP TCP Mostly UDP
Lost data Re-sent Re-sent Your choice
Built-in audio/video No No Yes
Needs a server to start Yes Yes Yes, for signalling only

That last row is the surprise of WebRTC: peers need a way to find and introduce each other, and WebRTC deliberately does not define it. You write (or rent) a signalling channel, often a WebSocket. After the introduction, the media and data flow peer to peer.

The big picture

flowchart LR
  A["Browser A"] <-->|"signalling (WebSocket, HTTP...)"| S["Signalling server"]
  B["Browser B"] <-->|"signalling"| S
  A <==>|"encrypted media and data (UDP)"| B
  A -.->|"ICE: discover public address"| T["STUN / TURN server"]
  B -.->|"ICE"| T

Signalling (thin lines) sets up the call; media and data (thick line) then flow directly. STUN and TURN help when peers sit behind NATs.

The three parts you will keep meeting

  • Signalling is how peers exchange the information needed to connect: who they are, which codecs they support, where they can be reached. You choose the channel. Chapter 2 is about this.
  • ICE, STUN and TURN find a network path between the peers. STUN tells a peer its public address; TURN relays traffic when no direct path exists. Chapter 4 and chapter 6.
  • Media and data: tracks from getUserMedia go into an RTCPeerConnection; custom data goes through RTCDataChannel. Chapters 3 and 5.

A first taste

This tiny page creates a peer connection and prints some facts about your browser. It needs no camera and no server.

Is WebRTC available?

The codec list depends on your browser, but you should see VP8 and opus in every modern one. signalingState starts as stable and connectionState as new: you will learn what those mean in the connection lifecycle.

A tiny conversation between two peers

Here is the smallest possible proof that WebRTC works: two peer connections in one page exchange a message. Do not worry about the details yet; the next lesson explains every line.

Two peers, one page

A short history

WebRTC was open-sourced by Google in 2011 and standardized by the W3C (APIs) and IETF (protocols). It reached all major browsers by about 2018 and became an official W3C Recommendation in January 2021. The APIs keep growing: encoded transforms, insertable streams, scalable video coding modes and more arrive regularly, so always check browser support for newer features.

What you will learn

This course starts with the concepts and the handshake (chapters 1 and 2), then media capture and the peer connection (3 and 4), data channels (5), the servers you need for production (6), quality and debugging (7), security and application design (8) and finally complete projects (9).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does WebRTC deliberately NOT define?

    WebRTC leaves signalling to you. You can use WebSockets, HTTP, or even copy and paste, as long as the peers can exchange connection information.
  2. 2. Why is UDP a better fit than TCP for live video?

    Waiting for a re-sent packet delays everything behind it. With UDP the application decides whether a lost packet matters.
  3. 3. After the peers are connected, where does WebRTC media normally flow?

    Signalling is only the introduction. Media and data go peer to peer, or through a TURN relay or media server when a direct path is impossible.
  4. 4. Can WebRTC media be sent unencrypted in a browser?

    Browsers always use SRTP for media and DTLS for data channels.

Summary

  • WebRTC lets browsers exchange audio, video and data in real time, mostly peer to peer over UDP.
  • It combines capture, connection (ICE), media transport (SRTP) and data channels (SCTP over DTLS).
  • A signalling channel, which you provide, introduces the peers; it is not part of WebRTC itself.
  • Everything is encrypted by default.
  • In this course, same-page peer connections run live; camera, multi-device and server topics are read-only with labelled stand-ins.

Next: Your First Loopback Call