lib/util
Helpers shared by the streaming cores and both dashboards: a small FIFO queue, the human-readable labels for wire values, the WebSocket decodability check, and the route prefix and localStorage namespace every caller derives the same way.
Classes
Queue
Defined in: lib/util.js:16
A FIFO queue over an array.
Constructors
Constructor
new Queue(...elements): Queue;Defined in: lib/util.js:18
Parameters
| Parameter | Type | Description |
|---|---|---|
...elements | any[] | Initial items, enqueued in order. |
Returns
Properties
items
items: any[];Defined in: lib/util.js:20
Methods
enqueue()
enqueue(...elements): void;Defined in: lib/util.js:26
Parameters
| Parameter | Type | Description |
|---|---|---|
...elements | any[] | Items appended in order. |
Returns
void
dequeue()
dequeue(count?): any;Defined in: lib/util.js:35
Removes the oldest count items.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
count? | number | 1 | How many items to drop. |
Returns
any
The oldest of the removed items.
size()
size(): number;Defined in: lib/util.js:40
Returns
number
isEmpty()
isEmpty(): boolean;Defined in: lib/util.js:45
Returns
boolean
toArray()
toArray(): any[];Defined in: lib/util.js:50
Returns
any[]
A copy of the items, oldest first.
remove()
remove(element): void;Defined in: lib/util.js:55
Removes the first occurrence of element.
Parameters
| Parameter | Type |
|---|---|
element | any |
Returns
void
find()
find(element): boolean;Defined in: lib/util.js:61
Parameters
| Parameter | Type |
|---|---|
element | any |
Returns
boolean
Whether element is queued.
clear()
clear(): void;Defined in: lib/util.js:66
Drops every item.
Returns
void
Variables
DISPLAY_LABELS
const DISPLAY_LABELS: object;Defined in: lib/util.js:78
Human-readable names for the wire values surfaced in UIs (transport modes, encoders, rate-control modes). The raw values are what the server APIs speak and stay untouched; unknown values fall through unchanged so new wire values render as-is. Locale-invariant technical terms, so they live here once rather than in every dashboard's translation dictionaries.
Type Declaration
websockets
websockets: string = "WebSockets";webrtc
webrtc: string = "WebRTC";h264enc
h264enc: string = "H.264 (Full Frame)";h264enc-striped
h264enc-striped: string = "H.264 (Striped Frame)";jpeg
jpeg: string = "JPEG (Striped Frame)";cbr
cbr: string = "CBR (Constant Bitrate)";crf
crf: string = "CRF (Constant Quality)";auto
auto: string = "Auto";h264
h264: string = "H.264";vp8
vp8: string = "VP8";mjpeg
mjpeg: string = "MJPEG";Functions
displayLabel()
function displayLabel(value): string;Defined in: lib/util.js:96
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | A wire value. |
Returns
string
Its display label, or the value itself when it has none.
canDecodeEncoder()
function canDecodeEncoder(encoder): boolean;Defined in: lib/util.js:108
Whether this engine can play an encoder on the WebSocket transport: every
H.264 mode decodes through WebCodecs' VideoDecoder, while jpeg (striped
JPEG painted through createImageBitmap) needs nothing. An engine without
WebCodecs therefore still streams: the core's pre-flight pins jpeg instead
of failing, and the settings offer nothing it cannot play. The WebRTC
transport decodes in the browser's media stack and is not subject to this.
Parameters
| Parameter | Type | Description |
|---|---|---|
encoder | string | An encoder wire value. |
Returns
boolean
decodableEncoders()
function decodableEncoders(encoders): string[];Defined in: lib/util.js:113
Parameters
| Parameter | Type | Description |
|---|---|---|
encoders | string[] | Encoder wire values. |
Returns
string[]
Those canDecodeEncoder accepts.
getRoutePrefix()
function getRoutePrefix(): string;Defined in: lib/util.js:122
Directory this document is served from, without a trailing slash ('' at
the server root). Every request the client builds hangs off it, so a
deployment reverse-proxied under a subfolder reaches its own routes, and an
iframed client reads its own path instead of the frame's.
Returns
string
The path prefix, e.g. /desk.
getStorageAppName()
function getStorageAppName(): string;Defined in: lib/util.js:136
The localStorage namespace every stored key is prefixed with.
Origin and pathname only, not the full URL: a per-session ?token= must
not mint a new namespace on each connect. Cores and dashboards share one
prefix, so this derivation is the single one they all call.
Returns
string
Sanitized namespace, empty outside a browser.