mirror of
https://github.com/videojs/video.js.git
synced 2026-11-21 08:24:15 +01:00
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
4.7 KiB
4.7 KiB
@videojs/spf/features/multi-cdn
Source: src/playback/features/multi-cdn.ts
multiCdnFeature
Plays sources served from several CDNs (redundant streams): keeps every track type on one CDN, and fails over to the next when a CDN fails, returning to it once its cooldown lapses. Single-CDN sources pass through unchanged.
Behaviors
Config
Feature default is the value a feature's defaultConfig supplies. A behavior's own fallback for a key left unset is described under Doc.
| Key | Type | Feature default | Read by | Doc |
|---|---|---|---|---|
failover? |
Partial<FailoverMonitorConfig> |
— | setupFailoverMonitor | Failover policy (cooldown); defaults to DEFAULT_FAILOVER_MONITOR_CONFIG. |
getCdnId? |
GetCdnId |
— | deriveCdnPriority | How to derive a CDN grouping key from a track URL — used to build cdnPriority, to record the failover trip in failedCdns, and by the track-switching CDN scope + failover constraint. One function, read by all of them, so the keys stay comparable. Defaults to the URL origin; override to key on something else (e.g. Mux's cdn= query param). (documented on switchVideoTrack) |
State
| Key | Type | Initial | Declared by | Doc |
|---|---|---|---|---|
cdnPriority |
string[] | undefined |
— | deriveCdnPriority | The CDNs the source is served from (track-URL origins), in manifest priority order — most-preferred first (mirrors HLS content steering's PATHWAY-PRIORITY). Owned by deriveCdnPriority, read by track-switching's preferActiveCdn scope, which narrows to the highest-priority CDN with surviving tracks so video / audio / text stay on one host. Only meaningful for redundant-stream sources; a single-CDN source has one entry. |
failedCdns |
string[] | undefined |
— | setupFailoverMonitor | CDN ids (origins) currently in failover cooldown — read by track-switching's excludeFailedCdns hard constraint, which prunes their tracks so the active-CDN scope falls to the next CDN in cdnPriority. Empty / absent means all CDNs are eligible. |
presentation |
MaybeResolvedPresentation | undefined |
— | deriveCdnPriority, setupFailoverMonitor | The presentation being played. A caller writes { url }; resolvePresentation parses the manifest and populates the rest. (documented on resolvePresentation) |
Composed by
- @videojs/spf/engines/hls-video
- @videojs/spf/engines/hls-audio
- @videojs/spf/engines/hls-video-mpeg-ts
- @videojs/spf/engines/hls-audio-mpeg-ts
Other functions and constants
| Name | Kind | Description | Source |
|---|---|---|---|
behaviors |
const | The behaviors the feature composes, in setup order. Listed under Behaviors. | src/playback/features/multi-cdn.ts |
defaultConfig |
const | The config defaults the feature contributes. It contributes none ({}). |
src/playback/features/multi-cdn.ts |
initialState |
const | The state values the feature seeds. It seeds none ({}). |
src/playback/features/multi-cdn.ts |
Types
| Name | Kind | Description | Source |
|---|---|---|---|
Behaviors |
type | The type of behaviors. |
src/playback/features/multi-cdn.ts |
Config |
type | Every config key the behaviors read. Listed under Config. | src/playback/features/multi-cdn.ts |
Context |
type | Every context key the behaviors declare. | src/playback/features/multi-cdn.ts |
State |
type | Every state key the behaviors and external signals declare. Listed under State. | src/playback/features/multi-cdn.ts |