mattebox 0.18.0 → 0.20.0

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.
Files changed (149) hide show
  1. package/README.md +17 -0
  2. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  3. package/dist/cdn/mattebox.dash-ll.min.js +3 -3
  4. package/dist/cdn/mattebox.dash.min.js +2 -2
  5. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  6. package/dist/cdn/mattebox.dual-ll.min.js +3 -3
  7. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  8. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  9. package/dist/cdn/mattebox.dual.min.js +3 -3
  10. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  11. package/dist/cdn/mattebox.hls-ll.min.js +3 -3
  12. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  13. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  14. package/dist/cdn/mattebox.hls.min.js +3 -3
  15. package/dist/cdn/mattebox.kernel.min.js +1 -1
  16. package/dist/cdn/mattebox.min.js +5 -5
  17. package/dist/containers/projection.d.ts +56 -0
  18. package/dist/containers/projection.d.ts.map +1 -0
  19. package/dist/containers/projection.js +105 -0
  20. package/dist/containers/projection.js.map +1 -0
  21. package/dist/containers/webm/cues.d.ts +59 -0
  22. package/dist/containers/webm/cues.d.ts.map +1 -0
  23. package/dist/containers/webm/cues.js +218 -0
  24. package/dist/containers/webm/cues.js.map +1 -0
  25. package/dist/containers/webm/index.d.ts +36 -0
  26. package/dist/containers/webm/index.d.ts.map +1 -0
  27. package/dist/containers/webm/index.js +271 -0
  28. package/dist/containers/webm/index.js.map +1 -0
  29. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/asyncToGenerator.js +1 -1
  30. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/defineProperty.js +1 -1
  31. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/objectSpread2.js +1 -1
  32. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/objectWithoutProperties.js +1 -1
  33. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  34. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/toPrimitive.js +1 -1
  35. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/toPropertyKey.js +1 -1
  36. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.159.0}/helpers/esm/typeof.js +1 -1
  37. package/dist/es2015/containers/emsg.js +2 -2
  38. package/dist/es2015/containers/fmp4/fit.js +1 -1
  39. package/dist/es2015/containers/fmp4/writer.js +1 -1
  40. package/dist/es2015/containers/id3.js +1 -1
  41. package/dist/es2015/containers/mp4-box/index.js +2 -2
  42. package/dist/es2015/containers/projection.js +107 -0
  43. package/dist/es2015/containers/scte35.js +1 -1
  44. package/dist/es2015/containers/sei.js +1 -1
  45. package/dist/es2015/containers/ts-transmux/demux.js +1 -1
  46. package/dist/es2015/containers/ts-transmux/h264.js +1 -1
  47. package/dist/es2015/containers/ts-transmux/h265.js +1 -1
  48. package/dist/es2015/containers/ts-transmux/index.js +1 -1
  49. package/dist/es2015/containers/ts-transmux/runner.js +2 -2
  50. package/dist/es2015/containers/ts-transmux/transmux.js +1 -1
  51. package/dist/es2015/containers/webm/cues.js +197 -0
  52. package/dist/es2015/containers/webm/index.js +255 -0
  53. package/dist/es2015/containers/webvtt.js +1 -1
  54. package/dist/es2015/containers/wvtt.js +1 -1
  55. package/dist/es2015/eme/index.js +3 -3
  56. package/dist/es2015/index.js +2 -2
  57. package/dist/es2015/kernel/append-queue.js +1 -1
  58. package/dist/es2015/kernel/dry-run.js +1 -1
  59. package/dist/es2015/kernel/mse.js +1 -1
  60. package/dist/es2015/kernel/prepare.js +2 -2
  61. package/dist/es2015/kernel/reducer.js +53 -4
  62. package/dist/es2015/kernel/refresh.js +1 -1
  63. package/dist/es2015/kernel/rendition-select.js +2 -2
  64. package/dist/es2015/kernel/scheduler.js +1 -1
  65. package/dist/es2015/kernel/timeline.js +1 -1
  66. package/dist/es2015/kernel/trace.js +2 -2
  67. package/dist/es2015/kernel/transport.js +2 -2
  68. package/dist/es2015/presets/define.js +2 -2
  69. package/dist/es2015/presets/full/index.js +6 -3
  70. package/dist/es2015/presets/tiers/dash-ll.js +2 -1
  71. package/dist/es2015/presets/tiers/dash.js +7 -2
  72. package/dist/es2015/protocols/dash-cmaf/index.js +12 -6
  73. package/dist/es2015/protocols/dash-cmaf/parse.js +102 -50
  74. package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +1 -1
  75. package/dist/es2015/protocols/dash-cmaf/periods.js +1 -1
  76. package/dist/es2015/protocols/dash-live/index.js +9 -6
  77. package/dist/es2015/protocols/dash-ll/index.js +3 -2
  78. package/dist/es2015/protocols/hls-cmaf/index.js +1 -1
  79. package/dist/es2015/protocols/hls-cmaf/parse.js +1 -1
  80. package/dist/es2015/protocols/hls-cmaf/unavailable.js +1 -1
  81. package/dist/es2015/protocols/hls-live/index.js +1 -1
  82. package/dist/es2015/protocols/hls-ll/parse.js +1 -1
  83. package/dist/es2015/stages/abr/index.js +1 -1
  84. package/dist/es2015/stages/aes-128/index.js +1 -1
  85. package/dist/es2015/stages/chapters/index.js +2 -2
  86. package/dist/es2015/stages/chapters/parse.js +2 -2
  87. package/dist/es2015/stages/cmcd/index.js +1 -2
  88. package/dist/es2015/stages/codec-probe/index.js +1 -1
  89. package/dist/es2015/stages/content-steering/index.js +1 -1
  90. package/dist/es2015/stages/eme-core/index.js +2 -2
  91. package/dist/es2015/stages/eme-fairplay/index.js +1 -1
  92. package/dist/es2015/stages/hdr/index.js +1 -1
  93. package/dist/es2015/stages/interstitials/breaks.js +1 -1
  94. package/dist/es2015/stages/interstitials/index.js +2 -2
  95. package/dist/es2015/stages/projection/index.js +51 -0
  96. package/dist/es2015/stages/qoe/index.js +1 -1
  97. package/dist/es2015/stages/recovery/index.js +1 -1
  98. package/dist/es2015/stages/rendition-names/index.js +1 -1
  99. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  100. package/dist/es2015/stages/text-cea708/decode.js +2 -2
  101. package/dist/es2015/stages/text-cea708/index.js +1 -1
  102. package/dist/es2015/stages/text-ttml/index.js +1 -1
  103. package/dist/es2015/stages/text-ttml/parse.js +1 -1
  104. package/dist/es2015/stages/thumbnails/index.js +1 -1
  105. package/dist/es2015/stages/timed-metadata/index.js +1 -1
  106. package/dist/es2015/stages/trick-play/index.js +1 -1
  107. package/dist/kernel/reducer.d.ts.map +1 -1
  108. package/dist/kernel/reducer.js +69 -1
  109. package/dist/kernel/reducer.js.map +1 -1
  110. package/dist/presets/full/index.d.ts.map +1 -1
  111. package/dist/presets/full/index.js +5 -2
  112. package/dist/presets/full/index.js.map +1 -1
  113. package/dist/presets/tiers/dash-ll.d.ts.map +1 -1
  114. package/dist/presets/tiers/dash-ll.js +2 -1
  115. package/dist/presets/tiers/dash-ll.js.map +1 -1
  116. package/dist/presets/tiers/dash.d.ts +7 -1
  117. package/dist/presets/tiers/dash.d.ts.map +1 -1
  118. package/dist/presets/tiers/dash.js +3 -2
  119. package/dist/presets/tiers/dash.js.map +1 -1
  120. package/dist/protocols/dash-cmaf/index.d.ts +8 -3
  121. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  122. package/dist/protocols/dash-cmaf/index.js +12 -5
  123. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  124. package/dist/protocols/dash-cmaf/parse.d.ts +6 -1
  125. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  126. package/dist/protocols/dash-cmaf/parse.js +87 -7
  127. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  128. package/dist/protocols/dash-live/index.d.ts +6 -3
  129. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  130. package/dist/protocols/dash-live/index.js +7 -4
  131. package/dist/protocols/dash-live/index.js.map +1 -1
  132. package/dist/protocols/dash-ll/index.d.ts.map +1 -1
  133. package/dist/protocols/dash-ll/index.js +3 -2
  134. package/dist/protocols/dash-ll/index.js.map +1 -1
  135. package/dist/stages/eme-wiseplay/index.d.ts +3 -2
  136. package/dist/stages/eme-wiseplay/index.d.ts.map +1 -1
  137. package/dist/stages/eme-wiseplay/index.js.map +1 -1
  138. package/dist/stages/projection/index.d.ts +3 -0
  139. package/dist/stages/projection/index.d.ts.map +1 -0
  140. package/dist/stages/projection/index.js +57 -0
  141. package/dist/stages/projection/index.js.map +1 -0
  142. package/dist/types/ir.d.ts +16 -1
  143. package/dist/types/ir.d.ts.map +1 -1
  144. package/dist/types/kernel.d.ts +5 -1
  145. package/dist/types/kernel.d.ts.map +1 -1
  146. package/dist/types/kernel.js.map +1 -1
  147. package/dist/types/messages.d.ts +23 -1
  148. package/dist/types/messages.d.ts.map +1 -1
  149. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/asyncToGenerator.js";
2
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
1
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
2
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
3
3
  // src/kernel/transport.ts
4
4
  const DEFAULT_RETRY_POLICY = {
5
5
  maxAttempts: 3,
@@ -1,6 +1,6 @@
1
1
  import { mattebox } from "../index.js";
2
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectWithoutProperties.js";
3
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectWithoutProperties.js";
3
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
4
4
  // src/presets/define.ts
5
5
  const _excluded = ["stages", "without"];
6
6
  /** Applies the merge rule. Exported for tests; presets call it through `stages`. */
@@ -1,6 +1,7 @@
1
1
  import chapters from "../../stages/chapters/index.js";
2
2
  import cmsd from "../../stages/cmsd/index.js";
3
3
  import hdr from "../../stages/hdr/index.js";
4
+ import projection from "../../stages/projection/index.js";
4
5
  import qoe from "../../stages/qoe/index.js";
5
6
  import renditionNames from "../../stages/rendition-names/index.js";
6
7
  import textCea708 from "../../stages/text-cea708/index.js";
@@ -24,8 +25,9 @@ import { tsTier } from "../tiers/ts.js";
24
25
  * streams carry 608 beside them, which the base reads), TTML subtitles
25
26
  * (opt-in by the owner's decision), HDR by capability (it excludes HDR
26
27
  * where nothing is known, which a page may not want by default), local
27
- * QoE metrics, CMSD (it acts on response headers a CDN must expose), and
28
- * localized rendition names (a menu reads them).
28
+ * QoE metrics, CMSD (it acts on response headers a CDN must expose),
29
+ * localized rendition names (a menu reads them), and the projection of a
30
+ * 360° init segment (most programmes are flat).
29
31
  * CMCD is in no preset: it changes every request, which costs a page that
30
32
  * never asked for it. A page adds the stage.
31
33
  * Feature parity with
@@ -48,6 +50,7 @@ const preset = definePreset("full", () => [
48
50
  hdr(),
49
51
  qoe(),
50
52
  cmsd(),
51
- renditionNames()
53
+ renditionNames(),
54
+ projection()
52
55
  ]);
53
56
  export { preset as default };
@@ -1,3 +1,4 @@
1
+ import webm from "../../containers/webm/index.js";
1
2
  import dashLl from "../../protocols/dash-ll/index.js";
2
3
  // src/presets/tiers/dash-ll.ts
3
4
  /**
@@ -12,6 +13,6 @@ import dashLl from "../../protocols/dash-ll/index.js";
12
13
  * plays it.
13
14
  */
14
15
  function dashLlLine() {
15
- return [dashLl()];
16
+ return [dashLl(), webm()];
16
17
  }
17
18
  export { dashLlLine };
@@ -1,3 +1,4 @@
1
+ import webm from "../../containers/webm/index.js";
1
2
  import dashCmaf from "../../protocols/dash-cmaf/index.js";
2
3
  import dashLive from "../../protocols/dash-live/index.js";
3
4
  // src/presets/tiers/dash.ts
@@ -7,8 +8,12 @@ import dashLive from "../../protocols/dash-live/index.js";
7
8
  * lazy chunks then gives each preset its stages and no others. Each group is
8
9
  * a function so a preset gets fresh stage instances.
9
10
  */
10
- /** DASH on demand and live. */
11
+ /** DASH on demand and live, with WebM next to MP4, as dash.js and Shaka Player play it. */
11
12
  function dashLine() {
12
- return [dashCmaf(), dashLive()];
13
+ return [
14
+ dashCmaf(),
15
+ dashLive(),
16
+ webm()
17
+ ];
13
18
  }
14
19
  export { dashLine };
@@ -6,7 +6,7 @@ import { isUnresolved } from "../../kernel/timeline.js";
6
6
  import { manifestFact } from "../adapter-shared.js";
7
7
  import { parse, sidxToSegments } from "./parse.js";
8
8
  import { installPeriods } from "./periods-runtime.js";
9
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
9
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
10
10
  // src/protocols/dash-cmaf/index.ts
11
11
  /**
12
12
  * The dash-cmaf protocol adapter as a stage. Inert module: exports a
@@ -67,7 +67,8 @@ function neededIndexes(state, kernel) {
67
67
  "audio",
68
68
  "text"
69
69
  ], kernel.quality.active)) {
70
- if (asSidx(rendition.segments) === null) continue;
70
+ const sidx = asSidx(rendition.segments);
71
+ if (sidx === null || sidx.format === "webm") continue;
71
72
  if (asked.has(rendition.id) || rendition.id in state.failed) continue;
72
73
  needed.push(rendition);
73
74
  }
@@ -119,8 +120,13 @@ function retry(state, renditionId) {
119
120
  constraint: { excludeIds: Object.keys(failed) }
120
121
  })]];
121
122
  }
122
- /** The slice reducer. `lowLatency` reads the MPD as dash-ll does. */
123
- const createReduceDash = (retryMs, lowLatency = false) => (slice, msg, kernel) => {
123
+ /**
124
+ * The slice reducer. `lowLatency` reads the MPD as dash-ll does.
125
+ * `capabilities` is the composition's, read once at install: they are
126
+ * fixed when the engine is built. A stage that provides `video/webm` keeps
127
+ * WebM Representations in.
128
+ */
129
+ const createReduceDash = (retryMs, lowLatency = false, capabilities = []) => (slice, msg, kernel) => {
124
130
  const state = slice !== null && slice !== void 0 ? slice : INITIAL;
125
131
  if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
126
132
  manifestUrl: msg.url,
@@ -133,7 +139,7 @@ const createReduceDash = (retryMs, lowLatency = false) => (slice, msg, kernel) =
133
139
  let warnings = [];
134
140
  const fact = manifestFact(msg.bytes, (_msg$url = msg.url) !== null && _msg$url !== void 0 ? _msg$url : state.manifestUrl, (text) => claims(state, text), (text, url) => {
135
141
  var _result$warnings;
136
- const result = parse(text, url, lowLatency);
142
+ const result = parse(text, url, lowLatency, capabilities);
137
143
  if (result.presentation !== null) warnings = (_result$warnings = result.warnings) !== null && _result$warnings !== void 0 ? _result$warnings : [];
138
144
  return result;
139
145
  });
@@ -249,7 +255,7 @@ function dashCmaf(options = {}) {
249
255
  name: "dash-cmaf",
250
256
  provides: ["dash-cmaf", ...MANIFEST_TYPES],
251
257
  install(ctx) {
252
- ctx.reduce("dash", createReduceDash(retryMs));
258
+ ctx.reduce("dash", createReduceDash(retryMs, false, ctx.capabilities()));
253
259
  return installDashPeriods(ctx);
254
260
  }
255
261
  };
@@ -4,7 +4,7 @@ import { resolveUrl } from "../../kernel/url.js";
4
4
  import { manifestError } from "../adapter-shared.js";
5
5
  import { dimensions } from "../dimensions.js";
6
6
  import { flattenPeriods } from "./periods.js";
7
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
7
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
8
8
  // src/protocols/dash-cmaf/parse.ts
9
9
  /**
10
10
  * MPD into the IR. Pure: no fetching, no state, no side effects. DOMParser
@@ -260,6 +260,52 @@ function supplementalOf(representation, adaptationSet) {
260
260
  for (const element of [representation, adaptationSet]) for (const attribute of Array.from(element.attributes)) if (attribute.localName === "supplementalCodecs") return { supplementalCodecs: attribute.value };
261
261
  return {};
262
262
  }
263
+ const OMAF_PROJECTION = "urn:mpeg:mpegI:omaf:2017:pf";
264
+ /**
265
+ * The OMAF projection format descriptor (ISO/IEC 23090-2 §8.3.2), on the
266
+ * Representation or its AdaptationSet, as EssentialProperty or
267
+ * SupplementalProperty: 3GPP TS 26.118 §5.2.2.3 uses the second, its
268
+ * advanced profile and the OMAF reference software the first.
269
+ * `omaf:projection_type` 0 is equirectangular, 1 a cube map, which the IR
270
+ * does not name. Read by local name, since the prefix is the manifest's
271
+ * choice. OMAF has no half-equirectangular type. Sources:
272
+ * https://www.etsi.org/deliver/etsi_ts/126100_126199/126118/17.00.00_60/ts_126118v170000p.pdf
273
+ * https://github.com/nokiatech/omaf/blob/d08ad5b82e021696483bc6fece804f915b5b389c/Player/Sources/Player/DashProvider/NVRMPDExtension.cpp#L25-L34
274
+ */
275
+ function projectionOf(representation, adaptationSet) {
276
+ for (const element of [representation, adaptationSet]) for (const property of [...children(element, "EssentialProperty"), ...children(element, "SupplementalProperty")]) {
277
+ if (attr(property, "schemeIdUri") !== OMAF_PROJECTION) continue;
278
+ for (const attribute of Array.from(property.attributes)) {
279
+ if (attribute.localName !== "projection_type") continue;
280
+ return attribute.value.trim().split(/\s+/)[0] === "0" ? { projection: "equirectangular" } : {};
281
+ }
282
+ }
283
+ return {};
284
+ }
285
+ /**
286
+ * The schemes of a `FramePacking` descriptor whose values are the frame
287
+ * packing arrangement types of H.264 Table D-8, which ITU-T H.273
288
+ * (`VideoFramePackingType`) repeats. DASH-IF lists both:
289
+ * https://dashif.org/identifiers/video_source_metadata/
290
+ */
291
+ const FRAME_PACKING = ["urn:mpeg:mpegB:cicp:VideoFramePackingType", "urn:mpeg:dash:14496:10:frame_packing_arrangement_type:2011"];
292
+ /**
293
+ * The `FramePacking` descriptor (ISO/IEC 23009-1 §5.8.4.6), on the
294
+ * Representation or its AdaptationSet: 3 is side by side, 4 top and bottom.
295
+ * The descriptor does not say which eye comes first, and the left one is
296
+ * the default of H.264's frame packing message. Another type, such as an
297
+ * interleaving, is not a packing the IR names.
298
+ */
299
+ function framePackingOf(representation, adaptationSet) {
300
+ for (const element of [representation, adaptationSet]) for (const descriptor of children(element, "FramePacking")) {
301
+ var _attr10;
302
+ if (!FRAME_PACKING.includes((_attr10 = attr(descriptor, "schemeIdUri")) !== null && _attr10 !== void 0 ? _attr10 : "")) continue;
303
+ const value = attr(descriptor, "value");
304
+ if (value === "3") return { framePacking: "side-by-side" };
305
+ return value === "4" ? { framePacking: "top-bottom" } : {};
306
+ }
307
+ return {};
308
+ }
263
309
  function videoRangeOf(representation, adaptationSet, codecs) {
264
310
  for (const element of [representation, adaptationSet]) for (const property of [...children(element, "EssentialProperty"), ...children(element, "SupplementalProperty")]) {
265
311
  if (attr(property, "schemeIdUri") !== TRANSFER_CHARACTERISTICS) continue;
@@ -303,9 +349,9 @@ const CICP_CHANNELS = [
303
349
  */
304
350
  function channelsOf(representation, adaptationSet) {
305
351
  for (const element of [representation, adaptationSet]) for (const config of children(element, "AudioChannelConfiguration")) {
306
- var _attr10, _attr11;
307
- const scheme = (_attr10 = attr(config, "schemeIdUri")) !== null && _attr10 !== void 0 ? _attr10 : "";
308
- const value = (_attr11 = attr(config, "value")) !== null && _attr11 !== void 0 ? _attr11 : "";
352
+ var _attr11, _attr12;
353
+ const scheme = (_attr11 = attr(config, "schemeIdUri")) !== null && _attr11 !== void 0 ? _attr11 : "";
354
+ const value = (_attr12 = attr(config, "value")) !== null && _attr12 !== void 0 ? _attr12 : "";
309
355
  let channels = 0;
310
356
  if (scheme === "urn:mpeg:dash:23003:3:audio_channel_configuration:2011") channels = Number(value);
311
357
  else if (scheme === "urn:mpeg:mpegB:cicp:ChannelConfiguration") {
@@ -332,8 +378,8 @@ function bitCount(value) {
332
378
  */
333
379
  function isTrickMode(adaptationSet) {
334
380
  for (const property of children(adaptationSet, "EssentialProperty")) {
335
- var _attr12;
336
- if (((_attr12 = attr(property, "schemeIdUri")) !== null && _attr12 !== void 0 ? _attr12 : "").includes("trickmode")) return true;
381
+ var _attr13;
382
+ if (((_attr13 = attr(property, "schemeIdUri")) !== null && _attr13 !== void 0 ? _attr13 : "").includes("trickmode")) return true;
337
383
  }
338
384
  if (numberAttr(adaptationSet, "maxPlayoutRate") !== null) return true;
339
385
  for (const representation of children(adaptationSet, "Representation")) {
@@ -352,8 +398,8 @@ function tileGridOf(representation, adaptationSet, width, height) {
352
398
  if (width === null || height === null) return null;
353
399
  const properties = [...children(representation, "EssentialProperty"), ...children(adaptationSet, "EssentialProperty")];
354
400
  for (const property of properties) {
355
- var _attr13;
356
- if (!((_attr13 = attr(property, "schemeIdUri")) !== null && _attr13 !== void 0 ? _attr13 : "").includes("thumbnail_tile")) continue;
401
+ var _attr14;
402
+ if (!((_attr14 = attr(property, "schemeIdUri")) !== null && _attr14 !== void 0 ? _attr14 : "").includes("thumbnail_tile")) continue;
357
403
  const grid = dimensions(attr(property, "value"));
358
404
  if (grid === null) continue;
359
405
  const [columns, rows] = grid;
@@ -384,19 +430,19 @@ function mergeTemplates(levels) {
384
430
  let complete = null;
385
431
  let found = false;
386
432
  for (const level of levels) {
387
- var _attr14, _attr15, _numberAttr4, _numberAttr5, _numberAttr6, _numberAttr7, _children$2, _availabilityOffsetOf, _attr16;
433
+ var _attr15, _attr16, _numberAttr4, _numberAttr5, _numberAttr6, _numberAttr7, _children$2, _availabilityOffsetOf, _attr17;
388
434
  const template = children(level, "SegmentTemplate")[0];
389
435
  if (template === void 0) continue;
390
436
  found = true;
391
- media = (_attr14 = attr(template, "media")) !== null && _attr14 !== void 0 ? _attr14 : media;
392
- initialization = (_attr15 = attr(template, "initialization")) !== null && _attr15 !== void 0 ? _attr15 : initialization;
437
+ media = (_attr15 = attr(template, "media")) !== null && _attr15 !== void 0 ? _attr15 : media;
438
+ initialization = (_attr16 = attr(template, "initialization")) !== null && _attr16 !== void 0 ? _attr16 : initialization;
393
439
  timescale = (_numberAttr4 = numberAttr(template, "timescale")) !== null && _numberAttr4 !== void 0 ? _numberAttr4 : timescale;
394
440
  startNumber = (_numberAttr5 = numberAttr(template, "startNumber")) !== null && _numberAttr5 !== void 0 ? _numberAttr5 : startNumber;
395
441
  duration = (_numberAttr6 = numberAttr(template, "duration")) !== null && _numberAttr6 !== void 0 ? _numberAttr6 : duration;
396
442
  pto = (_numberAttr7 = numberAttr(template, "presentationTimeOffset")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : pto;
397
443
  timelineElement = (_children$2 = children(template, "SegmentTimeline")[0]) !== null && _children$2 !== void 0 ? _children$2 : timelineElement;
398
444
  ato = (_availabilityOffsetOf = availabilityOffsetOf(template)) !== null && _availabilityOffsetOf !== void 0 ? _availabilityOffsetOf : ato;
399
- complete = (_attr16 = attr(template, "availabilityTimeComplete")) !== null && _attr16 !== void 0 ? _attr16 : complete;
445
+ complete = (_attr17 = attr(template, "availabilityTimeComplete")) !== null && _attr17 !== void 0 ? _attr17 : complete;
400
446
  }
401
447
  if (!found) return null;
402
448
  return {
@@ -423,7 +469,7 @@ function mergeTemplates(levels) {
423
469
  * level has a SegmentList.
424
470
  */
425
471
  function segmentListOf(levels, base, periodStart, periodEndUnits) {
426
- var _attr18;
472
+ var _attr19;
427
473
  let timescale = 1;
428
474
  let duration = null;
429
475
  let startNumber = 1;
@@ -456,20 +502,20 @@ function segmentListOf(levels, base, periodStart, periodEndUnits) {
456
502
  else if (urls.length > 1) return "invalid";
457
503
  const segments = [];
458
504
  urls.forEach((url, i) => {
459
- var _times$i, _attr17;
505
+ var _times$i, _attr18;
460
506
  const [time, length] = (_times$i = times[i]) !== null && _times$i !== void 0 ? _times$i : [offset, 0];
461
507
  const range = parseByteRange(attr(url, "mediaRange"));
462
508
  segments.push(_objectSpread2({
463
509
  seq: startNumber + i,
464
510
  start: periodStart + (time - offset) / timescale,
465
511
  duration: length / timescale,
466
- url: resolveUrl((_attr17 = attr(url, "media")) !== null && _attr17 !== void 0 ? _attr17 : "", base)
512
+ url: resolveUrl((_attr18 = attr(url, "media")) !== null && _attr18 !== void 0 ? _attr18 : "", base)
467
513
  }, range !== null ? { byteRange: range } : {}));
468
514
  });
469
515
  const initRange = initialization === null ? null : parseByteRange(attr(initialization, "range"));
470
516
  return {
471
517
  segments,
472
- init: initialization === null ? null : _objectSpread2({ url: resolveUrl((_attr18 = attr(initialization, "sourceURL")) !== null && _attr18 !== void 0 ? _attr18 : "", base) }, initRange !== null ? { byteRange: initRange } : {})
518
+ init: initialization === null ? null : _objectSpread2({ url: resolveUrl((_attr19 = attr(initialization, "sourceURL")) !== null && _attr19 !== void 0 ? _attr19 : "", base) }, initRange !== null ? { byteRange: initRange } : {})
473
519
  };
474
520
  }
475
521
  function parseTimeline(timelineElement, periodEndUnits) {
@@ -508,13 +554,13 @@ function substituteIdentity(template, id, bandwidth) {
508
554
  });
509
555
  }
510
556
  function contentTypeOf(adaptationSet, mimeType) {
511
- var _attr19, _children$5;
557
+ var _attr20, _children$5;
512
558
  const declared = attr(adaptationSet, "contentType");
513
559
  if (declared === "video" || declared === "audio" || declared === "text" || declared === "image" || declared === "metadata") return declared;
514
560
  if (mimeType.startsWith("audio/")) return "audio";
515
561
  if (mimeType.startsWith("image/")) return "image";
516
562
  if (mimeType.startsWith("text/") || mimeType === "application/ttml+xml") return "text";
517
- const codecs = (_attr19 = attr(adaptationSet, "codecs")) !== null && _attr19 !== void 0 ? _attr19 : attr((_children$5 = children(adaptationSet, "Representation")[0]) !== null && _children$5 !== void 0 ? _children$5 : adaptationSet, "codecs");
563
+ const codecs = (_attr20 = attr(adaptationSet, "codecs")) !== null && _attr20 !== void 0 ? _attr20 : attr((_children$5 = children(adaptationSet, "Representation")[0]) !== null && _children$5 !== void 0 ? _children$5 : adaptationSet, "codecs");
518
564
  if (mimeType === "application/mp4" && codecs !== null && /^(stpp|wvtt)/.test(codecs)) return "text";
519
565
  return "video";
520
566
  }
@@ -550,15 +596,15 @@ function periodSpans(elements, mpdDuration) {
550
596
  */
551
597
  function followsOf(adaptationSet) {
552
598
  return children(adaptationSet, "SupplementalProperty").filter((property) => {
553
- var _attr20;
554
- return /^urn:mpeg:dash:period-(continuity|connectivity):2015$/.test((_attr20 = attr(property, "schemeIdUri")) !== null && _attr20 !== void 0 ? _attr20 : "");
555
- }).flatMap((property) => {
556
599
  var _attr21;
557
- return ((_attr21 = attr(property, "value")) !== null && _attr21 !== void 0 ? _attr21 : "").split(/[\s,]+/).filter((v) => v !== "");
600
+ return /^urn:mpeg:dash:period-(continuity|connectivity):2015$/.test((_attr21 = attr(property, "schemeIdUri")) !== null && _attr21 !== void 0 ? _attr21 : "");
601
+ }).flatMap((property) => {
602
+ var _attr22;
603
+ return ((_attr22 = attr(property, "value")) !== null && _attr22 !== void 0 ? _attr22 : "").split(/[\s,]+/).filter((v) => v !== "");
558
604
  });
559
605
  }
560
- function parsePeriod(periodElement, span, index, mpdBase, isLive, availability) {
561
- var _attr30;
606
+ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability, capabilities) {
607
+ var _attr31;
562
608
  const matching = /* @__PURE__ */ new Map();
563
609
  const periodStart = span.start;
564
610
  const periodDuration = span.duration;
@@ -580,29 +626,31 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
580
626
  const renditions = [];
581
627
  let trackMime = null;
582
628
  for (const representation of children(adaptationSet, "Representation")) {
583
- var _ref2, _attr22, _trackMime, _parseFrameRate2, _numberAttr15, _attr28, _attr29;
629
+ var _ref2, _attr23, _trackMime, _parseFrameRate2, _numberAttr15, _attr29, _attr30;
584
630
  const id = attr(representation, "id");
585
631
  const bandwidth = numberAttr(representation, "bandwidth");
586
632
  if (id === null || bandwidth === null) continue;
587
633
  const repBase = applyBaseUrl(representation, asBase);
588
- const mimeType = (_ref2 = (_attr22 = attr(representation, "mimeType")) !== null && _attr22 !== void 0 ? _attr22 : asMime) !== null && _ref2 !== void 0 ? _ref2 : "video/mp4";
589
- if (/\/(webm|x-matroska)$/.test(mimeType)) continue;
634
+ const mimeType = (_ref2 = (_attr23 = attr(representation, "mimeType")) !== null && _attr23 !== void 0 ? _attr23 : asMime) !== null && _ref2 !== void 0 ? _ref2 : "video/mp4";
635
+ const webm = /\/(webm|x-matroska)$/.test(mimeType);
636
+ if (webm && !capabilities.some((c) => typeof c !== "string" && c.mimeType === mimeType)) continue;
590
637
  trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
591
638
  const segmentBase = children(representation, "SegmentBase")[0];
592
639
  if (segmentBase !== void 0) {
593
- var _numberAttr14, _parseFrameRate, _attr23, _attr24;
640
+ var _numberAttr14, _parseFrameRate, _attr24, _attr25;
594
641
  const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
595
642
  if (indexRange === null) continue;
596
643
  const baseTimescale = (_numberAttr14 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr14 !== void 0 ? _numberAttr14 : 1;
597
644
  const pto = numberAttr(segmentBase, "presentationTimeOffset");
598
645
  const initElement = children(segmentBase, "Initialization")[0];
599
646
  const initRange = initElement !== void 0 ? parseByteRange(attr(initElement, "range")) : null;
600
- const sidxSegments = _objectSpread2({
647
+ if (webm && initRange === null) continue;
648
+ const sidxSegments = _objectSpread2(_objectSpread2({
601
649
  kind: "sidx",
602
650
  url: repBase,
603
651
  indexRange,
604
652
  timescale: baseTimescale
605
- }, pto !== null && pto !== 0 ? { presentationTimeOffset: pto / baseTimescale } : {});
653
+ }, pto !== null && pto !== 0 ? { presentationTimeOffset: pto / baseTimescale } : {}), webm ? { format: "webm" } : {});
606
654
  const sidxInit = initRange !== null ? {
607
655
  url: repBase,
608
656
  byteRange: initRange
@@ -610,13 +658,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
610
658
  const w = numberAttr(representation, "width");
611
659
  const h = numberAttr(representation, "height");
612
660
  const fr = (_parseFrameRate = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate !== void 0 ? _parseFrameRate : parseFrameRate(attr(adaptationSet, "frameRate"));
613
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
661
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
614
662
  id,
615
663
  bitrate: bandwidth,
616
- codecs: (_attr23 = attr(representation, "codecs")) !== null && _attr23 !== void 0 ? _attr23 : asCodecs,
664
+ codecs: (_attr24 = attr(representation, "codecs")) !== null && _attr24 !== void 0 ? _attr24 : asCodecs,
617
665
  mimeType,
618
666
  segments: sidxSegments
619
- }, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}), videoRangeOf(representation, adaptationSet, (_attr24 = attr(representation, "codecs")) !== null && _attr24 !== void 0 ? _attr24 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
667
+ }, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}), videoRangeOf(representation, adaptationSet, (_attr25 = attr(representation, "codecs")) !== null && _attr25 !== void 0 ? _attr25 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)), projectionOf(representation, adaptationSet)), framePackingOf(representation, adaptationSet)));
620
668
  continue;
621
669
  }
622
670
  const list = segmentListOf([
@@ -626,15 +674,15 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
626
674
  ], repBase, periodStart, (timescale, offset) => periodDuration !== null ? Math.round(offset + periodDuration * timescale) : null);
627
675
  if (list === "invalid") return { error: manifestError(`bad SegmentList in '${id}'`) };
628
676
  if (list !== null) {
629
- var _attr25, _attr26;
677
+ var _attr26, _attr27;
630
678
  const segments = list.segments.map((segment) => segment.duration === 0 && periodDuration !== null ? _objectSpread2(_objectSpread2({}, segment), {}, { duration: periodDuration }) : segment);
631
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
679
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
632
680
  id,
633
681
  bitrate: bandwidth,
634
- codecs: (_attr25 = attr(representation, "codecs")) !== null && _attr25 !== void 0 ? _attr25 : asCodecs,
682
+ codecs: (_attr26 = attr(representation, "codecs")) !== null && _attr26 !== void 0 ? _attr26 : asCodecs,
635
683
  mimeType,
636
684
  segments
637
- }, list.init !== null ? { init: list.init } : {}), numberAttr(representation, "width") !== null ? { width: numberAttr(representation, "width") } : {}), numberAttr(representation, "height") !== null ? { height: numberAttr(representation, "height") } : {}), videoRangeOf(representation, adaptationSet, (_attr26 = attr(representation, "codecs")) !== null && _attr26 !== void 0 ? _attr26 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
685
+ }, list.init !== null ? { init: list.init } : {}), numberAttr(representation, "width") !== null ? { width: numberAttr(representation, "width") } : {}), numberAttr(representation, "height") !== null ? { height: numberAttr(representation, "height") } : {}), videoRangeOf(representation, adaptationSet, (_attr27 = attr(representation, "codecs")) !== null && _attr27 !== void 0 ? _attr27 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)), projectionOf(representation, adaptationSet)), framePackingOf(representation, adaptationSet)));
638
686
  continue;
639
687
  }
640
688
  const template = mergeTemplates([
@@ -644,11 +692,11 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
644
692
  ]);
645
693
  if (template === null || template.media === null) {
646
694
  if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
647
- var _attr27;
695
+ var _attr28;
648
696
  renditions.push({
649
697
  id,
650
698
  bitrate: bandwidth,
651
- codecs: (_attr27 = attr(representation, "codecs")) !== null && _attr27 !== void 0 ? _attr27 : asCodecs,
699
+ codecs: (_attr28 = attr(representation, "codecs")) !== null && _attr28 !== void 0 ? _attr28 : asCodecs,
652
700
  mimeType,
653
701
  segments: [{
654
702
  seq: 0,
@@ -682,13 +730,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
682
730
  const height = numberAttr(representation, "height");
683
731
  const tiles = tileGridOf(representation, adaptationSet, width, height);
684
732
  const playoutRate = trick ? (_numberAttr15 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr15 !== void 0 ? _numberAttr15 : asPlayoutRate : null;
685
- renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
733
+ renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
686
734
  id,
687
735
  bitrate: bandwidth,
688
- codecs: (_attr28 = attr(representation, "codecs")) !== null && _attr28 !== void 0 ? _attr28 : asCodecs,
736
+ codecs: (_attr29 = attr(representation, "codecs")) !== null && _attr29 !== void 0 ? _attr29 : asCodecs,
689
737
  mimeType,
690
738
  segments
691
- }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), videoRangeOf(representation, adaptationSet, (_attr29 = attr(representation, "codecs")) !== null && _attr29 !== void 0 ? _attr29 : asCodecs)), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
739
+ }, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), videoRangeOf(representation, adaptationSet, (_attr30 = attr(representation, "codecs")) !== null && _attr30 !== void 0 ? _attr30 : asCodecs)), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)), projectionOf(representation, adaptationSet)), framePackingOf(representation, adaptationSet)));
692
740
  }
693
741
  if (renditions.length === 0) continue;
694
742
  const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
@@ -739,7 +787,7 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
739
787
  }
740
788
  const events = eventsOf(periodElement, periodStart);
741
789
  return {
742
- id: (_attr30 = attr(periodElement, "id")) !== null && _attr30 !== void 0 ? _attr30 : `p${index}`,
790
+ id: (_attr31 = attr(periodElement, "id")) !== null && _attr31 !== void 0 ? _attr31 : `p${index}`,
743
791
  start: periodStart,
744
792
  duration: periodDuration,
745
793
  tracks,
@@ -765,11 +813,11 @@ const UTC_SCHEME = /^urn:mpeg:dash:utc:(http-xsdate|http-iso|http-head|direct):2
765
813
  * like any other.
766
814
  */
767
815
  function timeServerOf(mpd, baseUrl) {
768
- var _attr31, _attr32;
816
+ var _attr32, _attr33;
769
817
  const timing = children(mpd, "UTCTiming")[0];
770
818
  if (timing === void 0) return null;
771
- const scheme = (_attr31 = attr(timing, "schemeIdUri")) !== null && _attr31 !== void 0 ? _attr31 : "";
772
- const value = (_attr32 = attr(timing, "value")) !== null && _attr32 !== void 0 ? _attr32 : "";
819
+ const scheme = (_attr32 = attr(timing, "schemeIdUri")) !== null && _attr32 !== void 0 ? _attr32 : "";
820
+ const value = (_attr33 = attr(timing, "value")) !== null && _attr33 !== void 0 ? _attr33 : "";
773
821
  if (!UTC_SCHEME.test(scheme) || value === "") return null;
774
822
  return {
775
823
  scheme,
@@ -814,8 +862,12 @@ function serviceOf(mpd) {
814
862
  * dash.js's live delay: the ServiceDescription target, else
815
863
  * `@suggestedPresentationDelay`, else four `@maxSegmentDuration`, else four
816
864
  * `@minBufferTime`.
865
+ *
866
+ * `capabilities` is the composition's. A WebM Representation is kept
867
+ * only when a stage provides its MIME type as a content handler, as the
868
+ * `webm` container does.
817
869
  */
818
- function parse(text, baseUrl, lowLatency = false) {
870
+ function parse(text, baseUrl, lowLatency = false, capabilities = []) {
819
871
  var _flat$tracks, _flat$events;
820
872
  let doc;
821
873
  try {
@@ -841,8 +893,8 @@ function parse(text, baseUrl, lowLatency = false) {
841
893
  } : null;
842
894
  let live;
843
895
  if (isLive) {
844
- var _attr33, _service$target;
845
- const availabilityStart = Date.parse((_attr33 = attr(mpd, "availabilityStartTime")) !== null && _attr33 !== void 0 ? _attr33 : "");
896
+ var _attr34, _service$target;
897
+ const availabilityStart = Date.parse((_attr34 = attr(mpd, "availabilityStartTime")) !== null && _attr34 !== void 0 ? _attr34 : "");
846
898
  const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
847
899
  const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
848
900
  const service = lowLatency ? serviceOf(mpd) : {};
@@ -887,7 +939,7 @@ function parse(text, baseUrl, lowLatency = false) {
887
939
  const parsed = [];
888
940
  for (let i = 0; i < periodElements.length; i += 1) {
889
941
  if (i > 0 && isLive) break;
890
- const result = parsePeriod(periodElements[i], spans[i], i, mpdBase, isLive, availability);
942
+ const result = parsePeriod(periodElements[i], spans[i], i, mpdBase, isLive, availability, capabilities);
891
943
  if ("error" in result) return {
892
944
  presentation: null,
893
945
  error: result.error
@@ -1,6 +1,6 @@
1
1
  import { findRendition } from "../../kernel/presentation.js";
2
2
  import { segmentAt } from "../../kernel/timeline.js";
3
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/asyncToGenerator.js";
3
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
4
4
  // src/protocols/dash-cmaf/periods-runtime.ts
5
5
  /**
6
6
  * What a flattened multi-period presentation needs at playback time, kept
@@ -1,5 +1,5 @@
1
1
  import { isIndexed, isUnresolved, segmentAt } from "../../kernel/timeline.js";
2
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
2
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
3
3
  // src/protocols/dash-cmaf/periods.ts
4
4
  /**
5
5
  * Several DASH Periods as one continuous presentation, the way Shaka
@@ -1,7 +1,7 @@
1
1
  import { scheduled, tickAfter } from "../../kernel/effects.js";
2
2
  import { parse } from "../dash-cmaf/parse.js";
3
3
  import { registerLiveNamespace } from "../live-shared.js";
4
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
4
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
5
5
  // src/protocols/dash-live/index.ts
6
6
  /**
7
7
  * DASH live: the edge is computed, never read. Wall clock enters only as
@@ -51,7 +51,7 @@ const INITIAL = {
51
51
  };
52
52
  /** FNV-1a over the bytes: tells one MPD text from the next. */
53
53
  function hashOf(bytes) {
54
- let hash = 2166136261;
54
+ let hash = 0x811c9dc5;
55
55
  for (const byte of new Uint8Array(bytes)) hash = Math.imul(hash ^ byte, 16777619);
56
56
  return hash >>> 0;
57
57
  }
@@ -143,8 +143,11 @@ function reloadFailed(state, presentation, cause) {
143
143
  tickPending: true
144
144
  }), [tick((_presentation$live$up = presentation.live.updatePeriod) !== null && _presentation$live$up !== void 0 ? _presentation$live$up : 4)]];
145
145
  }
146
- /** The slice reducer. `lowLatency` reloads the MPD as dash-ll reads it. */
147
- const createReduceDashLive = (lowLatency = false) => (slice, msg, kernel) => {
146
+ /**
147
+ * The slice reducer. `lowLatency` reloads the MPD as dash-ll reads it.
148
+ * `capabilities` is the composition's, which the MPD parse reads.
149
+ */
150
+ const createReduceDashLive = (lowLatency = false, capabilities = []) => (slice, msg, kernel) => {
148
151
  let state = slice !== null && slice !== void 0 ? slice : INITIAL;
149
152
  if ((msg.type === "TIME_UPDATE" || msg.type === "SEGMENT_LOADED") && msg.wallClock !== void 0) state = _objectSpread2(_objectSpread2({}, state), {}, { lastWallClock: msg.wallClock });
150
153
  if (msg.type === "SEGMENT_LOADED" && (msg.trackId === "manifest" || msg.trackId === MPD_TOKEN) && msg.serverDate !== void 0 && msg.wallClock !== void 0) state = _objectSpread2(_objectSpread2({}, state), {}, { mpdSkew: msg.serverDate - msg.wallClock });
@@ -256,7 +259,7 @@ const createReduceDashLive = (lowLatency = false) => (slice, msg, kernel) => {
256
259
  var _msg$url;
257
260
  if (state.manifestUrl === null) return [state, []];
258
261
  const base = (_msg$url = msg.url) !== null && _msg$url !== void 0 ? _msg$url : state.manifestUrl;
259
- const result = parse(new TextDecoder().decode(msg.bytes), base, lowLatency);
262
+ const result = parse(new TextDecoder().decode(msg.bytes), base, lowLatency, capabilities);
260
263
  if (result.presentation === null) return reloadFailed(state, kernel.presentation, result.error.code);
261
264
  const effects = [];
262
265
  const hash = hashOf(msg.bytes);
@@ -296,7 +299,7 @@ function dashLive() {
296
299
  provides: ["dash-live"],
297
300
  requires: ["dash-cmaf"],
298
301
  install(ctx) {
299
- ctx.reduce("dash-live", createReduceDashLive());
302
+ ctx.reduce("dash-live", createReduceDashLive(false, ctx.capabilities()));
300
303
  registerLiveNamespace(ctx);
301
304
  }
302
305
  };
@@ -30,8 +30,9 @@ function dashLl(options = {}) {
30
30
  ...MANIFEST_TYPES
31
31
  ],
32
32
  install(ctx) {
33
- ctx.reduce("dash", createReduceDash(retryMs, true));
34
- ctx.reduce("dash-live", createReduceDashLive(true));
33
+ const capabilities = ctx.capabilities();
34
+ ctx.reduce("dash", createReduceDash(retryMs, true, capabilities));
35
+ ctx.reduce("dash-live", createReduceDashLive(true, capabilities));
35
36
  ctx.registerChunkSplitter(completeChunks);
36
37
  registerLiveNamespace(ctx);
37
38
  return installDashPeriods(ctx);
@@ -4,7 +4,7 @@ import { activeRenditions } from "../../kernel/rendition-select.js";
4
4
  import { manifestFact } from "../adapter-shared.js";
5
5
  import { parse, parseMediaPlaylist, refreshFor } from "./parse.js";
6
6
  import { LOAD_FAILED, readmitMessage, unavailableMessages } from "./unavailable.js";
7
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
7
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
8
8
  // src/protocols/hls-cmaf/index.ts
9
9
  /**
10
10
  * The hls-cmaf protocol adapter as a stage. Inert module: exports a
@@ -3,7 +3,7 @@ import { resolveUrl } from "../../kernel/url.js";
3
3
  import { manifestError } from "../adapter-shared.js";
4
4
  import { dimensions } from "../dimensions.js";
5
5
  import { lex } from "./lexer.js";
6
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
6
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
7
7
  // src/protocols/hls-cmaf/parse.ts
8
8
  /**
9
9
  * m3u8 into the IR. Pure: no fetching, no state, no side effects. URLs are
@@ -1,6 +1,6 @@
1
1
  import { isTrick } from "../../kernel/presentation.js";
2
2
  import { withDeadGroups } from "../../kernel/rendition-select.js";
3
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
3
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
4
4
  // src/protocols/hls-cmaf/unavailable.ts
5
5
  /**
6
6
  * What a playlist that cannot be used means for playback. Pure; shared by
@@ -4,7 +4,7 @@ import { activeRenditions } from "../../kernel/rendition-select.js";
4
4
  import { parseMediaPlaylist, refreshFor } from "../hls-cmaf/parse.js";
5
5
  import { RELOAD_FAILED, readmitMessage, unavailableMessages } from "../hls-cmaf/unavailable.js";
6
6
  import { registerLiveNamespace } from "../live-shared.js";
7
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
7
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
8
8
  // src/protocols/hls-live/index.ts
9
9
  /**
10
10
  * HLS live: the edge is read, never computed. A slice reducer reloads the
@@ -2,7 +2,7 @@ import { resolveUrl } from "../../kernel/url.js";
2
2
  import { manifestError } from "../adapter-shared.js";
3
3
  import { lex } from "../hls-cmaf/lexer.js";
4
4
  import { parseByteRange, parseMediaLines } from "../hls-cmaf/parse.js";
5
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
5
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
6
6
  // src/protocols/hls-ll/parse.ts
7
7
  /**
8
8
  * Low-latency HLS media playlists (RFC 8216bis §4.4.3.7, §4.4.3.8,