@blockcast/mmt-container 0.4.0-main.bbd83cb48eff → 0.4.0-main.ce637cfaae36
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 +362 -11
- package/dist/browser-runtime.js.map +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +441 -11
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-fec-session.d.ts +117 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +482 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/multicast-manager.d.ts +21 -2
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +35 -1
- package/dist/multicast-manager.js.map +2 -2
- package/dist/no-modules.d.ts +1 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +393 -0
- package/dist/no-modules.js.map +3 -3
- package/dist/repair-fetch.d.ts +23 -1
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +35 -10
- package/dist/repair-fetch.js.map +2 -2
- package/package.json +5 -5
- package/src/index.ts +13 -0
- package/src/mmtp-fec-session.ts +430 -0
- package/src/multicast-manager.ts +80 -2
- package/src/no-modules.ts +1 -0
- package/src/repair-fetch.ts +79 -14
package/dist/browser-runtime.js
CHANGED
|
@@ -23253,6 +23253,12 @@ var REPAIR_PRIORITY_REASONS = /* @__PURE__ */ new Set([
|
|
|
23253
23253
|
"repair-priority-absent",
|
|
23254
23254
|
"repair-priority-invalid"
|
|
23255
23255
|
]);
|
|
23256
|
+
var REPAIR_SKIP_REASONS = /* @__PURE__ */ new Set([
|
|
23257
|
+
"rtt-unmeasured",
|
|
23258
|
+
"rtt-exceeds-budget",
|
|
23259
|
+
"presentation-delay-unavailable"
|
|
23260
|
+
]);
|
|
23261
|
+
var REPAIR_DEADLINE_BOUNDS = /* @__PURE__ */ new Set(["wait", "presentation", "keyframe", "retention"]);
|
|
23256
23262
|
var GAP_REASONS = {
|
|
23257
23263
|
"rap-lost": "stall",
|
|
23258
23264
|
"rap-unknown": "stall",
|
|
@@ -23275,6 +23281,9 @@ function isSymbolCounts(value) {
|
|
|
23275
23281
|
function isNullableNonNegative(value) {
|
|
23276
23282
|
return value === null || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
23277
23283
|
}
|
|
23284
|
+
function isFiniteNumber(value) {
|
|
23285
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
23286
|
+
}
|
|
23278
23287
|
function isRepairLifecycleEvent(value) {
|
|
23279
23288
|
if (!isRecord(value) || value["version"] !== 2) return false;
|
|
23280
23289
|
const block = value["block"];
|
|
@@ -23292,6 +23301,20 @@ function isRepairLifecycleEvent(value) {
|
|
|
23292
23301
|
case "repair-preempted":
|
|
23293
23302
|
case "repair-deferred":
|
|
23294
23303
|
return hasExactKeys(value, ["version", "type", "block"]) && isRepairBlockIdentity(block);
|
|
23304
|
+
case "repair-sent":
|
|
23305
|
+
return hasExactKeys(value, [
|
|
23306
|
+
"version",
|
|
23307
|
+
"type",
|
|
23308
|
+
"block",
|
|
23309
|
+
"priority",
|
|
23310
|
+
"rttMs",
|
|
23311
|
+
"budgetMs",
|
|
23312
|
+
"delayMs",
|
|
23313
|
+
"blockAgeMs",
|
|
23314
|
+
"bound"
|
|
23315
|
+
]) && isRepairBlockIdentity(block) && (value["priority"] === 0 || value["priority"] === 1 || value["priority"] === 2) && isFiniteNumber(value["rttMs"]) && value["rttMs"] > 0 && isFiniteNumber(value["budgetMs"]) && value["budgetMs"] > value["rttMs"] && isNullableNonNegative(value["delayMs"]) && isNullableNonNegative(value["blockAgeMs"]) && value["delayMs"] === null === (value["blockAgeMs"] === null) && REPAIR_DEADLINE_BOUNDS.has(value["bound"]);
|
|
23316
|
+
case "repair-skipped":
|
|
23317
|
+
return hasExactKeys(value, ["version", "type", "block", "reason", "rttMs", "budgetMs"]) && isRepairBlockIdentity(block) && REPAIR_SKIP_REASONS.has(value["reason"]) && isNullableNonNegative(value["rttMs"]) && isFiniteNumber(value["budgetMs"]);
|
|
23295
23318
|
case "repair-priority": {
|
|
23296
23319
|
const blockClass = value["blockClass"];
|
|
23297
23320
|
const action = value["action"];
|
|
@@ -24794,8 +24817,19 @@ var MulticastManager = class {
|
|
|
24794
24817
|
stats.keyframeBudgetHoldMs += extensionMs;
|
|
24795
24818
|
}
|
|
24796
24819
|
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
24797
|
-
noteRepairFetchSent(priority,
|
|
24820
|
+
noteRepairFetchSent(priority, sbn, packetId, catalogTrackName, measurement) {
|
|
24798
24821
|
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
24822
|
+
this.#emitRepairLifecycle({
|
|
24823
|
+
version: 2,
|
|
24824
|
+
type: "repair-sent",
|
|
24825
|
+
block: repairBlockIdentity(packetId, sbn, catalogTrackName),
|
|
24826
|
+
priority,
|
|
24827
|
+
rttMs: measurement.rttMs,
|
|
24828
|
+
budgetMs: measurement.budgetMs,
|
|
24829
|
+
delayMs: measurement.delayMs,
|
|
24830
|
+
blockAgeMs: measurement.blockAgeMs,
|
|
24831
|
+
bound: measurement.bound
|
|
24832
|
+
});
|
|
24799
24833
|
}
|
|
24800
24834
|
/**
|
|
24801
24835
|
* Record a repair-scheduler decision about a delta block: preempted for
|
|
@@ -26708,6 +26742,297 @@ var CmcdProducer = class {
|
|
|
26708
26742
|
}
|
|
26709
26743
|
};
|
|
26710
26744
|
|
|
26745
|
+
// src/mmtp-fec-session.ts
|
|
26746
|
+
var MmtpFecSession = class {
|
|
26747
|
+
#decoder;
|
|
26748
|
+
/** Blocks a repair has defined and that are not settled yet, by SS_Start. */
|
|
26749
|
+
#blocks = /* @__PURE__ */ new Map();
|
|
26750
|
+
/** SS_Starts of settled blocks, so a later repair for one is refused. */
|
|
26751
|
+
#settled = /* @__PURE__ */ new Set();
|
|
26752
|
+
/** SS_IDs whose packet the parser has: received, or recovered by the session. */
|
|
26753
|
+
#have = /* @__PURE__ */ new Set();
|
|
26754
|
+
#newest;
|
|
26755
|
+
/** The newest SS_ID when the remembered SS_IDs were last pruned. */
|
|
26756
|
+
#prunedAt;
|
|
26757
|
+
#repairPacketId;
|
|
26758
|
+
#stats = {
|
|
26759
|
+
sourceSymbols: 0,
|
|
26760
|
+
repairSymbols: 0,
|
|
26761
|
+
blocksClean: 0,
|
|
26762
|
+
blocksRecovered: 0,
|
|
26763
|
+
blocksFailed: 0,
|
|
26764
|
+
blocksReleased: 0,
|
|
26765
|
+
packetsRecovered: 0,
|
|
26766
|
+
packetsLost: 0,
|
|
26767
|
+
dropped: {}
|
|
26768
|
+
};
|
|
26769
|
+
/**
|
|
26770
|
+
* @throws when the catalog block lacks or misstates a field the session
|
|
26771
|
+
* needs: the block profile, K, T, `interleaveDepthMs` or
|
|
26772
|
+
* `reorderToleranceMs`. None is defaulted.
|
|
26773
|
+
*/
|
|
26774
|
+
constructor(config) {
|
|
26775
|
+
const fec = config?.fec;
|
|
26776
|
+
if (!fec || typeof fec !== "object") {
|
|
26777
|
+
throw new Error("MmtpFecSession: the catalog fec block is required");
|
|
26778
|
+
}
|
|
26779
|
+
this.blockProfile = parseFecBlockProfile(fec.blockProfile, "fec.blockProfile");
|
|
26780
|
+
this.sourceSymbols = requirePositiveInteger(fec.sourceSymbols, "fec.sourceSymbols");
|
|
26781
|
+
this.symbolSize = requirePositiveInteger(fec.symbolSize, "fec.symbolSize");
|
|
26782
|
+
const interleaveDepthMs = requireNumber(fec.interleaveDepthMs, "fec.interleaveDepthMs");
|
|
26783
|
+
const reorderToleranceMs = requireNumber(fec.reorderToleranceMs, "fec.reorderToleranceMs");
|
|
26784
|
+
this.retentionBlocks = deriveFecRetentionBlocks(
|
|
26785
|
+
fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs),
|
|
26786
|
+
interleaveDepthMs
|
|
26787
|
+
);
|
|
26788
|
+
if (typeof config.Decoder !== "function") {
|
|
26789
|
+
throw new Error("MmtpFecSession: a decoder constructor (wasm_bindgen.MmtFecDecoder) is required");
|
|
26790
|
+
}
|
|
26791
|
+
const decoder = new config.Decoder(this.retentionBlocks, this.blockProfile);
|
|
26792
|
+
try {
|
|
26793
|
+
decoder.configure_params(this.sourceSymbols, this.symbolSize);
|
|
26794
|
+
} catch (error) {
|
|
26795
|
+
decoder.free();
|
|
26796
|
+
throw error;
|
|
26797
|
+
}
|
|
26798
|
+
this.#decoder = decoder;
|
|
26799
|
+
}
|
|
26800
|
+
/** True once release() ran. */
|
|
26801
|
+
get released() {
|
|
26802
|
+
return this.#decoder === null;
|
|
26803
|
+
}
|
|
26804
|
+
get stats() {
|
|
26805
|
+
return { ...this.#stats, dropped: { ...this.#stats.dropped } };
|
|
26806
|
+
}
|
|
26807
|
+
/**
|
|
26808
|
+
* Feeds one received source packet: the MMTP packet without its four-byte
|
|
26809
|
+
* Source FEC Payload ID, under the SS_ID that ID stated. This is what
|
|
26810
|
+
* MmtpContainerParser's onSourceSymbol() hands over.
|
|
26811
|
+
*
|
|
26812
|
+
* @returns the protected packets of this packet's block that it recovered,
|
|
26813
|
+
* in SS_ID order, for the caller to feed to its parser with
|
|
26814
|
+
* `{skipFecPayloadId: true, recovered: true}`. Usually empty.
|
|
26815
|
+
*/
|
|
26816
|
+
addSource(ssId, packet) {
|
|
26817
|
+
const decoder = this.#decoder;
|
|
26818
|
+
if (!decoder) return this.#drop("source:released");
|
|
26819
|
+
if (!Number.isInteger(ssId) || ssId < 0 || ssId > 4294967295) return this.#drop("source:bad-ss-id");
|
|
26820
|
+
if (!ssbg1FitsSymbol(packet.byteLength, this.symbolSize)) return this.#drop("source:exceeds-symbol");
|
|
26821
|
+
if (this.#have.has(ssId)) return this.#drop("source:duplicate");
|
|
26822
|
+
this.#have.add(ssId);
|
|
26823
|
+
this.#stats.sourceSymbols++;
|
|
26824
|
+
this.#noteNewest(ssId);
|
|
26825
|
+
const start = this.#blockStartOf(ssId);
|
|
26826
|
+
const block = start === void 0 ? void 0 : this.#blocks.get(start);
|
|
26827
|
+
if (block) block.received++;
|
|
26828
|
+
let output;
|
|
26829
|
+
try {
|
|
26830
|
+
output = decoder.add_source(ssId, packet, 0);
|
|
26831
|
+
} catch {
|
|
26832
|
+
this.#drop("source:decoder-refused");
|
|
26833
|
+
output = void 0;
|
|
26834
|
+
}
|
|
26835
|
+
const recovered = [];
|
|
26836
|
+
if (start !== void 0 && block) {
|
|
26837
|
+
if (output) {
|
|
26838
|
+
recovered.push(...this.#settleDecoded(start, block, output));
|
|
26839
|
+
} else if (block.received >= block.ssbLength) {
|
|
26840
|
+
this.#settleClean(start);
|
|
26841
|
+
}
|
|
26842
|
+
}
|
|
26843
|
+
this.#retireBehindHorizon();
|
|
26844
|
+
return recovered;
|
|
26845
|
+
}
|
|
26846
|
+
/**
|
|
26847
|
+
* Feeds one object of the repair track: a whole MMTP repair packet (ISO/IEC
|
|
26848
|
+
* 23008-1 C.5.3). A repair track carries one repair flow, so the first
|
|
26849
|
+
* repair packet fixes its packet ID and a packet of any other is refused.
|
|
26850
|
+
*
|
|
26851
|
+
* @returns the protected packets this repair symbol recovered, as for
|
|
26852
|
+
* addSource().
|
|
26853
|
+
*/
|
|
26854
|
+
addRepair(packet) {
|
|
26855
|
+
const decoder = this.#decoder;
|
|
26856
|
+
if (!decoder) return this.#drop("repair:released");
|
|
26857
|
+
let header;
|
|
26858
|
+
try {
|
|
26859
|
+
header = parseMMTPHeader(packet);
|
|
26860
|
+
} catch {
|
|
26861
|
+
return this.#drop("repair:malformed");
|
|
26862
|
+
}
|
|
26863
|
+
const frame = parseMoqRepairFrameWithHeader(packet, header);
|
|
26864
|
+
if (!frame) return this.#drop("repair:malformed");
|
|
26865
|
+
if (this.#repairPacketId === void 0) {
|
|
26866
|
+
this.#repairPacketId = frame.packetId;
|
|
26867
|
+
} else if (frame.packetId !== this.#repairPacketId) {
|
|
26868
|
+
return this.#drop("repair:foreign-packet-id");
|
|
26869
|
+
}
|
|
26870
|
+
if (frame.symbolData.byteLength !== this.symbolSize) return this.#drop("repair:symbol-size");
|
|
26871
|
+
if (frame.ssbLength > this.sourceSymbols) return this.#drop("repair:ssb-length");
|
|
26872
|
+
const start = frame.ssStart;
|
|
26873
|
+
let block = this.#blocks.get(start);
|
|
26874
|
+
if (block && block.ssbLength !== frame.ssbLength) return this.#drop("repair:conflicting-ssb-length");
|
|
26875
|
+
if (!block) {
|
|
26876
|
+
if (this.#settled.has(start)) return this.#drop("repair:block-settled");
|
|
26877
|
+
if (this.#behindHorizon(start)) return this.#drop("repair:behind-horizon");
|
|
26878
|
+
block = { ssbLength: frame.ssbLength, received: this.#countHeld(start, frame.ssbLength) };
|
|
26879
|
+
this.#blocks.set(start, block);
|
|
26880
|
+
}
|
|
26881
|
+
this.#noteNewest(serial32Add(start, frame.ssbLength - 1));
|
|
26882
|
+
if (block.received >= block.ssbLength) {
|
|
26883
|
+
this.#settleClean(start);
|
|
26884
|
+
this.#retireBehindHorizon();
|
|
26885
|
+
return [];
|
|
26886
|
+
}
|
|
26887
|
+
let output;
|
|
26888
|
+
try {
|
|
26889
|
+
output = decoder.add_repair(start, frame.ssbLength, frame.rsId, frame.symbolData, 0);
|
|
26890
|
+
} catch {
|
|
26891
|
+
return this.#drop("repair:decoder-refused");
|
|
26892
|
+
}
|
|
26893
|
+
this.#stats.repairSymbols++;
|
|
26894
|
+
const recovered = output ? this.#settleDecoded(start, block, output) : [];
|
|
26895
|
+
this.#retireBehindHorizon();
|
|
26896
|
+
return recovered;
|
|
26897
|
+
}
|
|
26898
|
+
/**
|
|
26899
|
+
* Frees the decoder and every block. Blocks still unsettled are counted as
|
|
26900
|
+
* released, not failed: nothing proved them unrecoverable. Idempotent;
|
|
26901
|
+
* returns whether this call released anything.
|
|
26902
|
+
*/
|
|
26903
|
+
release() {
|
|
26904
|
+
const decoder = this.#decoder;
|
|
26905
|
+
if (!decoder) return false;
|
|
26906
|
+
this.#decoder = null;
|
|
26907
|
+
this.#stats.blocksReleased += this.#blocks.size;
|
|
26908
|
+
this.#blocks.clear();
|
|
26909
|
+
this.#settled.clear();
|
|
26910
|
+
this.#have.clear();
|
|
26911
|
+
decoder.free();
|
|
26912
|
+
return true;
|
|
26913
|
+
}
|
|
26914
|
+
#drop(reason) {
|
|
26915
|
+
this.#stats.dropped[reason] = (this.#stats.dropped[reason] ?? 0) + 1;
|
|
26916
|
+
return [];
|
|
26917
|
+
}
|
|
26918
|
+
#noteNewest(ssId) {
|
|
26919
|
+
if (this.#newest === void 0 || serial32Precedes(this.#newest, ssId)) this.#newest = ssId;
|
|
26920
|
+
}
|
|
26921
|
+
#blockStartOf(ssId) {
|
|
26922
|
+
for (const [start, block] of this.#blocks) {
|
|
26923
|
+
if (isoBlockContains(start, block.ssbLength, ssId)) return start;
|
|
26924
|
+
}
|
|
26925
|
+
return void 0;
|
|
26926
|
+
}
|
|
26927
|
+
#countHeld(start, ssbLength) {
|
|
26928
|
+
let held = 0;
|
|
26929
|
+
for (let i = 0; i < ssbLength; i++) {
|
|
26930
|
+
if (this.#have.has(serial32Add(start, i))) held++;
|
|
26931
|
+
}
|
|
26932
|
+
return held;
|
|
26933
|
+
}
|
|
26934
|
+
/** The decoder's own rule: more than its retention behind, counted from below. */
|
|
26935
|
+
#behindHorizon(start) {
|
|
26936
|
+
const newest = this.#newest;
|
|
26937
|
+
if (newest === void 0) return false;
|
|
26938
|
+
return isoBlocksBehindLowerBound(start, newest, this.sourceSymbols) > this.retentionBlocks;
|
|
26939
|
+
}
|
|
26940
|
+
#settle(start) {
|
|
26941
|
+
this.#blocks.delete(start);
|
|
26942
|
+
this.#settled.add(start);
|
|
26943
|
+
}
|
|
26944
|
+
#settleClean(start) {
|
|
26945
|
+
if (!this.#blocks.has(start)) return;
|
|
26946
|
+
this.#settle(start);
|
|
26947
|
+
this.#stats.blocksClean++;
|
|
26948
|
+
try {
|
|
26949
|
+
this.#decoder?.cleanup_blocks_detailed(Uint32Array.of(start));
|
|
26950
|
+
} catch {
|
|
26951
|
+
}
|
|
26952
|
+
}
|
|
26953
|
+
/**
|
|
26954
|
+
* The decoder returns a completed block as its K' ssbg_mode1 symbols,
|
|
26955
|
+
* concatenated: split by T, trim by each symbol's length field, and hand
|
|
26956
|
+
* back the packets the parser does not have yet.
|
|
26957
|
+
*/
|
|
26958
|
+
#settleDecoded(start, block, output) {
|
|
26959
|
+
this.#settle(start);
|
|
26960
|
+
if (output.byteLength !== block.ssbLength * this.symbolSize) {
|
|
26961
|
+
this.#stats.blocksFailed++;
|
|
26962
|
+
this.#stats.packetsLost += block.ssbLength - block.received;
|
|
26963
|
+
this.#drop("block:decoded-length");
|
|
26964
|
+
return [];
|
|
26965
|
+
}
|
|
26966
|
+
const recovered = [];
|
|
26967
|
+
let refused = 0;
|
|
26968
|
+
for (let i = 0; i < block.ssbLength; i++) {
|
|
26969
|
+
const ssId = serial32Add(start, i);
|
|
26970
|
+
if (this.#have.has(ssId)) continue;
|
|
26971
|
+
const symbol = output.subarray(i * this.symbolSize, (i + 1) * this.symbolSize);
|
|
26972
|
+
const packet = trimSsbg1SourceSymbol(symbol);
|
|
26973
|
+
if (!packet) {
|
|
26974
|
+
refused++;
|
|
26975
|
+
continue;
|
|
26976
|
+
}
|
|
26977
|
+
this.#have.add(ssId);
|
|
26978
|
+
recovered.push(packet.slice());
|
|
26979
|
+
}
|
|
26980
|
+
if (refused > 0) {
|
|
26981
|
+
this.#stats.blocksFailed++;
|
|
26982
|
+
this.#stats.packetsLost += refused;
|
|
26983
|
+
this.#drop("block:bad-ssbg1-symbol");
|
|
26984
|
+
} else if (recovered.length === 0) {
|
|
26985
|
+
this.#stats.blocksClean++;
|
|
26986
|
+
} else {
|
|
26987
|
+
this.#stats.blocksRecovered++;
|
|
26988
|
+
}
|
|
26989
|
+
this.#stats.packetsRecovered += recovered.length;
|
|
26990
|
+
return recovered;
|
|
26991
|
+
}
|
|
26992
|
+
/**
|
|
26993
|
+
* Retires every block, and every SS_ID the session remembers, that the
|
|
26994
|
+
* newest SS_ID has moved past the retention. An unsettled block retired
|
|
26995
|
+
* here is a failure: more of its sources were lost than its repair could
|
|
26996
|
+
* restore, or its repair never arrived.
|
|
26997
|
+
*/
|
|
26998
|
+
#retireBehindHorizon() {
|
|
26999
|
+
const decoder = this.#decoder;
|
|
27000
|
+
const newest = this.#newest;
|
|
27001
|
+
if (!decoder || newest === void 0) return;
|
|
27002
|
+
try {
|
|
27003
|
+
decoder.cleanup_by_ss_start(newest);
|
|
27004
|
+
} catch {
|
|
27005
|
+
}
|
|
27006
|
+
for (const [start, block] of this.#blocks) {
|
|
27007
|
+
if (!this.#behindHorizon(start)) continue;
|
|
27008
|
+
this.#settle(start);
|
|
27009
|
+
this.#stats.blocksFailed++;
|
|
27010
|
+
this.#stats.packetsLost += block.ssbLength - block.received;
|
|
27011
|
+
}
|
|
27012
|
+
const prunedAt = this.#prunedAt;
|
|
27013
|
+
if (prunedAt !== void 0 && serial32Distance(prunedAt, newest) < this.sourceSymbols) return;
|
|
27014
|
+
this.#prunedAt = newest;
|
|
27015
|
+
for (const ssId of this.#have) {
|
|
27016
|
+
if (this.#behindHorizon(ssId)) this.#have.delete(ssId);
|
|
27017
|
+
}
|
|
27018
|
+
for (const start of this.#settled) {
|
|
27019
|
+
if (this.#behindHorizon(start)) this.#settled.delete(start);
|
|
27020
|
+
}
|
|
27021
|
+
}
|
|
27022
|
+
};
|
|
27023
|
+
function requirePositiveInteger(value, path) {
|
|
27024
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
27025
|
+
throw new Error(`MmtpFecSession: ${path} must be a positive integer (got ${String(value)})`);
|
|
27026
|
+
}
|
|
27027
|
+
return value;
|
|
27028
|
+
}
|
|
27029
|
+
function requireNumber(value, path) {
|
|
27030
|
+
if (typeof value !== "number") {
|
|
27031
|
+
throw new Error(`MmtpFecSession: ${path} is required (got ${String(value)}); it is never defaulted`);
|
|
27032
|
+
}
|
|
27033
|
+
return value;
|
|
27034
|
+
}
|
|
27035
|
+
|
|
26711
27036
|
// src/repair-fetch.ts
|
|
26712
27037
|
var MOQT_PRIORITY_MAX = 255;
|
|
26713
27038
|
var SOURCE_MEDIA_PRIORITY_MAX = REPAIR_PRIORITY_MIN - 1;
|
|
@@ -26788,7 +27113,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26788
27113
|
const admit = (entry, now) => {
|
|
26789
27114
|
const budgetMs = entry.deadlineAt - now;
|
|
26790
27115
|
const rttMs = readRtt();
|
|
26791
|
-
if (rttMs !== null && rttMs < budgetMs) return
|
|
27116
|
+
if (rttMs !== null && rttMs < budgetMs) return rttMs;
|
|
26792
27117
|
retire(entry);
|
|
26793
27118
|
releaseHold(entry);
|
|
26794
27119
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
@@ -26799,7 +27124,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26799
27124
|
entry.packetId,
|
|
26800
27125
|
entry.catalogTrackName
|
|
26801
27126
|
);
|
|
26802
|
-
return
|
|
27127
|
+
return null;
|
|
26803
27128
|
};
|
|
26804
27129
|
const retire = (entry) => {
|
|
26805
27130
|
if (entries.get(entry.key) === entry) entries.delete(entry.key);
|
|
@@ -26831,9 +27156,17 @@ function wireRepairFetch(mc, opts) {
|
|
|
26831
27156
|
return derived.kind === "omit" ? { subscriberPriority: void 0 } : null;
|
|
26832
27157
|
};
|
|
26833
27158
|
const start = (entry, counted = true) => {
|
|
26834
|
-
|
|
27159
|
+
const now = performance.now();
|
|
27160
|
+
const rttMs = admit(entry, now);
|
|
27161
|
+
if (rttMs === null) return;
|
|
26835
27162
|
if (counted) entry.attempts++;
|
|
26836
|
-
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName
|
|
27163
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
27164
|
+
rttMs,
|
|
27165
|
+
budgetMs: entry.deadlineAt - now,
|
|
27166
|
+
delayMs: entry.delayMs,
|
|
27167
|
+
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
27168
|
+
bound: entry.bound
|
|
27169
|
+
});
|
|
26837
27170
|
const run = { controller: new AbortController(), stopped: null };
|
|
26838
27171
|
entry.running = run;
|
|
26839
27172
|
mc.fecManager.holdBlockForRepair(
|
|
@@ -26980,6 +27313,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
26980
27313
|
);
|
|
26981
27314
|
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
26982
27315
|
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
27316
|
+
entry2.anchorAt = promotedDeadline.anchorAt;
|
|
27317
|
+
entry2.delayMs = promotedDeadline.delayMs;
|
|
27318
|
+
entry2.bound = promotedDeadline.bound;
|
|
26983
27319
|
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
26984
27320
|
}
|
|
26985
27321
|
if (entry2.running) {
|
|
@@ -27005,7 +27341,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
27005
27341
|
if (waitMs === void 0) return null;
|
|
27006
27342
|
const waitDeadlineAt = now + waitMs;
|
|
27007
27343
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
27008
|
-
if (anchor === void 0)
|
|
27344
|
+
if (anchor === void 0) {
|
|
27345
|
+
return { deadlineAt: waitDeadlineAt, extensionMs: 0, anchorAt: null, delayMs: null, bound: "wait" };
|
|
27346
|
+
}
|
|
27009
27347
|
let delayMs;
|
|
27010
27348
|
try {
|
|
27011
27349
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -27016,12 +27354,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
27016
27354
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
27017
27355
|
if (retentionMs === void 0) return null;
|
|
27018
27356
|
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
27019
|
-
const
|
|
27020
|
-
|
|
27357
|
+
const at = (delay, delayBound) => {
|
|
27358
|
+
const presentAt = Math.min(anchor + delay, ceilingAt);
|
|
27359
|
+
if (waitDeadlineAt >= presentAt) return { deadlineAt: waitDeadlineAt, bound: "wait" };
|
|
27360
|
+
return { deadlineAt: presentAt, bound: anchor + delay <= ceilingAt ? delayBound : "retention" };
|
|
27361
|
+
};
|
|
27362
|
+
const base = at(delayMs, "presentation");
|
|
27021
27363
|
const budgetMs = keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) && groupCanComplete(sbn, packetId, catalogTrackName) ? readKeyframeBudget(packetId, catalogTrackName) : null;
|
|
27022
|
-
if (budgetMs === null || budgetMs <= delayMs) return {
|
|
27023
|
-
const extended =
|
|
27024
|
-
return {
|
|
27364
|
+
if (budgetMs === null || budgetMs <= delayMs) return { ...base, extensionMs: 0, anchorAt: anchor, delayMs };
|
|
27365
|
+
const extended = at(budgetMs, "keyframe");
|
|
27366
|
+
return {
|
|
27367
|
+
...extended,
|
|
27368
|
+
extensionMs: extended.deadlineAt - base.deadlineAt,
|
|
27369
|
+
anchorAt: anchor,
|
|
27370
|
+
delayMs: budgetMs
|
|
27371
|
+
};
|
|
27025
27372
|
};
|
|
27026
27373
|
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
27027
27374
|
try {
|
|
@@ -27098,6 +27445,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
27098
27445
|
priority,
|
|
27099
27446
|
subscriberPriority: wire.subscriberPriority,
|
|
27100
27447
|
deadlineAt: deadline.deadlineAt,
|
|
27448
|
+
anchorAt: deadline.anchorAt,
|
|
27449
|
+
delayMs: deadline.delayMs,
|
|
27450
|
+
bound: deadline.bound,
|
|
27101
27451
|
order: enqueueOrder++,
|
|
27102
27452
|
attempts: 0,
|
|
27103
27453
|
running: null
|
|
@@ -27153,6 +27503,7 @@ export {
|
|
|
27153
27503
|
MfuReassemblyError,
|
|
27154
27504
|
MmtpContainerParser,
|
|
27155
27505
|
MmtpDecodePipeline,
|
|
27506
|
+
MmtpFecSession,
|
|
27156
27507
|
MmtpRouter,
|
|
27157
27508
|
MmtpToCmaf,
|
|
27158
27509
|
MulticastContainerContractError,
|