@ac-kit/format-dash 0.0.0-stage → 0.1.1

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 (92) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE +28 -0
  3. package/README.md +180 -2
  4. package/dist/_template.d.ts +34 -0
  5. package/dist/_template.d.ts.map +1 -0
  6. package/dist/_template.js +90 -0
  7. package/dist/_template.js.map +1 -0
  8. package/dist/_xlink.d.ts +9 -0
  9. package/dist/_xlink.d.ts.map +1 -0
  10. package/dist/_xlink.js +14 -0
  11. package/dist/_xlink.js.map +1 -0
  12. package/dist/dash-namespaces.d.ts +27 -0
  13. package/dist/dash-namespaces.d.ts.map +1 -0
  14. package/dist/dash-namespaces.js +30 -0
  15. package/dist/dash-namespaces.js.map +1 -0
  16. package/dist/errors.d.ts +127 -0
  17. package/dist/errors.d.ts.map +1 -0
  18. package/dist/errors.js +52 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +12 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/limits.d.ts +51 -0
  25. package/dist/limits.d.ts.map +1 -0
  26. package/dist/limits.js +39 -0
  27. package/dist/limits.js.map +1 -0
  28. package/dist/model/dash-common.d.ts +124 -0
  29. package/dist/model/dash-common.d.ts.map +1 -0
  30. package/dist/model/dash-common.js +2 -0
  31. package/dist/model/dash-common.js.map +1 -0
  32. package/dist/model/dash-mpd.d.ts +111 -0
  33. package/dist/model/dash-mpd.d.ts.map +1 -0
  34. package/dist/model/dash-mpd.js +2 -0
  35. package/dist/model/dash-mpd.js.map +1 -0
  36. package/dist/model/dash-segment-information.d.ts +90 -0
  37. package/dist/model/dash-segment-information.d.ts.map +1 -0
  38. package/dist/model/dash-segment-information.js +2 -0
  39. package/dist/model/dash-segment-information.js.map +1 -0
  40. package/dist/parse/_attribute-reader.d.ts +94 -0
  41. package/dist/parse/_attribute-reader.d.ts.map +1 -0
  42. package/dist/parse/_attribute-reader.js +382 -0
  43. package/dist/parse/_attribute-reader.js.map +1 -0
  44. package/dist/parse/_context.d.ts +35 -0
  45. package/dist/parse/_context.d.ts.map +1 -0
  46. package/dist/parse/_context.js +39 -0
  47. package/dist/parse/_context.js.map +1 -0
  48. package/dist/parse/_xs-temporal.d.ts +22 -0
  49. package/dist/parse/_xs-temporal.d.ts.map +1 -0
  50. package/dist/parse/_xs-temporal.js +98 -0
  51. package/dist/parse/_xs-temporal.js.map +1 -0
  52. package/dist/parse/parse-dash-mpd.d.ts +67 -0
  53. package/dist/parse/parse-dash-mpd.d.ts.map +1 -0
  54. package/dist/parse/parse-dash-mpd.js +928 -0
  55. package/dist/parse/parse-dash-mpd.js.map +1 -0
  56. package/dist/resolve/_base-url.d.ts +41 -0
  57. package/dist/resolve/_base-url.d.ts.map +1 -0
  58. package/dist/resolve/_base-url.js +69 -0
  59. package/dist/resolve/_base-url.js.map +1 -0
  60. package/dist/resolve/_essential-properties.d.ts +38 -0
  61. package/dist/resolve/_essential-properties.d.ts.map +1 -0
  62. package/dist/resolve/_essential-properties.js +106 -0
  63. package/dist/resolve/_essential-properties.js.map +1 -0
  64. package/dist/resolve/_inherit.d.ts +43 -0
  65. package/dist/resolve/_inherit.d.ts.map +1 -0
  66. package/dist/resolve/_inherit.js +105 -0
  67. package/dist/resolve/_inherit.js.map +1 -0
  68. package/dist/resolve/_segment-runs.d.ts +81 -0
  69. package/dist/resolve/_segment-runs.d.ts.map +1 -0
  70. package/dist/resolve/_segment-runs.js +126 -0
  71. package/dist/resolve/_segment-runs.js.map +1 -0
  72. package/dist/resolve/dash-resolve-diagnostic.d.ts +34 -0
  73. package/dist/resolve/dash-resolve-diagnostic.d.ts.map +1 -0
  74. package/dist/resolve/dash-resolve-diagnostic.js +2 -0
  75. package/dist/resolve/dash-resolve-diagnostic.js.map +1 -0
  76. package/dist/resolve/resolve-dash-representations.d.ts +130 -0
  77. package/dist/resolve/resolve-dash-representations.d.ts.map +1 -0
  78. package/dist/resolve/resolve-dash-representations.js +203 -0
  79. package/dist/resolve/resolve-dash-representations.js.map +1 -0
  80. package/dist/resolve/resolve-dash-segments.d.ts +169 -0
  81. package/dist/resolve/resolve-dash-segments.d.ts.map +1 -0
  82. package/dist/resolve/resolve-dash-segments.js +665 -0
  83. package/dist/resolve/resolve-dash-segments.js.map +1 -0
  84. package/dist/timing/_exact-period-timings.d.ts +28 -0
  85. package/dist/timing/_exact-period-timings.d.ts.map +1 -0
  86. package/dist/timing/_exact-period-timings.js +142 -0
  87. package/dist/timing/_exact-period-timings.js.map +1 -0
  88. package/dist/timing/dash-period-timings.d.ts +29 -0
  89. package/dist/timing/dash-period-timings.d.ts.map +1 -0
  90. package/dist/timing/dash-period-timings.js +23 -0
  91. package/dist/timing/dash-period-timings.js.map +1 -0
  92. package/package.json +63 -3
@@ -0,0 +1,169 @@
1
+ import { type WorkBudget } from "@ac-kit/core";
2
+ import type { DashBaseUrl, DashByteRange } from "../model/dash-common.js";
3
+ import type { DashMpd } from "../model/dash-mpd.js";
4
+ import type { DashRepresentationPath, DashResolveDiagnostic } from "./dash-resolve-diagnostic.js";
5
+ /** Options of {@link resolveDashSegments}. */
6
+ export type DashResolveSegmentsOptions = {
7
+ /**
8
+ * The wall clock, which the caller owns: there is no hidden clock. Required
9
+ * for a dynamic MPD, ignored for a static one.
10
+ */
11
+ readonly now?: Temporal.Instant;
12
+ /**
13
+ * Keep the segments ending after `from` and starting before `to`, seconds on
14
+ * the MPD timeline, within the Period either way. Unbounded by default; a
15
+ * span with `from >= to` selects nothing. Overlap is compared exactly against
16
+ * the supplied numbers, even at subnanosecond bounds.
17
+ */
18
+ readonly from?: number;
19
+ readonly to?: number;
20
+ /**
21
+ * Most segments the result may hold,
22
+ * {@link DEFAULT_DASH_LIMITS}`.maxSegments` (100 000) by default.
23
+ */
24
+ readonly maxSegments?: number;
25
+ /** Picks one of a level's alternative BaseURLs; the first by default. */
26
+ readonly chooseBaseUrl?: (candidates: readonly DashBaseUrl[]) => DashBaseUrl;
27
+ /**
28
+ * The work planning may do, including each selected SegmentURL, timeline
29
+ * entry, run and BaseURL level: a caller's `WorkBudget`, shared across calls
30
+ * and whose exhaustion error propagates as is, or a limit for a private one,
31
+ * {@link DEFAULT_DASH_WORK_BUDGET} by default, whose exhaustion is a
32
+ * {@link DashLimitError} `budget`. Iterating `segments` is bounded by
33
+ * `maxSegments` instead.
34
+ */
35
+ readonly budget?: WorkBudget | number;
36
+ };
37
+ /** An absolute URL and the inclusive byte range to request from it, if any. */
38
+ export type DashResource = {
39
+ /**
40
+ * Absolute URL; `null` when it does not resolve. Which schemes and hosts may
41
+ * be fetched is the caller's policy.
42
+ */
43
+ readonly href: string | null;
44
+ readonly range: DashByteRange | null;
45
+ };
46
+ /** One media segment. */
47
+ export type DashResolvedSegment = DashResource & {
48
+ /**
49
+ * `$Number$`: a `number`, since real start numbers are about 10⁹; a segment
50
+ * past 2^53−1 is refused.
51
+ */
52
+ readonly number: number;
53
+ /**
54
+ * `$Time$`, in `timescale` units: the segment's start on the sample timeline,
55
+ * as the DASH-IF timing model defines it — `S@t` for a SegmentTimeline;
56
+ * `@presentationTimeOffset + (number − startNumber) ×
57
+ *
58
+ * @duration` for simple addressing, which `@eptDelta` does not shift. A
59
+ * `bigint`, unlike HLS's numbers: an epoch-based time at a 10 MHz timescale
60
+ * passes 2^53.
61
+ */
62
+ readonly time: bigint;
63
+ /** In `timescale` units. */
64
+ readonly duration: bigint;
65
+ readonly timescale: number;
66
+ /**
67
+ * Seconds on the MPD timeline: Period start plus the segment's offset from it
68
+ * — `(time − PTO) / timescale` on a timeline, `(@eptDelta + k ×
69
+ *
70
+ * @duration) / timescale` for simple addressing.
71
+ */
72
+ readonly start: number;
73
+ readonly end: number;
74
+ /**
75
+ * The segment's index: SegmentURL `@index`/`@indexRange`, a SegmentTemplate
76
+ * `@index` with `$Number$` or `$Time$`, or the segment information's
77
+ * `@indexRange` on the media resource; `null` for none.
78
+ */
79
+ readonly index: DashResource | null;
80
+ /**
81
+ * Why `href` (or `index.href`) is `null` although the base resolved: the
82
+ * substituted URL does not resolve. A `null` `href` with no diagnostic means
83
+ * the base itself did not resolve; see the plan's `warnings`.
84
+ */
85
+ readonly diagnostic: DashResolveDiagnostic | null;
86
+ /**
87
+ * When the segment becomes available (dynamic MPD): availability start time
88
+ * plus Period start plus segment end, minus `availabilityTimeOffset`; `null`
89
+ * for a static MPD or an infinite offset.
90
+ */
91
+ readonly availabilityStart: Temporal.Instant | null;
92
+ /**
93
+ * When it stops being available: its availability start, without the offset,
94
+ * plus `timeShiftBufferDepth` plus its duration; `null` for a static MPD or
95
+ * no time-shift buffer depth.
96
+ */
97
+ readonly availabilityEnd: Temporal.Instant | null;
98
+ };
99
+ /** The selected segments, lazy and re-iterable, in presentation order. */
100
+ export type DashSegmentSequence = Iterable<DashResolvedSegment> & {
101
+ /** Known before iterating; at most `maxSegments`. */
102
+ readonly count: number;
103
+ };
104
+ /** What {@link resolveDashSegments} answers for one Representation. */
105
+ export type DashResolvedSegments = {
106
+ /**
107
+ * `base`: one segment covering the whole resource (SegmentBase, or a BaseURL
108
+ * alone).
109
+ */
110
+ readonly addressing: "base" | "list" | "template";
111
+ /** Whether a SegmentTimeline drives the segments. */
112
+ readonly timeline: boolean;
113
+ readonly initialization: DashResource | null;
114
+ /**
115
+ * The index of the whole Representation: RepresentationIndex,
116
+ * SegmentBase@indexRange, or a SegmentTemplate `@index` with neither
117
+ * `$Number$` nor `$Time$`. Per-segment indexes are on each segment.
118
+ */
119
+ readonly index: DashResource | null;
120
+ readonly segments: DashSegmentSequence;
121
+ readonly warnings: readonly DashResolveDiagnostic[];
122
+ };
123
+ /**
124
+ * Lists the segments of one Representation against `mpdUrl`, the URL the MPD
125
+ * was fetched from after redirects. Pure: no I/O, no clock.
126
+ *
127
+ * - Segment information is inherited attribute by attribute Period →
128
+ * AdaptationSet → Representation (§5.3.9.1), SegmentURLs from the nearest
129
+ * SegmentList that has some; BaseURLs are resolved level by level with the
130
+ * WHATWG `URL`, an absolute one resetting the chain; templates are
131
+ * substituted (§5.3.9.4.4) before resolution.
132
+ * - Simple addressing (`@duration`) places segment `k` at `@eptDelta + k ×
133
+ *
134
+ * @throws {RangeError} When `path` is out of range or names a `resolve-to-zero`
135
+ * element, `from`/`to` is `NaN` or too large to scale, or the MPD is dynamic
136
+ * and `now` is missing.
137
+ * @throws {TypeError} When `mpdUrl` is not an absolute URL.
138
+ * @throws {DashResolveError} When the segment description cannot be listed; see
139
+ * {@link DashResolveErrorCode}.
140
+ * @throws {DashLimitError} When more than `maxSegments` segments are selected,
141
+ * or a private `budget` runs out.
142
+ * @throws {UnsupportedError} For an unresolved remote Period, AdaptationSet or
143
+ * SegmentList, `S@k` above 1, `$SubNumber$`, or a BaseURL with `@byteRange`.
144
+ * @throws Whatever a caller's `budget` throws once spent.
145
+ * @duration` from the Period start, up to the segment that reaches the
146
+ * Period end or `@endNumber` (DASH-IF timing model §18.4).
147
+ * - A negative `S@r` repeats up to the next `S@t`, which must be written; on
148
+ * the last `S`, up to the Period end, `@endNumber`, the SegmentURL count or,
149
+ * live, the last segment available at `now`, whichever comes first.
150
+ * - A dynamic MPD keeps the segments available at `now` (DASH-IF IOP 4.3
151
+ * §4.3.2.2.7): from their availability start — `availabilityStartTime` +
152
+ * Period start + segment end − `availabilityTimeOffset`, the offsets of the
153
+ * segment information and of every chosen BaseURL summed, `INF` making every
154
+ * announced segment available early — to their availability end, that time
155
+ * without the offset plus `timeShiftBufferDepth` (the segment
156
+ * information's, a BaseURL's, else the MPD's; unbounded when absent) plus
157
+ * their duration. Nothing is available past `availabilityEndTime`. A
158
+ * SegmentList's timeline is checked against all its SegmentURLs before the
159
+ * window applies.
160
+ * - Segments outside the Period are never listed.
161
+ *
162
+ * Setup costs O(P + S + L) for P Periods, S `<S>` entries and L selected
163
+ * SegmentURLs, independent of timeline repeat counts — `r =
164
+ * 2^62` costs what `r = 0` does, as counts and window bounds come from bigint
165
+ * division. Runs are selected as they are computed, using memory
166
+ * O(selected runs). Each segment then costs O(URL length) when iterated.
167
+ */
168
+ export declare function resolveDashSegments(mpd: DashMpd, mpdUrl: string | URL, path: DashRepresentationPath, options?: DashResolveSegmentsOptions): DashResolvedSegments;
169
+ //# sourceMappingURL=resolve-dash-segments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-dash-segments.d.ts","sourceRoot":"","sources":["../../src/resolve/resolve-dash-segments.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,KAAK,UAAU,EAEf,MAAM,cAAc,CAAC;AAYtB,OAAO,KAAK,EACX,WAAW,EACX,aAAa,EAEb,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACX,OAAO,EAGP,MAAM,sBAAsB,CAAC;AAyB9B,OAAO,KAAK,EACX,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,8BAA8B,CAAC;AAEtC,8CAA8C;AAC9C,MAAM,MAAM,0BAA0B,GAAG;IACxC;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,WAAW,EAAE,KAAK,WAAW,CAAC;IAC7E;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CACtC,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,aAAa,GA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