Selkies

state/settings

The stream settings' state and rules, held once above the layout and read by the video, audio, and screen panels wherever a layout paints them.

State arrives through the message events the core posts on window: serverSettings (the server's settings payload, per key a value, allowed, min/max, default, locked, and overridden), effectiveCursorState, scalingDpiFollowed (the UI-scaling default the core re-derived), displayRefresh (the display's measured refresh, also window.displayRefreshRate, which the frame-rate slider offers as a stop of its own), and audioDeviceSelected. Changes go back as window.postMessage messages: settings (debounced key/value batches the core forwards to the server), mode, setScaleLocally, setManualResolution, resetResolutionToWindow, setAntiAliasing, and whatever the shared conditional-setting specs post. The transport is seeded from window.__SELKIES_STREAMING_MODE__, and a switch goes through the shared switchStreamMode.

Every value persists under a localStorage key from getPrefixedKey, which adds the _display2 suffix for per-display settings on a secondary display; the cores read the same keys. The cores also persist every value they are told to apply, so a stored key alone cannot tell a user's explicit pick from one the dashboard derived (HiDPI from the resolution mode) or applied from the server (paint-over). Those settings therefore carry an _explicit_choice marker beside their value and resolve through the shared specs of selkies-web-core/lib/conditional-settings.js, which honor pinned, locked, and operator-overridden server values: a derived write never pins them, and an unmarked stored echo is dropped once the ladder moves on.

Interfaces

AudioDevice

Defined in: state/settings.ts:204

An audio device as the picker lists it.

Properties

deviceId
deviceId: string;

Defined in: state/settings.ts:204

label
label: string;

Defined in: state/settings.ts:204

Type Aliases

StreamSettings

type StreamSettings = ReturnType<typeof useStreamSettings>;

Defined in: state/settings.ts:842

What useStreamSettings returns.

Variables

RESOLUTION_PRESETS

const RESOLUTION_PRESETS: string[];

Defined in: state/settings.ts:119

The presets the resolution menu offers.


WEBCAM_ENCODER_OPTIONS

const WEBCAM_ENCODER_OPTIONS: string[];

Defined in: state/settings.ts:128

webcam_encoder values; labels come from displayLabel.


STREAMING_MODES

const STREAMING_MODES: string[];

Defined in: state/settings.ts:169

The transports the mode menu offers.

Functions

deriveDpi()

function deriveDpi(manual): number;

Defined in: state/settings.ts:90

The default scaling_dpi, derived as the core derives it (lib/stream-density.js): from a manual resolution when one is set, since that framebuffer decides how large the desktop draws its UI and the local screen says nothing about it, and otherwise from the local display scaling (devicePixelRatio), so the remote desktop's fonts and UI match the local environment. A manual resolution is read off its shorter side -- an ultrawide is wide rather than dense -- and either density is snapped to the nearest option and clamped at both ends.

The ladder that governs the desktop is an operator override (which the server refuses to let clients clobber), then the stored pick, then this derived default; the cores send stored-else-derived on every connect.

Parameters

ParameterType
manual{ w: number; h: number; }
manual.wnumber
manual.hnumber

Returns

number


manualResolution()

function manualResolution(serverSettings): object;

Defined in: state/settings.ts:105

The manual resolution in force, as the cores resolve it: a deployment that forces one and names its size wins, since the core takes the server's over the client's there; otherwise the stored pick, and zeroes for a session sized to its window.

Parameters

ParameterType
serverSettingsany

Returns

object

w
w: number;
h
h: number;

useConditionalSetting()

function useConditionalSetting(
   spec, 
   serverSettings, 
   ctx, 
   deps, 
   read?
): readonly [any, Dispatch<any>];

Defined in: state/settings.ts:158

Drives a conditional setting: lazy init, then a re-resolve whenever the server settings or any dependency in deps changes (server sync and a dependency's re-derivation alike). The resolver honors explicit choices, so a re-resolve never clobbers a pinned value. Re-resolving writes state rather than deriving during render because the caller edits the value afterwards.

Parameters

ParameterTypeDefault valueDescription
specanyundefinedConditional-setting spec from conditional-settings.js.
serverSettingsanyundefinedThe last server settings payload, or null before one arrives.
ctxanyundefinedResolution context the spec reads (stream mode, encoder, ...).
depsany[]undefinedDependencies whose change triggers a re-resolve.
read?anyreadStoredStorage reader; the explicit-choice reader for settings that are also derived.

Returns

readonly [any, Dispatch<any>]

A [value, setValue] pair.


settingsPoster()

function settingsPoster(delay): (setting) => void;

Defined in: state/settings.ts:189

Trailing debounce of settings posts: a burst coalesces into one post carrying every setting changed in it, each at its last value, so a derived change never drops the one that caused it.

Parameters

ParameterType
delaynumber

Returns

(setting) => void


useStreamSettings()

function useStreamSettings(): object;

Defined in: state/settings.ts:215

The stream settings' state and handlers. Server settings are seeded from the cached broadcast because the provider may mount after the core connects, and every value stays editable afterwards with localStorage taking precedence. Each conditional setting is one useConditionalSetting call over a shared spec: the hook owns init and server sync, and client-driven changes go through writeConditional.

Returns

Everything the video, audio, and screen panels render from.

serverSettings
serverSettings: any;
renderable
renderable: any;
isWebrtc
isWebrtc: boolean;
show
show: object;
show.streamMode
streamMode: any;
show.encoder
encoder: any = renderable.encoder;
show.webcamEncoder
webcamEncoder: boolean;
show.fullColor
fullColor: boolean;
show.tenBit
tenBit: boolean;
show.framerate
framerate: any = renderable.framerate;
show.rateControl
rateControl: any;
show.bitrate
bitrate: any;
show.crf
crf: any;
show.turbo
turbo: any;
show.jpegQuality
jpegQuality: any;
show.paintOver
paintOver: any;
show.paintoverCrf
paintoverCrf: any;
show.paintoverBurst
paintoverBurst: any;
show.paintOverJpeg
paintOverJpeg: any;
show.cpu
cpu: any;
show.cpuThreading
cpuThreading: any;
show.audioBitrate
audioBitrate: any = renderable.audioBitrate;
show.hidpi
hidpi: any;
show.forceAligned
forceAligned: any;
show.uiScaling
uiScaling: any;
show.useBrowserCursors
useBrowserCursors: any = renderable.useBrowserCursors;
show.rawPointerMotion
rawPointerMotion: any = renderable.rawPointerMotion;
show.macCmdAsCtrl
macCmdAsCtrl: any = renderable.macCmdAsCtrl;
show.resolutionControls
resolutionControls: any;
show.videoPanel
videoPanel: any = renderable.videoSettings;
show.audioPanel
audioPanel: any = renderable.audioSettings;
show.screenPanel
screenPanel: any = renderable.screenSettings;
streamMode
streamMode: any;
setStreamMode
setStreamMode: (mode) => Promise<void> = setStreamModeChoice;

Switches the transport (switchStreamMode); the core reloads into it.

Parameters
ParameterType
modestring
Returns

Promise<void>

encoder
encoder: string;
encoderOptions
encoderOptions: string[] = encoderOptionsShown;
setEncoder
setEncoder: (value) => void;
Parameters
ParameterType
valuestring
Returns

void

webcamEncoder
webcamEncoder: string;
webcamEncoderLocked
webcamEncoderLocked: boolean = !!wceServer?.locked;
setWebcamEncoder
setWebcamEncoder: (value) => void;
Parameters
ParameterType
valuestring
Returns

void

videoFullColor
videoFullColor: any;
toggleFullColor
toggleFullColor: () => void;
Returns

void

fullColorLocked
fullColorLocked: boolean;
video10Bit
video10Bit: any;
toggle10Bit
toggle10Bit: () => void;
Returns

void

tenBitLocked
tenBitLocked: boolean;
framerate
framerate: number;
framerateFollows
framerateFollows: boolean;
displayFramerate
displayFramerate: number;
framerateStops
framerateStops: number[];
framerateIndex
framerateIndex: number;
setFramerateIndex
setFramerateIndex: (index) => void;

The display's own stop asks for the display's refresh wherever it moves.

Parameters
ParameterType
indexnumber
Returns

void

framerateFixed
framerateFixed: boolean;
rateControlMode
rateControlMode: any;
rateControlOptions
rateControlOptions: string[];
setRateControlMode
setRateControlMode: (mode) => void;
Parameters
ParameterType
modestring
Returns

void

videoBitRate
videoBitRate: number;
videoBitrateChoices
videoBitrateChoices: number[];

The slider stops inside the server's ranges; a stored value between stops (a server default, a clamp) shows at the nearest one.

bitrateIndex
bitrateIndex: number;
setVideoBitRate
setVideoBitRate: (value) => void;
Parameters
ParameterType
valuenumber
Returns

void

bitrateFixed
bitrateFixed: boolean;
videoCRF
videoCRF: number;
videoCRFChoices
videoCRFChoices: number[];
crfIndex
crfIndex: number;
setVideoCRF
setVideoCRF: (value) => void;
Parameters
ParameterType
valuenumber
Returns

void

crfFixed
crfFixed: boolean;
videoStreamingMode
videoStreamingMode: any;
toggleTurbo
toggleTurbo: () => void;
Returns

void

turboLocked
turboLocked: boolean;
jpegQuality
jpegQuality: number;
setJpegQuality
setJpegQuality: (value) => void;
Parameters
ParameterType
valuenumber
Returns

void

jpegQualityRange
jpegQualityRange: object;
jpegQualityRange.min
min: any;
jpegQualityRange.max
max: any;
jpegQualityFixed
jpegQualityFixed: boolean;
usePaintOverQuality
usePaintOverQuality: any;
togglePaintOver
togglePaintOver: () => void;
Returns

void

paintOverLocked
paintOverLocked: boolean;
videoPaintoverCRF
videoPaintoverCRF: number;
videoPaintoverCRFChoices
videoPaintoverCRFChoices: number[];
paintoverCrfIndex
paintoverCrfIndex: number;
setVideoPaintoverCRF
setVideoPaintoverCRF: (value) => void;
Parameters
ParameterType
valuenumber
Returns

void

paintoverCrfFixed
paintoverCrfFixed: boolean;
videoPaintoverBurstFrames
videoPaintoverBurstFrames: number;
setVideoPaintoverBurstFrames
setVideoPaintoverBurstFrames: (value) => void;
Parameters
ParameterType
valuenumber
Returns

void

paintoverBurstRange
paintoverBurstRange: object;
paintoverBurstRange.min
min: any;
paintoverBurstRange.max
max: any;
paintoverBurstFixed
paintoverBurstFixed: boolean;
paintOverJpegQuality
paintOverJpegQuality: number;
setPaintOverJpegQuality
setPaintOverJpegQuality: (value) => void;
Parameters
ParameterType
valuenumber
Returns

void

paintOverJpegRange
paintOverJpegRange: object;
paintOverJpegRange.min
min: any;
paintOverJpegRange.max
max: any;
paintOverJpegFixed
paintOverJpegFixed: boolean;
useCpu
useCpu: any;
toggleCpu
toggleCpu: () => void;
Returns

void

cpuLocked
cpuLocked: boolean;
cpuEncodeThreading
cpuEncodeThreading: any;
toggleCpuThreading
toggleCpuThreading: () => void;
Returns

void

cpuThreadingLocked
cpuThreadingLocked: boolean;
audioBitRate
audioBitRate: number;
audioBitrateChoices
audioBitrateChoices: number[];
setAudioBitRate
setAudioBitRate: (value) => void;
Parameters
ParameterType
valuenumber
Returns

void

audioInputDevices
audioInputDevices: AudioDevice[];
audioOutputDevices
audioOutputDevices: AudioDevice[];
selectedInputDeviceId
selectedInputDeviceId: any;
selectedOutputDeviceId
selectedOutputDeviceId: any;
isOutputSelectionSupported
isOutputSelectionSupported: boolean;
audioDeviceError
audioDeviceError: string;
isLoadingAudioDevices
isLoadingAudioDevices: boolean;
ensureAudioDevices
ensureAudioDevices: () => void;

Populates the audio device lists once. Enumerating labeled devices needs a getUserMedia grant, so this runs only when the audio panel is actually shown: merely opening the settings must not raise a microphone permission prompt.

Output selection is probed on the sink the active core plays through, HTMLMediaElement.setSinkId for the WebRTC core's video element and AudioContext.setSinkId for the WebSocket core, or where that is missing, as in Firefox, the media element that core then plays its context through; probing the wrong one would render a picker that does nothing.

Returns

void

selectAudioDevice
selectAudioDevice: (context, deviceId) => void;
Parameters
ParameterType
context"input" | "output"
deviceIdstring
Returns

void

antiAliasing
antiAliasing: boolean;
toggleAntiAliasing
toggleAntiAliasing: () => void;

Anti-aliasing is client-only; the core persists antiAliasingEnabled itself.

Returns

void

useBrowserCursors
useBrowserCursors: any;
toggleBrowserCursors
toggleBrowserCursors: () => void;

Propagates the new preference and lets the core, which owns persistence, report the effective (possibly multi-monitor-forced) value back. Derived from the displayed value: while multi-monitor forces the toggle on, the base preference may be off, and negating the base would silently persist the forced value over the user's real choice.

Returns

void

rawPointerMotion
rawPointerMotion: any;
toggleRawPointerMotion
toggleRawPointerMotion: () => void;
Returns

void

macCmdAsCtrl
macCmdAsCtrl: any;
toggleMacCmdAsCtrl
toggleMacCmdAsCtrl: () => void;
Returns

void

hidpiEnabled
hidpiEnabled: any;
toggleHidpi
toggleHidpi: () => void;

An explicit toggle pins the choice; the core persists useCssScaling when it applies the message.

Returns

void

hidpiDisabledReason
hidpiDisabledReason: string;
forceAlignedResolution
forceAlignedResolution: any;
toggleForceAligned
toggleForceAligned: () => void;
Returns

void

selectedDpi
selectedDpi: number;
dpiScalingChoices
dpiScalingChoices: object[];
setDpi
setDpi: (value) => void;
Parameters
ParameterType
valuestring
Returns

void

dpiDisabled
dpiDisabled: boolean;

A single allowed stop, or an operator-set DPI, leaves nothing to change.

manualWidth
manualWidth: string;
manualHeight
manualHeight: string;
presetValue
presetValue: string;
setManualWidth
setManualWidth: (value) => void;
Parameters
ParameterType
valuestring
Returns

void

setManualHeight
setManualHeight: (value) => void;
Parameters
ParameterType
valuestring
Returns

void

setManualResolution
setManualResolution: () => void;
Returns

void

choosePreset
choosePreset: (preset) => void;
Parameters
ParameterType
presetstring
Returns

void

resetResolution
resetResolution: () => void;

Restores HiDPI and the UI scaling to their derived defaults on reset-to-window. Unlike the resolution-derived writes, which respect a pinned choice, a reset means "back to defaults", so the client's own pin is dropped even under an operator-explicit value: use_css_scaling overridden does not imply locked, and a kept pin would keep outranking the operator's value in the resolution ladder. Only a locked value, or for the scaling an operator override, leaves everything alone.

Returns

void

scaleLocally
scaleLocally: boolean;
toggleScaleLocally
toggleScaleLocally: () => void;

The core persists scaleLocallyManual itself when it applies the message.

Returns

void


writeConditional()

function writeConditional(
   spec, 
   uiValue, 
   setValue, 
   opts?
): void;

Defined in: state/settings.ts:304

The one write path for conditional settings: optimistic setState, persistence only for an explicit choice (which pins it; a derived value keeps following), then propagation through the spec.

Parameters

ParameterType
specany
uiValueany
setValueany
opts?{ persist?: boolean; }
opts.persist?boolean

Returns

void


toggleScaleLocally()

function toggleScaleLocally(): void;

Defined in: state/settings.ts:570

The core persists scaleLocallyManual itself when it applies the message.

Returns

void


toggleHidpi()

function toggleHidpi(): void;

Defined in: state/settings.ts:577

An explicit toggle pins the choice; the core persists useCssScaling when it applies the message.

Returns

void


setStreamModeChoice()

function setStreamModeChoice(mode): Promise<void>;

Defined in: state/settings.ts:587

Switches the transport (switchStreamMode); the core reloads into it.

Parameters

ParameterType
modestring

Returns

Promise<void>


storeAndPost()

function storeAndPost(
   key, 
   value, 
   setValue
): void;

Defined in: state/settings.ts:593

Stores a plain setting and posts it to the server.

Parameters

ParameterType
keystring
valuestring | number
setValue(v) => void

Returns

void


setFramerateIndex()

function setFramerateIndex(index): void;

Defined in: state/settings.ts:624

The display's own stop asks for the display's refresh wherever it moves.

Parameters

ParameterType
indexnumber

Returns

void


deriveHidpiForResolution()

function deriveHidpiForResolution(manual): void;

Defined in: state/settings.ts:640

Pairs the resolution mode with CSS scaling: HiDPI off when a manual or preset resolution is set, on when reset, as a derived (unpinned) write. An explicit toggle or a locked or overridden server value pins HiDPI and stops the resolution buttons from re-deriving it.

Parameters

ParameterType
manualboolean

Returns

void


deriveDpiForResolution()

function deriveDpiForResolution(): void;

Defined in: state/settings.ts:651

A resolution the operator sets carries its own UI-scaling default, since the framebuffer asked for decides how large the desktop draws its UI. Not stored, so it stays a default: a stored pick, or a locked or operator-explicit server value, outranks it as it does at connect.

Returns

void


applyManualResolution()

function applyManualResolution(width, height): void;

Defined in: state/settings.ts:661

Applies a manual size: stores it, tells the core, and re-derives HiDPI and the UI scaling.

Parameters

ParameterType
widthnumber
heightnumber

Returns

void


resetResolution()

function resetResolution(): void;

Defined in: state/settings.ts:699

Restores HiDPI and the UI scaling to their derived defaults on reset-to-window. Unlike the resolution-derived writes, which respect a pinned choice, a reset means "back to defaults", so the client's own pin is dropped even under an operator-explicit value: use_css_scaling overridden does not imply locked, and a kept pin would keep outranking the operator's value in the resolution ladder. Only a locked value, or for the scaling an operator override, leaves everything alone.

Returns

void


toggleAntiAliasing()

function toggleAntiAliasing(): void;

Defined in: state/settings.ts:722

Anti-aliasing is client-only; the core persists antiAliasingEnabled itself.

Returns

void


framerateLabel()

function framerateLabel(rate): number;

Defined in: ../../selkies-web-core/lib/display-refresh.js:191

A frame rate as the dashboards show it: to a hundredth, so 60000/1001 reads 59.94.

Parameters

ParameterTypeDescription
ratenumber-

Returns

number


displayLabel()

function displayLabel(value): string;

Defined in: ../../selkies-web-core/lib/util.js:107

Parameters

ParameterTypeDescription
valuestringA wire value.

Returns

string

Its display label, or the value itself when it has none.


canPlayEncoder()

function canPlayEncoder(encoder, webrtc): boolean;

Defined in: ../../selkies-web-core/lib/util.js:270

Whether this engine plays an encoder on a transport: canDecodeEncoder on WebSockets, canReceiveEncoder on WebRTC. A menu lists what it cannot play disabled and marked, so a missing option reads as the browser's limit and never as the server's.

Parameters

ParameterTypeDescription
encoderstringAn encoder wire value.
webrtcbooleanWhether the transport is WebRTC.

Returns

boolean

On this page

InterfacesAudioDevicePropertiesdeviceIdlabelType AliasesStreamSettingsVariablesRESOLUTION_PRESETSWEBCAM_ENCODER_OPTIONSSTREAMING_MODESFunctionsderiveDpi()ParametersReturnsmanualResolution()ParametersReturnswhuseConditionalSetting()ParametersReturnssettingsPoster()ParametersReturnsuseStreamSettings()ReturnsserverSettingsrenderableisWebrtcshowshow.streamModeshow.encodershow.webcamEncodershow.fullColorshow.tenBitshow.framerateshow.rateControlshow.bitrateshow.crfshow.turboshow.jpegQualityshow.paintOvershow.paintoverCrfshow.paintoverBurstshow.paintOverJpegshow.cpushow.cpuThreadingshow.audioBitrateshow.hidpishow.forceAlignedshow.uiScalingshow.useBrowserCursorsshow.rawPointerMotionshow.macCmdAsCtrlshow.resolutionControlsshow.videoPanelshow.audioPanelshow.screenPanelstreamModesetStreamModeParametersReturnsencoderencoderOptionssetEncoderParametersReturnswebcamEncoderwebcamEncoderLockedsetWebcamEncoderParametersReturnsvideoFullColortoggleFullColorReturnsfullColorLockedvideo10Bittoggle10BitReturnstenBitLockedframerateframerateFollowsdisplayFramerateframerateStopsframerateIndexsetFramerateIndexParametersReturnsframerateFixedrateControlModerateControlOptionssetRateControlModeParametersReturnsvideoBitRatevideoBitrateChoicesbitrateIndexsetVideoBitRateParametersReturnsbitrateFixedvideoCRFvideoCRFChoicescrfIndexsetVideoCRFParametersReturnscrfFixedvideoStreamingModetoggleTurboReturnsturboLockedjpegQualitysetJpegQualityParametersReturnsjpegQualityRangejpegQualityRange.minjpegQualityRange.maxjpegQualityFixedusePaintOverQualitytogglePaintOverReturnspaintOverLockedvideoPaintoverCRFvideoPaintoverCRFChoicespaintoverCrfIndexsetVideoPaintoverCRFParametersReturnspaintoverCrfFixedvideoPaintoverBurstFramessetVideoPaintoverBurstFramesParametersReturnspaintoverBurstRangepaintoverBurstRange.minpaintoverBurstRange.maxpaintoverBurstFixedpaintOverJpegQualitysetPaintOverJpegQualityParametersReturnspaintOverJpegRangepaintOverJpegRange.minpaintOverJpegRange.maxpaintOverJpegFixeduseCputoggleCpuReturnscpuLockedcpuEncodeThreadingtoggleCpuThreadingReturnscpuThreadingLockedaudioBitRateaudioBitrateChoicessetAudioBitRateParametersReturnsaudioInputDevicesaudioOutputDevicesselectedInputDeviceIdselectedOutputDeviceIdisOutputSelectionSupportedaudioDeviceErrorisLoadingAudioDevicesensureAudioDevicesReturnsselectAudioDeviceParametersReturnsantiAliasingtoggleAntiAliasingReturnsuseBrowserCursorstoggleBrowserCursorsReturnsrawPointerMotiontoggleRawPointerMotionReturnsmacCmdAsCtrltoggleMacCmdAsCtrlReturnshidpiEnabledtoggleHidpiReturnshidpiDisabledReasonforceAlignedResolutiontoggleForceAlignedReturnsselectedDpidpiScalingChoicessetDpiParametersReturnsdpiDisabledmanualWidthmanualHeightpresetValuesetManualWidthParametersReturnssetManualHeightParametersReturnssetManualResolutionReturnschoosePresetParametersReturnsresetResolutionReturnsscaleLocallytoggleScaleLocallyReturnswriteConditional()ParametersReturnstoggleScaleLocally()ReturnstoggleHidpi()ReturnssetStreamModeChoice()ParametersReturnsstoreAndPost()ParametersReturnssetFramerateIndex()ParametersReturnsderiveHidpiForResolution()ParametersReturnsderiveDpiForResolution()ReturnsapplyManualResolution()ParametersReturnsresetResolution()ReturnstoggleAntiAliasing()ReturnsframerateLabel()ParametersReturnsdisplayLabel()ParametersReturnscanPlayEncoder()ParametersReturns
Edit on GitHub