@ac-kit/format-dash 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +78 -0
- package/LICENSE +28 -0
- package/README.md +180 -2
- package/dist/_template.d.ts +34 -0
- package/dist/_template.d.ts.map +1 -0
- package/dist/_template.js +90 -0
- package/dist/_template.js.map +1 -0
- package/dist/_xlink.d.ts +9 -0
- package/dist/_xlink.d.ts.map +1 -0
- package/dist/_xlink.js +14 -0
- package/dist/_xlink.js.map +1 -0
- package/dist/dash-namespaces.d.ts +27 -0
- package/dist/dash-namespaces.d.ts.map +1 -0
- package/dist/dash-namespaces.js +30 -0
- package/dist/dash-namespaces.js.map +1 -0
- package/dist/errors.d.ts +127 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/limits.d.ts +51 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +39 -0
- package/dist/limits.js.map +1 -0
- package/dist/model/dash-common.d.ts +124 -0
- package/dist/model/dash-common.d.ts.map +1 -0
- package/dist/model/dash-common.js +2 -0
- package/dist/model/dash-common.js.map +1 -0
- package/dist/model/dash-mpd.d.ts +111 -0
- package/dist/model/dash-mpd.d.ts.map +1 -0
- package/dist/model/dash-mpd.js +2 -0
- package/dist/model/dash-mpd.js.map +1 -0
- package/dist/model/dash-segment-information.d.ts +90 -0
- package/dist/model/dash-segment-information.d.ts.map +1 -0
- package/dist/model/dash-segment-information.js +2 -0
- package/dist/model/dash-segment-information.js.map +1 -0
- package/dist/parse/_attribute-reader.d.ts +94 -0
- package/dist/parse/_attribute-reader.d.ts.map +1 -0
- package/dist/parse/_attribute-reader.js +382 -0
- package/dist/parse/_attribute-reader.js.map +1 -0
- package/dist/parse/_context.d.ts +35 -0
- package/dist/parse/_context.d.ts.map +1 -0
- package/dist/parse/_context.js +39 -0
- package/dist/parse/_context.js.map +1 -0
- package/dist/parse/_xs-temporal.d.ts +22 -0
- package/dist/parse/_xs-temporal.d.ts.map +1 -0
- package/dist/parse/_xs-temporal.js +98 -0
- package/dist/parse/_xs-temporal.js.map +1 -0
- package/dist/parse/parse-dash-mpd.d.ts +67 -0
- package/dist/parse/parse-dash-mpd.d.ts.map +1 -0
- package/dist/parse/parse-dash-mpd.js +928 -0
- package/dist/parse/parse-dash-mpd.js.map +1 -0
- package/dist/resolve/_base-url.d.ts +41 -0
- package/dist/resolve/_base-url.d.ts.map +1 -0
- package/dist/resolve/_base-url.js +69 -0
- package/dist/resolve/_base-url.js.map +1 -0
- package/dist/resolve/_essential-properties.d.ts +38 -0
- package/dist/resolve/_essential-properties.d.ts.map +1 -0
- package/dist/resolve/_essential-properties.js +106 -0
- package/dist/resolve/_essential-properties.js.map +1 -0
- package/dist/resolve/_inherit.d.ts +43 -0
- package/dist/resolve/_inherit.d.ts.map +1 -0
- package/dist/resolve/_inherit.js +105 -0
- package/dist/resolve/_inherit.js.map +1 -0
- package/dist/resolve/_segment-runs.d.ts +81 -0
- package/dist/resolve/_segment-runs.d.ts.map +1 -0
- package/dist/resolve/_segment-runs.js +126 -0
- package/dist/resolve/_segment-runs.js.map +1 -0
- package/dist/resolve/dash-resolve-diagnostic.d.ts +34 -0
- package/dist/resolve/dash-resolve-diagnostic.d.ts.map +1 -0
- package/dist/resolve/dash-resolve-diagnostic.js +2 -0
- package/dist/resolve/dash-resolve-diagnostic.js.map +1 -0
- package/dist/resolve/resolve-dash-representations.d.ts +130 -0
- package/dist/resolve/resolve-dash-representations.d.ts.map +1 -0
- package/dist/resolve/resolve-dash-representations.js +203 -0
- package/dist/resolve/resolve-dash-representations.js.map +1 -0
- package/dist/resolve/resolve-dash-segments.d.ts +169 -0
- package/dist/resolve/resolve-dash-segments.d.ts.map +1 -0
- package/dist/resolve/resolve-dash-segments.js +665 -0
- package/dist/resolve/resolve-dash-segments.js.map +1 -0
- package/dist/timing/_exact-period-timings.d.ts +28 -0
- package/dist/timing/_exact-period-timings.d.ts.map +1 -0
- package/dist/timing/_exact-period-timings.js +142 -0
- package/dist/timing/_exact-period-timings.js.map +1 -0
- package/dist/timing/dash-period-timings.d.ts +29 -0
- package/dist/timing/dash-period-timings.d.ts.map +1 -0
- package/dist/timing/dash-period-timings.js +23 -0
- package/dist/timing/dash-period-timings.js.map +1 -0
- package/package.json +63 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @ac-kit/format-dash
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5152230: New package: MPEG-DASH manifests (ISO/IEC 23009-1, 5th edition schema).
|
|
8
|
+
|
|
9
|
+
- `parseDashMpd(source, options)` reads an MPD — string, bytes or a parsed
|
|
10
|
+
`@ac-kit/format-xml` document — into an as-written typed model (MPD, Period,
|
|
11
|
+
AdaptationSet, Representation, descriptors, ContentProtection at every
|
|
12
|
+
scope, BaseURL, SegmentBase, SegmentList, SegmentTemplate, SegmentTimeline),
|
|
13
|
+
keeping everything else in `otherAttributes`/`otherElements`. Elements match
|
|
14
|
+
by namespace (no namespace only for unprefixed names); an MPD in no
|
|
15
|
+
namespace or the legacy upper-case one is read with an advisory. Strict by
|
|
16
|
+
default (`DashSyntaxError` with a `code` and `position`; `MPD@profiles`,
|
|
17
|
+
`MPD@minBufferTime` and a Period required; XML Schema integer ranges
|
|
18
|
+
enforced); `mode: "lenient"` turns each unreadable typed attribute into
|
|
19
|
+
`null`, keeps it in `invalidAttributes` and reports it in `warnings`.
|
|
20
|
+
Durations and date-times are `Temporal` values after an XSD lexical check.
|
|
21
|
+
Limits `maxLength` (4 Mi), `maxTimelineEntries` (100 000), `maxWarnings`,
|
|
22
|
+
and a `budget` (a shareable `WorkBudget`, or a private limit of 500 000
|
|
23
|
+
units) covering XML parsing, namespace resolution and MPD construction.
|
|
24
|
+
A private budget raises `DashLimitError`; `tryParseDashMpd` answers `null`
|
|
25
|
+
for parse syntax errors but rethrows caller budget errors by identity, even
|
|
26
|
+
if the budget throws a syntax error.
|
|
27
|
+
- `resolveDashRepresentations(mpd, mpdUrl, options)` lists every
|
|
28
|
+
Representation with AdaptationSet values applied and its BaseURL `href`;
|
|
29
|
+
descriptors are given by scope, shared, never copied; `isProtected`,
|
|
30
|
+
`referencedContentProtections` and `ignoredBecause` (unknown
|
|
31
|
+
EssentialProperty at any scope, unreadable `@id`/`@bandwidth`) are flags,
|
|
32
|
+
never acted on. Remote (xlink) Periods and AdaptationSets list nothing;
|
|
33
|
+
`resolve-to-zero` ones are absent.
|
|
34
|
+
- `resolveDashSegments(mpd, mpdUrl, path, options)` lists one
|
|
35
|
+
Representation's initialization, index and media segments for every
|
|
36
|
+
addressing mode, following the DASH-IF timing model (`@presentationTimeOffset`
|
|
37
|
+
and `@eptDelta` in simple addressing, negative `S@r` bounded by the next `S@t`,
|
|
38
|
+
the Period end, `@endNumber`, the SegmentURL count or `now`), with exact
|
|
39
|
+
bigint `time`/`duration`, per-segment `index` and `diagnostic`, a lazy
|
|
40
|
+
re-iterable `segments` with a known `count`, `from`/`to` within the Period,
|
|
41
|
+
`maxSegments`, `budget`, and live (dynamic) availability windows from a
|
|
42
|
+
caller-supplied `now`. Span comparisons handle subnanosecond bounds exactly,
|
|
43
|
+
and explicit absolute resources resolve even after an invalid BaseURL.
|
|
44
|
+
Unreadable ranges on selected SegmentURLs never become whole-resource
|
|
45
|
+
requests. Errors are `DashResolveError`s with a `code`
|
|
46
|
+
(`unreadable-value` when a lenient parse lost a value the plan needs,
|
|
47
|
+
`invalid-availability` instead of a native `RangeError`); unresolved xlink,
|
|
48
|
+
`$SubNumber$`, `S@k` and `BaseURL@byteRange` are `UnsupportedError`s.
|
|
49
|
+
- `dashPeriodTimings(mpd)` gives each Period's start and duration.
|
|
50
|
+
|
|
51
|
+
ContentProtection, PSSH and license URLs are plain text only. URL policy
|
|
52
|
+
(which schemes and hosts to fetch) is the caller's. Requires a `Temporal`
|
|
53
|
+
global (Node 26, or a polyfill such as `temporal-polyfill`).
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [2a0fe74]
|
|
58
|
+
- Updated dependencies [5152230]
|
|
59
|
+
- Updated dependencies [2a0fe74]
|
|
60
|
+
- Updated dependencies [5152230]
|
|
61
|
+
- Updated dependencies [5152230]
|
|
62
|
+
- Updated dependencies [2a0fe74]
|
|
63
|
+
- Updated dependencies [2a0fe74]
|
|
64
|
+
- Updated dependencies [5152230]
|
|
65
|
+
- Updated dependencies [5152230]
|
|
66
|
+
- Updated dependencies [5152230]
|
|
67
|
+
- Updated dependencies [5152230]
|
|
68
|
+
- Updated dependencies [5152230]
|
|
69
|
+
- Updated dependencies [5152230]
|
|
70
|
+
- Updated dependencies [5152230]
|
|
71
|
+
- Updated dependencies [5152230]
|
|
72
|
+
- Updated dependencies [5152230]
|
|
73
|
+
- Updated dependencies [5152230]
|
|
74
|
+
- Updated dependencies [5152230]
|
|
75
|
+
- Updated dependencies [5152230]
|
|
76
|
+
- @ac-kit/core@0.10.0
|
|
77
|
+
- @ac-kit/format-xml@0.2.0
|
|
78
|
+
- @ac-kit/model-markup@0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,181 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ac-kit/format-dash
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MPEG-DASH manifests (ISO/IEC 23009-1, 5th edition schema): parse an MPD and
|
|
4
|
+
list its Representations and their segments.
|
|
5
|
+
|
|
6
|
+
An MPD describes a presentation as Periods of AdaptationSets of
|
|
7
|
+
Representations — one encoding each — and says where each Representation's
|
|
8
|
+
segments are with one of four addressing modes: a SegmentTemplate with
|
|
9
|
+
`@duration`, a SegmentTemplate with a SegmentTimeline, a SegmentList, or a
|
|
10
|
+
single file (SegmentBase, or a BaseURL alone). This package reads the whole
|
|
11
|
+
document into a typed model, values as written, then resolves what a
|
|
12
|
+
downloader needs: every Representation as a flat table, and each one's
|
|
13
|
+
initialization segment, index and media segments as absolute URLs with byte
|
|
14
|
+
ranges — for static and live (dynamic) MPDs alike. It performs no I/O and has
|
|
15
|
+
no clock: the caller fetches, and passes the time.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
parseDashMpd,
|
|
20
|
+
resolveDashRepresentations,
|
|
21
|
+
resolveDashSegments,
|
|
22
|
+
} from "@ac-kit/format-dash";
|
|
23
|
+
|
|
24
|
+
const url = "https://cdn.example.test/show/manifest.mpd";
|
|
25
|
+
const { mpd, warnings } = parseDashMpd(
|
|
26
|
+
`<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" type="static" mediaPresentationDuration="PT8S"
|
|
27
|
+
profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S">
|
|
28
|
+
<Period>
|
|
29
|
+
<AdaptationSet mimeType="video/mp4" codecs="avc1.64001f">
|
|
30
|
+
<SegmentTemplate timescale="1000" duration="4000"
|
|
31
|
+
media="$RepresentationID$/$Number%05d$.m4s" initialization="$RepresentationID$/init.mp4"/>
|
|
32
|
+
<Representation id="720p" bandwidth="2000000" width="1280" height="720"/>
|
|
33
|
+
</AdaptationSet>
|
|
34
|
+
</Period>
|
|
35
|
+
</MPD>`,
|
|
36
|
+
{ mode: "lenient" },
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const { representations } = resolveDashRepresentations(mpd, url);
|
|
40
|
+
const video = representations[0]!;
|
|
41
|
+
video.contentType; // "video"
|
|
42
|
+
video.isProtected; // false
|
|
43
|
+
|
|
44
|
+
const plan = resolveDashSegments(mpd, url, video.path);
|
|
45
|
+
plan.initialization?.href; // "https://cdn.example.test/show/720p/init.mp4"
|
|
46
|
+
plan.segments.count; // 2
|
|
47
|
+
for (const segment of plan.segments) {
|
|
48
|
+
segment.href; // "https://cdn.example.test/show/720p/00001.m4s", then 00002
|
|
49
|
+
}
|
|
50
|
+
warnings.length; // 0
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Requires a `Temporal` global.** Durations are `Temporal.Duration`s and
|
|
54
|
+
date-times `Temporal.Instant`s, and `now` is a `Temporal.Instant`. Node 26
|
|
55
|
+
ships one; elsewhere, load a polyfill such as
|
|
56
|
+
[`temporal-polyfill`](https://www.npmjs.com/package/temporal-polyfill) first.
|
|
57
|
+
|
|
58
|
+
## Strict and lenient
|
|
59
|
+
|
|
60
|
+
`parseDashMpd` takes a string, bytes (decoded as XML says) or an already
|
|
61
|
+
parsed `@ac-kit/format-xml` document. It is strict by default: the first
|
|
62
|
+
violation throws a `DashSyntaxError` with a stable `code` and the source
|
|
63
|
+
`position`. `mode: "lenient"` recovers from each instead and records it in
|
|
64
|
+
`warnings`: a typed attribute that does not read as its type — a number out
|
|
65
|
+
of its XML Schema range, a malformed duration or date-time, a template with an
|
|
66
|
+
unknown identifier — becomes `null`, and the attribute moves to
|
|
67
|
+
`invalidAttributes`. Strict mode also requires `MPD@profiles`,
|
|
68
|
+
`MPD@minBufferTime` and a Period. A document that is not well-formed XML
|
|
69
|
+
(`XmlSyntaxError`), or whose root is not an MPD, fails in both modes.
|
|
70
|
+
|
|
71
|
+
Elements match by namespace URI, whatever their prefix; no namespace matches
|
|
72
|
+
only an unprefixed name, so a lenient parse never reads an unbound `p:Period`
|
|
73
|
+
as a Period. An MPD in no namespace
|
|
74
|
+
or in the first edition's `urn:mpeg:DASH:schema:MPD:2011` is read like one in
|
|
75
|
+
`urn:mpeg:dash:schema:mpd:2011`, with an advisory. Lexical forms follow XML
|
|
76
|
+
Schema: `xs:duration` without weeks, fractional hours or a negative sign, and
|
|
77
|
+
with no years or months, which have no fixed length; an `xs:dateTime` with no
|
|
78
|
+
zone is taken as UTC. Everything the model does not type is kept in
|
|
79
|
+
`otherAttributes` and `otherElements` — EventStream, ServiceDescription,
|
|
80
|
+
Preselection, SubRepresentation, vendor extensions.
|
|
81
|
+
|
|
82
|
+
## Segments
|
|
83
|
+
|
|
84
|
+
`resolveDashSegments(mpd, mpdUrl, path, options)` applies segment-information
|
|
85
|
+
inheritance attribute by attribute (Period → AdaptationSet → Representation),
|
|
86
|
+
resolves BaseURLs level by level against `mpdUrl` — the URL after redirects —
|
|
87
|
+
and substitutes `$RepresentationID$`, `$Number$`, `$Time$`, `$Bandwidth$` and
|
|
88
|
+
`$$`, with a `%0<width>d` width of at most 64; SegmentURLs come from the
|
|
89
|
+
nearest SegmentList that has some. Segment counts and window bounds
|
|
90
|
+
come from exact integer division, so `S@r="4611686018427387904"` costs what
|
|
91
|
+
`S@r="0"` does; `segments` is lazy, re-iterable, and knows its `count` before
|
|
92
|
+
iterating. `from`/`to` select the segments overlapping a span of seconds,
|
|
93
|
+
always within the Period; an empty or reversed span selects nothing. Bounds
|
|
94
|
+
are compared exactly against the supplied JavaScript numbers, without rounding
|
|
95
|
+
to whole nanoseconds. Each segment carries its own `index` — SegmentURL `@index`/`@indexRange`, a
|
|
96
|
+
per-segment SegmentTemplate `@index`, or the `@indexRange` of the segment
|
|
97
|
+
information — and a `diagnostic` when its URL does not resolve against a base.
|
|
98
|
+
Explicit absolute resource URLs still resolve if a malformed BaseURL breaks
|
|
99
|
+
its chain; the BaseURL diagnostic remains.
|
|
100
|
+
|
|
101
|
+
`number` is a `number` (a segment past 2^53−1 is refused), but `time` and
|
|
102
|
+
`duration` are `bigint`s in `timescale` units, unlike `@ac-kit/format-hls`'s
|
|
103
|
+
plain numbers: a `$Time$` counted from 1970 at a 10 MHz timescale is about
|
|
104
|
+
1.7×10¹⁶, past 2^53. Times follow the DASH-IF timing model: with `@duration`
|
|
105
|
+
("simple") addressing, segment `k` starts `@eptDelta + k × @duration` after the
|
|
106
|
+
Period start and its `$Time$` is `@presentationTimeOffset + k × @duration`;
|
|
107
|
+
with a SegmentTimeline, `$Time$` is `S@t` and the start `S@t −
|
|
108
|
+
@presentationTimeOffset`. A negative `S@r` repeats up to the next `S@t`, which
|
|
109
|
+
must be written, or on the last `S` up to the Period end, `@endNumber`, the
|
|
110
|
+
SegmentURL count or, live, the last available segment.
|
|
111
|
+
|
|
112
|
+
A description that cannot be listed throws a `DashResolveError` with a `code`:
|
|
113
|
+
a SegmentTemplate `@duration` or a single segment with no known Period end in
|
|
114
|
+
a static MPD, a negative `S@r` with nothing to stop it, a SegmentList whose
|
|
115
|
+
timeline and SegmentURLs disagree on the count, or a value a lenient parse
|
|
116
|
+
could not read (`unreadable-value`: the parse keeps such attributes in
|
|
117
|
+
`invalidAttributes` rather than let a default stand in for them). This includes
|
|
118
|
+
unreadable byte ranges on selected SegmentURLs; they never become whole-resource
|
|
119
|
+
requests. Only Period timing attributes needed to derive the selected Period's
|
|
120
|
+
timing are checked.
|
|
121
|
+
`$SubNumber$`, `S@k` and `BaseURL@byteRange` throw `UnsupportedError`, and so
|
|
122
|
+
does a remote (xlink) Period, AdaptationSet or SegmentList: its inline content
|
|
123
|
+
is a placeholder, never listed. `resolve-to-zero` makes an element absent.
|
|
124
|
+
|
|
125
|
+
## Live MPDs
|
|
126
|
+
|
|
127
|
+
For a dynamic MPD pass `now`; nothing reads a clock. The segments listed are
|
|
128
|
+
those available at `now`, as DASH-IF IOP 4.3 §4.3.2.2.7 defines it: a segment
|
|
129
|
+
becomes available at `availabilityStartTime` + Period start + its end −
|
|
130
|
+
`availabilityTimeOffset` (the segment information's and every chosen
|
|
131
|
+
BaseURL's, summed; `INF` makes every announced segment available), and stays
|
|
132
|
+
so for `timeShiftBufferDepth` plus its duration. `S@r="-1"` on the last entry
|
|
133
|
+
of an open Period repeats up to the last available segment. Each segment
|
|
134
|
+
carries its `availabilityStart` and `availabilityEnd`, so a caller can tell
|
|
135
|
+
when to reload. An early-available Period (no start yet) cannot be listed.
|
|
136
|
+
|
|
137
|
+
## Protection, unusable Representations and URLs
|
|
138
|
+
|
|
139
|
+
ContentProtection descriptors, `cenc:default_KID`, `cenc:pssh` and DASH-IF
|
|
140
|
+
`Laurl` license URLs are read as plain text and never used: nothing here
|
|
141
|
+
acquires a license, fetches a key or decrypts. `resolveDashRepresentations`
|
|
142
|
+
only flags: `isProtected` when a ContentProtection applies at any scope (MPD,
|
|
143
|
+
Period, AdaptationSet, Representation; `@ref` targets are listed in
|
|
144
|
+
`referencedContentProtections`), and
|
|
145
|
+
`ignoredBecause` for a Representation under an EssentialProperty whose scheme
|
|
146
|
+
the caller did not list in `understoodEssentialProperties`, at any scope (the
|
|
147
|
+
standard tells
|
|
148
|
+
a client to ignore those), or one a lenient parse left without `@id` or
|
|
149
|
+
`@bandwidth`. `skipIgnored: true` leaves the latter out. Descriptor lists are
|
|
150
|
+
given by scope and shared between Representations, never copied.
|
|
151
|
+
|
|
152
|
+
**URL policy belongs to the caller.** Every `href` is whatever the MPD's
|
|
153
|
+
BaseURLs and templates resolve to with the WHATWG `URL` parser, `file:`,
|
|
154
|
+
`data:` and private hosts included; check the scheme and host before fetching.
|
|
155
|
+
An `href` that does not resolve is `null`, with a diagnostic in `warnings`.
|
|
156
|
+
|
|
157
|
+
## Limits
|
|
158
|
+
|
|
159
|
+
Parsing is bounded by `maxLength` (4 Mi characters by default, bytes at three
|
|
160
|
+
times that),
|
|
161
|
+
`maxTimelineEntries` (100 000 `<S>` elements) and `maxWarnings`, on top of
|
|
162
|
+
`@ac-kit/format-xml`'s entity-expansion and nesting limits; listing by
|
|
163
|
+
`maxSegments` (100 000 per call). Every call also takes a `budget`: a
|
|
164
|
+
`WorkBudget` from `@ac-kit/core` shared across calls — one per page, say —
|
|
165
|
+
whose own error propagates, or a limit for a private one, 500 000 units by
|
|
166
|
+
default. Parsing uses one allowance for XML parsing, namespace resolution,
|
|
167
|
+
and MPD model construction. A dense MPD can exhaust the budget before it hits
|
|
168
|
+
`maxLength` or `maxTimelineEntries`. Exceeding a DASH limit or a private budget
|
|
169
|
+
throws `DashLimitError` in every mode —
|
|
170
|
+
for `maxSegments` it carries the exact `count`, so the caller can narrow
|
|
171
|
+
`from`/`to`. Only the significant digits of an integer reach `BigInt`, and an
|
|
172
|
+
`xs:unsignedInt` or `xs:unsignedLong` past its range is refused; recursion
|
|
173
|
+
follows the schema's fixed depth and sibling lists are appended one by one, so
|
|
174
|
+
hostile input cannot overflow the stack.
|
|
175
|
+
|
|
176
|
+
Not in scope: printing an MPD, resolving xlink, MPD patches, subsegments from
|
|
177
|
+
`sidx` boxes, and anything to do with DRM.
|
|
178
|
+
|
|
179
|
+
See the
|
|
180
|
+
[generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/format-dash/)
|
|
181
|
+
for the full reference.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A template identifier (§5.3.9.4.4, Table 16). */
|
|
2
|
+
export type TemplateIdentifier = "RepresentationID" | "Number" | "Bandwidth" | "Time" | "SubNumber";
|
|
3
|
+
/** A literal run, or an identifier with its `%0<width>d` width (0 for none). */
|
|
4
|
+
export type TemplatePart = string | {
|
|
5
|
+
readonly identifier: TemplateIdentifier;
|
|
6
|
+
readonly width: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Splits a template into literal runs and identifiers, `$$` becoming a `$`.
|
|
10
|
+
* Only `%0<width>d` is a format, as DASH-IF IOP 4.3 §4.3.2.2.8 restricts it,
|
|
11
|
+
* and `$RepresentationID$` takes none. O(n).
|
|
12
|
+
*
|
|
13
|
+
* @returns The parts, or a message saying why the template is invalid.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseTemplate(text: string): TemplatePart[] | string;
|
|
16
|
+
/** The values substituted into a template; `null` for one not available. */
|
|
17
|
+
export type TemplateValues = {
|
|
18
|
+
readonly representationId: string | null;
|
|
19
|
+
readonly bandwidth: number | null;
|
|
20
|
+
readonly number: number | null;
|
|
21
|
+
readonly time: bigint | null;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Substitutes `values` into parsed `parts`, padding a formatted value with
|
|
25
|
+
* zeros to its width. O(output).
|
|
26
|
+
*
|
|
27
|
+
* @returns The text, or the identifier with no value.
|
|
28
|
+
*/
|
|
29
|
+
export declare function substituteTemplate(parts: readonly TemplatePart[], values: TemplateValues): string | {
|
|
30
|
+
readonly missing: TemplateIdentifier;
|
|
31
|
+
};
|
|
32
|
+
/** Whether `parts` use `identifier`. */
|
|
33
|
+
export declare function templateUses(parts: readonly TemplatePart[], identifier: TemplateIdentifier): boolean;
|
|
34
|
+
//# sourceMappingURL=_template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_template.d.ts","sourceRoot":"","sources":["../src/_template.ts"],"names":[],"mappings":"AAEA,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAC3B,kBAAkB,GAClB,QAAQ,GACR,WAAW,GACX,MAAM,GACN,WAAW,CAAC;AAEf,gFAAgF;AAChF,MAAM,MAAM,YAAY,GACrB,MAAM,GACN;IAAE,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAKvE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,GAAG,MAAM,CAwCnE;AAED,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,MAAM,EAAE,cAAc,GACpB,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAcnD;AAED,wCAAwC;AACxC,wBAAgB,YAAY,CAC3B,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAIT"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { DASH_MAX_TEMPLATE_WIDTH } from "./limits.js";
|
|
2
|
+
const IDENTIFIER_ = /\$(RepresentationID|Number|Bandwidth|Time|SubNumber)(?:%0(\d{1,3})d)?\$/y;
|
|
3
|
+
/**
|
|
4
|
+
* Splits a template into literal runs and identifiers, `$$` becoming a `$`.
|
|
5
|
+
* Only `%0<width>d` is a format, as DASH-IF IOP 4.3 §4.3.2.2.8 restricts it,
|
|
6
|
+
* and `$RepresentationID$` takes none. O(n).
|
|
7
|
+
*
|
|
8
|
+
* @returns The parts, or a message saying why the template is invalid.
|
|
9
|
+
*/
|
|
10
|
+
export function parseTemplate(text) {
|
|
11
|
+
const parts = [];
|
|
12
|
+
let literal = "";
|
|
13
|
+
let cursor = 0;
|
|
14
|
+
while (cursor < text.length) {
|
|
15
|
+
const dollar = text.indexOf("$", cursor);
|
|
16
|
+
if (dollar === -1) {
|
|
17
|
+
literal += text.slice(cursor);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
literal += text.slice(cursor, dollar);
|
|
21
|
+
if (text[dollar + 1] === "$") {
|
|
22
|
+
literal += "$";
|
|
23
|
+
cursor = dollar + 2;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
IDENTIFIER_.lastIndex = dollar;
|
|
27
|
+
const match = IDENTIFIER_.exec(text);
|
|
28
|
+
if (match === null) {
|
|
29
|
+
return `"${text}" has an unknown identifier or format at ${dollar}`;
|
|
30
|
+
}
|
|
31
|
+
const identifier = match[1];
|
|
32
|
+
const width = match[2] === undefined ? 0 : Number(match[2]);
|
|
33
|
+
if (identifier === "RepresentationID" && match[2] !== undefined) {
|
|
34
|
+
return `"${text}" formats $RepresentationID$, which takes no format`;
|
|
35
|
+
}
|
|
36
|
+
if (width > DASH_MAX_TEMPLATE_WIDTH) {
|
|
37
|
+
return `"${text}" asks for a width of ${width}, more than ${DASH_MAX_TEMPLATE_WIDTH}`;
|
|
38
|
+
}
|
|
39
|
+
if (literal.length > 0) {
|
|
40
|
+
parts.push(literal);
|
|
41
|
+
literal = "";
|
|
42
|
+
}
|
|
43
|
+
parts.push({ identifier, width });
|
|
44
|
+
cursor = IDENTIFIER_.lastIndex;
|
|
45
|
+
}
|
|
46
|
+
if (literal.length > 0) {
|
|
47
|
+
parts.push(literal);
|
|
48
|
+
}
|
|
49
|
+
return parts;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Substitutes `values` into parsed `parts`, padding a formatted value with
|
|
53
|
+
* zeros to its width. O(output).
|
|
54
|
+
*
|
|
55
|
+
* @returns The text, or the identifier with no value.
|
|
56
|
+
*/
|
|
57
|
+
export function substituteTemplate(parts, values) {
|
|
58
|
+
let output = "";
|
|
59
|
+
for (const part of parts) {
|
|
60
|
+
if (typeof part === "string") {
|
|
61
|
+
output += part;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const value = valueOf_(part.identifier, values);
|
|
65
|
+
if (value === null) {
|
|
66
|
+
return { missing: part.identifier };
|
|
67
|
+
}
|
|
68
|
+
output += value.padStart(part.width, "0");
|
|
69
|
+
}
|
|
70
|
+
return output;
|
|
71
|
+
}
|
|
72
|
+
/** Whether `parts` use `identifier`. */
|
|
73
|
+
export function templateUses(parts, identifier) {
|
|
74
|
+
return parts.some((part) => typeof part !== "string" && part.identifier === identifier);
|
|
75
|
+
}
|
|
76
|
+
function valueOf_(identifier, values) {
|
|
77
|
+
switch (identifier) {
|
|
78
|
+
case "RepresentationID":
|
|
79
|
+
return values.representationId;
|
|
80
|
+
case "Number":
|
|
81
|
+
return values.number === null ? null : String(values.number);
|
|
82
|
+
case "Bandwidth":
|
|
83
|
+
return values.bandwidth === null ? null : String(values.bandwidth);
|
|
84
|
+
case "Time":
|
|
85
|
+
return values.time === null ? null : String(values.time);
|
|
86
|
+
case "SubNumber":
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=_template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_template.js","sourceRoot":"","sources":["../src/_template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAetD,MAAM,WAAW,GAChB,0EAA0E,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACzC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YACnB,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC9B,MAAM;QACP,CAAC;QACD,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC9B,OAAO,IAAI,GAAG,CAAC;YACf,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC;YACpB,SAAS;QACV,CAAC;QACD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;QAC/B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,IAAI,IAAI,4CAA4C,MAAM,EAAE,CAAC;QACrE,CAAC;QACD,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAuB,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,UAAU,KAAK,kBAAkB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACjE,OAAO,IAAI,IAAI,qDAAqD,CAAC;QACtE,CAAC;QACD,IAAI,KAAK,GAAG,uBAAuB,EAAE,CAAC;YACrC,OAAO,IAAI,IAAI,yBAAyB,KAAK,eAAe,uBAAuB,EAAE,CAAC;QACvF,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACpB,OAAO,GAAG,EAAE,CAAC;QACd,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAClC,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC;IAChC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAA8B,EAC9B,MAAsB;IAEtB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,IAAI,CAAC;YACf,SAAS;QACV,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,YAAY,CAC3B,KAA8B,EAC9B,UAA8B;IAE9B,OAAO,KAAK,CAAC,IAAI,CAChB,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,CACpE,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAChB,UAA8B,EAC9B,MAAsB;IAEtB,QAAQ,UAAU,EAAE,CAAC;QACpB,KAAK,kBAAkB;YACtB,OAAO,MAAM,CAAC,gBAAgB,CAAC;QAChC,KAAK,QAAQ;YACZ,OAAO,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9D,KAAK,WAAW;YACf,OAAO,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACpE,KAAK,MAAM;YACV,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1D,KAAK,WAAW;YACf,OAAO,IAAI,CAAC;IACd,CAAC;AACF,CAAC"}
|
package/dist/_xlink.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DashXlink } from "./model/dash-common.js";
|
|
2
|
+
/**
|
|
3
|
+
* How a possibly remote element reads before any xlink is resolved (§5.5):
|
|
4
|
+
* `local` without `xlink:href`, `absent` for `resolve-to-zero`, `remote`
|
|
5
|
+
* otherwise — its inline content is a placeholder the remote one replaces, so
|
|
6
|
+
* nothing is listed from it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function xlinkState(xlink: DashXlink | null): "local" | "absent" | "remote";
|
|
9
|
+
//# sourceMappingURL=_xlink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_xlink.d.ts","sourceRoot":"","sources":["../src/_xlink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,SAAS,GAAG,IAAI,GACrB,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAK/B"}
|
package/dist/_xlink.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DASH_XLINK_RESOLVE_TO_ZERO } from "./dash-namespaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* How a possibly remote element reads before any xlink is resolved (§5.5):
|
|
4
|
+
* `local` without `xlink:href`, `absent` for `resolve-to-zero`, `remote`
|
|
5
|
+
* otherwise — its inline content is a placeholder the remote one replaces, so
|
|
6
|
+
* nothing is listed from it.
|
|
7
|
+
*/
|
|
8
|
+
export function xlinkState(xlink) {
|
|
9
|
+
if (xlink === null) {
|
|
10
|
+
return "local";
|
|
11
|
+
}
|
|
12
|
+
return xlink.href === DASH_XLINK_RESOLVE_TO_ZERO ? "absent" : "remote";
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=_xlink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_xlink.js","sourceRoot":"","sources":["../src/_xlink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGlE;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACzB,KAAuB;IAEvB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,KAAK,0BAA0B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MPD namespace of ISO/IEC 23009-1, every edition since the first
|
|
3
|
+
* corrigendum.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DASH_MPD_NAMESPACE = "urn:mpeg:dash:schema:mpd:2011";
|
|
6
|
+
/**
|
|
7
|
+
* The MPD namespace as the first edition spelled it, before the corrigendum
|
|
8
|
+
* lowered its case. Still read, with an advisory, since older packagers wrote
|
|
9
|
+
* it.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DASH_MPD_LEGACY_NAMESPACE = "urn:mpeg:DASH:schema:MPD:2011";
|
|
12
|
+
/**
|
|
13
|
+
* The Common Encryption namespace (ISO/IEC 23001-7), of `cenc:default_KID` and
|
|
14
|
+
* `cenc:pssh`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DASH_CENC_NAMESPACE = "urn:mpeg:cenc:2013";
|
|
17
|
+
/**
|
|
18
|
+
* The namespaces DASH-IF content protection guidelines have put the `Laurl`
|
|
19
|
+
* element in, newest first.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DASH_IF_CONTENT_PROTECTION_NAMESPACES: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* The `xlink:href` that resolves a remote element to nothing (§5.5.3): the
|
|
24
|
+
* element is treated as absent.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DASH_XLINK_RESOLVE_TO_ZERO = "urn:mpeg:dash:resolve-to-zero:2013";
|
|
27
|
+
//# sourceMappingURL=dash-namespaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash-namespaces.d.ts","sourceRoot":"","sources":["../src/dash-namespaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,kCAAkC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,kCAAkC,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,qCAAqC,EAAE,SAAS,MAAM,EAGlE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MPD namespace of ISO/IEC 23009-1, every edition since the first
|
|
3
|
+
* corrigendum.
|
|
4
|
+
*/
|
|
5
|
+
export const DASH_MPD_NAMESPACE = "urn:mpeg:dash:schema:mpd:2011";
|
|
6
|
+
/**
|
|
7
|
+
* The MPD namespace as the first edition spelled it, before the corrigendum
|
|
8
|
+
* lowered its case. Still read, with an advisory, since older packagers wrote
|
|
9
|
+
* it.
|
|
10
|
+
*/
|
|
11
|
+
export const DASH_MPD_LEGACY_NAMESPACE = "urn:mpeg:DASH:schema:MPD:2011";
|
|
12
|
+
/**
|
|
13
|
+
* The Common Encryption namespace (ISO/IEC 23001-7), of `cenc:default_KID` and
|
|
14
|
+
* `cenc:pssh`.
|
|
15
|
+
*/
|
|
16
|
+
export const DASH_CENC_NAMESPACE = "urn:mpeg:cenc:2013";
|
|
17
|
+
/**
|
|
18
|
+
* The namespaces DASH-IF content protection guidelines have put the `Laurl`
|
|
19
|
+
* element in, newest first.
|
|
20
|
+
*/
|
|
21
|
+
export const DASH_IF_CONTENT_PROTECTION_NAMESPACES = [
|
|
22
|
+
"https://dashif.org/CPS",
|
|
23
|
+
"https://dashif.org/",
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* The `xlink:href` that resolves a remote element to nothing (§5.5.3): the
|
|
27
|
+
* element is treated as absent.
|
|
28
|
+
*/
|
|
29
|
+
export const DASH_XLINK_RESOLVE_TO_ZERO = "urn:mpeg:dash:resolve-to-zero:2013";
|
|
30
|
+
//# sourceMappingURL=dash-namespaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash-namespaces.js","sourceRoot":"","sources":["../src/dash-namespaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,+BAA+B,CAAC;AAEzE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAsB;IACvE,wBAAwB;IACxB,qBAAqB;CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,oCAAoC,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable identifiers of everything {@link parseDashMpd} can report.
|
|
3
|
+
*
|
|
4
|
+
* Every code but `nonstandard-namespace` is a violation of ISO/IEC 23009-1: a
|
|
5
|
+
* strict parse throws at the first one, a lenient parse recovers as the code
|
|
6
|
+
* says and records it. `nonstandard-namespace` is an advisory in both modes.
|
|
7
|
+
*
|
|
8
|
+
* - `not-an-mpd`: the root element is not an MPD; fails in both modes.
|
|
9
|
+
* - `nonstandard-namespace`: the MPD is in no namespace, or in
|
|
10
|
+
* {@link DASH_MPD_LEGACY_NAMESPACE}; read as if it were in
|
|
11
|
+
* {@link DASH_MPD_NAMESPACE}.
|
|
12
|
+
* - `namespace`: a Namespaces in XML violation `resolveNamespaces` recovered from
|
|
13
|
+
* in lenient mode (strict mode throws its `XmlNamespaceError`).
|
|
14
|
+
* - `missing-attribute`: a required attribute is absent — `MPD@profiles`,
|
|
15
|
+
* `MPD@minBufferTime`, `MPD@availabilityStartTime` of a dynamic MPD,
|
|
16
|
+
* `Representation@id`, `@bandwidth`, `S@d`, a descriptor's `@schemeIdUri`.
|
|
17
|
+
* Lenient: the field is `null` (`profiles` empty).
|
|
18
|
+
* - `missing-element`: the MPD has no Period. Lenient: `periods` is empty.
|
|
19
|
+
* - `invalid-attribute-value`, `unsafe-integer`, `invalid-duration`,
|
|
20
|
+
* `invalid-date-time`, `invalid-template`: a typed attribute does not read as
|
|
21
|
+
* its type — an `xs:unsignedInt` past 4 294 967 295, an `xs:unsignedLong`
|
|
22
|
+
* past 2^64−1, a number past 2^53−1 where the model holds a `number`, a
|
|
23
|
+
* duration with years, months, weeks or a negative sign, a template with an
|
|
24
|
+
* unknown identifier or a format other than `%0<width>d` (width at most 64).
|
|
25
|
+
* Lenient: the field is `null` and the attribute moves to
|
|
26
|
+
* `invalidAttributes`; an unreadable `MPD@type` makes `type` `null`.
|
|
27
|
+
* - `conflicting-segment-information`: one element holds more than one of
|
|
28
|
+
* SegmentBase, SegmentList and SegmentTemplate, or two of one, or two
|
|
29
|
+
* SegmentTimelines. Lenient: the first is kept, the rest stay in
|
|
30
|
+
* `otherElements`.
|
|
31
|
+
* - `duplicate-representation-id`: two Representations of one Period share an
|
|
32
|
+
* `@id`. Lenient: both are kept.
|
|
33
|
+
*/
|
|
34
|
+
export type DashDiagnosticCode = "not-an-mpd" | "nonstandard-namespace" | "namespace" | "missing-attribute" | "missing-element" | "invalid-attribute-value" | "unsafe-integer" | "invalid-duration" | "invalid-date-time" | "invalid-template" | "conflicting-segment-information" | "duplicate-representation-id";
|
|
35
|
+
/** One problem found while parsing, at a source offset. */
|
|
36
|
+
export type DashDiagnostic = {
|
|
37
|
+
readonly code: DashDiagnosticCode;
|
|
38
|
+
/** An advisory never fails a parse; a violation fails a strict one. */
|
|
39
|
+
readonly severity: "violation" | "advisory";
|
|
40
|
+
readonly message: string;
|
|
41
|
+
/**
|
|
42
|
+
* Source offset of the element or attribute at fault, or of its nearest
|
|
43
|
+
* ancestor with a span (nodes an XML entity expanded into have none);
|
|
44
|
+
* `undefined` for a tree built in code.
|
|
45
|
+
*/
|
|
46
|
+
readonly position: number | undefined;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* An MPD that XML accepts but ISO/IEC 23009-1 does not, in the way the active
|
|
50
|
+
* mode does not tolerate: any violation in strict mode, and in both modes a
|
|
51
|
+
* root that is not an MPD.
|
|
52
|
+
*/
|
|
53
|
+
export declare class DashSyntaxError extends SyntaxError {
|
|
54
|
+
readonly code: DashDiagnosticCode;
|
|
55
|
+
/** As {@link DashDiagnostic.position}. */
|
|
56
|
+
readonly position: number | undefined;
|
|
57
|
+
constructor(code: DashDiagnosticCode, message: string,
|
|
58
|
+
/** As {@link DashDiagnostic.position}. */
|
|
59
|
+
position: number | undefined);
|
|
60
|
+
}
|
|
61
|
+
/** Which of the {@link DashLimits} a {@link DashLimitError} reports. */
|
|
62
|
+
export type DashLimitName = "maxLength" | "maxTimelineEntries" | "maxSegments" | "budget";
|
|
63
|
+
/** Input past one of the {@link DashLimits}; thrown in every mode. */
|
|
64
|
+
export declare class DashLimitError extends RangeError {
|
|
65
|
+
readonly limit: DashLimitName;
|
|
66
|
+
/** The bound that was exceeded; for `budget`, the private budget's limit. */
|
|
67
|
+
readonly value: number;
|
|
68
|
+
/**
|
|
69
|
+
* How many there were, when known: for `maxSegments`, the exact number of
|
|
70
|
+
* segments the request selects, so a caller can narrow `from`/`to`.
|
|
71
|
+
*/
|
|
72
|
+
readonly count: bigint | null;
|
|
73
|
+
constructor(limit: DashLimitName,
|
|
74
|
+
/** The bound that was exceeded; for `budget`, the private budget's limit. */
|
|
75
|
+
value: number,
|
|
76
|
+
/**
|
|
77
|
+
* How many there were, when known: for `maxSegments`, the exact number of
|
|
78
|
+
* segments the request selects, so a caller can narrow `from`/`to`.
|
|
79
|
+
*/
|
|
80
|
+
count?: bigint | null, options?: ErrorOptions);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Why a Representation's segments cannot be listed, though the MPD parsed.
|
|
84
|
+
*
|
|
85
|
+
* - `unknown-period-start`: the Period has no `@start` and no earlier Period
|
|
86
|
+
* gives one — an early-available Period of a dynamic MPD.
|
|
87
|
+
* - `unknown-period-duration`: the segment count depends on the Period's end
|
|
88
|
+
* (SegmentTemplate or SegmentList `@duration`, a single SegmentList entry,
|
|
89
|
+
* SegmentBase or a BaseURL alone), and neither a following Period,
|
|
90
|
+
* `Period@duration`, `MPD@mediaPresentationDuration` nor (for `@duration`)
|
|
91
|
+
* `@endNumber` bounds it, nor, live, a finite availability.
|
|
92
|
+
* - `unbounded-repeat`: a negative `S@r` on the last `S` with no Period end, no
|
|
93
|
+
* `@endNumber`, no SegmentURL count and, in a dynamic MPD, an infinite
|
|
94
|
+
* `availabilityTimeOffset`.
|
|
95
|
+
* - `invalid-timeline`: an `S` with `@d="0"`, an `@t` before the previous
|
|
96
|
+
* segment's start, or a negative `@r` followed by an `S` without `@t`.
|
|
97
|
+
* - `invalid-timescale`: `@timescale="0"`.
|
|
98
|
+
* - `invalid-duration`: `@duration="0"`, or a duration of the model with years or
|
|
99
|
+
* months, which have no fixed length.
|
|
100
|
+
* - `segment-count-mismatch`: a SegmentList's SegmentTimeline describes a
|
|
101
|
+
* different number of segments than it has SegmentURLs.
|
|
102
|
+
* - `missing-segment-duration`: a SegmentList of several entries with neither
|
|
103
|
+
* SegmentTimeline nor `@duration`.
|
|
104
|
+
* - `missing-media`: a SegmentTemplate with no `@media`.
|
|
105
|
+
* - `invalid-template`: a template with an unknown identifier or format.
|
|
106
|
+
* - `missing-attribute`: a value a lenient parse left `null` is needed —
|
|
107
|
+
* `Representation@id` or `@bandwidth` for a template,
|
|
108
|
+
* `MPD@availabilityStartTime` of a dynamic MPD.
|
|
109
|
+
* - `unsafe-segment-number`: a segment number would pass 2^53−1.
|
|
110
|
+
* - `unreadable-value`: a value the listing depends on is among the
|
|
111
|
+
* `invalidAttributes` of a lenient parse — `MPD@type`, a timescale, a
|
|
112
|
+
* duration, `S@t`/`@d`/`@r`, an availability offset… — so a default would
|
|
113
|
+
* stand where the MPD meant something else.
|
|
114
|
+
* - `invalid-availability`: the availability window cannot be represented:
|
|
115
|
+
* `availabilityTimeOffset`s summing past a double, or availability instants
|
|
116
|
+
* outside `Temporal.Instant`'s range.
|
|
117
|
+
*/
|
|
118
|
+
export type DashResolveErrorCode = "unknown-period-start" | "unknown-period-duration" | "unbounded-repeat" | "invalid-timeline" | "invalid-timescale" | "invalid-duration" | "segment-count-mismatch" | "missing-segment-duration" | "missing-media" | "invalid-template" | "missing-attribute" | "unsafe-segment-number" | "unreadable-value" | "invalid-availability";
|
|
119
|
+
/**
|
|
120
|
+
* A Representation whose segments {@link resolveDashSegments} cannot list: the
|
|
121
|
+
* MPD parsed, but its segment description is incomplete or contradicts itself.
|
|
122
|
+
*/
|
|
123
|
+
export declare class DashResolveError extends Error {
|
|
124
|
+
readonly code: DashResolveErrorCode;
|
|
125
|
+
constructor(code: DashResolveErrorCode, message: string);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=errors.d.ts.map
|