Design the browser client for a video conferencing product like Zoom or Google Meet.
Users join a meeting from a link, pick camera and microphone in a pre-join screen, then see participants in a grid or speaker layout. They can mute, turn video off, share their screen, chat, raise a hand and see who is speaking.
The interviewer adds:
Focus on the media architecture (topology and signalling), client components, adaptive quality, layouts, device handling, and the reliability, accessibility and observability of the client.
The defining constraint of video conferencing is real-time media under bad networks. Unlike video streaming, you cannot buffer for seconds: mouth-to-ear latency must stay under ~300 ms or conversation breaks down. So the front-end design is about choosing a media topology, controlling how much media each client sends and receives, and building a UI that stays responsive while decoding many video streams.
| Concern | Target |
|---|---|
| Join time | link click to seeing others < 3 s p50 |
| Latency | glass-to-glass < 300 ms p95 within a region (audio first) |
| Audio | no dropouts at up to 5% packet loss (Opus FEC/PLC); audio prioritised over video |
| Video | 720p for the active speaker on good links, graceful step-down to thumbnails or audio-only |
| Scale | 100 publishing participants; render up to 49 tiles; 10k receive-only viewers |
| CPU | < 50% of one mid-range laptop core budget per 9 visible tiles; device stays cool on 1-hour calls |
| Reconnection | ICE restart within 2–5 s after network change without rejoining |
| Accessibility | full keyboard control, screen reader announcements, captions, WCAG 2.2 AA |
Assume no E2EE by default (offered as a mode), evergreen browsers, sub-second latency for everyone.
| Topology | How it works | Client upload | Client download | Fits |
|---|---|---|---|---|
| Mesh (P2P) | every client sends to every other client | N−1 streams | N−1 streams | 1:1 and ≤ 4 people; lowest server cost; uploads explode beyond that |
| SFU (Selective Forwarding Unit) | each client uploads once; server forwards selected streams/layers to each receiver without decoding | 1 stream (with simulcast layers) | only what is shown | the industry standard for groups |
| MCU (Multipoint Control Unit) | server decodes, composites into one video, re-encodes | 1 | 1 | legacy/low-power endpoints; very expensive server CPU, adds latency, fixed layout |
Decision: an SFU for all group meetings, with an optional P2P path for 1:1 calls (lower latency, less server cost; switch to the SFU when a third person joins). Large webinars use SFU cascading (SFUs forwarding to edge SFUs) for sub-second delivery, or an HLS/LL-HLS broadcast for very large passive audiences where 2–5 s latency is acceptable.
WebRTC does not define signalling. We use a WebSocket to a signalling service for: join/leave, SDP offer/answer,
ICE candidates (trickle), participant metadata, and app events (chat, hand raise). Media flows over UDP via
RTCPeerConnection to the SFU. Connectivity uses ICE with STUN for reflexive addresses and TURN relays (UDP,
TCP and TLS over 443) for restrictive firewalls; corporate networks often force TURN/TLS, so TURN servers in every
region are mandatory, not optional.
| Component | Responsibility |
|---|---|
| Meeting shell (React) | routes, pre-join, layout, controls, panels, dialogs |
| Meeting store | participants, tracks, layout state, chat, roles; the UI's single source of truth |
| Signalling client | WebSocket, request/response correlation, reconnect, event dispatch |
| Media engine | RTCPeerConnection(s), transceivers, simulcast encodings, renegotiation, ICE restarts |
| Device manager | enumerate devices, permissions, devicechange, mute semantics, audio processing settings |
| Subscription manager | decides which remote tracks and which quality layer to receive based on layout and visibility |
| Video tile renderer | <video> elements per visible tile, attaching/detaching MediaStreams |
| Effects pipeline | background blur/replace using a segmentation model in a worker, via insertable streams |
| Stats/QoE monitor | polls getStats(), computes bitrate/loss/jitter/RTT, drives UI quality indicators and telemetry |
GET /meetings/:id), get a join token.getUserMedia for preview; show device pickers and a mic level meter (Web Audio AnalyserNode).sendonly) with simulcast encodings;
exchange SDP; trickle ICE.type ParticipantId = string;
interface Participant {
id: ParticipantId;
displayName: string;
avatarUrl?: string;
role: 'host' | 'cohost' | 'participant' | 'viewer';
joinedAt: number;
handRaisedAt?: number;
audio: { trackId?: string; muted: boolean };
video: { trackId?: string; muted: boolean; layers: VideoLayer[] };
screen?: { trackId: string; withAudio: boolean };
connectionQuality: 'good' | 'fair' | 'poor' | 'lost';
}
interface VideoLayer { rid: 'q' | 'h' | 'f'; width: number; height: number; maxBitrate: number }
interface MeetingState {
meetingId: string;
self: ParticipantId;
participants: Record<ParticipantId, Participant>;
order: ParticipantId[]; // stable order for the grid
activeSpeakers: ParticipantId[]; // most recent first, from SFU audio levels
pinned: ParticipantId | null;
layout: 'grid' | 'speaker' | 'sidebar';
page: number; // grid pagination
chat: ChatMessage[];
locked: boolean;
}
interface Subscription {
participantId: ParticipantId;
kind: 'video' | 'screen';
// what the UI needs; the SFU picks the layer
maxWidth: number;
maxHeight: number;
priority: 'high' | 'normal' | 'low';
}
MediaStream and RTCPeerConnection objects are not stored in React state; they live in the media engine,
keyed by track ID. The store holds serialisable metadata, and tiles look up the stream by ID.
GET /api/meetings/:id -> { id, title, requiresWaitingRoom, e2ee, hostName }
POST /api/meetings/:id/join { displayName } -> { token, signallingUrl, iceServers: [...], expiresAt }
type ClientMsg =
| { t: 'join'; token: string; capabilities: { codecs: string[]; simulcast: boolean } }
| { t: 'offer' | 'answer'; sdp: string }
| { t: 'ice'; candidate: RTCIceCandidateInit }
| { t: 'subscribe'; subs: Subscription[] } // replaces the full set, idempotent
| { t: 'mute'; kind: 'audio' | 'video'; muted: boolean }
| { t: 'chat'; clientMsgId: string; text: string }
| { t: 'raise-hand'; raised: boolean }
| { t: 'host-action'; action: 'mute' | 'remove' | 'lock'; target?: ParticipantId };
type ServerMsg =
| { t: 'joined'; self: Participant; participants: Participant[] }
| { t: 'participant-joined' | 'participant-updated'; participant: Participant }
| { t: 'participant-left'; id: ParticipantId }
| { t: 'offer' | 'answer'; sdp: string }
| { t: 'ice'; candidate: RTCIceCandidateInit }
| { t: 'active-speakers'; ids: ParticipantId[] }
| { t: 'bandwidth-estimate'; downlinkKbps: number }
| { t: 'chat'; message: ChatMessage }
| { t: 'request-unmute'; by: ParticipantId } // hosts cannot force-unmute
| { t: 'error'; code: 'MEETING_LOCKED' | 'REMOVED' | 'TOKEN_EXPIRED'; message: string };
interface VideoTileProps {
participantId: ParticipantId;
trackId?: string; // undefined renders avatar
mirrored?: boolean; // true for self-view only
fit: 'cover' | 'contain'; // contain for screen shares
isSpeaking: boolean;
onVisibleSizeChange?: (size: { width: number; height: number } | null) => void; // null when off-screen
}
sendEncodings: [{ rid: 'q', scaleResolutionDownBy: 4 }, { rid: 'h', scaleResolutionDownBy: 2 }, { rid: 'f' }].
The SFU forwards to each receiver the layer that fits its tile and bandwidth.scalabilityMode such as L3T3) achieves the same with one stream
of layered frames; more efficient upload, supported in Chromium and increasingly elsewhere. Use it where supported
with simulcast fallback.ResizeObserver) and visibility
(IntersectionObserver), and the subscription manager sends a debounced subscribe message. Off-screen tiles
are unsubscribed, a 160 px thumbnail never receives 720p. This is the biggest bandwidth and CPU lever the front end
controls.setParameters with active: false) to save upload and CPU.priority: 'high' / networkPriority on audio encodings), then the active speaker,
then screen share, then thumbnails.degradationPreference: maintain-resolution for screen share (text must be legible, framerate can drop),
maintain-framerate for camera.getStats() every 1–2 s: packetsLost, jitter, roundTripTime, availableOutgoingBitrate,
framesDropped, qualityLimitationReason (cpu vs bandwidth). If the limitation is CPU, reduce encoding layers or
disable background effects rather than bitrate.<video> element with srcObject; avoid re-mounting tiles when order changes (stable
keys, CSS grid order or transforms) because re-attaching streams causes black frames.document.visibilityState is hidden, which saves significant CPU.requestPictureInPicture() on a video element, or the Document Picture-in-Picture API
(Chromium) to pop out a mini meeting window with controls.NotAllowedError
(show how to re-enable in browser settings), NotFoundError (no camera) and NotReadableError (device in use by
another app).devicechange events: when headphones are plugged in, switch the output (setSinkId, where supported) and offer
the new mic. Persist preferred device IDs in localStorage.track.enabled = false keeps the device
light on; stopping the track releases it but re-acquiring takes time). Use enabled = false for audio (fast
unmute) and stop the camera track when video is off (privacy: light off).getUserMedia constraints; optional ML noise suppression
in an AudioWorklet.getDisplayMedia() must be triggered by a user gesture; tab/system audio availability varies by browser and OS.contentHint = 'detail' (or 'text') so the encoder favours sharpness.track.onended) and update state.Segmentation (a small ML model via WebGL/WebGPU or WebAssembly SIMD) runs per frame in a worker using
MediaStreamTrackProcessor/VideoTrackGenerator (insertable streams for raw media, Chromium; Safari has its own
variants) or a canvas pipeline fallback. Budget ~5–8 ms per frame; auto-disable when qualityLimitationReason is
cpu.
iceconnectionstatechange to disconnected/failed or on online events; keep the meeting UI and
show "Reconnecting…" instead of dropping the user.RTCRtpScriptTransform) using keys exchanged out of band; the SFU still
routes by headers. Cost: no server-side recording or transcription.aria-pressed for mute toggles) and a keyboard shortcut
(e.g. Ctrl/Cmd+D mute) listed in a help dialog; shortcuts never conflict with screen reader keys.getStats() summaries sent at end of call (and periodically for long calls).Why not mesh for 10 people? Each client would upload 9 copies of its video (e.g. 9 × 1 Mbps) and encode them separately; home uplinks and laptop CPUs cannot sustain it.
How do you detect the active speaker? The SFU reads audio level RTP header extensions without decoding and
publishes a ranked list; the client can also use getSynchronizationSources() audio levels for local smoothing.
How do you support 10,000 webinar viewers? Viewers are receive-only; use cascaded SFUs near viewers, or transcode the stage to LL-HLS for 2–5 s latency at CDN cost. Q&A goes through the signalling channel, not media.
How would you implement recording? A server-side bot joins as a hidden participant and composites streams, or the SFU writes tracks for later composition. Recording requires consent notices for all participants.
What changes with E2EE? Frame encryption via encoded transforms, key rotation when participants leave, no server features that need plaintext media, and verification UI (safety codes).
How do you test this? Fake media devices in Chromium (--use-fake-device-for-media-stream), network shaping
(packet loss, latency) in CI with multiple headless clients, and synthetic monitoring calls in every region.
Spotted a mistake or a rights concern? Report an issue