Media helpers for documents 16 (audio, voice-dc/1), 17 (video, video-dc/1, sfu-rtp/1) and 18 (media E2EE: SFrame and MediaAttestation): binary codecs with strict validation, constants, lease enforcement, the transmit gate, SFrame with WebCrypto, and MediaAttestation.

Capture, encoding, the jitter buffer, mixing and WebRTC itself are the platform's; these modules give a media engine the protocol rules as pure functions and small state machines.

import { … } from '@sloppyvoice/sdk/media'

Classes

AttestationBatcher class

The sender's open batches, one per KID (18 §9.3). Every encrypted frame joins its KID's batch, including frames that were then dropped; a batch closes 500 ms after its first frame, at 256 frames, or when the caller closes it (the KID is retired; SHOULD after a frame with E or the last frame before a pause). Times are the sender's monotonic clock. Signing is createMediaAttestation; never delay a frame for it (18 §9.3 item 6).

class AttestationBatcher

constructor

new AttestationBatcher()

add

add(kid: bigint, epoch: number, counter: number, hash: Uint8Array, nowMs: number): AttestationBatch | null

Add the frame hash of an encrypted frame. Counters of one KID must be consecutive (18 §3.4 item 2). Returns the batch this frame closed (at 256 frames), if any.

kid: bigint
epoch: number
counter: number
hash: Uint8Array
nowMs: number

poll

poll(nowMs: number): AttestationBatch[]

Close the batches whose first frame is 500 ms old or older (18 §9.3 item 2).

nowMs: number

close

close(kid: bigint): AttestationBatch | null

Close one KID's open batch (retirement, end of talkspurt, pause). Returns null if none is open.

kid: bigint

closeAll

closeAll(): AttestationBatch[]

Close every open batch (epoch change, leaving the call, 18 §9.3 items 2 and 7).

Source: media/attestation.ts:310

AttestationInbox class

The receiver's bookkeeping of incoming attestations (18 §9.6 item 4, §9.7 step 3): it ignores a copy identical to one processed in the last 10,000 ms (an altered copy is processed on its own), and keeps pending attestations for at most 4,000 ms and at most 16 per (from, src), dropping the oldest when a 17th arrives. Expired and dropped pending attestations are counted in attest.ignored by the caller. Times are the receiver's audio clock.

class AttestationInbox

constructor

new AttestationInbox()

pendingCount

get pendingCount(): number

Number of pending attestations held.

isDuplicate

isDuplicate(from: number, a: ParsedMediaAttestation, nowMs: number): boolean

Whether this copy is identical to one processed in the last 10,000 ms (18 §9.6 item 4). If it isn't, it is remembered as processed now. Unknown members aren't signed and aren't compared.

from: number
nowMs: number

addPending

addPending(from: number, a: ParsedMediaAttestation, nowMs: number): PendingAttestation[]

Keep a pending attestation (18 §9.7 step 3). Returns the ones dropped to stay within 16 per (from, src).

from: number
nowMs: number

takePending

takePending(filter: { epoch?: number; from?: number }, nowMs: number): PendingAttestation[]

Take the pending attestations to process again from step 3: those of epoch when it is installed (after the held frames of that epoch, 18 §9.7), or those of from when its roster entry arrives. Expired ones are removed first.

filter: { epoch?: number; from?: number }
nowMs: number

expirePending

expirePending(nowMs: number): PendingAttestation[]

Remove pending attestations older than 4,000 ms; returns them (count attest.ignored).

nowMs: number

discard

discard(from?: number): void

Discard a participant's pending attestations (its seat was removed, 18 §9.7 item 12), or all of them (migrating, item 11).

from?: number

Source: media/attestation.ts:401

FreshnessCheck class

The freshness check of one voice-dc/1 or video-dc/1 stream (18 §7). For every accepted frame D = a − ts (arrival time minus capture timestamp in ms, extended with serial arithmetic); Dref is maintained as min(Dref + (t − t_prev) / 10, D_new). A frame whose D exceeds Dref(a) + 1,000 is stale (media.replay). The first frame sets Dref. Not used on sfu-rtp/1, whose RTP timestamps aren't authenticated.

class FreshnessCheck

constructor

new FreshnessCheck()

drefAt

drefAt(tMs: number): number | null

Dref(t) before accepting anything at t, or null before the first frame.

tMs: number

check

check(arrivalMs: number, timestampMs: number): boolean

Whether a frame that arrived at arrivalMs with capture time timestampMs is fresh. Changes nothing.

arrivalMs: number
timestampMs: number

accept

accept(arrivalMs: number, timestampMs: number): void

Update Dref for an accepted frame (18 §7 rule 2: only after the tag and both checks passed).

arrivalMs: number
timestampMs: number

Source: media/replay.ts:170

LeaseTickTracker class

The tick state of one call (16 §12.1): accepts ticks from the relay, the WebSocket and join or rejoin responses, and from no other source; keeps the highest seq; never refreshes rxAt for a duplicate; and recovers from a wedged seq through the WebSocket once the newest tick is V old. rxAt must be the audio-clock time of receipt, stamped before any other processing; for a join response, the time the client first sent the request (16 §12.1 item 1).

class LeaseTickTracker

constructor

new LeaseTickTracker(callId: string)
callId: string

callId

get callId(): string

The call whose ticks this tracker accepts.

newest

get newest(): AcceptedTick | null

The newest accepted tick, or null.

sawUnexpectedValidMs

get sawUnexpectedValidMs(): boolean

True once an accepted tick carried a validMs other than 3,000 (a diagnostic, 16 §12.1 item 6).

joinNewCall

joinNewCall(callId: string): void

Discard all tick state and follow a new call (16 §12.1 item 2): a switch, a rejoin into a new call, or the new call after security_upgraded, group_restarted or server_restart. Then offer the join response's tick.

callId: string

offer

offer(tick: unknown, source: LeaseTickSource, rxAt: number): TickOfferResult

Offer a tick received from source at audio-clock time rxAt (16 §12.1).

tick: unknown
rxAt: number

isCovered

isCovered(pid: number, kind: "audio" | "video", nowMs: number): boolean

isCovered with this tracker's newest tick.

pid: number
kind: "audio" | "video"
nowMs: number

ownLeaseState

ownLeaseState(ownPid: number, nowMs: number, kind?: "audio" | "video"): LeaseState

ownLeaseState with this tracker's newest tick.

ownPid: number
nowMs: number
kind: "audio" | "video"

Default: 'audio'

hasListeningAuthority

hasListeningAuthority(ownPid: number, nowMs: number): boolean

hasListeningAuthority with this tracker's newest tick.

ownPid: number
nowMs: number

Source: media/lease.ts:138

MainThreadTickStamper class

Stamps ticks delivered on a web page's main thread (16 §12.1 item 5): the main thread posts a heartbeat at least every 100 ms; a tick that arrives after a heartbeat gap of more than 200 ms gets the time of the last heartbeat before the gap as its rxAt.

class MainThreadTickStamper

constructor

new MainThreadTickStamper()

heartbeat

heartbeat(nowMs: number): void

Record a heartbeat at audio-clock time nowMs.

nowMs: number

stamp

stamp(nowMs: number): number

The rxAt for a tick handled at nowMs.

nowMs: number

Source: media/lease.ts:209

ReceiverEpochs class

The receiver's installed epochs R of one secure call (18 §6.4–§6.6): epoch resolution by residue, the hold for frames of an unknown newer epoch (200 ms, never past the playout deadline, 32 frames per stream and 4 MiB per call), and retention: an old epoch x is kept for 10,000 ms after T(x), the first time the receiver learned a media epoch M newer than x, and erased at once when it falls below N − 15. The newest epoch and the device's own sending epoch are never erased while in the call. Erasing the keys themselves (SFrameEpochKeys.erase) and the replay state is the caller's, for every epoch this class reports.

class ReceiverEpochs<F extends HeldFrameInfo = HeldFrameInfo>

constructor

new ReceiverEpochs<F extends HeldFrameInfo = HeldFrameInfo>()

installed

get installed(): number[]

The installed epochs R, ascending.

newest

get newest(): number | null

N, the newest installed epoch, or null.

heldCount

get heldCount(): number

Number of frames held for unknown epochs.

resolve

resolve(residue: number): EpochResolution

Resolve a frame's epoch from its KID residue (18 §6.4). Throws when nothing is installed.

residue: number

setSendingEpoch

setSendingEpoch(epoch: number | null): void

The device's own sending epoch s, which is never erased while in the call (18 §6.6 item 4).

epoch: number | null

learnMediaEpoch

learnMediaEpoch(m: number, nowMs: number): void

Learn a media epoch M from call control at nowMs (the join response's call.mediaEpoch, a call.epoch_switch, or a lease tick's epoch): it starts the 10,000 ms retention clock T(x) of every installed epoch below it that hasn't started yet (18 §6.6 item 1).

m: number
nowMs: number

install

install(epoch: number, nowMs: number): InstallResult<F>

Install epoch epoch at nowMs (18 §6.2): erase at once every epoch below N − 15, and release the held frames whose target is this epoch (18 §6.5 item 2). Process those frames first, then the epoch's pending attestations (18 §9.7 step 3).

epoch: number
nowMs: number

hold

hold(frame: F, target: number, nowMs: number): F[]

Hold a frame of an unknown newer epoch, undecrypted (18 §6.5), with target epoch target from ReceiverEpochs.resolve. Returns the frames discarded to keep within 32 frames per stream and 4 MiB per call (oldest first): they are undecryptable.

frame: F
target: number
nowMs: number

tick

tick(nowMs: number): EpochTickResult<F>

Apply the timers at nowMs: held frames whose 200 ms (or playout deadline) passed are undecryptable (media.unknown_epoch); epochs other than N and the sending epoch whose retention of 10,000 ms after T(x) ended are erased (18 §6.6).

nowMs: number

missedCommitCheckDue

missedCommitCheckDue(nowMs: number): boolean

Whether to check for missed commits now (18 §6.4, SHOULD): once frames have been held for an unknown epoch for more than 1,000 ms in total in the call, at most once every 5 s. Returns true when a check is due and records it.

nowMs: number

eraseAll

eraseAll(): number[]

Leave the call, the call ends, the group generation changes, or the device is removed from the group (18 §6.6 item 3): every epoch is erased and every held frame discarded. Returns the erased epochs.

Source: media/epochs.ts:180

ReplayWindow class

The replay state of one (epoch, KID) (18 §7): H, Ha and the record of accepted counters. Apply ReplayWindow.check before decrypting; call ReplayWindow.record only after the tag verified and the freshness check passed (rule 2).

The counter check uses only counters above H − 4096. Entries that fall below the window are kept for REPLAY_RECORD_RETENTION_MS so attestations can still mark them attested and a rollback can restore H to them, as 18 §9.9 vector A2 requires.

class ReplayWindow

constructor

new ReplayWindow()

highest

get highest(): number | null

H: the highest recorded counter, or null.

highestAttested

get highestAttested(): number | null

Ha: the highest attested counter, or null.

entry

entry(counter: number): ReplayRecordEntry | undefined

A copy of the record entry for counter, if any.

counter: number

counters

counters(): number[]

The recorded counters in increasing order.

check

check(counter: number, nowMs: number): boolean

The counter check (18 §7): passes when H is undefined or c > H; or when c > H − 4096, c isn't recorded, and the smallest recorded counter greater than c was accepted less than 1,000 ms before nowMs.

counter: number
nowMs: number

record

record(counter: number, nowMs: number, hash?: Uint8Array<ArrayBufferLike>): void

Record an accepted frame (18 §7 rule 2): add c, raise H, and prune entries below H − 4096 older than the retention.

counter: number
nowMs: number
hash?: Uint8Array<ArrayBufferLike>

markAttested

markAttested(counter: number): boolean

Mark a recorded counter attested and raise Ha (18 §7 rule 5). Returns false if it isn't recorded.

counter: number

rollback

rollback(): ReplayRecordEntry[]

Rollback after a stop (18 §7 rule 6): remove every recorded counter above Ha that isn't attested, set H to the highest counter still recorded (null if none), and return the removed entries for the stream's stop list (18 §9.8).

Source: media/replay.ts:79

RungController class

The rung controller of one video source (17 §9.2): rung r, phase, step-up hold H (30 s, doubling to 240 s after failed trials) and the time tr of the last change. Call RungController.pressure for every one-second interval that was a pressure signal (17 §9.1) and RungController.advance at least once per second; times are the sender's monotonic clock in ms.

class RungController

constructor

new RungController(opts: { startRung: number; topRung: number; nowMs: number })
opts: { startRung: number; topRung: number; nowMs: number }

rung

get rung(): number

The controller rung r.

phase

get phase(): ControllerPhase

holdMs

get holdMs(): number

The step-up hold H in ms.

advance

advance(nowMs: number, opts?: { canStepUp?: boolean }): RungChange | null

Apply the time-based rows of 17 §9.2 at nowMs: a passed trial (10 s without a revert) sets H = 30 s; in steady, H without a pressure signal since tr steps up by one rung unless r is the top or canStepUp is false (frames not sent every second, or the shared-budget or viewer cap holds the source below r).

nowMs: number
opts: { canStepUp?: boolean }

Default: {}

pressure

pressure(nowMs: number): RungChange | null

Record a pressure signal for the one-second interval ending at nowMs (17 §9.1).

nowMs: number

changeLadder

changeLadder(equivalentRung: number, topRung: number, nowMs: number): RungChange

The content hint or ladder changed (17 §5.6): continue at the equivalent rung with H = 30 s.

equivalentRung: number
topRung: number
nowMs: number

newMediaProcess

newMediaProcess(startRung: number, nowMs: number): RungChange

A new media process (17 §4.5): r = min(r, starting rung), H = 30 s.

startRung: number
nowMs: number

Source: media/video-adapt.ts:142

SendingEpochState class

The sender's epoch state for one secure call (18 §6.3): I (installed epochs with their install times), M (the highest media epoch learned from call control: the join response's call.mediaEpoch, any call.epoch_switch, and the epoch of any lease tick) and s (the sending epoch). SendingEpochState.evaluate applies rows 1–3, keeps s from decreasing, moves s up to N when it falls below N − 15, and closes the gate after 8,000 ms behind call control (18 §6.3 item 4). Call it whenever an input changes and at least every few hundred ms (row 2 and item 4 are timers).

class SendingEpochState

constructor

new SendingEpochState()

sendingEpoch

get sendingEpoch(): number | null

The sending epoch s, or null.

mediaEpoch

get mediaEpoch(): number | null

M, or null before call control has named one.

installed

get installed(): number[]

The installed epochs I, ascending.

install

install(epoch: number, nowMs: number): void

An epoch's EpochMediaState was created (18 §6.2) at nowMs.

epoch: number
nowMs: number

remove

remove(epoch: number): void

An epoch was erased (18 §6.6); it leaves I.

epoch: number

learnMediaEpoch

learnMediaEpoch(m: number, nowMs: number): void

A media epoch learned from call control at nowMs (18 §6.3 M). M only rises.

m: number
nowMs: number

evaluate

evaluate(nowMs: number): SendingEpochDecision

Recompute s at nowMs (18 §6.3 rows 1–3 and items 4–5).

nowMs: number

Source: media/epochs.ts:54

SerialExtender class

Tracks the highest extended value of one wrapping counter and extends new values against it (16 §4.5.2). In a secure call, call SerialExtender.accept only for frames that decrypted successfully ("seen" means authenticated, 16 §4.5.2).

class SerialExtender

constructor

new SerialExtender(bits: 16 | 32)
bits: 16 | 32

bits

readonly bits: 16 | 32

highest

get highest(): number | null

The highest extended value accepted so far, or null.

extend

extend(value: number): number

Extend value without changing state.

value: number

accept

accept(value: number): number

Extend value and raise the highest value if it is higher. Returns the extended value.

value: number

reset

reset(): void

Forget all state (a new stream).

Source: media/serial.ts:57

SFrameEncryptor class

One SFrame encryptor instance (18 §4.4): one joinNonce and one counter per KID. A media process has one main instance; an SFU session adds its own. Counters start at 0 for each KID and increase by exactly 1 per encrypted frame, whether or not the frame is later sent (18 §3.4). Enforces the usage limits of 18 §3.6: it sets SFrameEncryptor.selfUpdateNeeded at half of either limit and refuses with media.key_exhausted at the limit. Counter values are reserved synchronously, so concurrent encrypt calls never share one.

The joinNonce persistence rule of 18 §4.3 item 4 is the caller's: add the joinNonce to the group's persisted set for the epoch before SFrameEncryptor.setSendingEpoch lets the first frame be encrypted in it.

class SFrameEncryptor

constructor

new SFrameEncryptor(opts: SFrameEncryptorOptions)

joinNonce

readonly joinNonce: number

gen

get gen(): number

The stream generation gen of this instance's frames on data channels (16 §4.5.1).

sendingEpoch

get sendingEpoch(): number | null

The current sending epoch, or null.

selfUpdateNeeded

get selfUpdateNeeded(): boolean

True once a KID reached half of a usage limit in the current epoch: start a self-update commit (18 §3.6 item 3).

setSendingEpoch

setSendingEpoch(keys: SFrameEpochKeys, leafIndex: number): void

Switch to a new sending epoch (18 §6.3 item 6): every following frame uses the new epoch's KIDs with counters from 0. The sending epoch never decreases.

leafIndex: number

kidFor

kidFor(sourceId: SourceId): bigint

The KID this instance uses for sourceId in the current sending epoch.

sourceId: SourceId

usage

usage(sourceId: SourceId): KidUsage

Usage of a KID in the current epoch (18 §3.6).

sourceId: SourceId

encrypt

encrypt(sourceId: SourceId, metadata: Uint8Array, plaintext: Uint8Array): Promise<SFrameEncrypted>

Encrypt one frame of sourceId with metadata (the route header, video frame header or SfuFrameMetadata, 18 §8). Throws media.keys_unavailable without a sending epoch and media.key_exhausted when the KID's limits would be exceeded (18 §3.6 item 4).

sourceId: SourceId
metadata: Uint8Array
plaintext: Uint8Array

Source: media/sframe.ts:518

SFrameEpochKeys class

The key part of one epoch's EpochMediaState (18 §6.1): the media epoch secret and a cache of derived SFrame keys, which may be evicted and recomputed at any time (18 §3.3 item 4). SFrameEpochKeys.erase wipes the secret (18 §6.6 item 5).

class SFrameEpochKeys

constructor

new SFrameEpochKeys(epoch: number, epochSecret: Uint8Array)
epoch: number
epochSecret: Uint8Array

epoch

readonly epoch: number

erased

get erased(): boolean

Whether the secret has been erased.

keyFor

keyFor(kid: bigint): Promise<SFrameKey>

The SFrame key for kid in this epoch. Throws media.kid_mismatch if the KID's residue isn't this epoch's low 4 bits, and media.unknown_epoch after erasure.

kid: bigint

evictCache

evictCache(): void

Drop cached keys (they can be recomputed while the secret is held, 18 §3.3 item 4).

erase

erase(): void

Erase the media epoch secret and every cached key (18 §6.6 item 5).

Source: media/sframe.ts:429

SourceStopHistory class

The stop history and route-disruption excuse budget of one (pid, sourceId) (18 §9.7 item 11, §9.8). Shared by every stream of the pair, so a fresh joinNonce buys no fresh budget. Discard it only when the participant leaves the call.

class SourceStopHistory

constructor

new SourceStopHistory()

stops

readonly stops: StopRecord[]

newStreamsStartStopped

newStreamsStartStopped(nowMs: number): boolean

Whether a new stream of this pair starts stopped: a stop in the last 60 s that isn't withdrawn (18 §9.8).

nowMs: number

countedStops

countedStops(nowMs: number): StopRecord[]

The counted stops of the last 60 s, oldest first.

nowMs: number

tryExcuse

tryExcuse(ms: number, nowMs: number): boolean

Try to excuse ms of played media at nowMs (at most 3,000 ms per 60 s, 18 §9.7 item 11).

ms: number
nowMs: number

Source: media/playback.ts:37

SourceStreams class

The streams of one (pid, sourceId) of a secure call (18 §4.5 "Bounding state", §7 rule 4, §9.8): at most 4 streams (joinNonce values) with replay and attestation state, the eviction order of 18 §4.5, the last 64 evicted joinNonce values (later frames carrying one are media.replay), and the stop history shared by every stream of the pair. Times are the receiver's audio clock.

class SourceStreams

constructor

new SourceStreams()

history

readonly history: SourceStopHistory

joinNonces

get joinNonces(): number[]

The joinNonce values that have state.

get

get(joinNonce: number): StreamPlayback | undefined

The stream of joinNonce, if it has state.

joinNonce: number

isEvicted

isEvicted(joinNonce: number): boolean

True if frames of joinNonce are dropped as media.replay because its state was evicted (18 §7 rule 4). Check before the counter check; an evicted stream can't be resumed.

joinNonce: number

admit

admit(joinNonce: number, nowMs: number): StreamAdmission

Call when a frame of stream joinNonce has decrypted successfully, before recording it with StreamPlayback.accept. Creates the stream's state if it is new, evicting another stream when there are already 4: first, among streams with no attested frame, the one whose newest accepted frame is oldest; otherwise, among streams whose newest accepted frame is more than 10,000 ms old, the oldest. If neither exists the new frame is dropped (media.stream_limit, 18 §4.5).

joinNonce: number
nowMs: number

discard

discard(joinNonce: number): void

Discard one stream's state without remembering it as evicted (the call ends).

joinNonce: number

Source: media/playback.ts:410

StreamPlayback class

Records, attestation comparison and the playing/stopped state machine of one stream (18 §9.7, §9.8), built on one ReplayWindow per (epoch, KID). Use StreamPlayback.checkCounter before decrypting, StreamPlayback.accept after the tag and freshness checks, StreamPlayback.onAttestation for each verified attestation, and StreamPlayback.tick regularly (at least every few hundred ms).

class StreamPlayback

constructor

new StreamPlayback(history: SourceStopHistory, nowMs: number)
nowMs: number

history

readonly history: SourceStopHistory

state

get state(): StreamPlaybackState

lastAcceptedAt

get lastAcceptedAt(): number | null

Audio-clock time of the newest accepted frame, or null (18 §4.5 eviction order).

hasAttestedFrames

get hasAttestedFrames(): boolean

Whether any frame of the stream has become attested (18 §4.5 eviction order, §9.8 item 6).

replayWindow

replayWindow(epoch: number, kid: bigint): ReplayWindow

The replay window of an (epoch, KID), for inspection.

epoch: number
kid: bigint

checkCounter

checkCounter(epoch: number, kid: bigint, counter: number, nowMs: number): boolean

The counter check of 18 §7, applied before decryption.

epoch: number
kid: bigint
counter: number
nowMs: number

accept

accept(f: AcceptedFrame, nowMs: number): { play: boolean; events: PlaybackEvent[] }

Record an accepted frame (18 §9.7 "Records") and compare it with stored attestations (step 7). Returns whether to play it: only while playing and above its KID's play floor (18 §9.8).

nowMs: number

onAttestation

onAttestation(a: VerifiedAttestation, nowMs: number): PlaybackEvent[]

Handle an attestation that verified (18 §9.7 steps 5–7, §9.8).

nowMs: number

tick

tick(nowMs: number, opts?: { isDisrupted?: (f: { epoch: number; kid: bigint; counter: number }) => boolean }): PlaybackEvent[]

Apply the timers (18 §9.7 items 10 and 11, §9.8): the 3,000 ms unattested limit for frames played while playing (with an optional route-disruption test, budgeted at 3,000 ms of media per 60 s for the pair), the 5,000 ms withdrawal window, and the stop list's lifetime.

nowMs: number
opts: { isDisrupted?: (f: { epoch: number; kid: bigint; counter: number }) => boolean }

Default: {}

Source: media/playback.ts:138

VideoAssemblySlot class

One assembly slot: the fragments of one frame (pid, sourceId, gen, extended frameNumber) (17 §6.9). The first fragment records the frame header, fragCount and the arrival time; fragments are stored by index; the slot is complete when it holds 0 to fragCount − 1, and the protected frame is the chunks in index order.

class VideoAssemblySlot

constructor

new VideoAssemblySlot(first: VideoFragment, arrivalMs: number)
arrivalMs: number

frameHeader

readonly frameHeader: Uint8Array

The frame header of the first fragment (a copy).

header

readonly header: VideoFrameHeader

fragCount

readonly fragCount: number

firstArrivalMs

readonly firstArrivalMs: number

Audio-clock arrival time of the first fragment (ms).

bytesStored

get bytesStored(): number

Bytes of chunks stored so far.

isComplete

get isComplete(): boolean

Whether every index is present.

add

add(f: VideoFragment): SlotAddResult

Add a fragment of this frame (the first one too).

expired

expired(nowMs: number): boolean

Whether the slot has expired: 500 ms since its first fragment (17 §6.9 slot rule 4).

nowMs: number

assemble

assemble(): Uint8Array

The protected frame: the chunks in index order (17 §6.9 slot rule 3). Throws if incomplete.

Source: media/video-dc.ts:351

VideoDecodeOrder class

The decodability state of one stream (17 §6.10): lastRef, lastFrame and chainOk, the held frames that are ahead of the chain, and the 250 ms wait before the chain counts as broken. Times are audio-clock milliseconds.

class VideoDecodeOrder<F extends DecodableFrame = DecodableFrame>

constructor

new VideoDecodeOrder<F extends DecodableFrame = DecodableFrame>()

state

get state(): { chainOk: boolean; lastRef: number | null; lastFrame: number | null }

Current state (chainOk, lastRef, lastFrame).

waitingKeyframe

get waitingKeyframe(): boolean

Whether the receiver is waiting for a requested keyframe (for video_report.waitingKeyframe).

onComplete

onComplete(f: F, nowMs: number): DecodeStep<F>

A frame completed reassembly and (secure calls) decrypted, at nowMs.

f: F
nowMs: number

onLost

onLost(f: Pick<DecodableFrame, "frameNumber" | "keyframe" | "discardable">, nowMs: number): DecodeStep<F>

A frame was abandoned before completing (17 §6.9) or lost to decryption failure (17 §10.4). A missing discardable frame is never needed; a missing non-discardable frame or keyframe newer than lastFrame breaks the chain (17 §6.10 item 1).

f: Pick<DecodableFrame, "frameNumber" | "keyframe" | "discardable">
nowMs: number

onDecoderError

onDecoderError(nowMs: number): DecodeStep<F>

A decoder error (17 §10.4): the chain breaks; the caller requests a keyframe with reason decoder_error.

nowMs: number

tick

tick(nowMs: number): DecodeStep<F>

Apply the 250 ms wait for frames ahead of the chain (17 §6.10 item 1).

nowMs: number

reset

reset(): void

Forget the chain (a new stream, or an attestation stop, 17 §10.1).

Source: media/video-dc.ts:581

VideoStreamReassembler class

The assembly slots of one stream (pid, sourceId, gen), keyed by extended frameNumber (17 §6.9 slot rules 1 to 5): duplicates, completion, abandonment after 500 ms, when a newer keyframe completes, above 32 slots or 8 MiB (oldest first), and late fragments of frames not newer than the newest decoded one, with a record of the last 256 finished frame numbers. The call-wide 64 MiB limit and the gen rules belong to the caller.

class VideoStreamReassembler

constructor

new VideoStreamReassembler()

bytesHeld

get bytesHeld(): number

Bytes held in this stream's slots.

slotCount

get slotCount(): number

Number of open slots.

markDecoded

markDecoded(frameNumber: number): void

Tell the reassembler the extended frameNumber of the newest decoded frame (slot rule 5).

frameNumber: number

extend

extend(frameNumber: number): number

Extend a 16-bit frameNumber against the highest seen (17 §6.4).

frameNumber: number

expire

expire(nowMs: number): ReassemblyEvent[]

Abandon slots older than 500 ms (slot rule 4). Call regularly with the audio clock.

nowMs: number

add

add(f: VideoFragment, nowMs: number): ReassemblyEvent[]

Add a fragment that passed validation, arriving at nowMs on the audio clock.

nowMs: number

Source: media/video-dc.ts:442

ViewerForwarder class

The forwarding state of one (sender, source, viewer) (17 §8.2): a viewer state and needKey. Decide once per frame, at its first fragment, from the frame's K and D flags and the viewer's backlog age A; apply the same decision to every later fragment of that frame. A new viewer starts normal with needKey set (not a state change). Times are the relay's (or sender's) monotonic clock.

class ViewerForwarder

constructor

new ViewerForwarder()

state

get state(): ViewerForwardingState

The current viewer state.

needKey

get needKey(): boolean

Whether only a keyframe may be forwarded next.

poll

poll(nowMs: number): boolean

Apply the time-based transition thinned → normal: 5 s since entering thinned or since the last congestion drop, with A < 100 ms at every decision in that time. Returns true if the state changed.

nowMs: number

decide

decide(frame: { keyframe: boolean; discardable: boolean }, ageMs: number, nowMs: number): ForwardDecision

Decide for a frame whose first fragment arrived now, with backlog age ageMs (17 §8.2 table).

frame: { keyframe: boolean; discardable: boolean }
ageMs: number
nowMs: number

onExpired

onExpired(frame: { discardable: boolean }, nowMs: number): boolean

A fragment waited 500 ms in the viewer's queue and its frame was discarded (17 §8.2 Expiry). For a non-discardable frame, needKey is set and the state becomes keyframes_only (or stays paused). Returns true if the state changed.

frame: { discardable: boolean }
nowMs: number

Source: media/video-adapt.ts:37

VoiceActivityDetector class

The voice-activation timing of 16 §7.6: consecutive 20 ms windows, active at the end of the 3rd consecutive window above θ, inactive at the end of the 30th consecutive window at or below θ. The windows during those 600 ms are sent. Feed it one boolean per window (above θ or not); use vadThreshold or a speech model to decide.

class VoiceActivityDetector

constructor

new VoiceActivityDetector()

active

get active(): boolean

vadActive.

push

push(aboveThreshold: boolean): VadStep

Process one window.

aboveThreshold: boolean

reset

reset(): void

Forget the history.

Source: media/audio.ts:143

Functions

acceptableVideoCodecs function

function acceptableVideoCodecs(viewerDecodeLists: readonly readonly string[][], opts?: { secureSfu?: boolean }): ("vp8" | "vp9" | "h264" | "av1")[]

The codecs a sender may use for a source (17 §5.3 item 1): those in the decode list of every current viewer, plus vp8 always; only vp8 when no viewer has sent a preference. In a secure call on the SFU route, pass secureSfu to limit the set to vp8 and vp9 (17 §12.4, 18 §8.4.2).

viewerDecodeLists: readonly readonly string[][]
opts: { secureSfu?: boolean }

Default: {}

Source: media/video-dc.ts:815

attestedHashMatches function

function attestedHashMatches(a: Pick<ParsedMediaAttestation, "first" | "last" | "hashes">, counter: number, hash: Uint8Array): boolean | null

Compare an attestation's hash for counter with a frame hash (18 §9.7 step 6). Returns null when the counter is outside the attestation's range, true on a match, false on a mismatch.

a: Pick<ParsedMediaAttestation, "first" | "last" | "hashes">
counter: number
hash: Uint8Array

Source: media/attestation.ts:278

attributeAttestation function

function attributeAttestation(i: { epochInstalled: boolean; epochNewerThanInstalled: boolean; senderInRoster: boolean; leafIsSenders: boolean }): "pending" | "ignored" | "verify" | "kid_mismatch"

Step 3 of 18 §9.7 (attribution), as a decision:

  • verify: the receiver holds the epoch's EpochMediaState, P is in the call roster, and the KID's leaf in that epoch's roster snapshot is P's device: go on to the signature check;
  • kid_mismatch: the leaf isn't P's device: ignore and count media.kid_mismatch; nothing stops;
  • pending: the epoch isn't installed and is newer than every installed epoch, or P isn't in the roster yet: keep it unverified (see AttestationInbox);
  • ignored: the epoch is older than every installed epoch or was erased: count attest.ignored.
i: { epochInstalled: boolean; epochNewerThanInstalled: boolean; senderInRoster: boolean; leafIsSenders: boolean }

Source: media/attestation.ts:370

buildAudioLoss function

function buildAudioLoss(input: { sourceId: AudioSourceId; expected: number; received: number; late: number; bufferTargetMs: number }): AudioLossFeedback

Build an audio_loss payload from interval counts (16 §4.7): expected counts sequence numbers from the first to the last received in the interval; lost = expected − received; permilles are floor(1,000 × n / expected) (0 when nothing was expected); received is capped at 65,535.

input: { sourceId: AudioSourceId; expected: number; received: number; late: number; bufferTargetMs: number }

Source: media/voice-dc.ts:270

checkKidForTransport function

function checkKidForTransport(kid: bigint, transport: { sourceId: number; gen?: number }): KidCheckFailure | null

KID checks 1 to 3 of 18 §4.5: the KID is below 2^56 with a registered sourceId; its sourceId equals the transport's (the route header's on data channels, the Track's on the SFU); and on data channels through the relay the low 12 bits of its joinNonce equal the route header's gen. Pass gen only for data-channel frames (the SFU path has none). Check 4 (the leaf against the roster) is checkKidLeaf. Returns null if the KID passes.

kid: bigint
transport: { sourceId: number; gen?: number }

Source: media/sframe.ts:111

checkKidLeaf function

function checkKidLeaf(leaf: RosterLeaf | null | undefined, participant: { did: string; addr: string }): KidCheckFailure | null

KID check 4 of 18 §4.5 (also used for attestations, 18 §9.7 step 3): the leaf the KID names in the resolved epoch's roster snapshot is not blank and belongs to the participant that sent the frame (same did and addr as the call roster says). Returns null if it passes.

leaf: RosterLeaf | null | undefined
participant: { did: string; addr: string }

Source: media/sframe.ts:135

checkVideoFragmentForReceiver function

function checkVideoFragmentForReceiver(f: VideoFrameHeader, ctx: VideoReceiveContext): VideoDropReason | null

Receiver validation of a parsed fragment, items 2 to 4 of 17 §6.8.1 and the codec rule. Returns null if the fragment passes, or the reason. codec is counted in codecUnsupported, not invalidDrops, and the receiver sends a VideoPreference if it hasn't since the stream started. Item 7 (header or fragCount differing from an existing slot) is VideoAssemblySlot.add.

Source: media/video-dc.ts:288

checkVideoMessageForRelay function

function checkVideoMessageForRelay(bytes: Uint8Array, ctx: VideoRelayContext): VideoDropReason | null

Relay validation of a message received on sv-video (17 §6.8.2). Returns null if the relay forwards it unchanged, or the reason to drop and count it. The relay never reassembles chunks.

bytes: Uint8Array

Source: media/video-dc.ts:311

checkVoiceFrameForReceiver function

function checkVoiceFrameForReceiver(frame: VoiceRouteHeader, ctx: VoiceReceiveContext): VoiceDropReason | null

Receiver validation, items 2 to 5 of 16 §4.9.1, for a frame that parseVoiceFrame accepted (item 1). Returns null if the frame passes, or the reason to drop it silently and count it in invalidDrops. Item 6 (the SFrame KID against the route header) is checkKidForTransport of the SFrame module, applied once the SFrame header is parsed.

Source: media/voice-dc.ts:201

checkVoiceMessageForRelay function

function checkVoiceMessageForRelay(bytes: Uint8Array, ctx: VoiceRelayContext): VoiceDropReason | null

Relay validation of a message received on a participant connection's sv-audio channel (16 §4.9.2): vt, §4.8 sizes, bound pid, sourceId 0 or 2, and the C flag. Returns null if the relay forwards it (unchanged), or the reason to drop and count it. The relay never inspects the payload.

bytes: Uint8Array

Source: media/voice-dc.ts:224

compareSerial function

function compareSerial(a: number, b: number, bits: 16 | 32): number

Compare two bits-wide serial numbers (RFC 1982 §3.2): negative if a precedes b, positive if it follows, 0 if equal. A difference of exactly 2^(bits−1) is undefined in RFC 1982; it is reported as a following b (16 §4.5.3: such gaps aren't meaningful anyway).

a: number
b: number
bits: 16 | 32

Source: media/serial.ts:37

composeKid function

function composeKid(k: KidInit): bigint

KID = (joinNonce << 24) | (sourceId << 20) | (leaf_index << 4) | (epoch mod 16) (18 §4.1). Always below 2^56.

Source: media/sframe.ts:60

concatVoiceFrame function

function concatVoiceFrame(routeHeader: Uint8Array, payload: Uint8Array): Uint8Array

Append a payload to an already encoded route header (for the secure path, where the header is built first and used as SFrame metadata, 18 §8.2 item 1). Enforces 16 §4.8.

routeHeader: Uint8Array
payload: Uint8Array

Source: media/voice-dc.ts:112

createMediaAttestation function

function createMediaAttestation(input: CreateMediaAttestationInput): Promise<MediaAttestationData>

Build and sign the d of a media.attestation message (18 §9.4, §9.5). Senders add no other members.

Source: media/attestation.ts:155

decodeSFrameHeader function

function decodeSFrameHeader(bytes: Uint8Array): SFrameHeader

Decode an SFrame header at the start of bytes (RFC 9605 §4.3), accepting every encoding the RFC permits (18 §3.2 item 2). Throws media.malformed_frame if the bytes end inside the header.

bytes: Uint8Array

Source: media/sframe.ts:196

decodeSfuFrameMetadata function

function decodeSfuFrameMetadata(bytes: Uint8Array): SfuFrameMetadata

Decode SfuFrameMetadata (18 §8.4.3). Throws media.malformed_frame for another version or a bad length.

bytes: Uint8Array

Source: media/protect.ts:179

decodeVideoFragment function

function decodeVideoFragment(bytes: Uint8Array): VideoFragment

Like parseVideoFragment, but throws sdk.protocol_violation with data.reason.

bytes: Uint8Array

Source: media/video-dc.ts:265

decodeVoiceFrame function

function decodeVoiceFrame(bytes: Uint8Array): VoiceFrame

Like parseVoiceFrame, but throws sdk.protocol_violation with data.reason.

bytes: Uint8Array

Source: media/voice-dc.ts:176

decomposeKid function

function decomposeKid(kid: bigint): KidFields

Decompose a KID into its fields (18 §4.5). Throws for a KID of 2^56 or more.

kid: bigint

Source: media/sframe.ts:70

deriveSenderBaseKey function

function deriveSenderBaseKey(epochSecret: Uint8Array, leafIndex: number): Promise<Uint8Array<ArrayBufferLike>>

sender_base_key(e, L) = HKDF-Expand(sframe_epoch_secret(e), uint32(L), 16) (18 §3.3, RFC 9605 §5.2).

epochSecret: Uint8Array
leafIndex: number

Source: media/sframe.ts:273

deriveSFrameKey function

function deriveSFrameKey(epochSecret: Uint8Array, kid: bigint): Promise<SFrameKey>

Derive the SFrame key for kid from a media epoch secret (18 §3.3): the leaf comes from the KID, then sender_base_key, then derive_key_salt. Intermediate secrets are wiped.

epochSecret: Uint8Array
kid: bigint

Source: media/sframe.ts:344

deriveSFrameKeyMaterial function

function deriveSFrameKeyMaterial(baseKey: Uint8Array, kid: bigint): Promise<SFrameKeyMaterial>

derive_key_salt(KID, base_key) of RFC 9605 §4.4.2 for suite AES_128_GCM_SHA256_128 (18 §3.3): Extract with an empty salt, then Expand the key (16 bytes) and the salt (12 bytes) with the KID-bound labels.

baseKey: Uint8Array
kid: bigint

Source: media/sframe.ts:316

drawJoinNonce function

function drawJoinNonce(opts?: { usedInEpoch?: ReadonlySet<number>; avoidGens?: ReadonlySet<number>; random?: (n: number) => Uint8Array }): number

Draw a joinNonce for a new encryptor instance (18 §4.3, 16 §4.5.1) from the CSPRNG: redraw while the value is in usedInEpoch (18 §4.3 item 3) or its gen is in avoidGens (the gen of the client's most recent media process in the call and of every one it started in the last 60 s, 16 §4.5.1). random is injectable for tests only.

opts: { usedInEpoch?: ReadonlySet<number>; avoidGens?: ReadonlySet<number>; random?: (n: number) => Uint8Array }

Default: {}

Source: media/sframe.ts:604

encodeMediaAttestationContent function

function encodeMediaAttestationContent(c: MediaAttestationContent): Uint8Array

Encode MediaAttestationContent in the TLS presentation language (18 §9.4): uint8 version (1), opaque group_id<V>, uint64 epoch, opaque call_id[16], uint64 kid, uint64 first_counter, uint64 last_counter, opaque frame_hashes<V>.

Source: media/attestation.ts:102

encodeOpaqueV function

function encodeOpaqueV(bytes: Uint8Array): Uint8Array

opaque x<V>: varint length ‖ bytes (04 §3.2).

bytes: Uint8Array

Source: media/attestation.ts:41

encodeSFrameHeader function

function encodeSFrameHeader(kid: number | bigint, counter: number | bigint): Uint8Array

Encode an SFrame header (RFC 9605 §4.3) in the fewest bytes, as senders MUST (18 §3.2 item 1): a value below 8 goes in the config byte, otherwise its minimal big-endian bytes follow.

kid: number | bigint
counter: number | bigint

Source: media/sframe.ts:164

encodeSfuFrameMetadata function

function encodeSfuFrameMetadata(codec: "vp8" | "vp9" | "opus", clearPrefix: Uint8Array): Uint8Array

Encode SfuFrameMetadata (18 §8.4.3): uint8 version (1), uint8 codec, opaque clear_prefix<V>. Clear prefixes are at most 10 octets, so the length is one octet.

codec: "vp8" | "vp9" | "opus"
clearPrefix: Uint8Array

Source: media/protect.ts:173

encodeVarint function

function encodeVarint(n: number): Uint8Array

The RFC 9420 variable-length integer that prefixes an opaque x<V> vector (04 §3.2): 1, 2 or 4 bytes for values below 2^6, 2^14 and 2^30, always in the shortest form.

n: number

Source: media/attestation.ts:33

encodeVideoFragment function

function encodeVideoFragment(frameHeader: Uint8Array, fragIndex: number, fragCount: number, chunk: Uint8Array): Uint8Array

Encode one fragment: frame header ‖ fragIndex ‖ fragCount ‖ chunk (17 §6.2), enforcing 17 §6.7.

frameHeader: Uint8Array
fragIndex: number
fragCount: number
chunk: Uint8Array

Source: media/video-dc.ts:180

encodeVideoFrameHeader function

function encodeVideoFrameHeader(h: VideoFrameHeaderInit): Uint8Array

Encode the 16-octet frame header (17 §6.2), enforcing the sender rules of 17 §6.2 and §6.3.

Source: media/video-dc.ts:109

encodeVoiceFrame function

function encodeVoiceFrame(h: VoiceRouteHeaderInit, payload: Uint8Array): Uint8Array

Encode a complete frame message: route header ‖ payload (16 §4.3). The payload is one Opus packet (insecure) or the SFrame ciphertext of one (secure, produced with this route header as metadata, 18 §8.2). Enforces the §4.9 size limits.

payload: Uint8Array

Source: media/voice-dc.ts:103

encodeVoiceRouteHeader function

function encodeVoiceRouteHeader(h: VoiceRouteHeaderInit): Uint8Array

Encode the 12-octet route header (16 §4.3). Enforces the sender rules: sourceId 0 or 2, a frame with D carries neither S nor E, and only microphone frames carry D (16 §4.4).

Source: media/voice-dc.ts:74

epochsBeyondWindow function

function epochsBeyondWindow(installed: Iterable<number>, newest: number): number[]

The epochs to erase at once when newest is installed: those below newest − 15 (18 §6.4, §6.6 item 3). Vector R3: installing 43 over {27…42} erases 27.

installed: Iterable<number>
newest: number

Source: media/replay.ts:44

equivalentRung function

function equivalentRung(oldBudgetKbps: number, newLadder: readonly ({ rung: number; budgetKbps: number })[]): number

The equivalent rung on a new ladder (17 §5.6): the rung with the largest budget not above the old rung's budget, or rung 0 if there is none.

oldBudgetKbps: number
newLadder: readonly ({ rung: number; budgetKbps: number })[]

Source: media/video-adapt.ts:251

evaluateGate function

function evaluateGate(i: GateInputs): GateResult

Evaluate the transmit gate (16 §7.3) and, in the same evaluation, the TalkState (16 §7.10), so the exported state never says transmitting while the gate is closed.

Source: media/audio.ts:77

extendSerial function

function extendSerial(value: number, highest: number | null, bits: 16 | 32): number

Extend a received bits-wide value to 64 bits: the extended value closest to highest, the highest extended value seen so far (16 §4.5.2, RFC 1982). With no highest yet, the value itself. A distance of exactly half the space resolves forwards.

value: number
highest: number | null
bits: 16 | 32

Source: media/serial.ts:19

fecPacketLossPercent function

function fecPacketLossPercent(recentLossPermilles: readonly number[]): number

The OPUS_SET_PACKET_LOSS_PERC setting (16 §5.3): 10 with no audio_loss report accepted for the source in the last 6 s (pass an empty list); otherwise clamp(ceil(p / 10), 5, 25) where p is the largest lossPermille among those reports.

recentLossPermilles: readonly number[]

Source: media/voice-dc.ts:291

fragmentVideoFrame function

function fragmentVideoFrame(frameHeader: Uint8Array, protectedFrame: Uint8Array, chunkSize?: number): Uint8Array<ArrayBufferLike>[]

Split a protected frame into fragments (17 §6.6): fragCount = ceil(length / chunkSize), chunks of consecutive octets in order, every chunk but the last of chunkSize octets, every fragment carrying the frame header unchanged. chunkSize defaults to the recommended 1,130 octets. Throws for a protected frame above 2 MiB or needing more than 2,048 fragments, which MUST NOT be sent (17 §6.6 item 5): the sender discards it and sends a lower-quality keyframe next.

frameHeader: Uint8Array
protectedFrame: Uint8Array
chunkSize: number

Default: VIDEO_RECOMMENDED_CHUNK_BYTES

Source: media/video-dc.ts:201

frameHash function

function frameHash(metadata: Uint8Array, sframeCiphertext: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

frame_hash = the first 8 octets of SHA-256(FrameHashInput) (18 §9.2).

metadata: Uint8Array
sframeCiphertext: Uint8Array

Source: media/attestation.ts:66

frameHashInput function

function frameHashInput(metadata: Uint8Array, sframeCiphertext: Uint8Array): Uint8Array

FrameHashInput (18 §9.2): opaque metadata<V> ‖ opaque sframe_ciphertext<V>. The metadata is the route header (voice-dc/1), the video frame header (video-dc/1) or the SfuFrameMetadata encoding (sfu-rtp/1); the ciphertext is the SFrame ciphertext as sent.

metadata: Uint8Array
sframeCiphertext: Uint8Array

Source: media/attestation.ts:61

genOfJoinNonce function

function genOfJoinNonce(joinNonce: number): number

The stream generation of a joinNonce: its low 12 bits (16 §4.5.1).

joinNonce: number

Source: media/sframe.ts:81

hasListeningAuthority function

function hasListeningAuthority(newest: AcceptedTick | null, ownPid: number, nowMs: number): boolean

Listening authority (16 §12.3, 17 §10.3 item 6): the client may render call audio and video only while the newest tick is fresh and lists its own pid in listeners.

newest: AcceptedTick | null
ownPid: number
nowMs: number

Source: media/lease.ts:112

importSFrameKey function

function importSFrameKey(kid: bigint, key: Uint8Array, salt: Uint8Array): Promise<SFrameKey>

Import a 16-byte sframe_key as a non-extractable WebCrypto AES-GCM key.

kid: bigint
key: Uint8Array
salt: Uint8Array

Source: media/sframe.ts:333

inspectSecureVideoFrame function

function inspectSecureVideoFrame(frameHeader: Uint8Array, protectedFrame: Uint8Array): ParsedSFrame

Parse a reassembled secure video frame's SFrame header and apply KID checks 1 to 3 against the frame header (18 §4.5, 17 §6.8.1). Throws media.malformed_frame or media.kid_mismatch.

frameHeader: Uint8Array
protectedFrame: Uint8Array

Source: media/protect.ts:127

inspectSecureVoiceFrame function

function inspectSecureVoiceFrame(frame: VoiceFrame): ParsedSFrame

Parse the SFrame header of a secure voice-dc/1 frame and apply KID checks 1 to 3 against the route header (18 §4.5, 16 §4.9.1 item 6). Returns the parsed SFrame so the caller can resolve the epoch, check the leaf and run the counter check before decrypting. Throws media.malformed_frame or media.kid_mismatch (the frame is invalid).

frame: VoiceFrame

Source: media/protect.ts:65

isCovered function

function isCovered(newest: AcceptedTick | null, pid: number, kind: "audio" | "video", nowMs: number): boolean

The coverage rule (16 §12.2, 17 §10.3): a sender pid is covered for kind (audio covers sources 0 and 2, video sources 1 and 3) if and only if the newest accepted tick is fresh and lists it. With no accepted tick, no sender is covered.

newest: AcceptedTick | null
pid: number
kind: "audio" | "video"
nowMs: number

Source: media/lease.ts:87

isMediaError function

function isMediaError(e: unknown, code?: "media.keys_unavailable" | "media.key_exhausted" | "media.decrypt_failed" | "media.unknown_epoch" | "media.replay" | "media.kid_mismatch" | "media.malformed_frame" | "media.stream_limit" | "media.attestation_invalid" | "media.attestation_mismatch" | "media.unattested" | "media.attestation_unexpected"): e is SloppyVoiceError

True if e is a media.* error, optionally a specific code (18 §10.1).

e: unknown
code?: "media.keys_unavailable" | "media.key_exhausted" | "media.decrypt_failed" | "media.unknown_epoch" | "media.replay" | "media.kid_mismatch" | "media.malformed_frame" | "media.stream_limit" | "media.attestation_invalid" | "media.attestation_mismatch" | "media.unattested" | "media.attestation_unexpected"

Source: media/errors.ts:36

isSourceCovered function

function isSourceCovered(newest: AcceptedTick | null, pid: number, sourceId: number, nowMs: number): boolean

Coverage of the sender of a given sourceId (16 §12.2, 17 §10.3).

newest: AcceptedTick | null
pid: number
sourceId: number
nowMs: number

Source: media/lease.ts:92

isTickFresh function

function isTickFresh(newest: AcceptedTick | null, nowMs: number): boolean

Whether the newest accepted tick is fresh at nowMs: t − K.rxAt < V (16 §12.2).

newest: AcceptedTick | null
nowMs: number

Source: media/lease.ts:78

isWellFormedTick function

function isWellFormedTick(t: unknown): t is LeaseTickLike

Well-formedness of a tick (16 §12.1 item 3, 15 §4.2): callId a string, seq and validMs non-negative integers, every list in ascending order without duplicates, and audio and video subsets of listeners. A tick that breaks these rules is not accepted.

t: unknown

Source: media/lease.ts:66

jitterTarget function

function jitterTarget(input: { recentX: readonly number[]; previousMs: number; latePercent: number }): number

The recommended target computation of 16 §9.3 for one stream: from the X values of the frames of the last 3 s of talkspurt time (at least 25 of them, else keep previousMs), then, if more than 3 % of the frames expected in the last 2 s were late, min(180, max(T, previous + 20)). The bounds (60–180 ms) hold whatever algorithm is used.

input: { recentX: readonly number[]; previousMs: number; latePercent: number }

Source: media/audio.ts:229

jitterTargetForPercentile function

function jitterTargetForPercentile(q95Ms: number): number

The jitter target for a 95th percentile Q of X = D − B: clamp(Q + 20, 60, 180) ms (16 §9.3 step 2).

q95Ms: number

Source: media/audio.ts:219

kidToString function

function kidToString(kid: bigint): string

A KID as a JSON kid-string: decimal, no leading zeros (18 §4.1).

kid: bigint

Source: media/sframe.ts:87

mediaAttestationMessage function

function mediaAttestationMessage(d: MediaAttestationData, from?: number): MediaAttestationMessage

Wrap a MediaAttestation in its control-channel message (18 §9.5). A sender leaves from out; the relay sets it to the sender's pid on the copies it forwards (15 §6.5).

from?: number

Source: media/attestation.ts:191

mediaError function

function mediaError(code: "media.keys_unavailable" | "media.key_exhausted" | "media.decrypt_failed" | "media.unknown_epoch" | "media.replay" | "media.kid_mismatch" | "media.malformed_frame" | "media.stream_limit" | "media.attestation_invalid" | "media.attestation_mismatch" | "media.unattested" | "media.attestation_unexpected", detail: string, opts?: { retryAfterMs?: number; data?: Record<string, unknown>; cause?: unknown }): SloppyVoiceError

Build a SloppyVoiceError for a media.* condition with the status, retryable and userAction of 18 §10.1. No media.* code defines data; data here is SDK-side context for the caller and is never sent anywhere. These errors are never shown as security warnings (D-055).

code: "media.keys_unavailable" | "media.key_exhausted" | "media.decrypt_failed" | "media.unknown_epoch" | "media.replay" | "media.kid_mismatch" | "media.malformed_frame" | "media.stream_limit" | "media.attestation_invalid" | "media.attestation_mismatch" | "media.unattested" | "media.attestation_unexpected"
detail: string
opts: { retryAfterMs?: number; data?: Record<string, unknown>; cause?: unknown }

Default: {}

Source: media/errors.ts:17

normalizeTalkStateForDisplay function

function normalizeTalkStateForDisplay(s: { state: string; reason: string | null; blockedBy?: string | null }): TalkState

How a user interface reads a TalkState from a possibly newer engine (16 §7.10): a state or reason it doesn't know is shown as not_heard with no reason, which never looks like transmitting.

s: { state: string; reason: string | null; blockedBy?: string | null }

Source: media/audio.ts:115

openSfuFrame function

function openSfuFrame(parts: SfuFrameParts, key: SFrameKey): Promise<Uint8Array<ArrayBufferLike>>

Receiver transform steps 4 and 5 (18 §8.4.4): decrypt X with SfuFrameMetadata and return P ‖ plaintext for the decoder. On failure (media.decrypt_failed) drop the frame.

Source: media/protect.ts:253

openVideoFrame function

function openVideoFrame(frameHeader: Uint8Array, protectedFrame: Uint8Array, key: SFrameKey): Promise<Uint8Array<ArrayBufferLike>>

Decrypt a reassembled secure video frame with its frame header as metadata (18 §8.3 item 3).

frameHeader: Uint8Array
protectedFrame: Uint8Array

Source: media/protect.ts:137

openVoiceFrame function

function openVoiceFrame(frame: VoiceFrame, key: SFrameKey): Promise<Uint8Array<ArrayBufferLike>>

Decrypt a secure voice-dc/1 frame with the key resolved for its KID (18 §8.2 item 4), using the route header as received as metadata. Returns the Opus packet. Throws as inspectSecureVoiceFrame and media.decrypt_failed. Apply the freshness check (18 §7) to the route header's timestamp after this succeeds.

frame: VoiceFrame

Source: media/protect.ts:79

opusPacketDurationMs function

function opusPacketDurationMs(packet: Uint8Array): number | null

The duration of an Opus packet in ms, derived from its TOC as receivers MUST (16 §5.6, RFC 6716 §3.1, §3.2): one frame for code 0, two for codes 1 and 2, and the count octet's M for code 3. Returns null for an empty packet, a code-3 packet without its count octet or with M = 0, or a duration above 120 ms (RFC 6716 §3.2.5). Receivers MUST handle 10 to 60 ms and MAY drop others.

packet: Uint8Array

Source: media/voice-dc.ts:339

ownLeaseState function

function ownLeaseState(newest: AcceptedTick | null, ownPid: number, nowMs: number, kind?: "audio" | "video"): LeaseState

The client's own leaseState for audio (16 §12.3): stale with no accepted tick or one that is V old or older; covered if its pid is in K.audio; otherwise excluded. Pass kind: 'video' for the same rule on the video list (17 §10.3 item 7).

newest: AcceptedTick | null
ownPid: number
nowMs: number
kind: "audio" | "video"

Default: 'audio'

Source: media/lease.ts:103

parseAudioLoss function

function parseAudioLoss(d: unknown): AudioLossFeedback | null

Check the d payload of an audio_loss feedback message (16 §4.7): kind, sourceId 0 or 2, permille values and bufferTargetMs 0–1,000, received 0–65,535. Unknown members are ignored. Returns the typed payload (known members only), or null when a sender must ignore it.

d: unknown

Source: media/voice-dc.ts:247

parseKidString function

function parseKidString(s: unknown): bigint | null

Parse a kid-string (18 §4.1 ABNF, value below 2^56), or return null.

s: unknown

Source: media/sframe.ts:95

parseMediaAttestation function

function parseMediaAttestation(d: unknown, opts: { callId: string; serializedLength?: number }): MediaAttestationParseResult

The structure check of 18 §9.7 step 2: every constraint of §9.5, callId equal to this call's, and src equal to the KID's sourceId. serializedLength, if given, is the size of the whole message as received; above 3,600 octets it is dropped. Unknown members are ignored.

d: unknown
opts: { callId: string; serializedLength?: number }

Source: media/attestation.ts:222

parseOpusToc function

function parseOpusToc(toc: number): OpusToc

Parse an Opus TOC octet (RFC 6716 §3.1).

toc: number

Source: media/voice-dc.ts:319

parseSFrameCiphertext function

function parseSFrameCiphertext(bytes: Uint8Array): ParsedSFrame

Parse an SFrame ciphertext under the sv1 profile (18 §3.1): a header RFC 9605 §4.3 can parse, a KID below 2^56 and a counter below 2^32, and room for the 16-byte tag. Anything else throws media.malformed_frame (the frame is invalid, not lost).

bytes: Uint8Array

Source: media/sframe.ts:228

parseVideoFeedback function

function parseVideoFeedback(d: unknown, opts?: { fromOwnRelay?: boolean }): KeyframeRequestFeedback | VideoPreference | VideoReportFeedback | RelayVideoFeedback | null

Check a received video feedback payload (17 §7.1 to §7.5). Returns the payload with known members only, or null when it must be ignored: an unknown kind, a sourceId other than 1 or 3, a member out of range, or a relay-originated kind that didn't arrive from the sender's own relay with no from (pass fromOwnRelay, 17 §7.1 item 3). Unknown reason and state values are kept as given; treat them as loss and paused (17 §7.2, §7.5).

d: unknown
opts: { fromOwnRelay?: boolean }

Default: {}

Source: media/video-dc.ts:747

parseVideoFragment function

function parseVideoFragment(bytes: Uint8Array): VideoParseResult

Parse a video-dc/1 message with the context-free checks receivers and relays share: vt, the 17 §6.7 sizes, K and D not both set, and the fragment fields (17 §6.8.1 items 1, 5, 6; 17 §6.8.2 items 1 and 5). The returned views alias bytes.

bytes: Uint8Array

Source: media/video-dc.ts:243

parseVoiceFrame function

function parseVoiceFrame(bytes: Uint8Array): VoiceParseResult

Parse a voice-dc/1 message with the context-free checks every receiver and relay applies: vt is 0x10, and the size limits of 16 §4.8 (13 to 1,100 octets; a plain Opus payload at most 1,000 octets). Field rules that depend on the call are in checkVoiceFrameForReceiver and checkVoiceFrameForRelay. The returned views alias bytes.

bytes: Uint8Array

Source: media/voice-dc.ts:166

percentile function

function percentile(values: readonly number[], p: number): number

Nearest-rank percentile (p in 0–100) of a list of numbers. Used for 16 §7.6's 10th percentile and 16 §9.3's 95th percentile, which don't name a percentile method.

values: readonly number[]
p: number

Source: media/audio.ts:197

playoutDecision function

function playoutDecision(input: { arrivalMs: number; streamTimeMs: number; offsetMs: number }): { deadlineMs: number; late: boolean; holdMs: number; exceedsHoldCap: boolean }

Timeliness and hold of one frame (16 §9.2, §9.3): with base delay B, playout offset O and the frame's stream time s (extended timestamp / 48) and arrival a, the deadline is p = s + O; the frame is late if a > p, and is held p − a, which must not exceed 200 ms.

input: { arrivalMs: number; streamTimeMs: number; offsetMs: number }

Source: media/audio.ts:240

protectSfuFrame function

function protectSfuFrame(encryptor: SFrameEncryptor, sourceId: SourceId, codec: "vp8" | "vp9" | "opus", frame: Uint8Array): Promise<ProtectedFrameInfo & { data: Uint8Array }>

Sender transform for one encoded frame of a published source (18 §8.4.4 sender steps 2 to 5): split off the clear prefix P, build SfuFrameMetadata, encrypt the rest B with the SFU encryptor instance, and return P ‖ X. A frame shorter than its clear prefix plus 1 octet MUST NOT be sent (18 §8.4.2 item 3); this throws. Step 1 (drop frames of a source the device's lease doesn't cover) is the caller's.

encryptor: SFrameEncryptor
sourceId: SourceId
codec: "vp8" | "vp9" | "opus"
frame: Uint8Array

Source: media/protect.ts:194

protectVideoFrame function

function protectVideoFrame(encryptor: SFrameEncryptor, header: Omit<VideoFrameHeaderInit, "ciphertext" | "gen">, encodedFrame: Uint8Array, chunkSize?: number): Promise<ProtectedFrameInfo & { frameHeader: Uint8Array; fragments: Uint8Array<ArrayBufferLike>[] }>

Protect one encoded video frame for video-dc/1 (18 §8.3, 17 §6.5): build the frame header with C set and gen from the encryptor, encrypt the whole frame with the header as metadata, then fragment the SFrame ciphertext (encrypt, then fragment). A frame whose protected form could exceed 2 MiB or 2,048 fragments is refused before it is encrypted (17 §6.6 item 5).

encryptor: SFrameEncryptor
header: Omit<VideoFrameHeaderInit, "ciphertext" | "gen">
encodedFrame: Uint8Array
chunkSize?: number

Source: media/protect.ts:95

protectVoiceFrame function

function protectVoiceFrame(encryptor: SFrameEncryptor, header: Omit<VoiceRouteHeaderInit, "ciphertext" | "gen">, opusPacket: Uint8Array): Promise<ProtectedFrameInfo & { message: Uint8Array }>

Protect one Opus packet as a secure voice-dc/1 frame (18 §8.2, 16 §4.6): build the complete route header with C set and gen = the encryptor's joinNonce low 12 bits, encrypt with that header as metadata, and append the SFrame ciphertext. The identical bytes go on every path.

encryptor: SFrameEncryptor
header: Omit<VoiceRouteHeaderInit, "ciphertext" | "gen">
opusPacket: Uint8Array

Source: media/protect.ts:47

readVideoFrameHeader function

function readVideoFrameHeader(bytes: Uint8Array): VideoFrameHeader

Decode the frame-header fields of a fragment or of a 16-octet header (17 §6.2), without validating them.

bytes: Uint8Array

Source: media/video-dc.ts:141

readVoiceRouteHeader function

function readVoiceRouteHeader(bytes: Uint8Array): VoiceRouteHeader

Decode the 12-octet route header fields (16 §4.3) without validating them.

bytes: Uint8Array

Source: media/voice-dc.ts:129

reassembleVideoFrame function

function reassembleVideoFrame(fragments: readonly VideoFragment[]): { frameHeader: Uint8Array; protectedFrame: Uint8Array }

Reassemble one frame from a complete set of its fragments in any order (17 §6.9). Returns the frame header and the protected frame, or throws sdk.protocol_violation when fragments are missing, duplicated or inconsistent.

fragments: readonly VideoFragment[]

Source: media/video-dc.ts:414

resolveFrameEpoch function

function resolveFrameEpoch(installed: Iterable<number>, residue: number): EpochResolution

Resolve the epoch of a frame whose KID has residue residue (18 §6.4). installed is the set R of epochs with an EpochMediaState, which 18 §6.6 keeps within 16 consecutive epochs so no two share a residue. With nothing installed there is no target; this throws.

installed: Iterable<number>
residue: number

Source: media/replay.ts:29

selectVideoCodec function

function selectVideoCodec(preference: readonly ("vp8" | "vp9" | "h264" | "av1")[], viewerDecodeLists: readonly readonly string[][], opts?: { secureSfu?: boolean }): "vp8" | "vp9" | "h264" | "av1"

Pick the first codec of preference that is acceptable (17 §5.3 item 2), vp8 if none, and vp8 when no viewer has sent a preference.

preference: readonly ("vp8" | "vp9" | "h264" | "av1")[]
viewerDecodeLists: readonly readonly string[][]
opts: { secureSfu?: boolean }

Default: {}

Source: media/video-dc.ts:826

serialDistance function

function serialDistance(a: number, b: number, bits: 16 | 32): number

(a − b) mod 2^bits: the forward distance from b to a (17 §6.10 uses it for refSeq).

a: number
b: number
bits: 16 | 32

Source: media/serial.ts:46

sframeContextId function

function sframeContextId(joinNonce: number, sourceId: SourceId): bigint

context_id = (joinNonce << 4) | sourceId, 36 bits (18 §4.1).

joinNonce: number
sourceId: SourceId

Source: media/sframe.ts:50

sframeDecrypt function

function sframeDecrypt(key: SFrameKey, ciphertext: Uint8Array, metadata: Uint8Array): Promise<SFrameDecrypted>

SFrame decryption (18 §3.5, RFC 9605 §4.4.4) with the key the caller resolved for the frame's KID (after epoch resolution, 18 §6.4, and the KID checks, 18 §4.5). The AAD is the header as received followed by metadata. Throws media.malformed_frame for a header outside the profile, media.kid_mismatch if key is for another KID, and media.decrypt_failed on a tag failure, releasing no plaintext. The replay checks of 18 §7 are the caller's (see ReplayWindow).

ciphertext: Uint8Array
metadata: Uint8Array

Source: media/sframe.ts:404

sframeEncrypt function

function sframeEncrypt(key: SFrameKey, counter: number | bigint, metadata: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>

SFrame encryption (18 §3.4, RFC 9605 §4.4.3): header || AES-128-GCM-Encrypt(key, nonce, header || metadata, plaintext). The caller owns the counter: one value per KID, ever (18 §5); SFrameEncryptor does that. Refuses an empty plaintext (18 §3.4 item 3).

counter: number | bigint
metadata: Uint8Array
plaintext: Uint8Array

Source: media/sframe.ts:376

sframeEpochSecret function

function sframeEpochSecret(exporter: MlsExporter): Promise<Uint8Array<ArrayBufferLike>>

sframe_epoch_secret(e) = MLS-Exporter("SFrame 1.0 Base Key", "", 16) (18 §3.3), computed while the device's MLS state is in epoch e: pass the MlsGroupHandle (or MlsPendingCommit) from your MlsProvider, in epoch e. Keep the result only in the EpochMediaState; never archive, share or back it up (18 §3.3 item 3).

exporter: MlsExporter

Source: media/sframe.ts:266

sframeKeyLabel function

function sframeKeyLabel(kid: bigint, cipherSuite?: number): Uint8Array

"SFrame 1.0 Secret key " || uint64(KID) || uint16(cipher_suite) (18 §3.3, RFC 9605 §4.4.2).

kid: bigint
cipherSuite: number

Default: SFRAME.cipherSuite

Source: media/sframe.ts:292

sframeNonce function

function sframeNonce(salt: Uint8Array, counter: number | bigint): Uint8Array

nonce = sframe_salt XOR uint96(CTR) (18 §3.4).

salt: Uint8Array
counter: number | bigint

Source: media/sframe.ts:362

sframeSaltLabel function

function sframeSaltLabel(kid: bigint, cipherSuite?: number): Uint8Array

"SFrame 1.0 Secret salt " || uint64(KID) || uint16(cipher_suite) (18 §3.3, RFC 9605 §4.4.2).

kid: bigint
cipherSuite: number

Default: SFRAME.cipherSuite

Source: media/sframe.ts:297

sfuClearPrefixLength function

function sfuClearPrefixLength(codec: "vp8" | "vp9" | "opus", frame: Uint8Array): number

The clear-prefix length of a frame (18 §8.4.2): Opus 0; VP8 10 for a keyframe (bit 0 of the first octet is 0) and 3 otherwise; VP9 0.

codec: "vp8" | "vp9" | "opus"
frame: Uint8Array

Source: media/protect.ts:160

sfuLayerLimits function

function sfuLayerLimits(pref: Pick<VideoPreference, "maxWidth" | "maxHeight" | "maxFps">, layers: { scaleDownFactors: readonly number[]; topPicture: { longEdge: number; shortEdge: number }; fullFps: number; temporalFractions?: readonly number[] }): { maxSpatialLayer?: number; maxTemporalLayer?: number }

Derive maxSpatialLayer and maxTemporalLayer for an SFU subscription from the viewer's own VideoPreference (17 §12.3). scaleDownFactors lists the spatial layers lowest first (webcam [4, 2, 1], motion screen [2, 1], detail screen [1]); topPicture is the top layer's picture (long × short edge); fullFps the full frame rate; temporalFractions defaults to L1T3's quarter, half and full. A member is omitted when the preference has no limit or no layer satisfies it.

pref: Pick<VideoPreference, "maxWidth" | "maxHeight" | "maxFps">
layers: { scaleDownFactors: readonly number[]; topPicture: { longEdge: number; shortEdge: number }; fullFps: number; temporalFractions?: readonly number[] }

Source: media/video-adapt.ts:273

sharedVideoBudgetKbps function

function sharedVideoBudgetKbps(maxInboundKbps: number): number

Shared budget of all video sources: 0.9 × maxInboundKbps − 300 kbit/s (17 §5.5 cap 1).

maxInboundKbps: number

Source: media/constants.ts:385

shouldReportAttestationFailure function

function shouldReportAttestationFailure(i: AttestationReportInput): boolean

Whether to send a media_attestation diagnostics report (18 §10.3): diagnostics failures or full; failures while already stopped aren't reported; unattested only once the stop counts and it is at least the third counted stop in the call; at most one per (call, pid, source) per 10 minutes and 10 per call.

Source: media/playback.ts:388

signMediaAttestationContent function

function signMediaAttestationContent(dsk: Ed25519Signer, c: MediaAttestationContent): Promise<Uint8Array<ArrayBufferLike>>

SignLabelled(DSK, "media-attest", MediaAttestationContent) (18 §9.4, 04 §7.1). Returns the 64-octet signature.

Source: media/attestation.ts:121

splitSfuFrame function

function splitSfuFrame(codec: "vp8" | "vp9" | "opus", data: Uint8Array, track: { sourceId: AudioSourceId | VideoSourceId }): SfuFrameParts

Receiver transform steps 1 to 3 (18 §8.4.4) for a frame of a Track whose sourceId comes from the session's Track list: determine the clear prefix, split, parse the SFrame header and check the KID's sourceId against the Track (there is no gen on this path). Throws media.malformed_frame (too short, or a header outside the profile) or media.kid_mismatch. The leaf check, epoch resolution and counter check follow; then openSfuFrame.

codec: "vp8" | "vp9" | "opus"
data: Uint8Array
track: { sourceId: AudioSourceId | VideoSourceId }

Source: media/protect.ts:237

talkBlockedBy function

function talkBlockedBy(voiceLease: VoiceLeaseAudio | null | undefined): AudioBlockedBy

blockedBy (16 §7.10): the newest VoiceLease's audioBlockedBy; other if that VoiceLease has audio true, none has arrived, or the value is unknown or null.

voiceLease: VoiceLeaseAudio | null | undefined

Source: media/audio.ts:68

vadThreshold function

function vadThreshold(recentWindowLevelsDbfs: readonly number[]): number

The automatic voice-activation threshold θ = clamp(N + 10 dB, −60 dBFS, −20 dBFS), N the 10th percentile of the window levels of the last 10 s (16 §7.6 item 2).

recentWindowLevelsDbfs: readonly number[]

Source: media/audio.ts:209

verifyMediaAttestation function

function verifyMediaAttestation(a: ParsedMediaAttestation, opts: { groupId: string; dsk: Uint8Array }): Promise<boolean>

Verify a parsed attestation's signature (18 §9.7 step 4): rebuild MediaAttestationContent from the message and the receiver's own group_id and call ID, and check it under the DSK the receiver looked up itself from the epoch's roster snapshot (the leaf the KID names). An invalid signature stops nothing (D-080).

opts: { groupId: string; dsk: Uint8Array }

Source: media/attestation.ts:266

verifyMediaAttestationContent function

function verifyMediaAttestationContent(dskPublicKey: Uint8Array, c: MediaAttestationContent, sig: Uint8Array): Promise<boolean>

VerifyLabelled(DSK, "media-attest", content, sig) with the strict rules of 04 §4.3 (18 §9.7 step 4).

dskPublicKey: Uint8Array
sig: Uint8Array

Source: media/attestation.ts:126

videoCodecName function

function videoCodecName(octet: number): "vp8" | "vp9" | "h264" | "av1" | null

The codec name of a video-dc/1 codec octet, or null for a reserved octet (17 §5.1).

octet: number

Source: media/video-dc.ts:47

videoCodecOctet function

function videoCodecOctet(name: "vp8" | "vp9" | "h264" | "av1"): number

The video-dc/1 codec octet of a codec name (17 §5.1).

name: "vp8" | "vp9" | "h264" | "av1"

Source: media/video-dc.ts:42

vp8ClearPrefixInfo function

function vp8ClearPrefixInfo(frame: Uint8Array): { keyframe: boolean; prefix: Uint8Array; firstPartitionSize: number; width?: number; height?: number }

The VP8 clear prefix of a frame (17 §12.6, §12.10): the 3-octet frame tag, and for a keyframe the start code and the 14-bit width and height. Returns the prefix and what it says.

frame: Uint8Array

Source: media/protect.ts:262

windowLevelDbfs function

function windowLevelDbfs(samples: ArrayLike<number>): number

The 20 ms window level in dBFS: RMS of samples in [−1, 1] (16 §7.6 item 1). Silence is −Infinity.

samples: ArrayLike<number>

Source: media/audio.ts:184

Interfaces

AcceptedFrame interface

A frame the receiver accepted (decrypted, and passed the checks of 18 §7).

interface AcceptedFrame

epoch

epoch: number

kid

kid: bigint

counter

counter: number

hash

hash: Uint8Array

The 8-octet frame hash (18 §9.2).

durationMs?

durationMs?: number

Media duration in ms, for the excuse budget (default 20).

Source: media/playback.ts:69

AcceptedTick interface

The newest accepted tick and its audio-clock receipt time rxAt (16 §12.1 item 4).

interface AcceptedTick

tick

tick: LeaseTickLike

rxAt

rxAt: number

Source: media/lease.ts:41

AttestationBatch interface

A closed batch, ready to sign with createMediaAttestation.

interface AttestationBatch

kid

kid: bigint

epoch

epoch: number

firstCounter

firstCounter: number

frameHashes

frameHashes: Uint8Array<ArrayBufferLike>[]

Source: media/attestation.ts:292

AttestationReportInput interface

Inputs of shouldReportAttestationFailure.

interface AttestationReportInput

diagnostics

diagnostics: "full" | string & {} | "off" | "failures"

15 §14.2's diagnostics setting.

reason

reason: "invalid" | "mismatch" | "equivocation" | "unattested"

alreadyStopped

alreadyStopped: boolean

The stream was already stopped when the failure happened.

stopCounted?

stopCounted?: boolean

For unattested: the stop now counts (it wasn't withdrawn within 5,000 ms).

countedStopsInCall

countedStopsInCall: number

Counted stops in this call so far, this one included.

lastReportForStreamAt

lastReportForStreamAt: number | null

When a report was last sent for this (callId, sender pid, sourceId), or null. Wall clock (18 §11).

reportsSentInCall

reportsSentInCall: number

nowMs

nowMs: number

Source: media/playback.ts:366

CreateMediaAttestationInput interface

Input of createMediaAttestation.

interface CreateMediaAttestationInput

dsk

dsk: Ed25519Signer

The sender device's DSK signer.

groupId

groupId: string

epoch

epoch: number

callId

callId: string

kid

kid: bigint

firstCounter

firstCounter: number

frameHashes

frameHashes: readonly Uint8Array<ArrayBufferLike>[]

The batch's 8-octet frame hashes in counter order, from firstCounter on (1 to 256).

Source: media/attestation.ts:139

DecodableFrame interface

A complete, authenticated frame as the decodability rules see it (17 §6.10).

interface DecodableFrame

frameNumber

frameNumber: number

Extended frameNumber (17 §6.4).

refSeq

refSeq: number

keyframe

keyframe: boolean

discardable

discardable: boolean

Source: media/video-dc.ts:554

DecodeStep interface

What VideoDecodeOrder decided for one input.

interface DecodeStep<F extends DecodableFrame>

decode

decode: F[]

Frames to pass to the decoder now, in this order (increasing frameNumber).

held

held: F[]

Frames held because they are ahead of the chain.

late

late: F[]

Frames dropped as behind; count framesLate.

undecodable

undecodable: F[]

Frames discarded because the chain is broken; count framesUndecodable.

requestKeyframe

requestKeyframe: boolean

Send keyframe_request with reason loss (subject to 17 §7.2's repeat limits).

Source: media/video-dc.ts:563

EpochTickResult interface

What ReceiverEpochs.tick found.

interface EpochTickResult<F>

erased

erased: number[]

Epochs whose retention ended (18 §6.6 item 2): erase their EpochMediaState.

expired

expired: F[]

Held frames whose hold expired: undecryptable, media.unknown_epoch (18 §6.5 item 3).

Source: media/epochs.ts:164

ForwardDecision interface

One forwarding decision (17 §8.2).

interface ForwardDecision

forward

forward: boolean

dropReason?

dropReason?: "congestion" | "need_key" | "thinning"

Why a frame was dropped: congestion (counts as a congestion drop), need_key, or thinning.

state

state: ViewerForwardingState

stateChanged

stateChanged: boolean

The state changed: the relay reports it to the sender with video_viewer_state (17 §7.5).

Source: media/video-adapt.ts:21

GateInputs interface

The inputs of the transmit gate, sampled on the audio clock (16 §7.2).

interface GateInputs

mode

mode: TransmitMode

pttDown

pttDown: boolean

userMuted

userMuted: boolean

muteReason

muteReason: MuteReason | null

Why userMuted was last set; null when not muted.

vadActive

vadActive: boolean

callState

callState: AudioCallState

routeUp

routeUp: boolean

The relay connection is usable (16 §7.2): sv-audio open, ICE neither disconnected nor failed, a message from the relay within the last 1,500 ms, and no bufferedAmount above 6,000 octets held for 200 ms (ROUTE_UP).

leaseState

leaseState: LeaseState

keysOk

keysOk: boolean

Always true in an insecure call (16 §7.2, 18 §6.3 item 5).

keysOkShare?

keysOkShare?: boolean

Defaults to keysOk.

captureOk

captureOk: boolean

shareActive?

shareActive?: boolean

shareCaptureOk?

shareCaptureOk?: boolean

voiceLease?

voiceLease?: VoiceLeaseAudio | null

The newest VoiceLease (join or rejoin response, or call.lease_changed); null or absent before any.

Source: media/audio.ts:24

GateResult interface

The gate's outputs (16 §7.3) with the TalkState evaluated in the same step (16 §7.10).

interface GateResult

intent

intent: boolean

able

able: boolean

ableShare

ableShare: boolean

transmit

transmit: boolean

Microphone (source 0) may be sent.

sendShare

sendShare: boolean

Shared sound (source 2) may be sent.

talkState

talkState: TalkState

Source: media/audio.ts:51

HeldFrameInfo interface

A frame held for an unknown newer epoch (18 §6.5).

interface HeldFrameInfo

stream

stream: string

The stream it belongs to, for the 32-frames-per-stream cap (any stable key, such as pid:sourceId:joinNonce).

bytes

bytes: number

Its size in octets, for the 4 MiB-per-call cap.

deadlineMs?

deadlineMs?: number

Its playout deadline on the audio clock, if it has one; the hold never passes it.

Source: media/epochs.ts:139

InstallResult interface

What ReceiverEpochs.install did.

interface InstallResult<F>

erased

erased: number[]

Epochs erased at once because they fell below N − 15 (18 §6.6 item 3).

released

released: ({ frame: F; arrivalMs: number })[]

Held frames whose target is the new epoch, in arrival order: process them now as if they had just arrived (18 §6.5 item 2).

Source: media/epochs.ts:156

KidFields interface

The fields of a decomposed KID (18 §4.5).

interface KidFields

joinNonce

joinNonce: number

sourceId

sourceId: number

0–15; 4–15 are reserved and make the frame invalid.

leafIndex

leafIndex: number

residue

residue: number

epoch mod 16.

Source: media/sframe.ts:36

KidInit interface

The fields that make up a KID (18 §4.1).

interface KidInit

joinNonce

joinNonce: number

The encryptor instance's 32-bit joinNonce.

sourceId

sourceId: SourceId

0–3; reserved values are refused (18 §4.2).

leafIndex

leafIndex: number

The sender device's leaf index in the context group, 0–65,535.

epoch

epoch: number | bigint

The full MLS epoch whose keys protect the frame; the KID keeps its low 4 bits.

Source: media/sframe.ts:24

KidUsage interface

Per-KID usage of an encryptor instance (18 §3.6).

interface KidUsage

kid

kid: bigint

nextCounter

nextCounter: number

The next counter, which equals the number of frames encrypted so far (counters have no gaps).

plaintextBytes

plaintextBytes: number

Source: media/sframe.ts:483

LadderRung interface

One rung of a quality ladder (17 §5.5). The picture box is long edge × short edge.

interface LadderRung

rung

readonly rung: number

longEdge

readonly longEdge: number

shortEdge

readonly shortEdge: number

maxFps

readonly maxFps: number

budgetKbps

readonly budgetKbps: number

targetKbps

readonly targetKbps: number

Source: media/constants.ts:341

LeaseTickLike interface

The members of a lease tick (a LeaseSnapshot delivered to a participant, 15 §4.2) that lease enforcement reads. Structurally compatible with 15's LeaseSnapshot; unknown members are ignored.

interface LeaseTickLike

callId

callId: string

seq

seq: number

Strictly increasing per call (15 §4.3).

validMs

validMs: number

Always 3,000 in v1; receivers use 3,000 whatever it says (16 §12.1 item 6).

audio

audio: readonly number[]

pids allowed to send sources 0 and 2.

video

video: readonly number[]

pids allowed to send sources 1 and 3.

listeners

listeners: readonly number[]

pids allowed to receive anything in the call.

epoch?

epoch?: number

The call's mediaEpoch (secure calls only).

Source: media/lease.ts:17

MediaAttestationContent interface

The fields of MediaAttestationContent (18 §9.4).

interface MediaAttestationContent

groupId

groupId: string

The context group's group_id, UTF-8 (13 §4.1).

epoch

epoch: number | bigint

The full MLS epoch of the KID's keys.

callId

callId: string

The call's callId (encoded as its 16-octet binary UUID).

kid

kid: bigint

firstCounter

firstCounter: number

lastCounter

lastCounter: number

frameHashes

frameHashes: Uint8Array

8 × (lastCounter − firstCounter + 1) octets, in counter order.

Source: media/attestation.ts:75

OpusToc interface

The fields of an Opus TOC octet (RFC 6716 §3.1).

interface OpusToc

config

config: number

Configuration number 0–31.

mode

mode: "silk" | "hybrid" | "celt"

bandwidth

bandwidth: "nb" | "mb" | "wb" | "swb" | "fb"

frameMs

frameMs: number

Duration of each frame in the packet, in ms (2.5, 5, 10, 20, 40 or 60).

stereo

stereo: boolean

code

code: 0 | 1 | 2 | 3

Frame-count code 0–3.

Source: media/voice-dc.ts:303

ParsedMediaAttestation interface

A structurally valid MediaAttestation (18 §9.5, §9.7 step 2).

interface ParsedMediaAttestation

callId

callId: string

epoch

epoch: number

src

src: SourceId

kid

kid: bigint

first

first: number

last

last: number

hashes

hashes: Uint8Array<ArrayBufferLike>[]

The frame hashes, one 8-octet array per counter from first to last.

hashBytes

hashBytes: Uint8Array

The concatenated hashes as signed.

sig

sig: Uint8Array

Source: media/attestation.ts:196

ParsedSFrame interface

An SFrame ciphertext split into its parts and checked against the sv1 profile.

interface ParsedSFrame

kid

kid: bigint

counter

counter: number

0 to 2^32 − 1 (18 §3.1).

header

header: Uint8Array

The header bytes exactly as received (part of the AAD and the frame hash, 18 §3.2 item 2).

body

body: Uint8Array

Encrypted data and the 16-byte tag.

Source: media/sframe.ts:213

PendingAttestation interface

A pending attestation kept by AttestationInbox.

interface PendingAttestation

from

from: number

The sender pid (the message's from).

attestation

attestation: ParsedMediaAttestation

receivedAt

receivedAt: number

Audio-clock time it first arrived.

Source: media/attestation.ts:386

ProtectedFrameInfo interface

What protecting one frame produced, for sending and for MediaAttestation (18 §9.3).

interface ProtectedFrameInfo

kid

kid: bigint

counter

counter: number

epoch

epoch: number

metadata

metadata: Uint8Array

The SFrame metadata used (route header, video frame header or SfuFrameMetadata).

sframe

sframe: Uint8Array

The SFrame ciphertext: header ‖ encrypted data ‖ tag.

frameHash

frameHash: Uint8Array

The 8-octet frame hash over metadata and SFrame ciphertext (18 §9.2), for the attestation batch.

Source: media/protect.ts:26

ReplayRecordEntry interface

One accepted counter in the replay record (18 §7, §9.7 "Records").

interface ReplayRecordEntry

counter

counter: number

acceptedAt

acceptedAt: number

Audio-clock time of acceptance.

hash?

hash?: Uint8Array<ArrayBufferLike>

The frame hash (18 §9.2), if the caller tracks attestations.

attested

attested: boolean

Whether a valid attestation matched it (18 §9.7).

Source: media/replay.ts:53

RosterLeaf interface

One leaf of an epoch's roster snapshot (18 §6.1).

interface RosterLeaf

dsk

dsk: Uint8Array

The leaf's DSK (its MLS signature_key, 07).

did

did: string

The DeviceCertificate's did.

addr

addr: string

The canonical address of the IdentityCertificate.

Source: media/sframe.ts:121

RungChange interface

A rung change made by the controller.

interface RungChange

atMs

atMs: number

from

from: number

to

to: number

kind

kind: "step_down" | "step_up" | "revert" | "trial_passed" | "ladder_change" | "new_media_process"

Source: media/video-adapt.ts:128

SendingEpochDecision interface

What SendingEpochState.evaluate decided.

interface SendingEpochDecision

sendingEpoch

sendingEpoch: number | null

The sending epoch s, or null while undefined.

changed

changed: boolean

s changed in this evaluation: close the open batches of the old epoch's KIDs and switch (18 §6.3 item 6).

previous

previous: number | null

The previous s when it changed.

behind

behind: boolean

M is higher than every installed epoch (18 §6.3 item 4).

keysOk

keysOk: boolean

This state's part of keysOk (18 §6.3 item 5): s is defined and item 4 hasn't closed the gate. The caller also requires the media epoch secret of s, no §3.6 item 4 stop for the source, and no verified_blocked pending key in the roster of s (07 §16.5).

code

code: "media.keys_unavailable" | null

media.keys_unavailable when keysOk is false (18 §10.1).

Source: media/epochs.ts:26

SFrameDecrypted interface

A decrypted SFrame frame.

interface SFrameDecrypted

kid

kid: bigint

counter

counter: number

header

header: Uint8Array

The header bytes as received.

plaintext

plaintext: Uint8Array

Source: media/sframe.ts:389

SFrameEncrypted interface

One encrypted frame from SFrameEncryptor.encrypt.

interface SFrameEncrypted

ciphertext

ciphertext: Uint8Array

The SFrame ciphertext: header ‖ encrypted data ‖ tag.

kid

kid: bigint

counter

counter: number

epoch

epoch: number

sourceId

sourceId: SourceId

Source: media/sframe.ts:491

SFrameEncryptorOptions interface

Options of SFrameEncryptor.

interface SFrameEncryptorOptions

joinNonce

joinNonce: number

The instance's fresh 32-bit joinNonce (18 §4.3).

Source: media/sframe.ts:501

SFrameHeader interface

A decoded SFrame header (RFC 9605 §4.3).

interface SFrameHeader

kid

kid: bigint

counter

counter: bigint

length

length: number

Length of the header in bytes.

Source: media/sframe.ts:185

SFrameKey interface

A ready-to-use SFrame key for one KID: a non-extractable AES-128-GCM key and its salt.

interface SFrameKey

kid

readonly kid: bigint

key

readonly key: CryptoKey

salt

readonly salt: Uint8Array

The salt is needed as bytes to compute nonces; it protects nothing without the key (18 §8.4.5).

Source: media/sframe.ts:325

SFrameKeyMaterial interface

The raw outputs of derive_key_salt (RFC 9605 §4.4.2). Wipe them when done (18 §6.6 item 5).

interface SFrameKeyMaterial

secret

secret: Uint8Array

sframe_secret = HKDF-Extract("", base_key), 32 bytes.

key

key: Uint8Array

sframe_key, 16 bytes.

salt

salt: Uint8Array

sframe_salt, 12 bytes.

Source: media/sframe.ts:302

SfuFrameMetadata interface

The SfuFrameMetadata fields (18 §8.4.3).

interface SfuFrameMetadata

version

version: number

Always 1.

codec

codec: number

18 §8.4.2's value: 1 Opus, 2 VP8, 3 VP9.

clearPrefix

clearPrefix: Uint8Array

Source: media/protect.ts:148

SfuFrameParts interface

A received SFU frame split for the receiver transform (18 §8.4.4 receiver steps 1 and 2).

interface SfuFrameParts

prefix

prefix: Uint8Array

The clear prefix P.

sframe

sframe: Uint8Array

X: the SFrame ciphertext after the prefix.

metadata

metadata: Uint8Array

SfuFrameMetadata built from the codec and P.

parsed

parsed: ParsedSFrame

Source: media/protect.ts:220

SfuRtpCodecInfo interface

One row of 17 §12.4's codec table.

interface SfuRtpCodecInfo

payloadFormat

readonly payloadFormat: string

insecure

readonly insecure: "MUST" | "SHOULD" | "MAY"

secure

readonly secure: "MUST" | "MAY" | "MUST NOT"

fmtp?

readonly fmtp?: string

Source: media/constants.ts:547

SimulcastEncoding interface

One simulcast encoding of sfu-rtp/1 (17 §12.5).

interface SimulcastEncoding

rid

readonly rid: "q" | "h" | "f"

scaleResolutionDownBy

readonly scaleResolutionDownBy: 1 | 2 | 4

scalabilityMode

readonly scalabilityMode: "L1T3" | "L1T2"

Source: media/constants.ts:585

StopRecord interface

One stop in a (pid, sourceId) stop history (18 §9.8).

interface StopRecord

atMs

atMs: number

reason

reason: StreamStopReason

counted

counted: boolean

Counted toward the budget of 3 per 60 s. A mismatch always counts; an unattested stop counts once 5,000 ms pass without withdrawal.

withdrawn

withdrawn: boolean

pending

pending: boolean

True while an unattested stop may still be withdrawn.

Source: media/playback.ts:22

VadStep interface

What one 20 ms window changed.

interface VadStep

active

active: boolean

vadActive after this window.

started

started: boolean

True at the end of the third consecutive window above θ: the talkspurt starts with the detecting windows as pre-roll.

stopped

stopped: boolean

True at the end of the thirtieth consecutive window at or below θ: the talkspurt ends with this window.

Source: media/audio.ts:128

VerifiedAttestation interface

A verified attestation as StreamPlayback.onAttestation needs it.

interface VerifiedAttestation

epoch

epoch: number

kid

kid: bigint

first

first: number

last

last: number

hashes

hashes: readonly Uint8Array<ArrayBufferLike>[]

One 8-octet hash per counter from first to last.

Source: media/playback.ts:80

VideoFragment interface

A parsed video-dc/1 fragment (17 §6.2). Byte views alias the message.

interface VideoFragment extends VideoFrameHeader

flags

flags: number

The raw flags octet, reserved bits included.

ciphertext

ciphertext: boolean

C: the protected frame is an SFrame ciphertext.

keyframe

keyframe: boolean

K: keyframe.

discardable

discardable: boolean

D: discardable.

endOfSource

endOfSource: boolean

E: end of source.

pid

pid: number

sourceId

sourceId: number

4-bit source; only 1 and 3 are valid in video-dc/1; parsing keeps any value for validation.

gen

gen: number

12-bit stream generation.

frameNumber

frameNumber: number

16-bit per-stream frame counter.

refSeq

refSeq: number

16-bit reference-chain counter (17 §6.4).

timestamp

timestamp: number

32-bit capture timestamp at 90 kHz from T0.

codec

codec: number

The codec octet (17 §5.1).

frameInfo

frameInfo: number

The raw frameInfo octet.

rotation

rotation: 0 | 1 | 2 | 3

Clockwise rotation in steps of 90° (bits 7–6 of frameInfo); receivers ignore it for source 1.

frameHeader

frameHeader: Uint8Array

Octets 0–15 exactly as received: the SFrame metadata in a secure call (17 §6.5).

fragIndex

fragIndex: number

fragCount

fragCount: number

chunk

chunk: Uint8Array

1 to 1,180 octets of the protected frame.

Source: media/video-dc.ts:170

VideoFrameHeader interface

The fields of a video-dc/1 frame header (17 §6.2).

interface VideoFrameHeader

flags

flags: number

The raw flags octet, reserved bits included.

ciphertext

ciphertext: boolean

C: the protected frame is an SFrame ciphertext.

keyframe

keyframe: boolean

K: keyframe.

discardable

discardable: boolean

D: discardable.

endOfSource

endOfSource: boolean

E: end of source.

pid

pid: number

sourceId

sourceId: number

4-bit source; only 1 and 3 are valid in video-dc/1; parsing keeps any value for validation.

gen

gen: number

12-bit stream generation.

frameNumber

frameNumber: number

16-bit per-stream frame counter.

refSeq

refSeq: number

16-bit reference-chain counter (17 §6.4).

timestamp

timestamp: number

32-bit capture timestamp at 90 kHz from T0.

codec

codec: number

The codec octet (17 §5.1).

frameInfo

frameInfo: number

The raw frameInfo octet.

rotation

rotation: 0 | 1 | 2 | 3

Clockwise rotation in steps of 90° (bits 7–6 of frameInfo); receivers ignore it for source 1.

Source: media/video-dc.ts:57

VideoFrameHeaderInit interface

What a sender supplies to build a frame header (17 §6.2). Reserved bits are always sent as 0.

interface VideoFrameHeaderInit

pid

pid: number

sourceId

sourceId: VideoSourceId

gen

gen: number

frameNumber

frameNumber: number

refSeq

refSeq: number

timestamp

timestamp: number

codec

codec: "vp8" | "vp9" | "h264" | "av1"

rotation?

rotation?: 0 | 1 | 3 | 2

0 for source 1 (17 §6.2).

ciphertext?

ciphertext?: boolean

keyframe?

keyframe?: boolean

discardable?

discardable?: boolean

endOfSource?

endOfSource?: boolean

Source: media/video-dc.ts:88

VideoReceiveContext interface

What a receiver knows when it validates a fragment (17 §6.8.1).

interface VideoReceiveContext

secure

secure: boolean

Whether the call is secure (18 §8.5).

ownPid

ownPid: number

isKnownPid

isKnownPid(pid: number): boolean

True if pid is in the roster or in the newest accepted tick's listeners (17 §6.8.1 item 3).

pid: number

canDecode?

canDecode(codecOctet: number): boolean

Whether this receiver can decode a codec octet. Defaults to vp8 only, the one MUST (17 §5.1).

codecOctet: number

Source: media/video-dc.ts:272

VideoRelayContext interface

What a relay knows when it validates a message from a participant connection (17 §6.8.2).

interface VideoRelayContext

secure

secure: boolean

boundPid

boundPid: number

The pid bound by the connection's RelayTicket.

profileAllowed?

profileAllowed?: boolean

Whether the session's ticket prof lists video-dc/1 (17 §6.8.2 item 6). Default true.

Source: media/video-dc.ts:299

VoiceFrame interface

A parsed voice-dc/1 frame message (16 §4.3).

interface VoiceFrame extends VoiceRouteHeader

flags

flags: number

The raw flags octet, reserved bits included (relays forward them unchanged, 16 §4.4).

ciphertext

ciphertext: boolean

C: the payload is an SFrame ciphertext (16 §4.4).

start

start: boolean

S: first frame of a talkspurt.

end

end: boolean

E: last frame of a talkspurt.

dtx

dtx: boolean

D: produced in Opus DTX.

pid

pid: number

The sender's participant index, 0–65535.

sourceId

sourceId: number

4-bit source: only 0 and 2 are valid in voice-dc/1; parsing keeps any value for validation.

gen

gen: number

12-bit stream generation (16 §4.5.1).

sequence

sequence: number

16-bit per-stream counter (16 §4.5.2).

timestamp

timestamp: number

32-bit capture timestamp, 48 kHz units from T0 (16 §4.5.3).

routeHeader

routeHeader: Uint8Array

Octets 0–11 exactly as received: the SFrame metadata in a secure call (16 §4.6).

payload

payload: Uint8Array

Octets 12 to the end: an Opus packet (C = 0) or an SFrame ciphertext (C = 1).

Source: media/voice-dc.ts:45

VoiceLeaseAudio interface

The newest VoiceLease's audio members (15 §4.1), as TalkState reads them (16 §7.10).

interface VoiceLeaseAudio

audio

audio: boolean

audioBlockedBy

audioBlockedBy: string | null

no_permission, muted_for_everyone, server_muted, timed_out, other, or null.

Source: media/audio.ts:17

VoiceReceiveContext interface

What a receiver knows about the call when it validates a frame (16 §4.9.1).

interface VoiceReceiveContext

secure

secure: boolean

Whether the call is secure (18 §8.5); decides the expected C flag.

ownPid

ownPid: number

The receiver's own pid.

isKnownPid

isKnownPid(pid: number): boolean

True if pid is in the call's roster (15 §2.5.2) or in the listeners list of the newest accepted lease tick (16 §4.9.1 item 3).

pid: number

Source: media/voice-dc.ts:183

VoiceRelayContext interface

What a relay knows when it validates a message from a participant connection (16 §4.9.2).

interface VoiceRelayContext

secure

secure: boolean

The call's mode, from the Call's security (relays follow it, 18 §8.5 item 3).

boundPid

boundPid: number

The pid bound to this connection by its RelayTicket (15 §4.5 step 2).

Source: media/voice-dc.ts:211

VoiceRouteHeader interface

The fields of a voice-dc/1 route header (16 §4.3).

interface VoiceRouteHeader

flags

flags: number

The raw flags octet, reserved bits included (relays forward them unchanged, 16 §4.4).

ciphertext

ciphertext: boolean

C: the payload is an SFrame ciphertext (16 §4.4).

start

start: boolean

S: first frame of a talkspurt.

end

end: boolean

E: last frame of a talkspurt.

dtx

dtx: boolean

D: produced in Opus DTX.

pid

pid: number

The sender's participant index, 0–65535.

sourceId

sourceId: number

4-bit source: only 0 and 2 are valid in voice-dc/1; parsing keeps any value for validation.

gen

gen: number

12-bit stream generation (16 §4.5.1).

sequence

sequence: number

16-bit per-stream counter (16 §4.5.2).

timestamp

timestamp: number

32-bit capture timestamp, 48 kHz units from T0 (16 §4.5.3).

Source: media/voice-dc.ts:21

VoiceRouteHeaderInit interface

What a sender supplies to build a route header (16 §4.3, §4.4). Reserved flag bits are always sent as 0.

interface VoiceRouteHeaderInit

pid

pid: number

sourceId

sourceId: AudioSourceId

gen

gen: number

sequence

sequence: number

timestamp

timestamp: number

ciphertext?

ciphertext?: boolean

C flag: true exactly in a secure call (SM-11).

start?

start?: boolean

end?

end?: boolean

dtx?

dtx?: boolean

Source: media/voice-dc.ts:53

Types

ControllerPhase type

Controller phase (17 §9.2).

type ControllerPhase = "steady" | "trial"

Source: media/video-adapt.ts:125

EpochResolution type

Result of resolveFrameEpoch.

type EpochResolution = { installed: true; epoch: number } | { installed: false; epoch: number }

Source: media/replay.ts:18

KidCheckFailure type

Why a KID fails the checks of 18 §4.5: check 1 is media.malformed_frame, checks 2 to 4 media.kid_mismatch.

type KidCheckFailure = "media.malformed_frame" | "media.kid_mismatch"

Source: media/sframe.ts:102

LeaseTickSource type

Where a tick came from (16 §12.1 item 1): the relay connection's sv-control channel, the event WebSocket (call.tick), or a join or rejoin response. The client accepts ticks from no other source (item 2).

type LeaseTickSource = "relay" | "websocket" | "join_response"

Source: media/lease.ts:38

MediaAttestationParseResult type

Result of parseMediaAttestation: media.attestation_invalid when any check of 18 §9.7 step 2 fails.

type MediaAttestationParseResult = { ok: true; attestation: ParsedMediaAttestation } | { ok: false; code: "media.attestation_invalid"; reason: string }

Source: media/attestation.ts:211

PlaybackEvent type

Something that happened to the stream.

type PlaybackEvent = { type: "stop"; reason: StreamStopReason; counted: boolean } | { type: "failure_while_stopped"; reason: "media.attestation_mismatch" } | { type: "resume"; playFloors: ({ epoch: number; kid: bigint; floor: number | null })[] } | { type: "resume_deferred"; untilMs: number } | { type: "withdrawn" } | { type: "stop_counted" } | { type: "excused"; counter: number }

Source: media/playback.ts:90

ReassemblyEvent type

One event of VideoStreamReassembler.

type ReassemblyEvent = { type: "complete"; frameNumber: number; header: VideoFrameHeader; frameHeader: Uint8Array; protectedFrame: Uint8Array; firstArrivalMs: number } | { type: "abandoned"; frameNumber: number; header: VideoFrameHeader; reason: "timeout" | "superseded" | "slot_limit" | "byte_limit" | "mismatch" } | { type: "invalid"; frameNumber: number; reason: "mismatch" | "oversize" } | { type: "duplicate"; frameNumber: number } | { type: "late"; frameNumber: number }

Source: media/video-dc.ts:426

SlotAddResult type

Outcome of adding a fragment to a slot (17 §6.9 slot rules 2 to 4, §6.8.1 item 7).

type SlotAddResult = "stored" | "complete" | "duplicate" | "mismatch" | "oversize"

Source: media/video-dc.ts:327

StreamAdmission type

Result of SourceStreams.admit.

type StreamAdmission = { ok: true; stream: StreamPlayback; created: boolean; evicted: number | null } | { ok: false; code: "media.replay" | "media.stream_limit" }

Source: media/playback.ts:398

StreamPlaybackState type

Playback state of a stream (18 §9.8).

type StreamPlaybackState = "playing" | "stopped"

Source: media/playback.ts:16

StreamStopReason type

Why a stream stopped (18 §9.7, §10.1).

type StreamStopReason = "media.attestation_mismatch" | "media.unattested"

Source: media/playback.ts:19

TickOfferResult type

The outcome of offering a tick to LeaseTickTracker.offer.

type TickOfferResult = "accepted" | "accepted_recovery" | "duplicate" | "lower_seq" | "other_call" | "malformed"

Source: media/lease.ts:117

VideoDropReason type

Why a video-dc/1 message is dropped (17 §6.8). version: vt isn't 0x10; size: outside 17 §6.7; source: sourceId isn't 1 or 3; own_pid, unknown_pid: item 3; wrong_pid: the relay's ticket-bound check; mode: the C flag doesn't match the call (item 4); flags: K and D both set; fragments: fragCount 0 or above 2,048, or fragIndex ≥ fragCount; codec: a reserved or undecodable codec, counted in codecUnsupported instead of invalidDrops; profile: the session's ticket prof lacks video-dc/1 (relay only).

type VideoDropReason = "version" | "size" | "source" | "own_pid" | "unknown_pid" | "wrong_pid" | "mode" | "flags" | "fragments" | "codec" | "profile"

Source: media/video-dc.ts:222

VideoParseResult type

Result of parsing a video-dc/1 message.

type VideoParseResult = { ok: true; fragment: VideoFragment } | { ok: false; reason: VideoDropReason }

Source: media/video-dc.ts:236

ViewerForwardingState type

The four viewer states of 17 §8.2.

type ViewerForwardingState = "normal" | "thinned" | "keyframes_only" | "paused"

Source: media/video-adapt.ts:18

VoiceDropReason type

Why a voice-dc/1 message is dropped (16 §4.9). version: vt isn't 0x10 (reserved types and other versions alike, 16 §4.2); size: outside 16 §4.8; source: sourceId isn't 0 or 2; own_pid, unknown_pid: item 3; wrong_pid: the relay's check against the ticket-bound pid; mode: the C flag doesn't match the call's mode; dtx_flags: D together with S or E, or on source 2.

type VoiceDropReason = "version" | "size" | "source" | "own_pid" | "unknown_pid" | "wrong_pid" | "mode" | "dtx_flags"

Source: media/voice-dc.ts:155

VoiceParseResult type

Result of parsing a voice-dc/1 message.

type VoiceParseResult = { ok: true; frame: VoiceFrame } | { ok: false; reason: VoiceDropReason }

Source: media/voice-dc.ts:158

Constants

AGC const

AGC target, about −20 dBFS RMS with at most 30 dB of gain (16 §6.2).

const AGC: { readonly targetDbfs: -20; readonly maxGainDb: 30 }

Source: media/constants.ts:148

APP_SOUND_SILENCE_DBFS const

Digital-silence threshold for source 2 (16 §5.4).

const APP_SOUND_SILENCE_DBFS: -90 = -90

Source: media/constants.ts:130

APP_SOUND_SILENCE_GATE_MS const

Silence gating of source 2: stop after 1 s of digital silence (every sample 0, or below −90 dBFS) (16 §5.4).

const APP_SOUND_SILENCE_GATE_MS: 1000 = 1000

Source: media/constants.ts:128

ATTESTATION const

MediaAttestation timers and limits (18 §9, §11).

const ATTESTATION: { readonly batchIntervalMs: 500; readonly batchMaxFrames: 256; readonly sendDelayMs: 50; readonly resendKeepMs: 4000; readonly frameHashBytes: 8; readonly signatureBytes: 64; readonly duplicateMemoryMs: 10000; readonly storeMs: 4000; readonly pendingMs: 4000; readonly pendingPerSource: 16; readonly verifyWithinMs: 500; readonly unattestedLimitMs: 3000; readonly excuseAfterReconnectMs: 3000; readonly excuseBudgetMs: 3000; readonly excuseWindowMs: 60000; readonly stopListMs: 5000; readonly stopBudget: 3; readonly stopWindowMs: 60000; readonly reportIntervalMs: 600000; readonly reportsPerCall: 10 }

Source: media/constants.ts:698

AUDIO_CLOCK_HZ const

Audio timestamp clock: 48 kHz whatever the Opus internal bandwidth (16 §4.5.3).

const AUDIO_CLOCK_HZ: 48000 = 48_000

Source: media/constants.ts:14

AUDIO_DEDUP_WINDOW const

Deduplicate per stream over at least the last 128 sequence numbers (16 §8.2).

const AUDIO_DEDUP_WINDOW: 128 = 128

Source: media/constants.ts:225

AUDIO_FRAME_MS const

Frame duration of every voice-dc/1 Opus packet sent: 20 ms (16 §5.1).

const AUDIO_FRAME_MS: 20 = 20

Source: media/constants.ts:22

AUDIO_FRAME_TICKS const

Timestamp advance of one 20 ms audio frame: 960 (16 §4.5.3).

const AUDIO_FRAME_TICKS: 960 = 960

Source: media/constants.ts:24

AUDIO_LOSS_INTERVAL_MS const

Listener: one audio_loss per stream every 2 s (SHOULD), at most one per second (MUST) (16 §4.7).

const AUDIO_LOSS_INTERVAL_MS: 2000 = 2000

Source: media/constants.ts:139

AUDIO_LOSS_MIN_SPACING_MS const

Minimum spacing of audio_loss per (sender, source) (16 §4.7).

const AUDIO_LOSS_MIN_SPACING_MS: 1000 = 1000

Source: media/constants.ts:141

AUDIO_TICKS_PER_MS const

Audio timestamp units per millisecond (16 §9.2: s_i = extended timestamp / 48).

const AUDIO_TICKS_PER_MS: 48 = 48

Source: media/constants.ts:18

CODEC_SWITCH const

Codec selection timing (17 §5.3).

const CODEC_SWITCH: { readonly newViewerWithinMs: 1000; readonly upgradeSpacingMs: 10000 }

Source: media/constants.ts:415

CONCEALMENT const

Concealment (16 §9.4).

const CONCEALMENT: { readonly fullLevelMs: 60; readonly fadeMs: 20; readonly fadeInMs: 5; readonly stopFadeMs: 20 }

Source: media/constants.ts:260

CONTENT_HINT_SWITCH const

Content-hint switching (17 §5.6).

const CONTENT_HINT_SWITCH: { readonly toMotion: { readonly changedPixelFraction: 0.5; readonly framesOf30: 20; readonly holdMs: 3000 }; readonly toDetail: { readonly changedPixelFraction: 0.1; readonly framesOf30: 25; readonly holdMs: 10000 }; readonly minIntervalMs: 30000 }

Source: media/constants.ts:418

CONTROLLER const

The rung controller (17 §9.1, §9.2).

const CONTROLLER: { readonly evaluateEveryMs: 1000; readonly stepDownSignals: 3; readonly stepDownWindowMs: 10000; readonly initialHoldMs: 30000; readonly maxHoldMs: 240000; readonly trialMs: 10000; readonly reportFreshMs: 3000; readonly p1BacklogMs: 250 }

Source: media/constants.ts:464

DECODABILITY_WAIT_MS const

Decodability: a frame ahead of the chain is held at most 250 ms after it completed (17 §6.10).

const DECODABILITY_WAIT_MS: 250 = 250

Source: media/constants.ts:334

DUCKING const

Ducking (16 §10): on at 50 % by default; attack 50 ms, hold 500 ms, release 300 ms.

const DUCKING: { readonly defaultLevelPercent: 50; readonly attackMs: 50; readonly holdMs: 500; readonly releaseMs: 300 }

Source: media/constants.ts:282

ENCODER_TARGET_FRACTION const

The encoder's target bitrate is 80 % of the budget (17 §5.5).

const ENCODER_TARGET_FRACTION: 0.8 = 0.8

Source: media/constants.ts:381

FEC_LOSS const

In-band FEC expected-loss setting (16 §5.3).

const FEC_LOSS: { readonly defaultPercent: 10; readonly minPercent: 5; readonly maxPercent: 25; readonly windowMs: 6000; readonly reevaluateMs: 1000 }

Source: media/constants.ts:116

GATE const

Transmit gate timing (16 §7.3, §7.4, §7.5, §7.10).

const GATE: { readonly evaluateEveryMs: 10; readonly inputLatencyMs: 20; readonly fadeMs: 2.5; readonly fadeSamples: 120; readonly senderAgeLimitMs: 100; readonly backlogHighOctets: 6000; readonly backlogLowOctets: 1200; readonly talkStateDeliveryMs: 100; readonly pttEventLatencyMs: 10; readonly interruptionMuteMs: 2000 }

Source: media/constants.ts:151

GEN_MODULUS const

gen = joinNonce mod 4096: the low 12 bits (16 §4.5.1).

const GEN_MODULUS: 4096 = 4096

Source: media/constants.ts:33

GEN_REUSE_WINDOW_MS const

A new media process's gen differs from every gen the client started in the same call within this window (16 §4.5.1).

const GEN_REUSE_WINDOW_MS: 60000 = 60_000

Source: media/constants.ts:35

GENTLE_TARGET_FRACTION const

A gentle first reaction to one pressure signal MAY use 60 % of the budget for 3 s (17 §9.2).

const GENTLE_TARGET_FRACTION: 0.6 = 0.6

Source: media/constants.ts:383

JITTER const

Jitter-buffer bounds (MUST) and the recommended target algorithm (16 §9.3).

const JITTER: { readonly initialTargetMs: 60; readonly minTargetMs: 60; readonly maxTargetMs: 180; readonly maxHoldMs: 200; readonly baseWindowMs: 10000; readonly percentileWindowMs: 3000; readonly minFramesForPercentile: 25; readonly percentile: 95; readonly marginMs: 20; readonly latePercentThreshold: 3; readonly lateWindowMs: 2000; readonly lateRaiseMs: 20; readonly raiseWithinMs: 200; readonly lowerThresholdMs: 10; readonly lowerAfterMs: 2000; readonly lowerMaxSpeedup: 0.05; readonly reanchorLateFrames: 10; readonly baseRestartGapMs: 10000 }

Source: media/constants.ts:228

KEYFRAMES const

Keyframes (17 §5.7, §7.2).

const KEYFRAMES: { readonly periodicMs: 10000; readonly requestedWithinMs: 200; readonly coalesceMs: 1000; readonly slowViewerMs: 10000; readonly repeatMs: 1000; readonly maxSizeFactor: 8; readonly maxPacerMs: 200 }

Source: media/constants.ts:390

L1T3_TEMPORAL_FPS_FRACTIONS const

With L1T3, temporal layers 0, 1 and 2 carry a quarter, a half and all of the frame rate (17 §12.3).

const L1T3_TEMPORAL_FPS_FRACTIONS: readonly [0.25, 0.5, 1]

Source: media/constants.ts:615

LEASE_TICK_VALIDITY_MS const

A tick's validity V, whatever its validMs says (16 §12.1 item 6, 15 §4.2).

const LEASE_TICK_VALIDITY_MS: 3000 = 3000

Source: media/constants.ts:291

MAX_MEANINGFUL_TIMESTAMP_GAP const

Gaps of more than 2^31 timestamp periods are not meaningful (16 §4.5.3).

const MAX_MEANINGFUL_TIMESTAMP_GAP: number

Source: media/constants.ts:26

MEDIA_ATTEST_LABEL const

The labelled-signature label of MediaAttestations (18 §9.4, 04 §7.3).

const MEDIA_ATTEST_LABEL: "media-attest" = 'media-attest'

Source: media/attestation.ts:23

MEDIA_KEYS const

Epoch keys and holds (18 §6, §11).

const MEDIA_KEYS: { readonly senderSwitchCapMs: 2000; readonly senderBehindLimitMs: 8000; readonly unknownEpochHoldMs: 200; readonly holdFramesPerStream: 32; readonly holdBytesPerCall: number; readonly oldKeyRetentionMs: 10000; readonly maxInstalledEpochs: 16; readonly missedCommitHoldMs: 1000; readonly missedCommitIntervalMs: 5000 }

Source: media/constants.ts:663

MIC_CONGESTION_BUFFERED_OCTETS const

Uplink congestion: bufferedAmount above 2,400 octets for 1 s or more lets a sender lower its bitrate (16 §5.1).

const MIC_CONGESTION_BUFFERED_OCTETS: 2400 = 2400

Source: media/constants.ts:107

MIC_CONGESTION_DURATION_MS const

...for at least this long (16 §5.1).

const MIC_CONGESTION_DURATION_MS: 1000 = 1000

Source: media/constants.ts:109

MIC_RECOVERY_BUFFERED_OCTETS const

Return to the default within 10 s after bufferedAmount stays at or below 1,200 octets (16 §5.1).

const MIC_RECOVERY_BUFFERED_OCTETS: 1200 = 1200

Source: media/constants.ts:111

MIC_RECOVERY_MS const

...within this time (16 §5.1).

const MIC_RECOVERY_MS: 10000 = 10_000

Source: media/constants.ts:113

MIN_CONCURRENT_STREAMS const

Receivers decode and mix at least 8 source-0 and 2 source-2 streams (16 §9.7).

const MIN_CONCURRENT_STREAMS: { readonly microphone: 8; readonly appSound: 2 }

Source: media/constants.ts:276

OPUS_APP_SOUND_PROFILE const

Application-sound (source 2) Opus profile (16 §5.2).

const OPUS_APP_SOUND_PROFILE: { readonly application: "OPUS_APPLICATION_AUDIO"; readonly channels: 2; readonly inputSampleRateHz: 48000; readonly bandwidth: "OPUS_BANDWIDTH_FULLBAND"; readonly frameMs: 20; readonly defaultBitrateStereoKbps: 96; readonly defaultBitrateMonoKbps: 64; readonly bitrateRangeKbps: readonly [48, 128]; readonly inbandFec: 1; readonly dtx: 0; readonly signal: "OPUS_SIGNAL_MUSIC" }

Source: media/constants.ts:89

OPUS_DECODE_DURATION_RANGE_MS const

Packet durations receivers MUST handle (16 §5.6).

const OPUS_DECODE_DURATION_RANGE_MS: readonly [10, 60]

Source: media/constants.ts:132

OPUS_MIC_PROFILE const

Microphone (source 0) Opus profile (16 §5.1). Names follow the libopus controls.

const OPUS_MIC_PROFILE: { readonly application: "OPUS_APPLICATION_VOIP"; readonly channels: 1; readonly inputSampleRateHz: 48000; readonly maxBandwidth: "OPUS_BANDWIDTH_WIDEBAND"; readonly maxBandwidthHighQuality: "OPUS_BANDWIDTH_FULLBAND"; readonly frameMs: 20; readonly defaultBitrateKbps: 32; readonly bitrateRangeKbps: readonly [16, 48]; readonly bitrateRangeHighQualityKbps: readonly [32, 64]; readonly minCongestedBitrateKbps: 16; readonly bluetoothBitrateKbps: 24; readonly vbrSecure: 0; readonly vbrInsecure: 1; readonly vbrConstraintInsecure: 1; readonly inbandFec: 1; readonly signal: "OPUS_SIGNAL_VOICE"; readonly complexityDesktop: 10; readonly complexityMobileWebMin: 5 }

Source: media/constants.ts:61

PACING const

Sender pacing (17 §8.1).

const PACING: { readonly targetMultiplier: 4; readonly headroomKbps: 1000; readonly inboundFraction: 0.9; readonly averagingWindowMs: 50; readonly minBufferedOctets: 4800; readonly bufferedMs: 40; readonly stopEncodingBacklogMs: 300; readonly resumeEncodingBacklogMs: 100; readonly flushBacklogMs: 1000 }

Source: media/constants.ts:425

PRESENTATION_MAX_HOLD_MS const

Presentation timeline: no source-2 frame is held more than 500 ms (16 §11.4).

const PRESENTATION_MAX_HOLD_MS: 500 = 500

Source: media/constants.ts:284

REASSEMBLY const

Reassembly limits (17 §6.9).

const REASSEMBLY: { readonly slotTimeoutMs: 500; readonly maxSlotsPerStream: 32; readonly maxBytesPerStream: number; readonly maxBytesPerCall: number; readonly finishedRecord: 256 }

Source: media/constants.ts:323

RELAY_AUDIO const

Per-recipient drop rules and inbound caps of the relay for voice-dc/1 (16 §8.1).

const RELAY_AUDIO: { readonly recipientBufferedOctets: 8000; readonly recipientAgeLimitMs: 60; readonly forwardTargetMs: 5; readonly inboundMessagesPerSecond: 55; readonly inboundMessageBurst: 10; readonly inboundOctetsPerSecond: 24000; readonly inboundOctetBurst: 6000 }

Source: media/constants.ts:205

RELAY_VIDEO const

Relay per-viewer forwarding thresholds (17 §8.2).

const RELAY_VIDEO: { readonly keyframeMaxAgeMs: 400; readonly nonDiscardableMaxAgeMs: 250; readonly discardableMaxAgeMs: 100; readonly thinnedRecoveryMs: 5000; readonly queueExpiryMs: 500; readonly defaultRateKbps: 2000; readonly minBufferedOctets: 4800; readonly bufferedMs: 40; readonly inboundOctetsPerSecond: 1100000; readonly inboundOctetBurst: 2200000; readonly inboundMessagesPerSecond: 2000; readonly inboundMessageBurst: 2000 }

Source: media/constants.ts:441

REPLAY const

Replay protection (18 §7).

const REPLAY: { readonly windowCounters: 4096; readonly reorderMs: 1000; readonly freshnessToleranceMs: 1000; readonly drefCreepDivisor: 10; readonly evictedJoinNonces: 64; readonly maxStreamsPerSource: 4; readonly attestedEvictionIdleMs: 10000 }

Source: media/constants.ts:682

REPLAY_RECORD_RETENTION_MS const

How long a record entry that has fallen out of the counter window (c ≤ H − 4096) is kept for attestation comparison and rollback: the 5,000 ms stop-list window (18 §9.8), which is longer than the 3,000 ms unattested limit and the 4,000 ms attestation store.

const REPLAY_RECORD_RETENTION_MS: 5000 = 5000

Source: media/replay.ts:68

RETIRED_GEN_MEMORY_MS const

Retired gen values are remembered for 60 s (16 §9.1, 17 §6.9).

const RETIRED_GEN_MEMORY_MS: 60000 = 60_000

Source: media/constants.ts:37

ROSTER_WAIT_MS const

Unknown-roster hold for a secure frame: 200 ms at most, never past the playout deadline (16 §4.9.1, 17 §6.8.1).

const ROSTER_WAIT_MS: 200 = 200

Source: media/constants.ts:272

ROUTE_UP const

routeUp rules (16 §7.2).

const ROUTE_UP: { readonly relayLivenessMs: 1500; readonly backlogOctets: 6000; readonly backlogWindowMs: 200 }

Source: media/constants.ts:173

SCREEN_DETAIL_LADDER const

Screen ladder for content hint detail, rung 0 first (17 §5.5).

const SCREEN_DETAIL_LADDER: readonly LadderRung[]

Source: media/constants.ts:351

SCREEN_MOTION_LADDER const

Screen ladder for content hint motion, rung 0 first; rung 5 only with "Smoother video" (17 §5.5).

const SCREEN_MOTION_LADDER: readonly LadderRung[]

Source: media/constants.ts:361

SFRAME const

SFrame profile parameters of sv1 (18 §3.1).

const SFRAME: { readonly cipherSuite: 4; readonly cipherSuiteName: "AES_128_GCM_SHA256_128"; readonly keyBytes: 16; readonly nonceBytes: 12; readonly tagBytes: 16; readonly epochBits: 4; readonly leafBits: 16; readonly contextIdBits: 36; readonly kidLimit: bigint; readonly counterLimit: number; readonly maxFramesPerKid: number; readonly maxBytesPerKid: number; readonly selfUpdateFrames: number; readonly selfUpdateBytes: number; readonly maxOverheadBytes: 29; readonly minCiphertextBytes: number; readonly exporterLabel: "SFrame 1.0 Base Key"; readonly exporterLength: 16; readonly keyLabel: "SFrame 1.0 Secret key "; readonly saltLabel: "SFrame 1.0 Secret salt " }

Source: media/constants.ts:624

SFU_KEYFRAME_REQUEST_INTERVAL_MS const

The SFU SHOULD forward or generate at most one keyframe request per encoding per 1,000 ms (17 §12.5 item 4).

const SFU_KEYFRAME_REQUEST_INTERVAL_MS: 1000 = 1000

Source: media/constants.ts:617

SFU_RTP_CODECS const

sfu-rtp/1 codecs and their requirement levels (17 §12.4; secure calls: 18 §8.4.2).

const SFU_RTP_CODECS: { readonly vp8: { readonly payloadFormat: "RFC 7741"; readonly insecure: "MUST"; readonly secure: "MUST" }; readonly vp9: { readonly payloadFormat: "RFC 9628"; readonly insecure: "MAY"; readonly secure: "MAY" }; readonly h264: { readonly payloadFormat: "RFC 6184"; readonly insecure: "SHOULD"; readonly secure: "MUST NOT"; readonly fmtp: "packetization-mode=1" }; readonly av1: { readonly payloadFormat: "AV1 RTP specification"; readonly insecure: "MAY"; readonly secure: "MUST NOT" }; readonly opus: { readonly payloadFormat: "RFC 7587"; readonly insecure: "MUST"; readonly secure: "MUST"; readonly fmtp: "stereo=1;sprop-stereo=1;useinbandfec=1 (cbr=1 in secure calls)" } }

Source: media/constants.ts:555

SFU_RTP_HEADER_EXTENSIONS const

RTP header extensions of sfu-rtp/1 and their requirement (17 §12.4).

const SFU_RTP_HEADER_EXTENSIONS: { readonly mid: { readonly uri: "urn:ietf:params:rtp-hdrext:sdes:mid"; readonly requirement: "MUST" }; readonly rtpStreamId: { readonly uri: "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"; readonly requirement: "MUST with simulcast" }; readonly repairedRtpStreamId: { readonly uri: "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"; readonly requirement: "MUST with simulcast" }; readonly transportWideCc: { readonly uri: "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"; readonly requirement: "MUST" }; readonly dependencyDescriptor: { readonly uri: "https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"; readonly requirement: "MUST with VP9; MAY with VP8; MAY with H.264 and AV1 (insecure calls only)" }; readonly videoOrientation: { readonly uri: "urn:3gpp:video-orientation"; readonly requirement: "SHOULD for source 3" }; readonly absCaptureTime: { readonly uri: "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time"; readonly requirement: "MAY" }; readonly playoutDelay: { readonly uri: "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; readonly requirement: "MAY" }; readonly audioLevel: { readonly uri: "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; readonly requirement: "MUST NOT on source 2 in secure calls; MAY in insecure calls" } }

Source: media/constants.ts:564

SFU_RTP_RTCP_FEEDBACK const

RTCP feedback of sfu-rtp/1 for video (17 §12.4).

const SFU_RTP_RTCP_FEEDBACK: { readonly must: readonly ["nack", "nack pli", "ccm fir", "transport-cc"]; readonly may: readonly ["goog-remb"] }

Source: media/constants.ts:580

SFU_RTP_SRTP_PROFILES const

SRTP protection profiles (17 §12.2): GCM SHOULD be offered first; CM-HMAC-SHA1-80 MUST be supported.

const SFU_RTP_SRTP_PROFILES: readonly ["SRTP_AEAD_AES_128_GCM", "SRTP_AES128_CM_HMAC_SHA1_80"]

Source: media/constants.ts:582

SFU_RTP_STRUCTURES const

Publishing structures per source (17 §12.5), with W3C WebRTC-SVC scalabilityMode names.

const SFU_RTP_STRUCTURES: { readonly webcam: { readonly simulcast: readonly [{ readonly rid: "q"; readonly scaleResolutionDownBy: 4; readonly scalabilityMode: "L1T3" }, { readonly rid: "h"; readonly scaleResolutionDownBy: 2; readonly scalabilityMode: "L1T3" }, { readonly rid: "f"; readonly scaleResolutionDownBy: 1; readonly scalabilityMode: "L1T3" }]; readonly vp9: "L3T3_KEY" }; readonly screenMotion: { readonly simulcast: readonly [{ readonly rid: "h"; readonly scaleResolutionDownBy: 2; readonly scalabilityMode: "L1T3" }, { readonly rid: "f"; readonly scaleResolutionDownBy: 1; readonly scalabilityMode: "L1T3" }]; readonly vp9: "L2T3_KEY" }; readonly screenDetail: { readonly simulcast: readonly [{ readonly rid: "f"; readonly scaleResolutionDownBy: 1; readonly scalabilityMode: "L1T3" }]; readonly vp9: "L1T3" } }

Source: media/constants.ts:592

SIMULCAST_BUDGET_SHARE const

Budget shares of the lower simulcast encodings: h at most 35 %, q at most 12 % (17 §12.5 item 1).

const SIMULCAST_BUDGET_SHARE: { readonly f: 1; readonly h: 0.35; readonly q: 0.12 }

Source: media/constants.ts:613

SPEAKING const

speaking holds while a received frame was rendered within 300 ms (16 §9.7), SHOULD above −50 dBFS.

const SPEAKING: { readonly windowMs: 300; readonly minLevelDbfs: -50 }

Source: media/constants.ts:280

STALL_THRESHOLD_MS const

An audio-clock jump of more than 500 ms between render callbacks is a stall (16 §9.6).

const STALL_THRESHOLD_MS: 500 = 500

Source: media/constants.ts:274

STARTING_RUNGS const

Starting rungs (17 §5.5).

const STARTING_RUNGS: { readonly screenDetail: 3; readonly screenMotion: 2; readonly webcamDesktop: 2; readonly webcamMobile: 1 }

Source: media/constants.ts:379

STREAM_IDLE_DISCARD_MS const

A stream with no frames (fragments) for 60 s is discarded (16 §9.1, 17 §6.9).

const STREAM_IDLE_DISCARD_MS: 60000 = 60_000

Source: media/constants.ts:39

VAD const

Voice activation (16 §7.6).

const VAD: { readonly windowMs: 20; readonly startWindows: 3; readonly stopWindows: 30; readonly autoOffsetDb: 10; readonly autoMinDbfs: -60; readonly autoMaxDbfs: -20; readonly noiseWindowMs: 10000; readonly noisePercentile: 10; readonly fixedRangeDbfs: readonly [-70, -10]; readonly preRollMs: 60 }

Source: media/constants.ts:182

VIDEO_CLOCK_HZ const

Video timestamp clock: 90 kHz, counted from the same T0 as audio (17 §4.4).

const VIDEO_CLOCK_HZ: 90000 = 90_000

Source: media/constants.ts:16

VIDEO_FEEDBACK const

Video feedback rates (17 §7.1, §7.3, §7.4, §7.5).

const VIDEO_FEEDBACK: { readonly videoReportIntervalMs: 1000; readonly videoPrefPerSecond: 2; readonly videoPrefAreaChange: 0.25; readonly videoPrefStableMs: 500; readonly edgeRange: readonly [16, 3840]; readonly fpsRange: readonly [1, 60]; readonly maxDecodeEntries: 8; readonly congestedWindowMs: 2000; readonly congestedLossFraction: 0.05; readonly congestedAssemblyMs: 50; readonly noAudiencePauseMs: 2000 }

Source: media/constants.ts:481

VIDEO_FRAGMENT_FIELDS_BYTES const

Length of the fragment fields (fragIndex, fragCount) (17 §6.2).

const VIDEO_FRAGMENT_FIELDS_BYTES: 4 = 4

Source: media/constants.ts:304

VIDEO_FRAGMENT_PREFIX_BYTES const

Frame header plus fragment fields (17 §6.2).

const VIDEO_FRAGMENT_PREFIX_BYTES: 20 = 20

Source: media/constants.ts:306

VIDEO_FRAME_HEADER_BYTES const

Length of the video-dc/1 frame header (17 §6.2). In secure calls it is the SFrame metadata.

const VIDEO_FRAME_HEADER_BYTES: 16 = 16

Source: media/constants.ts:302

VIDEO_HELD_LABEL_MS const

"Held" label after 750 ms without a new picture (17 §10.2).

const VIDEO_HELD_LABEL_MS: 750 = 750

Source: media/constants.ts:412

VIDEO_LIVENESS_MS const

Liveness: at least one frame every 500 ms while a source is active (17 §5.8).

const VIDEO_LIVENESS_MS: 500 = 500

Source: media/constants.ts:408

VIDEO_MAX_CHUNK_BYTES const

Chunk: 1 to 1,180 octets (17 §6.7).

const VIDEO_MAX_CHUNK_BYTES: 1180 = 1180

Source: media/constants.ts:312

VIDEO_MAX_FRAGMENTS const

fragCount: 1 to 2,048 (17 §6.7).

const VIDEO_MAX_FRAGMENTS: 2048 = 2048

Source: media/constants.ts:316

VIDEO_MAX_MESSAGE_BYTES const

Largest fragment message: 1,200 octets (17 §6.7).

const VIDEO_MAX_MESSAGE_BYTES: 1200 = 1200

Source: media/constants.ts:310

VIDEO_MAX_PICTURE const

Largest encoded picture: 3,840 × 2,160 (17 §5.2).

const VIDEO_MAX_PICTURE: { readonly width: 3840; readonly height: 2160 }

Source: media/constants.ts:320

VIDEO_MAX_PROTECTED_FRAME_BYTES const

Largest protected frame: 2 MiB (17 §6.6, §6.7).

const VIDEO_MAX_PROTECTED_FRAME_BYTES: 2097152 = 2_097_152

Source: media/constants.ts:318

VIDEO_MIN_MESSAGE_BYTES const

Smallest fragment message: 21 octets (17 §6.7).

const VIDEO_MIN_MESSAGE_BYTES: 21 = 21

Source: media/constants.ts:308

VIDEO_RECOMMENDED_CHUNK_BYTES const

Senders SHOULD use 1,130-octet chunks, so each message is at most 1,150 octets (17 §6.6).

const VIDEO_RECOMMENDED_CHUNK_BYTES: 1130 = 1130

Source: media/constants.ts:314

VIDEO_ROUTE_POLICY const

videoRoute policy for SFU-capable call control (17 §13.2, §13.3).

const VIDEO_ROUTE_POLICY: { readonly sfuSeatThreshold: 8; readonly sfuFanoutThreshold: 24; readonly sfuSlowViewerFraction: 0.25; readonly sfuSlowViewerWindowMs: 30000; readonly backToDcMaxSeats: 4; readonly backToDcSeatsWindowMs: 60000; readonly backToDcNoVideoMs: 120000; readonly minSwitchIntervalMs: 60000; readonly dcToSfuOverlapMaxMs: 5000; readonly sfuToDcKeyframeWaitMs: 1000 }

Source: media/constants.ts:529

VIDEO_SENDER_AGE_LIMIT_MS const

V-L2: a frame whose picture is older than 1,000 ms isn't handed to a transport (17 §5.9).

const VIDEO_SENDER_AGE_LIMIT_MS: 1000 = 1000

Source: media/constants.ts:410

VIDEO_TARGETS const

Latency and sync targets in the clean test setup (17 §11.4).

const VIDEO_TARGETS: { readonly screenCaptureToDisplayP95Ms: 500; readonly screenAvSyncP95Ms: 80; readonly webcamCaptureToDisplayP95Ms: 400; readonly webcamVideoBehindVoiceMaxMs: 90; readonly webcamVideoAheadOfVoiceMaxMs: 185; readonly firstPictureP95Ms: 1000; readonly recoveryP95Ms: 1000; readonly heldLabelMs: 750; readonly heldLabelToleranceMs: 50; readonly uncoveredRemovalMs: 250 }

Source: media/constants.ts:515

VIDEO_TICKS_PER_MS const

Video timestamp units per millisecond (17 §11.2, 18 §7: divided by 90).

const VIDEO_TICKS_PER_MS: 90 = 90

Source: media/constants.ts:20

VIDEO_TIMELINE const

Timeline synchronisation (17 §11.2, §11.3).

const VIDEO_TIMELINE: { readonly presentationTargetRangeMs: readonly [60, 450]; readonly presentationLateRaiseMs: 40; readonly presentationRaiseWithinMs: 500; readonly presentationLowerThresholdMs: 20; readonly presentationLowerAfterMs: 5000; readonly shownLateMs: 80; readonly restartGapMs: 10000; readonly renderMarginMs: 10; readonly webcamTargetRangeMs: readonly [30, 300]; readonly webcamMaxWaitForVoiceMs: 200 }

Source: media/constants.ts:501

VIDEO_UNCOVERED_REMOVAL_MS const

An uncovered sender's pictures are removed within 250 ms (17 §10.3).

const VIDEO_UNCOVERED_REMOVAL_MS: 250 = 250

Source: media/constants.ts:295

VOICE_MAX_MESSAGE_BYTES const

Largest voice-dc/1 frame message (16 §4.8).

const VOICE_MAX_MESSAGE_BYTES: 1100 = 1100

Source: media/constants.ts:50

VOICE_MAX_OPUS_PACKET_BYTES const

Largest Opus packet (plaintext payload) (16 §4.8).

const VOICE_MAX_OPUS_PACKET_BYTES: 1000 = 1000

Source: media/constants.ts:48

VOICE_MAX_PAYLOAD_BYTES const

Largest payload: 1,100 − 12 (16 §4.10 payload = 1*1088OCTET).

const VOICE_MAX_PAYLOAD_BYTES: 1088 = 1088

Source: media/constants.ts:54

VOICE_MIN_MESSAGE_BYTES const

Smallest voice-dc/1 frame message: the payload is never empty (16 §4.8).

const VOICE_MIN_MESSAGE_BYTES: 13 = 13

Source: media/constants.ts:52

VOICE_ROUTE_HEADER_BYTES const

Length of the voice-dc/1 route header (16 §4.3). In secure calls it is the SFrame metadata.

const VOICE_ROUTE_HEADER_BYTES: 12 = 12

Source: media/constants.ts:46

VOLUME_RANGE_PERCENT const

Local volume range per participant and source, default 100 % (16 §9.7).

const VOLUME_RANGE_PERCENT: readonly [0, 200]

Source: media/constants.ts:278

WEB_HEARTBEAT const

Web main-thread heartbeat at least every 100 ms; a gap over 200 ms stamps late ticks with the last heartbeat (16 §12.1 item 5).

const WEB_HEARTBEAT: { readonly intervalMs: 100; readonly gapMs: 200 }

Source: media/constants.ts:293

WEBCAM_LADDER const

Webcam ladder, rung 0 first (17 §5.5).

const WEBCAM_LADDER: readonly LadderRung[]

Source: media/constants.ts:371

Re-exports

Also exported from this entry point; documented where they are defined.