@blockcast/mmt-container 2.2.0-main.2c4d96d3ffc2 → 2.2.0-main.34b53d33bace
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/browser-runtime.js +954 -157
- package/dist/browser-runtime.js.map +3 -3
- package/dist/cmaf-block-assembler.js +92 -1
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +92 -1
- package/dist/codec-utils.js.map +2 -2
- package/dist/delta-fallback-config.js.map +1 -1
- package/dist/fec-manager.d.ts +71 -14
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +300 -60
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-worker-setup.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +80 -25
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/media-router.js.map +1 -1
- package/dist/mmtp-container-parser.d.ts +63 -10
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +218 -18
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +217 -19
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +218 -18
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +22 -9
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +384 -51
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-manager.d.ts +26 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +774 -130
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js +2 -2
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +218 -18
- package/dist/no-modules.js.map +3 -3
- package/dist/repair-fetch.d.ts +38 -8
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +286 -27
- package/dist/repair-fetch.js.map +3 -3
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +1 -0
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +218 -18
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +316 -34
- package/src/index.ts +2 -0
- package/src/iso-block-locator.ts +114 -31
- package/src/mmtp-container-parser.ts +238 -21
- package/src/mmtp-router.ts +271 -58
- package/src/multicast-manager.ts +136 -16
- package/src/repair-fetch.ts +366 -50
- package/src/track-session.ts +3 -0
package/src/iso-block-locator.ts
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* between are one or more blocks whose every repair symbol was lost: they are
|
|
15
15
|
* kept as one repair-less span, which completes clean once all of its SS_IDs
|
|
16
16
|
* arrived (C.5.2 makes a gap in consecutive SS_IDs directly visible) and
|
|
17
|
-
* otherwise resolves through its catalog-derived deadline.
|
|
18
|
-
*
|
|
19
|
-
* a
|
|
17
|
+
* otherwise resolves through its catalog-derived deadline. A block without
|
|
18
|
+
* repair completes that way, on the next block's SS_Start, never on a count of
|
|
19
|
+
* K source symbols, unless a repair that arrives later (a FETCH of the span's
|
|
20
|
+
* first group) states exactly the span's range: the span was that one block.
|
|
20
21
|
*/
|
|
21
22
|
import {
|
|
22
23
|
isoBlockContains,
|
|
@@ -58,14 +59,29 @@ export type IsoRepairPlacement<T> =
|
|
|
58
59
|
*/
|
|
59
60
|
readonly hole?: { readonly block: IsoBlockRange; readonly lostSsId: number }
|
|
60
61
|
}
|
|
61
|
-
/**
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Not a block this stream can use; the repair symbol is dropped. `ofSpan` is
|
|
64
|
+
* set when the repair stated only the first block of that repair-less span:
|
|
65
|
+
* the span holds more than one block, so no single repair group completes it.
|
|
66
|
+
*/
|
|
67
|
+
| {
|
|
68
|
+
readonly status: 'conflict' | 'overlap' | 'stale' | 'ahead'
|
|
69
|
+
readonly reason: string
|
|
70
|
+
readonly ofSpan?: IsoBlockRange
|
|
71
|
+
}
|
|
63
72
|
|
|
64
73
|
/**
|
|
65
74
|
* Retention: the locator is never without one. Every call that can grow it
|
|
66
75
|
* (`hold`, `placeRepair`) retires, behind the position it just saw, every
|
|
67
76
|
* block, span and held source more than `retentionBlocks` blocks back, by the
|
|
68
|
-
* one ISO horizon metric (`isoBlocksBehindLowerBound`). A
|
|
77
|
+
* one ISO horizon metric (`isoBlocksBehindLowerBound`). A held source stays
|
|
78
|
+
* while a pending hole holding it does: the hole's repair FETCH may still
|
|
79
|
+
* state its block, and closing the hole places it, so the span it leaves
|
|
80
|
+
* counts every source it received (BLO-52085). A pending hole the horizon
|
|
81
|
+
* passes stops being pending (its blocks can no longer be stated, and the
|
|
82
|
+
* release gate no longer waits for it), but keeps its sources until its
|
|
83
|
+
* owner closes it (`takeExpiredHoles`), so it still fails as the span it
|
|
84
|
+
* is. A block is measured
|
|
69
85
|
* from its last SS_ID, so it stays while any SS_ID of it is inside the
|
|
70
86
|
* horizon: a repair-less span has no length bound, and one measured from its
|
|
71
87
|
* start could be retired the moment it is created, before the sources it
|
|
@@ -88,6 +104,15 @@ export class IsoBlockLocator<T> {
|
|
|
88
104
|
#newestSource: number | undefined
|
|
89
105
|
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
90
106
|
readonly #holes: IsoBlockRange[] = []
|
|
107
|
+
/** Holes the horizon passed while pending: sources held until closed. */
|
|
108
|
+
readonly #expired: IsoBlockRange[] = []
|
|
109
|
+
/** Of `#expired`, those `takeExpiredHoles` has not handed out yet. */
|
|
110
|
+
readonly #newlyExpired: IsoBlockRange[] = []
|
|
111
|
+
/**
|
|
112
|
+
* Spans closed from expired holes: behind the horizon, so kept only for
|
|
113
|
+
* `locate` while their sources are fed, until the next retirement.
|
|
114
|
+
*/
|
|
115
|
+
readonly #closedBehind: IsoBlockRange[] = []
|
|
91
116
|
/**
|
|
92
117
|
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
93
118
|
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
@@ -192,18 +217,31 @@ export class IsoBlockLocator<T> {
|
|
|
192
217
|
|
|
193
218
|
/** The known block or span containing `ssId`, with its ESI. */
|
|
194
219
|
locate(ssId: number): { block: IsoBlockRange; esi: number } | null {
|
|
195
|
-
for (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
220
|
+
for (const blocks of [this.#blocks, this.#closedBehind]) {
|
|
221
|
+
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
222
|
+
const block = blocks[i]!
|
|
223
|
+
if (isoBlockContains(block.start, block.length, ssId)) {
|
|
224
|
+
return { block, esi: serial32Distance(block.start, ssId) }
|
|
225
|
+
}
|
|
199
226
|
}
|
|
200
227
|
}
|
|
201
228
|
return null
|
|
202
229
|
}
|
|
203
230
|
|
|
204
|
-
/** Number of pending
|
|
231
|
+
/** Number of holes not closed yet, pending or past the horizon. */
|
|
205
232
|
get holeCount(): number {
|
|
206
|
-
return this.#holes.length
|
|
233
|
+
return this.#holes.length + this.#expired.length
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The pending holes the horizon has passed since the last call, in the
|
|
238
|
+
* order it passed them. Each is no longer pending: no repair states a block
|
|
239
|
+
* in it (that repair is `stale`, as for a span the horizon retired) and the
|
|
240
|
+
* release gate does not wait for it. Its owner must close it
|
|
241
|
+
* (`closeHolesWithin`), which turns it into a span that is not kept here.
|
|
242
|
+
*/
|
|
243
|
+
takeExpiredHoles(): IsoBlockRange[] {
|
|
244
|
+
return this.#newlyExpired.splice(0)
|
|
207
245
|
}
|
|
208
246
|
|
|
209
247
|
/** The stated block (never a span) ending exactly at `end`. */
|
|
@@ -268,9 +306,11 @@ export class IsoBlockLocator<T> {
|
|
|
268
306
|
/**
|
|
269
307
|
* Apply one repair symbol's `(SS_Start, SSB_length)`. The first repair of a
|
|
270
308
|
* block states its range and places every held source in it; later repair
|
|
271
|
-
* symbols of the same block change nothing. A range
|
|
272
|
-
*
|
|
273
|
-
*
|
|
309
|
+
* symbols of the same block change nothing. A repair whose range is exactly
|
|
310
|
+
* a repair-less span states that span's one block. A range that contradicts
|
|
311
|
+
* a known block (a different length, or an overlap with another block or
|
|
312
|
+
* with part of a span) fails closed: the repair symbol is dropped and no
|
|
313
|
+
* block changes.
|
|
274
314
|
* A newly stated block retires behind its SS_Start (see the class note).
|
|
275
315
|
* A block so far past `newest` that stating it would retire the position
|
|
276
316
|
* `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
|
|
@@ -289,7 +329,25 @@ export class IsoBlockLocator<T> {
|
|
|
289
329
|
const known = this.blockAt(start)
|
|
290
330
|
if (known !== undefined) {
|
|
291
331
|
if (known.span) {
|
|
292
|
-
|
|
332
|
+
// A span is no accepted block: it is the whole blocks between two
|
|
333
|
+
// stated ones whose repair never came (blocks are consecutive), so a
|
|
334
|
+
// repair whose range is exactly the span states its one block and
|
|
335
|
+
// contradicts nothing (draft-ramadan-moq-fec-core-00 5.4). Its sources
|
|
336
|
+
// were placed at these same ESIs when the span closed. A FETCH of the
|
|
337
|
+
// span's Group ext(SS_Start) returns just this when one block lost
|
|
338
|
+
// every multicast repair (a join).
|
|
339
|
+
if (known.length === length) {
|
|
340
|
+
const block: IsoBlockRange = { start, length, span: false }
|
|
341
|
+
this.#blocks[this.#blocks.indexOf(known)] = block
|
|
342
|
+
return { status: 'placed', block, placed: [] }
|
|
343
|
+
}
|
|
344
|
+
return length < known.length
|
|
345
|
+
? {
|
|
346
|
+
status: 'overlap',
|
|
347
|
+
reason: `repair block ${start}+${length} is only the first block of repair-less span ${known.start}+${known.length}`,
|
|
348
|
+
ofSpan: known,
|
|
349
|
+
}
|
|
350
|
+
: { status: 'overlap', reason: `repair block ${start}+${length} runs past repair-less span ${known.start}+${known.length}` }
|
|
293
351
|
}
|
|
294
352
|
if (known.length !== length) {
|
|
295
353
|
return {
|
|
@@ -367,18 +425,28 @@ export class IsoBlockLocator<T> {
|
|
|
367
425
|
}
|
|
368
426
|
|
|
369
427
|
/**
|
|
370
|
-
* Turn every
|
|
371
|
-
*
|
|
372
|
-
*
|
|
428
|
+
* Turn every hole inside `[start, start + length)` into a repair-less span,
|
|
429
|
+
* claiming its held sources: its range FETCH ended, so nothing more will
|
|
430
|
+
* state its blocks. A hole the horizon passed (`takeExpiredHoles`) leaves a
|
|
431
|
+
* span that is not kept among the blocks, as the horizon would retire it at
|
|
432
|
+
* once; only `locate` finds it, until the next retirement, so its sources
|
|
433
|
+
* can be fed. Returns the spans, in SS_ID order.
|
|
373
434
|
*/
|
|
374
435
|
closeHolesWithin(start: number, length: number): { block: IsoBlockRange; placed: IsoPlacedSource<T>[] }[] {
|
|
375
436
|
const closed: { block: IsoBlockRange; placed: IsoPlacedSource<T>[] }[] = []
|
|
376
|
-
for (const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
437
|
+
for (const holes of [this.#holes, this.#expired]) {
|
|
438
|
+
for (const hole of [...holes]) {
|
|
439
|
+
if (!isoBlockContains(start, length, hole.start)) continue
|
|
440
|
+
holes.splice(holes.indexOf(hole), 1)
|
|
441
|
+
const spanBlock: IsoBlockRange = { start: hole.start, length: hole.length, span: true }
|
|
442
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) })
|
|
443
|
+
if (holes === this.#holes) {
|
|
444
|
+
this.#blocks.push(spanBlock)
|
|
445
|
+
} else {
|
|
446
|
+
this.#closedBehind.push(spanBlock)
|
|
447
|
+
if (this.#newlyExpired.includes(hole)) this.#newlyExpired.splice(this.#newlyExpired.indexOf(hole), 1)
|
|
448
|
+
}
|
|
449
|
+
}
|
|
382
450
|
}
|
|
383
451
|
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start))
|
|
384
452
|
}
|
|
@@ -395,15 +463,17 @@ export class IsoBlockLocator<T> {
|
|
|
395
463
|
}
|
|
396
464
|
|
|
397
465
|
/**
|
|
398
|
-
* Retire every block and span whose last SS_ID, and every held source
|
|
399
|
-
* lies more than `retentionBlocks` blocks behind
|
|
400
|
-
* lower-bound metric (`isoBlocksBehindLowerBound`)
|
|
401
|
-
* horizon uses
|
|
466
|
+
* Retire every block and span whose last SS_ID, and every held source
|
|
467
|
+
* outside a hole, lies more than `retentionBlocks` blocks behind
|
|
468
|
+
* `position`, with the shared lower-bound metric (`isoBlocksBehindLowerBound`)
|
|
469
|
+
* every ISO interleave horizon uses; a pending hole so far behind expires
|
|
470
|
+
* (`takeExpiredHoles`). Returns the retired block starts.
|
|
402
471
|
*/
|
|
403
472
|
retireBehind(position: number): number[] {
|
|
404
473
|
this.observe(position)
|
|
405
474
|
const horizon = this.#retentionBlocks
|
|
406
475
|
const retired: number[] = []
|
|
476
|
+
this.#closedBehind.length = 0
|
|
407
477
|
for (let i = this.#blocks.length - 1; i >= 0; i--) {
|
|
408
478
|
const block = this.#blocks[i]!
|
|
409
479
|
const last = serial32Add(block.start, block.length - 1)
|
|
@@ -415,10 +485,20 @@ export class IsoBlockLocator<T> {
|
|
|
415
485
|
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
416
486
|
const hole = this.#holes[i]!
|
|
417
487
|
const last = serial32Add(hole.start, hole.length - 1)
|
|
418
|
-
if (isoBlocksBehindLowerBound(last, position, this.#kMax)
|
|
488
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) <= horizon) continue
|
|
489
|
+
this.#holes.splice(i, 1)
|
|
490
|
+
this.#expired.push(hole)
|
|
491
|
+
this.#newlyExpired.push(hole)
|
|
419
492
|
}
|
|
493
|
+
// A held source stays while a hole holding it does (class note).
|
|
420
494
|
for (const ssId of [...this.#held.keys()]) {
|
|
421
|
-
if (
|
|
495
|
+
if (
|
|
496
|
+
isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon &&
|
|
497
|
+
!this.#holes.some((hole) => isoBlockContains(hole.start, hole.length, ssId)) &&
|
|
498
|
+
!this.#expired.some((hole) => isoBlockContains(hole.start, hole.length, ssId))
|
|
499
|
+
) {
|
|
500
|
+
this.#held.delete(ssId)
|
|
501
|
+
}
|
|
422
502
|
}
|
|
423
503
|
return retired
|
|
424
504
|
}
|
|
@@ -427,6 +507,9 @@ export class IsoBlockLocator<T> {
|
|
|
427
507
|
reset(): void {
|
|
428
508
|
this.#blocks.length = 0
|
|
429
509
|
this.#holes.length = 0
|
|
510
|
+
this.#expired.length = 0
|
|
511
|
+
this.#newlyExpired.length = 0
|
|
512
|
+
this.#closedBehind.length = 0
|
|
430
513
|
this.#held.clear()
|
|
431
514
|
this.#coverageEnd = undefined
|
|
432
515
|
this.#newest = undefined
|