@blockcast/mmt-container 0.1.0-main.c71423b8a4e4 → 0.1.0-main.ce3c8aeb7f68
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/align.d.ts +6 -2
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js.map +2 -2
- package/dist/audio-ring-buffer.js +23 -36
- package/dist/audio-ring-buffer.js.map +1 -1
- package/dist/browser-runtime.js +6865 -6485
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +3 -1
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +21 -2
- package/dist/carp-catalog.js.map +4 -4
- package/dist/catalog-fec-params.js +10 -0
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/cmaf-block-assembler.d.ts +42 -0
- package/dist/cmaf-block-assembler.d.ts.map +1 -1
- package/dist/cmaf-block-assembler.js +542 -535
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/cmaf-group-batcher.js +27 -46
- package/dist/cmaf-group-batcher.js.map +2 -2
- package/dist/cmcd-producer.js +45 -66
- package/dist/cmcd-producer.js.map +1 -1
- package/dist/fec-manager.d.ts +13 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +1151 -871
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-starvation-detector.js +25 -40
- package/dist/fec-starvation-detector.js.map +1 -1
- package/dist/fec-worker-setup.js +242 -225
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-bmff-timing.js +63 -88
- package/dist/iso-bmff-timing.js.map +1 -1
- package/dist/loc.js +7 -4
- package/dist/loc.js.map +1 -1
- package/dist/manifest-auth-plan.js +292 -311
- package/dist/manifest-auth-plan.js.map +1 -1
- package/dist/media-router.d.ts +0 -99
- package/dist/media-router.d.ts.map +1 -1
- package/dist/media-router.js +270 -504
- package/dist/media-router.js.map +3 -3
- package/dist/mfu-reassembler.js +597 -607
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +37 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +1531 -1522
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +179 -102
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +1641 -1651
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +34 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +3676 -3390
- package/dist/mmtp-router.js.map +3 -3
- package/dist/mmtp-to-cmaf.d.ts +7 -1
- package/dist/mmtp-to-cmaf.d.ts.map +1 -1
- package/dist/mmtp-to-cmaf.js +109 -134
- package/dist/mmtp-to-cmaf.js.map +2 -2
- package/dist/multicast-input.d.ts +7 -35
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +21 -2
- package/dist/multicast-input.js.map +4 -4
- package/dist/multicast-manager.d.ts +10 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +5584 -4961
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +7 -0
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +369 -421
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +53 -30
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.js +2096 -2097
- package/dist/no-modules.js.map +3 -3
- package/dist/sample-combiner.js +118 -139
- package/dist/sample-combiner.js.map +1 -1
- package/dist/signaling.js.map +2 -2
- package/dist/source-auth.js +353 -382
- package/dist/source-auth.js.map +1 -1
- package/dist/switching-set-alignment.js +14 -29
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +17 -11
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/track-pipeline-setup.js +105 -125
- package/dist/track-pipeline-setup.js.map +1 -1
- package/dist/track-pipeline.js +107 -127
- package/dist/track-pipeline.js.map +1 -1
- package/dist/track-session.d.ts +16 -0
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +230 -243
- package/dist/track-session.js.map +2 -2
- package/dist/transport-pool.js +24 -38
- package/dist/transport-pool.js.map +1 -1
- package/dist/wasm-mfu-reassembler.d.ts +6 -1
- package/dist/wasm-mfu-reassembler.d.ts.map +1 -1
- package/dist/wasm-mfu-reassembler.js +127 -144
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +1659 -1650
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/node_modules/@blockcast/fec-worker/README.md +5 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +8 -2
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +89 -16
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +48 -3
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +55 -8
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +2 -2
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts +1 -1
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -1
- package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +97 -17
- package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +46 -2
- package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +78 -10
- package/node_modules/@blockcast/fec-worker/src/index.ts +2 -0
- package/node_modules/@blockcast/mmt-base/README.md +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
- package/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
- package/package.json +7 -6
- package/schemas/catalog.schema.json +1 -1
- package/src/align.ts +6 -2
- package/src/carp-catalog.ts +13 -3
- package/src/cmaf-block-assembler.ts +90 -81
- package/src/fec-manager.ts +530 -146
- package/src/index.ts +2 -2
- package/src/media-router.ts +0 -397
- package/src/mmtp-container-parser.ts +97 -21
- package/src/mmtp-router.ts +302 -125
- package/src/mmtp-to-cmaf.ts +21 -7
- package/src/multicast-input.ts +23 -3
- package/src/multicast-manager.ts +83 -11
- package/src/multicast-transport.ts +56 -17
- package/src/track-session.ts +16 -0
- package/src/wasm-mfu-reassembler.ts +40 -24
- package/test-vectors/catalog/README.md +2 -0
- package/test-vectors/catalog/negative/multicast-packet-id-signaling.json +26 -0
- package/test-vectors/catalog-validation.json +11 -0
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
10
|
-
set _(value) {
|
|
11
|
-
__privateSet(obj, member, value, setter);
|
|
12
|
-
},
|
|
13
|
-
get _() {
|
|
14
|
-
return __privateGet(obj, member, getter);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
1
|
// ../mmt-alta-parse/dist/index.js
|
|
19
2
|
var MPU_HEADER_SIZE = 8;
|
|
20
3
|
var MPU_LENGTH_FIELD_SIZE = 2;
|
|
@@ -1900,52 +1883,61 @@ function asNumber(value) {
|
|
|
1900
1883
|
function timestampU32(timestamp) {
|
|
1901
1884
|
return Number(BigInt.asUintN(32, timestamp));
|
|
1902
1885
|
}
|
|
1903
|
-
var _bindings, _core, _now, _timeoutMs, _cleanupTimer, _nextStreamIdentity, _streamIdentityByKey, _streamNameByIdentity, _coreTotalFragments, _rejectedBeforeCore, _rejectedFragments, _WasmMfuReassembler_instances, refreshStats_fn, streamIdentityFor_fn, asReassemblyError_fn, scheduleCleanup_fn, clearCleanupTimer_fn;
|
|
1904
1886
|
var WasmMfuReassembler = class {
|
|
1887
|
+
#bindings;
|
|
1888
|
+
#core;
|
|
1889
|
+
#now;
|
|
1890
|
+
#timeoutMs;
|
|
1891
|
+
#cleanupTimer = null;
|
|
1892
|
+
#nextStreamIdentity = 1;
|
|
1893
|
+
#streamIdentityByKey = /* @__PURE__ */ new Map();
|
|
1894
|
+
#streamNameByIdentity = /* @__PURE__ */ new Map();
|
|
1895
|
+
// Every fragment handed to the core, including ones it rejected. This is
|
|
1896
|
+
// what `coreTotal + rejectedBeforeCore` computed with a core stats() round
|
|
1897
|
+
// trip before and after every fragment (BLO-36599).
|
|
1898
|
+
#offeredFragments = 0;
|
|
1899
|
+
#rejectedFragments = 0;
|
|
1900
|
+
#stats = {
|
|
1901
|
+
totalFragments: 0,
|
|
1902
|
+
reassembledMFUs: 0,
|
|
1903
|
+
rejectedFragments: 0,
|
|
1904
|
+
timedOutMFUs: 0,
|
|
1905
|
+
evictedMemoryLimit: 0,
|
|
1906
|
+
outOfOrderFragments: 0
|
|
1907
|
+
};
|
|
1905
1908
|
constructor(options) {
|
|
1906
|
-
__privateAdd(this, _WasmMfuReassembler_instances);
|
|
1907
|
-
__privateAdd(this, _bindings);
|
|
1908
|
-
__privateAdd(this, _core);
|
|
1909
|
-
__privateAdd(this, _now);
|
|
1910
|
-
__privateAdd(this, _timeoutMs);
|
|
1911
|
-
__privateAdd(this, _cleanupTimer, null);
|
|
1912
|
-
__privateAdd(this, _nextStreamIdentity, 1);
|
|
1913
|
-
__privateAdd(this, _streamIdentityByKey, /* @__PURE__ */ new Map());
|
|
1914
|
-
__privateAdd(this, _streamNameByIdentity, /* @__PURE__ */ new Map());
|
|
1915
|
-
__privateAdd(this, _coreTotalFragments, 0);
|
|
1916
|
-
__privateAdd(this, _rejectedBeforeCore, 0);
|
|
1917
|
-
__privateAdd(this, _rejectedFragments, 0);
|
|
1918
|
-
this.stats = {
|
|
1919
|
-
totalFragments: 0,
|
|
1920
|
-
reassembledMFUs: 0,
|
|
1921
|
-
rejectedFragments: 0,
|
|
1922
|
-
timedOutMFUs: 0,
|
|
1923
|
-
evictedMemoryLimit: 0,
|
|
1924
|
-
outOfOrderFragments: 0
|
|
1925
|
-
};
|
|
1926
1909
|
const maxBuffered = options.maxBuffered ?? 100;
|
|
1927
1910
|
if (!Number.isInteger(maxBuffered) || maxBuffered <= 0) {
|
|
1928
1911
|
throw new Error("[WasmMfuReassembler] maxBuffered must be a positive integer");
|
|
1929
1912
|
}
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1913
|
+
this.#bindings = options.bindings;
|
|
1914
|
+
this.#timeoutMs = options.timeoutMs;
|
|
1915
|
+
this.#now = options.now ?? (() => globalThis.performance?.now() ?? Date.now());
|
|
1916
|
+
this.#core = options.timeoutMs === null ? options.bindings.MmtReassembler.clock_free(maxBuffered) : new options.bindings.MmtReassembler(options.timeoutMs, maxBuffered);
|
|
1934
1917
|
}
|
|
1935
1918
|
get timeoutMs() {
|
|
1936
|
-
return
|
|
1919
|
+
return this.#timeoutMs;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Host-observable reassembly statistics, read from the core when asked.
|
|
1923
|
+
* Reading them is a wasm crossing plus six counter getters, so neither
|
|
1924
|
+
* addFragment nor the router's per-packet path refreshes them (BLO-36599).
|
|
1925
|
+
*/
|
|
1926
|
+
get stats() {
|
|
1927
|
+
this.#refreshStats();
|
|
1928
|
+
return this.#stats;
|
|
1937
1929
|
}
|
|
1938
1930
|
set timeoutMs(timeoutMs) {
|
|
1939
1931
|
if (timeoutMs !== null && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
|
|
1940
1932
|
throw new Error("[WasmMfuReassembler] timeoutMs must be a finite number > 0");
|
|
1941
1933
|
}
|
|
1942
|
-
|
|
1943
|
-
if (timeoutMs === null)
|
|
1944
|
-
else
|
|
1945
|
-
|
|
1934
|
+
this.#timeoutMs = timeoutMs;
|
|
1935
|
+
if (timeoutMs === null) this.#core.set_clock_free();
|
|
1936
|
+
else this.#core.set_timeout(Math.ceil(timeoutMs));
|
|
1937
|
+
this.#scheduleCleanup();
|
|
1946
1938
|
}
|
|
1947
1939
|
addFragment(fragment) {
|
|
1948
|
-
const wasmFragment = new
|
|
1940
|
+
const wasmFragment = new this.#bindings.MfuFragmentJs(
|
|
1949
1941
|
fragment.mpuSequenceNumber,
|
|
1950
1942
|
fragment.fragmentationIndicator,
|
|
1951
1943
|
fragment.fragmentCounter,
|
|
@@ -1971,30 +1963,26 @@ var WasmMfuReassembler = class {
|
|
|
1971
1963
|
if (fragment.source !== void 0) {
|
|
1972
1964
|
wasmFragment.set_attribution(fragment.source === "multicast" ? 1 : 2);
|
|
1973
1965
|
}
|
|
1974
|
-
const streamIdentity =
|
|
1966
|
+
const streamIdentity = this.#streamIdentityFor(fragment);
|
|
1975
1967
|
if (streamIdentity !== void 0) {
|
|
1976
1968
|
wasmFragment.set_stream_identity(streamIdentity);
|
|
1977
1969
|
}
|
|
1978
1970
|
let output;
|
|
1979
|
-
const coreTotalBefore = __privateGet(this, _coreTotalFragments);
|
|
1980
1971
|
try {
|
|
1981
|
-
output =
|
|
1972
|
+
output = this.#core.add_fragment(this.#now(), wasmFragment);
|
|
1982
1973
|
} catch (error) {
|
|
1983
|
-
const rejection =
|
|
1974
|
+
const rejection = this.#asReassemblyError(error);
|
|
1984
1975
|
if (rejection === null) throw error;
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
this.stats.totalFragments = __privateGet(this, _coreTotalFragments) + __privateGet(this, _rejectedBeforeCore);
|
|
1989
|
-
this.stats.rejectedFragments = __privateGet(this, _rejectedFragments);
|
|
1990
|
-
__privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
|
|
1976
|
+
this.#offeredFragments++;
|
|
1977
|
+
this.#rejectedFragments++;
|
|
1978
|
+
this.#ensureCleanupArmed();
|
|
1991
1979
|
throw rejection;
|
|
1992
1980
|
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1981
|
+
this.#offeredFragments++;
|
|
1982
|
+
this.#ensureCleanupArmed();
|
|
1995
1983
|
if (!output) return null;
|
|
1996
1984
|
try {
|
|
1997
|
-
const catalogTrackName = output.stream_identity === void 0 ? void 0 :
|
|
1985
|
+
const catalogTrackName = output.stream_identity === void 0 ? void 0 : this.#streamNameByIdentity.get(output.stream_identity);
|
|
1998
1986
|
const packetSequenceNumbers = output.packet_sequence_numbers === void 0 ? void 0 : Array.from(output.packet_sequence_numbers);
|
|
1999
1987
|
const repairedPacketSequenceNumbers = output.repaired_packet_sequence_numbers === void 0 ? void 0 : Array.from(output.repaired_packet_sequence_numbers);
|
|
2000
1988
|
return {
|
|
@@ -2024,105 +2012,100 @@ var WasmMfuReassembler = class {
|
|
|
2024
2012
|
}
|
|
2025
2013
|
}
|
|
2026
2014
|
flush() {
|
|
2027
|
-
|
|
2028
|
-
|
|
2015
|
+
this.#clearCleanupTimer();
|
|
2016
|
+
this.#core.flush();
|
|
2029
2017
|
}
|
|
2030
2018
|
resetStream(catalogTrackName) {
|
|
2031
|
-
const streamIdentity =
|
|
2019
|
+
const streamIdentity = this.#streamIdentityByKey.get(`catalog:${catalogTrackName}`);
|
|
2032
2020
|
if (streamIdentity === void 0) return;
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
__privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
|
|
2021
|
+
this.#clearCleanupTimer();
|
|
2022
|
+
this.#core.reset_stream(streamIdentity);
|
|
2023
|
+
this.#scheduleCleanup();
|
|
2037
2024
|
}
|
|
2038
2025
|
reset() {
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
__privateSet(this, _rejectedFragments, 0);
|
|
2047
|
-
__privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
|
|
2026
|
+
this.#clearCleanupTimer();
|
|
2027
|
+
this.#core.reset();
|
|
2028
|
+
this.#nextStreamIdentity = 1;
|
|
2029
|
+
this.#streamIdentityByKey.clear();
|
|
2030
|
+
this.#streamNameByIdentity.clear();
|
|
2031
|
+
this.#offeredFragments = 0;
|
|
2032
|
+
this.#rejectedFragments = 0;
|
|
2048
2033
|
}
|
|
2049
2034
|
get pendingCount() {
|
|
2050
|
-
return
|
|
2035
|
+
return this.#core.buffered_count;
|
|
2051
2036
|
}
|
|
2052
2037
|
getStatus() {
|
|
2053
|
-
|
|
2038
|
+
this.#refreshStats();
|
|
2054
2039
|
return {
|
|
2055
|
-
bufferedMFUs:
|
|
2056
|
-
pendingFragments:
|
|
2040
|
+
bufferedMFUs: this.#core.buffered_count,
|
|
2041
|
+
pendingFragments: this.#core.pending_fragment_count,
|
|
2057
2042
|
// Detailed fragment coordinates remain internal to the Rust core. Counts
|
|
2058
2043
|
// and health statistics stay available to MmtpRouter diagnostics.
|
|
2059
2044
|
pendingSamples: [],
|
|
2060
|
-
stats: { ...this
|
|
2045
|
+
stats: { ...this.#stats }
|
|
2061
2046
|
};
|
|
2062
2047
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2048
|
+
#refreshStats() {
|
|
2049
|
+
const stats = this.#core.stats();
|
|
2050
|
+
this.#stats.totalFragments = this.#offeredFragments;
|
|
2051
|
+
this.#stats.reassembledMFUs = asNumber(stats.reassembled_mfus);
|
|
2052
|
+
this.#stats.rejectedFragments = this.#rejectedFragments;
|
|
2053
|
+
this.#stats.timedOutMFUs = asNumber(stats.timed_out_mfus);
|
|
2054
|
+
this.#stats.evictedMemoryLimit = asNumber(stats.evicted_memory_limit) + asNumber(stats.evicted_data_units ?? 0);
|
|
2055
|
+
this.#stats.outOfOrderFragments = asNumber(stats.out_of_order_fragments);
|
|
2056
|
+
stats.free?.();
|
|
2057
|
+
}
|
|
2058
|
+
#streamIdentityFor(fragment) {
|
|
2059
|
+
const key = fragment.catalogTrackName !== void 0 ? `catalog:${fragment.catalogTrackName}` : fragment.packetId !== void 0 ? `packet:${fragment.packetId}` : void 0;
|
|
2060
|
+
if (key === void 0) return void 0;
|
|
2061
|
+
const existing = this.#streamIdentityByKey.get(key);
|
|
2062
|
+
if (existing !== void 0) return existing;
|
|
2063
|
+
const identity = this.#nextStreamIdentity++;
|
|
2064
|
+
this.#streamIdentityByKey.set(key, identity);
|
|
2065
|
+
if (fragment.catalogTrackName !== void 0) {
|
|
2066
|
+
this.#streamNameByIdentity.set(identity, fragment.catalogTrackName);
|
|
2067
|
+
}
|
|
2068
|
+
return identity;
|
|
2069
|
+
}
|
|
2070
|
+
#asReassemblyError(error) {
|
|
2071
|
+
if (typeof error !== "object" && typeof error !== "function" || error === null) return null;
|
|
2072
|
+
const code = Reflect.get(error, "code");
|
|
2073
|
+
if (!isMfuReassemblyErrorCode(code)) return null;
|
|
2074
|
+
const message = Reflect.get(error, "message");
|
|
2075
|
+
return new MfuReassemblyError(
|
|
2076
|
+
code,
|
|
2077
|
+
typeof message === "string" ? message : `MFU reassembly rejected: ${code}`
|
|
2078
|
+
);
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Arm the cleanup wake-up only when none is armed. A fragment can only add
|
|
2082
|
+
* a data unit whose deadline is its own arrival plus the one configured
|
|
2083
|
+
* timeout, which is never earlier than the deadline already armed; the
|
|
2084
|
+
* armed wake-up re-reads the core's next deadline after cleanup. Only a
|
|
2085
|
+
* timeout change can move the next deadline earlier, and the timeoutMs
|
|
2086
|
+
* setter re-arms for that. This replaces a next_timeout_at() crossing and a
|
|
2087
|
+
* clear+set timer pair on every fragment (BLO-36599).
|
|
2088
|
+
*/
|
|
2089
|
+
#ensureCleanupArmed() {
|
|
2090
|
+
if (this.#cleanupTimer === null) this.#scheduleCleanup();
|
|
2091
|
+
}
|
|
2092
|
+
#scheduleCleanup() {
|
|
2093
|
+
this.#clearCleanupTimer();
|
|
2094
|
+
if (this.#timeoutMs === null) return;
|
|
2095
|
+
const next = this.#core.next_timeout_at();
|
|
2096
|
+
if (next === void 0) return;
|
|
2097
|
+
const delay = Math.max(0, Math.ceil(next - this.#now()));
|
|
2098
|
+
this.#cleanupTimer = setTimeout(() => {
|
|
2099
|
+
this.#cleanupTimer = null;
|
|
2100
|
+
this.#core.cleanup_timeouts(this.#now());
|
|
2101
|
+
this.#scheduleCleanup();
|
|
2102
|
+
}, delay);
|
|
2103
|
+
}
|
|
2104
|
+
#clearCleanupTimer() {
|
|
2105
|
+
if (this.#cleanupTimer === null) return;
|
|
2106
|
+
clearTimeout(this.#cleanupTimer);
|
|
2107
|
+
this.#cleanupTimer = null;
|
|
2096
2108
|
}
|
|
2097
|
-
return identity;
|
|
2098
|
-
};
|
|
2099
|
-
asReassemblyError_fn = function(error) {
|
|
2100
|
-
if (typeof error !== "object" && typeof error !== "function" || error === null) return null;
|
|
2101
|
-
const code = Reflect.get(error, "code");
|
|
2102
|
-
if (!isMfuReassemblyErrorCode(code)) return null;
|
|
2103
|
-
const message = Reflect.get(error, "message");
|
|
2104
|
-
return new MfuReassemblyError(
|
|
2105
|
-
code,
|
|
2106
|
-
typeof message === "string" ? message : `MFU reassembly rejected: ${code}`
|
|
2107
|
-
);
|
|
2108
|
-
};
|
|
2109
|
-
scheduleCleanup_fn = function() {
|
|
2110
|
-
__privateMethod(this, _WasmMfuReassembler_instances, clearCleanupTimer_fn).call(this);
|
|
2111
|
-
if (__privateGet(this, _timeoutMs) === null) return;
|
|
2112
|
-
const next = __privateGet(this, _core).next_timeout_at();
|
|
2113
|
-
if (next === void 0) return;
|
|
2114
|
-
const delay = Math.max(0, Math.ceil(next - __privateGet(this, _now).call(this)));
|
|
2115
|
-
__privateSet(this, _cleanupTimer, setTimeout(() => {
|
|
2116
|
-
__privateSet(this, _cleanupTimer, null);
|
|
2117
|
-
__privateGet(this, _core).cleanup_timeouts(__privateGet(this, _now).call(this));
|
|
2118
|
-
__privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
|
|
2119
|
-
__privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
|
|
2120
|
-
}, delay));
|
|
2121
|
-
};
|
|
2122
|
-
clearCleanupTimer_fn = function() {
|
|
2123
|
-
if (__privateGet(this, _cleanupTimer) === null) return;
|
|
2124
|
-
clearTimeout(__privateGet(this, _cleanupTimer));
|
|
2125
|
-
__privateSet(this, _cleanupTimer, null);
|
|
2126
2109
|
};
|
|
2127
2110
|
function resolveGlobalMmtWasmBindings() {
|
|
2128
2111
|
const globals = globalThis;
|