@blockcast/mmt-container 0.4.0-main.bbd83cb48eff → 0.4.0-main.c7ae84be5039
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 +28 -14
- 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 +778 -272
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +58 -26
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +270 -194
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +1 -1
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +6 -13
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +1 -1
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js.map +1 -1
- 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/delivery-catalog.js +4 -12
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.js.map +1 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +14 -2
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.js.map +1 -1
- 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/iso-block-locator.js.map +1 -1
- package/dist/manifest-auth-plan.d.ts +26 -25
- package/dist/manifest-auth-plan.d.ts.map +1 -1
- package/dist/manifest-auth-plan.js +315 -1163
- package/dist/manifest-auth-plan.js.map +4 -4
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +947 -278
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +156 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +522 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +17 -0
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +331 -124
- package/dist/multicast-auth-catalog.js.map +3 -3
- package/dist/multicast-input.d.ts +26 -4
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +283 -23
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +23 -4
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +59 -29
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +2 -10
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +2 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +899 -267
- 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 +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/dist/repair-layers.js.map +1 -1
- 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/source-auth.js +22 -6
- package/dist/source-auth.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.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/schemas/catalog.schema.json +117 -34
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +120 -46
- package/src/catalog-fec-params.ts +5 -2
- package/src/catalog-network-source.ts +1 -1
- package/src/catalog-validator.ts +4 -11
- package/src/fec-state.ts +3 -2
- package/src/index.ts +18 -2
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-fec-session.ts +514 -0
- package/src/mmtp-router.ts +25 -0
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +109 -54
- package/src/multicast-manager.ts +88 -14
- package/src/no-modules.ts +2 -0
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +79 -14
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/catalog/README.md +55 -3
- 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-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-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-out-of-range.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/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 +2 -2
- 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 +27 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +3 -2
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
package/dist/browser-runtime.js
CHANGED
|
@@ -1015,11 +1015,262 @@ function catalogFecAvailable(fec) {
|
|
|
1015
1015
|
function isPositiveSafeInteger(value) {
|
|
1016
1016
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
1017
1017
|
}
|
|
1018
|
+
var ISO_SSBG1_MIN_SYMBOL_SIZE = 14;
|
|
1018
1019
|
function catalogFecDeclaresUnconfigurableInstance(fec) {
|
|
1019
1020
|
const block = recordOf(fec);
|
|
1020
1021
|
if (block === void 0 || block["algorithm"] === "none")
|
|
1021
1022
|
return false;
|
|
1022
|
-
|
|
1023
|
+
if (!(isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"])))
|
|
1024
|
+
return true;
|
|
1025
|
+
return block["blockProfile"] === "iso-ssbg1-v1" && block["symbolSize"] < ISO_SSBG1_MIN_SYMBOL_SIZE;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// ../mmt-base/dist/multicast-catalog.js
|
|
1029
|
+
var ED25519_PUBLIC_KEY_BASE64URL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
|
|
1030
|
+
var UINT32_MAX = 4294967295;
|
|
1031
|
+
var AUTH_MEMBERS = /* @__PURE__ */ new Set(["scheme", "version", "sig", "keys", "minEpoch"]);
|
|
1032
|
+
var KEY_MEMBERS = /* @__PURE__ */ new Set(["kid", "publicKey", "firstEpoch"]);
|
|
1033
|
+
var ENDPOINT_AUTH_MEMBERS = /* @__PURE__ */ new Set([
|
|
1034
|
+
"manifestPort",
|
|
1035
|
+
"streamId",
|
|
1036
|
+
"senderAddress",
|
|
1037
|
+
"maxAuthDelayMs",
|
|
1038
|
+
"manifestTimerMs",
|
|
1039
|
+
"manifestTrack"
|
|
1040
|
+
]);
|
|
1041
|
+
function isObject(value) {
|
|
1042
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1043
|
+
}
|
|
1044
|
+
function isNonEmptyString(value) {
|
|
1045
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
1046
|
+
}
|
|
1047
|
+
function isIntegerIn(value, min, max) {
|
|
1048
|
+
return Number.isSafeInteger(value) && value >= min && value <= max;
|
|
1049
|
+
}
|
|
1050
|
+
function multicastEndpointSource(endpoint) {
|
|
1051
|
+
if (!isObject(endpoint))
|
|
1052
|
+
return void 0;
|
|
1053
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
1054
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress))
|
|
1055
|
+
return void 0;
|
|
1056
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
1057
|
+
const protocol = endpoint["protocol"];
|
|
1058
|
+
if (protocol !== void 0 && protocol !== mode)
|
|
1059
|
+
return void 0;
|
|
1060
|
+
const auth = endpoint["auth"];
|
|
1061
|
+
const senderAddress = isObject(auth) ? auth["senderAddress"] : void 0;
|
|
1062
|
+
if (mode === "ssm")
|
|
1063
|
+
return senderAddress === void 0 ? { mode, source: sourceAddress } : void 0;
|
|
1064
|
+
if (auth === void 0)
|
|
1065
|
+
return { mode };
|
|
1066
|
+
return isNonEmptyString(senderAddress) ? { mode, source: senderAddress } : void 0;
|
|
1067
|
+
}
|
|
1068
|
+
function authIssues(auth) {
|
|
1069
|
+
const base = "$.multicast.auth";
|
|
1070
|
+
const issue = (path, message) => [
|
|
1071
|
+
{ code: "multicast_auth", path: `${base}${path}`, message }
|
|
1072
|
+
];
|
|
1073
|
+
if (!isObject(auth))
|
|
1074
|
+
return issue("", "auth must be an object");
|
|
1075
|
+
const unknown = Object.keys(auth).filter((key) => !AUTH_MEMBERS.has(key));
|
|
1076
|
+
if (unknown.length > 0) {
|
|
1077
|
+
return issue("", `auth has unknown member(s) ${unknown.join(", ")}; draft -01 7.2.6 defines scheme, version, sig, keys and minEpoch`);
|
|
1078
|
+
}
|
|
1079
|
+
if (auth["scheme"] !== "bc-provenance")
|
|
1080
|
+
return issue(".scheme", 'scheme must be "bc-provenance"');
|
|
1081
|
+
if (auth["version"] !== 2)
|
|
1082
|
+
return issue(".version", "version must be 2 (bc-provenance version 2, draft -01 7.2)");
|
|
1083
|
+
if (auth["sig"] !== "ed25519")
|
|
1084
|
+
return issue(".sig", 'sig must be "ed25519"');
|
|
1085
|
+
const keys = auth["keys"];
|
|
1086
|
+
if (!Array.isArray(keys) || keys.length < 1 || keys.length > 4) {
|
|
1087
|
+
return issue(".keys", "keys must be an array of one to four {kid, publicKey, firstEpoch} objects");
|
|
1088
|
+
}
|
|
1089
|
+
const kids = /* @__PURE__ */ new Set();
|
|
1090
|
+
const firstEpochs = /* @__PURE__ */ new Set();
|
|
1091
|
+
for (let index = 0; index < keys.length; index++) {
|
|
1092
|
+
const key = keys[index];
|
|
1093
|
+
const at = `.keys[${index}]`;
|
|
1094
|
+
if (!isObject(key) || Object.keys(key).some((member) => !KEY_MEMBERS.has(member))) {
|
|
1095
|
+
return issue(at, "a key is exactly {kid, publicKey, firstEpoch}");
|
|
1096
|
+
}
|
|
1097
|
+
if (!isIntegerIn(key["kid"], 0, UINT32_MAX))
|
|
1098
|
+
return issue(`${at}.kid`, "kid must be an unsigned 32-bit integer");
|
|
1099
|
+
if (typeof key["publicKey"] !== "string" || !ED25519_PUBLIC_KEY_BASE64URL.test(key["publicKey"])) {
|
|
1100
|
+
return issue(`${at}.publicKey`, "publicKey must be a 32-octet Ed25519 key in canonical unpadded base64url");
|
|
1101
|
+
}
|
|
1102
|
+
if (!isIntegerIn(key["firstEpoch"], 0, UINT32_MAX)) {
|
|
1103
|
+
return issue(`${at}.firstEpoch`, "firstEpoch must be an unsigned 32-bit integer");
|
|
1104
|
+
}
|
|
1105
|
+
if (kids.has(key["kid"]))
|
|
1106
|
+
return issue(`${at}.kid`, `kid ${key["kid"]} is repeated; the catalog holds no key set`);
|
|
1107
|
+
if (firstEpochs.has(key["firstEpoch"])) {
|
|
1108
|
+
return issue(`${at}.firstEpoch`, `firstEpoch ${key["firstEpoch"]} is repeated; the catalog holds no key set`);
|
|
1109
|
+
}
|
|
1110
|
+
kids.add(key["kid"]);
|
|
1111
|
+
firstEpochs.add(key["firstEpoch"]);
|
|
1112
|
+
}
|
|
1113
|
+
if (!isIntegerIn(auth["minEpoch"], 0, UINT32_MAX)) {
|
|
1114
|
+
return issue(".minEpoch", "minEpoch must be an unsigned 32-bit integer");
|
|
1115
|
+
}
|
|
1116
|
+
return [];
|
|
1117
|
+
}
|
|
1118
|
+
function endpointAuthIssue(endpoint, mode, at) {
|
|
1119
|
+
const auth = endpoint["auth"];
|
|
1120
|
+
if (!isObject(auth))
|
|
1121
|
+
return { path: `${at}.auth`, message: "auth must be an object" };
|
|
1122
|
+
const unknown = Object.keys(auth).filter((key) => !ENDPOINT_AUTH_MEMBERS.has(key));
|
|
1123
|
+
if (unknown.length > 0)
|
|
1124
|
+
return { path: `${at}.auth`, message: `auth has unknown member(s) ${unknown.join(", ")}` };
|
|
1125
|
+
if (!isIntegerIn(auth["manifestPort"], 1, 65535)) {
|
|
1126
|
+
return { path: `${at}.auth.manifestPort`, message: "manifestPort must be an integer from 1 to 65535" };
|
|
1127
|
+
}
|
|
1128
|
+
if (!isIntegerIn(auth["streamId"], 0, UINT32_MAX)) {
|
|
1129
|
+
return { path: `${at}.auth.streamId`, message: "streamId must be an unsigned 32-bit integer" };
|
|
1130
|
+
}
|
|
1131
|
+
if (mode === "ssm" && auth["senderAddress"] !== void 0) {
|
|
1132
|
+
return { path: `${at}.auth.senderAddress`, message: "senderAddress must not appear on an SSM endpoint; S is sourceAddress" };
|
|
1133
|
+
}
|
|
1134
|
+
if (mode === "asm" && !isNonEmptyString(auth["senderAddress"])) {
|
|
1135
|
+
return { path: `${at}.auth.senderAddress`, message: "a protected ASM endpoint requires senderAddress" };
|
|
1136
|
+
}
|
|
1137
|
+
if (auth["maxAuthDelayMs"] !== void 0 && !isIntegerIn(auth["maxAuthDelayMs"], 50, 1e3)) {
|
|
1138
|
+
return { path: `${at}.auth.maxAuthDelayMs`, message: "maxAuthDelayMs must be an integer from 50 to 1000" };
|
|
1139
|
+
}
|
|
1140
|
+
if (auth["manifestTimerMs"] !== void 0 && !isIntegerIn(auth["manifestTimerMs"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
1141
|
+
return { path: `${at}.auth.manifestTimerMs`, message: "manifestTimerMs must be an integer of at least 1" };
|
|
1142
|
+
}
|
|
1143
|
+
if (auth["manifestTrack"] !== void 0 && !isNonEmptyString(auth["manifestTrack"])) {
|
|
1144
|
+
return { path: `${at}.auth.manifestTrack`, message: "manifestTrack must be a non-empty string" };
|
|
1145
|
+
}
|
|
1146
|
+
if (!isIntegerIn(endpoint["bandwidth"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
1147
|
+
return { path: `${at}.bandwidth`, message: "a protected endpoint requires bandwidth, which bounds the receiver's hold queues" };
|
|
1148
|
+
}
|
|
1149
|
+
return void 0;
|
|
1150
|
+
}
|
|
1151
|
+
var CATALOG_NAMESPACE = /* @__PURE__ */ Symbol.for("@blockcast/mmt-base/catalogNamespace");
|
|
1152
|
+
function multicastCatalogIssues(catalog, options = {}) {
|
|
1153
|
+
if (!isObject(catalog))
|
|
1154
|
+
return [];
|
|
1155
|
+
const issues = [];
|
|
1156
|
+
if ("multicast.auth" in catalog) {
|
|
1157
|
+
issues.push({
|
|
1158
|
+
code: "multicast_auth",
|
|
1159
|
+
path: '$["multicast.auth"]',
|
|
1160
|
+
message: 'the root "multicast.auth" key is retired; declare auth as multicast.auth (draft -01 7.2.6)'
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
const multicast = catalog["multicast"];
|
|
1164
|
+
if (!isObject(multicast))
|
|
1165
|
+
return issues;
|
|
1166
|
+
const protectedCatalog = multicast["auth"] !== void 0;
|
|
1167
|
+
if (protectedCatalog)
|
|
1168
|
+
issues.push(...authIssues(multicast["auth"]));
|
|
1169
|
+
const endpoints = multicast["endpoints"];
|
|
1170
|
+
if (!Array.isArray(endpoints))
|
|
1171
|
+
return issues;
|
|
1172
|
+
const tracks = Array.isArray(catalog["tracks"]) ? catalog["tracks"] : [];
|
|
1173
|
+
const namespaceOf = /* @__PURE__ */ new Map();
|
|
1174
|
+
for (const track of tracks) {
|
|
1175
|
+
if (isObject(track) && typeof track["name"] === "string")
|
|
1176
|
+
namespaceOf.set(track["name"], track["namespace"]);
|
|
1177
|
+
}
|
|
1178
|
+
const tagged = catalog[CATALOG_NAMESPACE];
|
|
1179
|
+
let referenceNamespace = options.catalogNamespace ?? (typeof tagged === "string" ? tagged : void 0);
|
|
1180
|
+
const sources = [];
|
|
1181
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
1182
|
+
const endpoint = endpoints[index];
|
|
1183
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
1184
|
+
const fail = (code, path, message) => {
|
|
1185
|
+
issues.push({ code, path, message, endpointIndex: index });
|
|
1186
|
+
};
|
|
1187
|
+
sources.push(void 0);
|
|
1188
|
+
if (!isObject(endpoint)) {
|
|
1189
|
+
fail("multicast_endpoint", at, "endpoint must be an object");
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
const protocol = endpoint["protocol"];
|
|
1193
|
+
if (protocol !== void 0 && protocol !== "ssm" && protocol !== "asm") {
|
|
1194
|
+
fail("multicast_endpoint", `${at}.protocol`, `protocol must be "ssm" or "asm"; a bearer such as ${JSON.stringify(protocol)} is a networkSource entry (draft -01 4.2)`);
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
const hasAuth = endpoint["auth"] !== void 0;
|
|
1198
|
+
if (protectedCatalog !== hasAuth) {
|
|
1199
|
+
fail("multicast_endpoint_auth", `${at}.auth`, protectedCatalog ? "every endpoint requires auth when multicast carries auth; a receiver ignores this endpoint" : "auth names no key without multicast.auth; a receiver ignores this endpoint");
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1202
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
1203
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress)) {
|
|
1204
|
+
fail("multicast_endpoint", `${at}.sourceAddress`, "sourceAddress must be a non-empty string");
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
1208
|
+
if (protocol !== void 0 && protocol !== mode) {
|
|
1209
|
+
fail("multicast_endpoint", `${at}.protocol`, `protocol ${JSON.stringify(protocol)} disagrees with sourceAddress, which selects ${mode}`);
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
if (!isIntegerIn(endpoint["port"], 1, 65535)) {
|
|
1213
|
+
fail("multicast_endpoint", `${at}.port`, "port must be an integer from 1 to 65535");
|
|
1214
|
+
continue;
|
|
1215
|
+
}
|
|
1216
|
+
if (hasAuth) {
|
|
1217
|
+
const authIssue = endpointAuthIssue(endpoint, mode, at);
|
|
1218
|
+
if (authIssue) {
|
|
1219
|
+
fail("multicast_endpoint_auth", authIssue.path, authIssue.message);
|
|
1220
|
+
continue;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
sources[index] = multicastEndpointSource(endpoint);
|
|
1224
|
+
const refs = Array.isArray(endpoint["tracks"]) ? endpoint["tracks"] : [];
|
|
1225
|
+
for (let refIndex = 0; refIndex < refs.length; refIndex++) {
|
|
1226
|
+
const ref = refs[refIndex];
|
|
1227
|
+
const name = isObject(ref) ? ref["name"] : ref;
|
|
1228
|
+
if (typeof name !== "string")
|
|
1229
|
+
continue;
|
|
1230
|
+
const namespace = namespaceOf.get(name);
|
|
1231
|
+
if (typeof namespace !== "string")
|
|
1232
|
+
continue;
|
|
1233
|
+
referenceNamespace ??= namespace;
|
|
1234
|
+
if (namespace !== referenceNamespace) {
|
|
1235
|
+
fail("multicast_track", `${at}.tracks[${refIndex}].name`, `track ${JSON.stringify(name)} declares namespace ${JSON.stringify(namespace)}, not the catalog track's ${JSON.stringify(referenceNamespace)}`);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
const tupleOf = (index) => {
|
|
1240
|
+
const endpoint = endpoints[index];
|
|
1241
|
+
const auth = endpoint["auth"];
|
|
1242
|
+
return {
|
|
1243
|
+
sg: JSON.stringify([sources[index].source ?? null, endpoint["groupAddress"]]),
|
|
1244
|
+
port: endpoint["port"],
|
|
1245
|
+
manifestPort: isObject(auth) ? auth["manifestPort"] : void 0
|
|
1246
|
+
};
|
|
1247
|
+
};
|
|
1248
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
1249
|
+
if (!sources[index])
|
|
1250
|
+
continue;
|
|
1251
|
+
const own = tupleOf(index);
|
|
1252
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
1253
|
+
if (own.manifestPort !== void 0 && own.manifestPort === own.port) {
|
|
1254
|
+
issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: "manifestPort must differ from the endpoint's own port", endpointIndex: index });
|
|
1255
|
+
continue;
|
|
1256
|
+
}
|
|
1257
|
+
for (let other = 0; other < endpoints.length; other++) {
|
|
1258
|
+
if (other === index || !sources[other])
|
|
1259
|
+
continue;
|
|
1260
|
+
const peer = tupleOf(other);
|
|
1261
|
+
if (peer.sg !== own.sg)
|
|
1262
|
+
continue;
|
|
1263
|
+
if (peer.port === own.port) {
|
|
1264
|
+
issues.push({ code: "multicast_endpoint", path: `${at}.port`, message: `(S, G, port) is shared with endpoint ${other}; one endpoint object per multicast tuple`, endpointIndex: index });
|
|
1265
|
+
break;
|
|
1266
|
+
}
|
|
1267
|
+
if (own.manifestPort !== void 0 && (own.manifestPort === peer.port || own.manifestPort === peer.manifestPort)) {
|
|
1268
|
+
issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: `manifestPort is a port or manifestPort of endpoint ${other} on the same (S, G)`, endpointIndex: index });
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
return issues;
|
|
1023
1274
|
}
|
|
1024
1275
|
|
|
1025
1276
|
// src/mfu-reassembler.ts
|
|
@@ -6023,197 +6274,6 @@ if (void 0) {
|
|
|
6023
6274
|
});
|
|
6024
6275
|
}
|
|
6025
6276
|
|
|
6026
|
-
// src/multicast-auth-catalog.ts
|
|
6027
|
-
var RAW_ED25519_KEY_LENGTH = 32;
|
|
6028
|
-
var SOURCE_AUTH_SCOPE_LENGTH = 32;
|
|
6029
|
-
var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
6030
|
-
function encodeBase64Url(bytes) {
|
|
6031
|
-
let output = "";
|
|
6032
|
-
for (let i = 0; i < bytes.length; i += 3) {
|
|
6033
|
-
const b0 = bytes[i];
|
|
6034
|
-
const b1 = bytes[i + 1];
|
|
6035
|
-
const b2 = bytes[i + 2];
|
|
6036
|
-
output += BASE64URL_ALPHABET[b0 >> 2];
|
|
6037
|
-
output += BASE64URL_ALPHABET[(b0 & 3) << 4 | (b1 === void 0 ? 0 : b1 >> 4)];
|
|
6038
|
-
if (b1 === void 0) break;
|
|
6039
|
-
output += BASE64URL_ALPHABET[(b1 & 15) << 2 | (b2 === void 0 ? 0 : b2 >> 6)];
|
|
6040
|
-
if (b2 === void 0) break;
|
|
6041
|
-
output += BASE64URL_ALPHABET[b2 & 63];
|
|
6042
|
-
}
|
|
6043
|
-
return output;
|
|
6044
|
-
}
|
|
6045
|
-
var BASE64URL_DECODE_TABLE = (() => {
|
|
6046
|
-
const table = new Int8Array(128).fill(-1);
|
|
6047
|
-
for (let i = 0; i < BASE64URL_ALPHABET.length; i++) {
|
|
6048
|
-
table[BASE64URL_ALPHABET.charCodeAt(i)] = i;
|
|
6049
|
-
}
|
|
6050
|
-
return table;
|
|
6051
|
-
})();
|
|
6052
|
-
function decodeBase64Url(text) {
|
|
6053
|
-
if (text.length % 4 === 1) {
|
|
6054
|
-
throw new Error(`[multicast-auth-catalog] invalid unpadded base64url length for "${text}"`);
|
|
6055
|
-
}
|
|
6056
|
-
const bytes = [];
|
|
6057
|
-
let buffer = 0;
|
|
6058
|
-
let bits = 0;
|
|
6059
|
-
for (let i = 0; i < text.length; i++) {
|
|
6060
|
-
const code = text.charCodeAt(i);
|
|
6061
|
-
const value = code < 128 ? BASE64URL_DECODE_TABLE[code] : -1;
|
|
6062
|
-
if (value === void 0 || value < 0) {
|
|
6063
|
-
throw new Error(`[multicast-auth-catalog] invalid base64url character in "${text}"`);
|
|
6064
|
-
}
|
|
6065
|
-
buffer = buffer << 6 | value;
|
|
6066
|
-
bits += 6;
|
|
6067
|
-
if (bits >= 8) {
|
|
6068
|
-
bits -= 8;
|
|
6069
|
-
bytes.push(buffer >> bits & 255);
|
|
6070
|
-
}
|
|
6071
|
-
}
|
|
6072
|
-
const decoded = Uint8Array.from(bytes);
|
|
6073
|
-
if (encodeBase64Url(decoded) !== text) {
|
|
6074
|
-
throw new Error(`[multicast-auth-catalog] non-canonical base64url encoding "${text}"`);
|
|
6075
|
-
}
|
|
6076
|
-
return decoded;
|
|
6077
|
-
}
|
|
6078
|
-
function decodeAuthScope(authScope) {
|
|
6079
|
-
const bytes = decodeBase64Url(authScope);
|
|
6080
|
-
if (bytes.byteLength !== SOURCE_AUTH_SCOPE_LENGTH) {
|
|
6081
|
-
throw new Error(
|
|
6082
|
-
`[multicast-auth-catalog] authScope must decode to ${SOURCE_AUTH_SCOPE_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
6083
|
-
);
|
|
6084
|
-
}
|
|
6085
|
-
return bytes;
|
|
6086
|
-
}
|
|
6087
|
-
function decodeEd25519PublicKey(publicKey) {
|
|
6088
|
-
const bytes = decodeBase64Url(publicKey);
|
|
6089
|
-
if (bytes.byteLength !== RAW_ED25519_KEY_LENGTH) {
|
|
6090
|
-
throw new Error(
|
|
6091
|
-
`[multicast-auth-catalog] public key must decode to ${RAW_ED25519_KEY_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
6092
|
-
);
|
|
6093
|
-
}
|
|
6094
|
-
return bytes;
|
|
6095
|
-
}
|
|
6096
|
-
function isNonEmptyString(value) {
|
|
6097
|
-
return typeof value === "string" && value.length > 0;
|
|
6098
|
-
}
|
|
6099
|
-
function isValidAuthScopeField(value) {
|
|
6100
|
-
if (!isNonEmptyString(value)) return false;
|
|
6101
|
-
try {
|
|
6102
|
-
decodeAuthScope(value);
|
|
6103
|
-
return true;
|
|
6104
|
-
} catch {
|
|
6105
|
-
return false;
|
|
6106
|
-
}
|
|
6107
|
-
}
|
|
6108
|
-
function isValidPublicKeyField(value) {
|
|
6109
|
-
if (!isNonEmptyString(value)) return false;
|
|
6110
|
-
try {
|
|
6111
|
-
decodeEd25519PublicKey(value);
|
|
6112
|
-
return true;
|
|
6113
|
-
} catch {
|
|
6114
|
-
return false;
|
|
6115
|
-
}
|
|
6116
|
-
}
|
|
6117
|
-
function hasOnlyKeys(object2, allowed) {
|
|
6118
|
-
const allowedKeys = new Set(allowed);
|
|
6119
|
-
return Object.keys(object2).every((key) => allowedKeys.has(key));
|
|
6120
|
-
}
|
|
6121
|
-
function isMulticastAuthTrackConfig(obj) {
|
|
6122
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
6123
|
-
const o = obj;
|
|
6124
|
-
return hasOnlyKeys(o, ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"]) && isNonEmptyString(o["mediaTrack"]) && isNonEmptyString(o["manifestTrack"]) && o["mediaTrack"] !== o["manifestTrack"] && isValidAuthScopeField(o["authScope"]) && isNonEmptyString(o["sourceSymbolFormat"]);
|
|
6125
|
-
}
|
|
6126
|
-
var VALID_COMPACTION = /* @__PURE__ */ new Set(["merkle", "none"]);
|
|
6127
|
-
var VALID_ENFORCEMENT = /* @__PURE__ */ new Set(["shadow", "enforce"]);
|
|
6128
|
-
function hasUniqueMulticastAuthTrackBindings(tracks) {
|
|
6129
|
-
const bindings = tracks.flatMap((track) => {
|
|
6130
|
-
if (typeof track !== "object" || track === null) return [];
|
|
6131
|
-
const value = track;
|
|
6132
|
-
if (typeof value["mediaTrack"] !== "string" || typeof value["sourceSymbolFormat"] !== "string") {
|
|
6133
|
-
return [];
|
|
6134
|
-
}
|
|
6135
|
-
return [JSON.stringify([value["mediaTrack"], value["sourceSymbolFormat"]])];
|
|
6136
|
-
});
|
|
6137
|
-
return new Set(bindings).size === bindings.length;
|
|
6138
|
-
}
|
|
6139
|
-
function isMulticastAuthConfig(obj) {
|
|
6140
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
6141
|
-
const o = obj;
|
|
6142
|
-
if (o["scheme"] !== "bc-provenance") return false;
|
|
6143
|
-
if (o["hash"] !== "blake3") return false;
|
|
6144
|
-
if (o["sig"] !== "ed25519") return false;
|
|
6145
|
-
if (!hasOnlyKeys(o, ["scheme", "hash", "sig", "publicKey", "keyId", "previousKey", "compaction", "enforcement", "tracks"])) return false;
|
|
6146
|
-
if (!isValidPublicKeyField(o["publicKey"])) return false;
|
|
6147
|
-
if (!isNonEmptyString(o["keyId"])) return false;
|
|
6148
|
-
if (o["previousKey"] !== void 0 && !isValidPublicKeyField(o["previousKey"])) return false;
|
|
6149
|
-
if (o["previousKey"] === o["publicKey"]) return false;
|
|
6150
|
-
if (typeof o["compaction"] !== "string" || !VALID_COMPACTION.has(o["compaction"])) return false;
|
|
6151
|
-
if (o["enforcement"] !== void 0) {
|
|
6152
|
-
if (typeof o["enforcement"] !== "string" || !VALID_ENFORCEMENT.has(o["enforcement"])) return false;
|
|
6153
|
-
}
|
|
6154
|
-
if (!Array.isArray(o["tracks"]) || o["tracks"].length === 0) return false;
|
|
6155
|
-
const tracks = o["tracks"];
|
|
6156
|
-
if (!tracks.every((t) => isMulticastAuthTrackConfig(t))) return false;
|
|
6157
|
-
const typedTracks = tracks;
|
|
6158
|
-
const scopes = typedTracks.map((t) => t.authScope);
|
|
6159
|
-
if (new Set(scopes).size !== scopes.length) return false;
|
|
6160
|
-
if (!hasUniqueMulticastAuthTrackBindings(typedTracks)) return false;
|
|
6161
|
-
const manifestTracks = typedTracks.map((t) => t.manifestTrack);
|
|
6162
|
-
if (new Set(manifestTracks).size !== manifestTracks.length) return false;
|
|
6163
|
-
return true;
|
|
6164
|
-
}
|
|
6165
|
-
function resolveMulticastAuthMode(playerMode, auth) {
|
|
6166
|
-
if (playerMode !== void 0) return playerMode;
|
|
6167
|
-
if (auth === void 0) return "off";
|
|
6168
|
-
return auth.enforcement ?? "shadow";
|
|
6169
|
-
}
|
|
6170
|
-
function resolveMulticastAuthCatalog(catalog, playerMode) {
|
|
6171
|
-
if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) {
|
|
6172
|
-
throw new Error("[multicast-auth-catalog] catalog must be an object");
|
|
6173
|
-
}
|
|
6174
|
-
const root = catalog;
|
|
6175
|
-
const rawAuth = root["multicast.auth"];
|
|
6176
|
-
if (rawAuth === void 0) {
|
|
6177
|
-
if (playerMode === "enforce") {
|
|
6178
|
-
throw new Error("[multicast-auth-catalog] player enforce mode requires multicast.auth");
|
|
6179
|
-
}
|
|
6180
|
-
return void 0;
|
|
6181
|
-
}
|
|
6182
|
-
if (!isMulticastAuthConfig(rawAuth)) {
|
|
6183
|
-
throw new Error("[multicast-auth-catalog] invalid multicast.auth v2 block");
|
|
6184
|
-
}
|
|
6185
|
-
const rawTracks = root["tracks"];
|
|
6186
|
-
if (!Array.isArray(rawTracks)) {
|
|
6187
|
-
throw new Error("[multicast-auth-catalog] catalog tracks must be an array");
|
|
6188
|
-
}
|
|
6189
|
-
const catalogTrackNames = new Set(
|
|
6190
|
-
rawTracks.flatMap(
|
|
6191
|
-
(track) => typeof track === "object" && track !== null && typeof track["name"] === "string" ? [track["name"]] : []
|
|
6192
|
-
)
|
|
6193
|
-
);
|
|
6194
|
-
for (const track of rawAuth.tracks) {
|
|
6195
|
-
if (!catalogTrackNames.has(track.mediaTrack)) {
|
|
6196
|
-
throw new Error(`[multicast-auth-catalog] unknown mediaTrack "${track.mediaTrack}"`);
|
|
6197
|
-
}
|
|
6198
|
-
if (!catalogTrackNames.has(track.manifestTrack)) {
|
|
6199
|
-
throw new Error(`[multicast-auth-catalog] unknown manifestTrack "${track.manifestTrack}"`);
|
|
6200
|
-
}
|
|
6201
|
-
}
|
|
6202
|
-
return {
|
|
6203
|
-
keyId: rawAuth.keyId,
|
|
6204
|
-
acceptedPublicKeys: [
|
|
6205
|
-
decodeEd25519PublicKey(rawAuth.publicKey),
|
|
6206
|
-
...rawAuth.previousKey === void 0 ? [] : [decodeEd25519PublicKey(rawAuth.previousKey)]
|
|
6207
|
-
],
|
|
6208
|
-
mode: resolveMulticastAuthMode(playerMode, rawAuth),
|
|
6209
|
-
compaction: rawAuth.compaction,
|
|
6210
|
-
tracks: rawAuth.tracks.map((track) => ({
|
|
6211
|
-
...track,
|
|
6212
|
-
authScope: decodeAuthScope(track.authScope)
|
|
6213
|
-
}))
|
|
6214
|
-
};
|
|
6215
|
-
}
|
|
6216
|
-
|
|
6217
6277
|
// src/repair-layers.ts
|
|
6218
6278
|
var REPAIR_PRIORITY_MIN = 192;
|
|
6219
6279
|
var REPAIR_PRIORITY_MAX = 255;
|
|
@@ -6572,8 +6632,7 @@ function isMulticastTrackObject(obj) {
|
|
|
6572
6632
|
function isMulticastEndpoint(obj) {
|
|
6573
6633
|
if (typeof obj !== "object" || obj === null) return false;
|
|
6574
6634
|
const o = obj;
|
|
6575
|
-
|
|
6576
|
-
return typeof protocol === "string" && (protocol === "ssm" || protocol === "asm" || protocol === "amt" || protocol === "atsc3") && typeof o["groupAddress"] === "string" && o["groupAddress"].length > 0 && typeof o["port"] === "number" && o["port"] > 0 && o["port"] <= 65535 && Array.isArray(o["tracks"]) && o["tracks"].every((t) => typeof t === "string" || isMulticastTrackObject(t));
|
|
6635
|
+
return multicastEndpointSource(o) !== void 0 && typeof o["groupAddress"] === "string" && o["groupAddress"].length > 0 && typeof o["port"] === "number" && o["port"] > 0 && o["port"] <= 65535 && Array.isArray(o["tracks"]) && o["tracks"].every((t) => typeof t === "string" || isMulticastTrackObject(t));
|
|
6577
6636
|
}
|
|
6578
6637
|
function isMulticastCatalogConfig(obj) {
|
|
6579
6638
|
if (typeof obj !== "object" || obj === null) return false;
|
|
@@ -6677,7 +6736,7 @@ var CmsfCatalogValidationError = class extends Error {
|
|
|
6677
6736
|
function catalogError(code, path, message) {
|
|
6678
6737
|
throw new CmsfCatalogValidationError(code, path, message);
|
|
6679
6738
|
}
|
|
6680
|
-
function validateCmsfMmtpCatalog(value) {
|
|
6739
|
+
function validateCmsfMmtpCatalog(value, options = {}) {
|
|
6681
6740
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
6682
6741
|
catalogError("catalog_object", "$", "catalog must be an object");
|
|
6683
6742
|
}
|
|
@@ -6698,6 +6757,22 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6698
6757
|
"commonTrackFields is retired; every track carries its own fields"
|
|
6699
6758
|
);
|
|
6700
6759
|
}
|
|
6760
|
+
const initDataList = catalog["initDataList"];
|
|
6761
|
+
if (initDataList !== void 0) {
|
|
6762
|
+
if (!Array.isArray(initDataList)) {
|
|
6763
|
+
catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
|
|
6764
|
+
}
|
|
6765
|
+
initDataList.forEach((entry, i) => {
|
|
6766
|
+
const e = entry;
|
|
6767
|
+
const entryPath = `$.initDataList[${i}]`;
|
|
6768
|
+
if (typeof e !== "object" || e === null || Array.isArray(e) || typeof e["id"] !== "string" || e["id"].length === 0 || typeof e["type"] !== "string" || e["type"].length === 0) {
|
|
6769
|
+
catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
|
|
6770
|
+
}
|
|
6771
|
+
if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
|
|
6772
|
+
catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
|
|
6773
|
+
}
|
|
6774
|
+
});
|
|
6775
|
+
}
|
|
6701
6776
|
const tracks = catalog["tracks"];
|
|
6702
6777
|
const trackRecords = [];
|
|
6703
6778
|
const positiveInteger3 = (input) => Number.isSafeInteger(input) && input > 0;
|
|
@@ -6749,6 +6824,14 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6749
6824
|
if (keyframeIntervalMs !== void 0 && !positiveNumber2(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !positiveInteger3(keyframeIntervalTicks)) {
|
|
6750
6825
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
6751
6826
|
}
|
|
6827
|
+
const anchor = track["presentationAnchorTicks"];
|
|
6828
|
+
if (anchor !== void 0 && !Number.isSafeInteger(anchor)) {
|
|
6829
|
+
catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
|
|
6830
|
+
}
|
|
6831
|
+
const initRef = track["initRef"];
|
|
6832
|
+
if (initRef !== void 0 && (typeof initRef !== "string" || initRef.length === 0)) {
|
|
6833
|
+
catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
|
|
6834
|
+
}
|
|
6752
6835
|
if (packaging === "fec-repair") {
|
|
6753
6836
|
rejectRepairTrackGeometry(path, track, catalogError);
|
|
6754
6837
|
validateRepairTrackFields(describeRepairTrack(name, path, track), catalogError);
|
|
@@ -6756,9 +6839,8 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6756
6839
|
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
6757
6840
|
}
|
|
6758
6841
|
if (packaging === "mmtp") {
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
|
|
6842
|
+
if (track["mmtpMode"] !== "mfu") {
|
|
6843
|
+
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
|
|
6762
6844
|
}
|
|
6763
6845
|
if (!positiveInteger3(timescale)) {
|
|
6764
6846
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
@@ -6811,6 +6893,9 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6811
6893
|
}
|
|
6812
6894
|
}
|
|
6813
6895
|
readFecBlockProfile(config["blockProfile"], `${path}.fec.blockProfile`, algorithm !== "none", catalogError);
|
|
6896
|
+
if (algorithm !== "none" && config["symbolSize"] < ISO_SSBG1_MIN_SYMBOL_SIZE) {
|
|
6897
|
+
catalogError("track_fec", `${path}.fec.symbolSize`, "iso-ssbg1-v1 symbolSize must be at least 14");
|
|
6898
|
+
}
|
|
6814
6899
|
}
|
|
6815
6900
|
}
|
|
6816
6901
|
const repairDescriptors = trackRecords.flatMap(
|
|
@@ -6922,15 +7007,8 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
6922
7007
|
}
|
|
6923
7008
|
}
|
|
6924
7009
|
}
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
} catch (error) {
|
|
6928
|
-
catalogError(
|
|
6929
|
-
"multicast_auth",
|
|
6930
|
-
"$.multicast.auth",
|
|
6931
|
-
error instanceof Error ? error.message : "invalid multicast.auth v2 block"
|
|
6932
|
-
);
|
|
6933
|
-
}
|
|
7010
|
+
const [multicastIssue] = multicastCatalogIssues(catalog, options);
|
|
7011
|
+
if (multicastIssue) catalogError(multicastIssue.code, multicastIssue.path, multicastIssue.message);
|
|
6934
7012
|
validateArchive(catalog);
|
|
6935
7013
|
return catalog;
|
|
6936
7014
|
}
|
|
@@ -6956,7 +7034,7 @@ function resolveGroupDurationTicks(timing, timescale) {
|
|
|
6956
7034
|
const product = timing.groupDurationMs * timescale;
|
|
6957
7035
|
if (product % 1e3 !== 0) {
|
|
6958
7036
|
throw new Error(
|
|
6959
|
-
`[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} produces non-integer ticks (${product / 1e3}); publisher must use groupDurationTicks override (mmt-
|
|
7037
|
+
`[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} produces non-integer ticks (${product / 1e3}); publisher must use groupDurationTicks override (mmt-01 \xA74.4.2)`
|
|
6960
7038
|
);
|
|
6961
7039
|
}
|
|
6962
7040
|
return product / 1e3;
|
|
@@ -6977,14 +7055,6 @@ function validateSwitchingSetTiming(tracks) {
|
|
|
6977
7055
|
return { ok: false, expectedTicks, mismatches };
|
|
6978
7056
|
}
|
|
6979
7057
|
|
|
6980
|
-
// node_modules/@blockcast/mmt-transport/dist/types.js
|
|
6981
|
-
var MoqFecAlgorithm;
|
|
6982
|
-
(function(MoqFecAlgorithm2) {
|
|
6983
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["None"] = 0] = "None";
|
|
6984
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["Xor"] = 1] = "Xor";
|
|
6985
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
|
|
6986
|
-
})(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
|
|
6987
|
-
|
|
6988
7058
|
// node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
|
|
6989
7059
|
function endpointKey(endpoint) {
|
|
6990
7060
|
return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
|
|
@@ -7115,8 +7185,8 @@ var AdaptiveBitrateController = class {
|
|
|
7115
7185
|
/**
|
|
7116
7186
|
* Update FEC statistics for ABR decisions
|
|
7117
7187
|
*
|
|
7118
|
-
*
|
|
7119
|
-
*
|
|
7188
|
+
* ABR uses the effective loss rate (after FEC recovery) rather than the
|
|
7189
|
+
* raw transport loss rate.
|
|
7120
7190
|
*
|
|
7121
7191
|
* @param stats - FEC statistics from the FEC decoder
|
|
7122
7192
|
*/
|
|
@@ -8713,8 +8783,7 @@ function multicastFromConfig(input) {
|
|
|
8713
8783
|
);
|
|
8714
8784
|
}
|
|
8715
8785
|
}
|
|
8716
|
-
const
|
|
8717
|
-
const endpoints = input.endpoints.map((ep, idx) => validateEndpoint2(ep, idx, seenTuples));
|
|
8786
|
+
const endpoints = input.endpoints.map((ep, idx) => validateEndpoint2(ep, idx));
|
|
8718
8787
|
const out = { endpoints };
|
|
8719
8788
|
const { entries: networkSource, relayFrom } = resolveNetworkSource(input);
|
|
8720
8789
|
networkSource.forEach(validateNetworkSourceEntry);
|
|
@@ -8751,6 +8820,17 @@ function multicastFromConfig(input) {
|
|
|
8751
8820
|
`endpoint[${idx}] protocol=${ep.protocol} requires a multicast.networkSource entry of type "${ep.protocol}"` + (ep.protocol === "atsc3" ? " carrying frequency, plpId, serviceId and slsUri \u2014 an ATSC3 endpoint is not tunable without them" : "")
|
|
8752
8821
|
);
|
|
8753
8822
|
});
|
|
8823
|
+
input.endpoints.forEach((ep, idx) => {
|
|
8824
|
+
if (ep.protocol !== "amt" && ep.protocol !== "atsc3") return;
|
|
8825
|
+
endpoints[idx].networkSource = networkSource.filter((s) => s.type === ep.protocol).map((s) => ({ ...s }));
|
|
8826
|
+
});
|
|
8827
|
+
if (input.auth !== void 0) out.auth = input.auth;
|
|
8828
|
+
const [issue] = multicastCatalogIssues({ multicast: out });
|
|
8829
|
+
if (issue) {
|
|
8830
|
+
const kind = issue.code === "multicast_auth" ? "invalid_multicast_auth" : issue.code === "multicast_endpoint_auth" ? "invalid_endpoint_auth" : issue.path.endsWith(".port") ? "duplicate_endpoint_tuple" : "protocol_source_mismatch";
|
|
8831
|
+
const where = issue.endpointIndex === void 0 ? "" : `endpoint[${issue.endpointIndex}] `;
|
|
8832
|
+
throw new MulticastInputError(kind, issue.endpointIndex ?? null, `${where}${issue.path.replace("$.multicast.", "")}: ${issue.message}`);
|
|
8833
|
+
}
|
|
8754
8834
|
if (input.enabled !== void 0) out.enabled = input.enabled;
|
|
8755
8835
|
if (input.version !== void 0) out.version = input.version;
|
|
8756
8836
|
if (input.validUntil !== void 0) out.validUntil = input.validUntil;
|
|
@@ -8762,10 +8842,10 @@ function resolveNetworkSource(input) {
|
|
|
8762
8842
|
}
|
|
8763
8843
|
const relayDns = input.amtFallback?.relayDns?.trim();
|
|
8764
8844
|
const relay = relayDns || input.endpoints.map((ep) => ep.relayAddress?.trim()).find((r) => !!r);
|
|
8765
|
-
const discovery = input.amtFallback?.discovery
|
|
8766
|
-
if (discovery === void 0) return { entries: [], relayFrom: null };
|
|
8845
|
+
const discovery = input.amtFallback?.discovery;
|
|
8846
|
+
if (discovery === void 0 && !relay) return { entries: [], relayFrom: null };
|
|
8767
8847
|
return {
|
|
8768
|
-
entries: [{ type: "amt", discovery, ...relay ? { relay } : {} }],
|
|
8848
|
+
entries: [{ type: "amt", ...discovery ? { discovery } : {}, ...relay ? { relay } : {} }],
|
|
8769
8849
|
relayFrom: !relay ? null : relayDns ? "amtFallback.relayDns" : "endpoint.relayAddress"
|
|
8770
8850
|
};
|
|
8771
8851
|
}
|
|
@@ -8778,8 +8858,11 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
8778
8858
|
const extra = Object.keys(s).filter((k) => !keys.has(k) && s[k] !== void 0);
|
|
8779
8859
|
if (extra.length > 0) throw err("invalid_network_source", `has keys the schema rejects: ${extra.join(", ")}`);
|
|
8780
8860
|
if (s.type === "amt") {
|
|
8781
|
-
if (s.discovery !== "driad" && s.discovery !== "manual") {
|
|
8782
|
-
throw err(
|
|
8861
|
+
if (s.discovery !== void 0 && s.discovery !== "dns" && s.discovery !== "driad" && s.discovery !== "manual") {
|
|
8862
|
+
throw err(
|
|
8863
|
+
"invalid_amt_discovery",
|
|
8864
|
+
`discovery must be "dns", "driad" or "manual" when present; got ${JSON.stringify(s.discovery)}`
|
|
8865
|
+
);
|
|
8783
8866
|
}
|
|
8784
8867
|
if (s.relay !== void 0) {
|
|
8785
8868
|
const relay = typeof s.relay === "string" ? s.relay.trim() : "";
|
|
@@ -8788,8 +8871,8 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
8788
8871
|
}
|
|
8789
8872
|
s.relay = relay;
|
|
8790
8873
|
}
|
|
8791
|
-
if (s.discovery === "manual" && s.relay === void 0) {
|
|
8792
|
-
throw err("amt_requires_relay", `discovery="
|
|
8874
|
+
if ((s.discovery === "dns" || s.discovery === "manual") && s.relay === void 0) {
|
|
8875
|
+
throw err("amt_requires_relay", `discovery="${s.discovery}" requires a relay ("driad" resolves it at runtime)`);
|
|
8793
8876
|
}
|
|
8794
8877
|
if (s.port !== void 0 && (!Number.isInteger(s.port) || s.port < 1 || s.port > 65535)) {
|
|
8795
8878
|
throw err("invalid_port", `port must be 1..65535; got ${s.port}`);
|
|
@@ -8816,7 +8899,7 @@ function isAbsoluteUri(value) {
|
|
|
8816
8899
|
return false;
|
|
8817
8900
|
}
|
|
8818
8901
|
}
|
|
8819
|
-
function validateEndpoint2(ep, idx
|
|
8902
|
+
function validateEndpoint2(ep, idx) {
|
|
8820
8903
|
if (ep.protocol === "ssm" && (!ep.sourceAddress || ep.sourceAddress.length === 0)) {
|
|
8821
8904
|
throw new MulticastInputError(
|
|
8822
8905
|
"ssm_requires_source",
|
|
@@ -8824,6 +8907,13 @@ function validateEndpoint2(ep, idx, seenTuples) {
|
|
|
8824
8907
|
`endpoint[${idx}] protocol=ssm requires sourceAddress`
|
|
8825
8908
|
);
|
|
8826
8909
|
}
|
|
8910
|
+
if (ep.protocol === "asm" && ep.sourceAddress !== void 0) {
|
|
8911
|
+
throw new MulticastInputError(
|
|
8912
|
+
"protocol_source_mismatch",
|
|
8913
|
+
idx,
|
|
8914
|
+
`endpoint[${idx}] protocol=asm with sourceAddress "${ep.sourceAddress}"; sourceAddress selects SSM (draft -01 4.1)`
|
|
8915
|
+
);
|
|
8916
|
+
}
|
|
8827
8917
|
if (!isMulticastGroupAddress(ep.groupAddress)) {
|
|
8828
8918
|
throw new MulticastInputError(
|
|
8829
8919
|
"invalid_group_address",
|
|
@@ -8883,23 +8973,15 @@ function validateEndpoint2(ep, idx, seenTuples) {
|
|
|
8883
8973
|
`endpoint[${idx}] bandwidth must be positive; got ${ep.bandwidth}`
|
|
8884
8974
|
);
|
|
8885
8975
|
}
|
|
8886
|
-
const tupleKey = `${ep.sourceAddress ?? ""}|${ep.groupAddress}|${ep.port}`;
|
|
8887
|
-
if (seenTuples.has(tupleKey)) {
|
|
8888
|
-
throw new MulticastInputError(
|
|
8889
|
-
"duplicate_endpoint_tuple",
|
|
8890
|
-
idx,
|
|
8891
|
-
`endpoint[${idx}] duplicates (sourceAddress, groupAddress, port) tuple "${tupleKey}"`
|
|
8892
|
-
);
|
|
8893
|
-
}
|
|
8894
|
-
seenTuples.add(tupleKey);
|
|
8895
8976
|
const out = {
|
|
8896
|
-
protocol: ep.
|
|
8977
|
+
protocol: ep.sourceAddress === void 0 ? "asm" : "ssm",
|
|
8897
8978
|
groupAddress: ep.groupAddress,
|
|
8898
8979
|
port: ep.port,
|
|
8899
8980
|
tracks: ep.tracks.map((t) => ({ name: t.name, packetId: t.packetId }))
|
|
8900
8981
|
};
|
|
8901
8982
|
if (ep.sourceAddress !== void 0) out.sourceAddress = ep.sourceAddress;
|
|
8902
8983
|
if (ep.bandwidth !== void 0) out.bandwidth = ep.bandwidth;
|
|
8984
|
+
if (ep.auth !== void 0) out.auth = { ...ep.auth };
|
|
8903
8985
|
return out;
|
|
8904
8986
|
}
|
|
8905
8987
|
function isMulticastGroupAddress(addr) {
|
|
@@ -8942,9 +9024,9 @@ function multicastFromEnv(env = globalThis.process?.env ?? {}) {
|
|
|
8942
9024
|
endpoints,
|
|
8943
9025
|
...hasCatalogAmt ? {
|
|
8944
9026
|
amtFallback: {
|
|
8945
|
-
//
|
|
8946
|
-
//
|
|
8947
|
-
discovery: amtDiscovery
|
|
9027
|
+
// No default: an omitted discovery with a relay hostname is
|
|
9028
|
+
// "dns" (draft-ramadan-moq-multicast-01 4.2.1).
|
|
9029
|
+
...amtDiscovery ? { discovery: amtDiscovery } : {},
|
|
8948
9030
|
...amtRelayDns ? { relayDns: amtRelayDns } : {}
|
|
8949
9031
|
}
|
|
8950
9032
|
} : {}
|
|
@@ -9112,7 +9194,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
9112
9194
|
if (ot.role !== void 0 && existing.role === void 0) existing.role = ot.role;
|
|
9113
9195
|
if (existing.packaging === "mmtp") {
|
|
9114
9196
|
const mode = existing.mmtpMode ?? ot.mmtpMode;
|
|
9115
|
-
if (mode !== "
|
|
9197
|
+
if (mode !== "mfu") {
|
|
9116
9198
|
throw new Error(
|
|
9117
9199
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
9118
9200
|
);
|
|
@@ -9149,7 +9231,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
9149
9231
|
);
|
|
9150
9232
|
}
|
|
9151
9233
|
const mmtpMode = ot.mmtpMode;
|
|
9152
|
-
if (packaging === "mmtp" && mmtpMode !== "
|
|
9234
|
+
if (packaging === "mmtp" && mmtpMode !== "mfu") {
|
|
9153
9235
|
throw new Error(
|
|
9154
9236
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
9155
9237
|
);
|
|
@@ -9450,8 +9532,8 @@ function u32(v) {
|
|
|
9450
9532
|
}
|
|
9451
9533
|
var KEYFRAME_FLAGS = 33554432;
|
|
9452
9534
|
var DELTA_FLAGS = 16842752;
|
|
9453
|
-
var
|
|
9454
|
-
var MAX_TRACK_ID =
|
|
9535
|
+
var UINT32_MAX2 = 4294967295;
|
|
9536
|
+
var MAX_TRACK_ID = UINT32_MAX2 - 1;
|
|
9455
9537
|
var INT32_MIN = -2147483648;
|
|
9456
9538
|
var INT32_MAX = 2147483647;
|
|
9457
9539
|
function assertTrackId(trackId, label) {
|
|
@@ -9460,8 +9542,8 @@ function assertTrackId(trackId, label) {
|
|
|
9460
9542
|
}
|
|
9461
9543
|
}
|
|
9462
9544
|
function assertTimescale(timescale, label) {
|
|
9463
|
-
if (!Number.isInteger(timescale) || timescale <= 0 || timescale >
|
|
9464
|
-
throw new RangeError(`${label} must be an integer in 1..${
|
|
9545
|
+
if (!Number.isInteger(timescale) || timescale <= 0 || timescale > UINT32_MAX2) {
|
|
9546
|
+
throw new RangeError(`${label} must be an integer in 1..${UINT32_MAX2}, got ${timescale}`);
|
|
9465
9547
|
}
|
|
9466
9548
|
}
|
|
9467
9549
|
function assertCompositionTimeOffsets(samples) {
|
|
@@ -12544,7 +12626,7 @@ function isPositiveSafeInteger2(value) {
|
|
|
12544
12626
|
function catalogDeclaresFec(fec) {
|
|
12545
12627
|
const block = recordOf2(fec);
|
|
12546
12628
|
if (block === void 0 || block["algorithm"] === "none") return false;
|
|
12547
|
-
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
|
|
12629
|
+
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block) && !catalogFecDeclaresUnconfigurableInstance(block);
|
|
12548
12630
|
}
|
|
12549
12631
|
function requireBoolean(value, field) {
|
|
12550
12632
|
if (typeof value !== "boolean") {
|
|
@@ -18977,6 +19059,12 @@ var MmtpRouter = class {
|
|
|
18977
19059
|
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
18978
19060
|
*/
|
|
18979
19061
|
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
19062
|
+
/**
|
|
19063
|
+
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
19064
|
+
* not parsed, typically because its overlap copy was parsed first
|
|
19065
|
+
* (BLO-49179). The next video keyframe emitted on the stream consumes it.
|
|
19066
|
+
*/
|
|
19067
|
+
#multicastRapTwinByStream = /* @__PURE__ */ new Set();
|
|
18980
19068
|
#lastDirectSourceVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18981
19069
|
#lastDirectEmittedVideoTsByStream = /* @__PURE__ */ new Map();
|
|
18982
19070
|
#pendingDirectRecoveredVideoByStream = /* @__PURE__ */ new Map();
|
|
@@ -19110,6 +19198,12 @@ var MmtpRouter = class {
|
|
|
19110
19198
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName }
|
|
19111
19199
|
};
|
|
19112
19200
|
if (meta.source) frameMeta.source = meta.source;
|
|
19201
|
+
if (isVideo && frameMeta.keyframe) {
|
|
19202
|
+
const twinSeen = this.#multicastRapTwinByStream.delete(
|
|
19203
|
+
this.#mediaStreamKey(packetId, frameMeta.catalogTrackName)
|
|
19204
|
+
);
|
|
19205
|
+
if (twinSeen && frameMeta.source === "moq") frameMeta.source = "multicast";
|
|
19206
|
+
}
|
|
19113
19207
|
if (meta.deliveryProvenance !== void 0)
|
|
19114
19208
|
frameMeta.deliveryProvenance = meta.deliveryProvenance;
|
|
19115
19209
|
if (meta.recovered) frameMeta.recovered = true;
|
|
@@ -19932,6 +20026,7 @@ var MmtpRouter = class {
|
|
|
19932
20026
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
19933
20027
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
19934
20028
|
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
20029
|
+
this.#multicastRapTwinByStream.delete(streamKey);
|
|
19935
20030
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
19936
20031
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
19937
20032
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
@@ -20730,6 +20825,10 @@ var MmtpRouter = class {
|
|
|
20730
20825
|
// An FEC source frame is anchored by its own SS_ID (C.5.2).
|
|
20731
20826
|
...fecSource && fecPayloadId ? { fecSbn: fecPayloadId.ssId } : {}
|
|
20732
20827
|
}, parsed);
|
|
20828
|
+
} else if (source === "multicast" && info.rapFlag) {
|
|
20829
|
+
this.#multicastRapTwinByStream.add(
|
|
20830
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName)
|
|
20831
|
+
);
|
|
20733
20832
|
}
|
|
20734
20833
|
if (this.#classifyPacketId(info.packetId) === null) return;
|
|
20735
20834
|
if (this.#fecManager && fecPayloadId && coords && sourceSymbolAccepted && sourceSymbolTrackable) {
|
|
@@ -23068,7 +23167,7 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
|
|
|
23068
23167
|
throwRepairContractError(
|
|
23069
23168
|
"track_fec",
|
|
23070
23169
|
`${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
|
|
23071
|
-
"must be a positive integer"
|
|
23170
|
+
kValid && Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0 ? `iso-ssbg1-v1 symbolSize must be at least ${ISO_SSBG1_MIN_SYMBOL_SIZE}` : "must be a positive integer"
|
|
23072
23171
|
);
|
|
23073
23172
|
}
|
|
23074
23173
|
const fecUnavailable = catalogFecUnavailable(fec, fecPath);
|
|
@@ -23253,6 +23352,12 @@ var REPAIR_PRIORITY_REASONS = /* @__PURE__ */ new Set([
|
|
|
23253
23352
|
"repair-priority-absent",
|
|
23254
23353
|
"repair-priority-invalid"
|
|
23255
23354
|
]);
|
|
23355
|
+
var REPAIR_SKIP_REASONS = /* @__PURE__ */ new Set([
|
|
23356
|
+
"rtt-unmeasured",
|
|
23357
|
+
"rtt-exceeds-budget",
|
|
23358
|
+
"presentation-delay-unavailable"
|
|
23359
|
+
]);
|
|
23360
|
+
var REPAIR_DEADLINE_BOUNDS = /* @__PURE__ */ new Set(["wait", "presentation", "keyframe", "retention"]);
|
|
23256
23361
|
var GAP_REASONS = {
|
|
23257
23362
|
"rap-lost": "stall",
|
|
23258
23363
|
"rap-unknown": "stall",
|
|
@@ -23275,6 +23380,9 @@ function isSymbolCounts(value) {
|
|
|
23275
23380
|
function isNullableNonNegative(value) {
|
|
23276
23381
|
return value === null || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
23277
23382
|
}
|
|
23383
|
+
function isFiniteNumber(value) {
|
|
23384
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
23385
|
+
}
|
|
23278
23386
|
function isRepairLifecycleEvent(value) {
|
|
23279
23387
|
if (!isRecord(value) || value["version"] !== 2) return false;
|
|
23280
23388
|
const block = value["block"];
|
|
@@ -23292,6 +23400,20 @@ function isRepairLifecycleEvent(value) {
|
|
|
23292
23400
|
case "repair-preempted":
|
|
23293
23401
|
case "repair-deferred":
|
|
23294
23402
|
return hasExactKeys(value, ["version", "type", "block"]) && isRepairBlockIdentity(block);
|
|
23403
|
+
case "repair-sent":
|
|
23404
|
+
return hasExactKeys(value, [
|
|
23405
|
+
"version",
|
|
23406
|
+
"type",
|
|
23407
|
+
"block",
|
|
23408
|
+
"priority",
|
|
23409
|
+
"rttMs",
|
|
23410
|
+
"budgetMs",
|
|
23411
|
+
"delayMs",
|
|
23412
|
+
"blockAgeMs",
|
|
23413
|
+
"bound"
|
|
23414
|
+
]) && 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"]);
|
|
23415
|
+
case "repair-skipped":
|
|
23416
|
+
return hasExactKeys(value, ["version", "type", "block", "reason", "rttMs", "budgetMs"]) && isRepairBlockIdentity(block) && REPAIR_SKIP_REASONS.has(value["reason"]) && isNullableNonNegative(value["rttMs"]) && isFiniteNumber(value["budgetMs"]);
|
|
23295
23417
|
case "repair-priority": {
|
|
23296
23418
|
const blockClass = value["blockClass"];
|
|
23297
23419
|
const action = value["action"];
|
|
@@ -24481,7 +24603,7 @@ var MulticastManager = class {
|
|
|
24481
24603
|
*
|
|
24482
24604
|
* D-04: Validates completeness via validateSwitchingSet — throws if incomplete.
|
|
24483
24605
|
* D-07: Applies per-track FEC configs (base+delta get decoders; repair does not).
|
|
24484
|
-
* D-17: Builds altGroup → track-name index for getSwitchingSet().
|
|
24606
|
+
* D-17: Builds altGroup → track-name index for getSwitchingSet() (repair legs excluded).
|
|
24485
24607
|
* D-26: Registers packetId → TrackRole on MmtpRouter for block-complete fanout.
|
|
24486
24608
|
*
|
|
24487
24609
|
* FEC availability is per track (draft-ramadan-moq-fec §5.1). A media track
|
|
@@ -24532,11 +24654,9 @@ var MulticastManager = class {
|
|
|
24532
24654
|
}
|
|
24533
24655
|
}
|
|
24534
24656
|
const repairOwnerGroup = /* @__PURE__ */ new Map();
|
|
24535
|
-
const repairOwnerAltGroup = /* @__PURE__ */ new Map();
|
|
24536
24657
|
for (const track of catalog.tracks) {
|
|
24537
24658
|
for (const repairName of repairNamesBySource.get(track.name) ?? []) {
|
|
24538
24659
|
repairOwnerGroup.set(repairName, altGroupKey(track));
|
|
24539
|
-
repairOwnerAltGroup.set(repairName, track.altGroup);
|
|
24540
24660
|
}
|
|
24541
24661
|
}
|
|
24542
24662
|
const groupKeyFor = (track) => repairOwnerGroup.get(track.name) ?? altGroupKey(track);
|
|
@@ -24635,11 +24755,10 @@ var MulticastManager = class {
|
|
|
24635
24755
|
for (let i = 0; i < catalog.tracks.length; i++) {
|
|
24636
24756
|
const track = catalog.tracks[i];
|
|
24637
24757
|
const role = resolvedRoles[i];
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
const existing = this.#switchingSets.get(altGroup) ?? [];
|
|
24758
|
+
if (role !== "repair" && track.altGroup !== void 0) {
|
|
24759
|
+
const existing = this.#switchingSets.get(track.altGroup) ?? [];
|
|
24641
24760
|
existing.push(track.name);
|
|
24642
|
-
this.#switchingSets.set(altGroup, existing);
|
|
24761
|
+
this.#switchingSets.set(track.altGroup, existing);
|
|
24643
24762
|
}
|
|
24644
24763
|
if (track.packetId !== void 0) {
|
|
24645
24764
|
this.#router.setPacketIdRole(track.packetId, role);
|
|
@@ -24714,7 +24833,7 @@ var MulticastManager = class {
|
|
|
24714
24833
|
#multiTrackFecTracks = /* @__PURE__ */ new Map();
|
|
24715
24834
|
/**
|
|
24716
24835
|
* Return the track names belonging to the given altGroup switching set.
|
|
24717
|
-
* D-17:
|
|
24836
|
+
* D-17: tracks with equal altGroup form one switching set; repair legs are in none.
|
|
24718
24837
|
*
|
|
24719
24838
|
* @param altGroup - The altGroup number to look up.
|
|
24720
24839
|
* @returns Array of track names in that switching set (empty if none).
|
|
@@ -24794,8 +24913,19 @@ var MulticastManager = class {
|
|
|
24794
24913
|
stats.keyframeBudgetHoldMs += extensionMs;
|
|
24795
24914
|
}
|
|
24796
24915
|
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
24797
|
-
noteRepairFetchSent(priority,
|
|
24916
|
+
noteRepairFetchSent(priority, sbn, packetId, catalogTrackName, measurement) {
|
|
24798
24917
|
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
24918
|
+
this.#emitRepairLifecycle({
|
|
24919
|
+
version: 2,
|
|
24920
|
+
type: "repair-sent",
|
|
24921
|
+
block: repairBlockIdentity(packetId, sbn, catalogTrackName),
|
|
24922
|
+
priority,
|
|
24923
|
+
rttMs: measurement.rttMs,
|
|
24924
|
+
budgetMs: measurement.budgetMs,
|
|
24925
|
+
delayMs: measurement.delayMs,
|
|
24926
|
+
blockAgeMs: measurement.blockAgeMs,
|
|
24927
|
+
bound: measurement.bound
|
|
24928
|
+
});
|
|
24799
24929
|
}
|
|
24800
24930
|
/**
|
|
24801
24931
|
* Record a repair-scheduler decision about a delta block: preempted for
|
|
@@ -25712,7 +25842,7 @@ function asSeconds(n) {
|
|
|
25712
25842
|
}
|
|
25713
25843
|
return n;
|
|
25714
25844
|
}
|
|
25715
|
-
function groupIdForTicks(ticks, groupDurationTicks) {
|
|
25845
|
+
function groupIdForTicks(ticks, groupDurationTicks, presentationAnchorTicks = 0) {
|
|
25716
25846
|
if (!Number.isInteger(ticks)) {
|
|
25717
25847
|
throw new Error(
|
|
25718
25848
|
`[align] groupIdForTicks: ticks must be an integer, got ${ticks}`
|
|
@@ -25723,8 +25853,23 @@ function groupIdForTicks(ticks, groupDurationTicks) {
|
|
|
25723
25853
|
`[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`
|
|
25724
25854
|
);
|
|
25725
25855
|
}
|
|
25726
|
-
if (
|
|
25727
|
-
|
|
25856
|
+
if (!Number.isInteger(presentationAnchorTicks)) {
|
|
25857
|
+
throw new Error(
|
|
25858
|
+
`[align] groupIdForTicks: presentationAnchorTicks must be an integer, got ${presentationAnchorTicks}`
|
|
25859
|
+
);
|
|
25860
|
+
}
|
|
25861
|
+
const relativeTicks = ticks - presentationAnchorTicks;
|
|
25862
|
+
if (!Number.isSafeInteger(relativeTicks)) {
|
|
25863
|
+
throw new Error(
|
|
25864
|
+
`[align] groupIdForTicks: ticks - presentationAnchorTicks = ${relativeTicks} is not a safe integer`
|
|
25865
|
+
);
|
|
25866
|
+
}
|
|
25867
|
+
if (relativeTicks < 0) {
|
|
25868
|
+
throw new Error(
|
|
25869
|
+
`[align] groupIdForTicks: ticks ${ticks} precede presentationAnchorTicks ${presentationAnchorTicks}; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
25870
|
+
);
|
|
25871
|
+
}
|
|
25872
|
+
return Math.floor(relativeTicks / groupDurationTicks);
|
|
25728
25873
|
}
|
|
25729
25874
|
function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
25730
25875
|
if (!Number.isFinite(mediaTimeSec)) {
|
|
@@ -25737,7 +25882,11 @@ function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
|
25737
25882
|
`[align] groupIdFor: groupDurationSec must be a positive finite number, got ${groupDurationSec}`
|
|
25738
25883
|
);
|
|
25739
25884
|
}
|
|
25740
|
-
if (mediaTimeSec < 0)
|
|
25885
|
+
if (mediaTimeSec < 0) {
|
|
25886
|
+
throw new Error(
|
|
25887
|
+
`[align] groupIdFor: mediaTimeSec ${mediaTimeSec} precedes presentationAnchorTicks 0; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
25888
|
+
);
|
|
25889
|
+
}
|
|
25741
25890
|
const TS = 1e9;
|
|
25742
25891
|
const ticks = Math.round(mediaTimeSec * TS);
|
|
25743
25892
|
const durTicks = Math.round(groupDurationSec * TS);
|
|
@@ -26708,6 +26857,337 @@ var CmcdProducer = class {
|
|
|
26708
26857
|
}
|
|
26709
26858
|
};
|
|
26710
26859
|
|
|
26860
|
+
// src/mmtp-fec-session.ts
|
|
26861
|
+
var PATH_BITS = { moq: 1, multicast: 2 };
|
|
26862
|
+
var MIXED_PATHS = PATH_BITS.moq | PATH_BITS.multicast;
|
|
26863
|
+
var MmtpFecSession = class {
|
|
26864
|
+
#decoder;
|
|
26865
|
+
/** Blocks a repair has defined and that are not settled yet, by SS_Start. */
|
|
26866
|
+
#blocks = /* @__PURE__ */ new Map();
|
|
26867
|
+
/** SS_Starts of settled blocks, so a later repair for one is refused. */
|
|
26868
|
+
#settled = /* @__PURE__ */ new Set();
|
|
26869
|
+
/**
|
|
26870
|
+
* SS_IDs whose packet the parser has, with the PATH_BITS of the path it was
|
|
26871
|
+
* received on, or 0 for one the session recovered.
|
|
26872
|
+
*/
|
|
26873
|
+
#have = /* @__PURE__ */ new Map();
|
|
26874
|
+
#newest;
|
|
26875
|
+
/** The newest SS_ID when the remembered SS_IDs were last pruned. */
|
|
26876
|
+
#prunedAt;
|
|
26877
|
+
#repairPacketId;
|
|
26878
|
+
#stats = {
|
|
26879
|
+
sourceSymbols: 0,
|
|
26880
|
+
repairSymbols: 0,
|
|
26881
|
+
blocksClean: 0,
|
|
26882
|
+
blocksRecovered: 0,
|
|
26883
|
+
blocksFailed: 0,
|
|
26884
|
+
blocksReleased: 0,
|
|
26885
|
+
packetsRecovered: 0,
|
|
26886
|
+
packetsLost: 0,
|
|
26887
|
+
dropped: {},
|
|
26888
|
+
sourceSymbolsByPath: { moq: 0, multicast: 0 },
|
|
26889
|
+
repairSymbolsByPath: { moq: 0, multicast: 0 },
|
|
26890
|
+
mixedPath: { clean: 0, recovered: 0, failed: 0, released: 0 }
|
|
26891
|
+
};
|
|
26892
|
+
/**
|
|
26893
|
+
* @throws when the catalog block lacks or misstates a field the session
|
|
26894
|
+
* needs: the block profile, K, T, `interleaveDepthMs` or
|
|
26895
|
+
* `reorderToleranceMs`. None is defaulted.
|
|
26896
|
+
*/
|
|
26897
|
+
constructor(config) {
|
|
26898
|
+
const fec = config?.fec;
|
|
26899
|
+
if (!fec || typeof fec !== "object") {
|
|
26900
|
+
throw new Error("MmtpFecSession: the catalog fec block is required");
|
|
26901
|
+
}
|
|
26902
|
+
this.blockProfile = parseFecBlockProfile(fec.blockProfile, "fec.blockProfile");
|
|
26903
|
+
this.sourceSymbols = requirePositiveInteger(fec.sourceSymbols, "fec.sourceSymbols");
|
|
26904
|
+
this.symbolSize = requirePositiveInteger(fec.symbolSize, "fec.symbolSize");
|
|
26905
|
+
const interleaveDepthMs = requireNumber(fec.interleaveDepthMs, "fec.interleaveDepthMs");
|
|
26906
|
+
const reorderToleranceMs = requireNumber(fec.reorderToleranceMs, "fec.reorderToleranceMs");
|
|
26907
|
+
this.retentionBlocks = deriveFecRetentionBlocks(
|
|
26908
|
+
fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs),
|
|
26909
|
+
interleaveDepthMs
|
|
26910
|
+
);
|
|
26911
|
+
if (typeof config.Decoder !== "function") {
|
|
26912
|
+
throw new Error("MmtpFecSession: a decoder constructor (wasm_bindgen.MmtFecDecoder) is required");
|
|
26913
|
+
}
|
|
26914
|
+
const decoder = new config.Decoder(this.retentionBlocks, this.blockProfile);
|
|
26915
|
+
try {
|
|
26916
|
+
decoder.configure_params(this.sourceSymbols, this.symbolSize);
|
|
26917
|
+
} catch (error) {
|
|
26918
|
+
decoder.free();
|
|
26919
|
+
throw error;
|
|
26920
|
+
}
|
|
26921
|
+
this.#decoder = decoder;
|
|
26922
|
+
}
|
|
26923
|
+
/** True once release() ran. */
|
|
26924
|
+
get released() {
|
|
26925
|
+
return this.#decoder === null;
|
|
26926
|
+
}
|
|
26927
|
+
get stats() {
|
|
26928
|
+
return {
|
|
26929
|
+
...this.#stats,
|
|
26930
|
+
dropped: { ...this.#stats.dropped },
|
|
26931
|
+
sourceSymbolsByPath: { ...this.#stats.sourceSymbolsByPath },
|
|
26932
|
+
repairSymbolsByPath: { ...this.#stats.repairSymbolsByPath },
|
|
26933
|
+
mixedPath: { ...this.#stats.mixedPath }
|
|
26934
|
+
};
|
|
26935
|
+
}
|
|
26936
|
+
/**
|
|
26937
|
+
* Feeds one received source packet: the MMTP packet without its four-byte
|
|
26938
|
+
* Source FEC Payload ID, under the SS_ID that ID stated. This is what
|
|
26939
|
+
* MmtpContainerParser's onSourceSymbol() hands over. `path` is where it
|
|
26940
|
+
* was received; a caller that only subscribes over MoQT can leave it out.
|
|
26941
|
+
*
|
|
26942
|
+
* @returns the protected packets of this packet's block that it recovered,
|
|
26943
|
+
* in SS_ID order, for the caller to feed to its parser with
|
|
26944
|
+
* `{skipFecPayloadId: true, recovered: true}`. Usually empty.
|
|
26945
|
+
*/
|
|
26946
|
+
addSource(ssId, packet, path = "moq") {
|
|
26947
|
+
const decoder = this.#decoder;
|
|
26948
|
+
if (!decoder) return this.#drop("source:released");
|
|
26949
|
+
const pathBit = PATH_BITS[path];
|
|
26950
|
+
if (!pathBit) return this.#drop("source:unknown-path");
|
|
26951
|
+
if (!Number.isInteger(ssId) || ssId < 0 || ssId > 4294967295) return this.#drop("source:bad-ss-id");
|
|
26952
|
+
if (!ssbg1FitsSymbol(packet.byteLength, this.symbolSize)) return this.#drop("source:exceeds-symbol");
|
|
26953
|
+
if (this.#have.has(ssId)) return this.#drop("source:duplicate");
|
|
26954
|
+
this.#have.set(ssId, pathBit);
|
|
26955
|
+
this.#stats.sourceSymbols++;
|
|
26956
|
+
this.#stats.sourceSymbolsByPath[path]++;
|
|
26957
|
+
this.#noteNewest(ssId);
|
|
26958
|
+
const start = this.#blockStartOf(ssId);
|
|
26959
|
+
const block = start === void 0 ? void 0 : this.#blocks.get(start);
|
|
26960
|
+
if (block) {
|
|
26961
|
+
block.received++;
|
|
26962
|
+
block.paths |= pathBit;
|
|
26963
|
+
}
|
|
26964
|
+
let output;
|
|
26965
|
+
try {
|
|
26966
|
+
output = decoder.add_source(ssId, packet, 0);
|
|
26967
|
+
} catch {
|
|
26968
|
+
this.#drop("source:decoder-refused");
|
|
26969
|
+
output = void 0;
|
|
26970
|
+
}
|
|
26971
|
+
const recovered = [];
|
|
26972
|
+
if (start !== void 0 && block) {
|
|
26973
|
+
if (output) {
|
|
26974
|
+
recovered.push(...this.#settleDecoded(start, block, output));
|
|
26975
|
+
} else if (block.received >= block.ssbLength) {
|
|
26976
|
+
this.#settleClean(start);
|
|
26977
|
+
}
|
|
26978
|
+
}
|
|
26979
|
+
this.#retireBehindHorizon();
|
|
26980
|
+
return recovered;
|
|
26981
|
+
}
|
|
26982
|
+
/**
|
|
26983
|
+
* Feeds one object of the repair track: a whole MMTP repair packet (ISO/IEC
|
|
26984
|
+
* 23008-1 C.5.3). A repair track carries one repair flow, so the first
|
|
26985
|
+
* repair packet fixes its packet ID and a packet of any other is refused.
|
|
26986
|
+
* `path` is where it was received, as for addSource().
|
|
26987
|
+
*
|
|
26988
|
+
* @returns the protected packets this repair symbol recovered, as for
|
|
26989
|
+
* addSource().
|
|
26990
|
+
*/
|
|
26991
|
+
addRepair(packet, path = "moq") {
|
|
26992
|
+
const decoder = this.#decoder;
|
|
26993
|
+
if (!decoder) return this.#drop("repair:released");
|
|
26994
|
+
const pathBit = PATH_BITS[path];
|
|
26995
|
+
if (!pathBit) return this.#drop("repair:unknown-path");
|
|
26996
|
+
let header;
|
|
26997
|
+
try {
|
|
26998
|
+
header = parseMMTPHeader(packet);
|
|
26999
|
+
} catch {
|
|
27000
|
+
return this.#drop("repair:malformed");
|
|
27001
|
+
}
|
|
27002
|
+
const frame = parseMoqRepairFrameWithHeader(packet, header);
|
|
27003
|
+
if (!frame) return this.#drop("repair:malformed");
|
|
27004
|
+
if (this.#repairPacketId === void 0) {
|
|
27005
|
+
this.#repairPacketId = frame.packetId;
|
|
27006
|
+
} else if (frame.packetId !== this.#repairPacketId) {
|
|
27007
|
+
return this.#drop("repair:foreign-packet-id");
|
|
27008
|
+
}
|
|
27009
|
+
if (frame.symbolData.byteLength !== this.symbolSize) return this.#drop("repair:symbol-size");
|
|
27010
|
+
if (frame.ssbLength > this.sourceSymbols) return this.#drop("repair:ssb-length");
|
|
27011
|
+
const start = frame.ssStart;
|
|
27012
|
+
let block = this.#blocks.get(start);
|
|
27013
|
+
if (block && block.ssbLength !== frame.ssbLength) return this.#drop("repair:conflicting-ssb-length");
|
|
27014
|
+
if (!block) {
|
|
27015
|
+
if (this.#settled.has(start)) return this.#drop("repair:block-settled");
|
|
27016
|
+
if (this.#behindHorizon(start)) return this.#drop("repair:behind-horizon");
|
|
27017
|
+
block = { ssbLength: frame.ssbLength, received: 0, paths: 0 };
|
|
27018
|
+
this.#countHeld(start, block);
|
|
27019
|
+
this.#blocks.set(start, block);
|
|
27020
|
+
}
|
|
27021
|
+
this.#noteNewest(serial32Add(start, frame.ssbLength - 1));
|
|
27022
|
+
if (block.received >= block.ssbLength) {
|
|
27023
|
+
this.#settleClean(start);
|
|
27024
|
+
this.#retireBehindHorizon();
|
|
27025
|
+
return [];
|
|
27026
|
+
}
|
|
27027
|
+
let output;
|
|
27028
|
+
try {
|
|
27029
|
+
output = decoder.add_repair(start, frame.ssbLength, frame.rsId, frame.symbolData, 0);
|
|
27030
|
+
} catch {
|
|
27031
|
+
return this.#drop("repair:decoder-refused");
|
|
27032
|
+
}
|
|
27033
|
+
this.#stats.repairSymbols++;
|
|
27034
|
+
this.#stats.repairSymbolsByPath[path]++;
|
|
27035
|
+
block.paths |= pathBit;
|
|
27036
|
+
const recovered = output ? this.#settleDecoded(start, block, output) : [];
|
|
27037
|
+
this.#retireBehindHorizon();
|
|
27038
|
+
return recovered;
|
|
27039
|
+
}
|
|
27040
|
+
/**
|
|
27041
|
+
* Frees the decoder and every block. Blocks still unsettled are counted as
|
|
27042
|
+
* released, not failed: nothing proved them unrecoverable. Idempotent;
|
|
27043
|
+
* returns whether this call released anything.
|
|
27044
|
+
*/
|
|
27045
|
+
release() {
|
|
27046
|
+
const decoder = this.#decoder;
|
|
27047
|
+
if (!decoder) return false;
|
|
27048
|
+
this.#decoder = null;
|
|
27049
|
+
this.#stats.blocksReleased += this.#blocks.size;
|
|
27050
|
+
for (const block of this.#blocks.values()) this.#noteMixed(block, "released");
|
|
27051
|
+
this.#blocks.clear();
|
|
27052
|
+
this.#settled.clear();
|
|
27053
|
+
this.#have.clear();
|
|
27054
|
+
decoder.free();
|
|
27055
|
+
return true;
|
|
27056
|
+
}
|
|
27057
|
+
#drop(reason) {
|
|
27058
|
+
this.#stats.dropped[reason] = (this.#stats.dropped[reason] ?? 0) + 1;
|
|
27059
|
+
return [];
|
|
27060
|
+
}
|
|
27061
|
+
#noteNewest(ssId) {
|
|
27062
|
+
if (this.#newest === void 0 || serial32Precedes(this.#newest, ssId)) this.#newest = ssId;
|
|
27063
|
+
}
|
|
27064
|
+
#blockStartOf(ssId) {
|
|
27065
|
+
for (const [start, block] of this.#blocks) {
|
|
27066
|
+
if (isoBlockContains(start, block.ssbLength, ssId)) return start;
|
|
27067
|
+
}
|
|
27068
|
+
return void 0;
|
|
27069
|
+
}
|
|
27070
|
+
/** Counts the sources of a new block the parser already has, and their paths. */
|
|
27071
|
+
#countHeld(start, block) {
|
|
27072
|
+
for (let i = 0; i < block.ssbLength; i++) {
|
|
27073
|
+
const pathBit = this.#have.get(serial32Add(start, i));
|
|
27074
|
+
if (pathBit === void 0) continue;
|
|
27075
|
+
block.received++;
|
|
27076
|
+
block.paths |= pathBit;
|
|
27077
|
+
}
|
|
27078
|
+
}
|
|
27079
|
+
#noteMixed(block, outcome) {
|
|
27080
|
+
if ((block.paths & MIXED_PATHS) === MIXED_PATHS) this.#stats.mixedPath[outcome]++;
|
|
27081
|
+
}
|
|
27082
|
+
/** The decoder's own rule: more than its retention behind, counted from below. */
|
|
27083
|
+
#behindHorizon(start) {
|
|
27084
|
+
const newest = this.#newest;
|
|
27085
|
+
if (newest === void 0) return false;
|
|
27086
|
+
return isoBlocksBehindLowerBound(start, newest, this.sourceSymbols) > this.retentionBlocks;
|
|
27087
|
+
}
|
|
27088
|
+
#settle(start) {
|
|
27089
|
+
this.#blocks.delete(start);
|
|
27090
|
+
this.#settled.add(start);
|
|
27091
|
+
}
|
|
27092
|
+
#settleClean(start) {
|
|
27093
|
+
const block = this.#blocks.get(start);
|
|
27094
|
+
if (!block) return;
|
|
27095
|
+
this.#settle(start);
|
|
27096
|
+
this.#stats.blocksClean++;
|
|
27097
|
+
this.#noteMixed(block, "clean");
|
|
27098
|
+
try {
|
|
27099
|
+
this.#decoder?.cleanup_blocks_detailed(Uint32Array.of(start));
|
|
27100
|
+
} catch {
|
|
27101
|
+
}
|
|
27102
|
+
}
|
|
27103
|
+
/**
|
|
27104
|
+
* The decoder returns a completed block as its K' ssbg_mode1 symbols,
|
|
27105
|
+
* concatenated: split by T, trim by each symbol's length field, and hand
|
|
27106
|
+
* back the packets the parser does not have yet.
|
|
27107
|
+
*/
|
|
27108
|
+
#settleDecoded(start, block, output) {
|
|
27109
|
+
this.#settle(start);
|
|
27110
|
+
if (output.byteLength !== block.ssbLength * this.symbolSize) {
|
|
27111
|
+
this.#stats.blocksFailed++;
|
|
27112
|
+
this.#stats.packetsLost += block.ssbLength - block.received;
|
|
27113
|
+
this.#noteMixed(block, "failed");
|
|
27114
|
+
this.#drop("block:decoded-length");
|
|
27115
|
+
return [];
|
|
27116
|
+
}
|
|
27117
|
+
const recovered = [];
|
|
27118
|
+
let refused = 0;
|
|
27119
|
+
for (let i = 0; i < block.ssbLength; i++) {
|
|
27120
|
+
const ssId = serial32Add(start, i);
|
|
27121
|
+
if (this.#have.has(ssId)) continue;
|
|
27122
|
+
const symbol = output.subarray(i * this.symbolSize, (i + 1) * this.symbolSize);
|
|
27123
|
+
const packet = trimSsbg1SourceSymbol(symbol);
|
|
27124
|
+
if (!packet) {
|
|
27125
|
+
refused++;
|
|
27126
|
+
continue;
|
|
27127
|
+
}
|
|
27128
|
+
this.#have.set(ssId, 0);
|
|
27129
|
+
recovered.push(packet.slice());
|
|
27130
|
+
}
|
|
27131
|
+
if (refused > 0) {
|
|
27132
|
+
this.#stats.blocksFailed++;
|
|
27133
|
+
this.#stats.packetsLost += refused;
|
|
27134
|
+
this.#noteMixed(block, "failed");
|
|
27135
|
+
this.#drop("block:bad-ssbg1-symbol");
|
|
27136
|
+
} else if (recovered.length === 0) {
|
|
27137
|
+
this.#stats.blocksClean++;
|
|
27138
|
+
this.#noteMixed(block, "clean");
|
|
27139
|
+
} else {
|
|
27140
|
+
this.#stats.blocksRecovered++;
|
|
27141
|
+
this.#noteMixed(block, "recovered");
|
|
27142
|
+
}
|
|
27143
|
+
this.#stats.packetsRecovered += recovered.length;
|
|
27144
|
+
return recovered;
|
|
27145
|
+
}
|
|
27146
|
+
/**
|
|
27147
|
+
* Retires every block, and every SS_ID the session remembers, that the
|
|
27148
|
+
* newest SS_ID has moved past the retention. An unsettled block retired
|
|
27149
|
+
* here is a failure: more of its sources were lost than its repair could
|
|
27150
|
+
* restore, or its repair never arrived.
|
|
27151
|
+
*/
|
|
27152
|
+
#retireBehindHorizon() {
|
|
27153
|
+
const decoder = this.#decoder;
|
|
27154
|
+
const newest = this.#newest;
|
|
27155
|
+
if (!decoder || newest === void 0) return;
|
|
27156
|
+
try {
|
|
27157
|
+
decoder.cleanup_by_ss_start(newest);
|
|
27158
|
+
} catch {
|
|
27159
|
+
}
|
|
27160
|
+
for (const [start, block] of this.#blocks) {
|
|
27161
|
+
if (!this.#behindHorizon(start)) continue;
|
|
27162
|
+
this.#settle(start);
|
|
27163
|
+
this.#stats.blocksFailed++;
|
|
27164
|
+
this.#stats.packetsLost += block.ssbLength - block.received;
|
|
27165
|
+
this.#noteMixed(block, "failed");
|
|
27166
|
+
}
|
|
27167
|
+
const prunedAt = this.#prunedAt;
|
|
27168
|
+
if (prunedAt !== void 0 && serial32Distance(prunedAt, newest) < this.sourceSymbols) return;
|
|
27169
|
+
this.#prunedAt = newest;
|
|
27170
|
+
for (const ssId of this.#have.keys()) {
|
|
27171
|
+
if (this.#behindHorizon(ssId)) this.#have.delete(ssId);
|
|
27172
|
+
}
|
|
27173
|
+
for (const start of this.#settled) {
|
|
27174
|
+
if (this.#behindHorizon(start)) this.#settled.delete(start);
|
|
27175
|
+
}
|
|
27176
|
+
}
|
|
27177
|
+
};
|
|
27178
|
+
function requirePositiveInteger(value, path) {
|
|
27179
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
27180
|
+
throw new Error(`MmtpFecSession: ${path} must be a positive integer (got ${String(value)})`);
|
|
27181
|
+
}
|
|
27182
|
+
return value;
|
|
27183
|
+
}
|
|
27184
|
+
function requireNumber(value, path) {
|
|
27185
|
+
if (typeof value !== "number") {
|
|
27186
|
+
throw new Error(`MmtpFecSession: ${path} is required (got ${String(value)}); it is never defaulted`);
|
|
27187
|
+
}
|
|
27188
|
+
return value;
|
|
27189
|
+
}
|
|
27190
|
+
|
|
26711
27191
|
// src/repair-fetch.ts
|
|
26712
27192
|
var MOQT_PRIORITY_MAX = 255;
|
|
26713
27193
|
var SOURCE_MEDIA_PRIORITY_MAX = REPAIR_PRIORITY_MIN - 1;
|
|
@@ -26788,7 +27268,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26788
27268
|
const admit = (entry, now) => {
|
|
26789
27269
|
const budgetMs = entry.deadlineAt - now;
|
|
26790
27270
|
const rttMs = readRtt();
|
|
26791
|
-
if (rttMs !== null && rttMs < budgetMs) return
|
|
27271
|
+
if (rttMs !== null && rttMs < budgetMs) return rttMs;
|
|
26792
27272
|
retire(entry);
|
|
26793
27273
|
releaseHold(entry);
|
|
26794
27274
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
@@ -26799,7 +27279,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
26799
27279
|
entry.packetId,
|
|
26800
27280
|
entry.catalogTrackName
|
|
26801
27281
|
);
|
|
26802
|
-
return
|
|
27282
|
+
return null;
|
|
26803
27283
|
};
|
|
26804
27284
|
const retire = (entry) => {
|
|
26805
27285
|
if (entries.get(entry.key) === entry) entries.delete(entry.key);
|
|
@@ -26831,9 +27311,17 @@ function wireRepairFetch(mc, opts) {
|
|
|
26831
27311
|
return derived.kind === "omit" ? { subscriberPriority: void 0 } : null;
|
|
26832
27312
|
};
|
|
26833
27313
|
const start = (entry, counted = true) => {
|
|
26834
|
-
|
|
27314
|
+
const now = performance.now();
|
|
27315
|
+
const rttMs = admit(entry, now);
|
|
27316
|
+
if (rttMs === null) return;
|
|
26835
27317
|
if (counted) entry.attempts++;
|
|
26836
|
-
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName
|
|
27318
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
27319
|
+
rttMs,
|
|
27320
|
+
budgetMs: entry.deadlineAt - now,
|
|
27321
|
+
delayMs: entry.delayMs,
|
|
27322
|
+
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
27323
|
+
bound: entry.bound
|
|
27324
|
+
});
|
|
26837
27325
|
const run = { controller: new AbortController(), stopped: null };
|
|
26838
27326
|
entry.running = run;
|
|
26839
27327
|
mc.fecManager.holdBlockForRepair(
|
|
@@ -26980,6 +27468,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
26980
27468
|
);
|
|
26981
27469
|
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
26982
27470
|
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
27471
|
+
entry2.anchorAt = promotedDeadline.anchorAt;
|
|
27472
|
+
entry2.delayMs = promotedDeadline.delayMs;
|
|
27473
|
+
entry2.bound = promotedDeadline.bound;
|
|
26983
27474
|
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
26984
27475
|
}
|
|
26985
27476
|
if (entry2.running) {
|
|
@@ -27005,7 +27496,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
27005
27496
|
if (waitMs === void 0) return null;
|
|
27006
27497
|
const waitDeadlineAt = now + waitMs;
|
|
27007
27498
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
27008
|
-
if (anchor === void 0)
|
|
27499
|
+
if (anchor === void 0) {
|
|
27500
|
+
return { deadlineAt: waitDeadlineAt, extensionMs: 0, anchorAt: null, delayMs: null, bound: "wait" };
|
|
27501
|
+
}
|
|
27009
27502
|
let delayMs;
|
|
27010
27503
|
try {
|
|
27011
27504
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -27016,12 +27509,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
27016
27509
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
27017
27510
|
if (retentionMs === void 0) return null;
|
|
27018
27511
|
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
27019
|
-
const
|
|
27020
|
-
|
|
27512
|
+
const at = (delay, delayBound) => {
|
|
27513
|
+
const presentAt = Math.min(anchor + delay, ceilingAt);
|
|
27514
|
+
if (waitDeadlineAt >= presentAt) return { deadlineAt: waitDeadlineAt, bound: "wait" };
|
|
27515
|
+
return { deadlineAt: presentAt, bound: anchor + delay <= ceilingAt ? delayBound : "retention" };
|
|
27516
|
+
};
|
|
27517
|
+
const base = at(delayMs, "presentation");
|
|
27021
27518
|
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 {
|
|
27519
|
+
if (budgetMs === null || budgetMs <= delayMs) return { ...base, extensionMs: 0, anchorAt: anchor, delayMs };
|
|
27520
|
+
const extended = at(budgetMs, "keyframe");
|
|
27521
|
+
return {
|
|
27522
|
+
...extended,
|
|
27523
|
+
extensionMs: extended.deadlineAt - base.deadlineAt,
|
|
27524
|
+
anchorAt: anchor,
|
|
27525
|
+
delayMs: budgetMs
|
|
27526
|
+
};
|
|
27025
27527
|
};
|
|
27026
27528
|
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
27027
27529
|
try {
|
|
@@ -27098,6 +27600,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
27098
27600
|
priority,
|
|
27099
27601
|
subscriberPriority: wire.subscriberPriority,
|
|
27100
27602
|
deadlineAt: deadline.deadlineAt,
|
|
27603
|
+
anchorAt: deadline.anchorAt,
|
|
27604
|
+
delayMs: deadline.delayMs,
|
|
27605
|
+
bound: deadline.bound,
|
|
27101
27606
|
order: enqueueOrder++,
|
|
27102
27607
|
attempts: 0,
|
|
27103
27608
|
running: null
|
|
@@ -27153,6 +27658,7 @@ export {
|
|
|
27153
27658
|
MfuReassemblyError,
|
|
27154
27659
|
MmtpContainerParser,
|
|
27155
27660
|
MmtpDecodePipeline,
|
|
27661
|
+
MmtpFecSession,
|
|
27156
27662
|
MmtpRouter,
|
|
27157
27663
|
MmtpToCmaf,
|
|
27158
27664
|
MulticastContainerContractError,
|