@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.
- package/CHANGELOG.md +89 -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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { bigIntDivCeil, bigIntDivFloor, bigIntMax, bigIntMin, } from "@ac-kit/core";
|
|
2
|
+
import { DashResolveError } from "../errors.js";
|
|
3
|
+
/** Nanoseconds per second. */
|
|
4
|
+
export const GIGA_ = 1000000000n;
|
|
5
|
+
/**
|
|
6
|
+
* The indices `[first, last)` of the run's segments every bound keeps, found by
|
|
7
|
+
* division rather than by stepping, so a run of 2^62 segments costs what a run
|
|
8
|
+
* of one does. O(1).
|
|
9
|
+
*/
|
|
10
|
+
export function selectInRun(run, bounds) {
|
|
11
|
+
const scaledStart = run.relativeStart * GIGA_;
|
|
12
|
+
const scaledDuration = run.duration * GIGA_;
|
|
13
|
+
let first = 0n;
|
|
14
|
+
let last = run.count;
|
|
15
|
+
if (bounds.startBefore !== null) {
|
|
16
|
+
last = bigIntMin(last, bigIntDivCeil(bounds.startBefore - scaledStart, scaledDuration));
|
|
17
|
+
}
|
|
18
|
+
if (bounds.endAfter !== null) {
|
|
19
|
+
first = bigIntMax(first, bigIntDivFloor(bounds.endAfter - scaledStart, scaledDuration));
|
|
20
|
+
}
|
|
21
|
+
if (bounds.endAtMost !== null) {
|
|
22
|
+
last = bigIntMin(last, bigIntDivFloor(bounds.endAtMost - scaledStart, scaledDuration));
|
|
23
|
+
}
|
|
24
|
+
if (bounds.endPlusDurationAtLeast !== null) {
|
|
25
|
+
first = bigIntMax(first, bigIntDivCeil(bounds.endPlusDurationAtLeast - scaledStart, scaledDuration) - 2n);
|
|
26
|
+
}
|
|
27
|
+
if (bounds.maxNumber !== null) {
|
|
28
|
+
last = bigIntMin(last, bounds.maxNumber - run.firstNumber + 1n);
|
|
29
|
+
}
|
|
30
|
+
return last > first ? [first, last] : [first, first];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* How many segments of `duration` from `relativeStart` (number `firstNumber`,
|
|
34
|
+
* `listOffset` SegmentURLs already used) the smallest known terminal bound
|
|
35
|
+
* allows; `null` when none is known.
|
|
36
|
+
*/
|
|
37
|
+
export function terminalCount(relativeStart, duration, firstNumber, listOffset, terminal) {
|
|
38
|
+
const scaledStart = relativeStart * GIGA_;
|
|
39
|
+
const scaledDuration = duration * GIGA_;
|
|
40
|
+
let count = null;
|
|
41
|
+
const limit = (candidate) => {
|
|
42
|
+
const bounded = bigIntMax(0n, candidate);
|
|
43
|
+
count = count === null ? bounded : bigIntMin(count, bounded);
|
|
44
|
+
};
|
|
45
|
+
if (terminal.periodEnd !== null) {
|
|
46
|
+
limit(bigIntDivCeil(terminal.periodEnd - scaledStart, scaledDuration));
|
|
47
|
+
}
|
|
48
|
+
if (terminal.availability !== null) {
|
|
49
|
+
limit(bigIntDivFloor(terminal.availability - scaledStart, scaledDuration));
|
|
50
|
+
}
|
|
51
|
+
if (terminal.maxNumber !== null) {
|
|
52
|
+
limit(terminal.maxNumber - firstNumber + 1n);
|
|
53
|
+
}
|
|
54
|
+
if (terminal.maxCount !== null) {
|
|
55
|
+
limit(terminal.maxCount - listOffset);
|
|
56
|
+
}
|
|
57
|
+
return count;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The runs of a SegmentTimeline (§5.3.9.6), one per `<S>`, yielded as they are
|
|
61
|
+
* computed so a caller keeps only those it selects. `S@t` defaults to the end
|
|
62
|
+
* of the previous entry (0 for the first), `S@n` to the next number. A negative
|
|
63
|
+
* `S@r` repeats up to the next entry's `S@t`, which must then be written, or
|
|
64
|
+
* for the last entry up to the smallest {@link TerminalBounds}. O(1) per entry,
|
|
65
|
+
* whatever the repeat counts.
|
|
66
|
+
*
|
|
67
|
+
* @throws {DashResolveError} `invalid-timeline` for an entry with `@d="0"`, an
|
|
68
|
+
* `@t` before the previous segment's start, or a negative `@r` followed by an
|
|
69
|
+
* entry without `@t`; `unreadable-value` for an entry a lenient parse could
|
|
70
|
+
* not read; `unbounded-repeat` for a negative `@r` on the last entry with no
|
|
71
|
+
* terminal bound.
|
|
72
|
+
*/
|
|
73
|
+
export function* timelineRuns(entries, presentationTimeOffset, startNumber, terminal) {
|
|
74
|
+
let time = null;
|
|
75
|
+
let number = startNumber;
|
|
76
|
+
let previousStart = null;
|
|
77
|
+
let listOffset = 0n;
|
|
78
|
+
for (const [index, entry] of entries.entries()) {
|
|
79
|
+
const { d: duration, r: repeat } = entry;
|
|
80
|
+
if (duration === null ||
|
|
81
|
+
repeat === null ||
|
|
82
|
+
entry.invalidAttributes !== undefined) {
|
|
83
|
+
throw new DashResolveError("unreadable-value", `S ${index} has an attribute a lenient parse could not read`);
|
|
84
|
+
}
|
|
85
|
+
if (duration === 0n) {
|
|
86
|
+
throw new DashResolveError("invalid-timeline", `S ${index} has @d="0"`);
|
|
87
|
+
}
|
|
88
|
+
const start = entry.t ?? time ?? 0n;
|
|
89
|
+
if (previousStart !== null && start < previousStart) {
|
|
90
|
+
throw new DashResolveError("invalid-timeline", `S ${index} starts at ${start}, before the previous segment's start ${previousStart}`);
|
|
91
|
+
}
|
|
92
|
+
const firstNumber = entry.n === null ? number : BigInt(entry.n);
|
|
93
|
+
let count = repeat + 1n;
|
|
94
|
+
if (repeat < 0n) {
|
|
95
|
+
const next = entries[index + 1];
|
|
96
|
+
if (next !== undefined) {
|
|
97
|
+
if (next.t === null) {
|
|
98
|
+
throw new DashResolveError("invalid-timeline", `S ${index} repeats until the next @t, which S ${index + 1} does not have`);
|
|
99
|
+
}
|
|
100
|
+
count = bigIntMax(0n, bigIntDivCeil(next.t - start, duration));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const bounded = terminalCount(start - presentationTimeOffset, duration, firstNumber, listOffset, terminal);
|
|
104
|
+
if (bounded === null) {
|
|
105
|
+
throw new DashResolveError("unbounded-repeat", `S ${index} repeats with @r="${repeat}" and nothing bounds it`);
|
|
106
|
+
}
|
|
107
|
+
count = bounded;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
yield {
|
|
111
|
+
firstNumber,
|
|
112
|
+
relativeStart: start - presentationTimeOffset,
|
|
113
|
+
timeValue: start,
|
|
114
|
+
duration,
|
|
115
|
+
count,
|
|
116
|
+
listOffset,
|
|
117
|
+
};
|
|
118
|
+
if (count > 0n) {
|
|
119
|
+
previousStart = start + (count - 1n) * duration;
|
|
120
|
+
}
|
|
121
|
+
time = start + count * duration;
|
|
122
|
+
number = firstNumber + count;
|
|
123
|
+
listOffset += count;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=_segment-runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_segment-runs.js","sourceRoot":"","sources":["../../src/resolve/_segment-runs.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,cAAc,EACd,SAAS,EACT,SAAS,GACT,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAwDhD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,KAAK,GAAG,WAAc,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAC1B,GAAe,EACf,MAAqB;IAErB,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,GAAG,KAAK,CAAC;IAC9C,MAAM,cAAc,GAAG,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC5C,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;IACrB,IAAI,MAAM,CAAC,WAAW,KAA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AAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACP,MAAM,OAAO,GAAG,aAAa,CAC5B,KAAK,GAAG,sBAAsB,EAC9B,QAAQ,EACR,WAAW,EACX,UAAU,EACV,QAAQ,CACR,CAAC;gBACF,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;oBACtB,MAAM,IAAI,gBAAgB,CACzB,kBAAkB,EAClB,KAAK,KAAK,qBAAqB,MAAM,yBAAyB,CAC9D,CAAC;gBACH,CAAC;gBACD,KAAK,GAAG,OAAO,CAAC;YACjB,CAAC;QACF,CAAC;QACD,MAAM;YACL,WAAW;YACX,aAAa,EAAE,KAAK,GAAG,sBAAsB;YAC7C,SAAS,EAAE,KAAK;YAChB,QAAQ;YACR,KAAK;YACL,UAAU;SACV,CAAC;QACF,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;YAChB,aAAa,GAAG,KAAK,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC;QACjD,CAAC;QACD,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;QAChC,MAAM,GAAG,WAAW,GAAG,KAAK,CAAC;QAC7B,UAAU,IAAI,KAAK,CAAC;IACrB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why one item of a resolved view could not be resolved, or was left out.
|
|
3
|
+
*
|
|
4
|
+
* - `invalid-uri`: a BaseURL or a source URL does not resolve against the base in
|
|
5
|
+
* effect with the WHATWG `URL` parser; the `href`s depending on it are
|
|
6
|
+
* `null`.
|
|
7
|
+
* - `unresolved-xlink`: a remote Period or AdaptationSet (`xlink:href`) is not
|
|
8
|
+
* resolved; whatever it holds inline is a placeholder, so nothing is listed
|
|
9
|
+
* from it. Fetch it and splice it into the model to list what it holds.
|
|
10
|
+
* - `unknown-period-start`: the Period's start is unknown (an early-available
|
|
11
|
+
* Period of a dynamic MPD); its Representations are listed with a `null`
|
|
12
|
+
* `periodStart`.
|
|
13
|
+
* - `per-segment-index`: a SegmentTemplate `@index` uses `$Number$` or `$Time$`,
|
|
14
|
+
* an index per segment; the plan has no `index`.
|
|
15
|
+
*/
|
|
16
|
+
export type DashResolveDiagnostic = {
|
|
17
|
+
readonly code: "invalid-uri" | "unresolved-xlink" | "unknown-period-start";
|
|
18
|
+
readonly message: string;
|
|
19
|
+
/** Index of the Period concerned. */
|
|
20
|
+
readonly period: number;
|
|
21
|
+
/** Index of the AdaptationSet in its Period, when one is concerned. */
|
|
22
|
+
readonly adaptationSet: number | null;
|
|
23
|
+
/** Index of the Representation in its AdaptationSet, when one is concerned. */
|
|
24
|
+
readonly representation: number | null;
|
|
25
|
+
/** The URI as written, when the diagnostic is about one. */
|
|
26
|
+
readonly uri: string | null;
|
|
27
|
+
};
|
|
28
|
+
/** Indices of one Representation; the model has no parent links. */
|
|
29
|
+
export type DashRepresentationPath = {
|
|
30
|
+
readonly period: number;
|
|
31
|
+
readonly adaptationSet: number;
|
|
32
|
+
readonly representation: number;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=dash-resolve-diagnostic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash-resolve-diagnostic.d.ts","sourceRoot":"","sources":["../../src/resolve/dash-resolve-diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,qBAAqB,GAAG;IACnC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,kBAAkB,GAAG,sBAAsB,CAAC;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,+EAA+E;IAC/E,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash-resolve-diagnostic.js","sourceRoot":"","sources":["../../src/resolve/dash-resolve-diagnostic.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { type WorkBudget } from "@ac-kit/core";
|
|
2
|
+
import type { DashBaseUrl, DashContentProtection, DashDescriptor, DashLabel, DashRatio } from "../model/dash-common.js";
|
|
3
|
+
import type { DashAdaptationSet, DashMpd, DashPeriod, DashRepresentation } from "../model/dash-mpd.js";
|
|
4
|
+
import type { DashRepresentationPath, DashResolveDiagnostic } from "./dash-resolve-diagnostic.js";
|
|
5
|
+
/** Options of {@link resolveDashRepresentations}. */
|
|
6
|
+
export type DashResolveRepresentationsOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* `schemeIdUri`s of the EssentialProperty descriptors the caller understands.
|
|
9
|
+
* A Representation under any other is flagged with `ignoredBecause`, as
|
|
10
|
+
* §5.8.4.8 tells a client to ignore it. Empty by default: this package
|
|
11
|
+
* interprets none.
|
|
12
|
+
*/
|
|
13
|
+
readonly understoodEssentialProperties?: Iterable<string>;
|
|
14
|
+
/** Leave out the Representations flagged with `ignoredBecause`. */
|
|
15
|
+
readonly skipIgnored?: boolean;
|
|
16
|
+
/** Picks one of a level's alternative BaseURLs; the first by default. */
|
|
17
|
+
readonly chooseBaseUrl?: (candidates: readonly DashBaseUrl[]) => DashBaseUrl;
|
|
18
|
+
/**
|
|
19
|
+
* The work resolving may do, one unit per descriptor examined and BaseURL
|
|
20
|
+
* level: a caller's `WorkBudget`, whose exhaustion error propagates as is, or
|
|
21
|
+
* a limit for a private one, {@link DEFAULT_DASH_WORK_BUDGET} by default,
|
|
22
|
+
* whose exhaustion is a {@link DashLimitError} `budget`.
|
|
23
|
+
*/
|
|
24
|
+
readonly budget?: WorkBudget | number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Descriptors of one kind by the scope that declares them, each the model's own
|
|
28
|
+
* array, shared and never copied: every Representation of an AdaptationSet
|
|
29
|
+
* holds the same `mpd`, `period` and `adaptationSet` arrays.
|
|
30
|
+
*/
|
|
31
|
+
export type DashScopedDescriptors<T> = {
|
|
32
|
+
readonly mpd: readonly T[];
|
|
33
|
+
readonly period: readonly T[];
|
|
34
|
+
readonly adaptationSet: readonly T[];
|
|
35
|
+
readonly representation: readonly T[];
|
|
36
|
+
};
|
|
37
|
+
/** Why a resolved Representation should not be used as it is. */
|
|
38
|
+
export type DashIgnoredBecause = {
|
|
39
|
+
/** An EssentialProperty whose scheme the caller does not understand. */
|
|
40
|
+
readonly code: "essential-property";
|
|
41
|
+
readonly schemeIdUri: string | null;
|
|
42
|
+
} | {
|
|
43
|
+
/** A lenient parse could not read the required attribute. */
|
|
44
|
+
readonly code: "missing-attribute";
|
|
45
|
+
readonly attribute: "id" | "bandwidth";
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* One Representation, with its AdaptationSet's values applied where it declares
|
|
49
|
+
* none.
|
|
50
|
+
*/
|
|
51
|
+
export type DashResolvedRepresentation = {
|
|
52
|
+
readonly path: DashRepresentationPath;
|
|
53
|
+
readonly period: DashPeriod;
|
|
54
|
+
readonly adaptationSet: DashAdaptationSet;
|
|
55
|
+
readonly representation: DashRepresentation;
|
|
56
|
+
/** Seconds on the MPD timeline; `null` for an early-available Period. */
|
|
57
|
+
readonly periodStart: number | null;
|
|
58
|
+
/** Seconds; `null` while the Period has no known end. */
|
|
59
|
+
readonly periodDuration: number | null;
|
|
60
|
+
/**
|
|
61
|
+
* The BaseURL chain resolved for this Representation: the media file itself
|
|
62
|
+
* for one with no segment information. `null` when a BaseURL does not resolve
|
|
63
|
+
* (see `warnings`).
|
|
64
|
+
*/
|
|
65
|
+
readonly href: string | null;
|
|
66
|
+
readonly id: string | null;
|
|
67
|
+
readonly bandwidth: number | null;
|
|
68
|
+
/** `@contentType`, else the top-level type of the effective `@mimeType`. */
|
|
69
|
+
readonly contentType: string | null;
|
|
70
|
+
readonly mimeType: string | null;
|
|
71
|
+
readonly codecs: string | null;
|
|
72
|
+
readonly width: number | null;
|
|
73
|
+
readonly height: number | null;
|
|
74
|
+
readonly frameRate: DashRatio | null;
|
|
75
|
+
readonly sar: DashRatio | null;
|
|
76
|
+
readonly audioSamplingRate: readonly number[] | null;
|
|
77
|
+
readonly lang: string | null;
|
|
78
|
+
readonly roles: readonly DashDescriptor[];
|
|
79
|
+
readonly accessibility: readonly DashDescriptor[];
|
|
80
|
+
readonly labels: readonly DashLabel[];
|
|
81
|
+
readonly audioChannelConfigurations: readonly DashDescriptor[];
|
|
82
|
+
/** Every ContentProtection that applies, by scope, as plain data. */
|
|
83
|
+
readonly contentProtections: DashScopedDescriptors<DashContentProtection>;
|
|
84
|
+
/**
|
|
85
|
+
* The MPD- and Period-level ContentProtections a lower one names with `@ref`
|
|
86
|
+
* (matched by `@refId`), in the order referred to; inert data.
|
|
87
|
+
*/
|
|
88
|
+
readonly referencedContentProtections: readonly DashContentProtection[];
|
|
89
|
+
readonly essentialProperties: DashScopedDescriptors<DashDescriptor>;
|
|
90
|
+
readonly supplementalProperties: DashScopedDescriptors<DashDescriptor>;
|
|
91
|
+
/**
|
|
92
|
+
* Whether a ContentProtection applies at any scope. Only a flag: nothing here
|
|
93
|
+
* acquires a license or decrypts.
|
|
94
|
+
*/
|
|
95
|
+
readonly isProtected: boolean;
|
|
96
|
+
/** `null` for a Representation fit for use. */
|
|
97
|
+
readonly ignoredBecause: DashIgnoredBecause | null;
|
|
98
|
+
};
|
|
99
|
+
/** What {@link resolveDashRepresentations} answers. */
|
|
100
|
+
export type DashResolvedRepresentations = {
|
|
101
|
+
readonly representations: readonly DashResolvedRepresentation[];
|
|
102
|
+
readonly warnings: readonly DashResolveDiagnostic[];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Every Representation of every Period, in document order, as a flat table
|
|
106
|
+
* against `mpdUrl`, the URL the MPD was fetched from after redirects. One item
|
|
107
|
+
* that cannot be resolved gets `href: null` and a diagnostic; the others are
|
|
108
|
+
* unaffected. A remote (xlink) Period or AdaptationSet lists nothing, with an
|
|
109
|
+
* `unresolved-xlink` diagnostic, whatever placeholder content it holds; a
|
|
110
|
+
* `resolve-to-zero` one is absent.
|
|
111
|
+
*
|
|
112
|
+
* Nothing is filtered by default: an unusable Representation is flagged with
|
|
113
|
+
* `ignoredBecause` and a protected one with `isProtected`, from descriptors at
|
|
114
|
+
* every scope (MPD, Period, AdaptationSet, Representation), never acted on.
|
|
115
|
+
* Which URL schemes and hosts may be fetched is the caller's policy: an `href`
|
|
116
|
+
* may be any scheme an MPD names, `file:` and `data:` included.
|
|
117
|
+
*
|
|
118
|
+
* Time O(R + D) for R Representations and D descriptors: descriptor lists are
|
|
119
|
+
* shared, not copied, and what an upper scope decides is computed once per
|
|
120
|
+
* scope; one URL parse per BaseURL level.
|
|
121
|
+
*
|
|
122
|
+
* @throws {TypeError} When `mpdUrl` is not an absolute URL.
|
|
123
|
+
* @throws {UnsupportedError} When a chosen BaseURL has `@byteRange`.
|
|
124
|
+
* @throws {DashResolveError} `invalid-duration` for a duration with years or
|
|
125
|
+
* months, which only a model built in code can hold.
|
|
126
|
+
* @throws {DashLimitError} When a private `budget` runs out.
|
|
127
|
+
* @throws Whatever a caller's `budget` throws once spent.
|
|
128
|
+
*/
|
|
129
|
+
export declare function resolveDashRepresentations(mpd: DashMpd, mpdUrl: string | URL, options?: DashResolveRepresentationsOptions): DashResolvedRepresentations;
|
|
130
|
+
//# sourceMappingURL=resolve-dash-representations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-dash-representations.d.ts","sourceRoot":"","sources":["../../src/resolve/resolve-dash-representations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,cAAc,CAAC;AAK/D,OAAO,KAAK,EACX,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,SAAS,EACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACX,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,MAAM,sBAAsB,CAAC;AAY9B,OAAO,KAAK,EACX,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,8BAA8B,CAAC;AAEtC,qDAAqD;AACrD,MAAM,MAAM,iCAAiC,GAAG;IAC/C;;;;;OAKG;IACH,QAAQ,CAAC,6BAA6B,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1D,mEAAmE;IACnE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,WAAW,EAAE,KAAK,WAAW,CAAC;IAC7E;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CACtC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI;IACtC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,SAAS,CAAC,EAAE,CAAC;CACtC,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,kBAAkB,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|
3
|
+
import { DashLimitError } from "../errors.js";
|
|
4
|
+
import { DEFAULT_DASH_WORK_BUDGET } from "../limits.js";
|
|
5
|
+
import { exactPeriodTimings } from "../timing/_exact-period-timings.js";
|
|
6
|
+
import { chooseFirstBaseUrl, documentBase, resolveBaseChain, } from "./_base-url.js";
|
|
7
|
+
import { essentialScope, firstIgnoredBecause, } from "./_essential-properties.js";
|
|
8
|
+
/**
|
|
9
|
+
* Every Representation of every Period, in document order, as a flat table
|
|
10
|
+
* against `mpdUrl`, the URL the MPD was fetched from after redirects. One item
|
|
11
|
+
* that cannot be resolved gets `href: null` and a diagnostic; the others are
|
|
12
|
+
* unaffected. A remote (xlink) Period or AdaptationSet lists nothing, with an
|
|
13
|
+
* `unresolved-xlink` diagnostic, whatever placeholder content it holds; a
|
|
14
|
+
* `resolve-to-zero` one is absent.
|
|
15
|
+
*
|
|
16
|
+
* Nothing is filtered by default: an unusable Representation is flagged with
|
|
17
|
+
* `ignoredBecause` and a protected one with `isProtected`, from descriptors at
|
|
18
|
+
* every scope (MPD, Period, AdaptationSet, Representation), never acted on.
|
|
19
|
+
* Which URL schemes and hosts may be fetched is the caller's policy: an `href`
|
|
20
|
+
* may be any scheme an MPD names, `file:` and `data:` included.
|
|
21
|
+
*
|
|
22
|
+
* Time O(R + D) for R Representations and D descriptors: descriptor lists are
|
|
23
|
+
* shared, not copied, and what an upper scope decides is computed once per
|
|
24
|
+
* scope; one URL parse per BaseURL level.
|
|
25
|
+
*
|
|
26
|
+
* @throws {TypeError} When `mpdUrl` is not an absolute URL.
|
|
27
|
+
* @throws {UnsupportedError} When a chosen BaseURL has `@byteRange`.
|
|
28
|
+
* @throws {DashResolveError} `invalid-duration` for a duration with years or
|
|
29
|
+
* months, which only a model built in code can hold.
|
|
30
|
+
* @throws {DashLimitError} When a private `budget` runs out.
|
|
31
|
+
* @throws Whatever a caller's `budget` throws once spent.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveDashRepresentations(mpd, mpdUrl, options) {
|
|
34
|
+
const documentUrl = documentBase(mpdUrl);
|
|
35
|
+
return withWorkBudget(options?.budget ?? DEFAULT_DASH_WORK_BUDGET, (budget) => resolve_(mpd, documentUrl, options, budget), (cause) => new DashLimitError("budget", cause.limit, null, { cause }));
|
|
36
|
+
}
|
|
37
|
+
function resolve_(mpd, documentUrl, options, budget) {
|
|
38
|
+
const understood = new Set(options?.understoodEssentialProperties ?? []);
|
|
39
|
+
const choose = options?.chooseBaseUrl ?? chooseFirstBaseUrl;
|
|
40
|
+
const skipIgnored = options?.skipIgnored === true;
|
|
41
|
+
const timings = exactPeriodTimings(mpd);
|
|
42
|
+
const warnings = [];
|
|
43
|
+
const representations = [];
|
|
44
|
+
const mpdScope = essentialScope(null, mpd.essentialProperties, understood, budget);
|
|
45
|
+
const references = new Map();
|
|
46
|
+
const addReferences = (protections) => {
|
|
47
|
+
budget.spend(protections.length);
|
|
48
|
+
for (const protection of protections) {
|
|
49
|
+
if (protection.refId !== null && !references.has(protection.refId)) {
|
|
50
|
+
references.set(protection.refId, protection);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
addReferences(mpd.contentProtections);
|
|
55
|
+
const referenced = (protections) => {
|
|
56
|
+
budget.spend(protections.length);
|
|
57
|
+
const found = [];
|
|
58
|
+
for (const protection of protections) {
|
|
59
|
+
const target = protection.ref === null ? undefined : references.get(protection.ref);
|
|
60
|
+
if (target !== undefined) {
|
|
61
|
+
found.push(target);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return found;
|
|
65
|
+
};
|
|
66
|
+
for (const [periodIndex, period] of mpd.periods.entries()) {
|
|
67
|
+
const periodState = xlinkState(period.xlink);
|
|
68
|
+
if (periodState === "absent") {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (periodState === "remote") {
|
|
72
|
+
warnings.push(xlinkWarning_(period.xlink.href, periodIndex, null));
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const timing = timings[periodIndex];
|
|
76
|
+
if (timing.start === null && period.adaptationSets.length > 0) {
|
|
77
|
+
warnings.push({
|
|
78
|
+
code: "unknown-period-start",
|
|
79
|
+
message: `Period ${periodIndex} has no known start`,
|
|
80
|
+
period: periodIndex,
|
|
81
|
+
adaptationSet: null,
|
|
82
|
+
representation: null,
|
|
83
|
+
uri: null,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const periodScope = essentialScope(mpdScope, period.essentialProperties, understood, budget);
|
|
87
|
+
addReferences(period.contentProtections);
|
|
88
|
+
for (const [setIndex, adaptationSet] of period.adaptationSets.entries()) {
|
|
89
|
+
const setState = xlinkState(adaptationSet.xlink);
|
|
90
|
+
if (setState === "absent") {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (setState === "remote") {
|
|
94
|
+
warnings.push(xlinkWarning_(adaptationSet.xlink.href, periodIndex, setIndex));
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const setScope = essentialScope(periodScope, adaptationSet.essentialProperties, understood, budget);
|
|
98
|
+
const setReferenced = referenced(adaptationSet.contentProtections);
|
|
99
|
+
const setProtected = mpd.contentProtections.length > 0 ||
|
|
100
|
+
period.contentProtections.length > 0 ||
|
|
101
|
+
adaptationSet.contentProtections.length > 0;
|
|
102
|
+
for (const [representationIndex, representation,] of adaptationSet.representations.entries()) {
|
|
103
|
+
const path = {
|
|
104
|
+
period: periodIndex,
|
|
105
|
+
adaptationSet: setIndex,
|
|
106
|
+
representation: representationIndex,
|
|
107
|
+
};
|
|
108
|
+
budget.spend(4);
|
|
109
|
+
const { base } = resolveBaseChain([
|
|
110
|
+
mpd.baseUrls,
|
|
111
|
+
period.baseUrls,
|
|
112
|
+
adaptationSet.baseUrls,
|
|
113
|
+
representation.baseUrls,
|
|
114
|
+
], documentUrl, choose, path, warnings);
|
|
115
|
+
const ignoredBecause = ignoredBecause_(representation, firstIgnoredBecause(setScope, representation.essentialProperties, understood, budget));
|
|
116
|
+
if (skipIgnored && ignoredBecause !== null) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const ownReferenced = referenced(representation.contentProtections);
|
|
120
|
+
const mimeType = representation.mimeType ?? adaptationSet.mimeType;
|
|
121
|
+
representations.push({
|
|
122
|
+
path,
|
|
123
|
+
period,
|
|
124
|
+
adaptationSet,
|
|
125
|
+
representation,
|
|
126
|
+
periodStart: seconds_(timing.start),
|
|
127
|
+
periodDuration: seconds_(timing.duration),
|
|
128
|
+
href: base?.href ?? null,
|
|
129
|
+
id: representation.id,
|
|
130
|
+
bandwidth: representation.bandwidth,
|
|
131
|
+
contentType: adaptationSet.contentType ?? mimeType?.split("/")[0] ?? null,
|
|
132
|
+
mimeType,
|
|
133
|
+
codecs: representation.codecs ?? adaptationSet.codecs,
|
|
134
|
+
width: representation.width ?? adaptationSet.width,
|
|
135
|
+
height: representation.height ?? adaptationSet.height,
|
|
136
|
+
frameRate: representation.frameRate ?? adaptationSet.frameRate,
|
|
137
|
+
sar: representation.sar ?? adaptationSet.sar,
|
|
138
|
+
audioSamplingRate: representation.audioSamplingRate ?? adaptationSet.audioSamplingRate,
|
|
139
|
+
lang: adaptationSet.lang,
|
|
140
|
+
roles: adaptationSet.roles,
|
|
141
|
+
accessibility: adaptationSet.accessibility,
|
|
142
|
+
labels: adaptationSet.labels,
|
|
143
|
+
audioChannelConfigurations: representation.audioChannelConfigurations.length > 0
|
|
144
|
+
? representation.audioChannelConfigurations
|
|
145
|
+
: adaptationSet.audioChannelConfigurations,
|
|
146
|
+
contentProtections: {
|
|
147
|
+
mpd: mpd.contentProtections,
|
|
148
|
+
period: period.contentProtections,
|
|
149
|
+
adaptationSet: adaptationSet.contentProtections,
|
|
150
|
+
representation: representation.contentProtections,
|
|
151
|
+
},
|
|
152
|
+
referencedContentProtections: ownReferenced.length === 0
|
|
153
|
+
? setReferenced
|
|
154
|
+
: concatCharged_(setReferenced, ownReferenced, budget),
|
|
155
|
+
essentialProperties: {
|
|
156
|
+
mpd: mpd.essentialProperties,
|
|
157
|
+
period: period.essentialProperties,
|
|
158
|
+
adaptationSet: adaptationSet.essentialProperties,
|
|
159
|
+
representation: representation.essentialProperties,
|
|
160
|
+
},
|
|
161
|
+
supplementalProperties: {
|
|
162
|
+
mpd: mpd.supplementalProperties,
|
|
163
|
+
period: period.supplementalProperties,
|
|
164
|
+
adaptationSet: adaptationSet.supplementalProperties,
|
|
165
|
+
representation: representation.supplementalProperties,
|
|
166
|
+
},
|
|
167
|
+
isProtected: setProtected || representation.contentProtections.length > 0,
|
|
168
|
+
ignoredBecause,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { representations, warnings };
|
|
174
|
+
}
|
|
175
|
+
function ignoredBecause_(representation, essential) {
|
|
176
|
+
if (representation.id === null) {
|
|
177
|
+
return { code: "missing-attribute", attribute: "id" };
|
|
178
|
+
}
|
|
179
|
+
if (representation.bandwidth === null) {
|
|
180
|
+
return { code: "missing-attribute", attribute: "bandwidth" };
|
|
181
|
+
}
|
|
182
|
+
return essential === null
|
|
183
|
+
? null
|
|
184
|
+
: { code: "essential-property", schemeIdUri: essential.schemeIdUri };
|
|
185
|
+
}
|
|
186
|
+
function xlinkWarning_(href, period, adaptationSet) {
|
|
187
|
+
return {
|
|
188
|
+
code: "unresolved-xlink",
|
|
189
|
+
message: `${adaptationSet === null ? "Period" : "AdaptationSet"} is remote (xlink:href "${href}") and was not resolved`,
|
|
190
|
+
period,
|
|
191
|
+
adaptationSet,
|
|
192
|
+
representation: null,
|
|
193
|
+
uri: href,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function seconds_(nanoseconds) {
|
|
197
|
+
return nanoseconds === null ? null : Number(nanoseconds) / 1e9;
|
|
198
|
+
}
|
|
199
|
+
function concatCharged_(left, right, budget) {
|
|
200
|
+
budget.spend(left.length + right.length);
|
|
201
|
+
return left.concat(right);
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=resolve-dash-representations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-dash-representations.js","sourceRoot":"","sources":["../../src/resolve/resolve-dash-representations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAcxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EACN,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEN,cAAc,EACd,mBAAmB,GACnB,MAAM,4BAA4B,CAAC;AAgHpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,0BAA0B,CACzC,GAAY,EACZ,MAAoB,EACpB,OAA2C;IAE3C,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,cAAc,CACpB,OAAO,EAAE,MAAM,IAAI,wBAAwB,EAC3C,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,EACvD,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CACrE,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAChB,GAAY,EACZ,WAAgB,EAChB,OAAsD,EACtD,MAAkB;IAElB,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,6BAA6B,IAAI,EAAE,CAAC,CAAC;IACzE,MAAM,MAAM,GAAG,OAAO,EAAE,aAAa,IAAI,kBAAkB,CAAC;IAC5D,MAAM,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