@blockcast/mmt-transport 0.5.0 → 1.0.0-main.3cb7359ea316

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.
@@ -236,70 +236,6 @@
236
236
  var FEC_BLOCK_PROFILES = Object.freeze([
237
237
  "iso-ssbg1-v1"
238
238
  ]);
239
- function isFecBlockProfile(value) {
240
- return value === "iso-ssbg1-v1";
241
- }
242
-
243
- // node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
244
- var ALL_ROLES = Object.freeze(["video", "audio"]);
245
- function recordOf(value) {
246
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
247
- }
248
- function locateCatalogFecSource(catalog, source, roles = ALL_ROLES) {
249
- const root = recordOf(catalog);
250
- if (root === void 0)
251
- return void 0;
252
- for (const role of roles) {
253
- const renditions = recordOf(recordOf(root[role])?.["renditions"]);
254
- if (renditions === void 0 || !Object.hasOwn(renditions, source))
255
- continue;
256
- const entry2 = recordOf(renditions[source]);
257
- if (entry2 === void 0)
258
- continue;
259
- return Object.freeze({
260
- dialect: "hang",
261
- role,
262
- entry: entry2,
263
- fec: entry2["fec"],
264
- fecPath: `$.${role}.renditions[${JSON.stringify(source)}].fec`
265
- });
266
- }
267
- const tracks = root["tracks"];
268
- if (!Array.isArray(tracks))
269
- return void 0;
270
- const index = tracks.findIndex((track) => recordOf(track)?.["name"] === source);
271
- if (index < 0)
272
- return void 0;
273
- const entry = recordOf(tracks[index]) ?? {};
274
- return Object.freeze({
275
- dialect: "msf",
276
- index,
277
- entry,
278
- fec: entry["fec"],
279
- fecPath: `$.tracks[${index}].fec`
280
- });
281
- }
282
- function isoBlockSpanUsable(fec) {
283
- const block = recordOf(fec);
284
- if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1")
285
- return true;
286
- const ms = block["interleaveDepthMs"];
287
- return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
288
- }
289
- function catalogFecAvailable(fec) {
290
- const block = recordOf(fec);
291
- if (block === void 0)
292
- return true;
293
- if (fecAlgorithmUnimplemented(block["algorithm"]))
294
- return false;
295
- const declaresFecInstance = block["algorithm"] !== "none";
296
- const profile = block["blockProfile"];
297
- const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
298
- return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
299
- }
300
- function fecAlgorithmUnimplemented(algorithm) {
301
- return typeof algorithm === "string" && algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon";
302
- }
303
239
 
304
240
  // node_modules/@blockcast/mmt-base/dist/multicast-catalog.js
305
241
  var ED25519_PUBLIC_KEY_BASE64URL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
@@ -561,6 +497,538 @@
561
497
  return new Set(endpoints.map((_, index) => index).filter((index) => !ignored.has(index)));
562
498
  }
563
499
 
500
+ // node_modules/@blockcast/mmt-base/dist/fec-catalog.js
501
+ var DEFAULT_SCHEMES = ["reed-solomon", "raptorq"];
502
+ var DEFAULT_PROFILES = ["moq-object-v1", "iso-ssbg1-v1"];
503
+ var RS_MAX_BLOCK = 255;
504
+ var RAPTORQ_MAX_K = 56403;
505
+ var MAX_24 = 16777215;
506
+ var ISO_MIN_T = 14;
507
+ var GEOMETRY_KEYS = [
508
+ "scheme",
509
+ "blockProfile",
510
+ "mmtpMode",
511
+ "timescale",
512
+ "symbolSize",
513
+ "interleaveDepthMs",
514
+ "reorderToleranceMs",
515
+ "sourceSymbols",
516
+ "fec"
517
+ ];
518
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
519
+ var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
520
+ var isInt = (v) => typeof v === "number" && Number.isInteger(v);
521
+ var intIn = (v, lo, hi = Number.MAX_SAFE_INTEGER) => isInt(v) && v >= lo && v <= hi;
522
+ var profileAdmits = (profile, packaging) => profile !== "iso-ssbg1-v1" || packaging === "mmtp";
523
+ function validateFecCatalog(catalog, receiver = {}) {
524
+ const schemes = receiver.schemes ?? DEFAULT_SCHEMES;
525
+ const profiles = receiver.blockProfiles ?? DEFAULT_PROFILES;
526
+ const overlays = receiver.overlays ?? true;
527
+ const all = [];
528
+ const report = (code, path, inst) => {
529
+ const issue = { code, path };
530
+ all.push(issue);
531
+ inst?.issues.push(issue);
532
+ };
533
+ const tracks = isObj(catalog) && Array.isArray(catalog.tracks) ? catalog.tracks : [];
534
+ if (!isObj(catalog) || !Array.isArray(catalog.tracks))
535
+ report("fec_member", "/tracks");
536
+ let rejectAll = false;
537
+ tracks.forEach((t, ti) => {
538
+ if (!isObj(t))
539
+ return;
540
+ if (has(t, "enhancementRepair")) {
541
+ rejectAll = true;
542
+ report("fec_enhancement_repair", `/tracks/${ti}/enhancementRepair`);
543
+ }
544
+ if (Array.isArray(t.fec))
545
+ t.fec.forEach((o, ii) => {
546
+ if (isObj(o) && has(o, "enhancementRepair")) {
547
+ rejectAll = true;
548
+ report("fec_enhancement_repair", `/tracks/${ti}/fec/${ii}/enhancementRepair`);
549
+ }
550
+ });
551
+ });
552
+ const key = (ns, name) => JSON.stringify([ns ?? null, name]);
553
+ const byName = /* @__PURE__ */ new Map();
554
+ tracks.forEach((t, ti) => {
555
+ if (isObj(t) && typeof t.name === "string") {
556
+ const k = key(t.namespace, t.name);
557
+ if (!byName.has(k))
558
+ byName.set(k, ti);
559
+ }
560
+ });
561
+ const trackAt = (ti) => tracks[ti];
562
+ const insts = [];
563
+ tracks.forEach((t, ti) => {
564
+ if (!isObj(t) || !has(t, "fec") || t.packaging === "fec-repair" || t.packaging === "fec-source")
565
+ return;
566
+ if (!Array.isArray(t.fec)) {
567
+ report("fec_member", `/tracks/${ti}/fec`);
568
+ return;
569
+ }
570
+ t.fec.forEach((o, ii) => {
571
+ const path = `/tracks/${ti}/fec/${ii}`;
572
+ const inst = {
573
+ path,
574
+ ti,
575
+ track: t,
576
+ obj: isObj(o) ? o : null,
577
+ id: null,
578
+ unavailable: false,
579
+ overlay: false,
580
+ issues: [],
581
+ layer0: null,
582
+ symbolNamed: null,
583
+ attached: []
584
+ };
585
+ insts.push(inst);
586
+ if (!inst.obj)
587
+ return report("fec_member", path, inst);
588
+ const o2 = inst.obj;
589
+ if (!has(o2, "instanceId"))
590
+ inst.id = 0;
591
+ else if (intIn(o2.instanceId, 0, 255))
592
+ inst.id = o2.instanceId;
593
+ else
594
+ report("fec_member", `${path}/instanceId`, inst);
595
+ inst.overlay = has(o2, "scope");
596
+ });
597
+ });
598
+ const declaresFec = insts.length > 0;
599
+ for (const inst of insts) {
600
+ const o = inst.obj;
601
+ if (!o)
602
+ continue;
603
+ const avail = (field, impl) => {
604
+ const p = `${inst.path}/${field}`;
605
+ const absent = field === "scheme" ? "fec_scheme_absent" : "fec_block_profile_absent";
606
+ const unimpl = field === "scheme" ? "fec_scheme_unimplemented" : "fec_block_profile_unimplemented";
607
+ if (!has(o, field))
608
+ return report(absent, p, inst), false;
609
+ if (typeof o[field] !== "string")
610
+ return report("fec_member", p, inst), true;
611
+ if (!impl.includes(o[field]))
612
+ return report(unimpl, p, inst), false;
613
+ return true;
614
+ };
615
+ if (!avail("scheme", schemes) || !avail("blockProfile", profiles))
616
+ inst.unavailable = true;
617
+ else if (typeof o.blockProfile === "string" && !profileAdmits(o.blockProfile, inst.track.packaging)) {
618
+ report("fec_block_profile_packaging", `${inst.path}/blockProfile`, inst);
619
+ inst.unavailable = true;
620
+ }
621
+ }
622
+ const live = (i) => !i.unavailable;
623
+ for (const inst of insts.filter(live)) {
624
+ const o = inst.obj;
625
+ if (!o)
626
+ continue;
627
+ const p = inst.path;
628
+ for (const m of ["sourceSymbols", "repairSymbols", "symbolSize"])
629
+ if (!intIn(o[m], 1))
630
+ report("fec_member", `${p}/${m}`, inst);
631
+ if (typeof o.repairTrack !== "string")
632
+ report("fec_member", `${p}/repairTrack`, inst);
633
+ if (has(o, "symbolTrack") && typeof o.symbolTrack !== "string")
634
+ report("fec_member", `${p}/symbolTrack`, inst);
635
+ if (has(o, "interleaveDepthMs")) {
636
+ const d = o.interleaveDepthMs;
637
+ if (!intIn(d, 0) || d === 0 && o.blockProfile !== "iso-ssbg1-v1")
638
+ report("fec_member", `${p}/interleaveDepthMs`, inst);
639
+ }
640
+ if (has(o, "reorderToleranceMs")) {
641
+ const r = o.reorderToleranceMs;
642
+ if (typeof r !== "number" || !Number.isFinite(r) || r < 0)
643
+ report("fec_member", `${p}/reorderToleranceMs`, inst);
644
+ }
645
+ if (has(o, "label") && typeof o.label !== "string")
646
+ report("fec_member", `${p}/label`, inst);
647
+ if (inst.overlay && o.scope !== "keyframe")
648
+ report("fec_member", `${p}/scope`, inst);
649
+ }
650
+ const idGroups = /* @__PURE__ */ new Map();
651
+ for (const inst of insts)
652
+ if (inst.id !== null) {
653
+ const k = `${inst.ti}:${inst.id}`;
654
+ idGroups.set(k, [...idGroups.get(k) ?? [], inst]);
655
+ }
656
+ for (const group of idGroups.values())
657
+ if (group.length > 1)
658
+ for (const inst of group.filter(live))
659
+ report("fec_instance_id", inst.obj && has(inst.obj, "instanceId") ? `${inst.path}/instanceId` : inst.path, inst);
660
+ const nameUses = /* @__PURE__ */ new Map();
661
+ for (const inst of insts)
662
+ for (const field of ["repairTrack", "symbolTrack"])
663
+ if (inst.obj && typeof inst.obj[field] === "string") {
664
+ const k = key(inst.track.namespace, inst.obj[field]);
665
+ nameUses.set(k, [...nameUses.get(k) ?? [], { inst, field }]);
666
+ }
667
+ const namedBy = /* @__PURE__ */ new Map();
668
+ for (const [k, uses] of nameUses) {
669
+ const tj = byName.get(k);
670
+ for (const { inst, field } of uses) {
671
+ const path = `${inst.path}/${field}`;
672
+ if (tj === void 0 || trackAt(tj).packaging !== (field === "repairTrack" ? "fec-repair" : "fec-source")) {
673
+ if (live(inst))
674
+ report("fec_naming", path, inst);
675
+ } else if (uses.length > 1) {
676
+ if (live(inst))
677
+ report("fec_naming", path, inst);
678
+ if (!namedBy.has(tj))
679
+ namedBy.set(tj, inst);
680
+ } else {
681
+ namedBy.set(tj, inst);
682
+ if (field === "repairTrack")
683
+ inst.layer0 = tj;
684
+ else
685
+ inst.symbolNamed = tj;
686
+ }
687
+ }
688
+ }
689
+ const owner = /* @__PURE__ */ new Map();
690
+ if (declaresFec)
691
+ tracks.forEach((t, tj) => {
692
+ if (!isObj(t) || t.packaging !== "fec-repair" && t.packaging !== "fec-source")
693
+ return;
694
+ const tp = `/tracks/${tj}`;
695
+ const named = namedBy.get(tj);
696
+ if (named) {
697
+ owner.set(tj, named);
698
+ if (!live(named))
699
+ return;
700
+ if (has(t, "source") && t.source !== named.track.name)
701
+ report("fec_resolution", `${tp}/source`, named);
702
+ if (has(t, "instanceId") && t.instanceId !== named.id)
703
+ report("fec_resolution", `${tp}/instanceId`, named);
704
+ return;
705
+ }
706
+ if (!has(t, "source"))
707
+ return report("fec_orphan", tp);
708
+ const id = has(t, "instanceId") ? t.instanceId : 0;
709
+ const src = typeof t.source === "string" ? byName.get(key(t.namespace, t.source)) : void 0;
710
+ const target = src === void 0 ? void 0 : insts.find((i) => i.ti === src && i.id === id);
711
+ if (!target)
712
+ return report("fec_naming", has(t, "instanceId") && src !== void 0 ? `${tp}/instanceId` : `${tp}/source`);
713
+ owner.set(tj, target);
714
+ target.attached.push(tj);
715
+ });
716
+ for (const [tj, inst] of owner) {
717
+ if (!live(inst))
718
+ continue;
719
+ const t = trackAt(tj);
720
+ const tp = `/tracks/${tj}`;
721
+ const symbol = t.packaging === "fec-source";
722
+ if (has(t, "source") && typeof t.source !== "string")
723
+ report("fec_member", `${tp}/source`, inst);
724
+ if (has(t, "instanceId") && !intIn(t.instanceId, 0, 255))
725
+ report("fec_member", `${tp}/instanceId`, inst);
726
+ for (const m of ["repairLayer", "repairSymbols"]) {
727
+ if (!has(t, m))
728
+ continue;
729
+ if (symbol || !intIn(t[m], m === "repairLayer" ? 0 : 1))
730
+ report("fec_member", `${tp}/${m}`, inst);
731
+ }
732
+ if (has(t, "priority") && !intIn(t.priority, symbol ? 0 : 192, 255))
733
+ report("fec_member", `${tp}/priority`, inst);
734
+ for (const k of Object.keys(t))
735
+ if (GEOMETRY_KEYS.includes(k) || k.startsWith("groupDuration"))
736
+ report("fec_track_geometry", `${tp}/${k.replace(/~/g, "~0").replace(/\//g, "~1")}`, inst);
737
+ }
738
+ for (const inst of insts.filter(live)) {
739
+ const o = inst.obj;
740
+ if (!o)
741
+ continue;
742
+ const repairs = inst.attached.filter((tj) => trackAt(tj).packaging === "fec-repair");
743
+ const symbols = inst.attached.filter((tj) => trackAt(tj).packaging === "fec-source");
744
+ if (symbols.length + (inst.symbolNamed !== null ? 1 : 0) > 1)
745
+ for (const tj of symbols)
746
+ report("fec_symbol_tracks", `/tracks/${tj}`, inst);
747
+ const l0 = inst.layer0 === null ? null : trackAt(inst.layer0);
748
+ const l0p = `/tracks/${inst.layer0}`;
749
+ if (inst.overlay) {
750
+ if (l0 && has(l0, "repairLayer"))
751
+ report("fec_overlay", `${l0p}/repairLayer`, inst);
752
+ for (const tj of repairs)
753
+ report("fec_overlay", has(trackAt(tj), "repairLayer") ? `/tracks/${tj}/repairLayer` : `/tracks/${tj}`, inst);
754
+ } else {
755
+ if (l0 && has(l0, "repairLayer") && l0.repairLayer !== 0)
756
+ report("fec_layers", `${l0p}/repairLayer`, inst);
757
+ if (l0 && has(l0, "repairSymbols") && intIn(o.repairSymbols, 1) && l0.repairSymbols !== o.repairSymbols)
758
+ report("fec_layer0", `${l0p}/repairSymbols`, inst);
759
+ const layers = [];
760
+ for (const tj of repairs) {
761
+ const t = trackAt(tj);
762
+ if (!has(t, "repairLayer"))
763
+ report("fec_member", `/tracks/${tj}/repairLayer`, inst);
764
+ else if (t.repairLayer === 0)
765
+ report("fec_layers", `/tracks/${tj}/repairLayer`, inst);
766
+ else if (intIn(t.repairLayer, 1))
767
+ layers.push({ tj, layer: t.repairLayer });
768
+ if (!has(t, "repairSymbols"))
769
+ report("fec_member", `/tracks/${tj}/repairSymbols`, inst);
770
+ }
771
+ const counts = /* @__PURE__ */ new Map();
772
+ for (const { layer } of layers)
773
+ counts.set(layer, (counts.get(layer) ?? 0) + 1);
774
+ let missing = 1;
775
+ while (counts.has(missing))
776
+ missing++;
777
+ for (const { tj, layer } of layers)
778
+ if (counts.get(layer) > 1 || layer > missing)
779
+ report("fec_layers", `/tracks/${tj}/repairLayer`, inst);
780
+ const chain = [
781
+ { layer: 0, tj: inst.layer0, pri: l0 && intIn(l0.priority, 192, 255) ? l0.priority : l0 && has(l0, "priority") ? null : 240 },
782
+ ...layers.map(({ tj, layer }) => {
783
+ const pr = trackAt(tj).priority;
784
+ return { layer, tj, pri: intIn(pr, 192, 255) ? pr : null };
785
+ })
786
+ ].sort((a, b) => a.layer - b.layer);
787
+ let prev = null;
788
+ for (const c of chain) {
789
+ if (c.pri === null)
790
+ continue;
791
+ if (prev !== null && c.pri < prev)
792
+ report("fec_priority", `/tracks/${c.tj}/priority`, inst);
793
+ prev = Math.max(prev ?? c.pri, c.pri);
794
+ }
795
+ }
796
+ const K = o.sourceSymbols;
797
+ const T = o.symbolSize;
798
+ const P0 = o.repairSymbols;
799
+ if (intIn(K, 1) && intIn(P0, 1)) {
800
+ let P = P0;
801
+ if (!inst.overlay)
802
+ for (const tj of repairs) {
803
+ const t = trackAt(tj);
804
+ if (intIn(t.repairLayer, 1) && intIn(t.repairSymbols, 1))
805
+ P += t.repairSymbols;
806
+ }
807
+ if (P > MAX_24 || K + P - 1 > MAX_24)
808
+ report("fec_bounds", inst.path, inst);
809
+ else if (o.scheme === "reed-solomon" && K + P > RS_MAX_BLOCK)
810
+ report("fec_bounds", inst.path, inst);
811
+ }
812
+ if (o.scheme === "raptorq" && intIn(K, 1) && K > RAPTORQ_MAX_K)
813
+ report("fec_bounds", `${inst.path}/sourceSymbols`, inst);
814
+ if (intIn(T, 1)) {
815
+ if (o.scheme === "raptorq" && T % 8 !== 0)
816
+ report("fec_bounds", `${inst.path}/symbolSize`, inst);
817
+ else if (o.blockProfile === "iso-ssbg1-v1" && T < ISO_MIN_T)
818
+ report("fec_bounds", `${inst.path}/symbolSize`, inst);
819
+ }
820
+ }
821
+ const overlayTracks = new Set(insts.filter((i) => live(i) && i.overlay).map((i) => i.ti));
822
+ for (const ti of overlayTracks) {
823
+ const ofTrack = insts.filter((i) => i.ti === ti && live(i));
824
+ const ovs = ofTrack.filter((i) => i.overlay);
825
+ if (!overlays) {
826
+ for (const ov of ovs)
827
+ report("fec_overlay_unsupported", `${ov.path}/scope`, ov);
828
+ for (const i of ofTrack)
829
+ i.issues.length === 0 && i.issues.push({ code: "fec_overlay_unsupported", path: `${ovs[0].path}/scope` });
830
+ continue;
831
+ }
832
+ if (ovs.length > 1)
833
+ for (const ov of ovs)
834
+ report("fec_overlay", `${ov.path}/scope`, ov);
835
+ for (const ov of ovs)
836
+ if (ov.obj?.blockProfile !== "iso-ssbg1-v1")
837
+ report("fec_overlay", `${ov.path}/blockProfile`, ov);
838
+ const cause = ovs.flatMap((ov) => ov.issues).find((x) => x.code === "fec_overlay");
839
+ if (cause) {
840
+ for (const ov of ovs)
841
+ if (ov.issues.length === 0)
842
+ ov.issues.push(cause);
843
+ }
844
+ }
845
+ const rule4 = all.find((x) => x.code === "fec_enhancement_repair");
846
+ if (rejectAll && rule4) {
847
+ for (const i of insts)
848
+ if (i.issues.length === 0)
849
+ i.issues.push(rule4);
850
+ }
851
+ return {
852
+ instances: insts.map((i) => ({
853
+ path: i.path,
854
+ track: typeof i.track.name === "string" ? i.track.name : null,
855
+ instanceId: i.id,
856
+ outcome: rejectAll || !i.unavailable && i.issues.length > 0 ? "violation" : i.unavailable ? "unavailable" : "ok",
857
+ issues: i.issues,
858
+ trackIndex: i.ti,
859
+ repairTrack: i.layer0,
860
+ boundRepairTracks: i.attached.filter((tj) => trackAt(tj).packaging === "fec-repair"),
861
+ symbolTrack: i.symbolNamed ?? i.attached.find((tj) => trackAt(tj).packaging === "fec-source") ?? null
862
+ })),
863
+ issues: all
864
+ };
865
+ }
866
+
867
+ // node_modules/@blockcast/mmt-base/dist/fec-bindings.js
868
+ var RUNTIME_FEC_RECEIVER = Object.freeze({
869
+ schemes: Object.freeze(["raptorq", "reed-solomon"]),
870
+ blockProfiles: Object.freeze(["iso-ssbg1-v1"]),
871
+ overlays: true
872
+ });
873
+ var DEFAULT_FEC_REPAIR_PRIORITY = 240;
874
+ var recordOf = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : void 0;
875
+ var escape = (s) => s.replace(/~/g, "~0").replace(/\//g, "~1");
876
+ function fecCatalogTracks(catalog) {
877
+ const root = recordOf(catalog) ?? {};
878
+ const tracks = [];
879
+ const pointers = [];
880
+ const hangNames = /* @__PURE__ */ new Set();
881
+ for (const role of ["video", "audio"]) {
882
+ for (const [name, r] of Object.entries(recordOf(recordOf(root[role])?.["renditions"]) ?? {})) {
883
+ const entry = recordOf(r);
884
+ if (!entry)
885
+ continue;
886
+ hangNames.add(name);
887
+ const kind = recordOf(entry["container"])?.["kind"];
888
+ const view = { name, packaging: kind === void 0 || kind === "mmtp-fec" ? "mmtp" : kind };
889
+ if (entry["fec"] !== void 0)
890
+ view["fec"] = entry["fec"];
891
+ tracks.push(view);
892
+ pointers.push(`/${role}/renditions/${escape(name)}`);
893
+ }
894
+ }
895
+ const hangRenditions = tracks.length;
896
+ for (const [name, r] of Object.entries(recordOf(recordOf(root["repair"])?.["renditions"]) ?? {})) {
897
+ hangNames.add(name);
898
+ tracks.push({ packaging: "fec-repair", ...recordOf(r), name });
899
+ pointers.push(`/repair/renditions/${escape(name)}`);
900
+ }
901
+ const raw = Array.isArray(root["tracks"]) ? root["tracks"] : [];
902
+ const named = new Set(hangNames);
903
+ raw.forEach((t, i) => {
904
+ const name = recordOf(t)?.["name"];
905
+ if (typeof name === "string")
906
+ named.add(name);
907
+ if (typeof name === "string" && hangNames.has(name))
908
+ return;
909
+ tracks.push(t);
910
+ pointers.push(`/tracks/${i}`);
911
+ });
912
+ tracks.slice(0, hangRenditions).forEach((t, ti) => {
913
+ const view = t;
914
+ if (!Array.isArray(view["fec"]))
915
+ return;
916
+ view["fec"].forEach((o, ii) => {
917
+ const repairTrack = recordOf(o)?.["repairTrack"];
918
+ if (typeof repairTrack !== "string" || named.has(repairTrack))
919
+ return;
920
+ named.add(repairTrack);
921
+ const instanceId = recordOf(o)?.["instanceId"];
922
+ tracks.push({ name: repairTrack, packaging: "fec-repair", source: view["name"], ...instanceId === void 0 ? {} : { instanceId } });
923
+ pointers.push(`${pointers[ti]}/fec/${ii}/repairTrack`);
924
+ });
925
+ });
926
+ return { tracks, pointers };
927
+ }
928
+ function resolveFecBindings(catalog, receiver = RUNTIME_FEC_RECEIVER) {
929
+ const { tracks, pointers } = fecCatalogTracks(catalog);
930
+ const report = validateFecCatalog({ tracks }, receiver);
931
+ const at = (path) => {
932
+ const m = /^\/tracks\/(\d+)(.*)$/.exec(path);
933
+ return m ? pointers[Number(m[1])] + m[2] : path;
934
+ };
935
+ const trackAt = (i) => recordOf(tracks[i]) ?? {};
936
+ const nameAt = (i) => i === null ? void 0 : trackAt(i)["name"];
937
+ const why = (i) => Object.freeze({
938
+ code: i.issues[0]?.code ?? "fec_member",
939
+ path: at(i.issues[0]?.path ?? i.path),
940
+ outcome: i.outcome === "unavailable" ? "unavailable" : "violation"
941
+ });
942
+ const out = /* @__PURE__ */ new Map();
943
+ tracks.forEach((t, ti) => {
944
+ const track = recordOf(t);
945
+ const name = track?.["name"];
946
+ if (!track || typeof name !== "string" || out.has(name))
947
+ return;
948
+ if (track["packaging"] === "fec-repair" || track["packaging"] === "fec-source")
949
+ return;
950
+ const fec = track["fec"];
951
+ if (fec === void 0)
952
+ return;
953
+ if (!Array.isArray(fec)) {
954
+ const reason = { code: "fec_member", path: at(`/tracks/${ti}/fec`), outcome: "violation" };
955
+ out.set(name, Object.freeze({ status: "unavailable", track: name, pointer: pointers[ti], reason: Object.freeze(reason) }));
956
+ return;
957
+ }
958
+ if (fec.length === 0)
959
+ return;
960
+ const insts = report.instances.filter((i) => i.trackIndex === ti);
961
+ const isOverlay = (i) => Object.hasOwn(recordOf(fec[Number(i.path.split("/").pop())]) ?? {}, "scope");
962
+ const bases = insts.filter((i) => !isOverlay(i));
963
+ const okBases = bases.filter((i) => i.outcome === "ok");
964
+ if (okBases.length !== 1) {
965
+ const reason = (
966
+ // No base instance at all (overlay-only `fec`) is a count of 0, not
967
+ // the overlay's own issue.
968
+ okBases.length > 1 || bases.length === 0 ? Object.freeze({ code: "fec_base_instances", path: at(`/tracks/${ti}/fec`), outcome: "violation" }) : why(bases[0] ?? insts[0])
969
+ );
970
+ out.set(name, Object.freeze({ status: "unavailable", track: name, pointer: pointers[ti], reason }));
971
+ return;
972
+ }
973
+ const b = okBases[0];
974
+ const base = geometry(recordOf(fec[Number(b.path.split("/").pop())]), b.instanceId, nameAt(b.symbolTrack));
975
+ const priorityOf = (i) => {
976
+ const p = i === null ? void 0 : trackAt(i)["priority"];
977
+ return typeof p === "number" ? p : DEFAULT_FEC_REPAIR_PRIORITY;
978
+ };
979
+ const layers = [
980
+ { layer: 0, repairTrackName: base.repairTrack, repairSymbols: base.repairSymbols, rsIdOffset: 0, priority: priorityOf(b.repairTrack) }
981
+ ];
982
+ const more = b.boundRepairTracks.map((tj) => ({ tj, layer: trackAt(tj)["repairLayer"] })).sort((x, y) => x.layer - y.layer);
983
+ let offset = base.repairSymbols;
984
+ for (const { tj, layer } of more) {
985
+ const repairSymbols = trackAt(tj)["repairSymbols"];
986
+ layers.push({ layer, repairTrackName: nameAt(tj), repairSymbols, rsIdOffset: offset, priority: priorityOf(tj) });
987
+ offset += repairSymbols;
988
+ }
989
+ let overlay;
990
+ let overlayUnavailable;
991
+ const ov = insts.find(isOverlay);
992
+ if (ov?.outcome === "ok") {
993
+ const g = geometry(recordOf(fec[Number(ov.path.split("/").pop())]), ov.instanceId, nameAt(ov.symbolTrack));
994
+ overlay = Object.freeze({
995
+ repairTrackName: g.repairTrack,
996
+ scope: "keyframe",
997
+ sourceSymbols: g.sourceSymbols,
998
+ repairSymbols: g.repairSymbols,
999
+ priority: priorityOf(ov.repairTrack),
1000
+ geometry: g
1001
+ });
1002
+ } else if (ov)
1003
+ overlayUnavailable = why(ov);
1004
+ out.set(name, Object.freeze({
1005
+ status: "ok",
1006
+ track: name,
1007
+ pointer: pointers[ti],
1008
+ base,
1009
+ layers: Object.freeze(layers.map((l) => Object.freeze(l))),
1010
+ totalBaseRepairSymbols: offset,
1011
+ ...overlay ? { overlay } : {},
1012
+ ...overlayUnavailable ? { overlayUnavailable } : {}
1013
+ }));
1014
+ });
1015
+ return out;
1016
+ }
1017
+ function geometry(o, instanceId, symbolTrack) {
1018
+ return Object.freeze({
1019
+ instanceId,
1020
+ scheme: o["scheme"],
1021
+ blockProfile: o["blockProfile"],
1022
+ sourceSymbols: o["sourceSymbols"],
1023
+ repairSymbols: o["repairSymbols"],
1024
+ symbolSize: o["symbolSize"],
1025
+ ...typeof o["interleaveDepthMs"] === "number" ? { interleaveDepthMs: o["interleaveDepthMs"] } : {},
1026
+ ...typeof o["reorderToleranceMs"] === "number" ? { reorderToleranceMs: o["reorderToleranceMs"] } : {},
1027
+ repairTrack: o["repairTrack"],
1028
+ ...symbolTrack !== void 0 ? { symbolTrack } : {}
1029
+ });
1030
+ }
1031
+
564
1032
  // src/endpoint-config.ts
565
1033
  function toWindowMulticastSubscribeConfig(input) {
566
1034
  if (input.mode !== void 0 && !["auto", "native", "tunnel"].includes(input.mode)) {
@@ -1157,6 +1625,10 @@
1157
1625
  const defaultRenditionTrack = renditionTrack ? "" : lowestServedVideoRendition(catalog, usableEndpoints);
1158
1626
  return renditionTrack && usableEndpoints.find((endpoint) => endpoint.tracks?.some((track) => matchesPreferredTrack(track.name, renditionTrack))) || defaultRenditionTrack && usableEndpoints.find((endpoint) => endpoint.tracks?.some((track) => matchesPreferredTrack(track.name, defaultRenditionTrack))) || usableEndpoints.find((endpoint) => endpoint.tracks?.some((track) => matchesPreferredTrack(track.name, preferredTrack))) || usableEndpoints[0] || null;
1159
1627
  }
1628
+ function asmSenderFilter(endpoint) {
1629
+ const joinSource = multicastEndpointSource(endpoint);
1630
+ return joinSource?.mode === "asm" && joinSource.source ? { senderAddress: joinSource.source } : {};
1631
+ }
1160
1632
  function endpointToMulticastConfig(endpoint, catalog, selection) {
1161
1633
  if (!endpoint || !isUsableMulticastEndpoint(endpoint, catalog) || advertisesInvalidPacketId(endpoint)) return null;
1162
1634
  const config = {
@@ -1164,6 +1636,7 @@
1164
1636
  source: endpoint.sourceAddress || "",
1165
1637
  port: Number(endpoint.port)
1166
1638
  };
1639
+ Object.assign(config, asmSenderFilter(endpoint));
1167
1640
  const ownNetworkSource = Array.isArray(endpoint.networkSource) ? endpoint.networkSource : void 0;
1168
1641
  const networkSource = ownNetworkSource ?? catalog?.multicast?.networkSource;
1169
1642
  const amt = findAmtRelay(networkSource);
@@ -1268,6 +1741,7 @@
1268
1741
  companions.push({
1269
1742
  group: endpoint.groupAddress,
1270
1743
  source: endpoint.sourceAddress || "",
1744
+ ...asmSenderFilter(endpoint),
1271
1745
  port: Number(endpoint.port),
1272
1746
  ...transport,
1273
1747
  packetIds: normalizePacketIds(repairOwners.map((owner) => owner.packetId)),
@@ -1428,25 +1902,11 @@
1428
1902
  }
1429
1903
  function catalogRepairTracks(catalog, name) {
1430
1904
  assertNoRetiredTrackFields(catalog);
1431
- const tracks = Array.isArray(catalog?.tracks) ? catalog.tracks : [];
1432
- const fec = locateCatalogFecSource(catalog, name)?.fec;
1433
- if (!fec || typeof fec !== "object" || fec.algorithm === "none" || !catalogFecAvailable(fec)) return [];
1434
- const names = /* @__PURE__ */ new Set();
1435
- if (typeof fec.repairTrack === "string" && fec.repairTrack.length > 0) names.add(fec.repairTrack);
1436
- const dependsOn = (entry) => Array.isArray(entry?.depends) && entry.depends.length === 1 && entry.depends[0] === name;
1437
- for (const candidate of tracks) {
1438
- const packaging = candidate?.packaging;
1439
- if (packaging === "fec-repair" && typeof candidate?.name === "string" && candidate.name.length > 0 && dependsOn(candidate)) {
1440
- names.add(candidate.name);
1441
- }
1442
- }
1443
- const repairRenditions = catalog?.repair?.renditions;
1444
- if (repairRenditions && typeof repairRenditions === "object") {
1445
- for (const [repairName, entry] of Object.entries(repairRenditions)) {
1446
- if (repairName.length > 0 && dependsOn(entry)) names.add(repairName);
1447
- }
1448
- }
1449
- return [...names];
1905
+ const binding = resolveFecBindings(catalog).get(name);
1906
+ if (binding?.status !== "ok") return [];
1907
+ const names = binding.layers.map((layer) => layer.repairTrackName);
1908
+ if (binding.overlay) names.push(binding.overlay.repairTrackName);
1909
+ return names;
1450
1910
  }
1451
1911
  function catalogRepairTrackNames(catalog) {
1452
1912
  assertNoRetiredTrackFields(catalog);