Selkies
Developer ReferenceWeb client coreLib

lib/decode-gate

What a decoder should do with each frame that arrives, so a decoder that falls behind costs the stream as little as possible.

A decoder given more than it can decode has to let something go, and what it lets go breaks the frames that predict from it. Where the encoder says what each frame predicts from, the cheapest repair is to drop the frame, tell the server which one went, and hold back only what predicts from it: the encoder predicts past it and decoding resumes on its next frame, no key frame on the wire. Where the encoder says nothing -- a stripe of a striped stream, a codec whose session does not track its references -- the only repair is a key frame, so the gate asks for one instead. A run of drops that the encoder never predicts past is the same case and ends in that request too.

Classes

DecodeGate

Defined in: lib/decode-gate.js:40

Constructors

Constructor
new DecodeGate(options?): DecodeGate;

Defined in: lib/decode-gate.js:45

Parameters
ParameterTypeDescription
options?{ now?: () => number; }-
options.now?() => numberMonotonic clock in ms.
Returns

DecodeGate

Methods

configured()
configured(): void;

Defined in: lib/decode-gate.js:55

The decoder was (re)built, so it needs a key frame before anything else.

Returns

void

invalidated()
invalidated(): void;

Defined in: lib/decode-gate.js:62

Nothing decoded so far is usable, so only a key frame is.

Returns

void

decide()
decide(
   key, 
   frameId, 
   reference, 
   queueSize
): Decision;

Defined in: lib/decode-gate.js:80

Parameters
ParameterTypeDescription
keybooleanWhether the frame decodes on its own.
frameIdnumberThe frame's own id.
referencenumberThe id of the frame it predicts from; its own id, or undefined, where the encoder does not say.
queueSizenumberFrames the decoder has yet to decode.
Returns

Decision

Type Aliases

Decision

type Decision = "decode" | "lost" | "no_key" | "overload";

Defined in: lib/decode-gate.js:35

What to do with a frame: decode it, let it go and report it lost, or ask for a key frame because none has been decoded yet or because dropping more would not help.

Type Parameters

Type Parameter

Variables

OVERLOAD_QUEUE

const OVERLOAD_QUEUE: 6 = 6;

Defined in: lib/decode-gate.js:25

Frames of decode backlog that count as falling behind.


OVERLOAD_HOLD_MS

const OVERLOAD_HOLD_MS: 250 = 250;

Defined in: lib/decode-gate.js:27

How long that backlog must stand before a frame is let go, in ms.


LOST_RECOVERY_MS

const LOST_RECOVERY_MS: 1000 = 1000;

Defined in: lib/decode-gate.js:29

How long frames may go undecodable before a key frame is asked for, in ms.


LOST_MEMORY

const LOST_MEMORY: 64 = 64;

Defined in: lib/decode-gate.js:32

How many dropped frame ids are remembered. A frame predicts from one of the last few its encoder produced, so an older id can never be named again.

On this page

Edit on GitHub