What is WebRTC?
WebRTC stands for:
Web Real-Time Communication
It is a collection of:
- Browser APIs
- Network protocols
- Security mechanisms
- Media processing technologies
that allows applications to exchange:
- Audio
- Video
- Data
in real time.
The keyword here is:
Real Time
Real time means communication hapens almost instantly.
For example:
Chat Application
You send a message
↓
Friend receives it instantlyLatency:
~10ms - 100msVideo Call
You speak
↓
Friend hears almost immediatelyLatency:
<150ms preferredMultiplayer Game
Player moves
↓
Other players see movement instantlyLatency:
10ms - 50ms idealWebRTC was built specifically for these kinds of applications.
Why Was WebRTC Created?
To understand WebRTC, we must first understand the limitations of traditional web communication.
Traditional Web Model
When you open a website:
Browser
|
|
ServerExample:
GET /productsServer responds:
{
"products": []
}This works perfectly for:
- E-commerce websites
- Blogs
- Dashboards
- Content management systems
- Banking portals
because communication is request-response.
The Problem
Suppose two users want to video call.
Traditional Architecture
User A
|
Server
|
User BEvery audio packet:
A -> Server -> BEvery video packet:
A -> Server -> BThis introduces problems.
Problem 1: High Latency
Every network hop adds delay.
User A
|
Server
|
User BThe server becomes a middleman.
Instead of:
A -> Bwe get:
A -> Server -> Bwhich is slower.
For voice communication:
50ms delay = acceptable
300ms delay = annoying
1 second delay = terribleProblem 2: High Cost
Imagine:
1000 usersall in video calls.
Server bandwidth becomes enormous.
Example:
Eacch user sends:
2 Mbps videoBandwidth:
1000 × 2 Mbps upload
1000 × 2 Mbps downloadThe company pays for all traffic.
This becomes expensive.
Problem 3: Scalability
Traditional architecture scales poorly for media.
Example:
Netflixworks because user only download.
But video conferencing:
Everyone uploads
Everyone downloadswhich is much harder.
Problem 4: Browser Limitations
Before WebRTC, browsers relied on:
- Flash
- Java Applets
- Sliverlight
for camera and microphone access.
Problems:
Security vulnerabilities
Plugins required
Poor user experienceA modern solution was needed.
The Goal of WebRTC
WebRTC was designed with one core goal:
Allow browsers to communicate directly.
Instead of:
Browser A
|
Server
|
Browser Bwe want:
Browser A
|
|
Browser BThis is called:
Perr-to-Peer Communication
Or
P2P
What Does Peer-to-Peer Mean?
Peer means:
Equal participantNetiher browser acs as a server.
Both are equal.
Example:
Laptop <-> LaptopPhone <-> PhoneBrowser <-> BrowserData flows directly between participants.
Is WebRTC Completely Serverless?
A common misconception.
Many developers think:
WebRTC = No ServersThis is wrong.
WebRTC still requires servers.
A realistics architecture:
Signaling Server
|
|
--------------------------------
| |
| |
v v
Browser A <------WebRTC------> Browser BServers are needed for:
- User discovery
- Authentication
- Signaling
- Room management
- TURN relay
- Recording
- Analytics
What WebRTC removed is:
Media relay (when possible)Core Capabilities of WebRTC
WebRTC provides three major capabilities.
1 Audio Communication
Example:
Voice CallsWhatsApp Calling
Discord Voice
Teams Audio2 Video Communication
Example:
Video CallsGoogle Meet
Zoom3 Data Communication
Many developers don't know this.
WebRTC can transfer:
Text
Files
Game State
JSON
Binary Datadirectly:
Example:
Browser A
|
DataChannel
|
Browser BNo HTTP request required.
Core APIs
WebRTC exposes three main browser APIs.
getUserMedia()
Access camera and micorphone.
Example:
const stream =
await navigator.mediaDevices.getUserMedia({
video: true,
audio: true
});Returns:
MediaSteamcontaining media tracks.
RTCPeerConnection
Creates peer connection.
const peer =
new RTCPeerConnection();Responsible for:
- Audio transport
- Video transport
- Encryption
- Connectivity
RTCDataChannel
Creates data connection.
const channel =
peer.createDataChannel("chat");Used for:
- Messages
- Files
- Game Data
WebRTC vs HTTP
HTTP:
Client -> ServerDesigned for:
Pages
APIs
ResourcesCommunication style:
Request -> ResponseWebRTC:
Client <-> ClientDesigned for:
Audio
Video
Real-Time DataCommunication style:
Continuous
Bidirectional
Leave a comment
Your email address will not be published. Required fields are marked *
