@editframe/elements 0.26.2-beta.0 → 0.26.4-beta.0
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/dist/elements/EFTimegroup.js +7 -2
- package/dist/elements/EFTimegroup.js.map +1 -1
- package/package.json +2 -2
- package/scripts/build-css.js +3 -3
- package/tsdown.config.ts +1 -1
- package/types.json +1 -1
- package/src/elements/ContextProxiesController.ts +0 -124
- package/src/elements/CrossUpdateController.ts +0 -22
- package/src/elements/EFAudio.browsertest.ts +0 -706
- package/src/elements/EFAudio.ts +0 -56
- package/src/elements/EFCaptions.browsertest.ts +0 -1960
- package/src/elements/EFCaptions.ts +0 -823
- package/src/elements/EFImage.browsertest.ts +0 -120
- package/src/elements/EFImage.ts +0 -113
- package/src/elements/EFMedia/AssetIdMediaEngine.test.ts +0 -224
- package/src/elements/EFMedia/AssetIdMediaEngine.ts +0 -110
- package/src/elements/EFMedia/AssetMediaEngine.browsertest.ts +0 -140
- package/src/elements/EFMedia/AssetMediaEngine.ts +0 -385
- package/src/elements/EFMedia/BaseMediaEngine.browsertest.ts +0 -400
- package/src/elements/EFMedia/BaseMediaEngine.ts +0 -505
- package/src/elements/EFMedia/BufferedSeekingInput.browsertest.ts +0 -386
- package/src/elements/EFMedia/BufferedSeekingInput.ts +0 -430
- package/src/elements/EFMedia/JitMediaEngine.browsertest.ts +0 -226
- package/src/elements/EFMedia/JitMediaEngine.ts +0 -256
- package/src/elements/EFMedia/audioTasks/makeAudioBufferTask.browsertest.ts +0 -679
- package/src/elements/EFMedia/audioTasks/makeAudioBufferTask.ts +0 -117
- package/src/elements/EFMedia/audioTasks/makeAudioFrequencyAnalysisTask.ts +0 -246
- package/src/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.browsertest.ts +0 -59
- package/src/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.ts +0 -27
- package/src/elements/EFMedia/audioTasks/makeAudioInputTask.browsertest.ts +0 -55
- package/src/elements/EFMedia/audioTasks/makeAudioInputTask.ts +0 -53
- package/src/elements/EFMedia/audioTasks/makeAudioSeekTask.chunkboundary.regression.browsertest.ts +0 -207
- package/src/elements/EFMedia/audioTasks/makeAudioSeekTask.ts +0 -72
- package/src/elements/EFMedia/audioTasks/makeAudioSegmentFetchTask.ts +0 -32
- package/src/elements/EFMedia/audioTasks/makeAudioSegmentIdTask.ts +0 -29
- package/src/elements/EFMedia/audioTasks/makeAudioTasksVideoOnly.browsertest.ts +0 -95
- package/src/elements/EFMedia/audioTasks/makeAudioTimeDomainAnalysisTask.ts +0 -184
- package/src/elements/EFMedia/shared/AudioSpanUtils.ts +0 -129
- package/src/elements/EFMedia/shared/BufferUtils.ts +0 -342
- package/src/elements/EFMedia/shared/GlobalInputCache.ts +0 -77
- package/src/elements/EFMedia/shared/MediaTaskUtils.ts +0 -44
- package/src/elements/EFMedia/shared/PrecisionUtils.ts +0 -46
- package/src/elements/EFMedia/shared/RenditionHelpers.browsertest.ts +0 -246
- package/src/elements/EFMedia/shared/RenditionHelpers.ts +0 -56
- package/src/elements/EFMedia/shared/ThumbnailExtractor.ts +0 -227
- package/src/elements/EFMedia/tasks/makeMediaEngineTask.browsertest.ts +0 -167
- package/src/elements/EFMedia/tasks/makeMediaEngineTask.ts +0 -88
- package/src/elements/EFMedia/videoTasks/MainVideoInputCache.ts +0 -76
- package/src/elements/EFMedia/videoTasks/ScrubInputCache.ts +0 -61
- package/src/elements/EFMedia/videoTasks/makeScrubVideoBufferTask.ts +0 -114
- package/src/elements/EFMedia/videoTasks/makeScrubVideoInitSegmentFetchTask.ts +0 -35
- package/src/elements/EFMedia/videoTasks/makeScrubVideoInputTask.ts +0 -52
- package/src/elements/EFMedia/videoTasks/makeScrubVideoSeekTask.ts +0 -124
- package/src/elements/EFMedia/videoTasks/makeScrubVideoSegmentFetchTask.ts +0 -44
- package/src/elements/EFMedia/videoTasks/makeScrubVideoSegmentIdTask.ts +0 -32
- package/src/elements/EFMedia/videoTasks/makeUnifiedVideoSeekTask.ts +0 -370
- package/src/elements/EFMedia/videoTasks/makeVideoBufferTask.ts +0 -109
- package/src/elements/EFMedia.browsertest.ts +0 -872
- package/src/elements/EFMedia.ts +0 -341
- package/src/elements/EFSourceMixin.ts +0 -60
- package/src/elements/EFSurface.browsertest.ts +0 -151
- package/src/elements/EFSurface.ts +0 -142
- package/src/elements/EFTemporal.browsertest.ts +0 -215
- package/src/elements/EFTemporal.ts +0 -800
- package/src/elements/EFThumbnailStrip.browsertest.ts +0 -585
- package/src/elements/EFThumbnailStrip.media-engine.browsertest.ts +0 -714
- package/src/elements/EFThumbnailStrip.ts +0 -906
- package/src/elements/EFTimegroup.browsertest.ts +0 -870
- package/src/elements/EFTimegroup.ts +0 -878
- package/src/elements/EFVideo.browsertest.ts +0 -1482
- package/src/elements/EFVideo.ts +0 -564
- package/src/elements/EFWaveform.ts +0 -547
- package/src/elements/FetchContext.browsertest.ts +0 -401
- package/src/elements/FetchMixin.ts +0 -38
- package/src/elements/SampleBuffer.ts +0 -94
- package/src/elements/TargetController.browsertest.ts +0 -230
- package/src/elements/TargetController.ts +0 -224
- package/src/elements/TimegroupController.ts +0 -26
- package/src/elements/durationConverter.ts +0 -35
- package/src/elements/parseTimeToMs.ts +0 -9
- package/src/elements/printTaskStatus.ts +0 -16
- package/src/elements/renderTemporalAudio.ts +0 -108
- package/src/elements/updateAnimations.browsertest.ts +0 -1884
- package/src/elements/updateAnimations.ts +0 -217
- package/src/elements/util.ts +0 -24
- package/src/gui/ContextMixin.browsertest.ts +0 -860
- package/src/gui/ContextMixin.ts +0 -562
- package/src/gui/Controllable.browsertest.ts +0 -258
- package/src/gui/Controllable.ts +0 -41
- package/src/gui/EFConfiguration.ts +0 -40
- package/src/gui/EFControls.browsertest.ts +0 -389
- package/src/gui/EFControls.ts +0 -195
- package/src/gui/EFDial.browsertest.ts +0 -84
- package/src/gui/EFDial.ts +0 -172
- package/src/gui/EFFilmstrip.browsertest.ts +0 -712
- package/src/gui/EFFilmstrip.ts +0 -1349
- package/src/gui/EFFitScale.ts +0 -152
- package/src/gui/EFFocusOverlay.ts +0 -79
- package/src/gui/EFPause.browsertest.ts +0 -202
- package/src/gui/EFPause.ts +0 -73
- package/src/gui/EFPlay.browsertest.ts +0 -202
- package/src/gui/EFPlay.ts +0 -73
- package/src/gui/EFPreview.ts +0 -74
- package/src/gui/EFResizableBox.browsertest.ts +0 -79
- package/src/gui/EFResizableBox.ts +0 -898
- package/src/gui/EFScrubber.ts +0 -151
- package/src/gui/EFTimeDisplay.browsertest.ts +0 -237
- package/src/gui/EFTimeDisplay.ts +0 -55
- package/src/gui/EFToggleLoop.ts +0 -35
- package/src/gui/EFTogglePlay.ts +0 -70
- package/src/gui/EFWorkbench.ts +0 -115
- package/src/gui/PlaybackController.ts +0 -527
- package/src/gui/TWMixin.css +0 -6
- package/src/gui/TWMixin.ts +0 -61
- package/src/gui/TargetOrContextMixin.ts +0 -185
- package/src/gui/currentTimeContext.ts +0 -5
- package/src/gui/durationContext.ts +0 -3
- package/src/gui/efContext.ts +0 -6
- package/src/gui/fetchContext.ts +0 -5
- package/src/gui/focusContext.ts +0 -7
- package/src/gui/focusedElementContext.ts +0 -5
- package/src/gui/playingContext.ts +0 -5
- package/src/otel/BridgeSpanExporter.ts +0 -150
- package/src/otel/setupBrowserTracing.ts +0 -73
- package/src/otel/tracingHelpers.ts +0 -251
- package/src/transcoding/cache/RequestDeduplicator.test.ts +0 -170
- package/src/transcoding/cache/RequestDeduplicator.ts +0 -65
- package/src/transcoding/cache/URLTokenDeduplicator.test.ts +0 -182
- package/src/transcoding/cache/URLTokenDeduplicator.ts +0 -101
- package/src/transcoding/types/index.ts +0 -312
- package/src/transcoding/utils/MediaUtils.ts +0 -63
- package/src/transcoding/utils/UrlGenerator.ts +0 -68
- package/src/transcoding/utils/constants.ts +0 -36
- package/src/utils/LRUCache.test.ts +0 -274
- package/src/utils/LRUCache.ts +0 -696
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Task } from "@lit/task";
|
|
2
|
-
import { EF_INTERACTIVE } from "../../../EF_INTERACTIVE";
|
|
3
|
-
import type { MediaEngine } from "../../../transcoding/types";
|
|
4
|
-
import type { EFMedia } from "../../EFMedia";
|
|
5
|
-
import { AssetIdMediaEngine } from "../AssetIdMediaEngine";
|
|
6
|
-
import { AssetMediaEngine } from "../AssetMediaEngine";
|
|
7
|
-
import { JitMediaEngine } from "../JitMediaEngine";
|
|
8
|
-
|
|
9
|
-
export const getLatestMediaEngine = async (
|
|
10
|
-
host: EFMedia,
|
|
11
|
-
signal: AbortSignal,
|
|
12
|
-
): Promise<MediaEngine> => {
|
|
13
|
-
const mediaEngine = await host.mediaEngineTask.taskComplete;
|
|
14
|
-
signal.throwIfAborted();
|
|
15
|
-
if (!mediaEngine) {
|
|
16
|
-
throw new Error("Media engine is not available");
|
|
17
|
-
}
|
|
18
|
-
return mediaEngine;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Core logic for creating a MediaEngine with explicit dependencies.
|
|
23
|
-
* Pure function that requires all dependencies to be provided.
|
|
24
|
-
*/
|
|
25
|
-
export const createMediaEngine = (host: EFMedia): Promise<MediaEngine> => {
|
|
26
|
-
const { src, assetId, urlGenerator, apiHost } = host;
|
|
27
|
-
|
|
28
|
-
// Check for AssetID mode first
|
|
29
|
-
if (assetId !== null && assetId !== undefined && assetId.trim() !== "") {
|
|
30
|
-
if (!apiHost) {
|
|
31
|
-
return Promise.reject(new Error("API host is required for AssetID mode"));
|
|
32
|
-
}
|
|
33
|
-
return AssetIdMediaEngine.fetchByAssetId(
|
|
34
|
-
host,
|
|
35
|
-
urlGenerator,
|
|
36
|
-
assetId,
|
|
37
|
-
apiHost,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Check for null/undefined/empty/whitespace src
|
|
42
|
-
if (!src || typeof src !== "string" || src.trim() === "") {
|
|
43
|
-
console.error(`Unsupported media source: ${src}, assetId: ${assetId}`);
|
|
44
|
-
return Promise.reject(new Error("Unsupported media source"));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const lowerSrc = src.toLowerCase();
|
|
48
|
-
if (!lowerSrc.startsWith("http://") && !lowerSrc.startsWith("https://")) {
|
|
49
|
-
return AssetMediaEngine.fetch(host, urlGenerator, src);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Remote (http/https) source, now check configuration
|
|
53
|
-
const configuration = host.closest("ef-configuration");
|
|
54
|
-
if (configuration?.mediaEngine === "local") {
|
|
55
|
-
// Only use AssetMediaEngine for remote URLs when explicitly configured
|
|
56
|
-
return AssetMediaEngine.fetch(host, urlGenerator, src);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Default: Use JitMediaEngine for remote URLs (transcoding service)
|
|
60
|
-
const url = urlGenerator.generateManifestUrl(src);
|
|
61
|
-
return JitMediaEngine.fetch(host, urlGenerator, url);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Handle completion of media engine task - triggers necessary updates.
|
|
66
|
-
* Extracted for testability.
|
|
67
|
-
*/
|
|
68
|
-
export const handleMediaEngineComplete = (host: EFMedia): void => {
|
|
69
|
-
host.requestUpdate("intrinsicDurationMs");
|
|
70
|
-
host.requestUpdate("ownCurrentTimeMs");
|
|
71
|
-
host.rootTimegroup?.requestUpdate("ownCurrentTimeMs");
|
|
72
|
-
host.rootTimegroup?.requestUpdate("durationMs");
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
type MediaEngineTask = Task<readonly [string, string | null], MediaEngine>;
|
|
76
|
-
|
|
77
|
-
export const makeMediaEngineTask = (host: EFMedia): MediaEngineTask => {
|
|
78
|
-
return new Task(host, {
|
|
79
|
-
autoRun: EF_INTERACTIVE,
|
|
80
|
-
args: () => [host.src, host.assetId] as const,
|
|
81
|
-
task: async () => {
|
|
82
|
-
return createMediaEngine(host);
|
|
83
|
-
},
|
|
84
|
-
onComplete: (_value) => {
|
|
85
|
-
handleMediaEngineComplete(host);
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { BufferedSeekingInput } from "../BufferedSeekingInput";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Cache for main video BufferedSeekingInput instances
|
|
5
|
-
* Main video segments are typically 2s long, so we can reuse the same input
|
|
6
|
-
* for multiple frames within that segment (e.g., 60 frames at 30fps)
|
|
7
|
-
*/
|
|
8
|
-
export class MainVideoInputCache {
|
|
9
|
-
private cache = new Map<string, BufferedSeekingInput>();
|
|
10
|
-
private maxCacheSize = 10; // Keep last 10 main inputs (covers 20 seconds at 2s/segment)
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Create a cache key that uniquely identifies a segment
|
|
14
|
-
*/
|
|
15
|
-
private getCacheKey(
|
|
16
|
-
src: string,
|
|
17
|
-
segmentId: number,
|
|
18
|
-
renditionId: string | undefined,
|
|
19
|
-
): string {
|
|
20
|
-
return `${src}:${renditionId || "default"}:${segmentId}`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get or create BufferedSeekingInput for a main video segment
|
|
25
|
-
*/
|
|
26
|
-
async getOrCreateInput(
|
|
27
|
-
src: string,
|
|
28
|
-
segmentId: number,
|
|
29
|
-
renditionId: string | undefined,
|
|
30
|
-
createInputFn: () => Promise<BufferedSeekingInput | undefined>,
|
|
31
|
-
): Promise<BufferedSeekingInput | undefined> {
|
|
32
|
-
const cacheKey = this.getCacheKey(src, segmentId, renditionId);
|
|
33
|
-
|
|
34
|
-
// Check if we already have this segment cached
|
|
35
|
-
const cached = this.cache.get(cacheKey);
|
|
36
|
-
if (cached) {
|
|
37
|
-
return cached;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Create new input
|
|
41
|
-
const input = await createInputFn();
|
|
42
|
-
if (!input) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Add to cache and maintain size limit
|
|
47
|
-
this.cache.set(cacheKey, input);
|
|
48
|
-
|
|
49
|
-
// Evict oldest entries if cache is too large (LRU-like behavior)
|
|
50
|
-
if (this.cache.size > this.maxCacheSize) {
|
|
51
|
-
const oldestKey = this.cache.keys().next().value;
|
|
52
|
-
if (oldestKey !== undefined) {
|
|
53
|
-
this.cache.delete(oldestKey);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return input;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Clear the entire cache (called when video changes)
|
|
62
|
-
*/
|
|
63
|
-
clear() {
|
|
64
|
-
this.cache.clear();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Get cache statistics
|
|
69
|
-
*/
|
|
70
|
-
getStats() {
|
|
71
|
-
return {
|
|
72
|
-
size: this.cache.size,
|
|
73
|
-
cacheKeys: Array.from(this.cache.keys()),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { BufferedSeekingInput } from "../BufferedSeekingInput";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Cache for scrub BufferedSeekingInput instances
|
|
5
|
-
* Since scrub segments are 30s long, we can reuse the same input for many seeks
|
|
6
|
-
* within that time range, making scrub seeking very efficient
|
|
7
|
-
*/
|
|
8
|
-
export class ScrubInputCache {
|
|
9
|
-
private cache = new Map<number, BufferedSeekingInput>();
|
|
10
|
-
private maxCacheSize = 5; // Keep last 5 scrub inputs (covers 2.5 minutes)
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get or create BufferedSeekingInput for a scrub segment
|
|
14
|
-
*/
|
|
15
|
-
async getOrCreateInput(
|
|
16
|
-
segmentId: number,
|
|
17
|
-
createInputFn: () => Promise<BufferedSeekingInput | undefined>,
|
|
18
|
-
): Promise<BufferedSeekingInput | undefined> {
|
|
19
|
-
// Check if we already have this segment cached
|
|
20
|
-
const cached = this.cache.get(segmentId);
|
|
21
|
-
if (cached) {
|
|
22
|
-
return cached;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Create new input
|
|
26
|
-
const input = await createInputFn();
|
|
27
|
-
if (!input) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Add to cache and maintain size limit
|
|
32
|
-
this.cache.set(segmentId, input);
|
|
33
|
-
|
|
34
|
-
// Evict oldest entries if cache is too large
|
|
35
|
-
if (this.cache.size > this.maxCacheSize) {
|
|
36
|
-
const oldestKey = this.cache.keys().next().value;
|
|
37
|
-
if (oldestKey !== undefined) {
|
|
38
|
-
this.cache.delete(oldestKey);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return input;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Clear the entire cache (called when video changes)
|
|
47
|
-
*/
|
|
48
|
-
clear() {
|
|
49
|
-
this.cache.clear();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Get cache statistics
|
|
54
|
-
*/
|
|
55
|
-
getStats() {
|
|
56
|
-
return {
|
|
57
|
-
size: this.cache.size,
|
|
58
|
-
segmentIds: Array.from(this.cache.keys()),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Task } from "@lit/task";
|
|
2
|
-
|
|
3
|
-
import { EF_INTERACTIVE } from "../../../EF_INTERACTIVE.js";
|
|
4
|
-
import { EF_RENDERING } from "../../../EF_RENDERING.js";
|
|
5
|
-
import type { VideoRendition } from "../../../transcoding/types";
|
|
6
|
-
import type { EFVideo } from "../../EFVideo";
|
|
7
|
-
import type { MediaBufferState } from "../shared/BufferUtils";
|
|
8
|
-
import { manageMediaBuffer } from "../shared/BufferUtils";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Scrub video buffer task - aggressively preloads the ENTIRE scrub track
|
|
12
|
-
* Unlike main video buffering, this loads the full duration with higher concurrency
|
|
13
|
-
* for instant visual feedback during seeking
|
|
14
|
-
*/
|
|
15
|
-
export const makeScrubVideoBufferTask = (host: EFVideo) => {
|
|
16
|
-
let currentState: MediaBufferState = {
|
|
17
|
-
currentSeekTimeMs: 0,
|
|
18
|
-
requestedSegments: new Set(),
|
|
19
|
-
activeRequests: new Set(),
|
|
20
|
-
requestQueue: [],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return new Task(host, {
|
|
24
|
-
autoRun: EF_INTERACTIVE,
|
|
25
|
-
args: () => [host.mediaEngineTask.value] as const,
|
|
26
|
-
onError: (error) => {
|
|
27
|
-
console.error("scrubVideoBufferTask error", error);
|
|
28
|
-
},
|
|
29
|
-
onComplete: (value) => {
|
|
30
|
-
currentState = value as MediaBufferState;
|
|
31
|
-
},
|
|
32
|
-
task: async ([mediaEngine], { signal }) => {
|
|
33
|
-
// Skip entirely in rendering mode
|
|
34
|
-
if (EF_RENDERING()) {
|
|
35
|
-
return currentState;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Don't run if video buffering is disabled
|
|
39
|
-
if (!host.enableVideoBuffering) {
|
|
40
|
-
return currentState;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Need media engine to be available
|
|
44
|
-
if (!mediaEngine) {
|
|
45
|
-
return currentState;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Get scrub rendition using the proper interface method
|
|
49
|
-
const scrubRendition = mediaEngine.getScrubVideoRendition();
|
|
50
|
-
|
|
51
|
-
if (!scrubRendition) {
|
|
52
|
-
// No scrub rendition available - this is fine, just return current state
|
|
53
|
-
return currentState;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Add src to rendition
|
|
57
|
-
const scrubRenditionWithSrc = {
|
|
58
|
-
...scrubRendition,
|
|
59
|
-
src: mediaEngine.src,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
// First, ensure the init segment is cached for scrub content
|
|
64
|
-
try {
|
|
65
|
-
await mediaEngine.fetchInitSegment(scrubRenditionWithSrc, signal);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.warn(
|
|
68
|
-
"ScrubBuffer: Failed to cache scrub init segment:",
|
|
69
|
-
error,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Aggressively buffer the ENTIRE scrub track
|
|
74
|
-
const newState = await manageMediaBuffer<VideoRendition>(
|
|
75
|
-
0, // Always start from beginning to ensure complete coverage
|
|
76
|
-
{
|
|
77
|
-
// Buffer entire duration - scrub segments are 30s so much fewer total segments
|
|
78
|
-
bufferDurationMs: mediaEngine.durationMs,
|
|
79
|
-
// High concurrency for scrub - fewer segments overall (30s each vs 2s for main)
|
|
80
|
-
// E.g., 10min video = ~20 scrub segments vs ~300 main segments
|
|
81
|
-
maxParallelFetches: 10,
|
|
82
|
-
enableBuffering: true,
|
|
83
|
-
enableContinuousBuffering: true, // Keep going until all segments loaded
|
|
84
|
-
},
|
|
85
|
-
currentState,
|
|
86
|
-
mediaEngine.durationMs,
|
|
87
|
-
signal,
|
|
88
|
-
{
|
|
89
|
-
computeSegmentId: async (timeMs, rendition) => {
|
|
90
|
-
return mediaEngine.computeSegmentId(timeMs, rendition);
|
|
91
|
-
},
|
|
92
|
-
prefetchSegment: async (segmentId, rendition) => {
|
|
93
|
-
// Use the media engine to fetch and cache scrub segments
|
|
94
|
-
await mediaEngine.fetchMediaSegment(segmentId, rendition);
|
|
95
|
-
},
|
|
96
|
-
isSegmentCached: (segmentId, rendition) => {
|
|
97
|
-
return mediaEngine.isSegmentCached(segmentId, rendition);
|
|
98
|
-
},
|
|
99
|
-
getRendition: async () => scrubRenditionWithSrc,
|
|
100
|
-
logError: (message, error) => {
|
|
101
|
-
console.warn(`ScrubBuffer: ${message}`, error);
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return newState;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
if (signal.aborted) return currentState;
|
|
109
|
-
console.warn("ScrubBuffer failed:", error);
|
|
110
|
-
return currentState;
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Task } from "@lit/task";
|
|
2
|
-
import type { MediaEngine } from "../../../transcoding/types";
|
|
3
|
-
import type { EFVideo } from "../../EFVideo";
|
|
4
|
-
import { getLatestMediaEngine } from "../tasks/makeMediaEngineTask";
|
|
5
|
-
|
|
6
|
-
export const makeScrubVideoInitSegmentFetchTask = (
|
|
7
|
-
host: EFVideo,
|
|
8
|
-
): Task<readonly [MediaEngine | undefined], ArrayBuffer> => {
|
|
9
|
-
return new Task(host, {
|
|
10
|
-
args: () => [host.mediaEngineTask.value] as const,
|
|
11
|
-
onError: (error) => {
|
|
12
|
-
console.error("scrubVideoInitSegmentFetchTask error", error);
|
|
13
|
-
},
|
|
14
|
-
onComplete: (_value) => {},
|
|
15
|
-
task: async ([_mediaEngine], { signal }) => {
|
|
16
|
-
const mediaEngine = await getLatestMediaEngine(host, signal);
|
|
17
|
-
|
|
18
|
-
// Get scrub rendition using the proper interface method
|
|
19
|
-
const scrubRendition = mediaEngine.getScrubVideoRendition();
|
|
20
|
-
|
|
21
|
-
if (!scrubRendition) {
|
|
22
|
-
// No scrub rendition available - this is fine, scrub is optional
|
|
23
|
-
throw new Error("No scrub rendition available");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return mediaEngine.fetchInitSegment(
|
|
27
|
-
{
|
|
28
|
-
...scrubRendition,
|
|
29
|
-
src: mediaEngine.src, // Ensure src is set
|
|
30
|
-
},
|
|
31
|
-
signal,
|
|
32
|
-
);
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Task } from "@lit/task";
|
|
2
|
-
|
|
3
|
-
import { EFMedia } from "../../EFMedia";
|
|
4
|
-
import type { EFVideo } from "../../EFVideo";
|
|
5
|
-
import { BufferedSeekingInput } from "../BufferedSeekingInput";
|
|
6
|
-
import type { InputTask } from "../shared/MediaTaskUtils";
|
|
7
|
-
|
|
8
|
-
export const makeScrubVideoInputTask = (host: EFVideo): InputTask => {
|
|
9
|
-
return new Task<
|
|
10
|
-
readonly [ArrayBuffer | undefined, ArrayBuffer | undefined],
|
|
11
|
-
BufferedSeekingInput | undefined
|
|
12
|
-
>(host, {
|
|
13
|
-
args: () =>
|
|
14
|
-
[
|
|
15
|
-
host.scrubVideoInitSegmentFetchTask.value,
|
|
16
|
-
host.scrubVideoSegmentFetchTask.value,
|
|
17
|
-
] as const,
|
|
18
|
-
onError: (error) => {
|
|
19
|
-
console.error("scrubVideoInputTask error", error);
|
|
20
|
-
},
|
|
21
|
-
onComplete: (_value) => {},
|
|
22
|
-
task: async (_, { signal }) => {
|
|
23
|
-
const initSegment =
|
|
24
|
-
await host.scrubVideoInitSegmentFetchTask.taskComplete;
|
|
25
|
-
if (signal.aborted) return undefined;
|
|
26
|
-
|
|
27
|
-
const segment = await host.scrubVideoSegmentFetchTask.taskComplete;
|
|
28
|
-
if (signal.aborted) return undefined;
|
|
29
|
-
|
|
30
|
-
if (!initSegment || !segment) {
|
|
31
|
-
throw new Error("Scrub init segment or segment is not available");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Get startTimeOffsetMs from the scrub rendition if available
|
|
35
|
-
const mediaEngine = await host.mediaEngineTask.taskComplete;
|
|
36
|
-
if (signal.aborted) return undefined;
|
|
37
|
-
|
|
38
|
-
const scrubRendition = mediaEngine.getScrubVideoRendition();
|
|
39
|
-
const startTimeOffsetMs = scrubRendition?.startTimeOffsetMs;
|
|
40
|
-
|
|
41
|
-
const arrayBuffer = await new Blob([initSegment, segment]).arrayBuffer();
|
|
42
|
-
if (signal.aborted) return undefined;
|
|
43
|
-
|
|
44
|
-
const input = new BufferedSeekingInput(arrayBuffer, {
|
|
45
|
-
videoBufferSize: EFMedia.VIDEO_SAMPLE_BUFFER_SIZE,
|
|
46
|
-
audioBufferSize: EFMedia.AUDIO_SAMPLE_BUFFER_SIZE,
|
|
47
|
-
startTimeOffsetMs,
|
|
48
|
-
});
|
|
49
|
-
return input;
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Task } from "@lit/task";
|
|
2
|
-
|
|
3
|
-
import type { VideoSample } from "mediabunny";
|
|
4
|
-
|
|
5
|
-
import type { EFVideo } from "../../EFVideo";
|
|
6
|
-
import { ScrubInputCache } from "./ScrubInputCache";
|
|
7
|
-
|
|
8
|
-
type ScrubVideoSeekTask = Task<readonly [number], VideoSample | undefined>;
|
|
9
|
-
|
|
10
|
-
// Shared cache instance across all scrub seek tasks
|
|
11
|
-
const scrubInputCache = new ScrubInputCache();
|
|
12
|
-
|
|
13
|
-
export const makeScrubVideoSeekTask = (host: EFVideo): ScrubVideoSeekTask => {
|
|
14
|
-
return new Task(host, {
|
|
15
|
-
args: () => [host.desiredSeekTimeMs] as const,
|
|
16
|
-
onError: (error) => {
|
|
17
|
-
console.error("scrubVideoSeekTask error", error);
|
|
18
|
-
},
|
|
19
|
-
onComplete: (_value) => {},
|
|
20
|
-
task: async ([desiredSeekTimeMs], { signal }) => {
|
|
21
|
-
signal.throwIfAborted();
|
|
22
|
-
|
|
23
|
-
const mediaEngine = host.mediaEngineTask.value;
|
|
24
|
-
if (!mediaEngine) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Get scrub rendition using the proper interface method
|
|
29
|
-
const scrubRendition = mediaEngine.getScrubVideoRendition();
|
|
30
|
-
|
|
31
|
-
if (!scrubRendition) {
|
|
32
|
-
return undefined; // No scrub rendition
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const scrubRenditionWithSrc = {
|
|
36
|
-
...scrubRendition,
|
|
37
|
-
src: mediaEngine.src,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// Compute which scrub segment (30s) contains the desired seek time
|
|
41
|
-
const segmentId = mediaEngine.computeSegmentId(
|
|
42
|
-
desiredSeekTimeMs,
|
|
43
|
-
scrubRenditionWithSrc,
|
|
44
|
-
);
|
|
45
|
-
if (segmentId === undefined) {
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Check if this scrub segment is cached (preloaded by scrub buffer task)
|
|
50
|
-
const isCached = mediaEngine.isSegmentCached(
|
|
51
|
-
segmentId,
|
|
52
|
-
scrubRenditionWithSrc,
|
|
53
|
-
);
|
|
54
|
-
if (!isCached) {
|
|
55
|
-
// Scrub content not preloaded - fail fast, let main video handle it
|
|
56
|
-
// Scrub's job is instant feedback from cached content only
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
signal.throwIfAborted();
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
// Get or create BufferedSeekingInput for this scrub segment (30s)
|
|
64
|
-
// This efficiently reuses the same input for seeks within the same 30s range
|
|
65
|
-
const scrubInput = await scrubInputCache.getOrCreateInput(
|
|
66
|
-
segmentId,
|
|
67
|
-
async () => {
|
|
68
|
-
const [initSegment, mediaSegment] = await Promise.all([
|
|
69
|
-
mediaEngine.fetchInitSegment(scrubRenditionWithSrc, signal),
|
|
70
|
-
mediaEngine.fetchMediaSegment(segmentId, scrubRenditionWithSrc),
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
if (!initSegment || !mediaSegment || signal.aborted) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const { BufferedSeekingInput } = await import(
|
|
78
|
-
"../BufferedSeekingInput.js"
|
|
79
|
-
);
|
|
80
|
-
const { EFMedia } = await import("../../EFMedia.js");
|
|
81
|
-
|
|
82
|
-
return new BufferedSeekingInput(
|
|
83
|
-
await new Blob([initSegment, mediaSegment]).arrayBuffer(),
|
|
84
|
-
{
|
|
85
|
-
videoBufferSize: EFMedia.VIDEO_SAMPLE_BUFFER_SIZE,
|
|
86
|
-
audioBufferSize: EFMedia.AUDIO_SAMPLE_BUFFER_SIZE,
|
|
87
|
-
startTimeOffsetMs: scrubRendition.startTimeOffsetMs,
|
|
88
|
-
},
|
|
89
|
-
);
|
|
90
|
-
},
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (!scrubInput) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (signal.aborted) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Get video track and seek to precise time within the 30s scrub segment
|
|
102
|
-
const videoTrack = await scrubInput.getFirstVideoTrack();
|
|
103
|
-
if (!videoTrack) {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (signal.aborted) {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const sample = (await scrubInput.seek(
|
|
112
|
-
videoTrack.id,
|
|
113
|
-
desiredSeekTimeMs,
|
|
114
|
-
)) as unknown as VideoSample | undefined;
|
|
115
|
-
|
|
116
|
-
return sample;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if (signal.aborted) return undefined;
|
|
119
|
-
console.warn("Failed to get scrub video sample:", error);
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Task } from "@lit/task";
|
|
2
|
-
import type { MediaEngine } from "../../../transcoding/types";
|
|
3
|
-
import type { EFVideo } from "../../EFVideo";
|
|
4
|
-
import { getLatestMediaEngine } from "../tasks/makeMediaEngineTask";
|
|
5
|
-
|
|
6
|
-
export const makeScrubVideoSegmentFetchTask = (
|
|
7
|
-
host: EFVideo,
|
|
8
|
-
): Task<
|
|
9
|
-
readonly [MediaEngine | undefined, number | undefined],
|
|
10
|
-
ArrayBuffer
|
|
11
|
-
> => {
|
|
12
|
-
return new Task(host, {
|
|
13
|
-
args: () =>
|
|
14
|
-
[host.mediaEngineTask.value, host.scrubVideoSegmentIdTask.value] as const,
|
|
15
|
-
onError: (error) => {
|
|
16
|
-
console.error("scrubVideoSegmentFetchTask error", error);
|
|
17
|
-
},
|
|
18
|
-
onComplete: (_value) => {},
|
|
19
|
-
task: async (_, { signal }) => {
|
|
20
|
-
const mediaEngine = await getLatestMediaEngine(host, signal);
|
|
21
|
-
const segmentId = await host.scrubVideoSegmentIdTask.taskComplete;
|
|
22
|
-
if (segmentId === undefined) {
|
|
23
|
-
throw new Error("Scrub segment ID is not available for video");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Get scrub rendition using the proper interface method
|
|
27
|
-
const scrubRendition = mediaEngine.getScrubVideoRendition();
|
|
28
|
-
|
|
29
|
-
if (!scrubRendition) {
|
|
30
|
-
// No scrub rendition available - this is fine, scrub is optional
|
|
31
|
-
throw new Error("No scrub rendition available");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return mediaEngine.fetchMediaSegment(
|
|
35
|
-
segmentId,
|
|
36
|
-
{
|
|
37
|
-
...scrubRendition,
|
|
38
|
-
src: mediaEngine.src, // Ensure src is set
|
|
39
|
-
},
|
|
40
|
-
signal,
|
|
41
|
-
);
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Task } from "@lit/task";
|
|
2
|
-
import type { MediaEngine } from "../../../transcoding/types";
|
|
3
|
-
import type { EFVideo } from "../../EFVideo";
|
|
4
|
-
import { getLatestMediaEngine } from "../tasks/makeMediaEngineTask";
|
|
5
|
-
|
|
6
|
-
export const makeScrubVideoSegmentIdTask = (
|
|
7
|
-
host: EFVideo,
|
|
8
|
-
): Task<readonly [MediaEngine | undefined, number], number | undefined> => {
|
|
9
|
-
return new Task(host, {
|
|
10
|
-
args: () => [host.mediaEngineTask.value, host.desiredSeekTimeMs] as const,
|
|
11
|
-
onError: (error) => {
|
|
12
|
-
console.error("scrubVideoSegmentIdTask error", error);
|
|
13
|
-
},
|
|
14
|
-
onComplete: (_value) => {},
|
|
15
|
-
task: async ([, targetSeekTimeMs], { signal }) => {
|
|
16
|
-
const mediaEngine = await getLatestMediaEngine(host, signal);
|
|
17
|
-
signal.throwIfAborted(); // Abort if a new seek started
|
|
18
|
-
|
|
19
|
-
// Get scrub rendition using the proper interface method
|
|
20
|
-
const scrubRendition = mediaEngine.getScrubVideoRendition();
|
|
21
|
-
|
|
22
|
-
if (!scrubRendition) {
|
|
23
|
-
return undefined; // No scrub rendition available
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return mediaEngine.computeSegmentId(targetSeekTimeMs, {
|
|
27
|
-
...scrubRendition,
|
|
28
|
-
src: mediaEngine.src, // Ensure src is set
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
};
|