@blockcast/mmt-container 0.4.0 → 0.4.1-main.2e0aa69d293d
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/README.md +37 -21
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +5070 -908
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +28 -7
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/cmcd-producer.d.ts +13 -1
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +115 -235
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +113 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +464 -66
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +3692 -1213
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +192 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +640 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +101 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +422 -189
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +94 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +746 -131
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +140 -12
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +4104 -605
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +16 -3
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +127 -240
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +5 -3
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +3643 -1197
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +90 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +160 -32
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -18
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +23 -1
- package/src/fec-manager.ts +378 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/held-layer-admission.ts +161 -0
- package/src/index.ts +32 -19
- package/src/iso-block-locator.ts +110 -7
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +606 -0
- package/src/mmtp-router.ts +453 -236
- package/src/multicast-auth-catalog.ts +196 -231
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +447 -53
- package/src/multicast-transport.ts +23 -5
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +306 -42
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +71 -4
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/dist/manifest-auth-plan.d.ts +0 -30
- package/dist/manifest-auth-plan.d.ts.map +0 -1
- package/dist/manifest-auth-plan.js +0 -1266
- package/dist/manifest-auth-plan.js.map +0 -7
- package/dist/source-auth.d.ts +0 -2
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -1209
- package/dist/source-auth.js.map +0 -7
- package/src/fec-codec.ts +0 -61
- package/src/manifest-auth-plan.ts +0 -107
- package/src/source-auth.ts +0 -1
- package/test-vectors/generate-source-auth-fixture.mjs +0 -114
- package/test-vectors/source-auth-v1.json +0 -61
package/dist/cmcd-producer.d.ts
CHANGED
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
* @see CDN+ Track D BLO-1044
|
|
14
14
|
*/
|
|
15
15
|
import type { FecTrackStats } from '@blockcast/fec-worker';
|
|
16
|
-
import type {
|
|
16
|
+
import type { FecFailClosedReason } from './fec-manager.js';
|
|
17
|
+
/** Source-auth counters for CMCD: records verified, and drops per reason. */
|
|
18
|
+
export interface ManifestVerificationStats {
|
|
19
|
+
verified: number;
|
|
20
|
+
failures: Record<string, number>;
|
|
21
|
+
}
|
|
17
22
|
/** Transport state snapshot, built by the player wiring layer from SocketPool. */
|
|
18
23
|
export interface TransportSnapshot {
|
|
19
24
|
transport: 'native' | 'amt' | 'moq';
|
|
@@ -76,6 +81,13 @@ export declare class CmcdProducer {
|
|
|
76
81
|
* `x-bc-switch-miscount` on snapshots when the counter is > 0.
|
|
77
82
|
*/
|
|
78
83
|
incrementSwitchMiscount(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Record that FEC failed closed at runtime (fec-01 6.3.9). Every later
|
|
86
|
+
* snapshot carries `x-bc-fec-fail-closed` (the reason code) and
|
|
87
|
+
* `x-bc-fec-fail-layer` (the held layer i whose total B_i was undercut), so a
|
|
88
|
+
* stream playing without FEC is told apart from one with no loss.
|
|
89
|
+
*/
|
|
90
|
+
updateFecFailClosed(reason: FecFailClosedReason): void;
|
|
79
91
|
updateManifestVerification(stats: ManifestVerificationStats): void;
|
|
80
92
|
/**
|
|
81
93
|
* One-shot emit of `x-bc-switch-drift-us` for a single misalignment event.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmcd-producer.d.ts","sourceRoot":"","sources":["../src/cmcd-producer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"cmcd-producer.d.ts","sourceRoot":"","sources":["../src/cmcd-producer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAM3D,6EAA6E;AAC7E,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED,kFAAkF;AAClF,MAAM,WAAW,iBAAiB;IAChC,SAAS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IAAI;IASvC;;;OAGG;IACH,uBAAuB,IAAI,IAAI;IAI/B;;;;;OAKG;IACH,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAItD,0BAA0B,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI;IAIlE;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAkBtC;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IA0CpC;;;OAGG;IACH,mBAAmB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI;IAoB1D;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI;CAsBpD"}
|
package/dist/cmcd-producer.js
CHANGED
|
@@ -44,6 +44,7 @@ var CmcdProducer = class {
|
|
|
44
44
|
#deltaFailRate = null;
|
|
45
45
|
#switchMiscount = 0;
|
|
46
46
|
#manifestStats = null;
|
|
47
|
+
#fecFailClosed = null;
|
|
47
48
|
constructor(options) {
|
|
48
49
|
this.#onCmcdParams = options.onCmcdParams;
|
|
49
50
|
this.#onCmcdPost = options.onCmcdPost;
|
|
@@ -85,6 +86,15 @@ var CmcdProducer = class {
|
|
|
85
86
|
incrementSwitchMiscount() {
|
|
86
87
|
this.#switchMiscount += 1;
|
|
87
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Record that FEC failed closed at runtime (fec-01 6.3.9). Every later
|
|
91
|
+
* snapshot carries `x-bc-fec-fail-closed` (the reason code) and
|
|
92
|
+
* `x-bc-fec-fail-layer` (the held layer i whose total B_i was undercut), so a
|
|
93
|
+
* stream playing without FEC is told apart from one with no loss.
|
|
94
|
+
*/
|
|
95
|
+
updateFecFailClosed(reason) {
|
|
96
|
+
this.#fecFailClosed = reason;
|
|
97
|
+
}
|
|
88
98
|
updateManifestVerification(stats) {
|
|
89
99
|
this.#manifestStats = stats;
|
|
90
100
|
}
|
|
@@ -122,6 +132,10 @@ var CmcdProducer = class {
|
|
|
122
132
|
if (this.#playMode !== null) {
|
|
123
133
|
params["x-bc-play-mode"] = this.#playMode;
|
|
124
134
|
}
|
|
135
|
+
if (this.#fecFailClosed) {
|
|
136
|
+
params["x-bc-fec-fail-closed"] = this.#fecFailClosed.code;
|
|
137
|
+
params["x-bc-fec-fail-layer"] = this.#fecFailClosed.layer;
|
|
138
|
+
}
|
|
125
139
|
if (this.#playMode !== null && this.#playMode !== "single-track" && this.#deltaFailRate !== null) {
|
|
126
140
|
params["x-bc-delta-fail-rate"] = parseFloat(this.#deltaFailRate.toFixed(4));
|
|
127
141
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cmcd-producer.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * CmcdProducer \u2014 transport-agnostic CMCD telemetry producer.\n *\n * Maps FecTrackStats snapshots and TransportSnapshot state to x-bc-*\n * CMCD vendor keys (proto tags 70-99). Fires callbacks for two delivery\n * channels: MoQ SUBSCRIBE params and multicast HTTP POST.\n *\n * Does NOT call fetch() or write to QUIC directly \u2014 the player wiring\n * layer is responsible for attaching params to SUBSCRIBE or POSTing\n * the payload to the CDN CMCD endpoint.\n *\n * @see docs/superpowers/specs/2026-04-15-iwa-multicast-stack-design.md \u00A73.3\n * @see CDN+ Track D BLO-1044\n */\n\nimport type { FecTrackStats } from '@blockcast/fec-worker'\nimport type { ManifestVerificationStats } from '@blockcast/mmt-manifest-verify'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Transport state snapshot, built by the player wiring layer from SocketPool. */\nexport interface TransportSnapshot {\n transport: 'native' | 'amt' | 'moq'\n /** IPv4/IPv6 multicast group address */\n multicastGroup?: string\n /** SSM source address */\n multicastSource?: string\n /** AMT relay address (omit when undefined) */\n amtRelay?: string\n}\n\n/** Transport transition event identifiers for x-bc-ct. */\nexport type TransportTransitionEvent = 'mc-start' | 'mc-to-uc' | 'amt-start'\n\n/**\n * Phase 14 play-mode state (D-12, x-bc-play-mode):\n * - `full` \u2014 base + delta both active\n * - `base-only` \u2014 delta fell back; base carries playback\n * - `single-track` \u2014 stream is not a multi-track switching set (legacy)\n */\nexport type PlayMode = 'full' | 'base-only' | 'single-track'\n\nconst PLAY_MODES: readonly PlayMode[] = ['full', 'base-only', 'single-track']\n\n/** CMCD vendor key map. Values are string, number, or boolean. */\nexport type CmcdParams = Record<string, string | number | boolean>\n\n/** Options for CmcdProducer construction. */\nexport interface CmcdProducerOptions {\n /** Fired on each snapshot and on transport transitions. Params for MoQ SUBSCRIBE. */\n onCmcdParams?: (params: CmcdParams) => void\n /** Fired on each snapshot and on transport transitions. RFC 9559 query-string for HTTP POST body. */\n onCmcdPost?: (payload: string) => void\n}\n\n/** Snapshot data passed to onSnapshot(). */\nexport interface SnapshotData {\n tracks: FecTrackStats[]\n timestampMs: number\n}\n\n/** Transport-only telemetry for receivers that do not own FEC track stats. */\nexport interface TransportOnlySnapshotData {\n transport: TransportSnapshot\n timestampMs: number\n playMode?: PlayMode\n switchMiscount?: number\n}\n\n// ---------------------------------------------------------------------------\n// Value sanitization (T-06-01: header injection mitigation)\n// ---------------------------------------------------------------------------\n\n/** Strip commas, newlines, and carriage returns from string values. */\nfunction sanitize(value: string): string {\n return value.replace(/[,\\r\\n]/g, '')\n}\n\n// ---------------------------------------------------------------------------\n// Key building (pure functions, no side effects)\n// ---------------------------------------------------------------------------\n\n/** Build FEC vendor keys from a FecTrackStats snapshot. */\nfunction buildFecParams(stats: FecTrackStats): CmcdParams {\n const params: CmcdParams = {}\n const cfg = stats.config\n\n params['x-bc-fec-algo'] = cfg.algorithm\n params['x-bc-fec-k'] = cfg.k\n // P as this receiver JOINED it: the worker is configured from\n // TrackSessionConfig.joinedRepairCount, the sum of repairSymbols over the\n // joined base layers. Not the catalog total, which a receiver on a clean path\n // does not receive, and never including a keyframe overlay (separate FEC\n // instance with its own RSB_length).\n params['x-bc-fec-p'] = cfg.repairCount\n params['x-bc-fec-recovery'] = parseFloat((stats.recoveryRate / 100).toFixed(4))\n\n return params\n}\n\n/** Build transport vendor keys from a TransportSnapshot. */\nfunction buildTransportParams(snap: TransportSnapshot | undefined): CmcdParams {\n if (!snap) return {}\n\n const params: CmcdParams = {}\n params['x-bc-transport'] = snap.transport\n\n if (snap.multicastGroup != null) {\n params['x-bc-multicast-group'] = snap.multicastGroup\n }\n if (snap.multicastSource != null) {\n params['x-bc-multicast-source'] = snap.multicastSource\n }\n if (snap.amtRelay != null) {\n params['x-bc-amt-relay'] = snap.amtRelay\n }\n\n return params\n}\n\n// ---------------------------------------------------------------------------\n// Query-string serialization (RFC 9559 \u00A72)\n// ---------------------------------------------------------------------------\n\n/**\n * Serialize CmcdParams to RFC 9559 query-string format.\n * Keys sorted for deterministic output. String values sanitized.\n */\nfunction formatQueryString(params: CmcdParams): string {\n return Object.keys(params)\n .sort()\n .map(key => {\n const v = params[key]\n if (typeof v === 'string') return `${key}=${sanitize(v)}`\n return `${key}=${v}`\n })\n .join(',')\n}\n\n// ---------------------------------------------------------------------------\n// CmcdProducer\n// ---------------------------------------------------------------------------\n\nexport class CmcdProducer {\n #onCmcdParams: ((params: CmcdParams) => void) | undefined\n #onCmcdPost: ((payload: string) => void) | undefined\n #transport: TransportSnapshot | undefined\n #lastStats: FecTrackStats | undefined\n // Phase 14 state \u2014 Plan 03 Task 2 (D-12, D-15).\n #playMode: PlayMode | null = null\n #deltaFailRate: number | null = null\n #switchMiscount = 0\n #manifestStats: ManifestVerificationStats | null = null\n\n constructor(options: CmcdProducerOptions) {\n this.#onCmcdParams = options.onCmcdParams\n this.#onCmcdPost = options.onCmcdPost\n }\n\n /** Update the stored transport state. Called by player wiring layer. */\n updateTransport(snapshot: TransportSnapshot): void {\n this.#transport = snapshot\n }\n\n /**\n * Set the current play-mode. Emitted as `x-bc-play-mode` on subsequent\n * snapshots. Throws on any value outside {'full','base-only','single-track'}\n * (CLAUDE.md: error on bad init).\n */\n updatePlayMode(mode: PlayMode): void {\n if (typeof mode !== 'string' || !PLAY_MODES.includes(mode as PlayMode)) {\n throw new Error(\n `[CmcdProducer] invalid play-mode \"${String(mode)}\"; expected one of: ${PLAY_MODES.join(', ')}`,\n )\n }\n this.#playMode = mode\n }\n\n /**\n * Set the delta-track FEC block-failure rate (0..1 inclusive). Emitted as\n * `x-bc-delta-fail-rate` on snapshots when play-mode is 'full' or 'base-only'.\n * Omitted on single-track streams.\n */\n updateDeltaFailRate(rate: number): void {\n if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0 || rate > 1) {\n throw new Error(\n `[CmcdProducer] invalid delta-fail-rate \"${String(rate)}\"; expected a finite number in [0, 1]`,\n )\n }\n this.#deltaFailRate = rate\n }\n\n /**\n * Bump the cumulative switching-set misalignment counter. Emitted as\n * `x-bc-switch-miscount` on snapshots when the counter is > 0.\n */\n incrementSwitchMiscount(): void {\n this.#switchMiscount += 1\n }\n\n updateManifestVerification(stats: ManifestVerificationStats): void {\n this.#manifestStats = stats\n }\n\n /**\n * One-shot emit of `x-bc-switch-drift-us` for a single misalignment event.\n * Does NOT mutate snapshot state \u2014 subsequent onSnapshot() calls will not\n * include the drift key until the next emitSwitchDrift(). Mirrors the\n * existing onTransition() pattern.\n */\n emitSwitchDrift(driftUs: number): void {\n if (\n typeof driftUs !== 'number' ||\n !Number.isFinite(driftUs) ||\n driftUs < 0\n ) {\n throw new Error(\n `[CmcdProducer] invalid drift-us \"${String(driftUs)}\"; expected a non-negative finite number`,\n )\n }\n const params: CmcdParams = {}\n if (this.#lastStats) Object.assign(params, buildFecParams(this.#lastStats))\n Object.assign(params, buildTransportParams(this.#transport))\n if (this.#switchMiscount > 0) params['x-bc-switch-miscount'] = this.#switchMiscount\n params['x-bc-switch-drift-us'] = driftUs\n this.#emit(params)\n }\n\n /**\n * Process a FecTrackStats snapshot. Finds the video track, builds\n * x-bc-* vendor keys, and fires both delivery callbacks.\n */\n onSnapshot(data: SnapshotData): void {\n // Find first video track; skip if none\n const videoTrack = data.tracks.find(t => t.config.trackType === 'video')\n if (!videoTrack) return\n\n this.#lastStats = videoTrack\n\n const params: CmcdParams = {\n ...buildFecParams(videoTrack),\n ...buildTransportParams(this.#transport),\n }\n\n if (this.#playMode !== null) {\n params['x-bc-play-mode'] = this.#playMode\n }\n\n // Delta-fail-rate is only meaningful when a delta track exists.\n if (\n this.#playMode !== null &&\n this.#playMode !== 'single-track' &&\n this.#deltaFailRate !== null\n ) {\n params['x-bc-delta-fail-rate'] = parseFloat(this.#deltaFailRate.toFixed(4))\n }\n\n if (this.#switchMiscount > 0) {\n params['x-bc-switch-miscount'] = this.#switchMiscount\n }\n if (this.#manifestStats) {\n params['x-bc-manifest-verified'] = this.#manifestStats.verified > 0\n params['x-bc-manifest-failures'] = Object.values(this.#manifestStats.failures)\n .reduce((total, count) => total + count, 0)\n }\n\n this.#emit(params)\n }\n\n /**\n * Emit transport state without inventing FEC metrics. Cadence is owned by\n * the caller because only the transport integration knows when state changed.\n */\n onTransportSnapshot(data: TransportOnlySnapshotData): void {\n if (!Number.isFinite(data.timestampMs) || data.timestampMs < 0) {\n throw new Error('[CmcdProducer] transport snapshot timestamp must be a non-negative finite number')\n }\n if (data.playMode !== undefined) this.updatePlayMode(data.playMode)\n if (\n data.switchMiscount !== undefined &&\n (!Number.isSafeInteger(data.switchMiscount) || data.switchMiscount < 0)\n ) {\n throw new Error('[CmcdProducer] transport snapshot switch-miscount must be a non-negative safe integer')\n }\n\n this.#transport = data.transport\n const params = buildTransportParams(data.transport)\n if (this.#playMode !== null) params['x-bc-play-mode'] = this.#playMode\n const switchMiscount = data.switchMiscount ?? this.#switchMiscount\n if (switchMiscount > 0) params['x-bc-switch-miscount'] = switchMiscount\n this.#emit(params)\n }\n\n /**\n * Signal a transport transition event. Fires an immediate out-of-band\n * emit with x-bc-ct set. The subsequent onSnapshot() will NOT include\n * x-bc-ct (one-shot).\n */\n onTransition(event: TransportTransitionEvent): void {\n const params: CmcdParams = {}\n\n // Include last known FEC stats if available\n if (this.#lastStats) {\n Object.assign(params, buildFecParams(this.#lastStats))\n }\n\n // Include transport state if available\n Object.assign(params, buildTransportParams(this.#transport))\n\n // Add the transition event key (one-shot)\n params['x-bc-ct'] = event\n\n this.#emit(params)\n }\n\n /** Fire both delivery callbacks with the given params. */\n #emit(params: CmcdParams): void {\n this.#onCmcdParams?.(params)\n this.#onCmcdPost?.(formatQueryString(params))\n }\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * CmcdProducer \u2014 transport-agnostic CMCD telemetry producer.\n *\n * Maps FecTrackStats snapshots and TransportSnapshot state to x-bc-*\n * CMCD vendor keys (proto tags 70-99). Fires callbacks for two delivery\n * channels: MoQ SUBSCRIBE params and multicast HTTP POST.\n *\n * Does NOT call fetch() or write to QUIC directly \u2014 the player wiring\n * layer is responsible for attaching params to SUBSCRIBE or POSTing\n * the payload to the CDN CMCD endpoint.\n *\n * @see docs/superpowers/specs/2026-04-15-iwa-multicast-stack-design.md \u00A73.3\n * @see CDN+ Track D BLO-1044\n */\n\nimport type { FecTrackStats } from '@blockcast/fec-worker'\nimport type { FecFailClosedReason } from './fec-manager.js'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Source-auth counters for CMCD: records verified, and drops per reason. */\nexport interface ManifestVerificationStats {\n verified: number\n failures: Record<string, number>\n}\n\n/** Transport state snapshot, built by the player wiring layer from SocketPool. */\nexport interface TransportSnapshot {\n transport: 'native' | 'amt' | 'moq'\n /** IPv4/IPv6 multicast group address */\n multicastGroup?: string\n /** SSM source address */\n multicastSource?: string\n /** AMT relay address (omit when undefined) */\n amtRelay?: string\n}\n\n/** Transport transition event identifiers for x-bc-ct. */\nexport type TransportTransitionEvent = 'mc-start' | 'mc-to-uc' | 'amt-start'\n\n/**\n * Phase 14 play-mode state (D-12, x-bc-play-mode):\n * - `full` \u2014 base + delta both active\n * - `base-only` \u2014 delta fell back; base carries playback\n * - `single-track` \u2014 stream is not a multi-track switching set (legacy)\n */\nexport type PlayMode = 'full' | 'base-only' | 'single-track'\n\nconst PLAY_MODES: readonly PlayMode[] = ['full', 'base-only', 'single-track']\n\n/** CMCD vendor key map. Values are string, number, or boolean. */\nexport type CmcdParams = Record<string, string | number | boolean>\n\n/** Options for CmcdProducer construction. */\nexport interface CmcdProducerOptions {\n /** Fired on each snapshot and on transport transitions. Params for MoQ SUBSCRIBE. */\n onCmcdParams?: (params: CmcdParams) => void\n /** Fired on each snapshot and on transport transitions. RFC 9559 query-string for HTTP POST body. */\n onCmcdPost?: (payload: string) => void\n}\n\n/** Snapshot data passed to onSnapshot(). */\nexport interface SnapshotData {\n tracks: FecTrackStats[]\n timestampMs: number\n}\n\n/** Transport-only telemetry for receivers that do not own FEC track stats. */\nexport interface TransportOnlySnapshotData {\n transport: TransportSnapshot\n timestampMs: number\n playMode?: PlayMode\n switchMiscount?: number\n}\n\n// ---------------------------------------------------------------------------\n// Value sanitization (T-06-01: header injection mitigation)\n// ---------------------------------------------------------------------------\n\n/** Strip commas, newlines, and carriage returns from string values. */\nfunction sanitize(value: string): string {\n return value.replace(/[,\\r\\n]/g, '')\n}\n\n// ---------------------------------------------------------------------------\n// Key building (pure functions, no side effects)\n// ---------------------------------------------------------------------------\n\n/** Build FEC vendor keys from a FecTrackStats snapshot. */\nfunction buildFecParams(stats: FecTrackStats): CmcdParams {\n const params: CmcdParams = {}\n const cfg = stats.config\n\n params['x-bc-fec-algo'] = cfg.algorithm\n params['x-bc-fec-k'] = cfg.k\n // P as this receiver JOINED it: the worker is configured from\n // TrackSessionConfig.joinedRepairCount, the sum of repairSymbols over the\n // joined base layers. Not the catalog total, which a receiver on a clean path\n // does not receive, and never including a keyframe overlay (separate FEC\n // instance with its own RSB_length).\n params['x-bc-fec-p'] = cfg.repairCount\n params['x-bc-fec-recovery'] = parseFloat((stats.recoveryRate / 100).toFixed(4))\n\n return params\n}\n\n/** Build transport vendor keys from a TransportSnapshot. */\nfunction buildTransportParams(snap: TransportSnapshot | undefined): CmcdParams {\n if (!snap) return {}\n\n const params: CmcdParams = {}\n params['x-bc-transport'] = snap.transport\n\n if (snap.multicastGroup != null) {\n params['x-bc-multicast-group'] = snap.multicastGroup\n }\n if (snap.multicastSource != null) {\n params['x-bc-multicast-source'] = snap.multicastSource\n }\n if (snap.amtRelay != null) {\n params['x-bc-amt-relay'] = snap.amtRelay\n }\n\n return params\n}\n\n// ---------------------------------------------------------------------------\n// Query-string serialization (RFC 9559 \u00A72)\n// ---------------------------------------------------------------------------\n\n/**\n * Serialize CmcdParams to RFC 9559 query-string format.\n * Keys sorted for deterministic output. String values sanitized.\n */\nfunction formatQueryString(params: CmcdParams): string {\n return Object.keys(params)\n .sort()\n .map(key => {\n const v = params[key]\n if (typeof v === 'string') return `${key}=${sanitize(v)}`\n return `${key}=${v}`\n })\n .join(',')\n}\n\n// ---------------------------------------------------------------------------\n// CmcdProducer\n// ---------------------------------------------------------------------------\n\nexport class CmcdProducer {\n #onCmcdParams: ((params: CmcdParams) => void) | undefined\n #onCmcdPost: ((payload: string) => void) | undefined\n #transport: TransportSnapshot | undefined\n #lastStats: FecTrackStats | undefined\n // Phase 14 state \u2014 Plan 03 Task 2 (D-12, D-15).\n #playMode: PlayMode | null = null\n #deltaFailRate: number | null = null\n #switchMiscount = 0\n #manifestStats: ManifestVerificationStats | null = null\n #fecFailClosed: FecFailClosedReason | null = null\n\n constructor(options: CmcdProducerOptions) {\n this.#onCmcdParams = options.onCmcdParams\n this.#onCmcdPost = options.onCmcdPost\n }\n\n /** Update the stored transport state. Called by player wiring layer. */\n updateTransport(snapshot: TransportSnapshot): void {\n this.#transport = snapshot\n }\n\n /**\n * Set the current play-mode. Emitted as `x-bc-play-mode` on subsequent\n * snapshots. Throws on any value outside {'full','base-only','single-track'}\n * (CLAUDE.md: error on bad init).\n */\n updatePlayMode(mode: PlayMode): void {\n if (typeof mode !== 'string' || !PLAY_MODES.includes(mode as PlayMode)) {\n throw new Error(\n `[CmcdProducer] invalid play-mode \"${String(mode)}\"; expected one of: ${PLAY_MODES.join(', ')}`,\n )\n }\n this.#playMode = mode\n }\n\n /**\n * Set the delta-track FEC block-failure rate (0..1 inclusive). Emitted as\n * `x-bc-delta-fail-rate` on snapshots when play-mode is 'full' or 'base-only'.\n * Omitted on single-track streams.\n */\n updateDeltaFailRate(rate: number): void {\n if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0 || rate > 1) {\n throw new Error(\n `[CmcdProducer] invalid delta-fail-rate \"${String(rate)}\"; expected a finite number in [0, 1]`,\n )\n }\n this.#deltaFailRate = rate\n }\n\n /**\n * Bump the cumulative switching-set misalignment counter. Emitted as\n * `x-bc-switch-miscount` on snapshots when the counter is > 0.\n */\n incrementSwitchMiscount(): void {\n this.#switchMiscount += 1\n }\n\n /**\n * Record that FEC failed closed at runtime (fec-01 6.3.9). Every later\n * snapshot carries `x-bc-fec-fail-closed` (the reason code) and\n * `x-bc-fec-fail-layer` (the held layer i whose total B_i was undercut), so a\n * stream playing without FEC is told apart from one with no loss.\n */\n updateFecFailClosed(reason: FecFailClosedReason): void {\n this.#fecFailClosed = reason\n }\n\n updateManifestVerification(stats: ManifestVerificationStats): void {\n this.#manifestStats = stats\n }\n\n /**\n * One-shot emit of `x-bc-switch-drift-us` for a single misalignment event.\n * Does NOT mutate snapshot state \u2014 subsequent onSnapshot() calls will not\n * include the drift key until the next emitSwitchDrift(). Mirrors the\n * existing onTransition() pattern.\n */\n emitSwitchDrift(driftUs: number): void {\n if (\n typeof driftUs !== 'number' ||\n !Number.isFinite(driftUs) ||\n driftUs < 0\n ) {\n throw new Error(\n `[CmcdProducer] invalid drift-us \"${String(driftUs)}\"; expected a non-negative finite number`,\n )\n }\n const params: CmcdParams = {}\n if (this.#lastStats) Object.assign(params, buildFecParams(this.#lastStats))\n Object.assign(params, buildTransportParams(this.#transport))\n if (this.#switchMiscount > 0) params['x-bc-switch-miscount'] = this.#switchMiscount\n params['x-bc-switch-drift-us'] = driftUs\n this.#emit(params)\n }\n\n /**\n * Process a FecTrackStats snapshot. Finds the video track, builds\n * x-bc-* vendor keys, and fires both delivery callbacks.\n */\n onSnapshot(data: SnapshotData): void {\n // Find first video track; skip if none\n const videoTrack = data.tracks.find(t => t.config.trackType === 'video')\n if (!videoTrack) return\n\n this.#lastStats = videoTrack\n\n const params: CmcdParams = {\n ...buildFecParams(videoTrack),\n ...buildTransportParams(this.#transport),\n }\n\n if (this.#playMode !== null) {\n params['x-bc-play-mode'] = this.#playMode\n }\n\n if (this.#fecFailClosed) {\n params['x-bc-fec-fail-closed'] = this.#fecFailClosed.code\n params['x-bc-fec-fail-layer'] = this.#fecFailClosed.layer\n }\n\n // Delta-fail-rate is only meaningful when a delta track exists.\n if (\n this.#playMode !== null &&\n this.#playMode !== 'single-track' &&\n this.#deltaFailRate !== null\n ) {\n params['x-bc-delta-fail-rate'] = parseFloat(this.#deltaFailRate.toFixed(4))\n }\n\n if (this.#switchMiscount > 0) {\n params['x-bc-switch-miscount'] = this.#switchMiscount\n }\n if (this.#manifestStats) {\n params['x-bc-manifest-verified'] = this.#manifestStats.verified > 0\n params['x-bc-manifest-failures'] = Object.values(this.#manifestStats.failures)\n .reduce((total, count) => total + count, 0)\n }\n\n this.#emit(params)\n }\n\n /**\n * Emit transport state without inventing FEC metrics. Cadence is owned by\n * the caller because only the transport integration knows when state changed.\n */\n onTransportSnapshot(data: TransportOnlySnapshotData): void {\n if (!Number.isFinite(data.timestampMs) || data.timestampMs < 0) {\n throw new Error('[CmcdProducer] transport snapshot timestamp must be a non-negative finite number')\n }\n if (data.playMode !== undefined) this.updatePlayMode(data.playMode)\n if (\n data.switchMiscount !== undefined &&\n (!Number.isSafeInteger(data.switchMiscount) || data.switchMiscount < 0)\n ) {\n throw new Error('[CmcdProducer] transport snapshot switch-miscount must be a non-negative safe integer')\n }\n\n this.#transport = data.transport\n const params = buildTransportParams(data.transport)\n if (this.#playMode !== null) params['x-bc-play-mode'] = this.#playMode\n const switchMiscount = data.switchMiscount ?? this.#switchMiscount\n if (switchMiscount > 0) params['x-bc-switch-miscount'] = switchMiscount\n this.#emit(params)\n }\n\n /**\n * Signal a transport transition event. Fires an immediate out-of-band\n * emit with x-bc-ct set. The subsequent onSnapshot() will NOT include\n * x-bc-ct (one-shot).\n */\n onTransition(event: TransportTransitionEvent): void {\n const params: CmcdParams = {}\n\n // Include last known FEC stats if available\n if (this.#lastStats) {\n Object.assign(params, buildFecParams(this.#lastStats))\n }\n\n // Include transport state if available\n Object.assign(params, buildTransportParams(this.#transport))\n\n // Add the transition event key (one-shot)\n params['x-bc-ct'] = event\n\n this.#emit(params)\n }\n\n /** Fire both delivery callbacks with the given params. */\n #emit(params: CmcdParams): void {\n this.#onCmcdParams?.(params)\n this.#onCmcdPost?.(formatQueryString(params))\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAkDA,IAAM,aAAkC,CAAC,QAAQ,aAAa,cAAc;AAgC5E,SAAS,SAAS,OAAuB;AACvC,SAAO,MAAM,QAAQ,YAAY,EAAE;AACrC;AAOA,SAAS,eAAe,OAAkC;AACxD,QAAM,SAAqB,CAAC;AAC5B,QAAM,MAAM,MAAM;AAElB,SAAO,eAAe,IAAI,IAAI;AAC9B,SAAO,YAAY,IAAI,IAAI;AAM3B,SAAO,YAAY,IAAI,IAAI;AAC3B,SAAO,mBAAmB,IAAI,YAAY,MAAM,eAAe,KAAK,QAAQ,CAAC,CAAC;AAE9E,SAAO;AACT;AAGA,SAAS,qBAAqB,MAAiD;AAC7E,MAAI,CAAC,KAAM,QAAO,CAAC;AAEnB,QAAM,SAAqB,CAAC;AAC5B,SAAO,gBAAgB,IAAI,KAAK;AAEhC,MAAI,KAAK,kBAAkB,MAAM;AAC/B,WAAO,sBAAsB,IAAI,KAAK;AAAA,EACxC;AACA,MAAI,KAAK,mBAAmB,MAAM;AAChC,WAAO,uBAAuB,IAAI,KAAK;AAAA,EACzC;AACA,MAAI,KAAK,YAAY,MAAM;AACzB,WAAO,gBAAgB,IA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M;AAC3B,SAAK,cAAc,kBAAkB,MAAM,CAAC;AAAA,EAC9C;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/delivery-catalog.js
CHANGED
|
@@ -27,189 +27,6 @@ function parseFecBlockProfile(value, where) {
|
|
|
27
27
|
// ../mmt-base/dist/catalog-fec-source.js
|
|
28
28
|
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
29
29
|
|
|
30
|
-
// node_modules/@blockcast/mmt-transport/dist/types.js
|
|
31
|
-
var MoqFecAlgorithm;
|
|
32
|
-
(function(MoqFecAlgorithm2) {
|
|
33
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["None"] = 0] = "None";
|
|
34
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["Xor"] = 1] = "Xor";
|
|
35
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
|
|
36
|
-
})(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
|
|
37
|
-
|
|
38
|
-
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
39
|
-
var MPU_HEADER_SIZE2 = 8;
|
|
40
|
-
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
41
|
-
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
42
|
-
var MMTP_SIGNALING_PACKET_ID = 0;
|
|
43
|
-
var MMTP_PACKET_ID_MAX = 65535;
|
|
44
|
-
|
|
45
|
-
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
46
|
-
var DEFAULT_AMT_RELAY_PORT = 2268;
|
|
47
|
-
|
|
48
|
-
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
49
|
-
var NTP_SHORT_BITS2 = 32;
|
|
50
|
-
var NTP_SHORT_MODULUS2 = 2 ** NTP_SHORT_BITS2;
|
|
51
|
-
var NTP_SHORT_HALF_RANGE2 = 2 ** (NTP_SHORT_BITS2 - 1);
|
|
52
|
-
function isNtpShort(value) {
|
|
53
|
-
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS2;
|
|
54
|
-
}
|
|
55
|
-
function compareNtpShort(a, b) {
|
|
56
|
-
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
57
|
-
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS2}), got ${String(a)} and ${String(b)}`);
|
|
58
|
-
}
|
|
59
|
-
if (a === b)
|
|
60
|
-
return "equal";
|
|
61
|
-
const forward = (a - b + NTP_SHORT_MODULUS2) % NTP_SHORT_MODULUS2;
|
|
62
|
-
if (forward < NTP_SHORT_HALF_RANGE2)
|
|
63
|
-
return "after";
|
|
64
|
-
if (forward > NTP_SHORT_HALF_RANGE2)
|
|
65
|
-
return "before";
|
|
66
|
-
return "unordered";
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
70
|
-
var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
71
|
-
"iso-ssbg1-v1"
|
|
72
|
-
]);
|
|
73
|
-
|
|
74
|
-
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
75
|
-
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
76
|
-
|
|
77
|
-
// node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
|
|
78
|
-
var DRIADDiscovery = class {
|
|
79
|
-
cache = /* @__PURE__ */ new Map();
|
|
80
|
-
cacheExpiry = 3e5;
|
|
81
|
-
// 5 minutes
|
|
82
|
-
/**
|
|
83
|
-
* Discover AMT relays for a multicast source address (RFC 8777)
|
|
84
|
-
*
|
|
85
|
-
* @param source - The multicast source IP address (NOT the group!)
|
|
86
|
-
* @returns Array of discovered AMT relays that can tunnel traffic from this source
|
|
87
|
-
*/
|
|
88
|
-
async discoverRelays(source) {
|
|
89
|
-
const cached = this.cache.get(source);
|
|
90
|
-
if (cached) {
|
|
91
|
-
return cached;
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
95
|
-
const queryDomain = `${reversedSource}.amt.in-addr.arpa`;
|
|
96
|
-
console.log(`[DRIAD] Discovering relays for source ${source} via ${queryDomain}`);
|
|
97
|
-
const relays = await this.queryDRIADProxy(source);
|
|
98
|
-
if (relays.length > 0) {
|
|
99
|
-
this.cache.set(source, relays);
|
|
100
|
-
setTimeout(() => this.cache.delete(source), this.cacheExpiry);
|
|
101
|
-
}
|
|
102
|
-
return relays;
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.warn(`[DRIAD] Discovery failed for source ${source}:`, error);
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Query DRIAD proxy service (browser-compatible)
|
|
110
|
-
*/
|
|
111
|
-
async queryDRIADProxy(source) {
|
|
112
|
-
const proxyEndpoints = [
|
|
113
|
-
"https://driad.amt.net/api/v1/relays",
|
|
114
|
-
"https://multicast-gateway.cloudflare.com/driad"
|
|
115
|
-
];
|
|
116
|
-
for (const endpoint of proxyEndpoints) {
|
|
117
|
-
try {
|
|
118
|
-
const response = await fetch(`${endpoint}?source=${encodeURIComponent(source)}`, {
|
|
119
|
-
method: "GET",
|
|
120
|
-
headers: { Accept: "application/json" },
|
|
121
|
-
signal: AbortSignal.timeout(5e3)
|
|
122
|
-
});
|
|
123
|
-
if (response.ok) {
|
|
124
|
-
const data = await response.json();
|
|
125
|
-
return data.relays || [];
|
|
126
|
-
}
|
|
127
|
-
} catch {
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const dohRelay = await this.queryDNSOverHTTPS(source);
|
|
131
|
-
if (dohRelay) {
|
|
132
|
-
return [dohRelay];
|
|
133
|
-
}
|
|
134
|
-
return [];
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Query DNS-over-HTTPS for DRIAD relay based on source address (RFC 8777)
|
|
138
|
-
*/
|
|
139
|
-
async queryDNSOverHTTPS(source) {
|
|
140
|
-
try {
|
|
141
|
-
const reversedSource = source.split(".").reverse().join(".");
|
|
142
|
-
const queryName = `${reversedSource}.amt.in-addr.arpa`;
|
|
143
|
-
const dohUrl = `https://cloudflare-dns.com/dns-query?name=${queryName}&type=A`;
|
|
144
|
-
const response = await fetch(dohUrl, {
|
|
145
|
-
headers: { Accept: "application/dns-json" },
|
|
146
|
-
signal: AbortSignal.timeout(3e3)
|
|
147
|
-
});
|
|
148
|
-
if (!response.ok) {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
const result = await response.json();
|
|
152
|
-
if (result.Answer && result.Answer.length > 0) {
|
|
153
|
-
return {
|
|
154
|
-
host: result.Answer[0].data,
|
|
155
|
-
port: DEFAULT_AMT_RELAY_PORT,
|
|
156
|
-
priority: 10,
|
|
157
|
-
weight: 100,
|
|
158
|
-
asn: 0
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
} catch (error) {
|
|
163
|
-
console.warn("[DRIAD] DNS-over-HTTPS query failed:", error);
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Select best relay based on RTT measurements
|
|
169
|
-
*/
|
|
170
|
-
async selectBestRelay(relays) {
|
|
171
|
-
if (relays.length === 0)
|
|
172
|
-
return null;
|
|
173
|
-
const measured = await Promise.all(relays.map(async (relay) => {
|
|
174
|
-
const rtt = await this.measureRTT(relay.host, relay.port);
|
|
175
|
-
return { ...relay, rtt };
|
|
176
|
-
}));
|
|
177
|
-
measured.sort((a, b) => {
|
|
178
|
-
if (a.priority !== b.priority)
|
|
179
|
-
return a.priority - b.priority;
|
|
180
|
-
return (a.rtt || Infinity) - (b.rtt || Infinity);
|
|
181
|
-
});
|
|
182
|
-
console.log(`[DRIAD] Selected relay: ${measured[0].host} (RTT: ${measured[0].rtt}ms)`);
|
|
183
|
-
return measured[0];
|
|
184
|
-
}
|
|
185
|
-
async measureRTT(host, _port) {
|
|
186
|
-
const start = performance.now();
|
|
187
|
-
try {
|
|
188
|
-
await fetch(`https://${host}/health`, {
|
|
189
|
-
method: "HEAD",
|
|
190
|
-
signal: AbortSignal.timeout(2e3),
|
|
191
|
-
mode: "no-cors"
|
|
192
|
-
});
|
|
193
|
-
return performance.now() - start;
|
|
194
|
-
} catch {
|
|
195
|
-
return Infinity;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Clear the relay cache
|
|
200
|
-
*/
|
|
201
|
-
clearCache() {
|
|
202
|
-
this.cache.clear();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Get cached relays for a source address
|
|
206
|
-
*/
|
|
207
|
-
getCached(source) {
|
|
208
|
-
return this.cache.get(source);
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
var driadDiscovery = new DRIADDiscovery();
|
|
212
|
-
|
|
213
30
|
// node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
|
|
214
31
|
function endpointKey(endpoint) {
|
|
215
32
|
return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
|
|
@@ -340,8 +157,8 @@ var AdaptiveBitrateController = class {
|
|
|
340
157
|
/**
|
|
341
158
|
* Update FEC statistics for ABR decisions
|
|
342
159
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
160
|
+
* ABR uses the effective loss rate (after FEC recovery) rather than the
|
|
161
|
+
* raw transport loss rate.
|
|
345
162
|
*
|
|
346
163
|
* @param stats - FEC statistics from the FEC decoder
|
|
347
164
|
*/
|
|
@@ -417,6 +234,45 @@ var AdaptiveBitrateController = class {
|
|
|
417
234
|
}
|
|
418
235
|
};
|
|
419
236
|
|
|
237
|
+
// node_modules/@blockcast/mmt-base/dist/mmtp.js
|
|
238
|
+
var MPU_HEADER_SIZE2 = 8;
|
|
239
|
+
var MPU_LENGTH_FIELD_SIZE2 = 2;
|
|
240
|
+
var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
|
|
241
|
+
var MMTP_SIGNALING_PACKET_ID2 = 0;
|
|
242
|
+
var MMTP_PACKET_ID_MAX = 65535;
|
|
243
|
+
|
|
244
|
+
// node_modules/@blockcast/mmt-base/dist/net-constants.js
|
|
245
|
+
var DEFAULT_AMT_RELAY_PORT = 2268;
|
|
246
|
+
|
|
247
|
+
// node_modules/@blockcast/mmt-base/dist/ntp-short.js
|
|
248
|
+
var NTP_SHORT_BITS2 = 32;
|
|
249
|
+
var NTP_SHORT_MODULUS2 = 2 ** NTP_SHORT_BITS2;
|
|
250
|
+
var NTP_SHORT_HALF_RANGE2 = 2 ** (NTP_SHORT_BITS2 - 1);
|
|
251
|
+
function isNtpShort(value) {
|
|
252
|
+
return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS2;
|
|
253
|
+
}
|
|
254
|
+
function compareNtpShort(a, b) {
|
|
255
|
+
if (!isNtpShort(a) || !isNtpShort(b)) {
|
|
256
|
+
throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS2}), got ${String(a)} and ${String(b)}`);
|
|
257
|
+
}
|
|
258
|
+
if (a === b)
|
|
259
|
+
return "equal";
|
|
260
|
+
const forward = (a - b + NTP_SHORT_MODULUS2) % NTP_SHORT_MODULUS2;
|
|
261
|
+
if (forward < NTP_SHORT_HALF_RANGE2)
|
|
262
|
+
return "after";
|
|
263
|
+
if (forward > NTP_SHORT_HALF_RANGE2)
|
|
264
|
+
return "before";
|
|
265
|
+
return "unordered";
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
|
|
269
|
+
var FEC_BLOCK_PROFILES2 = Object.freeze([
|
|
270
|
+
"iso-ssbg1-v1"
|
|
271
|
+
]);
|
|
272
|
+
|
|
273
|
+
// node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
|
|
274
|
+
var ALL_ROLES2 = Object.freeze(["video", "audio"]);
|
|
275
|
+
|
|
420
276
|
// node_modules/@blockcast/mmt-transport/dist/multicast-orchestrator.js
|
|
421
277
|
var DEFAULT_DWELL_MS = 3e3;
|
|
422
278
|
var DEFAULT_JOIN_DEADLINE_MS = 5e3;
|
|
@@ -647,29 +503,68 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
647
503
|
if (input.packetIds?.some((id) => !isMulticastTrackPacketId(id)) || input.tracks?.some((track) => !isMulticastTrackPacketId(track.packetId))) {
|
|
648
504
|
throw new RangeError(`multicast packetId must be an integer from 1 to ${MMTP_PACKET_ID_MAX}; packetId 0 is the MMTP signaling flow and is never a track's`);
|
|
649
505
|
}
|
|
506
|
+
const source = input.source?.trim() || void 0;
|
|
507
|
+
const senderAddress = input.senderAddress?.trim() || void 0;
|
|
508
|
+
if (source && senderAddress) {
|
|
509
|
+
throw new TypeError("multicast senderAddress is an ASM filter and never appears beside source");
|
|
510
|
+
}
|
|
650
511
|
const base = {
|
|
651
512
|
group: input.group,
|
|
652
513
|
port: input.port,
|
|
653
|
-
...
|
|
514
|
+
...source ? { source } : {},
|
|
654
515
|
consume: "bytes",
|
|
655
516
|
...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
|
|
656
517
|
};
|
|
518
|
+
const filter = senderAddress ? { senderAddress } : {};
|
|
519
|
+
if (input.atsc3) {
|
|
520
|
+
if (senderAddress)
|
|
521
|
+
throw new TypeError("an ATSC3 tuner request carries no senderAddress");
|
|
522
|
+
const { frequency, plpId, serviceId } = input.atsc3;
|
|
523
|
+
if (!Number.isInteger(frequency) || frequency < 1) {
|
|
524
|
+
throw new TypeError(`ATSC3 tuning requires a positive integer frequency in kHz, got ${String(frequency)}`);
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
...base,
|
|
528
|
+
origin: "tuner",
|
|
529
|
+
standard: "atsc3",
|
|
530
|
+
frequency,
|
|
531
|
+
...plpId !== void 0 ? { plpId } : {},
|
|
532
|
+
...serviceId !== void 0 ? { serviceId } : {}
|
|
533
|
+
};
|
|
534
|
+
}
|
|
657
535
|
const relay = input.amtRelay?.trim();
|
|
658
|
-
const
|
|
536
|
+
const driad = !relay && input.amtDiscovery === "driad";
|
|
537
|
+
const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && (relay !== void 0 && relay !== "" || driad);
|
|
659
538
|
if (!wantsAmt) {
|
|
660
539
|
const native = {
|
|
661
540
|
...base,
|
|
541
|
+
...filter,
|
|
662
542
|
origin: "ip-multicast",
|
|
663
543
|
...input.tracks?.length ? { tracks: input.tracks.map(({ name, packetId }) => ({ name, packetId })) } : {}
|
|
664
544
|
};
|
|
665
545
|
return native;
|
|
666
546
|
}
|
|
667
547
|
const relayPort = input.amtRelayPort;
|
|
548
|
+
if (driad) {
|
|
549
|
+
if (!base.source)
|
|
550
|
+
throw new TypeError("AMT DRIAD discovery requires a source address");
|
|
551
|
+
if (relayPort !== void 0 && !isPositivePort(relayPort)) {
|
|
552
|
+
throw new TypeError("AMT DRIAD discovery requires a valid relay port when one is given");
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
...base,
|
|
556
|
+
source: base.source,
|
|
557
|
+
origin: "amt",
|
|
558
|
+
discovery: "driad",
|
|
559
|
+
...relayPort !== void 0 ? { relayPort } : {}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
668
562
|
if (!relay || relayPort === void 0 || !isPositivePort(relayPort)) {
|
|
669
563
|
throw new TypeError("AMT requires a resolved relay and a valid relay port");
|
|
670
564
|
}
|
|
671
565
|
return {
|
|
672
566
|
...base,
|
|
567
|
+
...filter,
|
|
673
568
|
origin: "amt",
|
|
674
569
|
relay,
|
|
675
570
|
relayPort
|
|
@@ -695,6 +590,9 @@ function isValidMulticastGroupAddress(address) {
|
|
|
695
590
|
function normalizeMulticastEndpoint(endpoint) {
|
|
696
591
|
const groupAddress = endpoint.groupAddress.trim().toLowerCase();
|
|
697
592
|
const sourceAddress = endpoint.sourceAddress?.trim().toLowerCase() || void 0;
|
|
593
|
+
const senderAddress = endpoint.senderAddress?.trim().toLowerCase() || void 0;
|
|
594
|
+
if (sourceAddress && senderAddress)
|
|
595
|
+
return void 0;
|
|
698
596
|
const amtRelay = endpoint.amtRelay?.trim().toLowerCase() || void 0;
|
|
699
597
|
if (!isValidMulticastGroupAddress(groupAddress) || !isPositivePort(endpoint.port))
|
|
700
598
|
return void 0;
|
|
@@ -705,10 +603,12 @@ function normalizeMulticastEndpoint(endpoint) {
|
|
|
705
603
|
return {
|
|
706
604
|
groupAddress,
|
|
707
605
|
...sourceAddress ? { sourceAddress } : {},
|
|
606
|
+
...senderAddress ? { senderAddress } : {},
|
|
708
607
|
port: endpoint.port,
|
|
709
608
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
710
609
|
...amtRelay ? { amtRelay } : {},
|
|
711
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
610
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
611
|
+
...endpoint.amtDiscovery === "driad" ? { amtDiscovery: "driad" } : {}
|
|
712
612
|
};
|
|
713
613
|
}
|
|
714
614
|
function multicastEndpointKey(endpoint) {
|
|
@@ -721,11 +621,15 @@ function multicastEndpointKey(endpoint) {
|
|
|
721
621
|
normalized.port,
|
|
722
622
|
normalized.mode ?? "auto",
|
|
723
623
|
normalized.amtRelay ?? "",
|
|
724
|
-
normalized.amtRelayPort ?? ""
|
|
624
|
+
normalized.amtRelayPort ?? "",
|
|
625
|
+
// A DRIAD join is a different gateway subscription from a native one.
|
|
626
|
+
...normalized.amtDiscovery ? [normalized.amtDiscovery] : [],
|
|
627
|
+
// An ASM sender filter is a different subscription from the unfiltered join.
|
|
628
|
+
...normalized.senderAddress ? [{ senderAddress: normalized.senderAddress }] : []
|
|
725
629
|
]);
|
|
726
630
|
}
|
|
727
631
|
function isMulticastTrackPacketId(value) {
|
|
728
|
-
return Number.isInteger(value) && value >
|
|
632
|
+
return Number.isInteger(value) && value > MMTP_SIGNALING_PACKET_ID2 && value <= MMTP_PACKET_ID_MAX;
|
|
729
633
|
}
|
|
730
634
|
function isValidIpv6MulticastAddress(value) {
|
|
731
635
|
if (!/^[0-9a-f:]+$/.test(value))
|
|
@@ -761,7 +665,8 @@ var MulticastSubscriptionPool = class {
|
|
|
761
665
|
port: config.port,
|
|
762
666
|
mode: config.mode,
|
|
763
667
|
amtRelay: config.amtRelay,
|
|
764
|
-
amtRelayPort: config.amtRelayPort
|
|
668
|
+
amtRelayPort: config.amtRelayPort,
|
|
669
|
+
amtDiscovery: config.amtDiscovery
|
|
765
670
|
});
|
|
766
671
|
if (!endpoint)
|
|
767
672
|
throw new Error("Invalid multicast endpoint");
|
|
@@ -827,7 +732,8 @@ var MulticastSubscriptionPool = class {
|
|
|
827
732
|
port: endpoint.port,
|
|
828
733
|
...endpoint.mode ? { mode: endpoint.mode } : {},
|
|
829
734
|
...endpoint.amtRelay ? { amtRelay: endpoint.amtRelay } : {},
|
|
830
|
-
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
|
|
735
|
+
...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {},
|
|
736
|
+
...endpoint.amtDiscovery ? { amtDiscovery: endpoint.amtDiscovery } : {}
|
|
831
737
|
}));
|
|
832
738
|
const consumers = /* @__PURE__ */ new Map();
|
|
833
739
|
let entry;
|
|
@@ -907,7 +813,6 @@ var TransportManager = class {
|
|
|
907
813
|
};
|
|
908
814
|
capabilities = null;
|
|
909
815
|
subscription = null;
|
|
910
|
-
driad = new DRIADDiscovery();
|
|
911
816
|
/** Built by `connect()` from the caller's ladder; there is no built-in one. */
|
|
912
817
|
abr = null;
|
|
913
818
|
multicastOrchestrator = null;
|
|
@@ -957,8 +862,8 @@ var TransportManager = class {
|
|
|
957
862
|
nativeIGMP: hasGatewayBytes,
|
|
958
863
|
directSockets: typeof win?.UDPSocket !== "undefined",
|
|
959
864
|
amt: false,
|
|
960
|
-
driad:
|
|
961
|
-
//
|
|
865
|
+
driad: hasGatewayBytes,
|
|
866
|
+
// the gateway runs RFC 8777 discovery
|
|
962
867
|
fecDecode: false
|
|
963
868
|
};
|
|
964
869
|
console.log("[Transport] Capabilities:", this.capabilities);
|
|
@@ -969,7 +874,7 @@ var TransportManager = class {
|
|
|
969
874
|
*
|
|
970
875
|
* Promotion hierarchy:
|
|
971
876
|
* 1. window.multicast gateway bytes
|
|
972
|
-
* 2. AMT
|
|
877
|
+
* 2. AMT: a configured relay via the AMT proxy, else gateway DRIAD discovery
|
|
973
878
|
* 3. MOQ WebTransport (final fallback)
|
|
974
879
|
*
|
|
975
880
|
* The ABR ladder (`abrLadder`) and initial rendition (`initialQuality`)
|
|
@@ -1063,7 +968,7 @@ var TransportManager = class {
|
|
|
1063
968
|
/**
|
|
1064
969
|
* Connect via the lowercase window.multicast bytes gateway.
|
|
1065
970
|
*/
|
|
1066
|
-
async connectWindowMulticast(config, generation) {
|
|
971
|
+
async connectWindowMulticast(config, generation, mode = "multicast") {
|
|
1067
972
|
try {
|
|
1068
973
|
const gateway = this.getWindowMulticastGateway();
|
|
1069
974
|
if (typeof gateway?.subscribe !== "function")
|
|
@@ -1098,7 +1003,7 @@ var TransportManager = class {
|
|
|
1098
1003
|
}
|
|
1099
1004
|
};
|
|
1100
1005
|
this.state = {
|
|
1101
|
-
mode
|
|
1006
|
+
mode,
|
|
1102
1007
|
connected: true,
|
|
1103
1008
|
group: config.group,
|
|
1104
1009
|
source: config.source,
|
|
@@ -1116,29 +1021,19 @@ var TransportManager = class {
|
|
|
1116
1021
|
}
|
|
1117
1022
|
}
|
|
1118
1023
|
/**
|
|
1119
|
-
* Connect via AMT proxy
|
|
1024
|
+
* Connect via AMT: a configured relay goes through the AMT proxy; with no
|
|
1025
|
+
* relay, the window.multicast gateway discovers one per RFC 8777 (DRIAD).
|
|
1120
1026
|
*/
|
|
1121
1027
|
async connectAmt(config, generation) {
|
|
1122
1028
|
try {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
const relays = await this.driad.discoverRelays(config.source);
|
|
1127
|
-
if (generation !== this.connectionGeneration)
|
|
1128
|
-
return false;
|
|
1129
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
1130
|
-
if (generation !== this.connectionGeneration)
|
|
1131
|
-
return false;
|
|
1132
|
-
if (bestRelay) {
|
|
1133
|
-
amtRelay = bestRelay.host;
|
|
1134
|
-
this.state.amtRelay = amtRelay;
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
if (!amtRelay) {
|
|
1029
|
+
if (config.amtRelay)
|
|
1030
|
+
return await this.connectAmtProxy(config, config.amtRelay, generation);
|
|
1031
|
+
if (config.driadEnabled === false || !config.source || config.mode === "native") {
|
|
1138
1032
|
console.warn("[Transport] No AMT relay available (DRIAD requires source address for SSM)");
|
|
1139
1033
|
return false;
|
|
1140
1034
|
}
|
|
1141
|
-
|
|
1035
|
+
console.log(`[Transport] Asking the gateway for a DRIAD relay for source ${config.source}...`);
|
|
1036
|
+
return await this.connectWindowMulticast({ ...config, amtDiscovery: "driad" }, generation, "amt");
|
|
1142
1037
|
} catch (error) {
|
|
1143
1038
|
console.warn("[Transport] AMT connection failed:", error);
|
|
1144
1039
|
return false;
|
|
@@ -1369,7 +1264,6 @@ var AMTGatewayManager = class {
|
|
|
1369
1264
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1370
1265
|
messageHandler;
|
|
1371
1266
|
pendingPackets = /* @__PURE__ */ new Map();
|
|
1372
|
-
driad = new DRIADDiscovery();
|
|
1373
1267
|
constructor() {
|
|
1374
1268
|
this.messageHandler = (event) => {
|
|
1375
1269
|
const data = event.data;
|
|
@@ -1400,26 +1294,12 @@ var AMTGatewayManager = class {
|
|
|
1400
1294
|
return keyStr;
|
|
1401
1295
|
}
|
|
1402
1296
|
try {
|
|
1403
|
-
|
|
1404
|
-
let discoveryMethod;
|
|
1297
|
+
const relayAddress = config.relayAddress;
|
|
1405
1298
|
const relayPort = config.relayPort || DEFAULT_AMT_RELAY_PORT;
|
|
1406
|
-
if (
|
|
1407
|
-
|
|
1408
|
-
discoveryMethod = "manual";
|
|
1409
|
-
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
1410
|
-
} else if (key.source) {
|
|
1411
|
-
console.log(`[AMT] No relay configured, discovering via DRIAD for source ${key.source}...`);
|
|
1412
|
-
const relays = await this.driad.discoverRelays(key.source);
|
|
1413
|
-
const bestRelay = await this.driad.selectBestRelay(relays);
|
|
1414
|
-
if (!bestRelay) {
|
|
1415
|
-
throw new Error(`AMT relay discovery failed for source ${key.source}. Please specify a relay address in the subscription configuration.`);
|
|
1416
|
-
}
|
|
1417
|
-
relayAddress = bestRelay.host;
|
|
1418
|
-
discoveryMethod = "driad";
|
|
1419
|
-
console.log(`[AMT] Discovered relay via DRIAD: ${relayAddress}:${relayPort}`);
|
|
1420
|
-
} else {
|
|
1421
|
-
throw new Error(`AMT relay discovery requires a source address for SSM (RFC 8777). Please specify either a relay address or source address.`);
|
|
1299
|
+
if (!relayAddress) {
|
|
1300
|
+
throw new Error(`AMT relay address required: this manager does no relay discovery. For RFC 8777 DRIAD discovery, join through window.multicast with amtDiscovery: "driad".`);
|
|
1422
1301
|
}
|
|
1302
|
+
console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
|
|
1423
1303
|
const subscriptionId = keyStr;
|
|
1424
1304
|
this.pendingPackets.set(subscriptionId, []);
|
|
1425
1305
|
const subscription = {
|
|
@@ -1430,7 +1310,7 @@ var AMTGatewayManager = class {
|
|
|
1430
1310
|
relay: {
|
|
1431
1311
|
address: relayAddress,
|
|
1432
1312
|
port: relayPort,
|
|
1433
|
-
discoveryMethod,
|
|
1313
|
+
discoveryMethod: "manual",
|
|
1434
1314
|
discoveredAt: Date.now()
|
|
1435
1315
|
}
|
|
1436
1316
|
};
|