@ac-kit/format-hls 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 +83 -0
- package/LICENSE +28 -0
- package/README.md +145 -2
- package/dist/_date-range-fields.d.ts +14 -0
- package/dist/_date-range-fields.d.ts.map +1 -0
- package/dist/_date-range-fields.js +53 -0
- package/dist/_date-range-fields.js.map +1 -0
- package/dist/_key-scope.d.ts +8 -0
- package/dist/_key-scope.d.ts.map +1 -0
- package/dist/_key-scope.js +14 -0
- package/dist/_key-scope.js.map +1 -0
- package/dist/_temporal.d.ts +3 -0
- package/dist/_temporal.d.ts.map +1 -0
- package/dist/_temporal.js +14 -0
- package/dist/_temporal.js.map +1 -0
- package/dist/attribute/_print-attribute.d.ts +10 -0
- package/dist/attribute/_print-attribute.d.ts.map +1 -0
- package/dist/attribute/_print-attribute.js +31 -0
- package/dist/attribute/_print-attribute.js.map +1 -0
- package/dist/attribute/_scan-attribute-list.d.ts +24 -0
- package/dist/attribute/_scan-attribute-list.d.ts.map +1 -0
- package/dist/attribute/_scan-attribute-list.js +147 -0
- package/dist/attribute/_scan-attribute-list.js.map +1 -0
- package/dist/attribute/hls-attribute.d.ts +38 -0
- package/dist/attribute/hls-attribute.d.ts.map +1 -0
- package/dist/attribute/hls-attribute.js +42 -0
- package/dist/attribute/hls-attribute.js.map +1 -0
- package/dist/document/hls-document.d.ts +52 -0
- package/dist/document/hls-document.d.ts.map +1 -0
- package/dist/document/hls-document.js +2 -0
- package/dist/document/hls-document.js.map +1 -0
- package/dist/document/parse-hls-document.d.ts +14 -0
- package/dist/document/parse-hls-document.d.ts.map +1 -0
- package/dist/document/parse-hls-document.js +79 -0
- package/dist/document/parse-hls-document.js.map +1 -0
- package/dist/document/print-hls-document.d.ts +10 -0
- package/dist/document/print-hls-document.d.ts.map +1 -0
- package/dist/document/print-hls-document.js +28 -0
- package/dist/document/print-hls-document.js.map +1 -0
- package/dist/errors.d.ts +92 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +67 -0
- package/dist/errors.js.map +1 -0
- package/dist/hls-playlist-queries.d.ts +16 -0
- package/dist/hls-playlist-queries.d.ts.map +1 -0
- package/dist/hls-playlist-queries.js +28 -0
- package/dist/hls-playlist-queries.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/limits.d.ts +48 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +24 -0
- package/dist/limits.js.map +1 -0
- package/dist/live/apply-hls-delta-update.d.ts +49 -0
- package/dist/live/apply-hls-delta-update.d.ts.map +1 -0
- package/dist/live/apply-hls-delta-update.js +298 -0
- package/dist/live/apply-hls-delta-update.js.map +1 -0
- package/dist/model/hls-key.d.ts +29 -0
- package/dist/model/hls-key.d.ts.map +1 -0
- package/dist/model/hls-key.js +2 -0
- package/dist/model/hls-key.js.map +1 -0
- package/dist/model/hls-media-playlist.d.ts +202 -0
- package/dist/model/hls-media-playlist.d.ts.map +1 -0
- package/dist/model/hls-media-playlist.js +2 -0
- package/dist/model/hls-media-playlist.js.map +1 -0
- package/dist/model/hls-multivariant-playlist.d.ts +142 -0
- package/dist/model/hls-multivariant-playlist.d.ts.map +1 -0
- package/dist/model/hls-multivariant-playlist.js +2 -0
- package/dist/model/hls-multivariant-playlist.js.map +1 -0
- package/dist/model/hls-playlist.d.ts +77 -0
- package/dist/model/hls-playlist.d.ts.map +1 -0
- package/dist/model/hls-playlist.js +2 -0
- package/dist/model/hls-playlist.js.map +1 -0
- package/dist/parse/_attribute-reader.d.ts +106 -0
- package/dist/parse/_attribute-reader.d.ts.map +1 -0
- package/dist/parse/_attribute-reader.js +266 -0
- package/dist/parse/_attribute-reader.js.map +1 -0
- package/dist/parse/_context.d.ts +87 -0
- package/dist/parse/_context.d.ts.map +1 -0
- package/dist/parse/_context.js +179 -0
- package/dist/parse/_context.js.map +1 -0
- package/dist/parse/_interpret-media.d.ts +18 -0
- package/dist/parse/_interpret-media.d.ts.map +1 -0
- package/dist/parse/_interpret-media.js +677 -0
- package/dist/parse/_interpret-media.js.map +1 -0
- package/dist/parse/_interpret-multivariant.d.ts +9 -0
- package/dist/parse/_interpret-multivariant.d.ts.map +1 -0
- package/dist/parse/_interpret-multivariant.js +435 -0
- package/dist/parse/_interpret-multivariant.js.map +1 -0
- package/dist/parse/_media-validation.d.ts +14 -0
- package/dist/parse/_media-validation.d.ts.map +1 -0
- package/dist/parse/_media-validation.js +50 -0
- package/dist/parse/_media-validation.js.map +1 -0
- package/dist/parse/_prepare-lines.d.ts +12 -0
- package/dist/parse/_prepare-lines.d.ts.map +1 -0
- package/dist/parse/_prepare-lines.js +118 -0
- package/dist/parse/_prepare-lines.js.map +1 -0
- package/dist/parse/_sink.d.ts +30 -0
- package/dist/parse/_sink.d.ts.map +1 -0
- package/dist/parse/_sink.js +53 -0
- package/dist/parse/_sink.js.map +1 -0
- package/dist/parse/_values.d.ts +31 -0
- package/dist/parse/_values.d.ts.map +1 -0
- package/dist/parse/_values.js +89 -0
- package/dist/parse/_values.js.map +1 -0
- package/dist/parse/_variables.d.ts +34 -0
- package/dist/parse/_variables.d.ts.map +1 -0
- package/dist/parse/_variables.js +65 -0
- package/dist/parse/_variables.js.map +1 -0
- package/dist/parse/parse-hls-date-time.d.ts +13 -0
- package/dist/parse/parse-hls-date-time.d.ts.map +1 -0
- package/dist/parse/parse-hls-date-time.js +36 -0
- package/dist/parse/parse-hls-date-time.js.map +1 -0
- package/dist/parse/parse-hls-playlist.d.ts +58 -0
- package/dist/parse/parse-hls-playlist.d.ts.map +1 -0
- package/dist/parse/parse-hls-playlist.js +119 -0
- package/dist/parse/parse-hls-playlist.js.map +1 -0
- package/dist/parse-stream.d.ts +19 -0
- package/dist/parse-stream.d.ts.map +1 -0
- package/dist/parse-stream.js +54 -0
- package/dist/parse-stream.js.map +1 -0
- package/dist/print/print-hls-playlist.d.ts +39 -0
- package/dist/print/print-hls-playlist.d.ts.map +1 -0
- package/dist/print/print-hls-playlist.js +504 -0
- package/dist/print/print-hls-playlist.js.map +1 -0
- package/dist/print-stream.d.ts +11 -0
- package/dist/print-stream.d.ts.map +1 -0
- package/dist/print-stream.js +13 -0
- package/dist/print-stream.js.map +1 -0
- package/dist/resolve/_href.d.ts +13 -0
- package/dist/resolve/_href.d.ts.map +1 -0
- package/dist/resolve/_href.js +26 -0
- package/dist/resolve/_href.js.map +1 -0
- package/dist/resolve/hls-resolve-diagnostic.d.ts +26 -0
- package/dist/resolve/hls-resolve-diagnostic.d.ts.map +1 -0
- package/dist/resolve/hls-resolve-diagnostic.js +2 -0
- package/dist/resolve/hls-resolve-diagnostic.js.map +1 -0
- package/dist/resolve/resolve-hls-segments.d.ts +74 -0
- package/dist/resolve/resolve-hls-segments.d.ts.map +1 -0
- package/dist/resolve/resolve-hls-segments.js +179 -0
- package/dist/resolve/resolve-hls-segments.js.map +1 -0
- package/dist/resolve/resolve-hls-variants.d.ts +105 -0
- package/dist/resolve/resolve-hls-variants.d.ts.map +1 -0
- package/dist/resolve/resolve-hls-variants.js +162 -0
- package/dist/resolve/resolve-hls-variants.js.map +1 -0
- package/package.json +63 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,gFAAgF;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEpD,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CACxC,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAOvC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,iBAAiB,CAU/D"}
|
package/dist/limits.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The defaults behind every unset bound in {@link HlsLimits}. */
|
|
2
|
+
export const DEFAULT_HLS_LIMITS = {
|
|
3
|
+
maxLength: 16777216,
|
|
4
|
+
maxLineLength: 1048576,
|
|
5
|
+
maxLines: 1048576,
|
|
6
|
+
maxSegments: 262144,
|
|
7
|
+
maxWarnings: 1000,
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Fills in the unset bounds from {@link DEFAULT_HLS_LIMITS}; `maxExpansion`
|
|
11
|
+
* defaults to the resolved `maxLength`.
|
|
12
|
+
*/
|
|
13
|
+
export function hlsLimits(limits) {
|
|
14
|
+
const maxLength = limits?.maxLength ?? DEFAULT_HLS_LIMITS.maxLength;
|
|
15
|
+
return {
|
|
16
|
+
maxLength,
|
|
17
|
+
maxLineLength: limits?.maxLineLength ?? DEFAULT_HLS_LIMITS.maxLineLength,
|
|
18
|
+
maxLines: limits?.maxLines ?? DEFAULT_HLS_LIMITS.maxLines,
|
|
19
|
+
maxSegments: limits?.maxSegments ?? DEFAULT_HLS_LIMITS.maxSegments,
|
|
20
|
+
maxExpansion: limits?.maxExpansion ?? maxLength,
|
|
21
|
+
maxWarnings: limits?.maxWarnings ?? DEFAULT_HLS_LIMITS.maxWarnings,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AA0CA,kEAAkE;AAClE,MAAM,CAAC,MAAM,kBAAkB,GAE3B;IACH,SAAS,EAAE,QAAU;IACrB,aAAa,EAAE,OAAS;IACxB,QAAQ,EAAE,OAAS;IACnB,WAAW,EAAE,MAAO;IACpB,WAAW,EAAE,IAAI;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAkB;IAC3C,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,kBAAkB,CAAC,SAAS,CAAC;IACpE,OAAO;QACN,SAAS;QACT,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,kBAAkB,CAAC,aAAa;QACxE,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,kBAAkB,CAAC,QAAQ;QACzD,WAAW,EAAE,MAAM,EAAE,WAAW,IAAI,kBAAkB,CAAC,WAAW;QAClE,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,SAAS;QAC/C,WAAW,EAAE,MAAM,EAAE,WAAW,IAAI,kBAAkB,CAAC,WAAW;KAClE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { HlsMediaPlaylist } from "../model/hls-media-playlist.js";
|
|
2
|
+
/** Options of {@link applyHlsDeltaUpdate}. */
|
|
3
|
+
export type HlsDeltaUpdateOptions = {
|
|
4
|
+
/** Most segments the merged playlist may hold; 262 144 by default. */
|
|
5
|
+
readonly maxSegments?: number;
|
|
6
|
+
/**
|
|
7
|
+
* The playlist URL, to tell whether a continued byte range names the same
|
|
8
|
+
* resource as the sub-range before it when the two URIs are spelled
|
|
9
|
+
* differently (`a` and `./a`). Without it, distinct relative spellings do not
|
|
10
|
+
* match.
|
|
11
|
+
*/
|
|
12
|
+
readonly playlistUrl?: string | URL;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Merges a Playlist Delta Update (§6.2.5.1, §6.3.7) into the previous full
|
|
16
|
+
* version of the playlist, giving the up-to-date full playlist.
|
|
17
|
+
*
|
|
18
|
+
* - The skipped segments are taken from `previous` by Media Sequence Number, with
|
|
19
|
+
* every tag that applied to them.
|
|
20
|
+
* - The first segment of the merge carries the state that slid out with earlier
|
|
21
|
+
* segments: the keys in effect, prepended to its `keyTags` as declarations;
|
|
22
|
+
* its program date, extrapolated from the last dated segment when no
|
|
23
|
+
* discontinuity intervenes; and an absolute offset when its byte range
|
|
24
|
+
* continued an earlier sub-range.
|
|
25
|
+
* - Key declarations stay declarations, so an update's explicit `METHOD=NONE` or
|
|
26
|
+
* replacement by `KEYFORMAT` applies as written. The update's segments before
|
|
27
|
+
* its first `EXT-X-MAP` or `EXT-X-BITRATE` take the value in effect at the
|
|
28
|
+
* last skipped segment.
|
|
29
|
+
* - When the update also skipped date ranges (`RECENTLY-REMOVED-DATERANGES`
|
|
30
|
+
* present), every declaration of `previous` the update does not repeat is
|
|
31
|
+
* kept, on the segment it was on or on the first one when that slid out;
|
|
32
|
+
* every declaration of a removed ID is dropped.
|
|
33
|
+
* - Everything else comes from the update, with `skip` set to `null`.
|
|
34
|
+
*
|
|
35
|
+
* The merge checks the byte-range splice, program-date anchors, date ranges and
|
|
36
|
+
* sequence numbers. O(segments + date ranges + keys) time and memory.
|
|
37
|
+
*
|
|
38
|
+
* @throws {HlsPlaylistError} `not-a-delta-update` when `update` has no
|
|
39
|
+
* `EXT-X-SKIP` or `previous` has one; `incomplete-delta-update` when
|
|
40
|
+
* `previous` lacks a skipped segment, the sub-range a byte range continues,
|
|
41
|
+
* or the first declaration or program-date anchor needed by a date range —
|
|
42
|
+
* reload without `_HLS_skip`; `inconsistent-delta-update` when date-range
|
|
43
|
+
* declarations disagree, program dates are ambiguous, or byte ranges at the
|
|
44
|
+
* splice or sequence numbers overflow; `unrepresentable-value` when an
|
|
45
|
+
* anchored byte range ends past 2^53−1.
|
|
46
|
+
* @throws {HlsLimitError} `maxSegments` when the merge would hold more.
|
|
47
|
+
*/
|
|
48
|
+
export declare function applyHlsDeltaUpdate(previous: HlsMediaPlaylist, update: HlsMediaPlaylist, options?: HlsDeltaUpdateOptions): HlsMediaPlaylist;
|
|
49
|
+
//# sourceMappingURL=apply-hls-delta-update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-hls-delta-update.d.ts","sourceRoot":"","sources":["../../src/live/apply-hls-delta-update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEX,gBAAgB,EAGhB,MAAM,gCAAgC,CAAC;AAWxC,8CAA8C;AAC9C,MAAM,MAAM,qBAAqB,GAAG;IACnC,sEAAsE;IACtE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,gBAAgB,CA6DlB"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { mergeDateRangeFields } from "../_date-range-fields.js";
|
|
2
|
+
import { addSeconds } from "../_temporal.js";
|
|
3
|
+
import { HlsLimitError, HlsPlaylistError } from "../errors.js";
|
|
4
|
+
import { DEFAULT_HLS_LIMITS } from "../limits.js";
|
|
5
|
+
import { byteRangeEnd, checkDateRangeTimeline, checkProgramDate, checkSequenceBounds, compareSegmentResources, } from "../parse/_media-validation.js";
|
|
6
|
+
import { parseHlsDateTime } from "../parse/parse-hls-date-time.js";
|
|
7
|
+
/**
|
|
8
|
+
* Merges a Playlist Delta Update (§6.2.5.1, §6.3.7) into the previous full
|
|
9
|
+
* version of the playlist, giving the up-to-date full playlist.
|
|
10
|
+
*
|
|
11
|
+
* - The skipped segments are taken from `previous` by Media Sequence Number, with
|
|
12
|
+
* every tag that applied to them.
|
|
13
|
+
* - The first segment of the merge carries the state that slid out with earlier
|
|
14
|
+
* segments: the keys in effect, prepended to its `keyTags` as declarations;
|
|
15
|
+
* its program date, extrapolated from the last dated segment when no
|
|
16
|
+
* discontinuity intervenes; and an absolute offset when its byte range
|
|
17
|
+
* continued an earlier sub-range.
|
|
18
|
+
* - Key declarations stay declarations, so an update's explicit `METHOD=NONE` or
|
|
19
|
+
* replacement by `KEYFORMAT` applies as written. The update's segments before
|
|
20
|
+
* its first `EXT-X-MAP` or `EXT-X-BITRATE` take the value in effect at the
|
|
21
|
+
* last skipped segment.
|
|
22
|
+
* - When the update also skipped date ranges (`RECENTLY-REMOVED-DATERANGES`
|
|
23
|
+
* present), every declaration of `previous` the update does not repeat is
|
|
24
|
+
* kept, on the segment it was on or on the first one when that slid out;
|
|
25
|
+
* every declaration of a removed ID is dropped.
|
|
26
|
+
* - Everything else comes from the update, with `skip` set to `null`.
|
|
27
|
+
*
|
|
28
|
+
* The merge checks the byte-range splice, program-date anchors, date ranges and
|
|
29
|
+
* sequence numbers. O(segments + date ranges + keys) time and memory.
|
|
30
|
+
*
|
|
31
|
+
* @throws {HlsPlaylistError} `not-a-delta-update` when `update` has no
|
|
32
|
+
* `EXT-X-SKIP` or `previous` has one; `incomplete-delta-update` when
|
|
33
|
+
* `previous` lacks a skipped segment, the sub-range a byte range continues,
|
|
34
|
+
* or the first declaration or program-date anchor needed by a date range —
|
|
35
|
+
* reload without `_HLS_skip`; `inconsistent-delta-update` when date-range
|
|
36
|
+
* declarations disagree, program dates are ambiguous, or byte ranges at the
|
|
37
|
+
* splice or sequence numbers overflow; `unrepresentable-value` when an
|
|
38
|
+
* anchored byte range ends past 2^53−1.
|
|
39
|
+
* @throws {HlsLimitError} `maxSegments` when the merge would hold more.
|
|
40
|
+
*/
|
|
41
|
+
export function applyHlsDeltaUpdate(previous, update, options) {
|
|
42
|
+
const skip = update.skip;
|
|
43
|
+
if (skip === null || previous.skip !== null) {
|
|
44
|
+
throw new HlsPlaylistError("not-a-delta-update", skip === null
|
|
45
|
+
? "The update has no EXT-X-SKIP"
|
|
46
|
+
: "The previous playlist is itself an unmerged delta update");
|
|
47
|
+
}
|
|
48
|
+
const start = update.mediaSequence - previous.mediaSequence;
|
|
49
|
+
const end = start + skip.skippedSegments;
|
|
50
|
+
if (start < 0 || end > previous.segments.length) {
|
|
51
|
+
throw new HlsPlaylistError("incomplete-delta-update", `The previous playlist does not hold segments ${update.mediaSequence} to ${update.mediaSequence + skip.skippedSegments - 1}`);
|
|
52
|
+
}
|
|
53
|
+
const maxSegments = options?.maxSegments ?? DEFAULT_HLS_LIMITS.maxSegments;
|
|
54
|
+
if (skip.skippedSegments + update.segments.length > maxSegments) {
|
|
55
|
+
throw new HlsLimitError("maxSegments", maxSegments, 0);
|
|
56
|
+
}
|
|
57
|
+
const kept = previous.segments.slice(start, end);
|
|
58
|
+
const inherited = kept.at(-1) ?? previous.segments[start - 1] ?? null;
|
|
59
|
+
const tail = inheritScope_([...update.segments, update.trailer], inherited);
|
|
60
|
+
let segments = [
|
|
61
|
+
...kept,
|
|
62
|
+
...tail.slice(0, -1),
|
|
63
|
+
];
|
|
64
|
+
let trailer = tail.at(-1);
|
|
65
|
+
const anchored = anchorFirst_(previous, start, segments[0] ?? trailer, options?.playlistUrl);
|
|
66
|
+
if (segments.length > 0) {
|
|
67
|
+
segments[0] = anchored;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
trailer = anchored;
|
|
71
|
+
}
|
|
72
|
+
checkRangeSplice_(segments, kept.length, options?.playlistUrl);
|
|
73
|
+
const removed = skip.recentlyRemovedDateRanges;
|
|
74
|
+
if (removed !== null) {
|
|
75
|
+
const merged = mergeDateRanges_(previous, start, segments, trailer, new Set(removed));
|
|
76
|
+
segments = merged.segments;
|
|
77
|
+
trailer = merged.trailer;
|
|
78
|
+
}
|
|
79
|
+
checkMergedTimeline_(update, segments, trailer);
|
|
80
|
+
return { ...update, skip: null, segments, trailer };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gives `first` the state that slid out of the playlist with the segments
|
|
84
|
+
* before `previous.segments[start]`.
|
|
85
|
+
*/
|
|
86
|
+
function anchorFirst_(previous, start, first, playlistUrl) {
|
|
87
|
+
const keys = new Map();
|
|
88
|
+
let date = null;
|
|
89
|
+
let lastEnd = null;
|
|
90
|
+
for (let index = 0; index < start; index++) {
|
|
91
|
+
const segment = previous.segments[index];
|
|
92
|
+
for (const key of segment.keyTags) {
|
|
93
|
+
if (key.method === "NONE") {
|
|
94
|
+
keys.clear();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
keys.set(key.keyFormat ?? "identity", key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const own = segment.programDateTime === null
|
|
101
|
+
? null
|
|
102
|
+
: parseHlsDateTime(segment.programDateTime);
|
|
103
|
+
date = own ?? (segment.discontinuity ? null : date);
|
|
104
|
+
date = date === null ? null : addSeconds(date, segment.duration);
|
|
105
|
+
const range = segment.byteRange;
|
|
106
|
+
if (range === null) {
|
|
107
|
+
lastEnd = null;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const offset = range.offset ??
|
|
111
|
+
(lastEnd !== null &&
|
|
112
|
+
compareSegmentResources(lastEnd.uri, segment.uri, playlistUrl) === true
|
|
113
|
+
? lastEnd.end
|
|
114
|
+
: null);
|
|
115
|
+
const end = offset === null ? null : byteRangeEnd(offset, range.length);
|
|
116
|
+
lastEnd = end === null ? null : { uri: segment.uri, end };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
let anchored = first;
|
|
120
|
+
if (keys.size > 0) {
|
|
121
|
+
anchored = { ...anchored, keyTags: [...keys.values(), ...first.keyTags] };
|
|
122
|
+
}
|
|
123
|
+
if (date !== null && first.programDateTime === null && !first.discontinuity) {
|
|
124
|
+
anchored = { ...anchored, programDateTime: date.toString() };
|
|
125
|
+
}
|
|
126
|
+
if ("uri" in first) {
|
|
127
|
+
const segment = first;
|
|
128
|
+
if (segment.byteRange !== null && segment.byteRange.offset === null) {
|
|
129
|
+
if (lastEnd === null ||
|
|
130
|
+
compareSegmentResources(lastEnd.uri, segment.uri, playlistUrl) !== true) {
|
|
131
|
+
throw new HlsPlaylistError("incomplete-delta-update", `The first segment continues a byte range of "${segment.uri}" whose start slid out of the previous playlist`);
|
|
132
|
+
}
|
|
133
|
+
if (byteRangeEnd(lastEnd.end, segment.byteRange.length) === null) {
|
|
134
|
+
throw new HlsPlaylistError("unrepresentable-value", "The anchored byte range ends past 2^53-1");
|
|
135
|
+
}
|
|
136
|
+
anchored = {
|
|
137
|
+
...anchored,
|
|
138
|
+
byteRange: { length: segment.byteRange.length, offset: lastEnd.end },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return anchored;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Checks the implicit chain that crosses the splice, from its last explicit
|
|
146
|
+
* offset.
|
|
147
|
+
*/
|
|
148
|
+
function checkRangeSplice_(segments, skipped, playlistUrl) {
|
|
149
|
+
if (skipped === 0 || segments[skipped]?.byteRange?.offset !== null) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
let start = skipped - 1;
|
|
153
|
+
while (start > 0 && segments[start].byteRange?.offset === null) {
|
|
154
|
+
start--;
|
|
155
|
+
}
|
|
156
|
+
let end = null;
|
|
157
|
+
for (let index = start; index < segments.length; index++) {
|
|
158
|
+
const { uri, byteRange } = segments[index];
|
|
159
|
+
if (byteRange === null) {
|
|
160
|
+
if (index < skipped) {
|
|
161
|
+
throw new HlsPlaylistError("incomplete-delta-update", "The last skipped segment has no byte range to continue");
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
if (index > skipped && byteRange.offset !== null) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
let offset = byteRange.offset;
|
|
169
|
+
if (offset === null) {
|
|
170
|
+
const previous = segments[index - 1];
|
|
171
|
+
if (end === null ||
|
|
172
|
+
previous === undefined ||
|
|
173
|
+
compareSegmentResources(previous.uri, uri, playlistUrl) !== true) {
|
|
174
|
+
throw new HlsPlaylistError("incomplete-delta-update", `The continued byte range of "${uri}" has no preceding sub-range of the same resource`);
|
|
175
|
+
}
|
|
176
|
+
offset = end;
|
|
177
|
+
}
|
|
178
|
+
end = byteRangeEnd(offset, byteRange.length);
|
|
179
|
+
if (end === null) {
|
|
180
|
+
throw new HlsPlaylistError("inconsistent-delta-update", `The continued byte range of "${uri}" ends past 2^53-1`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Gives the leading blocks with no map or bitrate of their own the value in
|
|
186
|
+
* effect at `inherited`. Keys need nothing: they are declarations, and the
|
|
187
|
+
* merged list replays them in order.
|
|
188
|
+
*/
|
|
189
|
+
function inheritScope_(blocks, inherited) {
|
|
190
|
+
if (inherited === null) {
|
|
191
|
+
return [...blocks];
|
|
192
|
+
}
|
|
193
|
+
let mapOpen = true;
|
|
194
|
+
let bitrateOpen = true;
|
|
195
|
+
return blocks.map((block) => {
|
|
196
|
+
mapOpen &&= block.map === null;
|
|
197
|
+
bitrateOpen &&= block.bitrate === null;
|
|
198
|
+
if (!mapOpen && !bitrateOpen) {
|
|
199
|
+
return block;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
...block,
|
|
203
|
+
map: mapOpen ? inherited.map : block.map,
|
|
204
|
+
bitrate: bitrateOpen ? inherited.bitrate : block.bitrate,
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function mergeDateRanges_(previous, start, segments, trailer, removed) {
|
|
209
|
+
const present = new Set();
|
|
210
|
+
for (const block of [...segments, trailer]) {
|
|
211
|
+
for (const range of block.dateRanges) {
|
|
212
|
+
present.add(JSON.stringify(range));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const carried = new Map();
|
|
216
|
+
const carry = (index, range) => {
|
|
217
|
+
const identity = JSON.stringify(range);
|
|
218
|
+
if (removed.has(range.id) || present.has(identity)) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
present.add(identity);
|
|
222
|
+
// With no segment left, -1 stands for the trailer.
|
|
223
|
+
const target = Math.min(Math.max(index, 0), segments.length - 1);
|
|
224
|
+
const list = carried.get(target);
|
|
225
|
+
if (list === undefined) {
|
|
226
|
+
carried.set(target, [range]);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
list.push(range);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
for (const [index, segment] of previous.segments.entries()) {
|
|
233
|
+
for (const range of segment.dateRanges) {
|
|
234
|
+
carry(index - start, range);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
for (const range of previous.trailer.dateRanges) {
|
|
238
|
+
carry(previous.segments.length - start, range);
|
|
239
|
+
}
|
|
240
|
+
const keepRange = (range) => !removed.has(range.id);
|
|
241
|
+
const merged = segments.map((segment, index) => {
|
|
242
|
+
const extra = carried.get(index) ?? [];
|
|
243
|
+
const own = segment.dateRanges.filter(keepRange);
|
|
244
|
+
if (extra.length === 0 && own.length === segment.dateRanges.length) {
|
|
245
|
+
return segment;
|
|
246
|
+
}
|
|
247
|
+
return { ...segment, dateRanges: [...extra, ...own] };
|
|
248
|
+
});
|
|
249
|
+
return {
|
|
250
|
+
segments: merged,
|
|
251
|
+
trailer: {
|
|
252
|
+
...trailer,
|
|
253
|
+
dateRanges: [
|
|
254
|
+
...(carried.get(-1) ?? []),
|
|
255
|
+
...trailer.dateRanges.filter(keepRange),
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Validates the full timeline after declarations from both playlists are
|
|
262
|
+
* joined.
|
|
263
|
+
*/
|
|
264
|
+
function checkMergedTimeline_(update, segments, trailer) {
|
|
265
|
+
const report = (code, _line, _column, message) => {
|
|
266
|
+
throw new HlsPlaylistError(code === "missing-tag"
|
|
267
|
+
? "incomplete-delta-update"
|
|
268
|
+
: "inconsistent-delta-update", message);
|
|
269
|
+
};
|
|
270
|
+
const dates = new Set();
|
|
271
|
+
let firstDateRange = 0;
|
|
272
|
+
let discontinuities = 0;
|
|
273
|
+
const known = new Map();
|
|
274
|
+
for (const [index, block] of [...segments, trailer].entries()) {
|
|
275
|
+
const position = index + 1;
|
|
276
|
+
if (block.discontinuity) {
|
|
277
|
+
discontinuities++;
|
|
278
|
+
}
|
|
279
|
+
if (block.programDateTime !== null) {
|
|
280
|
+
checkProgramDate(dates, block.programDateTime, report, position, 1);
|
|
281
|
+
}
|
|
282
|
+
if (block.dateRanges.length > 0) {
|
|
283
|
+
firstDateRange ||= position;
|
|
284
|
+
}
|
|
285
|
+
for (const range of block.dateRanges) {
|
|
286
|
+
const conflict = mergeDateRangeFields(known, range);
|
|
287
|
+
if (conflict !== null) {
|
|
288
|
+
throw new HlsPlaylistError("inconsistent-delta-update", `Two declarations of date range "${range.id}" disagree on ${conflict}`);
|
|
289
|
+
}
|
|
290
|
+
if (known.get(range.id)?.has("START-DATE") !== true) {
|
|
291
|
+
throw new HlsPlaylistError("incomplete-delta-update", `The first declaration of date range "${range.id}" has no START-DATE`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
checkDateRangeTimeline(firstDateRange, dates.size > 0, report);
|
|
296
|
+
checkSequenceBounds(update.mediaSequence, update.discontinuitySequence, segments.length, 0, discontinuities, report, 0);
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=apply-hls-delta-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-hls-delta-update.js","sourceRoot":"","sources":["../../src/live/apply-hls-delta-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oB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,MAAM,CAAC,qBAAqB,EAC5B,QAAQ,CAAC,MAAM,EACf,CAAC,EACD,eAAe,EACf,MAAM,EACN,CAAC,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HlsAttribute } from "../attribute/hls-attribute.js";
|
|
2
|
+
/** The encryption methods §4.4.4.4 defines. */
|
|
3
|
+
export type HlsKeyMethod = "NONE" | "AES-128" | "SAMPLE-AES" | "SAMPLE-AES-CTR" | "AES-256-GCM";
|
|
4
|
+
/**
|
|
5
|
+
* `EXT-X-KEY` or `EXT-X-SESSION-KEY` (§4.4.4.4, §4.4.6.5), as plain data.
|
|
6
|
+
*
|
|
7
|
+
* This package never fetches a key, never decrypts, never derives an IV from a
|
|
8
|
+
* Media Sequence Number and never resolves a key URI. An unrecognized `method`
|
|
9
|
+
* is kept as written, so a segment under it still counts as encrypted.
|
|
10
|
+
*/
|
|
11
|
+
export type HlsKey = {
|
|
12
|
+
/**
|
|
13
|
+
* As written. `""` when a lenient parse found no readable `METHOD` — absent,
|
|
14
|
+
* quoted, or `NONE` beside other attributes — in which case the raw attribute
|
|
15
|
+
* is in `unknownAttributes`: a malformed declaration never reads as clear
|
|
16
|
+
* media.
|
|
17
|
+
*/
|
|
18
|
+
readonly method: HlsKeyMethod | (string & {});
|
|
19
|
+
/** As written, after variable substitution; never resolved. */
|
|
20
|
+
readonly uri: string | null;
|
|
21
|
+
/** The hexadecimal-sequence as written, `0x` prefix included. */
|
|
22
|
+
readonly iv: string | null;
|
|
23
|
+
/** `null` means the implicit `"identity"`. */
|
|
24
|
+
readonly keyFormat: string | null;
|
|
25
|
+
/** `null` means the implicit `[1]`. */
|
|
26
|
+
readonly keyFormatVersions: readonly number[] | null;
|
|
27
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=hls-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hls-key.d.ts","sourceRoot":"","sources":["../../src/model/hls-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GACrB,MAAM,GACN,SAAS,GACT,YAAY,GACZ,gBAAgB,GAChB,aAAa,CAAC;AAEjB;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,uCAAuC;IACvC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IACrD,QAAQ,CAAC,iBAAiB,EAAE,SAAS,YAAY,EAAE,CAAC;CACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hls-key.js","sourceRoot":"","sources":["../../src/model/hls-key.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { HlsAttribute } from "../attribute/hls-attribute.js";
|
|
2
|
+
import type { HlsKey } from "./hls-key.js";
|
|
3
|
+
import type { HlsByteRange, HlsPlaylistHeader, HlsUnknownTag } from "./hls-playlist.js";
|
|
4
|
+
/** A media playlist (§4.4.3): the segments of one rendition. */
|
|
5
|
+
export type HlsMediaPlaylist = HlsPlaylistHeader & {
|
|
6
|
+
readonly kind: "media";
|
|
7
|
+
/**
|
|
8
|
+
* `EXT-X-TARGETDURATION`, seconds. A lenient parse of a playlist without it
|
|
9
|
+
* derives the largest rounded `EXTINF`, or 0 with no segment.
|
|
10
|
+
*/
|
|
11
|
+
readonly targetDuration: number;
|
|
12
|
+
/**
|
|
13
|
+
* `EXT-X-MEDIA-SEQUENCE` as written, 0 when absent: the Media Sequence Number
|
|
14
|
+
* of the first segment of the playlist. In a delta update that is the first
|
|
15
|
+
* skipped segment, so the first listed one is this plus
|
|
16
|
+
* `skip.skippedSegments`.
|
|
17
|
+
*/
|
|
18
|
+
readonly mediaSequence: number;
|
|
19
|
+
/** `EXT-X-DISCONTINUITY-SEQUENCE`, 0 when absent. */
|
|
20
|
+
readonly discontinuitySequence: number;
|
|
21
|
+
/** `EXT-X-ENDLIST`: no segment will be added. */
|
|
22
|
+
readonly endList: boolean;
|
|
23
|
+
/** `EXT-X-PLAYLIST-TYPE`. */
|
|
24
|
+
readonly playlistType: "EVENT" | "VOD" | null;
|
|
25
|
+
/** `EXT-X-I-FRAMES-ONLY`. */
|
|
26
|
+
readonly iFramesOnly: boolean;
|
|
27
|
+
/** `EXT-X-PART-INF`. */
|
|
28
|
+
readonly partInf: HlsPartInf | null;
|
|
29
|
+
/** `EXT-X-SERVER-CONTROL`. */
|
|
30
|
+
readonly serverControl: HlsServerControl | null;
|
|
31
|
+
/** `EXT-X-SKIP`: present only in a Playlist Delta Update (§6.2.5.1). */
|
|
32
|
+
readonly skip: HlsSkip | null;
|
|
33
|
+
readonly segments: readonly HlsSegment[];
|
|
34
|
+
/**
|
|
35
|
+
* What follows the last URI line: at the live edge, the partial segments and
|
|
36
|
+
* tags of the parent segment still being written.
|
|
37
|
+
*/
|
|
38
|
+
readonly trailer: HlsSegmentTags;
|
|
39
|
+
/** `EXT-X-PRELOAD-HINT`s, in source order. */
|
|
40
|
+
readonly preloadHints: readonly HlsPreloadHint[];
|
|
41
|
+
/** `EXT-X-RENDITION-REPORT`s, in source order. */
|
|
42
|
+
readonly renditionReports: readonly HlsRenditionReport[];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Everything that applies to a segment besides `EXTINF`, `EXT-X-BYTERANGE` and
|
|
46
|
+
* its URI. `map` and `bitrate` are the values in effect, however far back they
|
|
47
|
+
* were declared; keys are kept as the declarations of this block only
|
|
48
|
+
* (`keyTags`), so a playlist costs memory linear in its size however many key
|
|
49
|
+
* formats it rotates through — {@link resolveHlsSegments} gives the keys in
|
|
50
|
+
* effect.
|
|
51
|
+
*/
|
|
52
|
+
export type HlsSegmentTags = {
|
|
53
|
+
/** `EXT-X-DISCONTINUITY` before this segment. */
|
|
54
|
+
readonly discontinuity: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The `EXT-X-KEY` tags of this block, in order (§4.4.4.4): `METHOD=NONE`
|
|
57
|
+
* clears every key in effect, any other method replaces the key of the same
|
|
58
|
+
* `KEYFORMAT`. Plain data: nothing here fetches, resolves or decrypts.
|
|
59
|
+
*/
|
|
60
|
+
readonly keyTags: readonly HlsKey[];
|
|
61
|
+
/** The `EXT-X-MAP` in effect. */
|
|
62
|
+
readonly map: HlsMap | null;
|
|
63
|
+
/**
|
|
64
|
+
* `EXT-X-PROGRAM-DATE-TIME` as written; read it with {@link parseHlsDateTime},
|
|
65
|
+
* or take the extrapolated date from {@link resolveHlsSegments}.
|
|
66
|
+
*/
|
|
67
|
+
readonly programDateTime: string | null;
|
|
68
|
+
/** `EXT-X-GAP`: the segment holds no media and should not be loaded. */
|
|
69
|
+
readonly gap: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The `EXT-X-BITRATE` in effect, kbit/s. The format says it does not apply to
|
|
72
|
+
* a segment with a byte range; it is still carried there, unchanged.
|
|
73
|
+
*/
|
|
74
|
+
readonly bitrate: number | null;
|
|
75
|
+
/** `EXT-X-PART`s of this (parent) segment, in order. */
|
|
76
|
+
readonly parts: readonly HlsPart[];
|
|
77
|
+
/** `EXT-X-DATERANGE`s found in this block, in order; not consolidated by ID. */
|
|
78
|
+
readonly dateRanges: readonly HlsDateRange[];
|
|
79
|
+
/** Unmodelled or set-aside tags of this block, in order. */
|
|
80
|
+
readonly unknownTags: readonly HlsUnknownTag[];
|
|
81
|
+
};
|
|
82
|
+
/** A media segment (§3): its URI and the tags that apply to it. */
|
|
83
|
+
export type HlsSegment = HlsSegmentTags & {
|
|
84
|
+
/** The URI line as written, after variable substitution. */
|
|
85
|
+
readonly uri: string;
|
|
86
|
+
/** `EXTINF` duration, seconds; 0 when a lenient parse found no `EXTINF`. */
|
|
87
|
+
readonly duration: number;
|
|
88
|
+
/** `EXTINF` title; `null` when missing, empty or whitespace. */
|
|
89
|
+
readonly title: string | null;
|
|
90
|
+
/** `EXT-X-BYTERANGE`. */
|
|
91
|
+
readonly byteRange: HlsByteRange | null;
|
|
92
|
+
};
|
|
93
|
+
/** `EXT-X-MAP` (§4.4.4.5): the Media Initialization Section. */
|
|
94
|
+
export type HlsMap = {
|
|
95
|
+
readonly uri: string;
|
|
96
|
+
/** The offset is required in `EXT-X-MAP`. */
|
|
97
|
+
readonly byteRange: {
|
|
98
|
+
readonly length: number;
|
|
99
|
+
readonly offset: number;
|
|
100
|
+
} | null;
|
|
101
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
102
|
+
};
|
|
103
|
+
/** `EXT-X-PART-INF` (§4.4.3.7). */
|
|
104
|
+
export type HlsPartInf = {
|
|
105
|
+
/** `PART-TARGET`, seconds. */
|
|
106
|
+
readonly partTarget: number;
|
|
107
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
108
|
+
};
|
|
109
|
+
/** `EXT-X-PART` (§4.4.4.9): a partial segment. */
|
|
110
|
+
export type HlsPart = {
|
|
111
|
+
readonly uri: string;
|
|
112
|
+
/** Seconds. */
|
|
113
|
+
readonly duration: number;
|
|
114
|
+
/** `INDEPENDENT=YES`. */
|
|
115
|
+
readonly independent: boolean;
|
|
116
|
+
readonly byteRange: HlsByteRange | null;
|
|
117
|
+
/** `GAP=YES`. */
|
|
118
|
+
readonly gap: boolean;
|
|
119
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
120
|
+
};
|
|
121
|
+
/** `EXT-X-SERVER-CONTROL` (§4.4.3.8). */
|
|
122
|
+
export type HlsServerControl = {
|
|
123
|
+
/** `CAN-SKIP-UNTIL`, the Skip Boundary in seconds. */
|
|
124
|
+
readonly canSkipUntil: number | null;
|
|
125
|
+
/** `CAN-SKIP-DATERANGES=YES`. */
|
|
126
|
+
readonly canSkipDateRanges: boolean;
|
|
127
|
+
/** `HOLD-BACK`, seconds; `null` means three target durations. */
|
|
128
|
+
readonly holdBack: number | null;
|
|
129
|
+
/** `PART-HOLD-BACK`, seconds. */
|
|
130
|
+
readonly partHoldBack: number | null;
|
|
131
|
+
/** `CAN-BLOCK-RELOAD=YES`. */
|
|
132
|
+
readonly canBlockReload: boolean;
|
|
133
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
134
|
+
};
|
|
135
|
+
/** `EXT-X-SKIP` (§4.4.5.2). */
|
|
136
|
+
export type HlsSkip = {
|
|
137
|
+
/** `SKIPPED-SEGMENTS`. */
|
|
138
|
+
readonly skippedSegments: number;
|
|
139
|
+
/**
|
|
140
|
+
* `RECENTLY-REMOVED-DATERANGES` split at tabs; `null` when absent, which
|
|
141
|
+
* means the update did not skip date ranges.
|
|
142
|
+
*/
|
|
143
|
+
readonly recentlyRemovedDateRanges: readonly string[] | null;
|
|
144
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
145
|
+
};
|
|
146
|
+
/** `EXT-X-PRELOAD-HINT` (§4.4.5.3). */
|
|
147
|
+
export type HlsPreloadHint = {
|
|
148
|
+
readonly type: "PART" | "MAP";
|
|
149
|
+
readonly uri: string;
|
|
150
|
+
/** `BYTERANGE-START`; `null` means 0. */
|
|
151
|
+
readonly byteRangeStart: number | null;
|
|
152
|
+
/** `BYTERANGE-LENGTH`; `null` means to the end of the resource. */
|
|
153
|
+
readonly byteRangeLength: number | null;
|
|
154
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* `EXT-X-RENDITION-REPORT` (§4.4.5.4). A server may omit even a required
|
|
158
|
+
* attribute, so the numbers are nullable.
|
|
159
|
+
*/
|
|
160
|
+
export type HlsRenditionReport = {
|
|
161
|
+
readonly uri: string;
|
|
162
|
+
/** `LAST-MSN`. */
|
|
163
|
+
readonly lastMsn: number | null;
|
|
164
|
+
/** `LAST-PART`. */
|
|
165
|
+
readonly lastPart: number | null;
|
|
166
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
167
|
+
};
|
|
168
|
+
/** The Trigger Identifiers §4.4.5.1 defines for `CUE`. */
|
|
169
|
+
export type HlsCueTrigger = "PRE" | "POST" | "ONCE";
|
|
170
|
+
/** `EXT-X-DATERANGE` (§4.4.5.1). */
|
|
171
|
+
export type HlsDateRange = {
|
|
172
|
+
readonly id: string;
|
|
173
|
+
readonly class: string | null;
|
|
174
|
+
/** ISO 8601 text as written; read it with {@link parseHlsDateTime}. */
|
|
175
|
+
readonly startDate: string | null;
|
|
176
|
+
/** ISO 8601 text as written. */
|
|
177
|
+
readonly endDate: string | null;
|
|
178
|
+
/**
|
|
179
|
+
* `CUE`, every identifier as written: the format says to ignore an
|
|
180
|
+
* unrecognized one, so it is kept for the caller to skip.
|
|
181
|
+
*/
|
|
182
|
+
readonly cue: readonly (HlsCueTrigger | (string & {}))[];
|
|
183
|
+
/** `DURATION`, seconds. */
|
|
184
|
+
readonly duration: number | null;
|
|
185
|
+
/** `PLANNED-DURATION`, seconds. */
|
|
186
|
+
readonly plannedDuration: number | null;
|
|
187
|
+
/** `END-ON-NEXT=YES`. */
|
|
188
|
+
readonly endOnNext: boolean;
|
|
189
|
+
/** `SCTE35-CMD`, the hexadecimal-sequence as written. */
|
|
190
|
+
readonly scte35Cmd: string | null;
|
|
191
|
+
/** `SCTE35-OUT`, the hexadecimal-sequence as written. */
|
|
192
|
+
readonly scte35Out: string | null;
|
|
193
|
+
/** `SCTE35-IN`, the hexadecimal-sequence as written. */
|
|
194
|
+
readonly scte35In: string | null;
|
|
195
|
+
/**
|
|
196
|
+
* `X-` attributes in source order, quoted and hexadecimal values substituted;
|
|
197
|
+
* interstitials (Appendix D) live here.
|
|
198
|
+
*/
|
|
199
|
+
readonly clientAttributes: readonly HlsAttribute[];
|
|
200
|
+
readonly unknownAttributes: readonly HlsAttribute[];
|
|
201
|
+
};
|
|
202
|
+
//# sourceMappingURL=hls-media-playlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hls-media-playlist.d.ts","sourceRoot":"","sources":["../../src/model/hls-media-playlist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EACX,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,MAAM,mBAAmB,CAAC;AAE3B,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG;IAClD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,qDAAqD;IACrD,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;IAC9C,6BAA6B;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,wBAAwB;IACxB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,8BAA8B;IAC9B,QAAQ,CAAC,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAChD,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,C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