@videojs/spf 10.0.0-beta.3 → 10.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -38
- package/dist/default/core/actors/create-machine-actor.js +91 -0
- package/dist/default/core/actors/create-machine-actor.js.map +1 -0
- package/dist/default/core/actors/create-transition-actor.js +46 -0
- package/dist/default/core/actors/create-transition-actor.js.map +1 -0
- package/dist/default/core/composition/create-composition.js +85 -0
- package/dist/default/core/composition/create-composition.js.map +1 -0
- package/dist/default/core/composition/share-signals.js +39 -0
- package/dist/default/core/composition/share-signals.js.map +1 -0
- package/dist/default/core/machine.js +26 -0
- package/dist/default/core/machine.js.map +1 -0
- package/dist/default/core/reactors/create-machine-reactor.js +83 -0
- package/dist/default/core/reactors/create-machine-reactor.js.map +1 -0
- package/dist/default/core/signals/effect.js +41 -0
- package/dist/default/core/signals/effect.js.map +1 -0
- package/dist/default/core/signals/primitives.js +54 -0
- package/dist/default/core/signals/primitives.js.map +1 -0
- package/dist/default/core/signals/when.js +38 -0
- package/dist/default/core/signals/when.js.map +1 -0
- package/dist/default/core/tasks/delayed-reschedule.js +31 -0
- package/dist/default/core/tasks/delayed-reschedule.js.map +1 -0
- package/dist/default/core/tasks/task.js +321 -0
- package/dist/default/core/tasks/task.js.map +1 -0
- package/dist/default/dom.js +9 -0
- package/dist/default/hls-audio.js +3 -0
- package/dist/default/hls-background-video.js +3 -0
- package/dist/default/hls-video.js +4 -0
- package/dist/default/hls.js +8 -0
- package/dist/default/index.js +23 -0
- package/dist/default/index.js.map +1 -0
- package/dist/default/media/abr/quality-selection.js +21 -0
- package/dist/default/media/abr/quality-selection.js.map +1 -0
- package/dist/default/media/buffer/back-buffer.js +46 -0
- package/dist/default/media/buffer/back-buffer.js.map +1 -0
- package/dist/default/media/buffer/forward-buffer.js +119 -0
- package/dist/default/media/buffer/forward-buffer.js.map +1 -0
- package/dist/default/media/dom/capabilities.js +72 -0
- package/dist/default/media/dom/capabilities.js.map +1 -0
- package/dist/default/media/dom/mse/append-segment.js +60 -0
- package/dist/default/media/dom/mse/append-segment.js.map +1 -0
- package/dist/default/media/dom/mse/buffer-flusher.js +55 -0
- package/dist/default/media/dom/mse/buffer-flusher.js.map +1 -0
- package/dist/default/media/dom/mse/duration.js +95 -0
- package/dist/default/media/dom/mse/duration.js.map +1 -0
- package/dist/default/media/dom/mse/end-of-stream.js +20 -0
- package/dist/default/media/dom/mse/end-of-stream.js.map +1 -0
- package/dist/default/media/dom/mse/mediasource-setup.js +242 -0
- package/dist/default/media/dom/mse/mediasource-setup.js.map +1 -0
- package/dist/default/media/dom/screen.js +112 -0
- package/dist/default/media/dom/screen.js.map +1 -0
- package/dist/default/media/dom/text/resolve-vtt-segment.js +50 -0
- package/dist/default/media/dom/text/resolve-vtt-segment.js.map +1 -0
- package/dist/default/media/dom/text/text-track-slots.js +69 -0
- package/dist/default/media/dom/text/text-track-slots.js.map +1 -0
- package/dist/default/media/errors.js +69 -0
- package/dist/default/media/errors.js.map +1 -0
- package/dist/default/media/hls/parse-attributes.js +148 -0
- package/dist/default/media/hls/parse-attributes.js.map +1 -0
- package/dist/default/media/hls/parse-media-playlist.js +261 -0
- package/dist/default/media/hls/parse-media-playlist.js.map +1 -0
- package/dist/default/media/hls/parse-multivariant.js +234 -0
- package/dist/default/media/hls/parse-multivariant.js.map +1 -0
- package/dist/default/media/hls/reload-policy.js +71 -0
- package/dist/default/media/hls/reload-policy.js.map +1 -0
- package/dist/default/media/hls/resolve-url.js +11 -0
- package/dist/default/media/hls/resolve-url.js.map +1 -0
- package/dist/default/media/live-window.js +36 -0
- package/dist/default/media/live-window.js.map +1 -0
- package/dist/default/media/media-tracks/media-tracks.js +101 -0
- package/dist/default/media/media-tracks/media-tracks.js.map +1 -0
- package/dist/default/media/mp4/box.js +58 -0
- package/dist/default/media/mp4/box.js.map +1 -0
- package/dist/default/media/mp4/timestamp-origin.js +107 -0
- package/dist/default/media/mp4/timestamp-origin.js.map +1 -0
- package/dist/default/media/primitives/resolution.js +29 -0
- package/dist/default/media/primitives/resolution.js.map +1 -0
- package/dist/default/media/primitives/select-tracks.js +107 -0
- package/dist/default/media/primitives/select-tracks.js.map +1 -0
- package/dist/default/media/text/parse-vtt-timestamp-map.js +42 -0
- package/dist/default/media/text/parse-vtt-timestamp-map.js.map +1 -0
- package/dist/default/media/text/resolve-vtt-metadata.js +23 -0
- package/dist/default/media/text/resolve-vtt-metadata.js.map +1 -0
- package/dist/default/media/types/index.js +50 -0
- package/dist/default/media/types/index.js.map +1 -0
- package/dist/default/media/utils/cdn.js +56 -0
- package/dist/default/media/utils/cdn.js.map +1 -0
- package/dist/default/media/utils/preload.js +22 -0
- package/dist/default/media/utils/preload.js.map +1 -0
- package/dist/default/media/utils/track-selection.js +47 -0
- package/dist/default/media/utils/track-selection.js.map +1 -0
- package/dist/default/media/utils/tracks.js +144 -0
- package/dist/default/media/utils/tracks.js.map +1 -0
- package/dist/default/media-tracks.js +2 -0
- package/dist/default/mux-audio.js +3 -0
- package/dist/default/mux-background-video.js +3 -0
- package/dist/default/mux-video.js +3 -0
- package/dist/default/network/bandwidth-estimator.js +96 -0
- package/dist/default/network/bandwidth-estimator.js.map +1 -0
- package/dist/default/network/chunked-stream-iterable.js +49 -0
- package/dist/default/network/chunked-stream-iterable.js.map +1 -0
- package/dist/default/network/ewma.js +71 -0
- package/dist/default/network/ewma.js.map +1 -0
- package/dist/default/network/fetch.js +115 -0
- package/dist/default/network/fetch.js.map +1 -0
- package/dist/default/playback/actors/dom/segment-loader.js +249 -0
- package/dist/default/playback/actors/dom/segment-loader.js.map +1 -0
- package/dist/default/playback/actors/dom/source-buffer.js +139 -0
- package/dist/default/playback/actors/dom/source-buffer.js.map +1 -0
- package/dist/default/playback/actors/dom/text-tracks.js +46 -0
- package/dist/default/playback/actors/dom/text-tracks.js.map +1 -0
- package/dist/default/playback/actors/text-track-segment-loader.js +149 -0
- package/dist/default/playback/actors/text-track-segment-loader.js.map +1 -0
- package/dist/default/playback/adapters/hls-audio/adapter.js +186 -0
- package/dist/default/playback/adapters/hls-audio/adapter.js.map +1 -0
- package/dist/default/playback/adapters/hls-audio/media.js +9 -0
- package/dist/default/playback/adapters/hls-audio/media.js.map +1 -0
- package/dist/default/playback/adapters/hls-background-video/adapter.js +211 -0
- package/dist/default/playback/adapters/hls-background-video/adapter.js.map +1 -0
- package/dist/default/playback/adapters/hls-background-video/host.js +60 -0
- package/dist/default/playback/adapters/hls-background-video/host.js.map +1 -0
- package/dist/default/playback/adapters/hls-background-video/media.js +21 -0
- package/dist/default/playback/adapters/hls-background-video/media.js.map +1 -0
- package/dist/default/playback/adapters/hls-video/adapter.js +316 -0
- package/dist/default/playback/adapters/hls-video/adapter.js.map +1 -0
- package/dist/default/playback/adapters/hls-video/error-surface.js +51 -0
- package/dist/default/playback/adapters/hls-video/error-surface.js.map +1 -0
- package/dist/default/playback/adapters/hls-video/media-tracks.js +126 -0
- package/dist/default/playback/adapters/hls-video/media-tracks.js.map +1 -0
- package/dist/default/playback/adapters/hls-video/media.js +11 -0
- package/dist/default/playback/adapters/hls-video/media.js.map +1 -0
- package/dist/default/playback/adapters/mux-audio/media.js +26 -0
- package/dist/default/playback/adapters/mux-audio/media.js.map +1 -0
- package/dist/default/playback/adapters/mux-video/adapter.js +105 -0
- package/dist/default/playback/adapters/mux-video/adapter.js.map +1 -0
- package/dist/default/playback/adapters/mux-video/media.js +23 -0
- package/dist/default/playback/adapters/mux-video/media.js.map +1 -0
- package/dist/default/playback/behaviors/calculate-presentation-duration.js +36 -0
- package/dist/default/playback/behaviors/calculate-presentation-duration.js.map +1 -0
- package/dist/default/playback/behaviors/collect-errors.js +111 -0
- package/dist/default/playback/behaviors/collect-errors.js.map +1 -0
- package/dist/default/playback/behaviors/derive-cdn-priority.js +68 -0
- package/dist/default/playback/behaviors/derive-cdn-priority.js.map +1 -0
- package/dist/default/playback/behaviors/dom/airplay.js +211 -0
- package/dist/default/playback/behaviors/dom/airplay.js.map +1 -0
- package/dist/default/playback/behaviors/dom/apply-start-position.js +93 -0
- package/dist/default/playback/behaviors/dom/apply-start-position.js.map +1 -0
- package/dist/default/playback/behaviors/dom/end-of-stream.js +102 -0
- package/dist/default/playback/behaviors/dom/end-of-stream.js.map +1 -0
- package/dist/default/playback/behaviors/dom/load-segments.js +181 -0
- package/dist/default/playback/behaviors/dom/load-segments.js.map +1 -0
- package/dist/default/playback/behaviors/dom/recover-end-stall.js +77 -0
- package/dist/default/playback/behaviors/dom/recover-end-stall.js.map +1 -0
- package/dist/default/playback/behaviors/dom/seek-to-live-edge.js +132 -0
- package/dist/default/playback/behaviors/dom/seek-to-live-edge.js.map +1 -0
- package/dist/default/playback/behaviors/dom/setup-buffer-actors.js +205 -0
- package/dist/default/playback/behaviors/dom/setup-buffer-actors.js.map +1 -0
- package/dist/default/playback/behaviors/dom/setup-mediasource.js +114 -0
- package/dist/default/playback/behaviors/dom/setup-mediasource.js.map +1 -0
- package/dist/default/playback/behaviors/dom/setup-text-track-actors.js +40 -0
- package/dist/default/playback/behaviors/dom/setup-text-track-actors.js.map +1 -0
- package/dist/default/playback/behaviors/dom/sync-live-seekable-range.js +26 -0
- package/dist/default/playback/behaviors/dom/sync-live-seekable-range.js.map +1 -0
- package/dist/default/playback/behaviors/dom/sync-text-tracks.js +124 -0
- package/dist/default/playback/behaviors/dom/sync-text-tracks.js.map +1 -0
- package/dist/default/playback/behaviors/dom/track-current-time.js +52 -0
- package/dist/default/playback/behaviors/dom/track-current-time.js.map +1 -0
- package/dist/default/playback/behaviors/dom/track-load-triggers.js +94 -0
- package/dist/default/playback/behaviors/dom/track-load-triggers.js.map +1 -0
- package/dist/default/playback/behaviors/dom/track-playback-rate.js +37 -0
- package/dist/default/playback/behaviors/dom/track-playback-rate.js.map +1 -0
- package/dist/default/playback/behaviors/dom/track-player-resolution.js +57 -0
- package/dist/default/playback/behaviors/dom/track-player-resolution.js.map +1 -0
- package/dist/default/playback/behaviors/dom/track-screen-resolution.js +29 -0
- package/dist/default/playback/behaviors/dom/track-screen-resolution.js.map +1 -0
- package/dist/default/playback/behaviors/dom/update-mediasource-duration.js +113 -0
- package/dist/default/playback/behaviors/dom/update-mediasource-duration.js.map +1 -0
- package/dist/default/playback/behaviors/establish-start-media-time.js +197 -0
- package/dist/default/playback/behaviors/establish-start-media-time.js.map +1 -0
- package/dist/default/playback/behaviors/resolve-presentation.js +85 -0
- package/dist/default/playback/behaviors/resolve-presentation.js.map +1 -0
- package/dist/default/playback/behaviors/resolve-track.js +141 -0
- package/dist/default/playback/behaviors/resolve-track.js.map +1 -0
- package/dist/default/playback/behaviors/select-tracks.js +216 -0
- package/dist/default/playback/behaviors/select-tracks.js.map +1 -0
- package/dist/default/playback/behaviors/setup-failover-monitor.js +66 -0
- package/dist/default/playback/behaviors/setup-failover-monitor.js.map +1 -0
- package/dist/default/playback/behaviors/sync-preload.js +59 -0
- package/dist/default/playback/behaviors/sync-preload.js.map +1 -0
- package/dist/default/playback/behaviors/track-switching.js +391 -0
- package/dist/default/playback/behaviors/track-switching.js.map +1 -0
- package/dist/default/playback/engines/hls/engine-audio-only.js +98 -0
- package/dist/default/playback/engines/hls/engine-audio-only.js.map +1 -0
- package/dist/default/playback/engines/hls/engine-background-video.js +92 -0
- package/dist/default/playback/engines/hls/engine-background-video.js.map +1 -0
- package/dist/default/playback/engines/hls/engine.js +147 -0
- package/dist/default/playback/engines/hls/engine.js.map +1 -0
- package/dist/default/playback/primitives/error-messages.js +51 -0
- package/dist/default/playback/primitives/error-messages.js.map +1 -0
- package/dist/default/playback/primitives/failover-fetch.js +42 -0
- package/dist/default/playback/primitives/failover-fetch.js.map +1 -0
- package/dist/default/playback/primitives/head-peek.js +44 -0
- package/dist/default/playback/primitives/head-peek.js.map +1 -0
- package/dist/default/playback/primitives/live-window.js +66 -0
- package/dist/default/playback/primitives/live-window.js.map +1 -0
- package/dist/default/playback/primitives/relocation-pipelines.js +203 -0
- package/dist/default/playback/primitives/relocation-pipelines.js.map +1 -0
- package/dist/default/playback/primitives/report-track-conditions.js +86 -0
- package/dist/default/playback/primitives/report-track-conditions.js.map +1 -0
- package/dist/default/playback/primitives/segment-load-pipeline.js +96 -0
- package/dist/default/playback/primitives/segment-load-pipeline.js.map +1 -0
- package/dist/default/playback/primitives/selection-rules.js +86 -0
- package/dist/default/playback/primitives/selection-rules.js.map +1 -0
- package/dist/default/playback/primitives/text-segment-load-pipeline.js +37 -0
- package/dist/default/playback/primitives/text-segment-load-pipeline.js.map +1 -0
- package/dist/default/playback/primitives/track-types.js +61 -0
- package/dist/default/playback/primitives/track-types.js.map +1 -0
- package/dist/dev/core/actors/actor.d.ts +26 -0
- package/dist/dev/core/actors/actor.d.ts.map +1 -0
- package/dist/dev/core/actors/create-machine-actor.d.ts +128 -0
- package/dist/dev/core/actors/create-machine-actor.d.ts.map +1 -0
- package/dist/dev/core/actors/create-machine-actor.js +91 -0
- package/dist/dev/core/actors/create-machine-actor.js.map +1 -0
- package/dist/dev/core/actors/create-transition-actor.d.ts +41 -0
- package/dist/dev/core/actors/create-transition-actor.d.ts.map +1 -0
- package/dist/dev/core/actors/create-transition-actor.js +46 -0
- package/dist/dev/core/actors/create-transition-actor.js.map +1 -0
- package/dist/dev/core/composition/create-composition.d.ts +273 -0
- package/dist/dev/core/composition/create-composition.d.ts.map +1 -0
- package/dist/dev/core/composition/create-composition.js +85 -0
- package/dist/dev/core/composition/create-composition.js.map +1 -0
- package/dist/dev/core/composition/share-signals.d.ts +46 -0
- package/dist/dev/core/composition/share-signals.d.ts.map +1 -0
- package/dist/dev/core/composition/share-signals.js +39 -0
- package/dist/dev/core/composition/share-signals.js.map +1 -0
- package/dist/dev/core/machine.d.ts +21 -0
- package/dist/dev/core/machine.d.ts.map +1 -0
- package/dist/dev/core/machine.js +26 -0
- package/dist/dev/core/machine.js.map +1 -0
- package/dist/dev/core/reactors/create-machine-reactor.d.ts +93 -0
- package/dist/dev/core/reactors/create-machine-reactor.d.ts.map +1 -0
- package/dist/dev/core/reactors/create-machine-reactor.js +83 -0
- package/dist/dev/core/reactors/create-machine-reactor.js.map +1 -0
- package/dist/dev/core/signals/effect.d.ts +15 -0
- package/dist/dev/core/signals/effect.d.ts.map +1 -0
- package/dist/dev/core/signals/effect.js +41 -0
- package/dist/dev/core/signals/effect.js.map +1 -0
- package/dist/dev/core/signals/primitives.d.ts +46 -0
- package/dist/dev/core/signals/primitives.d.ts.map +1 -0
- package/dist/dev/core/signals/primitives.js +54 -0
- package/dist/dev/core/signals/primitives.js.map +1 -0
- package/dist/dev/core/signals/when.js +38 -0
- package/dist/dev/core/signals/when.js.map +1 -0
- package/dist/dev/core/tasks/delayed-reschedule.js +31 -0
- package/dist/dev/core/tasks/delayed-reschedule.js.map +1 -0
- package/dist/dev/core/tasks/task.d.ts +166 -0
- package/dist/dev/core/tasks/task.d.ts.map +1 -0
- package/dist/dev/core/tasks/task.js +321 -0
- package/dist/dev/core/tasks/task.js.map +1 -0
- package/dist/dev/dom.d.ts +9 -0
- package/dist/dev/dom.js +9 -0
- package/dist/dev/hls-audio.d.ts +3 -0
- package/dist/dev/hls-audio.js +3 -0
- package/dist/dev/hls-background-video.d.ts +4 -0
- package/dist/dev/hls-background-video.js +3 -0
- package/dist/dev/hls-video.d.ts +5 -0
- package/dist/dev/hls-video.js +4 -0
- package/dist/dev/hls.d.ts +9 -0
- package/dist/dev/hls.js +8 -0
- package/dist/dev/index.d.ts +24 -0
- package/dist/dev/index.d.ts.map +1 -0
- package/dist/dev/index.js +23 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/dev/media/abr/quality-selection.d.ts +22 -0
- package/dist/dev/media/abr/quality-selection.d.ts.map +1 -0
- package/dist/dev/media/abr/quality-selection.js +21 -0
- package/dist/dev/media/abr/quality-selection.js.map +1 -0
- package/dist/dev/media/buffer/back-buffer.d.ts +14 -0
- package/dist/dev/media/buffer/back-buffer.d.ts.map +1 -0
- package/dist/dev/media/buffer/back-buffer.js +46 -0
- package/dist/dev/media/buffer/back-buffer.js.map +1 -0
- package/dist/dev/media/buffer/forward-buffer.d.ts +14 -0
- package/dist/dev/media/buffer/forward-buffer.d.ts.map +1 -0
- package/dist/dev/media/buffer/forward-buffer.js +119 -0
- package/dist/dev/media/buffer/forward-buffer.js.map +1 -0
- package/dist/dev/media/dom/capabilities.js +72 -0
- package/dist/dev/media/dom/capabilities.js.map +1 -0
- package/dist/dev/media/dom/mse/append-segment.d.ts +18 -0
- package/dist/dev/media/dom/mse/append-segment.d.ts.map +1 -0
- package/dist/dev/media/dom/mse/append-segment.js +60 -0
- package/dist/dev/media/dom/mse/append-segment.js.map +1 -0
- package/dist/dev/media/dom/mse/buffer-flusher.d.ts +24 -0
- package/dist/dev/media/dom/mse/buffer-flusher.d.ts.map +1 -0
- package/dist/dev/media/dom/mse/buffer-flusher.js +55 -0
- package/dist/dev/media/dom/mse/buffer-flusher.js.map +1 -0
- package/dist/dev/media/dom/mse/duration.js +95 -0
- package/dist/dev/media/dom/mse/duration.js.map +1 -0
- package/dist/dev/media/dom/mse/end-of-stream.js +20 -0
- package/dist/dev/media/dom/mse/end-of-stream.js.map +1 -0
- package/dist/dev/media/dom/mse/mediasource-setup.js +242 -0
- package/dist/dev/media/dom/mse/mediasource-setup.js.map +1 -0
- package/dist/dev/media/dom/screen.d.ts +7 -0
- package/dist/dev/media/dom/screen.d.ts.map +1 -0
- package/dist/dev/media/dom/screen.js +112 -0
- package/dist/dev/media/dom/screen.js.map +1 -0
- package/dist/dev/media/dom/text/resolve-vtt-segment.d.ts +6 -0
- package/dist/dev/media/dom/text/resolve-vtt-segment.d.ts.map +1 -0
- package/dist/dev/media/dom/text/resolve-vtt-segment.js +50 -0
- package/dist/dev/media/dom/text/resolve-vtt-segment.js.map +1 -0
- package/dist/dev/media/dom/text/text-track-slots.d.ts +30 -0
- package/dist/dev/media/dom/text/text-track-slots.d.ts.map +1 -0
- package/dist/dev/media/dom/text/text-track-slots.js +69 -0
- package/dist/dev/media/dom/text/text-track-slots.js.map +1 -0
- package/dist/dev/media/errors.d.ts +82 -0
- package/dist/dev/media/errors.d.ts.map +1 -0
- package/dist/dev/media/errors.js +69 -0
- package/dist/dev/media/errors.js.map +1 -0
- package/dist/dev/media/hls/parse-attributes.js +148 -0
- package/dist/dev/media/hls/parse-attributes.js.map +1 -0
- package/dist/dev/media/hls/parse-media-playlist.js +261 -0
- package/dist/dev/media/hls/parse-media-playlist.js.map +1 -0
- package/dist/dev/media/hls/parse-multivariant.js +234 -0
- package/dist/dev/media/hls/parse-multivariant.js.map +1 -0
- package/dist/dev/media/hls/reload-policy.js +71 -0
- package/dist/dev/media/hls/reload-policy.js.map +1 -0
- package/dist/dev/media/hls/resolve-url.js +11 -0
- package/dist/dev/media/hls/resolve-url.js.map +1 -0
- package/dist/dev/media/live-window.js +36 -0
- package/dist/dev/media/live-window.js.map +1 -0
- package/dist/dev/media/media-tracks/media-tracks.d.ts +51 -0
- package/dist/dev/media/media-tracks/media-tracks.d.ts.map +1 -0
- package/dist/dev/media/media-tracks/media-tracks.js +101 -0
- package/dist/dev/media/media-tracks/media-tracks.js.map +1 -0
- package/dist/dev/media/mp4/box.js +58 -0
- package/dist/dev/media/mp4/box.js.map +1 -0
- package/dist/dev/media/mp4/timestamp-origin.js +107 -0
- package/dist/dev/media/mp4/timestamp-origin.js.map +1 -0
- package/dist/dev/media/primitives/resolution.d.ts +24 -0
- package/dist/dev/media/primitives/resolution.d.ts.map +1 -0
- package/dist/dev/media/primitives/resolution.js +29 -0
- package/dist/dev/media/primitives/resolution.js.map +1 -0
- package/dist/dev/media/primitives/select-tracks.js +107 -0
- package/dist/dev/media/primitives/select-tracks.js.map +1 -0
- package/dist/dev/media/text/parse-vtt-timestamp-map.js +42 -0
- package/dist/dev/media/text/parse-vtt-timestamp-map.js.map +1 -0
- package/dist/dev/media/text/resolve-vtt-metadata.js +23 -0
- package/dist/dev/media/text/resolve-vtt-metadata.js.map +1 -0
- package/dist/dev/media/types/index.d.ts +377 -0
- package/dist/dev/media/types/index.d.ts.map +1 -0
- package/dist/dev/media/types/index.js +50 -0
- package/dist/dev/media/types/index.js.map +1 -0
- package/dist/dev/media/utils/cdn.d.ts +13 -0
- package/dist/dev/media/utils/cdn.d.ts.map +1 -0
- package/dist/dev/media/utils/cdn.js +56 -0
- package/dist/dev/media/utils/cdn.js.map +1 -0
- package/dist/dev/media/utils/preload.js +22 -0
- package/dist/dev/media/utils/preload.js.map +1 -0
- package/dist/dev/media/utils/track-selection.js +47 -0
- package/dist/dev/media/utils/track-selection.js.map +1 -0
- package/dist/dev/media/utils/tracks.js +144 -0
- package/dist/dev/media/utils/tracks.js.map +1 -0
- package/dist/dev/media-tracks.d.ts +3 -0
- package/dist/dev/media-tracks.js +2 -0
- package/dist/dev/mux-audio.d.ts +4 -0
- package/dist/dev/mux-audio.js +3 -0
- package/dist/dev/mux-background-video.d.ts +4 -0
- package/dist/dev/mux-background-video.js +3 -0
- package/dist/dev/mux-video.d.ts +4 -0
- package/dist/dev/mux-video.js +3 -0
- package/dist/dev/network/bandwidth-estimator.d.ts +50 -0
- package/dist/dev/network/bandwidth-estimator.d.ts.map +1 -0
- package/dist/dev/network/bandwidth-estimator.js +96 -0
- package/dist/dev/network/bandwidth-estimator.js.map +1 -0
- package/dist/dev/network/chunked-stream-iterable.js +49 -0
- package/dist/dev/network/chunked-stream-iterable.js.map +1 -0
- package/dist/dev/network/ewma.js +71 -0
- package/dist/dev/network/ewma.js.map +1 -0
- package/dist/dev/network/fetch.js +115 -0
- package/dist/dev/network/fetch.js.map +1 -0
- package/dist/dev/playback/actors/dom/segment-loader.d.ts +48 -0
- package/dist/dev/playback/actors/dom/segment-loader.d.ts.map +1 -0
- package/dist/dev/playback/actors/dom/segment-loader.js +249 -0
- package/dist/dev/playback/actors/dom/segment-loader.js.map +1 -0
- package/dist/dev/playback/actors/dom/source-buffer.d.ts +47 -0
- package/dist/dev/playback/actors/dom/source-buffer.d.ts.map +1 -0
- package/dist/dev/playback/actors/dom/source-buffer.js +139 -0
- package/dist/dev/playback/actors/dom/source-buffer.js.map +1 -0
- package/dist/dev/playback/actors/dom/text-tracks.d.ts +3 -0
- package/dist/dev/playback/actors/dom/text-tracks.js +46 -0
- package/dist/dev/playback/actors/dom/text-tracks.js.map +1 -0
- package/dist/dev/playback/actors/text-track-segment-loader.d.ts +54 -0
- package/dist/dev/playback/actors/text-track-segment-loader.d.ts.map +1 -0
- package/dist/dev/playback/actors/text-track-segment-loader.js +149 -0
- package/dist/dev/playback/actors/text-track-segment-loader.js.map +1 -0
- package/dist/dev/playback/actors/text-tracks.d.ts +33 -0
- package/dist/dev/playback/actors/text-tracks.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-audio/adapter.d.ts +54 -0
- package/dist/dev/playback/adapters/hls-audio/adapter.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-audio/adapter.js +186 -0
- package/dist/dev/playback/adapters/hls-audio/adapter.js.map +1 -0
- package/dist/dev/playback/adapters/hls-audio/media.d.ts +10 -0
- package/dist/dev/playback/adapters/hls-audio/media.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-audio/media.js +9 -0
- package/dist/dev/playback/adapters/hls-audio/media.js.map +1 -0
- package/dist/dev/playback/adapters/hls-background-video/adapter.d.ts +77 -0
- package/dist/dev/playback/adapters/hls-background-video/adapter.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-background-video/adapter.js +211 -0
- package/dist/dev/playback/adapters/hls-background-video/adapter.js.map +1 -0
- package/dist/dev/playback/adapters/hls-background-video/host.d.ts +38 -0
- package/dist/dev/playback/adapters/hls-background-video/host.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-background-video/host.js +60 -0
- package/dist/dev/playback/adapters/hls-background-video/host.js.map +1 -0
- package/dist/dev/playback/adapters/hls-background-video/media.d.ts +20 -0
- package/dist/dev/playback/adapters/hls-background-video/media.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-background-video/media.js +21 -0
- package/dist/dev/playback/adapters/hls-background-video/media.js.map +1 -0
- package/dist/dev/playback/adapters/hls-video/adapter.d.ts +63 -0
- package/dist/dev/playback/adapters/hls-video/adapter.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-video/adapter.js +316 -0
- package/dist/dev/playback/adapters/hls-video/adapter.js.map +1 -0
- package/dist/dev/playback/adapters/hls-video/error-surface.d.ts +18 -0
- package/dist/dev/playback/adapters/hls-video/error-surface.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-video/error-surface.js +51 -0
- package/dist/dev/playback/adapters/hls-video/error-surface.js.map +1 -0
- package/dist/dev/playback/adapters/hls-video/media-tracks.d.ts +22 -0
- package/dist/dev/playback/adapters/hls-video/media-tracks.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-video/media-tracks.js +126 -0
- package/dist/dev/playback/adapters/hls-video/media-tracks.js.map +1 -0
- package/dist/dev/playback/adapters/hls-video/media.d.ts +10 -0
- package/dist/dev/playback/adapters/hls-video/media.d.ts.map +1 -0
- package/dist/dev/playback/adapters/hls-video/media.js +11 -0
- package/dist/dev/playback/adapters/hls-video/media.js.map +1 -0
- package/dist/dev/playback/adapters/mux-audio/media.d.ts +28 -0
- package/dist/dev/playback/adapters/mux-audio/media.d.ts.map +1 -0
- package/dist/dev/playback/adapters/mux-audio/media.js +26 -0
- package/dist/dev/playback/adapters/mux-audio/media.js.map +1 -0
- package/dist/dev/playback/adapters/mux-video/adapter.d.ts +34 -0
- package/dist/dev/playback/adapters/mux-video/adapter.d.ts.map +1 -0
- package/dist/dev/playback/adapters/mux-video/adapter.js +105 -0
- package/dist/dev/playback/adapters/mux-video/adapter.js.map +1 -0
- package/dist/dev/playback/adapters/mux-video/media.d.ts +24 -0
- package/dist/dev/playback/adapters/mux-video/media.d.ts.map +1 -0
- package/dist/dev/playback/adapters/mux-video/media.js +23 -0
- package/dist/dev/playback/adapters/mux-video/media.js.map +1 -0
- package/dist/dev/playback/behaviors/calculate-presentation-duration.d.ts +26 -0
- package/dist/dev/playback/behaviors/calculate-presentation-duration.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/calculate-presentation-duration.js +36 -0
- package/dist/dev/playback/behaviors/calculate-presentation-duration.js.map +1 -0
- package/dist/dev/playback/behaviors/collect-errors.js +111 -0
- package/dist/dev/playback/behaviors/collect-errors.js.map +1 -0
- package/dist/dev/playback/behaviors/derive-cdn-priority.js +68 -0
- package/dist/dev/playback/behaviors/derive-cdn-priority.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/airplay.js +211 -0
- package/dist/dev/playback/behaviors/dom/airplay.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/apply-start-position.js +93 -0
- package/dist/dev/playback/behaviors/dom/apply-start-position.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/end-of-stream.js +102 -0
- package/dist/dev/playback/behaviors/dom/end-of-stream.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/load-segments.d.ts +72 -0
- package/dist/dev/playback/behaviors/dom/load-segments.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/dom/load-segments.js +181 -0
- package/dist/dev/playback/behaviors/dom/load-segments.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/recover-end-stall.js +77 -0
- package/dist/dev/playback/behaviors/dom/recover-end-stall.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/seek-to-live-edge.js +132 -0
- package/dist/dev/playback/behaviors/dom/seek-to-live-edge.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/setup-buffer-actors.js +205 -0
- package/dist/dev/playback/behaviors/dom/setup-buffer-actors.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/setup-mediasource.js +114 -0
- package/dist/dev/playback/behaviors/dom/setup-mediasource.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/setup-text-track-actors.d.ts +28 -0
- package/dist/dev/playback/behaviors/dom/setup-text-track-actors.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/dom/setup-text-track-actors.js +40 -0
- package/dist/dev/playback/behaviors/dom/setup-text-track-actors.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/sync-live-seekable-range.js +26 -0
- package/dist/dev/playback/behaviors/dom/sync-live-seekable-range.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/sync-text-tracks.js +124 -0
- package/dist/dev/playback/behaviors/dom/sync-text-tracks.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-current-time.d.ts +33 -0
- package/dist/dev/playback/behaviors/dom/track-current-time.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-current-time.js +52 -0
- package/dist/dev/playback/behaviors/dom/track-current-time.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-load-triggers.d.ts +47 -0
- package/dist/dev/playback/behaviors/dom/track-load-triggers.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-load-triggers.js +94 -0
- package/dist/dev/playback/behaviors/dom/track-load-triggers.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-playback-rate.d.ts +33 -0
- package/dist/dev/playback/behaviors/dom/track-playback-rate.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-playback-rate.js +37 -0
- package/dist/dev/playback/behaviors/dom/track-playback-rate.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-player-resolution.d.ts +8 -0
- package/dist/dev/playback/behaviors/dom/track-player-resolution.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-player-resolution.js +57 -0
- package/dist/dev/playback/behaviors/dom/track-player-resolution.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/track-screen-resolution.js +29 -0
- package/dist/dev/playback/behaviors/dom/track-screen-resolution.js.map +1 -0
- package/dist/dev/playback/behaviors/dom/update-mediasource-duration.js +113 -0
- package/dist/dev/playback/behaviors/dom/update-mediasource-duration.js.map +1 -0
- package/dist/dev/playback/behaviors/establish-start-media-time.d.ts +36 -0
- package/dist/dev/playback/behaviors/establish-start-media-time.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/establish-start-media-time.js +197 -0
- package/dist/dev/playback/behaviors/establish-start-media-time.js.map +1 -0
- package/dist/dev/playback/behaviors/resolve-presentation.d.ts +8 -0
- package/dist/dev/playback/behaviors/resolve-presentation.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/resolve-presentation.js +85 -0
- package/dist/dev/playback/behaviors/resolve-presentation.js.map +1 -0
- package/dist/dev/playback/behaviors/resolve-track.js +141 -0
- package/dist/dev/playback/behaviors/resolve-track.js.map +1 -0
- package/dist/dev/playback/behaviors/select-tracks.d.ts +72 -0
- package/dist/dev/playback/behaviors/select-tracks.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/select-tracks.js +216 -0
- package/dist/dev/playback/behaviors/select-tracks.js.map +1 -0
- package/dist/dev/playback/behaviors/setup-failover-monitor.d.ts +14 -0
- package/dist/dev/playback/behaviors/setup-failover-monitor.d.ts.map +1 -0
- package/dist/dev/playback/behaviors/setup-failover-monitor.js +66 -0
- package/dist/dev/playback/behaviors/setup-failover-monitor.js.map +1 -0
- package/dist/dev/playback/behaviors/sync-preload.js +59 -0
- package/dist/dev/playback/behaviors/sync-preload.js.map +1 -0
- package/dist/dev/playback/behaviors/track-switching.js +391 -0
- package/dist/dev/playback/behaviors/track-switching.js.map +1 -0
- package/dist/dev/playback/engines/hls/engine-audio-only.d.ts +173 -0
- package/dist/dev/playback/engines/hls/engine-audio-only.d.ts.map +1 -0
- package/dist/dev/playback/engines/hls/engine-audio-only.js +98 -0
- package/dist/dev/playback/engines/hls/engine-audio-only.js.map +1 -0
- package/dist/dev/playback/engines/hls/engine-background-video.d.ts +158 -0
- package/dist/dev/playback/engines/hls/engine-background-video.d.ts.map +1 -0
- package/dist/dev/playback/engines/hls/engine-background-video.js +92 -0
- package/dist/dev/playback/engines/hls/engine-background-video.js.map +1 -0
- package/dist/dev/playback/engines/hls/engine.d.ts +329 -0
- package/dist/dev/playback/engines/hls/engine.d.ts.map +1 -0
- package/dist/dev/playback/engines/hls/engine.js +147 -0
- package/dist/dev/playback/engines/hls/engine.js.map +1 -0
- package/dist/dev/playback/primitives/derive-start-media-time.d.ts +16 -0
- package/dist/dev/playback/primitives/derive-start-media-time.d.ts.map +1 -0
- package/dist/dev/playback/primitives/error-messages.js +51 -0
- package/dist/dev/playback/primitives/error-messages.js.map +1 -0
- package/dist/dev/playback/primitives/failover-fetch.js +42 -0
- package/dist/dev/playback/primitives/failover-fetch.js.map +1 -0
- package/dist/dev/playback/primitives/head-peek.js +44 -0
- package/dist/dev/playback/primitives/head-peek.js.map +1 -0
- package/dist/dev/playback/primitives/live-window.js +66 -0
- package/dist/dev/playback/primitives/live-window.js.map +1 -0
- package/dist/dev/playback/primitives/relocation-pipelines.js +203 -0
- package/dist/dev/playback/primitives/relocation-pipelines.js.map +1 -0
- package/dist/dev/playback/primitives/report-track-conditions.d.ts +11 -0
- package/dist/dev/playback/primitives/report-track-conditions.d.ts.map +1 -0
- package/dist/dev/playback/primitives/report-track-conditions.js +86 -0
- package/dist/dev/playback/primitives/report-track-conditions.js.map +1 -0
- package/dist/dev/playback/primitives/segment-load-pipeline.d.ts +2 -0
- package/dist/dev/playback/primitives/segment-load-pipeline.js +96 -0
- package/dist/dev/playback/primitives/segment-load-pipeline.js.map +1 -0
- package/dist/dev/playback/primitives/selection-rules.d.ts +38 -0
- package/dist/dev/playback/primitives/selection-rules.d.ts.map +1 -0
- package/dist/dev/playback/primitives/selection-rules.js +86 -0
- package/dist/dev/playback/primitives/selection-rules.js.map +1 -0
- package/dist/dev/playback/primitives/source-buffer-messages.d.ts +43 -0
- package/dist/dev/playback/primitives/source-buffer-messages.d.ts.map +1 -0
- package/dist/dev/playback/primitives/text-segment-load-pipeline.d.ts +65 -0
- package/dist/dev/playback/primitives/text-segment-load-pipeline.d.ts.map +1 -0
- package/dist/dev/playback/primitives/text-segment-load-pipeline.js +37 -0
- package/dist/dev/playback/primitives/text-segment-load-pipeline.js.map +1 -0
- package/dist/dev/playback/primitives/text-track-messages.d.ts +14 -0
- package/dist/dev/playback/primitives/text-track-messages.d.ts.map +1 -0
- package/dist/dev/playback/primitives/track-types.js +61 -0
- package/dist/dev/playback/primitives/track-types.js.map +1 -0
- package/package.json +63 -26
- package/dist/adapter-CMw-rvbk.js +0 -3512
- package/dist/adapter-CMw-rvbk.js.map +0 -1
- package/dist/adapter-l8iJN_GI.d.ts +0 -689
- package/dist/adapter-l8iJN_GI.d.ts.map +0 -1
- package/dist/dom/index.d.ts +0 -243
- package/dist/dom/index.d.ts.map +0 -1
- package/dist/dom/index.js +0 -38
- package/dist/dom/index.js.map +0 -1
- package/dist/dom/playback-engine/index.d.ts +0 -2
- package/dist/dom/playback-engine/index.js +0 -4
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/src-DRsS_H80.js +0 -14
- package/dist/src-DRsS_H80.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-window.js","names":[],"sources":["../../../../src/playback/primitives/live-window.ts"],"sourcesContent":["/**\n * Resolve the live window from engine state — the single call site the\n * seek-to-live-edge and live-seekable-range behaviors share, so their window\n * derivation can't drift apart.\n *\n * The window is the **intersection over the selected A/V tracks'** windows\n * (`max` of starts, `min` of ends): publication skew between the two playlists\n * shrinks the window to what both can actually serve, and the `max` also clamps\n * the legitimate *negative* early `startTime` of a non-reference track whose\n * window precedes the join point (presentation-0) — see\n * `internal/design/spf/live-presentation-timeline-model.md` (Phase 2 window\n * math). With one selected type (video-only / audio-only) its window stands\n * alone.\n *\n * Reads signals lazily — call it inside a reactive context (an effect) so the\n * read tracks `presentation` + the selected-track ids.\n */\nimport type { ReadonlySignal } from '../../core/signals/primitives';\nimport { type LiveWindow, liveWindowFor } from '../../media/live-window';\nimport type { MaybeResolvedPresentation, TrackType } from '../../media/types';\nimport { getTracksByType } from '../../media/utils/tracks';\n\nexport interface LiveWindowState {\n presentation: ReadonlySignal<MaybeResolvedPresentation | undefined>;\n selectedVideoTrackId?: ReadonlySignal<string | undefined>;\n selectedAudioTrackId?: ReadonlySignal<string | undefined>;\n}\n\n/**\n * The id of the timeline-bearing track: the selected video track when present,\n * else the selected audio track. The single pick both the window derivation and\n * the live-latency resolution (`seek-to-live-edge`) share, so they can't drift.\n */\nexport function liveTrackId(state: LiveWindowState): string | undefined {\n return state.selectedVideoTrackId?.get() ?? state.selectedAudioTrackId?.get();\n}\n\n/**\n * One type's window: the selected track's when it's resolved, else any resolved\n * track of the type. The fallback keeps the window from blinking to `null`\n * mid ABR / user switch — all renditions of a type are time-aligned and share\n * the anchor, so a deselected track's window may trail live by up to one reload\n * during the switch gap (acceptable; the selected track's fresh window resumes\n * the moment it resolves). A null blink would flip `seekToLiveEdge` out of\n * `live` and stall the seekable-range writer.\n */\nfunction liveWindowForType(\n presentation: MaybeResolvedPresentation | undefined,\n selectedId: string | undefined,\n type: TrackType\n): LiveWindow | null {\n if (!presentation || selectedId === undefined) return null;\n const selected = liveWindowFor(presentation, selectedId);\n if (selected) return selected;\n for (const track of getTracksByType(presentation, type)) {\n const window = liveWindowFor(presentation, track.id);\n if (window) return window;\n }\n return null;\n}\n\nexport function liveWindowFromState(state: LiveWindowState): LiveWindow | null {\n const presentation = state.presentation.get();\n const video = liveWindowForType(presentation, state.selectedVideoTrackId?.get(), 'video');\n const audio = liveWindowForType(presentation, state.selectedAudioTrackId?.get(), 'audio');\n if (video && audio) {\n const start = Math.max(video.start, audio.start);\n const end = Math.min(video.end, audio.end);\n // A degenerate intersection (disjoint windows — one playlist stalled a full\n // window behind the other) means there is no position both types can serve:\n // no live edge, rather than an invented one.\n return start < end ? { start, end } : null;\n }\n return video ?? audio;\n}\n\n/**\n * Resolve the target live latency (seconds the playhead should trail the live\n * edge) for the timeline-bearing track. Format-specific — supplied by the engine\n * (HLS: `HOLD-BACK`; DASH would use `suggestedPresentationDelay`) — so the live\n * edge stays format-neutral.\n */\nexport type ResolveLiveLatency = (\n presentation: MaybeResolvedPresentation | undefined,\n trackId: string | undefined\n) => number;\n\n/** The live window plus the target playhead position within it. */\nexport interface LiveEdge extends LiveWindow {\n /** Where to sit near the live edge: `end` − live latency, clamped to `start`. */\n liveEdgeStart: number;\n}\n\n/**\n * Resolve the live edge — the window bounds plus the target playhead position —\n * from a behavior's setup arguments. Bundles the window geometry and the\n * format-specific latency policy (`config.resolveLiveLatency`) so the consuming\n * behavior never has to compose them; it just forwards its `{ state, config }`.\n * `null` when there is no live edge (VOD / ended / unresolved).\n *\n * Reads signals lazily — call it inside a reactive context (an effect).\n */\nexport function getLiveEdge({\n state,\n // context, // not needed yet; in the shape for setup-parity when it is\n config,\n}: {\n state: LiveWindowState;\n config?: { resolveLiveLatency?: ResolveLiveLatency };\n}): LiveEdge | null {\n const window = liveWindowFromState(state);\n if (!window) return null;\n const latency = config?.resolveLiveLatency?.(state.presentation.get(), liveTrackId(state)) ?? 0;\n return { ...window, liveEdgeStart: Math.max(window.start, window.end - latency) };\n}\n"],"mappings":";;;;;;;;AAiCA,SAAgB,YAAY,OAA4C;CACtE,OAAO,MAAM,sBAAsB,IAAI,KAAK,MAAM,sBAAsB,IAAI;AAC9E;;;;;;;;;;AAWA,SAAS,kBACP,cACA,YACA,MACmB;CACnB,IAAI,CAAC,gBAAgB,eAAe,KAAA,GAAW,OAAO;CACtD,MAAM,WAAW,cAAc,cAAc,UAAU;CACvD,IAAI,UAAU,OAAO;CACrB,KAAK,MAAM,SAAS,gBAAgB,cAAc,IAAI,GAAG;EACvD,MAAM,SAAS,cAAc,cAAc,MAAM,EAAE;EACnD,IAAI,QAAQ,OAAO;CACrB;CACA,OAAO;AACT;AAEA,SAAgB,oBAAoB,OAA2C;CAC7E,MAAM,eAAe,MAAM,aAAa,IAAI;CAC5C,MAAM,QAAQ,kBAAkB,cAAc,MAAM,sBAAsB,IAAI,GAAG,OAAO;CACxF,MAAM,QAAQ,kBAAkB,cAAc,MAAM,sBAAsB,IAAI,GAAG,OAAO;CACxF,IAAI,SAAS,OAAO;EAClB,MAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,MAAM,KAAK;EAC/C,MAAM,MAAM,KAAK,IAAI,MAAM,KAAK,MAAM,GAAG;EAIzC,OAAO,QAAQ,MAAM;GAAE;GAAO;EAAI,IAAI;CACxC;CACA,OAAO,SAAS;AAClB;;;;;;;;;;AA4BA,SAAgB,YAAY,EAC1B,OAEA,UAIkB;CAClB,MAAM,SAAS,oBAAoB,KAAK;CACxC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,UAAU,QAAQ,qBAAqB,MAAM,aAAa,IAAI,GAAG,YAAY,KAAK,CAAC,KAAK;CAC9F,OAAO;EAAE,GAAG;EAAQ,eAAe,KAAK,IAAI,OAAO,OAAO,OAAO,MAAM,OAAO;CAAE;AAClF"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { peek, update } from "../../core/signals/primitives.js";
|
|
2
|
+
import { effect } from "../../core/signals/effect.js";
|
|
3
|
+
import { resolveVttSegmentMetadata } from "../../media/text/resolve-vtt-metadata.js";
|
|
4
|
+
import { findTrackById, getTracksByType } from "../../media/utils/tracks.js";
|
|
5
|
+
import { dispatchCuesStep, textStepWiring } from "./text-segment-load-pipeline.js";
|
|
6
|
+
import { dispatchStep, fetchStep } from "./segment-load-pipeline.js";
|
|
7
|
+
import { findMediaTrack, readBaseMediaDecodeTime } from "../../media/mp4/timestamp-origin.js";
|
|
8
|
+
import { peekHead } from "./head-peek.js";
|
|
9
|
+
//#region src/playback/primitives/relocation-pipelines.ts
|
|
10
|
+
/** Assert the relocation state view from the opaque step deps — this module knows the slots the composition provides. */
|
|
11
|
+
function relocationState(deps) {
|
|
12
|
+
return deps.state;
|
|
13
|
+
}
|
|
14
|
+
function containerSlot(deps) {
|
|
15
|
+
return relocationState(deps).mediaContainerData;
|
|
16
|
+
}
|
|
17
|
+
/** Synchronous RMW of the per-type entry — disjoint keys across producers, so no lost update. */
|
|
18
|
+
function writeContainer(slot, trackType, patch) {
|
|
19
|
+
update(slot, (current) => ({
|
|
20
|
+
...current,
|
|
21
|
+
[trackType]: {
|
|
22
|
+
...current?.[trackType],
|
|
23
|
+
...patch
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve once `read()` returns a number. Shared by the A/V stamp (waits for the
|
|
29
|
+
* `derive`d origin — immediate for per-type, the shared-`min` barrier for coordinated)
|
|
30
|
+
* and the text step (waits for the primary A/V origin). No bound: for fMP4 the origin
|
|
31
|
+
* always establishes.
|
|
32
|
+
*/
|
|
33
|
+
function awaitDefined(read) {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let stop;
|
|
36
|
+
stop = effect(() => {
|
|
37
|
+
const value = read();
|
|
38
|
+
if (value !== void 0) {
|
|
39
|
+
stop?.();
|
|
40
|
+
resolve(value);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Relocation pipelines for one track type — a plain config `messagePipelines`.
|
|
47
|
+
* Keyed by **track type** (`'video'` / `'audio'`), so ABR rungs of a type share the
|
|
48
|
+
* origin (discover skips once the type's value is present). The steps read/write
|
|
49
|
+
* `state.mediaContainerData[trackType]` via their call-time `deps`; the stamp applies
|
|
50
|
+
* the same `derive` seam the reactor uses (pass the composition's resolved
|
|
51
|
+
* `deriveStartMediaTime` so the buffer offset and the model's `startMediaTime` agree).
|
|
52
|
+
*/
|
|
53
|
+
function relocationPipelinesFor(trackType, derive) {
|
|
54
|
+
const handlerType = trackType === "video" ? "vide" : "soun";
|
|
55
|
+
/**
|
|
56
|
+
* Init step: head-peek the buffered media track's `track_id` + `mdhd` timescale into
|
|
57
|
+
* `mediaContainerData[trackType]`. Matching by handler (`vide`/`soun`) skips a muxed
|
|
58
|
+
* `clcp` caption track, and the `track_id` lets `readSegmentOrigin` read *this*
|
|
59
|
+
* track's `tfdt` rather than the first `traf` in the segment.
|
|
60
|
+
*/
|
|
61
|
+
const readInitTrackInfo = async (frame, _signal, deps) => {
|
|
62
|
+
const { op } = frame;
|
|
63
|
+
if (op.type !== "append-init" || !frame.data) return;
|
|
64
|
+
const slot = containerSlot(deps);
|
|
65
|
+
if (peek(slot)?.[trackType]?.timescale !== void 0) return;
|
|
66
|
+
frame.data = await peekHead(frame.data, (bytes) => {
|
|
67
|
+
const track = findMediaTrack(bytes, handlerType);
|
|
68
|
+
if (track === void 0) return false;
|
|
69
|
+
writeContainer(slot, trackType, {
|
|
70
|
+
trackId: track.trackId,
|
|
71
|
+
timescale: track.timescale
|
|
72
|
+
});
|
|
73
|
+
return true;
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Media-segment step: head-peek the `tfdt` baseMediaDecodeTime of the media track's
|
|
78
|
+
* `traf` (matched by the `track_id` discovered from the init), recording the
|
|
79
|
+
* segment's 0-based `startTime` with it — the origin is `bmdt/ts − segmentStartTime`,
|
|
80
|
+
* so the first *loaded* segment need not be the 0th. Without a discovered `track_id`
|
|
81
|
+
* (non-fMP4 / mock init) there's no media track to relocate, so the step no-ops and
|
|
82
|
+
* the append stays native.
|
|
83
|
+
*/
|
|
84
|
+
const readSegmentOrigin = async (frame, _signal, deps) => {
|
|
85
|
+
const { op } = frame;
|
|
86
|
+
if (op.type !== "append-segment" || !frame.data) return;
|
|
87
|
+
const slot = containerSlot(deps);
|
|
88
|
+
const container = peek(slot)?.[trackType];
|
|
89
|
+
if (container?.baseMediaDecodeTime !== void 0) return;
|
|
90
|
+
const { trackId } = container ?? {};
|
|
91
|
+
if (trackId === void 0) return;
|
|
92
|
+
const segmentStartTime = op.meta.startTime;
|
|
93
|
+
frame.data = await peekHead(frame.data, (bytes) => {
|
|
94
|
+
const baseMediaDecodeTime = readBaseMediaDecodeTime(bytes, trackId);
|
|
95
|
+
if (baseMediaDecodeTime === void 0) return false;
|
|
96
|
+
writeContainer(slot, trackType, {
|
|
97
|
+
baseMediaDecodeTime,
|
|
98
|
+
segmentStartTime
|
|
99
|
+
});
|
|
100
|
+
return true;
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Stamp step — tier-agnostic apply. Relocate by the `derive`d `startMediaTime` for
|
|
105
|
+
* this type (`offset = −startMediaTime`). Applies the **same** `derive` the reactor
|
|
106
|
+
* uses, over the shared `mediaContainerData` slot — so the buffer offset matches the
|
|
107
|
+
* model's stamped `startMediaTime`, and it's robust to `established` + late tracks
|
|
108
|
+
* (the slot persists; the model value may not be re-stamped after the reactor goes
|
|
109
|
+
* sticky). Awaited: per-type resolves at once (own origin discovered earlier in this
|
|
110
|
+
* pipeline); shared-`min` waits until every selected A/V origin is in — the barrier,
|
|
111
|
+
* filled by the other type's discover step. A derived `0` (0-PTS / below threshold)
|
|
112
|
+
* leaves the append native — setting `timestampOffset` at all can ripple.
|
|
113
|
+
*/
|
|
114
|
+
const stampStartMediaTime = async (frame, signal, deps) => {
|
|
115
|
+
if (frame.op.type !== "append-segment") return;
|
|
116
|
+
const state = relocationState(deps);
|
|
117
|
+
const own = peek(state.mediaContainerData)?.[trackType];
|
|
118
|
+
if (own?.timescale === void 0 || own.baseMediaDecodeTime === void 0 || own.segmentStartTime === void 0) return;
|
|
119
|
+
const startMediaTime = await awaitDefined(() => {
|
|
120
|
+
const containerData = state.mediaContainerData.get();
|
|
121
|
+
if (!containerData) return void 0;
|
|
122
|
+
return derive(containerData, {
|
|
123
|
+
selectedVideoTrackId: state.selectedVideoTrackId?.get(),
|
|
124
|
+
selectedAudioTrackId: state.selectedAudioTrackId?.get()
|
|
125
|
+
})[trackType];
|
|
126
|
+
});
|
|
127
|
+
if (signal.aborted || startMediaTime === 0) return;
|
|
128
|
+
frame.meta = {
|
|
129
|
+
...frame.meta ?? frame.op.meta,
|
|
130
|
+
timestampOffset: -startMediaTime
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
return () => ({
|
|
134
|
+
remove: [dispatchStep],
|
|
135
|
+
"append-init": [
|
|
136
|
+
fetchStep,
|
|
137
|
+
readInitTrackInfo,
|
|
138
|
+
dispatchStep
|
|
139
|
+
],
|
|
140
|
+
"append-segment": [
|
|
141
|
+
fetchStep,
|
|
142
|
+
readSegmentOrigin,
|
|
143
|
+
stampStartMediaTime,
|
|
144
|
+
dispatchStep
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Resolve step for the relocation text pipeline. Reuses the injected host resolver
|
|
150
|
+
* (the loader's folded `resolveSegment`, via `textStepWiring`) for cues and fetches
|
|
151
|
+
* the `X-TIMESTAMP-MAP` header in parallel, stashing it on `frame.metadata` for
|
|
152
|
+
* `relocateCuesStep`. Replaces the
|
|
153
|
+
* base `resolveCuesStep` (which fetches cues only) — text's native `<track>` parser
|
|
154
|
+
* discards the header, so the map needs its own raw-bytes fetch.
|
|
155
|
+
*/
|
|
156
|
+
const resolveWithMetadataStep = async (frame, signal, deps) => {
|
|
157
|
+
const [cues, metadata] = await Promise.all([textStepWiring(deps).resolveSegment(frame.op.segment.url), resolveVttSegmentMetadata(frame.op.segment.url)]);
|
|
158
|
+
if (signal.aborted) return;
|
|
159
|
+
frame.cues = cues;
|
|
160
|
+
frame.metadata = metadata;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Relocate step — shifts each cue onto the 0-based presentation timeline:
|
|
164
|
+
* `cueFinal = cueNative − startMediaTime`, where `startMediaTime` is the primary
|
|
165
|
+
* A/V track's origin (selected **video**, else **audio** — the single-anchor rule,
|
|
166
|
+
* and defensive like the reactor's optional selection) and `cueNative` folds in the
|
|
167
|
+
* `X-TIMESTAMP-MAP` correction (`mpegts/90000 − local`) for map-bearing VTT (Apple)
|
|
168
|
+
* or is the absolute cue time (no map, e.g. Mux). Text can resolve before A/V
|
|
169
|
+
* establishes, so the origin is awaited; fMP4 always establishes it (0-PTS → 0),
|
|
170
|
+
* and a text-only source (no A/V selected) simply gets offset 0.
|
|
171
|
+
*/
|
|
172
|
+
const relocateCuesStep = async (frame, signal, deps) => {
|
|
173
|
+
if (!frame.cues?.length) return;
|
|
174
|
+
const state = deps.state;
|
|
175
|
+
const startMediaTime = await awaitDefined(() => {
|
|
176
|
+
const presentation = state.presentation.get();
|
|
177
|
+
if (!presentation) return void 0;
|
|
178
|
+
const primaryId = state.selectedVideoTrackId.get() ?? state.selectedAudioTrackId.get();
|
|
179
|
+
if (primaryId !== void 0) return findTrackById(presentation, primaryId)?.startMediaTime;
|
|
180
|
+
return getTracksByType(presentation, "video").length > 0 || getTracksByType(presentation, "audio").length > 0 ? void 0 : 0;
|
|
181
|
+
});
|
|
182
|
+
if (signal.aborted) return;
|
|
183
|
+
const { timestampMap } = frame.metadata ?? {};
|
|
184
|
+
const delta = (timestampMap ? timestampMap.mpegts / 9e4 - timestampMap.local : 0) - startMediaTime;
|
|
185
|
+
if (delta !== 0) for (const cue of frame.cues) {
|
|
186
|
+
cue.startTime += delta;
|
|
187
|
+
cue.endTime += delta;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Relocation text pipeline — the text analog of `relocationPipelinesFor(type)`.
|
|
192
|
+
* `resolveWithMetadata` (cues + `X-TIMESTAMP-MAP`) → `relocateCues` (shift by the
|
|
193
|
+
* primary A/V origin) → `dispatchCues`.
|
|
194
|
+
*/
|
|
195
|
+
const relocatingTextPipelines = () => [
|
|
196
|
+
resolveWithMetadataStep,
|
|
197
|
+
relocateCuesStep,
|
|
198
|
+
dispatchCuesStep
|
|
199
|
+
];
|
|
200
|
+
//#endregion
|
|
201
|
+
export { relocatingTextPipelines, relocationPipelinesFor };
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=relocation-pipelines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relocation-pipelines.js","names":[],"sources":["../../../../src/playback/primitives/relocation-pipelines.ts"],"sourcesContent":["/**\n * Non-zero-PTS relocation pipelines — the config-supplied, loader-facing half of the\n * `establishStartMediaTime` behavior (`../behaviors/establish-start-media-time`). The\n * reactor there owns the lifecycle and the `derive` coordination seam; this file supplies\n * the `messagePipelines` the segment/text loaders run to *fill and act on* that behavior's\n * state. It's the relocation analog of `track-switching`'s config-supplied constraint/rule\n * chain — a pluggable strategy handed to the machinery via config, not applied inline —\n * supplied to the loaders rather than applied by the behavior, so the two coordinate\n * through the shared `mediaContainerData` / `startMediaTime` slots alone, never by import.\n *\n * DOM-free: it composes the loader vocabularies (`segment-load-pipeline`,\n * `text-segment-load-pipeline`) through their structural sink seams and shifts cues via\n * the structural `Cue` type, so it names no `SourceBuffer`, `TextTracksActor`, or\n * `VTTCue`. The A/V pipeline is a plain `messagePipelines` array:\n * - `discover` — init `track_id` + `mdhd` timescale for the buffered media track, then\n * that same track's `tfdt` baseMediaDecodeTime, matched by `track_id` so a muxed\n * segment reads the media track's origin, not the first `traf` — writes\n * `state.mediaContainerData`.\n * - `stamp` — reads that track's derived origin back and relocates via\n * `timestampOffset = −startMediaTime`.\n * Steps read composition `state` from their call-time `deps` (no closures, no context).\n *\n * The text half (`relocatingTextPipelines`) is the same idea for the text-segment loader:\n * a `resolveWithMetadata → relocateCues → dispatchCues` pipeline that shifts cues onto the\n * same 0-based timeline, reading the primary A/V track's `startMediaTime` (the reactor's\n * consumed value) via `deps`.\n */\nimport type { StateSignals } from '../../core/composition/create-composition';\nimport { effect } from '../../core/signals/effect';\nimport { peek, type Signal, update } from '../../core/signals/primitives';\nimport { findMediaTrack, type MediaHandlerType, readBaseMediaDecodeTime } from '../../media/mp4/timestamp-origin';\nimport { resolveVttSegmentMetadata, type TextSegmentMetadata } from '../../media/text/resolve-vtt-metadata';\nimport type { Cue, MaybeResolvedPresentation, MediaContainerData } from '../../media/types';\nimport { findTrackById, getTracksByType } from '../../media/utils/tracks';\nimport type { DeriveStartMediaTime } from './derive-start-media-time';\nimport { peekHead } from './head-peek';\nimport { dispatchStep, fetchStep, type LoadStep, type MessagePipelines, type StepDeps } from './segment-load-pipeline';\nimport {\n dispatchCuesStep,\n type TextFrame,\n type TextLoadStep,\n type TextStepDeps,\n textStepWiring,\n} from './text-segment-load-pipeline';\n\n/** The composition slots these steps read — the view asserted from the opaque `deps.state`. */\ninterface RelocationSlots {\n presentation?: MaybeResolvedPresentation;\n mediaContainerData?: Record<string, MediaContainerData>;\n selectedVideoTrackId?: string;\n selectedAudioTrackId?: string;\n}\n\ntype ContainerSlot = Signal<Record<string, MediaContainerData> | undefined>;\n\n/** Assert the relocation state view from the opaque step deps — this module knows the slots the composition provides. */\nfunction relocationState(deps: StepDeps): StateSignals<RelocationSlots> {\n return deps.state as unknown as StateSignals<RelocationSlots>;\n}\n\nfunction containerSlot(deps: StepDeps): ContainerSlot {\n return relocationState(deps).mediaContainerData;\n}\n\n/** Synchronous RMW of the per-type entry — disjoint keys across producers, so no lost update. */\nfunction writeContainer(slot: ContainerSlot, trackType: string, patch: Partial<MediaContainerData>): void {\n update(slot, (current) => ({ ...current, [trackType]: { ...current?.[trackType], ...patch } }));\n}\n\n/**\n * Resolve once `read()` returns a number. Shared by the A/V stamp (waits for the\n * `derive`d origin — immediate for per-type, the shared-`min` barrier for coordinated)\n * and the text step (waits for the primary A/V origin). No bound: for fMP4 the origin\n * always establishes.\n */\nfunction awaitDefined(read: () => number | undefined): Promise<number> {\n return new Promise((resolve) => {\n let stop: (() => void) | undefined;\n stop = effect(() => {\n const value = read();\n if (value !== undefined) {\n stop?.();\n resolve(value);\n }\n });\n });\n}\n\n/**\n * Relocation pipelines for one track type — a plain config `messagePipelines`.\n * Keyed by **track type** (`'video'` / `'audio'`), so ABR rungs of a type share the\n * origin (discover skips once the type's value is present). The steps read/write\n * `state.mediaContainerData[trackType]` via their call-time `deps`; the stamp applies\n * the same `derive` seam the reactor uses (pass the composition's resolved\n * `deriveStartMediaTime` so the buffer offset and the model's `startMediaTime` agree).\n */\nexport function relocationPipelinesFor(trackType: 'video' | 'audio', derive: DeriveStartMediaTime): MessagePipelines {\n const handlerType: MediaHandlerType = trackType === 'video' ? 'vide' : 'soun';\n\n /**\n * Init step: head-peek the buffered media track's `track_id` + `mdhd` timescale into\n * `mediaContainerData[trackType]`. Matching by handler (`vide`/`soun`) skips a muxed\n * `clcp` caption track, and the `track_id` lets `readSegmentOrigin` read *this*\n * track's `tfdt` rather than the first `traf` in the segment.\n */\n const readInitTrackInfo: LoadStep = async (frame, _signal, deps) => {\n const { op } = frame;\n if (op.type !== 'append-init' || !frame.data) return;\n const slot = containerSlot(deps);\n if (peek(slot)?.[trackType]?.timescale !== undefined) return; // already have it (any rung of this type)\n frame.data = await peekHead(frame.data, (bytes) => {\n const track = findMediaTrack(bytes, handlerType);\n if (track === undefined) return false;\n writeContainer(slot, trackType, { trackId: track.trackId, timescale: track.timescale });\n return true;\n });\n };\n\n /**\n * Media-segment step: head-peek the `tfdt` baseMediaDecodeTime of the media track's\n * `traf` (matched by the `track_id` discovered from the init), recording the\n * segment's 0-based `startTime` with it — the origin is `bmdt/ts − segmentStartTime`,\n * so the first *loaded* segment need not be the 0th. Without a discovered `track_id`\n * (non-fMP4 / mock init) there's no media track to relocate, so the step no-ops and\n * the append stays native.\n */\n const readSegmentOrigin: LoadStep = async (frame, _signal, deps) => {\n const { op } = frame;\n if (op.type !== 'append-segment' || !frame.data) return;\n const slot = containerSlot(deps);\n const container = peek(slot)?.[trackType];\n if (container?.baseMediaDecodeTime !== undefined) return; // established\n const { trackId } = container ?? {};\n if (trackId === undefined) return; // init didn't identify a media track — nothing to match\n const segmentStartTime = op.meta.startTime;\n frame.data = await peekHead(frame.data, (bytes) => {\n const baseMediaDecodeTime = readBaseMediaDecodeTime(bytes, trackId);\n if (baseMediaDecodeTime === undefined) return false;\n writeContainer(slot, trackType, { baseMediaDecodeTime, segmentStartTime });\n return true;\n });\n };\n\n /**\n * Stamp step — tier-agnostic apply. Relocate by the `derive`d `startMediaTime` for\n * this type (`offset = −startMediaTime`). Applies the **same** `derive` the reactor\n * uses, over the shared `mediaContainerData` slot — so the buffer offset matches the\n * model's stamped `startMediaTime`, and it's robust to `established` + late tracks\n * (the slot persists; the model value may not be re-stamped after the reactor goes\n * sticky). Awaited: per-type resolves at once (own origin discovered earlier in this\n * pipeline); shared-`min` waits until every selected A/V origin is in — the barrier,\n * filled by the other type's discover step. A derived `0` (0-PTS / below threshold)\n * leaves the append native — setting `timestampOffset` at all can ripple.\n */\n const stampStartMediaTime: LoadStep = async (frame, signal, deps) => {\n if (frame.op.type !== 'append-segment') return;\n const state = relocationState(deps);\n // Liveness guard: if THIS type's own origin wasn't discovered — `readSegmentOrigin`\n // ran earlier in this pipeline and found no `tfdt` (mock / TS / containerless) — the\n // source isn't relocatable, so leave the append native and DON'T wait. Only a\n // discoverable type awaits the derived origin (which for shared-`min` legitimately\n // blocks on the other selected type — the barrier).\n const own = peek(state.mediaContainerData)?.[trackType];\n if (own?.timescale === undefined || own.baseMediaDecodeTime === undefined || own.segmentStartTime === undefined) {\n return;\n }\n const startMediaTime = await awaitDefined(() => {\n const containerData = state.mediaContainerData.get();\n if (!containerData) return undefined;\n return derive(containerData, {\n selectedVideoTrackId: state.selectedVideoTrackId?.get(),\n selectedAudioTrackId: state.selectedAudioTrackId?.get(),\n })[trackType];\n });\n if (signal.aborted || startMediaTime === 0) return;\n frame.meta = { ...(frame.meta ?? frame.op.meta), timestampOffset: -startMediaTime };\n };\n\n return () => ({\n remove: [dispatchStep],\n 'append-init': [fetchStep, readInitTrackInfo, dispatchStep],\n 'append-segment': [fetchStep, readSegmentOrigin, stampStartMediaTime, dispatchStep],\n });\n}\n\n// ============================================================================\n// TEXT (cue relocation)\n// ============================================================================\n\n/**\n * Resolve step for the relocation text pipeline. Reuses the injected host resolver\n * (the loader's folded `resolveSegment`, via `textStepWiring`) for cues and fetches\n * the `X-TIMESTAMP-MAP` header in parallel, stashing it on `frame.metadata` for\n * `relocateCuesStep`. Replaces the\n * base `resolveCuesStep` (which fetches cues only) — text's native `<track>` parser\n * discards the header, so the map needs its own raw-bytes fetch.\n */\nconst resolveWithMetadataStep = async <C extends Cue>(\n frame: TextFrame<C>,\n signal: AbortSignal,\n deps: TextStepDeps\n): Promise<void> => {\n const [cues, metadata] = await Promise.all([\n textStepWiring<C>(deps).resolveSegment(frame.op.segment.url),\n resolveVttSegmentMetadata(frame.op.segment.url),\n ]);\n if (signal.aborted) return;\n frame.cues = cues;\n frame.metadata = metadata;\n};\n\n/**\n * Relocate step — shifts each cue onto the 0-based presentation timeline:\n * `cueFinal = cueNative − startMediaTime`, where `startMediaTime` is the primary\n * A/V track's origin (selected **video**, else **audio** — the single-anchor rule,\n * and defensive like the reactor's optional selection) and `cueNative` folds in the\n * `X-TIMESTAMP-MAP` correction (`mpegts/90000 − local`) for map-bearing VTT (Apple)\n * or is the absolute cue time (no map, e.g. Mux). Text can resolve before A/V\n * establishes, so the origin is awaited; fMP4 always establishes it (0-PTS → 0),\n * and a text-only source (no A/V selected) simply gets offset 0.\n */\nconst relocateCuesStep = async <C extends Cue>(\n frame: TextFrame<C>,\n signal: AbortSignal,\n deps: TextStepDeps\n): Promise<void> => {\n if (!frame.cues?.length) return;\n const state = deps.state as unknown as StateSignals<RelocationSlots>;\n const startMediaTime = await awaitDefined(() => {\n const presentation = state.presentation.get();\n if (!presentation) return undefined;\n const primaryId = state.selectedVideoTrackId.get() ?? state.selectedAudioTrackId.get();\n if (primaryId !== undefined) {\n // A/V selected: use its origin once stamped (undefined until then → keep waiting).\n return findTrackById(presentation, primaryId)?.startMediaTime;\n }\n // No A/V selected. Distinguish \"not selected YET\" from \"text-only source\". If the\n // presentation has A/V tracks, one WILL be selected and stamped — wait for it, or the\n // cues get shifted by the full `mapCorrection` (e.g. +10s on Apple X-TIMESTAMP-MAP\n // sources) when text relocation wins the race against A/V selection. Only a genuinely\n // text-only source (no A/V origin ever coming) legitimately relocates by offset 0.\n const hasAv =\n getTracksByType(presentation, 'video').length > 0 || getTracksByType(presentation, 'audio').length > 0;\n return hasAv ? undefined : 0;\n });\n if (signal.aborted) return;\n const { timestampMap } = (frame.metadata as TextSegmentMetadata | undefined) ?? {};\n const mapCorrection = timestampMap ? timestampMap.mpegts / 90000 - timestampMap.local : 0;\n const delta = mapCorrection - startMediaTime;\n if (delta !== 0) {\n for (const cue of frame.cues) {\n cue.startTime += delta;\n cue.endTime += delta;\n }\n }\n};\n\n/**\n * Relocation text pipeline — the text analog of `relocationPipelinesFor(type)`.\n * `resolveWithMetadata` (cues + `X-TIMESTAMP-MAP`) → `relocateCues` (shift by the\n * primary A/V origin) → `dispatchCues`.\n */\nexport const relocatingTextPipelines = <C extends Cue>(): TextLoadStep<C>[] => [\n resolveWithMetadataStep,\n relocateCuesStep,\n dispatchCuesStep,\n];\n"],"mappings":";;;;;;;;;;AAwDA,SAAS,gBAAgB,MAA+C;CACtE,OAAO,KAAK;AACd;AAEA,SAAS,cAAc,MAA+B;CACpD,OAAO,gBAAgB,IAAI,CAAC,CAAC;AAC/B;;AAGA,SAAS,eAAe,MAAqB,WAAmB,OAA0C;CACxG,OAAO,OAAO,aAAa;EAAE,GAAG;GAAU,YAAY;GAAE,GAAG,UAAU;GAAY,GAAG;EAAM;CAAE,EAAE;AAChG;;;;;;;AAQA,SAAS,aAAa,MAAiD;CACrE,OAAO,IAAI,SAAS,YAAY;EAC9B,IAAI;EACJ,OAAO,aAAa;GAClB,MAAM,QAAQ,KAAK;GACnB,IAAI,UAAU,KAAA,GAAW;IACvB,OAAO;IACP,QAAQ,KAAK;GACf;EACF,CAAC;CACH,CAAC;AACH;;;;;;;;;AAUA,SAAgB,uBAAuB,WAA8B,QAAgD;CACnH,MAAM,cAAgC,cAAc,UAAU,SAAS;;;;;;;CAQvE,MAAM,oBAA8B,OAAO,OAAO,SAAS,SAAS;EAClE,MAAM,EAAE,OAAO;EACf,IAAI,GAAG,SAAS,iBAAiB,CAAC,MAAM,MAAM;EAC9C,MAAM,OAAO,cAAc,IAAI;EAC/B,IAAI,KAAK,IAAI,CAAC,GAAG,UAAU,EAAE,cAAc,KAAA,GAAW;EACtD,MAAM,OAAO,MAAM,SAAS,MAAM,OAAO,UAAU;GACjD,MAAM,QAAQ,eAAe,OAAO,WAAW;GAC/C,IAAI,UAAU,KAAA,GAAW,OAAO;GAChC,eAAe,MAAM,WAAW;IAAE,SAAS,MAAM;IAAS,WAAW,MAAM;GAAU,CAAC;GACtF,OAAO;EACT,CAAC;CACH;;;;;;;;;CAUA,MAAM,oBAA8B,OAAO,OAAO,SAAS,SAAS;EAClE,MAAM,EAAE,OAAO;EACf,IAAI,GAAG,SAAS,oBAAoB,CAAC,MAAM,MAAM;EACjD,MAAM,OAAO,cAAc,IAAI;EAC/B,MAAM,YAAY,KAAK,IAAI,CAAC,GAAG;EAC/B,IAAI,WAAW,wBAAwB,KAAA,GAAW;EAClD,MAAM,EAAE,YAAY,aAAa,CAAC;EAClC,IAAI,YAAY,KAAA,GAAW;EAC3B,MAAM,mBAAmB,GAAG,KAAK;EACjC,MAAM,OAAO,MAAM,SAAS,MAAM,OAAO,UAAU;GACjD,MAAM,sBAAsB,wBAAwB,OAAO,OAAO;GAClE,IAAI,wBAAwB,KAAA,GAAW,OAAO;GAC9C,eAAe,MAAM,WAAW;IAAE;IAAqB;GAAiB,CAAC;GACzE,OAAO;EACT,CAAC;CACH;;;;;;;;;;;;CAaA,MAAM,sBAAgC,OAAO,OAAO,QAAQ,SAAS;EACnE,IAAI,MAAM,GAAG,SAAS,kBAAkB;EACxC,MAAM,QAAQ,gBAAgB,IAAI;EAMlC,MAAM,MAAM,KAAK,MAAM,kBAAkB,CAAC,GAAG;EAC7C,IAAI,KAAK,cAAc,KAAA,KAAa,IAAI,wBAAwB,KAAA,KAAa,IAAI,qBAAqB,KAAA,GACpG;EAEF,MAAM,iBAAiB,MAAM,mBAAmB;GAC9C,MAAM,gBAAgB,MAAM,mBAAmB,IAAI;GACnD,IAAI,CAAC,eAAe,OAAO,KAAA;GAC3B,OAAO,OAAO,eAAe;IAC3B,sBAAsB,MAAM,sBAAsB,IAAI;IACtD,sBAAsB,MAAM,sBAAsB,IAAI;GACxD,CAAC,CAAC,CAAC;EACL,CAAC;EACD,IAAI,OAAO,WAAW,mBAAmB,GAAG;EAC5C,MAAM,OAAO;GAAE,GAAI,MAAM,QAAQ,MAAM,GAAG;GAAO,iBAAiB,CAAC;EAAe;CACpF;CAEA,cAAc;EACZ,QAAQ,CAAC,YAAY;EACrB,eAAe;GAAC;GAAW;GAAmB;EAAY;EAC1D,kBAAkB;GAAC;GAAW;GAAmB;GAAqB;EAAY;CACpF;AACF;;;;;;;;;AAcA,MAAM,0BAA0B,OAC9B,OACA,QACA,SACkB;CAClB,MAAM,CAAC,MAAM,YAAY,MAAM,QAAQ,IAAI,CACzC,eAAkB,IAAI,CAAC,CAAC,eAAe,MAAM,GAAG,QAAQ,GAAG,GAC3D,0BAA0B,MAAM,GAAG,QAAQ,GAAG,CAChD,CAAC;CACD,IAAI,OAAO,SAAS;CACpB,MAAM,OAAO;CACb,MAAM,WAAW;AACnB;;;;;;;;;;;AAYA,MAAM,mBAAmB,OACvB,OACA,QACA,SACkB;CAClB,IAAI,CAAC,MAAM,MAAM,QAAQ;CACzB,MAAM,QAAQ,KAAK;CACnB,MAAM,iBAAiB,MAAM,mBAAmB;EAC9C,MAAM,eAAe,MAAM,aAAa,IAAI;EAC5C,IAAI,CAAC,cAAc,OAAO,KAAA;EAC1B,MAAM,YAAY,MAAM,qBAAqB,IAAI,KAAK,MAAM,qBAAqB,IAAI;EACrF,IAAI,cAAc,KAAA,GAEhB,OAAO,cAAc,cAAc,SAAS,CAAC,EAAE;EASjD,OADE,gBAAgB,cAAc,OAAO,CAAC,CAAC,SAAS,KAAK,gBAAgB,cAAc,OAAO,CAAC,CAAC,SAAS,IACxF,KAAA,IAAY;CAC7B,CAAC;CACD,IAAI,OAAO,SAAS;CACpB,MAAM,EAAE,iBAAkB,MAAM,YAAgD,CAAC;CAEjF,MAAM,SADgB,eAAe,aAAa,SAAS,MAAQ,aAAa,QAAQ,KAC1D;CAC9B,IAAI,UAAU,GACZ,KAAK,MAAM,OAAO,MAAM,MAAM;EAC5B,IAAI,aAAa;EACjB,IAAI,WAAW;CACjB;AAEJ;;;;;;AAOA,MAAa,gCAAkE;CAC7E;CACA;CACA;AACF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { getMediaPlaylistMetadata } from "../../media/types/index.js";
|
|
2
|
+
import { SVTA_UNSUPPORTED_AUDIO_FORMAT, SVTA_UNSUPPORTED_DRM_SYSTEM, SVTA_UNSUPPORTED_VIDEO_FORMAT } from "../../media/errors.js";
|
|
3
|
+
import { NON_FMP4_CONTAINER_MIMES } from "../../media/hls/parse-media-playlist.js";
|
|
4
|
+
//#region src/playback/primitives/report-track-conditions.ts
|
|
5
|
+
/**
|
|
6
|
+
* The seam `resolve-track` uses to report conditions discovered in a freshly
|
|
7
|
+
* parsed media playlist.
|
|
8
|
+
*
|
|
9
|
+
* Injected rather than baked in so `resolve-track` stays free of format and
|
|
10
|
+
* policy knowledge: it parses and commits, and whatever the composition wants
|
|
11
|
+
* noticed about the result is this function's business. Which conditions matter,
|
|
12
|
+
* and which codes they carry, therefore vary per composition — a provider that
|
|
13
|
+
* never ships MPEG-TS can drop that check, and future playlist-derived notices
|
|
14
|
+
* (LL-HLS or DVR support that's partial rather than absent) attach here without
|
|
15
|
+
* touching the resolver.
|
|
16
|
+
*
|
|
17
|
+
* Reported **per rendition, as it resolves**, which is why these are causes and
|
|
18
|
+
* not verdicts: one rendition being unplayable doesn't make the source
|
|
19
|
+
* unplayable. The verdict is `track-switching`'s, which reports
|
|
20
|
+
* `SVTA_NO_SUPPORTED_{VIDEO,AUDIO}_TRACK` when a type's candidates actually
|
|
21
|
+
* empty. Keeping the two apart is what lets a mixed source — some renditions
|
|
22
|
+
* encrypted or MPEG-TS, others playable — log its causes and still play.
|
|
23
|
+
*/
|
|
24
|
+
/** Unsupported-format code per type; text has none — absent captions aren't a failure. */
|
|
25
|
+
const UNSUPPORTED_FORMAT_CODE = {
|
|
26
|
+
video: SVTA_UNSUPPORTED_VIDEO_FORMAT,
|
|
27
|
+
audio: SVTA_UNSUPPORTED_AUDIO_FORMAT
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The types a reported cause can legitimately describe: the ones whose candidates
|
|
31
|
+
* `canPlayTrack` actually prunes, via `track-switching`'s `excludeUnplayableTracks`
|
|
32
|
+
* pre-pass.
|
|
33
|
+
*
|
|
34
|
+
* Text is outside it by design — its switching chain runs failed-CDN constraints
|
|
35
|
+
* alone, because an MSE codec probe is the wrong question for a WebVTT rendition
|
|
36
|
+
* (see `track-switching.ts`). So nothing prunes a text rendition, no verdict can
|
|
37
|
+
* follow from one, and a cause reported against it would be an orphan: the
|
|
38
|
+
* adapter's unsupported-feature substitution scans the sequence as a whole, so a
|
|
39
|
+
* lone encrypted subtitle would otherwise recode an unrelated verdict — an
|
|
40
|
+
* all-CDN cooldown among them — as "this engine can't play the source".
|
|
41
|
+
*/
|
|
42
|
+
const CAPABILITY_PRUNED_TYPES = /* @__PURE__ */ new Set(["video", "audio"]);
|
|
43
|
+
/**
|
|
44
|
+
* The default: report what makes a rendition unplayable *to this engine* — a
|
|
45
|
+
* container MSE can't accept, or encryption with no decryption pipeline. Both
|
|
46
|
+
* mirror what `canPlayTrack` prunes on, so a reported cause always has a
|
|
47
|
+
* corresponding exclusion.
|
|
48
|
+
*
|
|
49
|
+
* A condition carries its code and its context, not copy. `data.mimeType` is
|
|
50
|
+
* what preserves the specificity — the format codes cover every non-fMP4
|
|
51
|
+
* container, so "which one" lives there for a consumer that wants to say, rather
|
|
52
|
+
* than being flattened into an English sentence here.
|
|
53
|
+
*
|
|
54
|
+
* Both carry `trackType`, redundantly for the format codes (1004/1005 are
|
|
55
|
+
* already per type) but not for 4008, which isn't per type — SVTA has one
|
|
56
|
+
* content-protection code for both. Nothing branches on the tag: it's diagnostic
|
|
57
|
+
* context, reaching a developer through the logged sequence and `error.data`,
|
|
58
|
+
* which is why it goes on every condition rather than only where the code can't
|
|
59
|
+
* carry it. `trackId` alongside it is what distinguishes two renditions of the
|
|
60
|
+
* same type.
|
|
61
|
+
*/
|
|
62
|
+
function reportUnsupportedTrackConditions(track) {
|
|
63
|
+
if (!CAPABILITY_PRUNED_TYPES.has(track.type)) return [];
|
|
64
|
+
const conditions = [];
|
|
65
|
+
const data = {
|
|
66
|
+
trackType: track.type,
|
|
67
|
+
trackId: track.id
|
|
68
|
+
};
|
|
69
|
+
const formatCode = UNSUPPORTED_FORMAT_CODE[track.type];
|
|
70
|
+
if (formatCode !== void 0 && NON_FMP4_CONTAINER_MIMES.has(track.mimeType)) conditions.push({
|
|
71
|
+
code: formatCode,
|
|
72
|
+
data: {
|
|
73
|
+
...data,
|
|
74
|
+
mimeType: track.mimeType
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
if (getMediaPlaylistMetadata(track)?.encrypted) conditions.push({
|
|
78
|
+
code: SVTA_UNSUPPORTED_DRM_SYSTEM,
|
|
79
|
+
data
|
|
80
|
+
});
|
|
81
|
+
return conditions;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { reportUnsupportedTrackConditions };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=report-track-conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-track-conditions.js","names":[],"sources":["../../../../src/playback/primitives/report-track-conditions.ts"],"sourcesContent":["/**\n * The seam `resolve-track` uses to report conditions discovered in a freshly\n * parsed media playlist.\n *\n * Injected rather than baked in so `resolve-track` stays free of format and\n * policy knowledge: it parses and commits, and whatever the composition wants\n * noticed about the result is this function's business. Which conditions matter,\n * and which codes they carry, therefore vary per composition — a provider that\n * never ships MPEG-TS can drop that check, and future playlist-derived notices\n * (LL-HLS or DVR support that's partial rather than absent) attach here without\n * touching the resolver.\n *\n * Reported **per rendition, as it resolves**, which is why these are causes and\n * not verdicts: one rendition being unplayable doesn't make the source\n * unplayable. The verdict is `track-switching`'s, which reports\n * `SVTA_NO_SUPPORTED_{VIDEO,AUDIO}_TRACK` when a type's candidates actually\n * empty. Keeping the two apart is what lets a mixed source — some renditions\n * encrypted or MPEG-TS, others playable — log its causes and still play.\n */\nimport {\n SVTA_UNSUPPORTED_AUDIO_FORMAT,\n SVTA_UNSUPPORTED_DRM_SYSTEM,\n SVTA_UNSUPPORTED_VIDEO_FORMAT,\n type SvtaError,\n} from '../../media/errors';\nimport { NON_FMP4_CONTAINER_MIMES } from '../../media/hls/parse-media-playlist';\nimport { getMediaPlaylistMetadata, type ResolvedTrack, type TrackType } from '../../media/types';\n\n/**\n * Conditions worth reporting about a just-resolved track. Return an empty array\n * (or omit the seam) to report nothing.\n */\nexport type ReportUnsupportedTrackConditions = (track: ResolvedTrack) => readonly SvtaError[];\n\n/** Unsupported-format code per type; text has none — absent captions aren't a failure. */\nconst UNSUPPORTED_FORMAT_CODE: Partial<Record<TrackType, number>> = {\n video: SVTA_UNSUPPORTED_VIDEO_FORMAT,\n audio: SVTA_UNSUPPORTED_AUDIO_FORMAT,\n};\n\n/**\n * The types a reported cause can legitimately describe: the ones whose candidates\n * `canPlayTrack` actually prunes, via `track-switching`'s `excludeUnplayableTracks`\n * pre-pass.\n *\n * Text is outside it by design — its switching chain runs failed-CDN constraints\n * alone, because an MSE codec probe is the wrong question for a WebVTT rendition\n * (see `track-switching.ts`). So nothing prunes a text rendition, no verdict can\n * follow from one, and a cause reported against it would be an orphan: the\n * adapter's unsupported-feature substitution scans the sequence as a whole, so a\n * lone encrypted subtitle would otherwise recode an unrelated verdict — an\n * all-CDN cooldown among them — as \"this engine can't play the source\".\n */\nconst CAPABILITY_PRUNED_TYPES: ReadonlySet<TrackType> = new Set<TrackType>(['video', 'audio']);\n\n/**\n * The default: report what makes a rendition unplayable *to this engine* — a\n * container MSE can't accept, or encryption with no decryption pipeline. Both\n * mirror what `canPlayTrack` prunes on, so a reported cause always has a\n * corresponding exclusion.\n *\n * A condition carries its code and its context, not copy. `data.mimeType` is\n * what preserves the specificity — the format codes cover every non-fMP4\n * container, so \"which one\" lives there for a consumer that wants to say, rather\n * than being flattened into an English sentence here.\n *\n * Both carry `trackType`, redundantly for the format codes (1004/1005 are\n * already per type) but not for 4008, which isn't per type — SVTA has one\n * content-protection code for both. Nothing branches on the tag: it's diagnostic\n * context, reaching a developer through the logged sequence and `error.data`,\n * which is why it goes on every condition rather than only where the code can't\n * carry it. `trackId` alongside it is what distinguishes two renditions of the\n * same type.\n */\nexport function reportUnsupportedTrackConditions(track: ResolvedTrack): readonly SvtaError[] {\n if (!CAPABILITY_PRUNED_TYPES.has(track.type)) return [];\n\n const conditions: SvtaError[] = [];\n const data = { trackType: track.type, trackId: track.id };\n\n const formatCode = UNSUPPORTED_FORMAT_CODE[track.type];\n if (formatCode !== undefined && NON_FMP4_CONTAINER_MIMES.has(track.mimeType)) {\n conditions.push({ code: formatCode, data: { ...data, mimeType: track.mimeType } });\n }\n if (getMediaPlaylistMetadata(track)?.encrypted) {\n conditions.push({ code: SVTA_UNSUPPORTED_DRM_SYSTEM, data });\n }\n return conditions;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,0BAA8D;CAClE,OAAO;CACP,OAAO;AACT;;;;;;;;;;;;;;AAeA,MAAM,0CAAkD,IAAI,IAAe,CAAC,SAAS,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;AAqB7F,SAAgB,iCAAiC,OAA4C;CAC3F,IAAI,CAAC,wBAAwB,IAAI,MAAM,IAAI,GAAG,OAAO,CAAC;CAEtD,MAAM,aAA0B,CAAC;CACjC,MAAM,OAAO;EAAE,WAAW,MAAM;EAAM,SAAS,MAAM;CAAG;CAExD,MAAM,aAAa,wBAAwB,MAAM;CACjD,IAAI,eAAe,KAAA,KAAa,yBAAyB,IAAI,MAAM,QAAQ,GACzE,WAAW,KAAK;EAAE,MAAM;EAAY,MAAM;GAAE,GAAG;GAAM,UAAU,MAAM;EAAS;CAAE,CAAC;CAEnF,IAAI,yBAAyB,KAAK,CAAC,EAAE,WACnC,WAAW,KAAK;EAAE,MAAM;EAA6B;CAAK,CAAC;CAE7D,OAAO;AACT"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { effect } from "../../core/signals/effect.js";
|
|
2
|
+
//#region src/playback/primitives/segment-load-pipeline.ts
|
|
3
|
+
/**
|
|
4
|
+
* Base-step view of the loader's own wiring. `createSegmentLoaderActor` folds its
|
|
5
|
+
* `sourceBufferActor` + `fetch` into the threaded `config` so base steps read them
|
|
6
|
+
* from the uniform passthrough — present whether the loader runs inside a composition
|
|
7
|
+
* or standalone. `config` is loose (`object`), so assert the shape here (one cast, like
|
|
8
|
+
* relocation's `containerSlot`).
|
|
9
|
+
*/
|
|
10
|
+
function stepWiring(deps) {
|
|
11
|
+
return deps.config;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolves when the SourceBufferActor snapshot reaches 'idle'.
|
|
15
|
+
* Rejects if the signal is aborted or the actor is destroyed.
|
|
16
|
+
*
|
|
17
|
+
* Used to sequence SourceBufferActor operations without awaiting send()
|
|
18
|
+
* directly — send() is fire-and-forget; callers observe completion via
|
|
19
|
+
* state transition.
|
|
20
|
+
*/
|
|
21
|
+
function waitForIdle(snapshot, signal) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
if (snapshot.get().value === "idle") {
|
|
24
|
+
resolve();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (snapshot.get().value === "destroyed") {
|
|
28
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (signal.aborted) {
|
|
32
|
+
reject(signal.reason);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let stop;
|
|
36
|
+
const cleanup = (fn) => {
|
|
37
|
+
stop?.();
|
|
38
|
+
signal.removeEventListener("abort", onAbort);
|
|
39
|
+
fn();
|
|
40
|
+
};
|
|
41
|
+
const onAbort = () => cleanup(() => reject(signal.reason));
|
|
42
|
+
stop = effect(() => {
|
|
43
|
+
const value = snapshot.get().value;
|
|
44
|
+
if (value === "idle") cleanup(resolve);
|
|
45
|
+
else if (value === "destroyed") cleanup(() => reject(new DOMException("Aborted", "AbortError")));
|
|
46
|
+
});
|
|
47
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Build the SourceBuffer message a completed frame dispatches. `fetchStep` always precedes `dispatchStep` in append pipelines, so `data` is set by now. */
|
|
51
|
+
function toMessage({ op, data, meta }) {
|
|
52
|
+
switch (op.type) {
|
|
53
|
+
case "remove": return op;
|
|
54
|
+
case "append-init": return {
|
|
55
|
+
type: "append-init",
|
|
56
|
+
data,
|
|
57
|
+
meta: op.meta
|
|
58
|
+
};
|
|
59
|
+
case "append-segment": return {
|
|
60
|
+
type: "append-segment",
|
|
61
|
+
data,
|
|
62
|
+
meta: meta ?? op.meta
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Fetch this op's bytes into the frame. Init segments need the full body
|
|
68
|
+
* (`minChunkSize: Infinity`) before appending; media segments stream so chunks
|
|
69
|
+
* append as they arrive. Awaiting headers eagerly also starts the HTTP
|
|
70
|
+
* connection (and records the fetch in observers like tests).
|
|
71
|
+
*/
|
|
72
|
+
const fetchStep = async (frame, signal, deps) => {
|
|
73
|
+
const { op } = frame;
|
|
74
|
+
if (op.type === "remove") return;
|
|
75
|
+
const { fetch } = stepWiring(deps);
|
|
76
|
+
frame.data = await fetch(op, op.type === "append-init" ? {
|
|
77
|
+
signal,
|
|
78
|
+
minChunkSize: Infinity
|
|
79
|
+
} : { signal });
|
|
80
|
+
};
|
|
81
|
+
/** Dispatch the frame's message to the SourceBufferActor and await its return to idle. */
|
|
82
|
+
const dispatchStep = async (frame, signal, deps) => {
|
|
83
|
+
const { sourceBufferActor } = stepWiring(deps);
|
|
84
|
+
sourceBufferActor.send(toMessage(frame));
|
|
85
|
+
await waitForIdle(sourceBufferActor.snapshot, signal);
|
|
86
|
+
};
|
|
87
|
+
/** Tier 0 default: fetch (for ops that carry bytes) then dispatch. No relocation vocabulary. */
|
|
88
|
+
const DEFAULT_MESSAGE_PIPELINES = () => ({
|
|
89
|
+
remove: [dispatchStep],
|
|
90
|
+
"append-init": [fetchStep, dispatchStep],
|
|
91
|
+
"append-segment": [fetchStep, dispatchStep]
|
|
92
|
+
});
|
|
93
|
+
//#endregion
|
|
94
|
+
export { DEFAULT_MESSAGE_PIPELINES, dispatchStep, fetchStep };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=segment-load-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment-load-pipeline.js","names":[],"sources":["../../../../src/playback/primitives/segment-load-pipeline.ts"],"sourcesContent":["/**\n * The v/a segment **load pipeline** — the step vocabulary and base steps a segment\n * loader runs, extracted from the loader actor so the \"what\" (the composable steps)\n * is separable from the \"how\" (the actor's scheduling). A pipeline is a per-op list\n * of {@link LoadStep}s the loader drains in order; the default is `fetch → dispatch`,\n * and a composition can insert its own steps between them (e.g. non-zero-PTS\n * relocation) without the loader knowing.\n *\n * The base steps reach their SourceBuffer sink through the structural {@link AppendSink}\n * seam rather than the concrete actor type — the loader folds the real actor into\n * `config` at construction, and it satisfies the seam by structure — so this module\n * carries no dependency on the actor implementation, and no dependency on the DOM.\n */\nimport type { AnySlotMap } from '../../core/composition/create-composition';\nimport { effect } from '../../core/signals/effect';\nimport type { ReadonlySignal } from '../../core/signals/primitives';\nimport type { AddressableObject } from '../../media/types';\nimport type {\n AppendInitMessage,\n AppendSegmentMessage,\n IndividualSourceBufferMessage,\n RemoveMessage,\n} from './source-buffer-messages';\n\n// ============================================================================\n// SINK SEAM\n// ============================================================================\n\n/**\n * The structural view of a SourceBuffer sink the base steps use — just the ops\n * {@link dispatchStep} needs (`send` + a `snapshot` to await idle). The concrete\n * `SourceBufferActor` satisfies it by structure, so the pipeline names no actor.\n */\nexport interface AppendSink {\n send(message: IndividualSourceBufferMessage): void;\n snapshot: ReadonlySignal<{ value: string }>;\n}\n\n// ============================================================================\n// STEP MODEL\n// ============================================================================\n\n/**\n * A LoadTask is the intent to perform one unit of SegmentLoader work.\n * Unlike SourceBufferMessage, fetch-based tasks carry a URL rather than\n * pre-fetched data — the runner fetches and appends them in sequence.\n *\n * Derived from SourceBufferMessage types by removing `data` and adding\n * a fetch URL via AddressableObject.\n *\n * @todo Rename — \"LoadTask\" risks confusion with the `Task` class used for\n * SourceBufferActor scheduling. These are closer to operation descriptors or\n * messages than tasks in that sense.\n */\nexport type LoadTask =\n | (Omit<AppendInitMessage, 'data'> & AddressableObject)\n | (Omit<AppendSegmentMessage, 'data'> & AddressableObject)\n | RemoveMessage;\n\n/**\n * A {@link LoadTask} mid-reassembly into its append message. `LoadTask` is a\n * message with `data` omitted and a URL added; the pipeline reverses that —\n * `fetchStep` produces `data`, `dispatchStep` reassembles the message. `data` is\n * the omitted payload (kept as the fetched stream — the loader never produces the\n * `ArrayBuffer` arm of `SegmentData` — widened back at dispatch). `meta` overrides\n * `op.meta` for `append-segment` (e.g. a stamped `timestampOffset`); an\n * `append-init` dispatches `op.meta` directly.\n */\nexport interface Frame {\n readonly op: LoadTask;\n data?: AsyncIterable<Uint8Array>;\n meta?: AppendSegmentMessage['meta'];\n}\n\n/**\n * One stage of a message pipeline. Mutates the {@link Frame} in place and may be\n * async; the runner checks `signal.aborted` before each step and passes the\n * actor's {@link StepDeps} on every call, so a stateless step (e.g.\n * {@link fetchStep}) is a plain value, and a step that needs composition signals\n * (relocation's discover/stamp) reads them from `deps` at call time.\n */\nexport type LoadStep = (frame: Frame, signal: AbortSignal, deps: StepDeps) => void | Promise<void>;\n\n/**\n * The uniform passthrough handed to every {@link LoadStep} on every call — the\n * composition triple, nothing more. `state`/`context` are the full composition signal\n * maps; `config` is the threaded config with the loader's own wiring folded in (see\n * {@link stepWiring} + `createSegmentLoaderActor`). All three are typed loose: the\n * loader is a conduit and never reads them; a step asserts the slots it knows are\n * present (composition steps read `state`; base steps read the folded wiring off\n * `config`).\n */\nexport interface StepDeps {\n state: AnySlotMap;\n context: AnySlotMap;\n config: object;\n}\n\n/**\n * Base-step view of the loader's own wiring. `createSegmentLoaderActor` folds its\n * `sourceBufferActor` + `fetch` into the threaded `config` so base steps read them\n * from the uniform passthrough — present whether the loader runs inside a composition\n * or standalone. `config` is loose (`object`), so assert the shape here (one cast, like\n * relocation's `containerSlot`).\n */\nfunction stepWiring(deps: StepDeps): { sourceBufferActor: AppendSink; fetch: FetchBytes } {\n return deps.config as { sourceBufferActor: AppendSink; fetch: FetchBytes };\n}\n\n/**\n * Builds the ordered step list for each message type. Called **once per actor**\n * — its role is per-actor instantiation, so stateful steps (relocation's origin\n * discoverer) get fresh state per source reset; deps arrive at step-call time,\n * not here. The default ({@link DEFAULT_MESSAGE_PIPELINES}) is `fetch → dispatch`;\n * a non-zero-PTS composition returns a map that inserts its own discover/stamp\n * steps between them (see `establishStartMediaTime`), so the loader stays oblivious\n * to relocation and the Tier 0 pipeline carries no relocation vocabulary at all.\n */\nexport type MessagePipelines = () => Record<LoadTask['type'], LoadStep[]>;\n\n// ============================================================================\n// BASE STEPS\n// ============================================================================\n\nexport type FetchBytes = (\n addressable: AddressableObject,\n options?: RequestInit & { minChunkSize?: number }\n) => Promise<AsyncIterable<Uint8Array>>;\n\n/**\n * Resolves when the SourceBufferActor snapshot reaches 'idle'.\n * Rejects if the signal is aborted or the actor is destroyed.\n *\n * Used to sequence SourceBufferActor operations without awaiting send()\n * directly — send() is fire-and-forget; callers observe completion via\n * state transition.\n */\nfunction waitForIdle(snapshot: AppendSink['snapshot'], signal: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (snapshot.get().value === 'idle') {\n resolve();\n return;\n }\n if (snapshot.get().value === 'destroyed') {\n reject(new DOMException('Aborted', 'AbortError'));\n return;\n }\n if (signal.aborted) {\n reject(signal.reason);\n return;\n }\n\n let stop: (() => void) | undefined;\n\n const cleanup = (fn: () => void) => {\n stop?.();\n signal.removeEventListener('abort', onAbort);\n fn();\n };\n\n const onAbort = () => cleanup(() => reject(signal.reason));\n\n stop = effect(() => {\n const value = snapshot.get().value;\n if (value === 'idle') cleanup(resolve);\n else if (value === 'destroyed') cleanup(() => reject(new DOMException('Aborted', 'AbortError')));\n });\n\n signal.addEventListener('abort', onAbort, { once: true });\n });\n}\n\n/** Build the SourceBuffer message a completed frame dispatches. `fetchStep` always precedes `dispatchStep` in append pipelines, so `data` is set by now. */\nfunction toMessage({ op, data, meta }: Frame): IndividualSourceBufferMessage {\n switch (op.type) {\n case 'remove':\n return op;\n case 'append-init':\n return { type: 'append-init', data: data!, meta: op.meta };\n case 'append-segment':\n return { type: 'append-segment', data: data!, meta: meta ?? op.meta };\n }\n}\n\n/**\n * Fetch this op's bytes into the frame. Init segments need the full body\n * (`minChunkSize: Infinity`) before appending; media segments stream so chunks\n * append as they arrive. Awaiting headers eagerly also starts the HTTP\n * connection (and records the fetch in observers like tests).\n */\nexport const fetchStep: LoadStep = async (frame, signal, deps) => {\n const { op } = frame;\n if (op.type === 'remove') return; // fetchStep only appears in append pipelines\n const { fetch } = stepWiring(deps);\n frame.data = await fetch(op, op.type === 'append-init' ? { signal, minChunkSize: Infinity } : { signal });\n};\n\n/** Dispatch the frame's message to the SourceBufferActor and await its return to idle. */\nexport const dispatchStep: LoadStep = async (frame, signal, deps) => {\n const { sourceBufferActor } = stepWiring(deps);\n sourceBufferActor.send(toMessage(frame));\n await waitForIdle(sourceBufferActor.snapshot, signal);\n};\n\n/** Tier 0 default: fetch (for ops that carry bytes) then dispatch. No relocation vocabulary. */\nexport const DEFAULT_MESSAGE_PIPELINES: MessagePipelines = () => ({\n remove: [dispatchStep],\n 'append-init': [fetchStep, dispatchStep],\n 'append-segment': [fetchStep, dispatchStep],\n});\n"],"mappings":";;;;;;;;;AAyGA,SAAS,WAAW,MAAsE;CACxF,OAAO,KAAK;AACd;;;;;;;;;AA8BA,SAAS,YAAY,UAAkC,QAAoC;CACzF,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI,SAAS,IAAI,CAAC,CAAC,UAAU,QAAQ;GACnC,QAAQ;GACR;EACF;EACA,IAAI,SAAS,IAAI,CAAC,CAAC,UAAU,aAAa;GACxC,OAAO,IAAI,aAAa,WAAW,YAAY,CAAC;GAChD;EACF;EACA,IAAI,OAAO,SAAS;GAClB,OAAO,OAAO,MAAM;GACpB;EACF;EAEA,IAAI;EAEJ,MAAM,WAAW,OAAmB;GAClC,OAAO;GACP,OAAO,oBAAoB,SAAS,OAAO;GAC3C,GAAG;EACL;EAEA,MAAM,gBAAgB,cAAc,OAAO,OAAO,MAAM,CAAC;EAEzD,OAAO,aAAa;GAClB,MAAM,QAAQ,SAAS,IAAI,CAAC,CAAC;GAC7B,IAAI,UAAU,QAAQ,QAAQ,OAAO;QAChC,IAAI,UAAU,aAAa,cAAc,OAAO,IAAI,aAAa,WAAW,YAAY,CAAC,CAAC;EACjG,CAAC;EAED,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CAC1D,CAAC;AACH;;AAGA,SAAS,UAAU,EAAE,IAAI,MAAM,QAA8C;CAC3E,QAAQ,GAAG,MAAX;EACE,KAAK,UACH,OAAO;EACT,KAAK,eACH,OAAO;GAAE,MAAM;GAAqB;GAAO,MAAM,GAAG;EAAK;EAC3D,KAAK,kBACH,OAAO;GAAE,MAAM;GAAwB;GAAO,MAAM,QAAQ,GAAG;EAAK;CACxE;AACF;;;;;;;AAQA,MAAa,YAAsB,OAAO,OAAO,QAAQ,SAAS;CAChE,MAAM,EAAE,OAAO;CACf,IAAI,GAAG,SAAS,UAAU;CAC1B,MAAM,EAAE,UAAU,WAAW,IAAI;CACjC,MAAM,OAAO,MAAM,MAAM,IAAI,GAAG,SAAS,gBAAgB;EAAE;EAAQ,cAAc;CAAS,IAAI,EAAE,OAAO,CAAC;AAC1G;;AAGA,MAAa,eAAyB,OAAO,OAAO,QAAQ,SAAS;CACnE,MAAM,EAAE,sBAAsB,WAAW,IAAI;CAC7C,kBAAkB,KAAK,UAAU,KAAK,CAAC;CACvC,MAAM,YAAY,kBAAkB,UAAU,MAAM;AACtD;;AAGA,MAAa,mCAAqD;CAChE,QAAQ,CAAC,YAAY;CACrB,eAAe,CAAC,WAAW,YAAY;CACvC,kBAAkB,CAAC,WAAW,YAAY;AAC5C"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//#region src/playback/primitives/selection-rules.ts
|
|
2
|
+
/**
|
|
3
|
+
* Apply rules to a candidate list in order; the pick is the first survivor.
|
|
4
|
+
* Two responsibilities the rules don't carry: a rule that returns nothing is
|
|
5
|
+
* skipped (fall-through — a preference never empties the set), and once one
|
|
6
|
+
* survivor remains the chain stops (early-bail — later rules, including the
|
|
7
|
+
* bandwidth ranker, never run, so the effect doesn't subscribe to their
|
|
8
|
+
* signals while the choice is fixed).
|
|
9
|
+
*
|
|
10
|
+
* @param rules - Rules to apply, most authoritative first
|
|
11
|
+
* @param tracks - Candidate tracks
|
|
12
|
+
* @param deps - The behavior's `{ state, context, config }`, passed through to each rule
|
|
13
|
+
* @returns The surviving candidates, pick first
|
|
14
|
+
*/
|
|
15
|
+
function applyRules(rules, tracks, deps) {
|
|
16
|
+
let current = tracks;
|
|
17
|
+
for (const rule of rules) {
|
|
18
|
+
const remaining = rule(current, deps);
|
|
19
|
+
if (remaining.length === 0) continue;
|
|
20
|
+
current = remaining;
|
|
21
|
+
if (current.length === 1) break;
|
|
22
|
+
}
|
|
23
|
+
return current;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Apply hard constraints to a candidate list — the pre-pass that runs before the
|
|
27
|
+
* rule chain. A constraint shares a rule's signature but its exclusion is
|
|
28
|
+
* *hard*: it removes the unplayable (a codec the environment can't decode, a CDN
|
|
29
|
+
* in failover cooldown) and a removed track is never attempted. Unlike
|
|
30
|
+
* `applyRules`, this never skips an empty result and never early-bails — every
|
|
31
|
+
* constraint always applies, and an empty survivor set is a real outcome
|
|
32
|
+
* ("nothing playable here"), not a fall-through. Because each constraint only
|
|
33
|
+
* removes, the order they run in can't change which tracks survive — though one
|
|
34
|
+
* that also *reports* reads the list at its own position, so placement matters.
|
|
35
|
+
*
|
|
36
|
+
* @param constraints - Constraints to apply, in order
|
|
37
|
+
* @param tracks - Candidate tracks
|
|
38
|
+
* @param deps - The behavior's `{ state, context, config }`, passed to each constraint
|
|
39
|
+
* @returns The playable survivors (possibly empty)
|
|
40
|
+
*/
|
|
41
|
+
function applyConstraints(constraints, tracks, deps) {
|
|
42
|
+
let current = tracks;
|
|
43
|
+
for (const constraint of constraints) current = constraint(current, deps);
|
|
44
|
+
return current;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Whether two candidate sets hold the same tracks, by id.
|
|
48
|
+
*
|
|
49
|
+
* The `equals` both selection behaviors give their candidate-set `computed`. A
|
|
50
|
+
* live playlist refresh swaps in a new presentation object carrying the same
|
|
51
|
+
* variants, and a constraint's own inputs can churn without changing which
|
|
52
|
+
* tracks survive; in both cases the set is unchanged and the reaction must not
|
|
53
|
+
* re-fire. Compares by id rather than array identity for exactly that.
|
|
54
|
+
*/
|
|
55
|
+
function sameCandidateSet(a, b) {
|
|
56
|
+
return a.length === b.length && a.every((track) => b.some((other) => other.id === track.id));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Capability constraint — a *hard* filter for the {@link applyConstraints}
|
|
60
|
+
* pre-pass. Removes renditions this environment can't decode, probed via the
|
|
61
|
+
* injected `canPlayTrack` (codec → `MediaSource.isTypeSupported`, plus the
|
|
62
|
+
* container and encryption assertions that probe can't make). Constraining here
|
|
63
|
+
* — before selection — means an unplayable variant is pruned upstream and never
|
|
64
|
+
* picked, instead of surviving into the pipeline to fail late at
|
|
65
|
+
* `createSourceBuffer`. That late throw stays as a defensive structural
|
|
66
|
+
* guarantee; with this constraint it should rarely fire.
|
|
67
|
+
*
|
|
68
|
+
* Lives here rather than beside `switchVideoTrack` for the reason this module
|
|
69
|
+
* exists: both the re-evaluating variant and the pinned `selectVideoTrack` apply
|
|
70
|
+
* it, and reaching it through `behaviors/track-switching.ts` would drag the ABR
|
|
71
|
+
* path into a composition that deliberately omits it.
|
|
72
|
+
*
|
|
73
|
+
* Passes everything through when there's no probe (a composition that didn't
|
|
74
|
+
* wire one, or DOM-free tests). When it prunes *every* track, the empty result is
|
|
75
|
+
* preserved (per `applyConstraints`) — "nothing playable" — which each consuming
|
|
76
|
+
* behavior answers by clearing its selection; reporting the verdict is separate.
|
|
77
|
+
*/
|
|
78
|
+
function excludeUnplayableTracks(tracks, { config }) {
|
|
79
|
+
const canPlay = config?.canPlayTrack;
|
|
80
|
+
if (!canPlay) return tracks;
|
|
81
|
+
return tracks.filter((track) => canPlay(track));
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { applyConstraints, applyRules, excludeUnplayableTracks, sameCandidateSet };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=selection-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-rules.js","names":[],"sources":["../../../../src/playback/primitives/selection-rules.ts"],"sourcesContent":["/**\n * The selection-rule substrate: the shape of a rule, and the two composers that\n * turn a list of them into a pick.\n *\n * Lives here rather than beside `switchVideoTrack` so both track-selection\n * behaviors can share rules. The simple `selectVideoTrack` variant exists\n * specifically to tree-shake the ABR path out, so importing a composer from\n * `behaviors/track-switching.ts` would drag the bandwidth estimator and quality\n * selection back in with it. These four have no dependencies at all — pure\n * generics over a candidate list — so either side can reach them freely.\n *\n * See `internal/design/spf/track-switching-model.md` for the model these\n * implement: a hard constraints pre-pass, then an ordered chain of soft\n * narrowing rules and rankers, with the pick as the first survivor.\n */\n\nimport type { CanPlayTrack } from '../../media/types';\n\n/**\n * Deps handed to each rule and to `applyRules`, mirroring a behavior's setup\n * deps so a rule reads from the same surfaces a behavior does. `context` is\n * optional — it's threaded through but absent on direct setup calls (and\n * unread by today's rules), so the whole deps object can pass straight through.\n */\nexport interface SelectionRuleDeps<State = unknown, Context = unknown, Config = unknown> {\n state: State;\n context?: Context;\n config: Config;\n}\n\n/**\n * A selection rule narrows or reorders the candidate list. It reads the state,\n * context, and config it needs at apply time (tightly-coupled reads), so a\n * rule's `.get()`s subscribe the running effect to exactly what it consulted.\n * Returning an empty list means \"no match\" — the composer skips it, so a soft\n * filter never narrows the set to nothing. A ranker returns the list with its\n * pick at the head.\n */\nexport type SelectionRule<T, State = unknown, Context = unknown, Config = unknown> = (\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n) => readonly T[];\n\n/**\n * Apply rules to a candidate list in order; the pick is the first survivor.\n * Two responsibilities the rules don't carry: a rule that returns nothing is\n * skipped (fall-through — a preference never empties the set), and once one\n * survivor remains the chain stops (early-bail — later rules, including the\n * bandwidth ranker, never run, so the effect doesn't subscribe to their\n * signals while the choice is fixed).\n *\n * @param rules - Rules to apply, most authoritative first\n * @param tracks - Candidate tracks\n * @param deps - The behavior's `{ state, context, config }`, passed through to each rule\n * @returns The surviving candidates, pick first\n */\nexport function applyRules<T, State, Context, Config>(\n rules: readonly SelectionRule<T, State, Context, Config>[],\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n let current = tracks;\n for (const rule of rules) {\n const remaining = rule(current, deps);\n if (remaining.length === 0) continue;\n current = remaining;\n if (current.length === 1) break;\n }\n return current;\n}\n\n/**\n * Apply hard constraints to a candidate list — the pre-pass that runs before the\n * rule chain. A constraint shares a rule's signature but its exclusion is\n * *hard*: it removes the unplayable (a codec the environment can't decode, a CDN\n * in failover cooldown) and a removed track is never attempted. Unlike\n * `applyRules`, this never skips an empty result and never early-bails — every\n * constraint always applies, and an empty survivor set is a real outcome\n * (\"nothing playable here\"), not a fall-through. Because each constraint only\n * removes, the order they run in can't change which tracks survive — though one\n * that also *reports* reads the list at its own position, so placement matters.\n *\n * @param constraints - Constraints to apply, in order\n * @param tracks - Candidate tracks\n * @param deps - The behavior's `{ state, context, config }`, passed to each constraint\n * @returns The playable survivors (possibly empty)\n */\nexport function applyConstraints<T, State, Context, Config>(\n constraints: readonly SelectionRule<T, State, Context, Config>[],\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n let current = tracks;\n for (const constraint of constraints) current = constraint(current, deps);\n return current;\n}\n\n/**\n * Whether two candidate sets hold the same tracks, by id.\n *\n * The `equals` both selection behaviors give their candidate-set `computed`. A\n * live playlist refresh swaps in a new presentation object carrying the same\n * variants, and a constraint's own inputs can churn without changing which\n * tracks survive; in both cases the set is unchanged and the reaction must not\n * re-fire. Compares by id rather than array identity for exactly that.\n */\nexport function sameCandidateSet<T extends { id: string }>(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((track) => b.some((other) => other.id === track.id));\n}\n\n/**\n * What {@link excludeUnplayableTracks} reads off the config it is handed.\n *\n * Read through a cast rather than constraining the rule's `Config` generic, the\n * same way `screenResolutionCap` reads `screenResolution` off its state: a rule\n * composes into chains whose config types have nothing else in common, and\n * constraining the generic would make every one of those a weak-type mismatch.\n * Each engine defaults `canPlayTrack` to the DOM-bound probe; unwired means \"no\n * capability filtering\" and the constraint passes everything through.\n */\nexport interface CapabilityConstraintConfig {\n canPlayTrack?: CanPlayTrack;\n}\n\n/**\n * Capability constraint — a *hard* filter for the {@link applyConstraints}\n * pre-pass. Removes renditions this environment can't decode, probed via the\n * injected `canPlayTrack` (codec → `MediaSource.isTypeSupported`, plus the\n * container and encryption assertions that probe can't make). Constraining here\n * — before selection — means an unplayable variant is pruned upstream and never\n * picked, instead of surviving into the pipeline to fail late at\n * `createSourceBuffer`. That late throw stays as a defensive structural\n * guarantee; with this constraint it should rarely fire.\n *\n * Lives here rather than beside `switchVideoTrack` for the reason this module\n * exists: both the re-evaluating variant and the pinned `selectVideoTrack` apply\n * it, and reaching it through `behaviors/track-switching.ts` would drag the ABR\n * path into a composition that deliberately omits it.\n *\n * Passes everything through when there's no probe (a composition that didn't\n * wire one, or DOM-free tests). When it prunes *every* track, the empty result is\n * preserved (per `applyConstraints`) — \"nothing playable\" — which each consuming\n * behavior answers by clearing its selection; reporting the verdict is separate.\n */\nexport function excludeUnplayableTracks<T, State, Context, Config>(\n tracks: readonly T[],\n { config }: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n const canPlay = (config as CapabilityConstraintConfig | undefined)?.canPlayTrack;\n if (!canPlay) return tracks;\n return tracks.filter((track) => canPlay(track as Parameters<CanPlayTrack>[0]));\n}\n"],"mappings":";;;;;;;;;;;;;;AAwDA,SAAgB,WACd,OACA,QACA,MACc;CACd,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,YAAY,KAAK,SAAS,IAAI;EACpC,IAAI,UAAU,WAAW,GAAG;EAC5B,UAAU;EACV,IAAI,QAAQ,WAAW,GAAG;CAC5B;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;AAkBA,SAAgB,iBACd,aACA,QACA,MACc;CACd,IAAI,UAAU;CACd,KAAK,MAAM,cAAc,aAAa,UAAU,WAAW,SAAS,IAAI;CACxE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,iBAA2C,GAAiB,GAA0B;CACpG,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,UAAU,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM,EAAE,CAAC;AAC7F;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,wBACd,QACA,EAAE,UACY;CACd,MAAM,UAAW,QAAmD;CACpE,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,OAAO,QAAQ,UAAU,QAAQ,KAAoC,CAAC;AAC/E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/playback/primitives/text-segment-load-pipeline.ts
|
|
2
|
+
/**
|
|
3
|
+
* Base-step view of the loader's wiring, folded into `config` by
|
|
4
|
+
* `createTextTrackSegmentLoaderActor` so base steps read it from the uniform passthrough
|
|
5
|
+
* — present in both composition and standalone use. `config` is loose (`object`), so
|
|
6
|
+
* assert the shape here (mirrors the v/a loader's `stepWiring`). The sink is the
|
|
7
|
+
* structural {@link CueSink}, not the concrete actor.
|
|
8
|
+
*/
|
|
9
|
+
function textStepWiring(deps) {
|
|
10
|
+
return deps.config;
|
|
11
|
+
}
|
|
12
|
+
/** Resolve the op's cues (via the injected host primitive) into the frame. The text analog of `fetchStep`. */
|
|
13
|
+
const resolveCuesStep = async (frame, signal, deps) => {
|
|
14
|
+
const cues = await textStepWiring(deps).resolveSegment(frame.op.segment.url);
|
|
15
|
+
if (signal.aborted) return;
|
|
16
|
+
frame.cues = cues;
|
|
17
|
+
};
|
|
18
|
+
/** Dispatch the frame's cues to the TextTracksActor as `add-cues`. The text analog of `dispatchStep`. */
|
|
19
|
+
const dispatchCuesStep = (frame, _signal, deps) => {
|
|
20
|
+
const { op } = frame;
|
|
21
|
+
textStepWiring(deps).textTracksActor.send({
|
|
22
|
+
type: "add-cues",
|
|
23
|
+
meta: {
|
|
24
|
+
trackId: op.trackId,
|
|
25
|
+
id: op.segment.id,
|
|
26
|
+
startTime: op.segment.startTime,
|
|
27
|
+
duration: op.segment.duration
|
|
28
|
+
},
|
|
29
|
+
cues: frame.cues ?? []
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
/** Tier 0 default: resolve then dispatch. No relocation vocabulary. */
|
|
33
|
+
const DEFAULT_TEXT_MESSAGE_PIPELINES = () => [resolveCuesStep, dispatchCuesStep];
|
|
34
|
+
//#endregion
|
|
35
|
+
export { DEFAULT_TEXT_MESSAGE_PIPELINES, dispatchCuesStep, resolveCuesStep, textStepWiring };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=text-segment-load-pipeline.js.map
|