Lesson 8 of 9 · 29m
Bandwidth, Congestion Control, and Simulcast
Use sender adaptation, receiver feedback, simulcast/SVC, and layout-aware subscriptions to preserve call quality under constrained and variable networks.
Real-time media quality is a controlled degradation problem. The network will drop packets, jitter will spike, a user will upload over a phone hotspot, and the correct answer is never "send everything anyway." WebRTC includes congestion control, but applications still make the highest-leverage decisions: resolution, frame rate, bitrate, layer selection, and which streams deserve bandwidth at all.
The feedback loop in one picture
sender -> network loss/jitter -> receiver feedback
^---- bitrate/resolution/framerate adaptation ----┘WebRTC implementations use receiver reports, transport-wide congestion control, loss statistics, and delay estimates to adjust sending behavior. Your job is to give the encoder reasonable bounds and avoid product decisions that fight the transport.
Do not confuse capture quality with send quality
You can capture 720p and send lower; you cannot sustainably send more than the network allows. Browser encoding adapts, but explicit caps help align cost:
const sender = pc.getSenders().find(s => s.track?.kind === "video");
const params = sender.getParameters();
params.encodings[0].maxBitrate = 1_200_000;
params.encodings[0].maxFramerate = 24;
params.encodings[0].scaleResolutionDownBy = 1.0;
await sender.setParameters(params);Those parameters are guidance to the browser, not a service-level guarantee. Verify actual outbound bitrate and frame dimensions in getStats().
Simulcast sends several versions at once
With simulcast, the sender publishes multiple layers of the same video:
pc.addTransceiver(videoTrack, {
direction: "sendonly",
streams: [videoStream],
sendEncodings: [
{rid: "f", maxBitrate: 1_500_000, scaleResolutionDownBy: 1},
{rid: "h", maxBitrate: 600_000, scaleResolutionDownBy: 2},
{rid: "q", maxBitrate: 180_000, scaleResolutionDownBy: 4},
],
});An SFU can forward the full layer to a large tile and the quarter layer to thumbnails. The cost moves to the sender's encode and uplink, which is why simulcast is powerful but not free.
SVC trades sender fan-out for layer dependency
Scalable Video Coding encodes temporal and spatial layers in one stream. The SFU chooses which layers to forward based on bandwidth and dependency structure. SVC can be more efficient than independent simulcast encodes, but codec support, hardware acceleration, packetization behavior, and decoder compatibility are less uniform. VP9 and AV1 deployments commonly discuss SVC; H.264 in browsers often centers on simulcast instead.
Layout-aware subscription is application congestion control
The biggest video tile matters. A sixteen-person grid does not need sixteen high-resolution streams. Use active speaker, pinned participant, visible viewport, and screen share priority to decide subscriptions:
screen share full or high spatial layer, low motion tolerance
active speaker large medium/high layer
visible thumbnails low layer
offscreen participants audio only or paused video
dominant speaker only avoid re-subscribing on every coughAggressively switching layers on every speaker change causes keyframe storms, decode instability, and visual churn. Hysteresis is your friend: require the speaker to remain dominant briefly before upgrading their layer.
Packet loss and jitter have different signatures
Loss causes missing frames and sometimes artifacts until a keyframe arrives. Jitter causes irregular arrival and decoding delay. High RTT makes interaction feel sluggish even when image quality is good. getStats() gives you separate signals:
{
packetsLost: report.packetsLost,
jitter: report.jitter,
framesPerSecond: report.framesPerSecond,
freezeCount: report.freezeCount,
}Do not collapse all of this into a single green/yellow/red indicator without retaining the raw cause. "Bad network" is not a diagnosis.
Field notes
- Audio quality deserves priority over video sharpness. Users tolerate soft video far better than choppy speech.
- Screen share wants resolution and legibility more than frame rate; camera video usually wants smoother motion.
- A bitrate cap is not a bandwidth reservation. Congestion feedback still controls actual throughput.
- Simulcast does not fix a camera source that is already overloaded. If capture drops frames, encoded layers inherit the problem.
Was this lesson helpful?