Skip to content

Commit 61cf28c

Browse files
authored
Add markdown files for basic explanation on WebRTC (#756)
1 parent 9f5d8c4 commit 61cf28c

File tree

2 files changed

+243
-0
lines changed

2 files changed

+243
-0
lines changed

webrtc-explained.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# WebRTC Core Concepts
2+
3+
Below are the core components you see in WebRTC libraries (including Rust implementations like webrtc-rs).
4+
5+
## Media
6+
Handles audio and video streams:
7+
- microphone
8+
- webcam
9+
- screen share
10+
- encoding/decoding (Opus, VP8, H264, etc.)
11+
- track pipelines
12+
- jitter buffers
13+
14+
Represents the actual media content.
15+
16+
## Interceptor
17+
Middleware for packet flow in WebRTC.
18+
19+
Used for:
20+
- congestion control
21+
- retransmissions
22+
- analytics
23+
- logging
24+
- bitrate adaptation
25+
- simulcast filters
26+
27+
## Data
28+
Refers to WebRTC Data Channels.
29+
30+
Supports:
31+
- text and binary
32+
- reliable or unreliable delivery
33+
- ordered or unordered delivery
34+
35+
Used for chat, game sync, file transfer, etc.
36+
37+
## RTP (Real-time Transport Protocol)
38+
Packet format for real-time media transmission.
39+
40+
Includes:
41+
- timestamps
42+
- sequence numbers
43+
- SSRC identifiers
44+
45+
Carries media data.
46+
47+
## RTCP (RTP Control Protocol)
48+
Feedback channel for RTP.
49+
50+
Reports:
51+
- packet loss
52+
- jitter
53+
- round trip time
54+
- bandwidth
55+
- keyframe requests
56+
57+
## SRTP (Secure RTP)
58+
Encrypted RTP for media.
59+
60+
Uses keys negotiated via DTLS.
61+
62+
## SCTP (Stream Control Transmission Protocol)
63+
Protocol used by WebRTC Data Channels.
64+
65+
Provides:
66+
- multiple streams
67+
- partial reliability
68+
- no head-of-line blocking
69+
70+
Runs inside DTLS.
71+
72+
## DTLS (Datagram TLS)
73+
TLS over UDP.
74+
75+
Used for:
76+
- verifying peer identity
77+
- negotiating encryption keys
78+
- securing SCTP
79+
- securing SRTP
80+
81+
## mDNS
82+
Masks local LAN IP addresses for privacy (e.g. *.local hostnames).
83+
84+
## STUN
85+
Discovers:
86+
- public IP
87+
- public port
88+
- NAT mappings
89+
90+
Used for peer-to-peer connectivity.
91+
92+
## TURN
93+
Relay server fallback when direct P2P isn't possible.
94+
95+
Used in restrictive NAT environments.
96+
97+
## ICE (Interactive Connectivity Establishment)
98+
System that tests multiple network paths and selects the best one.
99+
100+
Uses:
101+
- host candidates
102+
- STUN candidates
103+
- TURN relay candidates
104+
105+
Continuously monitors connectivity.
106+
107+
## SDP (Session Description Protocol)
108+
Text-based connection description used for signaling.
109+
110+
Contains:
111+
- codecs
112+
- ICE credentials
113+
- DTLS fingerprints
114+
- media types
115+
- transport configs
116+
117+
Used in offers and answers.
118+
119+
## Util
120+
Shared helper utilities.
121+
122+
Commonly includes:
123+
- random generators
124+
- buffer helpers
125+
- parsers
126+
- timers
127+
- UUID helpers
128+

webrtc-signaling-explained.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# WebRTC Signaling Explained
2+
3+
## What is Signaling?
4+
5+
Signaling is the process where two peers exchange the information required to establish a WebRTC connection.
6+
It happens *before* any direct peer connection is possible.
7+
8+
This includes exchanging:
9+
- SDP Offer
10+
- SDP Answer
11+
- ICE Candidates
12+
13+
14+
## Why Signaling Is Needed
15+
16+
WebRTC peers cannot discover each other on their own.
17+
18+
They need to:
19+
- agree on codecs and media setup
20+
- share network information
21+
- exchange security fingerprints
22+
23+
Signaling provides this exchange.
24+
25+
26+
## What Signaling Is Not
27+
28+
Signaling is **not**:
29+
- part of WebRTC itself
30+
- standardized
31+
- a fixed protocol
32+
- tied to any transport
33+
34+
35+
## Signaling Transport Options
36+
37+
Signaling can use any transport, including:
38+
- WebSockets
39+
- HTTP
40+
- REST
41+
- SSE
42+
- MQTT
43+
- TCP
44+
- UDP
45+
- Redis pub/sub
46+
- anything else
47+
48+
49+
## What Information Gets Exchanged
50+
51+
### SDP (Session Description Protocol)
52+
Contains:
53+
- codecs
54+
- media directions
55+
- ICE usernames/passwords
56+
- DTLS fingerprints
57+
- transport description
58+
- media streams
59+
60+
### ICE Candidates
61+
Contain:
62+
- IP addresses
63+
- ports
64+
- transport protocol
65+
- candidate priority
66+
67+
68+
## Typical Signaling Flow
69+
70+
1. Peer A creates PeerConnection
71+
2. Peer A generates Offer (SDP)
72+
3. Peer A sends Offer to Peer B using the signaling channel
73+
4. Peer B sets remote Offer
74+
5. Peer B generates Answer (SDP)
75+
6. Peer B sends Answer back via signaling channel
76+
7. Both sides exchange ICE Candidates
77+
8. ICE finds a working route
78+
9. Peers connect directly
79+
80+
81+
## Signaling Server Responsibilities
82+
83+
A signaling server:
84+
- relays Offer
85+
- relays Answer
86+
- relays ICE candidates
87+
88+
It does *not*:
89+
- relay audio/video (RTP)
90+
- relay data channel traffic
91+
- stay involved after connection succeeds
92+
93+
94+
## Server After Connection
95+
96+
Once the WebRTC connection is established:
97+
- the signaling server is no longer required
98+
- peers communicate directly (unless TURN is used)
99+
100+
101+
## Simplified Diagram
102+
103+
Peer A ---- Offer/Answer/ICE ----> Signaling Server ---- Offer/Answer/ICE ----> Peer B
104+
105+
Peer A <------------------------------------- P2P ------------------------------------> Peer B
106+
107+
108+
## Summary
109+
110+
- Signaling exists only to bootstrap WebRTC.
111+
- It exchanges Offer, Answer, and ICE candidates.
112+
- It is not part of WebRTC protocol.
113+
- You can use any transport you want.
114+
- Once done, peers can communicate directly.
115+

0 commit comments

Comments
 (0)