import { AudioTrack, CanPlayTrack, MaybeResolvedPresentation, MediaContainerData, TextTrack, VideoTrack } from "../../../media/types/index.js"; import { Composition, ContextSignals, StateSignals } from "../../../core/composition/create-composition.js"; import { ShareSignalsConfig } from "../../../core/composition/share-signals.js"; import { BackBufferConfig } from "../../../media/buffer/back-buffer.js"; import { ForwardBufferConfig } from "../../../media/buffer/forward-buffer.js"; import { SourceBufferActor } from "../../actors/dom/source-buffer.js"; import { SegmentLoaderActor } from "../../actors/dom/segment-loader.js"; import { TextTrackSegmentResolver } from "../../primitives/text-segment-load-pipeline.js"; import { TextTracksActor } from "../../actors/text-tracks.js"; import { TextTrackSegmentLoaderActor } from "../../actors/text-track-segment-loader.js"; import { ParsePresentation } from "../../behaviors/resolve-presentation.js"; import { DeriveStartMediaTime } from "../../primitives/derive-start-media-time.js"; import "../../behaviors/establish-start-media-time.js"; import { QualityConfig } from "../../../media/abr/quality-selection.js"; import { addSubtitlesTracksToMedia, getShowingSubtitlesTrackFromMedia, removeAllSubtitlesTracksFromMedia } from "../../../media/dom/text/text-track-slots.js"; import { GetCdnId } from "../../../media/utils/cdn.js"; import { BandwidthConfig, BandwidthState } from "../../../network/bandwidth-estimator.js"; import "../../actors/dom/text-tracks.js"; import { PresentationDurationResolver } from "../../behaviors/calculate-presentation-duration.js"; import { FailoverMonitorConfig } from "../../behaviors/setup-failover-monitor.js"; //#region src/playback/engines/hls/engine.d.ts /** * State shape for the HLS playback engine. * * This is the union of all state required by the behaviors composed into * the HLS engine. Each behavior declares its own state interface; this * type satisfies all of them. */ interface SimpleHlsEngineState { /** * The presentation being played. A caller writes `{ url }`; * `resolvePresentation` parses the manifest and populates the rest. */ presentation?: MaybeResolvedPresentation; preload?: 'auto' | 'metadata' | 'none'; selectedVideoTrackId?: string; selectedAudioTrackId?: string; selectedTextTrackId?: string; bandwidthState?: BandwidthState; mediaContainerData?: Record; userVideoTrackSelection?: Partial; /** * Consumer-driven constraint narrowing the audio candidate set. Sibling * of `userVideoTrackSelection`. Partial-track shape — `{ language: 'es' }`, * `{ id: 'audio-en' }`, etc. `selectAudioTrack` reads this and re-picks * when it changes. Multi-language-audio Tier 2 programmatic-write path. */ userAudioTrackSelection?: Partial; /** * Consumer-driven *intent* for text selection, resolved into * `selectedTextTrackId` by `switchTextTrack`. A language-based partial * (`{ language: 'es' }`) selects captions, `'off'` disables them, and absence * means auto (the engine's `preferredSubtitleLanguage` / DEFAULT-track policy). * Also the write path for the DOM caption UI (via `syncTextTracks`); unlike the * resolved id it persists across source changes (sticky preference). */ userTextTrackSelection?: Partial | 'off'; /** * 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. */ cdnPriority?: string[]; /** * CDN ids (origins) currently in failover cooldown — written by the CDN * monitor when a host fails too often, 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. */ failedCdns?: string[]; currentTime?: number; loadActivated?: boolean; /** * One-shot command: start the current source at this position * (presentation-timeline seconds). Written by consumers or by * `setupAirPlay`'s session-end snapshot; consumed (cleared) by * `applyStartPosition` once the element seeks. See * `behaviors/dom/apply-start-position.ts`. */ startPosition?: number; /** * Intent-level loading policy: initiate no new loading work while `true`. * Written by `setupAirPlay` (the only behavior declaring the key) while a * remote-playback session owns presentation; observed by the * `loadXSegments` dispatchers (park in `'dormant'`) and by * `setupMediaSource` (a pending rebuild waits). See * `SegmentLoadingState['loadingSuspended']`. */ loadingSuspended?: boolean; /** * Author intent for the AirPlay/remote-playback picker, written by the media * adapter's `disableRemotePlayback` IDL property. `true` is an explicit * opt-out: `setupAirPlay` reads it at attach and sets nothing up, leaving the * element's remote playback disabled. Distinct from the underlying * `