Protocol guide
Voice and video media
How a call's microphone, shared sound, screen video and webcam are framed, sent, buffered, adapted and end-to-end encrypted on the voice-dc/1, video-dc/1 and sfu-rtp/1 media profiles.
Specification: 16 Audio, 17 Screen share and webcam, 18 Media end-to-end encryption
Calls covers joining a call, leases, the relay connection and its data channels. This page covers what travels on those channels afterwards: the binary audio and video formats, what a sender may send and when, how a receiver buffers and plays it, and how secure calls protect it with SFrame keyed from the context's MLS group.
Three documents own this material: document 16 (audio), document 17 (screen share and webcam) and document 18 (media end-to-end encryption). None defines an HTTP endpoint or a WebSocket event. Their wire surface is binary messages on the sv-audio and sv-video data channels, payload kinds of call.media_feedback, the media.attestation control message, RTP on the SFU route, and diagnostics members. Problems are silent drops counted in diagnostics, never warnings (17 §1.1).
Full and Web clients implement everything. A relay validates and forwards frames per recipient and never decodes or decrypts. Media is optional for bots, but a bot that sends audio meets 16 §4, §5, §7.5, §8 and §12.3, a bot that handles video must support VP8, and a bot in a secure call implements all of 18 (16 Conformance, 17 §1.1, 18 Conformance).
Sources and media processes
sourceId |
Source | Relay | SFU route | Lease list |
|---|---|---|---|---|
| 0 | Microphone | voice-dc/1 |
never | audio |
| 1 | Screen video | video-dc/1 |
sfu-rtp/1 |
video |
| 2 | Screen or application sound | voice-dc/1 |
sfu-rtp/1, only with source 1 |
audio |
| 3 | Webcam | video-dc/1 |
sfu-rtp/1 |
video |
Values 4–15 are reserved, and receivers and relays drop them (18 §4.2). Clients never send media to each other: every frame goes through the hosting server's relay, or through its SFU for sources 1–3 on the SFU route, in every context and security mode (16 §8, 17 §13.1, 18 §8.1 item 6). Other participants therefore never learn your IP address from a call; only the hosting server's relay and SFU see it (16 §15 item 14, 17 §16 item 10).
A media process is one run of your media engine for one call. A new one starts at every join, every rejoin (planned or not), the restart after your own MLS resync, and every engine restart (16 §7.5 L5). Each has:
- a fresh 32-bit
joinNoncefrom a CSPRNG, drawn in insecure calls too; - a stream generation
gen = joinNonce mod 4096, in cleartext so receivers see that your media restarted; - a reference instant
T0on your audio clock. Audio timestamps count 48 kHz periods fromT0and video timestamps 90 kHz periods from the sameT0, which lines up screen sound with screen video without extra signalling (17 §4.4).
Redraw joinNonce if its gen equals that of your previous media process in the call or of any you started in the last 60 s (16 §4.5.1).
The voice-dc/1 frame
sv-audio is unordered with maxRetransmits = 0, so a late frame is lost instead of delaying the frames behind it. Each data-channel message is one frame (16 §4.1). Version 1 has one type, vt = 0x10; drop anything else silently (16 §4.2).
| Octets | Field | Notes |
|---|---|---|
| 0 | vt |
0x10 |
| 1 | flags |
C 0x80, S 0x40, E 0x20, D 0x10; low nibble reserved, send 0 |
| 2–3 | pid |
Your participant index |
| 4–5 | sourceId (high 4 bits), gen (low 12 bits) |
sourceId 0 or 2 only |
| 6–7 | sequence |
uint16, per stream |
| 8–11 | timestamp |
uint32, 48 kHz from T0 |
| 12– | payload |
One Opus packet, or its SFrame ciphertext in a secure call |
Octets 0–11 are the route header. It is never encrypted; in a secure call it is the SFrame metadata, so it is authenticated (16 §4.3). Integers are big-endian.
| Flag | Meaning (16 §4.4) |
|---|---|
| C | 1 exactly in a secure call, so a modified client can't inject plain audio into one |
| S | First frame of a talkspurt; the receiver re-anchors playout |
| E | Last frame of a talkspurt; the receiver plays silence with no concealment |
| D | Opus DTX or comfort noise in open mic; missing frames after it are not loss. Never with S or E, never on source 2 |
sequence starts at 0 per stream and counts frames actually created. timestamp counts capture time, so it keeps advancing while nothing is sent; a 20 ms packet advances it by 960. A gap in sequence means loss; a gap in timestamp alone means nothing was sent. Calls have no length limit, so extend sequence to 64 bits and compare timestamps with RFC 1982 serial arithmetic (16 §4.5). The Opus packet is at most 1,000 octets, the message at most 1,100, and anything under 13 octets is dropped (16 §4.8).
Test vector 1 of 16 §4.11: an insecure microphone frame starting a talkspurt, joinNonce 0x8F3C12A5, pid 7, sequence 0, captured 1,000 ms after T0:
10 40 00 07 02 a5 00 00 00 00 bb 80 48 0b e4 55Receiver validation (16 §4.9.1). Drop silently, counting invalidDrops, when:
vtor the size is wrong, orsourceIdisn't 0 or 2;pidis your own, or is in neither the roster nor the newest accepted tick'slisteners;- the C flag doesn't match the call's mode, or D is combined with S, E or source 2;
- in a secure call, the KID's source, leaf or
joinNoncedoesn't match the route header.
The tick's listeners is accepted because a newcomer's first frames often arrive before its roster event. In a secure call a frame from a pid that isn't in the roster yet can't have its KID leaf checked, so hold it undecrypted until the roster entry arrives, for at most 200 ms and never past its playout deadline; after that it is lost, not invalid. A relay checks only size and vt, that pid is the one its RelayTicket bound to the connection, sourceId, and the C flag (16 §4.9.2).
Opus profiles
| Microphone (16 §5.1) | Application sound (16 §5.2) | |
|---|---|---|
| Application | OPUS_APPLICATION_VOIP |
OPUS_APPLICATION_AUDIO |
| Channels | Mono | Stereo, or mono for a mono source |
| Bandwidth | Wideband; fullband with "High-quality voice" | Fullband |
| Frame | 20 ms, one per packet | 20 ms, one per packet |
| Bitrate | 32 kbit/s (16–48; 32–64 high-quality) | 96 kbit/s stereo, 64 mono (48–128) |
| Mode | Secure: CBR (MUST). Insecure: constrained VBR | Secure: CBR (MUST). Insecure: VBR allowed |
| In-band FEC | MUST | SHOULD |
| DTX | Only in open_mic |
Never; silence gating instead |
Secure contexts only
Every encoder runs at constant bitrate in a secure call, because variable-bitrate packet sizes reveal spoken phrases and SFrame doesn't hide sizes (16 §5.5).
You MAY lower the microphone bitrate, never below 16 kbit/s, only for your own uplink congestion (bufferedAmount above 2,400 octets for 1 s), and never because of listener reports, so one listener's bad network can't degrade everyone (16 §5.1).
Listeners report loss with the audio_loss kind (AudioLossFeedback) about every 2 s per stream, never more than once per second, through the relay on your sv-control channel (16 §4.7):
{ "t": "call.media_feedback", "from": 3, "to": 7,
"d": { "kind": "audio_loss", "sourceId": 0, "lossPermille": 100, "latePermille": 20,
"bufferTargetMs": 60, "received": 90 } }The sender sets OPUS_SET_PACKET_LOSS_PERC to 10 with no report in the last 6 s, otherwise to clamp(ceil(p / 10), 5, 25) with p the largest accepted lossPermille in that window (16 §5.3). The 25 % cap bounds what a malicious listener can make you spend on redundancy.
In open mic, send the first DTX packet after speech with D, suppress the rest, send comfort-noise updates with D, and put S on resumed speech. Stop source 2 after 1 s of digital silence, ending with E (16 §5.4). Decoders take packet duration from the TOC, handle 10–60 ms packets and MUST be robust against malformed input (16 §5.6). Echo cancellation is on by default and its reference includes everything played for the call; shared-sound capture MUST exclude the call's own playout (16 §6).
Transmit gate and push-to-talk
The gate is a pure function in the audio engine that decides, sample by sample, whether microphone audio may be sent. It implements D-012: the app never looks as if it is transmitting when the user isn't heard, and nothing captured while the user believed they weren't heard is sent later (16 §7.3). Modes are ptt, vad (the default) and open_mic.
intent = (mode = ptt AND pttDown AND NOT userMuted)
OR (mode = vad AND vadActive AND NOT userMuted)
OR (mode = open_mic AND NOT userMuted)
able = callState = connected AND routeUp AND leaseState = covered AND keysOk AND captureOk
ableShare = callState = connected AND routeUp AND leaseState = covered AND keysOkShare AND shareCaptureOk
transmit = intent AND able (source 0)
sendShare = shareActive AND ableShare (source 2)Evaluate it on every input change and at least every 10 ms, and apply PTT, mute and mode changes within 20 ms. It runs on the audio engine's thread and clock, so a stalled UI can't hold it open: when ticks stop, leaseState goes stale and the gate closes. routeUp requires a usable relay connection (sv-audio open, ICE not disconnected or failed, a message from the relay in the last 1,500 ms, bufferedAmount not above 6,000 octets for 200 ms), so "not heard" shows within about 1.5 s instead of after the 5 s relay failure timeout (16 §7.2). In a secure call a missing send key makes keysOk false.
Talkspurts (16 §7.4). On opening, reset the encoder, align frames to the first sample and set S. When intent ends, send the partial frame up to the release instant, faded over 2.5 ms and padded with silence, with E; push-to-talk has no release hangover. When able ends instead, discard everything unsent and send no E.
Live audio only (16 §7.5):
- L1 Nothing captured while the gate was closed is sent, except up to 60 ms of
vadpre-roll captured while unmuted and able. - L2 Discard a frame whose first sample is more than 100 ms old.
- L3 While
bufferedAmountexceeds 6,000 octets, discard new frames until it falls to 1,200 or less. - L4 Flush unsent audio when ability is lost.
- L5 Every media process has new streams.
- L6 Never send faster than real time to catch up.
Voice activation measures 20 ms windows against θ = clamp(N + 10 dB, −60 dBFS, −20 dBFS), starts after 3 windows above it (sent as pre-roll) and stops after 30 at or below it (16 §7.6). If you can't observe the PTT control (lost focus, no global shortcut, hidden page), treat it as released and show a persistent hint. A low-level input hook MUST discard every other event at once and be removed outside calls and outside ptt mode, so it can't become a keylogger (16 §7.7).
The engine mutes vad and open_mic users itself when the call enters reconnecting (muteReason rejoin; they stay muted after the rejoin), when the VoiceLease audioBlockedBy becomes non-null (user), and after an OS audio interruption longer than 2 s (interruption). ptt users change nothing: if PTT is held when a rejoin completes, transmission starts at once with live audio. Planned migrations keep the gate open and switch media process at a frame boundary, E on the old stream and S on the new (16 §7.4, 16 §7.8, 16 §7.9). Report every userMuted change as selfMuted on PATCH /v1/contexts/{ctx}/call/participants/{pid}.
TalkState
TalkState is the (state, reason, blockedBy) triple that drives the talk and mute indicators. Compute it in the same evaluation as the gate and deliver changes within 100 ms; first match wins (16 §7.10):
- not in a call:
(off, -); transmit:(transmitting, -);- muted and not holding PTT:
(muted, muteReason); - wants to talk:
(not_heard, R),Rthe first ofmuted,not_allowed,connecting,reconnecting,waiting_for_keys,no_microphonethat applies; - otherwise
(idle, I).
blockedBy accompanies not_allowed: no_permission, muted_for_everyone, server_muted, timed_out or other. A UI that receives an unknown value MUST show not_heard. The D-012 timeline of 16 §7.11, PTT pressed at 0 s:
| Time | Event | TalkState | Sent |
|---|---|---|---|
| 5.000 s | Drop detected | (not_heard, reconnecting) |
Partial frame discarded |
| 6.000 s | PTT released | (idle, reconnecting) |
— |
| 7.000 s | PTT pressed | (not_heard, reconnecting) |
Nothing |
| 8.200 s | Rejoin completes | (transmitting, -) |
New gen, sequence 0, S |
Delivering and receiving audio
A frame is encoded once, encrypted once, and sent as one copy on your relay connection's sv-audio channel, or to both relays during a planned relay migration (16 §8, 16 §8.1). The relay forwards the identical bytes to everyone in listeners except you; source 2 also needs a relay.subscribe. The relay drops a frame for one recipient when that recipient has more than 8,000 octets buffered or the frame waited 60 ms, so one slow listener never affects another, and caps what each (connection, sourceId) sends it at 55 messages and 24,000 octets per second (16 §8.1). Receivers drop duplicate copies by extended sequence number over at least the last 128 (16 §8.2). Sound-only source 2 always uses voice-dc/1 through the relay, and receivers subscribe to it automatically (16 §8.3).
Secure contexts only
A frame changes no receiver state, including the duplicate record, until it decrypts. A forged copy from a relay therefore can't start a stream or suppress the genuine copy that arrives through the other relay during a planned relay migration (16 §8.2, 16 §9.1).
Jitter buffer (16 §9.2, 16 §9.3). Keep one state per (pid, sourceId, gen), or per full joinNonce in a secure call. With D = arrival − media time, B the minimum D over 10 s and T the target, a frame's deadline is s + O with O aiming at B + T. These bounds are mandatory:
| Bound | Value |
|---|---|
| Initial target | 60 ms |
| Target range | 60–180 ms |
| Longest hold of any frame | 200 ms |
A late frame is never played. The recommended target is the 95th percentile of D − B over 3 s plus 20 ms. Reset the offset at each talkspurt start and re-anchor after 10 consecutive late frames. With B = 40 ms and T = 60 ms, a frame with s = 1,000 arriving at 1,052 is on time; one with s = 1,020 arriving at 1,125 is late.
Concealment (16 §9.4). Recover a missing frame from the next frame's FEC, otherwise run Opus PLC, for at most 60 ms, then fade over 20 ms to silence. After E, play silence; after D, render comfort noise. Undecryptable frames are lost, not invalid, and a frame of an unknown newer epoch is held up to 200 ms (16 §9.5). Clients mix at least 8 voice and 2 shared-sound streams, with per-participant volumes of 0–200 % (16 §9.7).
Game sound and ducking (16 §10). Ducking is a listener setting, on by default at 50 %: while any remote participant is speaking, source 2 drops within 50 ms, holds 500 ms after speech stops, then returns over 300 ms. Senders MUST NOT duck their own source 2, because the choice belongs to each listener.
Clocks and lease enforcement
Every audio timing decision, and every receiver-side video timing decision, uses the audio clock (16 §11.1, 17 §11.1): monotonic, unaffected by wall-clock changes, and still counting during sleep (CLOCK_BOOTTIME, mach_continuous_time, QueryInterruptTimePrecise). Web clients treat any detected suspend as invalidating every earlier tick (16 §11.1).
Accept a LeaseSnapshot tick only from the relay's sv-control, from call.tick, or from a join response, and only with a strictly higher seq. The network thread stamps rxAt on arrival; a response tick's rxAt is when its request was first sent. Validity is 3,000 ms whatever validMs says. When the newest tick is that old, the next WebSocket tick is accepted whatever its seq, which recovers from a forged huge seq (16 §12.1).
A sender is covered when the newest tick is less than 3,000 ms old and lists it in audio (or video for video). Check audio coverage at every render quantum, on the relay and the SFU route alike and in both modes; uncovered output is never rendered, so a revoked speaker is cut within 4 s (16 §12.2). Your own leaseState comes from the same tick. If no tick is fresh, or your pid isn't in the fresh tick's listeners, stop rendering call audio (16 §12.3). The relay and the SFU enforce the same snapshots on every frame they forward and send nothing to a session outside listeners; every frame passes through one of them, so while the hosting server is honest a modified client can't keep a revoked speaker audible (16 §12, 16 §12.2, 16 §12.3).
The video-dc/1 fragment
sv-video is unordered with maxPacketLifeTime 120 ms, so SCTP repairs most single losses per hop (17 §6.1). Each message is one fragment (17 §6.2):
| Octets | Field | Notes |
|---|---|---|
| 0 | vt |
0x10 |
| 1 | flags |
C 0x80, K 0x40, D 0x20, E 0x10 |
| 2–3 | pid |
|
| 4–5 | sourceId (high 4 bits), gen (low 12 bits) |
sourceId 1 or 3 only |
| 6–7 | frameNumber |
Per stream |
| 8–9 | refSeq |
Counts non-discardable frames |
| 10–13 | timestamp |
90 kHz from T0 |
| 14 | codec |
0x01 vp8, 0x02 vp9, 0x03 h264, 0x04 av1 |
| 15 | frameInfo |
Bits 7–6: rotation in 90° steps |
| 16–17 | fragIndex |
Not authenticated |
| 18–19 | fragCount |
1 to 2,048; not authenticated |
| 20– | chunk |
1 to 1,180 octets |
Octets 0–15 are the frame header, identical in every fragment of a frame and the SFrame metadata in a secure call. K marks a keyframe, D a frame nothing references (never with K), E the last frame of a source. K and D are cleartext so a relay can drop frames for one viewer without breaking that viewer's decoding (17 §6.3). refSeq is 0 on the first keyframe and rises by 1 per non-discardable frame; a discardable frame carries the refSeq it references, so a receiver knows at once whether a missing frame matters (17 §6.4).
Encrypt, then fragment (17 §6.5, 17 §6.6). The protected frame is the encoded frame, or in a secure call the SFrame ciphertext of the whole encoded frame. Use 1,130-octet chunks so a message is at most 1,150 octets. Never send a protected frame over 2,097,152 octets or 2,048 fragments. Test vector 1 of 17 §6.13, a 2,500-octet insecure VP8 screen keyframe:
frame header: 10 40 00 07 12 a5 00 00 00 00 00 01 5f 90 01 00
fragment 0: <frame header> 00 00 00 03 + octets 0..1129
fragment 1: <frame header> 00 01 00 03 + octets 1130..2259
fragment 2: <frame header> 00 02 00 03 + octets 2260..2499Receivers validate fragments like audio frames, plus K with D, a bad fragCount or fragIndex, and a header that conflicts with an open slot (17 §6.8.1). A new gen becomes current only after it completes a frame (in a secure call, one that decrypts and passes the KID checks, and, if the current stream has an attested frame, only once one of the new stream's frames is attested), so a stray or forged fragment can't end a live stream. Abandon an assembly slot after 500 ms, when a newer keyframe completes, or past 32 slots or 8 MiB per stream or 64 MiB per call (17 §6.9).
Decodability (17 §6.10):
| Frame | Decodable when |
|---|---|
| Keyframe | frameNumber > lastFrame, or nothing decoded yet |
| Non-discardable | chain intact, refSeq = lastRef + 1 and frameNumber > lastFrame |
| Discardable | chain intact, refSeq = lastRef and frameNumber > lastFrame |
Hold a frame that is ahead of the chain for up to 250 ms. If its reference is abandoned or the time passes, the chain is broken: discard held non-keyframes and send keyframe_request with reason loss. Decode strictly in frameNumber order.
Codecs and keyframes
VP8 is mandatory to encode and decode, because every platform can do it in software. VP9 profile 0, H.264 Constrained Baseline (Annex B, 4-octet start codes) and AV1 Main 8-bit are SHOULD decode, MAY encode (17 §5.1). Every keyframe is self-contained and size, codec and configuration change only at keyframes, because video-dc/1 has no out-of-band decoder configuration (17 §5.2).
Choose your most-preferred codec in the acceptable set, the codecs in every current viewer's VideoPreference decode list plus vp8. When a new viewer can't decode the current codec, send a keyframe in an acceptable one within 1,000 ms of receiving its VideoPreference; switch to a codec you prefer no sooner than 10 s after the previous codec change; with no VideoPreference from anyone, use vp8 (17 §5.3). L1T1 is recommended for screen detail at 8 fps or less, and L1T2 (odd frames after a keyframe discardable) for webcam and for screen motion at 15 fps or more (17 §5.4).
Send a keyframe first in each media process, at least every 10 s, in answer to a request you honour (within one frame interval and at most 200 ms, or at the coalesced time of 17 §7.2 rule 2), at every size, codec or structure change, and as the very next frame after you discard or fail to send a non-discardable frame (17 §5.7). Send a frame at least every 500 ms even for a still screen, because viewers label a picture "held" after 750 ms (17 §5.8). Never send a frame captured more than 1,000 ms earlier, or anything captured while you couldn't send (17 §5.9).
Note
17 §5.7 item 3 attributes the "within one frame interval and at most 200 ms" answer time to 17 §7.2 rule 2, which defines only the 1,000 ms coalescing.
Screen share and webcam
To start a source (17 §4.2):
- Check that your newest tick covers
video(source 2 needsaudio); if not, explain why from the VoiceLeasevideoBlockedBy. - Ask for OS permission just in time and capture only what the user picks.
- Send
sources(screen,screenAudio,webcam) on the participant PATCH; on call.not_permitted, release the capture. - In a secure call, wait for the sending key.
- Send a keyframe first.
A camera or share never starts without a deliberate action in the current call. To stop, send a final frame with E, stop within one frame interval, then PATCH the flag to false; stopping source 1 also stops source 2 unless the user chose "share sound only" (17 §4.3).
After an unexpected drop, stop sending all video at once (17 §4.5, D-090). The webcam turns off and comes back off. The screen capture keeps running with a "not being seen" indicator, and resumes with a keyframe only if the rejoin's response has seatRestored: true and arrives within 30 s of your detecting the drop; otherwise stop it and show SHARE.stopped.reconnect. Relay migration and your own MLS resync keep both, switching to a new gen with a keyframe. After any rejoin, re-send the sources PATCH unless the join response already shows the flag, and clear stale true flags.
Exclude your own windows from whole-screen capture where possible, offer window or tab capture first, include the cursor by default, stop the capture (not only the sending) on "Stop sharing", and make "Pause sharing" cover picture and sound with a neutral "Paused" card (17 §4.6). While your client displays recovery words or a pairing QR code or code that could fall inside the capture, you MUST exclude it through the platform or send the neutral picture instead, so a share never leaks account secrets (17 §4.6 item 7).
Quality adaptation
Each video source sends at one rung of a ladder; the encoder targets 80 % of the rung's budget (17 §5.5). Budgets are in kbit/s.
| Ladder | Rungs, top to 0 | Start |
|---|---|---|
Screen detail |
2560×1600@15 5,000; 2560×1600@8 3,500; 1920×1200@8 2,200; 1920×1200@5 1,500; 1600×1000@5 900; 1280×800@3 500 | 3 |
Screen motion |
1920×1080@60 8,000 ("Smoother video" only); 1920×1080@30 5,000; 1600×900@30 3,500; 1280×720@30 2,200; 1280×720@15 1,200; 960×540@15 700 | 2 |
| Webcam | 1280×720@30 1,800; 960×540@30 1,000; 640×360@30 500; 320×180@15 150 | 2 desktop, 1 mobile |
The controller's rung is then capped by the shared budget of all your video sources (0.9 × maxInboundKbps − 300, 8,700 kbit/s by default, with the webcam at rung 1 at most during a screen share), by the largest viewer's requested size and frame rate, by the captured size, and by device pressure. The client picks detail or motion automatically from how much of the picture changes (17 §5.6).
Feedback travels in call.media_feedback through the relay on sv-control (17 §7.1). Viewers send keyframe_request (1/s per source), video_pref (2/s per sender) and video_report (1/s per source). The relay alone sends video_viewer_state, video_audience and video_upload_pressure, with no from; accept them only from your own relay connection. From 17 §7.6:
{ "t": "call.media_feedback", "from": 12, "to": 3,
"d": { "kind": "video_pref", "sourceId": 1, "subscribed": true,
"maxWidth": 2560, "maxHeight": 1440, "maxFps": 60, "decode": ["vp8", "vp9", "av1", "h264"] } }
{ "t": "call.media_feedback", "from": 12, "to": 3,
"d": { "kind": "keyframe_request", "sourceId": 1, "reason": "subscribe" } }maxWidth is the larger edge of the display area and maxHeight the smaller, in device pixels, whatever the orientation (17 §7.3). Senders send at most one request-driven keyframe per source per 1,000 ms and honour a slow viewer's request at most once per 10 s (17 §7.2).
Slow-viewer isolation (17 §8.2). The relay keeps a queue per viewer and decides once per frame from the viewer's backlog age A:
| Frame | Forwarded when | A congestion drop moves the viewer to |
|---|---|---|
| Keyframe | A < 400 ms |
paused |
| Non-discardable | A < 250 ms, no keyframe owed |
keyframes_only |
| Discardable | A < 100 ms, viewer normal |
thinned |
A forwarded keyframe lifts keyframes_only and paused to thinned, and thinned returns to normal after 5 s with A under 100 ms. After a non-discardable frame is dropped, nothing but keyframes is forwarded until one arrives. A fragment that waits 500 ms in a viewer's queue is discarded with the rest of its frame. A new viewer gets only keyframes until its first one. The sender uploads each frame once and paces its relay connection at R = min(4 × Σ targets + 1,000 kbit/s, 0.9 × maxInboundKbps) (17 §8.1).
The sender's rung controller counts pressure signals once per second: its own uplink backlog over 250 ms, a video_upload_pressure, strictly more than half of its viewers pressured, or an encoder that can't keep up or thermal or battery pressure (17 §9.1). Three within 10 s lower the rung; after 30 s without pressure it tries one higher, and a failed trial doubles the wait to 60, 120, then 240 s (17 §9). Because viewer pressure needs a strict majority, one slow viewer never lowers quality for the others.
Displaying video
Open a source by adding it to relay.subscribe (or the SFU subscription), sending video_pref with subscribed: true, and sending keyframe_request with reason subscribe, repeated every 1,000 ms until a keyframe decodes (17 §10.1). After 750 ms without a new picture, keep the last one with a calm "Picture delayed" label that never says "Paused" (17 §10.1, 17 §10.2).
Note
17 §10.1 sends keyframe_request on opening a source whatever the route, but 17 §7.1 and 17 §12.8 say RTCP replaces keyframe_request on the SFU route. Display new pictures only from senders covered for video, and remove an uncovered sender's picture within 250 ms (17 §10.3).
Screen video and screen sound share one playout offset, so they play together within the ±80 ms target; webcam video waits up to 200 ms for the same person's voice, and the voice never waits. The targets at the 95th percentile are under 500 ms capture to display for screen share, under 400 ms for webcam, and under 1,000 ms to the first picture (17 §11).
The sfu-rtp/1 route
Call control moves a group DM or voice channel call to videoRoute sfu for large calls or large fan-out; a 1:1 DM call always uses the relay (17 §13.1, 17 §13.2). Sources 1, 2 and 3 then travel as RTP through one RTCPeerConnection to the SFU with BUNDLE, rtcp-mux and DTLS-SRTP; clients configure no STUN or TURN servers, and the relay connection stays up beside it (17 §12.2). The microphone never takes this route (17 §12.1). Put source 1 and source 2 of a share in one msid stream (17 §12.3).
| Source | VP8 or H.264 simulcast | VP9 SVC |
|---|---|---|
| Webcam | q, h, f, each L1T3 |
L3T3_KEY |
Screen motion |
h, f, each L1T3 |
L2T3_KEY |
Screen detail |
f, L1T3 |
L1T3 |
RTCP replaces keyframe_request and video_report; video_pref is still sent and each viewer maps it to maxSpatialLayer and maxTemporalLayer (17 §12.8). WebRTC congestion control replaces the rung controller. VP8 and Opus are mandatory; H.264 and AV1 are allowed only in insecure calls, because browser packetizers parse their bitstreams after the encoded transform and can't packetize ciphertext (17 §12.4). In a secure call, source 2 on this route uses cbr=1 and MUST NOT carry the ssrc-audio-level header extension, which would reveal the loudness of shared sound frame by frame (17 §12.4). Received source 2 still goes through your audio engine for ducking, volume and lease enforcement (17 §12.9).
Route switches are silent (17 §13.3). On dc → sfu after call.route_changed, the sender publishes on the SFU from a keyframe and keeps video-dc/1 running for up to 5 s, and viewers switch display at the first decoded SFU keyframe. On sfu → dc the first frame is a keyframe, and viewers send keyframe_request with reason route_change if none arrives within 1,000 ms.
Media end-to-end encryption
This section applies only to secure calls. Insecure calls use the same framing with the C flag 0, no SFrame and no attestations, and every server involved can read and alter the media (18 §8.6). Keys come from the context's MLS group (MLS and sealed messages).
Secure contexts only
You decide whether a call is secure: it is if the Call's security is secure or your own view of the context is secure. If the server says insecure for a context you hold to be secure, send and play nothing; 18 §8.5 says when to raise W9.
SFrame and keys
The only suite is AES_128_GCM_SHA256_128 (0x0004), with no negotiation (18 §3.1). Senders encode the RFC 9605 header minimally and receivers accept any valid encoding (18 §3.2). Keys follow the RFC 9605 §5.2 MLS schedule (18 §3.3):
sframe_epoch_secret(e) = MLS-Exporter("SFrame 1.0 Base Key", "", 16)
sender_base_key(e, L) = HKDF-Expand(sframe_epoch_secret(e), uint32(L), 16)
sframe_secret = HKDF-Extract("", sender_base_key(e, L))
sframe_key = HKDF-Expand(sframe_secret, "SFrame 1.0 Secret key " || uint64(K) || uint16(0x0004), 16)
sframe_salt = HKDF-Expand(sframe_secret, "SFrame 1.0 Secret salt " || uint64(K) || uint16(0x0004), 12)The labels keep their trailing space and have no sv1 prefix, because RFC 9605 defines them. Compute the epoch secret while your MLS state is in that epoch, keep it only in that epoch's EpochMediaState, and never archive or back it up; there is no media history.
The nonce is sframe_salt XOR uint96(CTR) and the AAD is header || metadata (18 §3.4). Increment the counter on every encryption, even for a frame you don't send, so counters have no gaps, and send the identical ciphertext on every relay connection that carries the frame (both relays during a planned relay migration). Per KID, start an MLS self-update at 2^31 frames or 2^35 bytes and stop the source at 2^32 or 2^36 (18 §3.6).
KID layout and joinNonce
KID = (joinNonce << 24) | (sourceId << 20) | (leaf_index << 4) | (epoch mod 16)| Bits | Field |
|---|---|
| 55–24 | joinNonce |
| 23–20 | sourceId |
| 19–4 | sender's MLS leaf index |
| 3–0 | epoch residue |
Keys are derived from the KID, so a new joinNonce gives new keys and counters can restart at 0 after a crash or rejoin (18 §4.1). In JSON a KID is a decimal string, because it can exceed 2^53 − 1: joinNonce 8f3c1fff, source 2, leaf 5, epoch 42 is KID 8f3c1fff20005a, "40317029791563866" (18 §13.1).
The joinNonce rule keeps AES-GCM nonces unique (18 §4.3):
- Draw a fresh CSPRNG
joinNoncefor every encryptor instance: every join, rejoin, media-process restart and new SFU session. - Keep a per-group set of values used in the current epoch, even after leaving the call, and redraw on collision.
- Persist the set with your MLS state before the first frame under a
joinNoncein each epoch. - Discard it only when the group advances an epoch, you leave the group, or its generation is retired.
Warning
Don't persist counters instead of the set, derive joinNonce from anything predictable, or let two threads encrypt under one KID without one atomic counter. Nonce reuse would expose plaintext XORs and the GHASH key to the relay (18 §14 item 6).
The media process's main encryptor instance protects all voice-dc/1 and video-dc/1 frames; each SFU session has its own instance and joinNonce, so the data-channel pipeline and the encoded transform never share a counter (18 §4.4). Receivers drop as invalid a frame whose KID is too large or names a reserved source (media.malformed_frame), or whose source, gen or leaf doesn't match the transport and the sender's device in their own roster snapshot (media.kid_mismatch). They keep at most 4 streams per (pid, sourceId) (18 §4.5).
Epoch rotation
Every commit in the context group rotates media keys (18 §6):
- Install. While still in the new epoch, create its EpochMediaState with a roster snapshot, then post
call.epoch_ready; install every intermediate epoch when catching up (18 §6.2). - Send. Use the highest installed epoch at or below the call's media epoch
M(from the join response, call.epoch_switch or a tick), or one you installed at least 2,000 ms ago if higher. If no installed epoch is at or belowM(you joined the group after the call'sM), use your lowest installed epoch. The sending epoch never decreases and never falls more than 15 below your newest installed epoch, because receivers keep only 16. On a switch, close the old KIDs' attestation batches and start the new KIDs at counter 0 (18 §6.3). - Lag. If
Mis above everything you hold, keep sending and fetch commits; after 8,000 ms the gate closes with media.keys_unavailable, shown only as "not being heard". In a DM or group DM call,keysOkis also false while the sending epoch's roster holds the pending key of averified_blockedcontact pin, until the user accepts or verifies it (18 §6.3 item 5); receivers likewise don't play that leaf's streams (18 §9.8 item 5). - Resolve a received frame's epoch from its residue. An unknown residue is held up to 200 ms, never past its deadline, then becomes media.unknown_epoch (18 §6.4, 18 §6.5).
- Erase an old epoch 10,000 ms after first learning a newer
M, not after the first newer frame (18 §6.6).
Replay protection
Per (epoch, KID), keep the highest counter H and a record of counters above H − 4096 (18 §7). Before decrypting, accept counter c if c > H, or if it is in the window, unrecorded, and the next higher recorded counter arrived less than 1,000 ms ago. After the tag verifies, on data channels, reject a frame whose arrival-minus-capture delay exceeds the stream's slowly rising reference Dref by more than 1,000 ms, which stops a relay replaying a held-back talkspurt tail. Update state only after both checks pass; a failure is media.replay. Remember the last 64 evicted joinNonce values per (pid, sourceId) and reject their frames as media.replay, because fresh replay state for an evicted stream would accept its old frames again.
Per-transport framing
| Transport | Metadata | Encrypted |
|---|---|---|
voice-dc/1 |
12-octet route header (18 §8.2) | One Opus packet |
video-dc/1 |
16-octet frame header (18 §8.3) | The whole frame, before fragmentation |
sfu-rtp/1 |
SfuFrameMetadata (18 §8.4.3) | The frame after its clear prefix |
On the SFU route SFrame runs in an encoded transform (RTCRtpScriptTransform, not SFrameTransform, which can't carry metadata). SfuFrameMetadata is version 1 | codec | clear_prefix<V>, with codec 1 Opus (no prefix), 2 VP8 (10 octets on a keyframe, 3 otherwise) or 3 VP9 (no prefix); these values are unrelated to the video-dc/1 codec octets (18 §8.4.2). Receivers check the KID against the Track's pid and sourceId; this route has no freshness check (18 §8.4.4). A secure call's SFU offer with no allowed video codec gets sfu.bad_sdp. From 17 §12.10, a 1280×720 VP8 key frame:
clear prefix: 90 46 02 9d 01 2a 00 05 d0 02
SfuFrameMetadata: 01 02 0a 90 46 02 9d 01 2a 00 05 d0 02Note
The minimum SFU-route frame length is stated three ways: the clear prefix plus 1 octet (18 §8.4.2 item 3), the prefix plus 1 octet plus the minimum SFrame overhead (18 §8.4.4), and shorter than the clear prefix (18 §10.1, media.malformed_frame).
MediaAttestation
Every group member can derive every sender's keys, so a member who also controls a relay or SFU could inject frames under someone else's KID. MediaAttestation detects that within about 1 s, or 3 s if attestations are suppressed, without delaying playback (18 §9.1). The frame hash is the first 8 octets of SHA-256 over FrameHashInput, the length-prefixed metadata followed by the length-prefixed SFrame ciphertext; it covers the metadata because AES-GCM isn't key-committing (18 §9.2).
Sending (18 §9.3, 18 §9.6). Add every encrypted frame's hash, sent or not, to its KID's batch. Close the batch at 500 ms after its first frame, at 256 frames, or when the KID retires, sign MediaAttestationContent with your DSK under the label media-attest, and send it within 50 ms on sv-control of every open relay connection, including for SFU-routed sources, because SFU sessions have no control channel:
{ "t": "media.attestation", "from": 513,
"d": { "v": 1, "callId": "01938f40-5a6b-7c8d-9e0f-102132435465", "epoch": 42, "src": 2,
"kid": "40317029791563866", "first": 1000, "last": 1003,
"hashes": "3A1kHQTta0z15ThCKBPFrqVShRH4hZMMQCxfrstJQFw",
"sig": "sY6BiR_rEVDdYnaFowVthpHfwRkdgzkxFZY1HmDr5jgupp0p-WhIeNhGGH516XV_KsIyO2MIVSTJSkV0YDiBCQ" } }Keep every attestation you sent for 4,000 ms. After an unexpected drop, close any batch the drop left open and send the ones you still hold on the new relay connection once the rejoin completes, so receivers can withdraw stops caused by attestations the outage lost (18 §9.3 item 8, 18 §9.6 item 2). The relay forwards each attestation to every listener except you, whether or not they subscribed to the source, which lets a viewer on the SFU route verify it (18 §9.6 item 3).
Verifying (18 §9.7):
- Check structure,
callIdandsrc, and that the KID's leaf isfrom's device. Keep an attestation for an epoch or participant you don't have yet pending for up to 4,000 ms. - Verify the signature against your own
group_idand call ID. An invalid signature stops nothing, because anyone on the path can produce one. - A recorded frame with a different hash, or two valid attestations disagreeing on one counter, stops the stream (media.attestation_mismatch).
- A frame played but not attested within 3,000 ms stops the stream (media.unattested), except for up to 3,000 ms per minute excused by route disruptions.
A stopped stream fades out within 20 ms (video shows the avatar within 250 ms) and keeps being decrypted and checked; frames accepted while stopped are never played. It resumes on a clean attestation covering a newer frame, with a play floor at the current H. A media.unattested stop is withdrawn, and doesn't count, if every frame it played unattested gets a matching attestation within 5,000 ms; a mismatch always counts. While a pair has a stop in the last 60 s that wasn't withdrawn, its new streams start stopped, so a fresh joinNonce buys no fresh budget. After 3 counted stops per (pid, sourceId) in 60 s it waits out the minute (18 §9.8). No warning, toast or badge is ever shown.
Error codes
The media.* codes are local engine conditions that no endpoint returns; bot SDKs surface them as problem objects (18 §10.1). media.keys_unavailable and media.key_exhausted are 409, retryable, userAction wait. The rest, including media.decrypt_failed, media.stream_limit, media.attestation_invalid and media.attestation_unexpected, are 400, not retryable, none. Clients MUST NOT show any of them as a security warning.
Diagnostics
Media problems become counters in the diagnostics Sample that Calls uploads with POST /v1/diagnostics: AudioStats as audio (16 §13) and VideoStats as video (17 §14). A media_attestation report is sent only when the diagnostics setting is failures or full, for an invalid signature, a mismatch, an equivocation, or an unattested stop that counts and is at least the third counted stop in the call, at most once per (call, sender, source) per 10 minutes and 10 times per call (18 §10.3). None of it carries content, KIDs, hashes or keys.
Insecure and secure calls compared
| Aspect | Insecure call | Secure call |
|---|---|---|
| C flag and payload | 0; plain Opus or encoded frame | 1; SFrame ciphertext, header authenticated |
joinNonce |
Used only for gen |
Also in the KID; persisted per-epoch set |
| Opus | VBR allowed | CBR on every encoder |
| Receiver state | Updated on arrival | Changed only after decryption |
| SFU video codecs | VP8, VP9, H.264, AV1 | VP8 and VP9 |
| Attestations | Never sent; ignored | Sent and verified |
| Servers can | Read, alter and inject media | Drop or delay; see metadata |
The gate, the live-only rules, lease enforcement, the jitter bounds, slow-viewer isolation and ducking are the same in both modes. A call never changes mode; a context that becomes secure gets a new call with new media processes (18 §8.6). Residual risks, including brief member forgery and metadata visible to relays, are in Security model.