Selkies
Developer ReferenceWeb client coreLib

lib/stream-stats

What a dashboard shows of the session, gathered in one place for both cores and published on window under one contract.

window.stream_info is what the server said of the stream: the capture path and whether it is zero-copy, the encoder and whether it is hardware, the GPU, and the reason a faster path was declined (stream_stats.py on the server). It arrives once and again on a change, whether or not anybody looks. window.stream_client is this page's half: the transport and the path it took, the codec and resolution, and the decoder with the evidence for calling it hardware or software.

Everything that moves is gathered only while a dashboard has its stats on screen. It says so with a statsOpen window message; the collector then asks the server for stream_stats (the _stats verb), the core samples its own side once a second, and each second's figures land in window.stream_stats: latest, and history, which starts empty when the stats open and grows while they stay open, up to HISTORY_MAX seconds. Shut, nothing is sampled, nothing is sent and the server sends nothing. A shared viewer never subscribes.

Classes

StreamStats

Defined in: lib/stream-stats.js:138

Constructors

Constructor
new StreamStats(options): StreamStats;

Defined in: lib/stream-stats.js:145

Parameters
ParameterTypeDescription
options{ transport: "webrtc" | "websockets"; send: (arg0) => void; isViewer: () => boolean; onOpenChange: (arg0) => void; }send puts one text message on the session connection; onOpenChange lets the core start and stop its own sampling.
options.transport"webrtc" | "websockets"-
options.send(arg0) => void-
options.isViewer() => boolean-
options.onOpenChange(arg0) => void-
Returns

StreamStats

Accessors

open
Get Signature
get open(): boolean;

Defined in: lib/stream-stats.js:165

Whether a dashboard has its stats on screen.

Returns

boolean

Methods

setOpen()
setOpen(open): void;

Defined in: lib/stream-stats.js:173

A dashboard opened or shut its stats. Opening starts a fresh history.

Parameters
ParameterTypeDescription
openboolean-
Returns

void

subscribe()
subscribe(): void;

Defined in: lib/stream-stats.js:185

Tells the server what this page wants; a fresh connection has to be told again.

Returns

void

disconnected()
disconnected(): void;

Defined in: lib/stream-stats.js:197

The connection went away, and the subscription with it.

Returns

void

setInfo()
setInfo(info): void;

Defined in: lib/stream-stats.js:202

Parameters
ParameterTypeDescription
infoStreamInfoThe server's stream_info.
Returns

void

setClient()
setClient(description): void;

Defined in: lib/stream-stats.js:207

Parameters
ParameterTypeDescription
descriptionPartial<StreamClient>What the core learned of its own side.
Returns

void

serverSample()
serverSample(stats): void;

Defined in: lib/stream-stats.js:212

Parameters
ParameterTypeDescription
stats{ }The server's stream_stats.
Returns

void

noteBytes()
noteBytes(bytes): void;

Defined in: lib/stream-stats.js:218

Parameters
ParameterTypeDescription
bytesnumberStream bytes that arrived, for the bandwidth figure.
Returns

void

clientSample()
clientSample(figures): void;

Defined in: lib/stream-stats.js:227

One second's figures from the core, merged with the server's and appended to the history. mbps comes from noteBytes unless the core measured it.

Parameters
ParameterTypeDescription
figures{ }-
Returns

void

Variables

HISTORY_MAX

const HISTORY_MAX: 600 = 600;

Defined in: lib/stream-stats.js:32

Seconds of history kept for the graphs.


SERVER_FRESH_MS

const SERVER_FRESH_MS: 3000 = 3000;

Defined in: lib/stream-stats.js:34

Server figures older than this are left out of a sample, in ms.

Functions

decoderOfFormat()

function decoderOfFormat(format): "hardware" | "software" | "unknown";

Defined in: lib/stream-stats.js:92

What a decoded frame's pixel format says of the decoder behind it. A hardware decoder hands out NV12 or an opaque frame, a software one planar I4xx.

Parameters

ParameterTypeDescription
formatstringVideoFrame.format; undefined where no frame was seen.

Returns

"hardware" | "software" | "unknown"


webcodecsDecoder()

function webcodecsDecoder(evidence): object;

Defined in: lib/stream-stats.js:107

The WebCodecs decoder verdict from everything the page can know: a software preference is certain, an engine that refuses the stream's configuration with hardware required has none, and otherwise the frames say which kind made them.

Parameters

ParameterTypeDescription
evidence{ forcedSoftware: boolean; hardwareSupported: boolean; format: string; }hardwareSupported is VideoDecoder.isConfigSupported with prefer-hardware, null where unasked.
evidence.forcedSoftwareboolean-
evidence.hardwareSupportedboolean-
evidence.formatstring-

Returns

object

decoder
decoder: "hardware" | "software" | "unknown";
decoder_evidence
decoder_evidence: string;

webrtcDecoder()

function webrtcDecoder(evidence): object;

Defined in: lib/stream-stats.js:124

The WebRTC decoder verdict from the inbound video report. Engines name the decoder only to a page that holds a capture permission, so without one the verdict falls back to whether the engine has an efficient decoder at all.

Parameters

ParameterTypeDescription
evidence{ implementation: string; powerEfficient: boolean; capable: boolean; }capable is MediaCapabilities.decodingInfo().powerEfficient for the stream.
evidence.implementationstring-
evidence.powerEfficientboolean-
evidence.capableboolean-

Returns

object

decoder
decoder: "hardware" | "software" | "unknown";
decoder_evidence
decoder_evidence: string;

References

StreamInfo

Re-exports StreamInfo


StreamClient

Re-exports StreamClient


StreamSample

Re-exports StreamSample

On this page

Edit on GitHub