@caprid/moq-media 0.0.0 → 0.1.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/LICENSE +20 -0
- package/NOTICE +6 -0
- package/README.md +187 -2
- package/UPSTREAM.json +19 -0
- package/dist/audio-player.d.ts +206 -0
- package/dist/audio-player.d.ts.map +1 -0
- package/dist/audio-player.js +480 -0
- package/dist/audio-player.js.map +1 -0
- package/dist/audio-worklet.d.ts +64 -0
- package/dist/audio-worklet.d.ts.map +1 -0
- package/dist/audio-worklet.js +355 -0
- package/dist/audio-worklet.js.map +1 -0
- package/dist/catalog.d.ts +141 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +174 -0
- package/dist/catalog.js.map +1 -0
- package/dist/clock.d.ts +178 -0
- package/dist/clock.d.ts.map +1 -0
- package/dist/clock.js +190 -0
- package/dist/clock.js.map +1 -0
- package/dist/echo-loopback.d.ts +38 -0
- package/dist/echo-loopback.d.ts.map +1 -0
- package/dist/echo-loopback.js +100 -0
- package/dist/echo-loopback.js.map +1 -0
- package/dist/h264.d.ts +4 -0
- package/dist/h264.d.ts.map +1 -0
- package/dist/h264.js +8 -0
- package/dist/h264.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/interrupt.d.ts +35 -0
- package/dist/interrupt.d.ts.map +1 -0
- package/dist/interrupt.js +44 -0
- package/dist/interrupt.js.map +1 -0
- package/dist/loc.d.ts +55 -0
- package/dist/loc.d.ts.map +1 -0
- package/dist/loc.js +74 -0
- package/dist/loc.js.map +1 -0
- package/dist/parse-catalog.d.ts +81 -0
- package/dist/parse-catalog.d.ts.map +1 -0
- package/dist/parse-catalog.js +134 -0
- package/dist/parse-catalog.js.map +1 -0
- package/dist/render-clock.d.ts +38 -0
- package/dist/render-clock.d.ts.map +1 -0
- package/dist/render-clock.js +40 -0
- package/dist/render-clock.js.map +1 -0
- package/dist/sequencer.d.ts +130 -0
- package/dist/sequencer.d.ts.map +1 -0
- package/dist/sequencer.js +599 -0
- package/dist/sequencer.js.map +1 -0
- package/dist/source.d.ts +21 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +54 -0
- package/dist/source.js.map +1 -0
- package/dist/timeline.d.ts +69 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.js +83 -0
- package/dist/timeline.js.map +1 -0
- package/dist/transcript.d.ts +84 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/transcript.js +151 -0
- package/dist/transcript.js.map +1 -0
- package/dist/webcodecs.d.ts +32 -0
- package/dist/webcodecs.d.ts.map +1 -0
- package/dist/webcodecs.js +79 -0
- package/dist/webcodecs.js.map +1 -0
- package/package.json +34 -4
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
import { locTimestampUs } from './loc.js';
|
|
2
|
+
/** How many keyframe timestamps are kept to measure intervals between consecutive groups. */
|
|
3
|
+
const KEYFRAMES_KEPT = 8;
|
|
4
|
+
/** While the clock is idle and frames are held, poll again after this long: the clock may have anchored meanwhile. */
|
|
5
|
+
const IDLE_RECHECK_US = 50_000;
|
|
6
|
+
/** At most this many frames are held, about 20 s of audio; beyond it everything held is dropped as a gap. */
|
|
7
|
+
const MAX_HELD_FRAMES = 1024;
|
|
8
|
+
/** Create a frame sequencer for one track. */
|
|
9
|
+
export function createFrameSequencer(options) {
|
|
10
|
+
const { clock } = options;
|
|
11
|
+
const keyframeGrouping = (options.grouping ?? 'keyframe') === 'keyframe';
|
|
12
|
+
let trackProperties = options.trackProperties ?? [];
|
|
13
|
+
const lateDropOption = optionalDuration(options.lateDropUs, 'lateDropUs', { infinite: true });
|
|
14
|
+
const reorderWindowUs = optionalDuration(options.reorderWindowUs, 'reorderWindowUs') ?? 0;
|
|
15
|
+
const catchUpAfterUs = optionalDuration(options.catchUpAfterUs, 'catchUpAfterUs');
|
|
16
|
+
if (catchUpAfterUs === 0)
|
|
17
|
+
throw new RangeError('catchUpAfterUs must be positive');
|
|
18
|
+
if (keyframeGrouping && (lateDropOption !== undefined || reorderWindowUs > 0)) {
|
|
19
|
+
throw new RangeError('lateDropUs and reorderWindowUs apply to frame grouping only');
|
|
20
|
+
}
|
|
21
|
+
const lateDropUs = () => lateDropOption ?? clock.lateDropUs;
|
|
22
|
+
const stats = { delivered: 0, late: 0, skippedGroups: 0, resyncs: 0, untimed: 0 };
|
|
23
|
+
// Groups above `floor` that have not been delivered or abandoned.
|
|
24
|
+
const groups = new Map();
|
|
25
|
+
// Groups at or below `floor` are behind what was delivered or abandoned; `undefined` until the first.
|
|
26
|
+
let floor;
|
|
27
|
+
// The group being delivered and its next object, under keyframe grouping.
|
|
28
|
+
let cursor;
|
|
29
|
+
let lastDeliveredUs;
|
|
30
|
+
// Under frame grouping, the group and object of the last delivered frame.
|
|
31
|
+
let lastDeliveredGroup;
|
|
32
|
+
let lastDeliveredObject = 0;
|
|
33
|
+
let deliveredSinceRestart = false;
|
|
34
|
+
let pending;
|
|
35
|
+
// Starving: something arrived but none of it was within the budget, since this position, and late by about this much.
|
|
36
|
+
// The wait is measured on the clock's local time, which never jumps; the position can, when the clock re-anchors.
|
|
37
|
+
let starve;
|
|
38
|
+
// The newest group (keyframe grouping) or frame (frame grouping) dropped as late: what a resync delivers.
|
|
39
|
+
let newestLate;
|
|
40
|
+
// Since when, on the clock's local time, every frame that arrived was dropped as late with none delivered, and when
|
|
41
|
+
// the latest of them was.
|
|
42
|
+
let lateSinceUs;
|
|
43
|
+
let lateLatestUs = 0;
|
|
44
|
+
// A catch-up was signalled and no frame has been delivered since: it is not signalled again until one is.
|
|
45
|
+
let caughtUp = false;
|
|
46
|
+
// The group of the last frame delivered, under either grouping, for `missingGroups`; reset with the group IDs.
|
|
47
|
+
let lastGroupOut;
|
|
48
|
+
// Under a reorder window, the highest group an end or reset with nothing in it said was over. It moves no floor: a
|
|
49
|
+
// multi-frame group taken before it may still bring later objects.
|
|
50
|
+
let emptyThrough;
|
|
51
|
+
// Under a reorder window, the highest group taken, dropped or known to be over: the next one is due, and any further
|
|
52
|
+
// one waits for the groups between. Frame grouping keeps the group being taken in `cursor` and `floor` one below it.
|
|
53
|
+
const settledThrough = () => {
|
|
54
|
+
const candidates = [floor, cursor?.groupId, floor === undefined && cursor === undefined ? undefined : emptyThrough];
|
|
55
|
+
const known = candidates.filter((id) => id !== undefined);
|
|
56
|
+
return known.length === 0 ? undefined : Math.max(...known);
|
|
57
|
+
};
|
|
58
|
+
const keyframes = new Map();
|
|
59
|
+
// The most frames one poll may return.
|
|
60
|
+
let limit = Number.POSITIVE_INFINITY;
|
|
61
|
+
let sinceHeldCheck = 0;
|
|
62
|
+
const frameOf = (object, timestampUs) => ({
|
|
63
|
+
groupId: object.groupId,
|
|
64
|
+
objectId: object.objectId,
|
|
65
|
+
timestampUs,
|
|
66
|
+
key: object.objectId === 0,
|
|
67
|
+
payload: object.payload,
|
|
68
|
+
properties: object.properties,
|
|
69
|
+
});
|
|
70
|
+
const groupOf = (groupId) => {
|
|
71
|
+
let group = groups.get(groupId);
|
|
72
|
+
if (!group) {
|
|
73
|
+
group = { frames: new Map(), ended: false, reset: false };
|
|
74
|
+
groups.set(groupId, group);
|
|
75
|
+
}
|
|
76
|
+
return group;
|
|
77
|
+
};
|
|
78
|
+
const noteKeyframe = (groupId, timestampUs) => {
|
|
79
|
+
if (keyframes.has(groupId))
|
|
80
|
+
return;
|
|
81
|
+
keyframes.set(groupId, timestampUs);
|
|
82
|
+
const before = keyframes.get(groupId - 1);
|
|
83
|
+
if (before !== undefined && timestampUs > before)
|
|
84
|
+
clock.reportKeyframeInterval(timestampUs - before);
|
|
85
|
+
const after = keyframes.get(groupId + 1);
|
|
86
|
+
if (after !== undefined && after > timestampUs)
|
|
87
|
+
clock.reportKeyframeInterval(after - timestampUs);
|
|
88
|
+
if (keyframes.size > KEYFRAMES_KEPT)
|
|
89
|
+
keyframes.delete(Math.min(...keyframes.keys()));
|
|
90
|
+
};
|
|
91
|
+
const behind = (groupId, objectId) => {
|
|
92
|
+
if (floor !== undefined && groupId <= floor)
|
|
93
|
+
return true;
|
|
94
|
+
if (cursor === undefined)
|
|
95
|
+
return false;
|
|
96
|
+
return groupId < cursor.groupId || (groupId === cursor.groupId && objectId < cursor.nextObjectId);
|
|
97
|
+
};
|
|
98
|
+
// A late frame. Starving restarts whenever the lateness moves by more than a quarter of the target latency: a stall
|
|
99
|
+
// (lateness growing) or a backlog draining (shrinking) is not a lasting change in delay, and a resync on it would
|
|
100
|
+
// anchor the clock on frames that are about to be caught up with.
|
|
101
|
+
const noteLate = (positionUs, latenessUs) => {
|
|
102
|
+
if (starve === undefined || Math.abs(latenessUs - starve.latenessUs) > clock.targetLatencyUs / 4) {
|
|
103
|
+
starve = { sinceUs: positionUs, sinceLocalUs: clock.localNow(), latenessUs, resets: clock.resets };
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
// A frame judged late as it is taken, for catch-up. Not when a held candidate is judged again on a changed clock: a
|
|
107
|
+
// catch-up follows late arrivals, not a re-anchor.
|
|
108
|
+
const lateArrived = () => {
|
|
109
|
+
lateLatestUs = clock.localNow();
|
|
110
|
+
lateSinceUs ??= lateLatestUs;
|
|
111
|
+
};
|
|
112
|
+
// Mark a group as not delivered whole, and everything up to it as behind.
|
|
113
|
+
const passOver = (groupId) => {
|
|
114
|
+
const group = groups.get(groupId);
|
|
115
|
+
groups.delete(groupId);
|
|
116
|
+
for (const id of groups.keys()) {
|
|
117
|
+
if (id < groupId) {
|
|
118
|
+
groups.delete(id);
|
|
119
|
+
stats.skippedGroups++;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
floor = Math.max(floor ?? groupId, groupId);
|
|
123
|
+
if (cursor?.groupId === groupId)
|
|
124
|
+
cursor = undefined;
|
|
125
|
+
stats.skippedGroups++;
|
|
126
|
+
if (deliveredSinceRestart)
|
|
127
|
+
pending ??= 'gap';
|
|
128
|
+
return group;
|
|
129
|
+
};
|
|
130
|
+
const lateGroup = (groupId, positionUs, timestampUs) => {
|
|
131
|
+
const group = passOver(groupId);
|
|
132
|
+
stats.late += group?.frames.size ?? 0;
|
|
133
|
+
// Only a group that still has its keyframe can be resynced on.
|
|
134
|
+
if (group?.frames.has(0) && (newestLate === undefined || groupId > newestLate.groupId)) {
|
|
135
|
+
newestLate = { groupId, group };
|
|
136
|
+
}
|
|
137
|
+
noteLate(positionUs, positionUs - timestampUs);
|
|
138
|
+
lateArrived();
|
|
139
|
+
// Its later objects already held count too: a draining backlog's shrinking lateness shows in them.
|
|
140
|
+
for (const objectId of [...(group?.frames.keys() ?? [])].sort((a, b) => a - b)) {
|
|
141
|
+
const frame = group?.frames.get(objectId);
|
|
142
|
+
if (frame.timestampUs > timestampUs)
|
|
143
|
+
noteLate(positionUs, positionUs - frame.timestampUs);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const deliver = (frame, out) => {
|
|
147
|
+
const discontinuity = pending;
|
|
148
|
+
pending = undefined;
|
|
149
|
+
const missing = lastGroupOut !== undefined && frame.groupId > lastGroupOut + 1
|
|
150
|
+
? { firstGroupId: lastGroupOut + 1, lastGroupId: frame.groupId - 1 }
|
|
151
|
+
: undefined;
|
|
152
|
+
lastGroupOut = frame.groupId;
|
|
153
|
+
out.push(discontinuity || missing
|
|
154
|
+
? { ...frame, ...(discontinuity ? { discontinuity } : {}), ...(missing ? { missingGroups: missing } : {}) }
|
|
155
|
+
: frame);
|
|
156
|
+
lateSinceUs = undefined;
|
|
157
|
+
caughtUp = false;
|
|
158
|
+
lastDeliveredUs = frame.timestampUs;
|
|
159
|
+
deliveredSinceRestart = true;
|
|
160
|
+
starve = undefined;
|
|
161
|
+
newestLate = undefined;
|
|
162
|
+
stats.delivered++;
|
|
163
|
+
};
|
|
164
|
+
const lowestKeyed = (above) => {
|
|
165
|
+
let lowest;
|
|
166
|
+
for (const [id, group] of groups) {
|
|
167
|
+
if ((above === undefined || id > above) && group.frames.has(0) && (lowest === undefined || id < lowest)) {
|
|
168
|
+
lowest = id;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return lowest;
|
|
172
|
+
};
|
|
173
|
+
// Keyframe grouping: deliver what is in order, wait for what may still come, skip what is too late.
|
|
174
|
+
const pollKeyframes = (out) => {
|
|
175
|
+
const positionUs = clock.position();
|
|
176
|
+
const target = clock.targetLatencyUs;
|
|
177
|
+
const lateBefore = positionUs === undefined ? Number.NEGATIVE_INFINITY : positionUs - target;
|
|
178
|
+
// How long newer frames wait on a missing one: it is later than the last delivered frame, so it may still come
|
|
179
|
+
// until that frame's timestamp plus the target latency. While the clock is idle nothing is late, and the wait
|
|
180
|
+
// ends with the missing frame's group.
|
|
181
|
+
const gapWait = () => {
|
|
182
|
+
if (positionUs === undefined)
|
|
183
|
+
return undefined;
|
|
184
|
+
return lastDeliveredUs === undefined ? 0 : lastDeliveredUs + target - positionUs;
|
|
185
|
+
};
|
|
186
|
+
for (;;) {
|
|
187
|
+
if (out.length >= limit)
|
|
188
|
+
return 0;
|
|
189
|
+
// A group that ended or was reset without its keyframe can never be delivered; only the next group's says a gap.
|
|
190
|
+
const next = floor === undefined ? undefined : floor + 1;
|
|
191
|
+
for (const [id, group] of groups) {
|
|
192
|
+
if (id !== next && id !== cursor?.groupId && (group.ended || group.reset) && !group.frames.has(0)) {
|
|
193
|
+
groups.delete(id);
|
|
194
|
+
stats.skippedGroups++;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (cursor) {
|
|
198
|
+
const group = groups.get(cursor.groupId);
|
|
199
|
+
const frame = group.frames.get(cursor.nextObjectId);
|
|
200
|
+
if (frame) {
|
|
201
|
+
if (frame.timestampUs < lateBefore) {
|
|
202
|
+
lateGroup(cursor.groupId, positionUs, frame.timestampUs);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
group.frames.delete(cursor.nextObjectId);
|
|
206
|
+
cursor.nextObjectId++;
|
|
207
|
+
deliver(frame, out);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (group.ended && group.frames.size === 0) {
|
|
211
|
+
// Delivered whole: the next group follows on.
|
|
212
|
+
groups.delete(cursor.groupId);
|
|
213
|
+
floor = cursor.groupId;
|
|
214
|
+
cursor = undefined;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (!group.ended && !group.reset) {
|
|
218
|
+
// The group is open and its next frame missing, which costs nothing until a newer group is waiting.
|
|
219
|
+
if (lowestKeyed(cursor.groupId) === undefined)
|
|
220
|
+
return undefined;
|
|
221
|
+
const wait = gapWait();
|
|
222
|
+
if (wait === undefined || wait > 0)
|
|
223
|
+
return wait;
|
|
224
|
+
}
|
|
225
|
+
// Reset, ended with a hole, or waited out.
|
|
226
|
+
passOver(cursor.groupId);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const started = next === undefined ? undefined : groups.get(next);
|
|
230
|
+
if (next !== undefined && started && !started.frames.has(0)) {
|
|
231
|
+
// The next group started without its keyframe, which may still come while its stream is open.
|
|
232
|
+
if (!started.ended && !started.reset) {
|
|
233
|
+
if (lowestKeyed(next) === undefined)
|
|
234
|
+
return undefined;
|
|
235
|
+
const wait = gapWait();
|
|
236
|
+
if (wait === undefined || wait > 0)
|
|
237
|
+
return wait;
|
|
238
|
+
}
|
|
239
|
+
passOver(next);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
// The next group if it has its keyframe; otherwise, or before anything was delivered, the lowest that does.
|
|
243
|
+
const groupId = started ? next : lowestKeyed(floor);
|
|
244
|
+
if (groupId === undefined)
|
|
245
|
+
return undefined;
|
|
246
|
+
const keyframe = groups.get(groupId).frames.get(0);
|
|
247
|
+
if (keyframe.timestampUs < lateBefore) {
|
|
248
|
+
lateGroup(groupId, positionUs, keyframe.timestampUs);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (positionUs !== undefined && keyframe.timestampUs - positionUs > target) {
|
|
252
|
+
// The clock is behind what arrives, anchored on a backlog: resync forward on this keyframe, in a poll of its own
|
|
253
|
+
// so the frames before it are handled on the clock they were judged on.
|
|
254
|
+
if (out.length > 0)
|
|
255
|
+
return 0;
|
|
256
|
+
resyncForward();
|
|
257
|
+
return pollKeyframes(out);
|
|
258
|
+
}
|
|
259
|
+
if (next !== undefined && groupId > next) {
|
|
260
|
+
// An older group may still be on its way, or may never be sent (a failed group's ID is not reused). Wait only
|
|
261
|
+
// while this keyframe is not yet due: until then, holding it costs no latency.
|
|
262
|
+
if (positionUs !== undefined && keyframe.timestampUs > positionUs)
|
|
263
|
+
return keyframe.timestampUs - positionUs;
|
|
264
|
+
if (deliveredSinceRestart)
|
|
265
|
+
pending ??= 'gap';
|
|
266
|
+
}
|
|
267
|
+
for (const id of [...groups.keys()]) {
|
|
268
|
+
if (id < groupId) {
|
|
269
|
+
groups.delete(id);
|
|
270
|
+
stats.skippedGroups++;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
cursor = { groupId, nextObjectId: 0 };
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
// Frame grouping: every frame stands alone; deliver in order at once, and drop what is late or behind. A group may
|
|
277
|
+
// hold several frames, one per object, as a subgroup writer sends them: the position taken is a (group, object) pair,
|
|
278
|
+
// so the group's later objects are still ahead of it while its earlier ones are behind.
|
|
279
|
+
const pollFrames = (out) => {
|
|
280
|
+
let positionUs = clock.position();
|
|
281
|
+
let lateBefore = positionUs === undefined ? Number.NEGATIVE_INFINITY : positionUs - lateDropUs();
|
|
282
|
+
for (const id of [...groups.keys()].sort((a, b) => a - b)) {
|
|
283
|
+
const group = groups.get(id);
|
|
284
|
+
if (reorderWindowUs > 0) {
|
|
285
|
+
// A group that ended or was reset with nothing in it brings nothing: the next one need not wait for it. One
|
|
286
|
+
// further on, or one seen before anything was delivered (so before there is a floor), is kept until the
|
|
287
|
+
// groups before it are settled.
|
|
288
|
+
const through = settledThrough();
|
|
289
|
+
if (group.frames.size === 0 && (group.ended || group.reset)) {
|
|
290
|
+
if (through !== undefined && id <= through + 1) {
|
|
291
|
+
groups.delete(id);
|
|
292
|
+
emptyThrough = Math.max(emptyThrough ?? id, id);
|
|
293
|
+
}
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
// An earlier group is missing: this one, and every newer one, waits for it until the window from its arrival
|
|
297
|
+
// ends.
|
|
298
|
+
if (through !== undefined && id > through + 1 && group.arrivedUs !== undefined) {
|
|
299
|
+
const waitUs = group.arrivedUs + reorderWindowUs - clock.localNow();
|
|
300
|
+
if (waitUs > 0)
|
|
301
|
+
return waitUs;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
for (const objectId of [...group.frames.keys()].sort((a, b) => a - b)) {
|
|
305
|
+
if (out.length >= limit)
|
|
306
|
+
return 0;
|
|
307
|
+
const frame = group.frames.get(objectId);
|
|
308
|
+
if (positionUs !== undefined && frame.timestampUs - positionUs > clock.targetLatencyUs) {
|
|
309
|
+
// The clock is behind what arrives, anchored on a backlog: resync forward on this frame, in a poll of its
|
|
310
|
+
// own so the frames before it are handled on the clock they were judged on.
|
|
311
|
+
if (out.length > 0)
|
|
312
|
+
return 0;
|
|
313
|
+
resyncForward();
|
|
314
|
+
positionUs = undefined;
|
|
315
|
+
lateBefore = Number.NEGATIVE_INFINITY;
|
|
316
|
+
}
|
|
317
|
+
group.frames.delete(objectId);
|
|
318
|
+
floor = id - 1;
|
|
319
|
+
cursor = { groupId: id, nextObjectId: objectId + 1 };
|
|
320
|
+
if (positionUs !== undefined && frame.timestampUs < lateBefore) {
|
|
321
|
+
stats.late++;
|
|
322
|
+
newestLate = { groupId: id, group: { frames: new Map([[objectId, frame]]), ended: true, reset: false } };
|
|
323
|
+
noteLate(positionUs, positionUs - frame.timestampUs);
|
|
324
|
+
lateArrived();
|
|
325
|
+
if (deliveredSinceRestart)
|
|
326
|
+
pending ??= 'gap';
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
// A group ID or an object ID skipped since the last delivered frame is a frame that never came, or was reset.
|
|
330
|
+
if (deliveredSinceRestart && lastDeliveredGroup !== undefined) {
|
|
331
|
+
const skipped = id === lastDeliveredGroup
|
|
332
|
+
? objectId > lastDeliveredObject + 1
|
|
333
|
+
: id > lastDeliveredGroup + 1 || objectId > 0;
|
|
334
|
+
if (skipped)
|
|
335
|
+
pending ??= 'gap';
|
|
336
|
+
}
|
|
337
|
+
lastDeliveredGroup = id;
|
|
338
|
+
lastDeliveredObject = objectId;
|
|
339
|
+
deliver(frame, out);
|
|
340
|
+
}
|
|
341
|
+
groups.delete(id);
|
|
342
|
+
}
|
|
343
|
+
return undefined;
|
|
344
|
+
};
|
|
345
|
+
// Bound what is held when nobody polls: past the bound, everything held is dropped and the next frame is a gap.
|
|
346
|
+
const boundHeld = () => {
|
|
347
|
+
if (++sinceHeldCheck < 64)
|
|
348
|
+
return;
|
|
349
|
+
sinceHeldCheck = 0;
|
|
350
|
+
const candidate = newestLate?.group.frames.size ?? 0;
|
|
351
|
+
let held = candidate;
|
|
352
|
+
let highest = newestLate?.groupId;
|
|
353
|
+
for (const [id, group] of groups) {
|
|
354
|
+
held += group.frames.size;
|
|
355
|
+
highest = highest === undefined ? id : Math.max(highest, id);
|
|
356
|
+
}
|
|
357
|
+
if ((held <= MAX_HELD_FRAMES && groups.size <= MAX_HELD_FRAMES) || highest === undefined)
|
|
358
|
+
return;
|
|
359
|
+
// The resync candidate's frames were counted as late when they arrived.
|
|
360
|
+
stats.late += held - candidate;
|
|
361
|
+
stats.skippedGroups += groups.size;
|
|
362
|
+
groups.clear();
|
|
363
|
+
newestLate = undefined;
|
|
364
|
+
starve = undefined;
|
|
365
|
+
cursor = undefined;
|
|
366
|
+
floor = Math.max(floor ?? highest, highest);
|
|
367
|
+
if (deliveredSinceRestart)
|
|
368
|
+
pending ??= 'gap';
|
|
369
|
+
};
|
|
370
|
+
// A frame more than the target latency ahead of the position: the clock was anchored on a backlog (a resync during a
|
|
371
|
+
// long stall), and holding everything that far behind would make the backlog permanent.
|
|
372
|
+
const resyncForward = () => {
|
|
373
|
+
clock.reset();
|
|
374
|
+
stats.resyncs++;
|
|
375
|
+
pending = pending === 'restart' ? 'restart' : 'resync';
|
|
376
|
+
starve = undefined;
|
|
377
|
+
newestLate = undefined;
|
|
378
|
+
};
|
|
379
|
+
// Nothing within the budget for a whole target latency: deliver the newest late group or frame, and reset the
|
|
380
|
+
// clock so it re-anchors there. A lasting increase in delay must not keep the player black or silent.
|
|
381
|
+
const resyncWait = (out) => {
|
|
382
|
+
if (starve === undefined || !newestLate || out.length >= limit)
|
|
383
|
+
return undefined;
|
|
384
|
+
const positionUs = clock.position();
|
|
385
|
+
if (positionUs === undefined)
|
|
386
|
+
return undefined;
|
|
387
|
+
const wait = starve.sinceLocalUs + clock.targetLatencyUs - clock.localNow();
|
|
388
|
+
if (wait > 0)
|
|
389
|
+
return wait;
|
|
390
|
+
const { groupId, group } = newestLate;
|
|
391
|
+
newestLate = undefined;
|
|
392
|
+
starve = undefined;
|
|
393
|
+
clock.reset();
|
|
394
|
+
stats.resyncs++;
|
|
395
|
+
// Counted as late when dropped; it is delivered after all.
|
|
396
|
+
stats.late -= group.frames.size;
|
|
397
|
+
for (const id of [...groups.keys()]) {
|
|
398
|
+
if (id < groupId)
|
|
399
|
+
groups.delete(id);
|
|
400
|
+
}
|
|
401
|
+
// Under frame grouping the group's later objects may be held already: keep them beside the candidate.
|
|
402
|
+
const held = groups.get(groupId);
|
|
403
|
+
if (held)
|
|
404
|
+
for (const [objectId, frame] of group.frames)
|
|
405
|
+
held.frames.set(objectId, frame);
|
|
406
|
+
else
|
|
407
|
+
groups.set(groupId, group);
|
|
408
|
+
floor = groupId - 1;
|
|
409
|
+
cursor = undefined;
|
|
410
|
+
pending = pending === 'restart' ? 'restart' : 'resync';
|
|
411
|
+
if (!keyframeGrouping)
|
|
412
|
+
return pollFrames(out);
|
|
413
|
+
// From the resynced keyframe on; the clock is idle, so nothing is late until it anchors again.
|
|
414
|
+
cursor = { groupId, nextObjectId: 0 };
|
|
415
|
+
return pollKeyframes(out);
|
|
416
|
+
};
|
|
417
|
+
// A group's stream is over. One with nothing in it is kept only when it is the next group, where it says a gap;
|
|
418
|
+
// anything else would only accumulate.
|
|
419
|
+
const groupOver = (groupId, how) => {
|
|
420
|
+
if (newestLate?.groupId === groupId) {
|
|
421
|
+
newestLate.group[how] = true;
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (floor !== undefined && groupId <= floor)
|
|
425
|
+
return;
|
|
426
|
+
const group = groups.get(groupId);
|
|
427
|
+
if (group)
|
|
428
|
+
group[how] = true;
|
|
429
|
+
// Under a reorder window, any missing group's end is kept, even before the first delivery: it releases the frames
|
|
430
|
+
// waiting for that group.
|
|
431
|
+
else if (reorderWindowUs > 0 || (floor !== undefined && groupId === floor + 1))
|
|
432
|
+
groupOf(groupId)[how] = true;
|
|
433
|
+
boundHeld();
|
|
434
|
+
};
|
|
435
|
+
const groupEnded = (groupId) => groupOver(groupId, 'ended');
|
|
436
|
+
const groupReset = (groupId) => groupOver(groupId, 'reset');
|
|
437
|
+
// Another track can reset or re-anchor the shared clock. A resync candidate back within the budget then (or with
|
|
438
|
+
// the clock idle, when nothing is late) goes back to normal delivery, and a wait measured on the old timeline starts
|
|
439
|
+
// over.
|
|
440
|
+
const revisit = () => {
|
|
441
|
+
const positionUs = clock.position();
|
|
442
|
+
// The timeline changed: the clock was reset, or re-anchored so that its position no longer moved with local time.
|
|
443
|
+
if (starve !== undefined &&
|
|
444
|
+
(positionUs === undefined ||
|
|
445
|
+
starve.resets !== clock.resets ||
|
|
446
|
+
Math.abs(positionUs - starve.sinceUs - (clock.localNow() - starve.sinceLocalUs)) > clock.targetLatencyUs / 4)) {
|
|
447
|
+
starve = undefined;
|
|
448
|
+
}
|
|
449
|
+
if (!newestLate)
|
|
450
|
+
return;
|
|
451
|
+
const { groupId, group } = newestLate;
|
|
452
|
+
const first = group.frames.get(keyframeGrouping ? 0 : Math.min(...group.frames.keys()));
|
|
453
|
+
if (!first)
|
|
454
|
+
return;
|
|
455
|
+
const bound = keyframeGrouping ? clock.targetLatencyUs : lateDropUs();
|
|
456
|
+
if (positionUs !== undefined && first.timestampUs < positionUs - bound) {
|
|
457
|
+
// Still late on the new timeline: the wait starts over from here.
|
|
458
|
+
if (starve === undefined) {
|
|
459
|
+
for (const frame of [...group.frames.values()].sort((a, b) => a.objectId - b.objectId)) {
|
|
460
|
+
noteLate(positionUs, positionUs - frame.timestampUs);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
newestLate = undefined;
|
|
466
|
+
starve = undefined;
|
|
467
|
+
// Counted as late when dropped; it is delivered after all.
|
|
468
|
+
stats.late -= group.frames.size;
|
|
469
|
+
for (const id of [...groups.keys()]) {
|
|
470
|
+
if (id < groupId)
|
|
471
|
+
groups.delete(id);
|
|
472
|
+
}
|
|
473
|
+
// Under frame grouping the group's later objects may be held already: keep them beside the candidate.
|
|
474
|
+
const held = groups.get(groupId);
|
|
475
|
+
if (held)
|
|
476
|
+
for (const [objectId, frame] of group.frames)
|
|
477
|
+
held.frames.set(objectId, frame);
|
|
478
|
+
else
|
|
479
|
+
groups.set(groupId, group);
|
|
480
|
+
floor = groupId - 1;
|
|
481
|
+
cursor = undefined;
|
|
482
|
+
};
|
|
483
|
+
const minWait = (a, b) => a === undefined ? b : b === undefined ? a : Math.min(a, b);
|
|
484
|
+
return {
|
|
485
|
+
get trackProperties() {
|
|
486
|
+
return trackProperties;
|
|
487
|
+
},
|
|
488
|
+
set trackProperties(properties) {
|
|
489
|
+
trackProperties = properties;
|
|
490
|
+
},
|
|
491
|
+
get stats() {
|
|
492
|
+
return stats;
|
|
493
|
+
},
|
|
494
|
+
object(object) {
|
|
495
|
+
if (object.status === 'end-of-group') {
|
|
496
|
+
groupEnded(object.groupId);
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (object.status !== 'normal')
|
|
500
|
+
return;
|
|
501
|
+
const timestampUs = locTimestampUs(object.properties, { trackProperties });
|
|
502
|
+
if (timestampUs === undefined) {
|
|
503
|
+
stats.untimed++;
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
if (keyframeGrouping && newestLate?.groupId === object.groupId) {
|
|
507
|
+
// The resync candidate keeps collecting its group: a resync delivers from its keyframe on.
|
|
508
|
+
if (!newestLate.group.frames.has(object.objectId)) {
|
|
509
|
+
newestLate.group.frames.set(object.objectId, frameOf(object, timestampUs));
|
|
510
|
+
stats.late++;
|
|
511
|
+
const positionUs = clock.position();
|
|
512
|
+
if (positionUs !== undefined) {
|
|
513
|
+
noteLate(positionUs, positionUs - timestampUs);
|
|
514
|
+
lateArrived();
|
|
515
|
+
}
|
|
516
|
+
boundHeld();
|
|
517
|
+
}
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (behind(object.groupId, object.objectId)) {
|
|
521
|
+
stats.late++;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const group = groupOf(object.groupId);
|
|
525
|
+
if (group.frames.has(object.objectId))
|
|
526
|
+
return;
|
|
527
|
+
// Only a keyframe that can still be delivered reports an interval: an old duplicate must not move the budget.
|
|
528
|
+
if (keyframeGrouping && object.objectId === 0)
|
|
529
|
+
noteKeyframe(object.groupId, timestampUs);
|
|
530
|
+
group.arrivedUs ??= clock.localNow();
|
|
531
|
+
group.frames.set(object.objectId, frameOf(object, timestampUs));
|
|
532
|
+
boundHeld();
|
|
533
|
+
},
|
|
534
|
+
groupEnded,
|
|
535
|
+
groupReset,
|
|
536
|
+
restart() {
|
|
537
|
+
// The new subscription's timeline is not judged against the old one's anchor.
|
|
538
|
+
clock.reset();
|
|
539
|
+
groups.clear();
|
|
540
|
+
keyframes.clear();
|
|
541
|
+
floor = undefined;
|
|
542
|
+
cursor = undefined;
|
|
543
|
+
lastDeliveredUs = undefined;
|
|
544
|
+
lastDeliveredGroup = undefined;
|
|
545
|
+
lastGroupOut = undefined;
|
|
546
|
+
emptyThrough = undefined;
|
|
547
|
+
lateSinceUs = undefined;
|
|
548
|
+
starve = undefined;
|
|
549
|
+
newestLate = undefined;
|
|
550
|
+
// Always marked: the clock was reset, and whatever else plays on it must hear of that.
|
|
551
|
+
pending = 'restart';
|
|
552
|
+
deliveredSinceRestart = false;
|
|
553
|
+
},
|
|
554
|
+
poll(maxFrames) {
|
|
555
|
+
if (maxFrames !== undefined && !(Number.isSafeInteger(maxFrames) && maxFrames > 0)) {
|
|
556
|
+
throw new RangeError('maxFrames must be a positive integer');
|
|
557
|
+
}
|
|
558
|
+
limit = maxFrames ?? Number.POSITIVE_INFINITY;
|
|
559
|
+
const frames = [];
|
|
560
|
+
revisit();
|
|
561
|
+
let waitUs;
|
|
562
|
+
waitUs = keyframeGrouping ? pollKeyframes(frames) : pollFrames(frames);
|
|
563
|
+
waitUs = minWait(waitUs, resyncWait(frames));
|
|
564
|
+
let catchUp = false;
|
|
565
|
+
// Judged at the latest late frame: lateness that stopped arriving (a talker who went quiet) is no backlog.
|
|
566
|
+
if (catchUpAfterUs !== undefined &&
|
|
567
|
+
lateSinceUs !== undefined &&
|
|
568
|
+
!caughtUp &&
|
|
569
|
+
lateLatestUs - lateSinceUs >= catchUpAfterUs) {
|
|
570
|
+
catchUp = true;
|
|
571
|
+
caughtUp = true;
|
|
572
|
+
}
|
|
573
|
+
// Held frames wait on deadlines that only exist once the clock has a position.
|
|
574
|
+
if (waitUs === undefined && clock.position() === undefined && (groups.size > 0 || newestLate)) {
|
|
575
|
+
waitUs = IDLE_RECHECK_US;
|
|
576
|
+
}
|
|
577
|
+
const result = {
|
|
578
|
+
frames,
|
|
579
|
+
waitUs: waitUs === undefined ? undefined : Math.max(0, Math.ceil(waitUs)),
|
|
580
|
+
};
|
|
581
|
+
if (catchUp)
|
|
582
|
+
result.catchUp = true;
|
|
583
|
+
return result;
|
|
584
|
+
},
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
/** An optional duration option in microseconds: not negative, and finite unless `infinite` allows it. */
|
|
588
|
+
function optionalDuration(value, name, { infinite = false } = {}) {
|
|
589
|
+
if (value === undefined)
|
|
590
|
+
return undefined;
|
|
591
|
+
if (typeof value !== 'number' || Number.isNaN(value))
|
|
592
|
+
throw new TypeError(`${name} must be a number`);
|
|
593
|
+
if (!infinite && !Number.isFinite(value))
|
|
594
|
+
throw new RangeError(`${name} must be finite`);
|
|
595
|
+
if (value < 0)
|
|
596
|
+
throw new RangeError(`${name} must not be negative`);
|
|
597
|
+
return value;
|
|
598
|
+
}
|
|
599
|
+
//# sourceMappingURL=sequencer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequencer.js","sourceRoot":"","sources":["../src/sequencer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA2I1C,6FAA6F;AAC7F,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,sHAAsH;AACtH,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,6GAA6G;AAC7G,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,8CAA8C;AAC9C,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1B,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,UAAU,CAAC,KAAK,UAAU,CAAC;IACzE,IAAI,eAAe,GAA4B,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;IAC7E,MAAM,cAAc,GAAG,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9F,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1F,MAAM,cAAc,GAAG,gBAAgB,CAAC,OAAO,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAClF,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CAAC;YACnC,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,yGAAyG;AACzG,SAAS,gBAAgB,CAAC,KAAyB,EAAE,IAAY,EAAE,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,EAAE;IAC1F,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,mBAAmB,CAAC,CAAC;IACtG,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,iBAAiB,CAAC,CAAC;IACzF,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,uBAAuB,CAAC,CAAC;IACpE,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/source.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Encode one namespace field or track name into the MSF string form. */
|
|
2
|
+
export declare function encodeNameComponent(value: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* The MSF string form of a full track name: each namespace field encoded with {@link encodeNameComponent} and joined
|
|
5
|
+
* with `-`, then `--` and the encoded track name.
|
|
6
|
+
*/
|
|
7
|
+
export declare function encodeNamespaceName(namespace: readonly string[], trackName: string): string;
|
|
8
|
+
/** Options for {@link composeMoqSource}. */
|
|
9
|
+
export interface ComposeMoqSourceOptions {
|
|
10
|
+
/** The track the source names. Default {@link CATALOG_TRACK}. */
|
|
11
|
+
trackName?: string;
|
|
12
|
+
/** A token for the player to present, carried percent-encoded in the fragment's `c4m` parameter. */
|
|
13
|
+
token?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Compose the `moqt://` source URL a MoQ player takes: the relay URL with its scheme switched to `moqt:` (authority,
|
|
17
|
+
* path and query kept), and a `#msf:` fragment naming the namespace and track. The relay URL must be an absolute
|
|
18
|
+
* `https://` or `moqt://` URL with no credentials or fragment; namespace fields must be non-empty.
|
|
19
|
+
*/
|
|
20
|
+
export declare function composeMoqSource(origin: string, namespace: readonly string[], options?: ComposeMoqSourceOptions): string;
|
|
21
|
+
//# sourceMappingURL=source.d.ts.map
|