@skax/hls-parse 0.0.1-beta.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/LICENSE +21 -0
- package/README.md +271 -0
- package/dist/index.esm.js +6 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +6 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/index.d.ts +1102 -0
- package/package.json +68 -0
|
@@ -0,0 +1,1102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HLS Playlist Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* All types conforming to {@link https://datatracker.ietf.org/doc/html/rfc8216 | RFC 8216}
|
|
5
|
+
* (HTTP Live Streaming) and LL-HLS (Low-Latency HLS) extensions.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* All URIs in these types will be resolved to absolute when
|
|
9
|
+
* {@link ParseOptions.uri} is provided to {@link parse}.
|
|
10
|
+
*
|
|
11
|
+
* @module types
|
|
12
|
+
* @category Types
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Media Initialization Section.
|
|
16
|
+
*
|
|
17
|
+
* Corresponds to the `#EXT-X-MAP` tag.
|
|
18
|
+
* Contains the URI and optional byte range of the initialization resource
|
|
19
|
+
* required to parse applicable Media Segments.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.5 | RFC 8216 §4.3.2.5}
|
|
22
|
+
*/
|
|
23
|
+
interface MediaInitializationSection {
|
|
24
|
+
/** Whether this is a preload hint (LL-HLS). */
|
|
25
|
+
hint?: boolean;
|
|
26
|
+
/** URI to the initialization section resource. */
|
|
27
|
+
uri: string;
|
|
28
|
+
/** Byte range within the resource. */
|
|
29
|
+
byterange?: Byterange;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Byte range specification.
|
|
33
|
+
*
|
|
34
|
+
* Corresponds to the `#EXT-X-BYTERANGE` tag value.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* When `offset` is `-1` it indicates the sub-range begins at the next byte
|
|
38
|
+
* following the sub-range of the previous Media Segment.
|
|
39
|
+
*
|
|
40
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.2 | RFC 8216 §4.3.2.2}
|
|
41
|
+
*/
|
|
42
|
+
interface Byterange {
|
|
43
|
+
/** Length of the byte range in bytes. */
|
|
44
|
+
length: number;
|
|
45
|
+
/**
|
|
46
|
+
* Start offset in bytes.
|
|
47
|
+
*
|
|
48
|
+
* @defaultValue `-1` (implicit offset)
|
|
49
|
+
*/
|
|
50
|
+
offset: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Display resolution.
|
|
54
|
+
*
|
|
55
|
+
* Corresponds to the `RESOLUTION` attribute value.
|
|
56
|
+
*
|
|
57
|
+
* @example `{ width: 1920, height: 1080 }` for `RESOLUTION=1920x1080`
|
|
58
|
+
*/
|
|
59
|
+
interface Resolution {
|
|
60
|
+
/** Horizontal pixel dimension. */
|
|
61
|
+
width: number;
|
|
62
|
+
/** Vertical pixel dimension. */
|
|
63
|
+
height: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Encryption / decryption key.
|
|
67
|
+
*
|
|
68
|
+
* Corresponds to `#EXT-X-KEY` and `#EXT-X-SESSION-KEY` tags.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.4 | RFC 8216 §4.3.2.4}
|
|
71
|
+
*/
|
|
72
|
+
interface Key {
|
|
73
|
+
/**
|
|
74
|
+
* Encryption method.
|
|
75
|
+
*
|
|
76
|
+
* @remarks Valid values: `"NONE"`, `"AES-128"`, `"SAMPLE-AES"`.
|
|
77
|
+
*/
|
|
78
|
+
method: string;
|
|
79
|
+
/** URI to obtain the key file. */
|
|
80
|
+
uri?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Initialization Vector.
|
|
83
|
+
*
|
|
84
|
+
* @remarks Must be exactly 128 bits (16 bytes) when present.
|
|
85
|
+
*/
|
|
86
|
+
iv?: Uint8Array;
|
|
87
|
+
/**
|
|
88
|
+
* Key format identifier.
|
|
89
|
+
*
|
|
90
|
+
* @defaultValue `"identity"`
|
|
91
|
+
*/
|
|
92
|
+
format?: string;
|
|
93
|
+
/** Key format version(s), separated by `/`. */
|
|
94
|
+
formatVersion?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parsed `#EXTINF` tag data.
|
|
98
|
+
*
|
|
99
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.1 | RFC 8216 §4.3.2.1}
|
|
100
|
+
*/
|
|
101
|
+
interface ExtInfo {
|
|
102
|
+
/** Segment duration in seconds. */
|
|
103
|
+
duration: number;
|
|
104
|
+
/** Optional human-readable title. */
|
|
105
|
+
title?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Partial segment for Low-Latency HLS.
|
|
109
|
+
*
|
|
110
|
+
* Corresponds to `#EXT-X-PART` and `#EXT-X-PRELOAD-HINT` (TYPE=PART) tags.
|
|
111
|
+
*
|
|
112
|
+
* @beta LL-HLS feature
|
|
113
|
+
*/
|
|
114
|
+
interface PartialSegment {
|
|
115
|
+
/** Whether this is a preload hint (`#EXT-X-PRELOAD-HINT`). */
|
|
116
|
+
hint?: boolean;
|
|
117
|
+
/** URI to the partial segment. */
|
|
118
|
+
uri: string;
|
|
119
|
+
/** Byte range within the resource. */
|
|
120
|
+
byterange?: Byterange;
|
|
121
|
+
/** Duration in seconds. */
|
|
122
|
+
duration?: number;
|
|
123
|
+
/** Whether this segment can be decoded independently. */
|
|
124
|
+
independent?: boolean;
|
|
125
|
+
/** Whether this segment is a gap. */
|
|
126
|
+
gap?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Prefetch segment for Low-Latency HLS.
|
|
130
|
+
*
|
|
131
|
+
* Corresponds to the `#EXT-X-PREFETCH` tag.
|
|
132
|
+
*
|
|
133
|
+
* @beta LL-HLS feature
|
|
134
|
+
*/
|
|
135
|
+
interface PrefetchSegment {
|
|
136
|
+
/** URI of the prefetch segment. */
|
|
137
|
+
uri: string;
|
|
138
|
+
/** Media Sequence Number. */
|
|
139
|
+
mediaSequenceNumber: number;
|
|
140
|
+
/** Discontinuity Sequence Number. */
|
|
141
|
+
discontinuitySequence: number;
|
|
142
|
+
/** Whether this segment indicates a discontinuity. */
|
|
143
|
+
discontinuity?: boolean;
|
|
144
|
+
/** Encryption key (inherited from previous segment if not specified). */
|
|
145
|
+
key?: Key | null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Media Segment.
|
|
149
|
+
*
|
|
150
|
+
* Represents a single segment in a Media Playlist, including all associated tags
|
|
151
|
+
* (`#EXTINF`, `#EXT-X-KEY`, `#EXT-X-MAP`, `#EXT-X-BYTERANGE`, etc.).
|
|
152
|
+
*/
|
|
153
|
+
interface Segment {
|
|
154
|
+
/** URI of the media segment. */
|
|
155
|
+
uri: string;
|
|
156
|
+
/** Duration in seconds (from `#EXTINF`). */
|
|
157
|
+
duration?: number;
|
|
158
|
+
/** Optional title (from `#EXTINF`). */
|
|
159
|
+
title?: string;
|
|
160
|
+
/** Byte range within the resource (from `#EXT-X-BYTERANGE`). */
|
|
161
|
+
byterange?: Byterange;
|
|
162
|
+
/** Media Sequence Number. */
|
|
163
|
+
mediaSequenceNumber: number;
|
|
164
|
+
/** Discontinuity Sequence Number. */
|
|
165
|
+
discontinuitySequence: number;
|
|
166
|
+
/** Whether this segment is a discontinuity (`#EXT-X-DISCONTINUITY`). */
|
|
167
|
+
discontinuity?: boolean;
|
|
168
|
+
/** Whether this segment is a gap (`#EXT-X-GAP`). */
|
|
169
|
+
gap?: boolean;
|
|
170
|
+
/** Encryption key (`#EXT-X-KEY`). Inherited if not present. */
|
|
171
|
+
key?: Key | null;
|
|
172
|
+
/** Media Initialization Section (`#EXT-X-MAP`). Inherited if not present. */
|
|
173
|
+
map?: MediaInitializationSection | null;
|
|
174
|
+
/** Program date/time (`#EXT-X-PROGRAM-DATE-TIME`). */
|
|
175
|
+
programDateTime?: Date;
|
|
176
|
+
/** Date range metadata (`#EXT-X-DATERANGE`). */
|
|
177
|
+
dateRange?: DateRange;
|
|
178
|
+
/** Splice / marker information. */
|
|
179
|
+
markers?: SpliceInfo[];
|
|
180
|
+
/** Partial segments (LL-HLS `#EXT-X-PART` / `#EXT-X-PRELOAD-HINT`). */
|
|
181
|
+
parts?: PartialSegment[];
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Date Range metadata.
|
|
185
|
+
*
|
|
186
|
+
* Corresponds to the `#EXT-X-DATERANGE` tag.
|
|
187
|
+
*
|
|
188
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.7 | RFC 8216 §4.3.2.7}
|
|
189
|
+
*/
|
|
190
|
+
interface DateRange {
|
|
191
|
+
/** Unique identifier. */
|
|
192
|
+
id: string;
|
|
193
|
+
/** CLASS name grouping ranges with shared semantics. */
|
|
194
|
+
classId?: string;
|
|
195
|
+
/** Start date/time. */
|
|
196
|
+
start: Date;
|
|
197
|
+
/** Cue information. */
|
|
198
|
+
cue?: string;
|
|
199
|
+
/** End date/time. */
|
|
200
|
+
end?: Date;
|
|
201
|
+
/** Duration in seconds. */
|
|
202
|
+
duration?: number;
|
|
203
|
+
/** Expected duration (when actual is not yet known). */
|
|
204
|
+
plannedDuration?: number;
|
|
205
|
+
/**
|
|
206
|
+
* Whether this range ends at the start of the next range of the same CLASS.
|
|
207
|
+
*
|
|
208
|
+
* @remarks Cannot coexist with `duration` or `end`.
|
|
209
|
+
*/
|
|
210
|
+
endOnNext?: boolean;
|
|
211
|
+
/** Custom attributes (SCTE35- and X- prefixed). */
|
|
212
|
+
attributes?: Record<string, any>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Splice / marker information.
|
|
216
|
+
*
|
|
217
|
+
* Carried by `#EXT-X-CUE-OUT`, `#EXT-X-CUE-IN`, and raw SCTE-35 tags.
|
|
218
|
+
*/
|
|
219
|
+
interface SpliceInfo {
|
|
220
|
+
/** Marker type. */
|
|
221
|
+
type: "OUT" | "IN" | "RAW";
|
|
222
|
+
/** Duration in seconds (for `OUT` type). */
|
|
223
|
+
duration?: number;
|
|
224
|
+
/** Original tag name (for `RAW` type). */
|
|
225
|
+
tagName?: string;
|
|
226
|
+
/** Raw tag value. */
|
|
227
|
+
value?: any;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Alternative Rendition.
|
|
231
|
+
*
|
|
232
|
+
* Corresponds to the `#EXT-X-MEDIA` tag.
|
|
233
|
+
*
|
|
234
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.1 | RFC 8216 §4.3.4.1}
|
|
235
|
+
*/
|
|
236
|
+
interface Rendition {
|
|
237
|
+
/** Media type: `"AUDIO"`, `"VIDEO"`, `"SUBTITLES"`, or `"CLOSED-CAPTIONS"`. */
|
|
238
|
+
type: string;
|
|
239
|
+
/** URI of the media playlist (optional for AUDIO/VIDEO). */
|
|
240
|
+
uri?: string;
|
|
241
|
+
/** Rendition group ID. */
|
|
242
|
+
groupId: string;
|
|
243
|
+
/** Primary language (RFC 5646 tag). */
|
|
244
|
+
language?: string;
|
|
245
|
+
/** Associated language (RFC 5646 tag). */
|
|
246
|
+
assocLanguage?: string;
|
|
247
|
+
/** Human-readable name. */
|
|
248
|
+
name: string;
|
|
249
|
+
/** Whether this is the default rendition. */
|
|
250
|
+
isDefault?: boolean;
|
|
251
|
+
/** Whether this can be auto-selected. */
|
|
252
|
+
autoselect?: boolean;
|
|
253
|
+
/** Whether this is forced (SUBTITLES only). */
|
|
254
|
+
forced?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* In-stream ID.
|
|
257
|
+
*
|
|
258
|
+
* @remarks Required when `type` is `"CLOSED-CAPTIONS"`.
|
|
259
|
+
* Valid: `"CC1"`-`"CC4"`, `"SERVICE1"`-`"SERVICE63"`.
|
|
260
|
+
*/
|
|
261
|
+
instreamId?: string;
|
|
262
|
+
/** Uniform Type Identifiers (UTIs), comma-separated. */
|
|
263
|
+
characteristics?: string;
|
|
264
|
+
/** Audio channel count and parameters. */
|
|
265
|
+
channels?: string;
|
|
266
|
+
/** Pathway ID for content steering. */
|
|
267
|
+
pathwayId?: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Variant Stream.
|
|
271
|
+
*
|
|
272
|
+
* Corresponds to `#EXT-X-STREAM-INF` or `#EXT-X-I-FRAME-STREAM-INF`.
|
|
273
|
+
*
|
|
274
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.2 | RFC 8216 §4.3.4.2}
|
|
275
|
+
*/
|
|
276
|
+
interface Variant {
|
|
277
|
+
/** URI of the media playlist. */
|
|
278
|
+
uri: string;
|
|
279
|
+
/** Peak bit rate in bits per second. */
|
|
280
|
+
bandwidth: number;
|
|
281
|
+
/** Average bit rate in bits per second. */
|
|
282
|
+
averageBandwidth?: number;
|
|
283
|
+
/**
|
|
284
|
+
* Variant SCORE (LL-HLS), used for prioritised playlist reload.
|
|
285
|
+
*
|
|
286
|
+
* @remarks If any variant has a SCORE, all variants SHOULD have one.
|
|
287
|
+
*/
|
|
288
|
+
score?: number;
|
|
289
|
+
/** Codec identifiers (RFC 6381). */
|
|
290
|
+
codecs?: string;
|
|
291
|
+
/** Optimal display resolution. */
|
|
292
|
+
resolution?: Resolution;
|
|
293
|
+
/** Maximum frame rate (rounded to 3 decimal places). */
|
|
294
|
+
frameRate?: number;
|
|
295
|
+
/** HDCP level: `"TYPE-0"` or `"NONE"`. */
|
|
296
|
+
hdcpLevel?: string;
|
|
297
|
+
/** Allowed Content Protection Configurations. */
|
|
298
|
+
allowedCpc?: AllowedCpc[];
|
|
299
|
+
/** Video range: `"SDR"`, `"HLG"`, or `"PQ"`. */
|
|
300
|
+
videoRange?: string;
|
|
301
|
+
/** Stable variant identifier. */
|
|
302
|
+
stableVariantId?: string;
|
|
303
|
+
/** Pathway ID for content steering. */
|
|
304
|
+
pathwayId?: string;
|
|
305
|
+
/** Program ID.
|
|
306
|
+
*
|
|
307
|
+
* @deprecated Removed in protocol version 6.
|
|
308
|
+
*/
|
|
309
|
+
programId?: number;
|
|
310
|
+
/** Whether this is an I-frame variant (`#EXT-X-I-FRAME-STREAM-INF`). */
|
|
311
|
+
isIFrameOnly?: boolean;
|
|
312
|
+
/** Audio renditions matching this variant's GROUP-ID. */
|
|
313
|
+
audio?: Rendition[];
|
|
314
|
+
/** Video renditions matching this variant's GROUP-ID. */
|
|
315
|
+
video?: Rendition[];
|
|
316
|
+
/** Subtitle renditions matching this variant's GROUP-ID. */
|
|
317
|
+
subtitles?: Rendition[];
|
|
318
|
+
/** Closed-caption renditions matching this variant's GROUP-ID. */
|
|
319
|
+
closedCaptions?: Rendition[];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Allowed Content Protection Configuration entry.
|
|
323
|
+
*
|
|
324
|
+
* Part of the `ALLOWED-CPC` attribute value.
|
|
325
|
+
*/
|
|
326
|
+
interface AllowedCpc {
|
|
327
|
+
/** Content protection format identifier. */
|
|
328
|
+
format: string;
|
|
329
|
+
/** List of Content Protection Configurations. */
|
|
330
|
+
cpcList: string[];
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Session Data.
|
|
334
|
+
*
|
|
335
|
+
* Corresponds to the `#EXT-X-SESSION-DATA` tag.
|
|
336
|
+
*
|
|
337
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.4 | RFC 8216 §4.3.4.4}
|
|
338
|
+
*/
|
|
339
|
+
interface SessionData {
|
|
340
|
+
/** Data identifier (reverse-DNS recommended). */
|
|
341
|
+
id: string;
|
|
342
|
+
/** Inline value (mutually exclusive with `uri`). */
|
|
343
|
+
value?: string;
|
|
344
|
+
/** URI to a JSON resource (mutually exclusive with `value`). */
|
|
345
|
+
uri?: string;
|
|
346
|
+
/** Language of the value (RFC 5646 tag). */
|
|
347
|
+
language?: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Content Steering configuration.
|
|
351
|
+
*
|
|
352
|
+
* Corresponds to the `#EXT-X-CONTENT-STEERING` tag.
|
|
353
|
+
*/
|
|
354
|
+
interface ContentSteering {
|
|
355
|
+
/** Server URI for the steering manifest. */
|
|
356
|
+
serverUri: string;
|
|
357
|
+
/** Pathway ID to use. */
|
|
358
|
+
pathwayId?: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Rendition Report for Low-Latency HLS.
|
|
362
|
+
*
|
|
363
|
+
* Corresponds to the `#EXT-X-RENDITION-REPORT` tag.
|
|
364
|
+
*
|
|
365
|
+
* @beta LL-HLS feature
|
|
366
|
+
*/
|
|
367
|
+
interface RenditionReport {
|
|
368
|
+
/** URI of the rendition playlist (must be relative). */
|
|
369
|
+
uri: string;
|
|
370
|
+
/** Last Media Sequence Number. */
|
|
371
|
+
lastMSN?: number;
|
|
372
|
+
/** Last Part index. */
|
|
373
|
+
lastPart?: number;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Preferred start position.
|
|
377
|
+
*
|
|
378
|
+
* Corresponds to the `#EXT-X-START` tag.
|
|
379
|
+
*
|
|
380
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.5.2 | RFC 8216 §4.3.5.2}
|
|
381
|
+
*/
|
|
382
|
+
interface StartData {
|
|
383
|
+
/**
|
|
384
|
+
* Time offset in seconds.
|
|
385
|
+
*
|
|
386
|
+
* @remarks Positive = from beginning, negative = from end.
|
|
387
|
+
*/
|
|
388
|
+
offset: number;
|
|
389
|
+
/**
|
|
390
|
+
* Whether to precisely seek to the TIME-OFFSET.
|
|
391
|
+
*
|
|
392
|
+
* @defaultValue `false`
|
|
393
|
+
*/
|
|
394
|
+
precise?: boolean;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Low-Latency HLS server control parameters.
|
|
398
|
+
*
|
|
399
|
+
* Corresponds to the `#EXT-X-SERVER-CONTROL` tag.
|
|
400
|
+
*
|
|
401
|
+
* @beta LL-HLS feature
|
|
402
|
+
*/
|
|
403
|
+
interface LowLatencyCompatibility {
|
|
404
|
+
/** Whether block reload is supported. */
|
|
405
|
+
canBlockReload: boolean;
|
|
406
|
+
/** Maximum skip duration in seconds. */
|
|
407
|
+
canSkipUntil?: number;
|
|
408
|
+
/** Minimum hold-back time in seconds. */
|
|
409
|
+
holdBack?: number;
|
|
410
|
+
/** Minimum part hold-back time in seconds. */
|
|
411
|
+
partHoldBack?: number;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* User-defined attribute value.
|
|
415
|
+
*
|
|
416
|
+
* @internal
|
|
417
|
+
*/
|
|
418
|
+
type UserAttribute = string | number | Uint8Array;
|
|
419
|
+
/**
|
|
420
|
+
* Master Playlist.
|
|
421
|
+
*
|
|
422
|
+
* Contains variant streams and renditions for adaptive bitrate streaming.
|
|
423
|
+
*
|
|
424
|
+
* @remarks
|
|
425
|
+
* Type discriminator: `isMasterPlaylist === true`.
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```ts
|
|
429
|
+
* import { parse } from '@skax/hls-parse';
|
|
430
|
+
* const pl = parse(m3u8Content) as MasterPlaylist;
|
|
431
|
+
* for (const v of pl.variants) {
|
|
432
|
+
* console.log(v.bandwidth, v.uri);
|
|
433
|
+
* }
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
interface MasterPlaylist {
|
|
437
|
+
/** Type discriminator — always `true` for Master Playlist. */
|
|
438
|
+
isMasterPlaylist: true;
|
|
439
|
+
/** The raw playlist source text. */
|
|
440
|
+
source?: string;
|
|
441
|
+
/** Protocol compatibility version. */
|
|
442
|
+
version?: number;
|
|
443
|
+
/** Whether independent segments are signaled. */
|
|
444
|
+
independentSegments?: boolean;
|
|
445
|
+
/** Preferred start position. */
|
|
446
|
+
start?: StartData;
|
|
447
|
+
/** Content steering configuration. */
|
|
448
|
+
contentSteering?: ContentSteering;
|
|
449
|
+
/** Variable definitions (`#EXT-X-DEFINE`). */
|
|
450
|
+
defines?: Record<string, any>[];
|
|
451
|
+
/** Session data entries. */
|
|
452
|
+
sessionDataList: SessionData[];
|
|
453
|
+
/** Session keys. */
|
|
454
|
+
sessionKeyList: Key[];
|
|
455
|
+
/** Variant streams (`#EXT-X-STREAM-INF` / `#EXT-X-I-FRAME-STREAM-INF`). */
|
|
456
|
+
variants: Variant[];
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Media Playlist.
|
|
460
|
+
*
|
|
461
|
+
* Contains segments and metadata for sequential playback.
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
* Type discriminator: `isMasterPlaylist === false`.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```ts
|
|
468
|
+
* import { parse } from '@skax/hls-parse';
|
|
469
|
+
* const pl = parse(m3u8Content) as MediaPlaylist;
|
|
470
|
+
* for (const seg of pl.segments) {
|
|
471
|
+
* console.log(seg.uri, seg.duration);
|
|
472
|
+
* }
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
interface MediaPlaylist {
|
|
476
|
+
/** Type discriminator — always `false` for Media Playlist. */
|
|
477
|
+
isMasterPlaylist: false;
|
|
478
|
+
/** The raw playlist source text. */
|
|
479
|
+
source?: string;
|
|
480
|
+
/** Protocol compatibility version. */
|
|
481
|
+
version?: number;
|
|
482
|
+
/** Whether independent segments are signaled. */
|
|
483
|
+
independentSegments?: boolean;
|
|
484
|
+
/** Preferred start position. */
|
|
485
|
+
start?: StartData;
|
|
486
|
+
/** Variable definitions (`#EXT-X-DEFINE`). */
|
|
487
|
+
defines?: Record<string, any>[];
|
|
488
|
+
/** Maximum segment duration in seconds (`#EXT-X-TARGETDURATION`). */
|
|
489
|
+
targetDuration?: number;
|
|
490
|
+
/** Base media sequence number. */
|
|
491
|
+
mediaSequenceBase?: number;
|
|
492
|
+
/** Base discontinuity sequence number. */
|
|
493
|
+
discontinuitySequenceBase?: number;
|
|
494
|
+
/** Whether the playlist is complete (`#EXT-X-ENDLIST`). */
|
|
495
|
+
endlist?: boolean;
|
|
496
|
+
/** Playlist type: `"EVENT"` or `"VOD"`. */
|
|
497
|
+
playlistType?: string;
|
|
498
|
+
/** Whether this is an I-frame only playlist. */
|
|
499
|
+
isIFrame?: boolean;
|
|
500
|
+
/** LL-HLS server control parameters. */
|
|
501
|
+
lowLatencyCompatibility?: LowLatencyCompatibility;
|
|
502
|
+
/** Partial segment target duration (LL-HLS). */
|
|
503
|
+
partTargetDuration?: number;
|
|
504
|
+
/** Bitrate of the media playlist in bps (RFC 8216bis EXT-X-BITRATE). */
|
|
505
|
+
bitrate?: number;
|
|
506
|
+
/** Number of skipped segments (LL-HLS `#EXT-X-SKIP`). */
|
|
507
|
+
skip?: number;
|
|
508
|
+
/** Media segments. */
|
|
509
|
+
segments: Segment[];
|
|
510
|
+
/** Prefetch segments (LL-HLS). */
|
|
511
|
+
prefetchSegments: PrefetchSegment[];
|
|
512
|
+
/** Rendition reports (LL-HLS). */
|
|
513
|
+
renditionReports: RenditionReport[];
|
|
514
|
+
/** Date ranges in the playlist. */
|
|
515
|
+
dateRanges: DateRange[];
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Union type for any parsed playlist.
|
|
519
|
+
*
|
|
520
|
+
* @remarks
|
|
521
|
+
* Use the `isMasterPlaylist` discriminator to narrow the type:
|
|
522
|
+
* ```ts
|
|
523
|
+
* if (pl.isMasterPlaylist) {
|
|
524
|
+
* // pl is MasterPlaylist
|
|
525
|
+
* } else {
|
|
526
|
+
* // pl is MediaPlaylist
|
|
527
|
+
* }
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
type Playlist = MasterPlaylist | MediaPlaylist;
|
|
531
|
+
/**
|
|
532
|
+
* Options for the {@link parse} function.
|
|
533
|
+
*/
|
|
534
|
+
interface ParseOptions {
|
|
535
|
+
/**
|
|
536
|
+
* Base URI for resolving relative URLs in the playlist.
|
|
537
|
+
*
|
|
538
|
+
* @remarks
|
|
539
|
+
* If provided, all relative URIs (segment URIs, key URIs, map URIs,
|
|
540
|
+
* variant URIs, etc.) will be resolved to absolute URLs.
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```ts
|
|
544
|
+
* const pl = parse(m3u8, { uri: 'https://example.com/hls/main.m3u8' });
|
|
545
|
+
* // pl.segments[0].uri → 'https://example.com/hls/segment.ts'
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
uri?: string;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Type guard: returns `true` if the parsed playlist is a Master Playlist.
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```ts
|
|
555
|
+
* const pl = parse(m3u8);
|
|
556
|
+
* if (isMasterPlaylist(pl)) {
|
|
557
|
+
* pl.variants; // ← narrowed to MasterPlaylist
|
|
558
|
+
* }
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
declare function isMasterPlaylist(pl: Playlist): pl is MasterPlaylist;
|
|
562
|
+
/**
|
|
563
|
+
* Type guard: returns `true` if the parsed playlist is a Media Playlist.
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```ts
|
|
567
|
+
* const pl = parse(m3u8);
|
|
568
|
+
* if (isMediaPlaylist(pl)) {
|
|
569
|
+
* pl.segments; // ← narrowed to MediaPlaylist
|
|
570
|
+
* }
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
573
|
+
declare function isMediaPlaylist(pl: Playlist): pl is MediaPlaylist;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* HLS / M3U8 Playlist Parser
|
|
577
|
+
*
|
|
578
|
+
* Parses M3U8 playlists according to RFC 8216 (HTTP Live Streaming),
|
|
579
|
+
* including support for:
|
|
580
|
+
* - Master Playlists (EXT-X-STREAM-INF, EXT-X-I-FRAME-STREAM-INF, etc.)
|
|
581
|
+
* - Media Playlists (Media Segments, Encryption Keys, etc.)
|
|
582
|
+
* - LL-HLS / Low-Latency HLS (EXT-X-PART, EXT-X-PRELOAD-HINT,
|
|
583
|
+
* EXT-X-SERVER-CONTROL, EXT-X-SKIP, EXT-X-RENDITION-REPORT, etc.)
|
|
584
|
+
* - Relative URL resolution
|
|
585
|
+
* - Automatic protocol version detection
|
|
586
|
+
* - Variable substitution (EXT-X-DEFINE)
|
|
587
|
+
*
|
|
588
|
+
* Usage:
|
|
589
|
+
* import { parse } from '@skax/hls-parse';
|
|
590
|
+
* const playlist = parse(m3u8Content);
|
|
591
|
+
* // With URL resolution:
|
|
592
|
+
* const playlist = parse(m3u8Content, { uri: 'https://example.com/playlist.m3u8' });
|
|
593
|
+
*
|
|
594
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8216
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Parses an M3U8 playlist string into a structured object.
|
|
599
|
+
*
|
|
600
|
+
* Automatically detects whether the playlist is a Master Playlist or
|
|
601
|
+
* Media Playlist and parses accordingly.
|
|
602
|
+
*
|
|
603
|
+
* @param text - The raw M3U8 playlist content as a string
|
|
604
|
+
* @param options - Optional parsing options
|
|
605
|
+
* @param options.uri - Base URI for resolving relative URLs in the playlist
|
|
606
|
+
* @returns A structured MasterPlaylist or MediaPlaylist object
|
|
607
|
+
*
|
|
608
|
+
* @throws {InvalidPlaylistError} If the playlist violates RFC 8216 syntax rules
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* import { parse } from '@skax/hls-parse';
|
|
613
|
+
*
|
|
614
|
+
* // Parse a simple media playlist
|
|
615
|
+
* const media = parse(`#EXTM3U
|
|
616
|
+
* #EXT-X-TARGETDURATION:10
|
|
617
|
+
* #EXTINF:9.009,
|
|
618
|
+
* segment1.ts
|
|
619
|
+
* #EXTINF:9.009,
|
|
620
|
+
* segment2.ts
|
|
621
|
+
* #EXT-X-ENDLIST`);
|
|
622
|
+
*
|
|
623
|
+
* // Parse with relative URL resolution
|
|
624
|
+
* const master = parse(m3u8Content, {
|
|
625
|
+
* uri: 'https://example.com/path/to/playlist.m3u8'
|
|
626
|
+
* });
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
declare function parse(text: string, options?: ParseOptions): MasterPlaylist | MediaPlaylist;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Utility functions for HLS parsing.
|
|
633
|
+
*
|
|
634
|
+
* @module utils
|
|
635
|
+
* @category Internal
|
|
636
|
+
* @internal
|
|
637
|
+
*/
|
|
638
|
+
/**
|
|
639
|
+
* Custom error class for invalid playlist parsing.
|
|
640
|
+
*
|
|
641
|
+
* Thrown by {@link parse} when a playlist violates RFC 8216 syntax rules.
|
|
642
|
+
* Extends the standard `Error` class.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```ts
|
|
646
|
+
* try {
|
|
647
|
+
* parse(m3u8);
|
|
648
|
+
* } catch (e) {
|
|
649
|
+
* if (e instanceof InvalidPlaylistError) {
|
|
650
|
+
* console.log(e.message);
|
|
651
|
+
* }
|
|
652
|
+
* }
|
|
653
|
+
* ```
|
|
654
|
+
*/
|
|
655
|
+
declare class InvalidPlaylistError extends Error {
|
|
656
|
+
constructor(message: string);
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Resolves a relative URI against a base URI.
|
|
660
|
+
*
|
|
661
|
+
* If the URI is absolute (has a scheme), it is returned as-is.
|
|
662
|
+
* If no base URI is provided, the URI is returned as-is.
|
|
663
|
+
* Supports `http://`, `https://`, and other standard schemes.
|
|
664
|
+
*
|
|
665
|
+
* @param base - The base URI for resolution, or `undefined`
|
|
666
|
+
* @param relative - The relative URI to resolve
|
|
667
|
+
* @returns The resolved absolute URI, or the original if already absolute
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```ts
|
|
671
|
+
* resolveUrl('https://example.com/dir/playlist.m3u8', 'segment.ts');
|
|
672
|
+
* // 'https://example.com/dir/segment.ts'
|
|
673
|
+
*
|
|
674
|
+
* resolveUrl(undefined, 'segment.ts');
|
|
675
|
+
* // 'segment.ts' (no base, returned as-is)
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
declare function resolveUrl(base: string | undefined, relative: string): string;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* HLS Tag 常量定义
|
|
682
|
+
*
|
|
683
|
+
* 所有 M3U8 / HLS 标签名称的统一常量。
|
|
684
|
+
* 每个 tag 附带中英双语文档注释,
|
|
685
|
+
* 使用时通过 `TAGS.TAG_NAME` 引用,避免硬编码字符串。
|
|
686
|
+
*
|
|
687
|
+
* @module constants
|
|
688
|
+
* @category Types
|
|
689
|
+
*
|
|
690
|
+
* @example
|
|
691
|
+
* ```ts
|
|
692
|
+
* import { TAGS } from '@skax/hls-parse';
|
|
693
|
+
* // TAGS.EXT_X_TARGETDURATION === "#EXT-X-TARGETDURATION"
|
|
694
|
+
* ```
|
|
695
|
+
*/
|
|
696
|
+
/**
|
|
697
|
+
* 文件格式标识符
|
|
698
|
+
*
|
|
699
|
+
* Extended M3U Playlist format identifier.
|
|
700
|
+
* MUST be the first line of every Media or Master Playlist.
|
|
701
|
+
*
|
|
702
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.1.1 | RFC 8216 §4.3.1.1}
|
|
703
|
+
*/
|
|
704
|
+
declare const EXTM3U = "EXTM3U";
|
|
705
|
+
/**
|
|
706
|
+
* 协议兼容版本号
|
|
707
|
+
*
|
|
708
|
+
* Protocol compatibility version number.
|
|
709
|
+
*
|
|
710
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.1.2 | RFC 8216 §4.3.1.2}
|
|
711
|
+
*/
|
|
712
|
+
declare const EXT_X_VERSION = "EXT-X-VERSION";
|
|
713
|
+
/**
|
|
714
|
+
* 内容转向服务器配置
|
|
715
|
+
*
|
|
716
|
+
* Content Steering server URI.
|
|
717
|
+
*
|
|
718
|
+
* @beta RFC 8216bis
|
|
719
|
+
*/
|
|
720
|
+
declare const EXT_X_CONTENT_STEERING = "EXT-X-CONTENT-STEERING";
|
|
721
|
+
/**
|
|
722
|
+
* 片段时长及标题
|
|
723
|
+
*
|
|
724
|
+
* Segment duration and optional human-readable title.
|
|
725
|
+
* REQUIRED for each Media Segment.
|
|
726
|
+
*
|
|
727
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.1 | RFC 8216 §4.3.2.1}
|
|
728
|
+
*/
|
|
729
|
+
declare const EXTINF = "EXTINF";
|
|
730
|
+
/**
|
|
731
|
+
* 子范围字节区间
|
|
732
|
+
*
|
|
733
|
+
* Sub-range byte range within a resource.
|
|
734
|
+
*
|
|
735
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.2 | RFC 8216 §4.3.2.2}
|
|
736
|
+
*/
|
|
737
|
+
declare const EXT_X_BYTERANGE = "EXT-X-BYTERANGE";
|
|
738
|
+
/**
|
|
739
|
+
* 不连续标记
|
|
740
|
+
*
|
|
741
|
+
* Discontinuity between the following segment and the one before it.
|
|
742
|
+
*
|
|
743
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.3 | RFC 8216 §4.3.2.3}
|
|
744
|
+
*/
|
|
745
|
+
declare const EXT_X_DISCONTINUITY = "EXT-X-DISCONTINUITY";
|
|
746
|
+
/**
|
|
747
|
+
* LL-HLS 预取不连续
|
|
748
|
+
*
|
|
749
|
+
* Discontinuity marker for LL-HLS prefetch segments.
|
|
750
|
+
*
|
|
751
|
+
* @beta LL-HLS feature
|
|
752
|
+
*/
|
|
753
|
+
declare const EXT_X_PREFETCH_DISCONTINUITY = "EXT-X-PREFETCH-DISCONTINUITY";
|
|
754
|
+
/**
|
|
755
|
+
* 加密密钥
|
|
756
|
+
*
|
|
757
|
+
* Encryption / decryption key for Media Segments.
|
|
758
|
+
* Method: NONE | AES-128 | SAMPLE-AES
|
|
759
|
+
*
|
|
760
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.4 | RFC 8216 §4.3.2.4}
|
|
761
|
+
*/
|
|
762
|
+
declare const EXT_X_KEY = "EXT-X-KEY";
|
|
763
|
+
/**
|
|
764
|
+
* 媒体初始化段
|
|
765
|
+
*
|
|
766
|
+
* Media Initialization Section URI and optional byte range.
|
|
767
|
+
*
|
|
768
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.5 | RFC 8216 §4.3.2.5}
|
|
769
|
+
*/
|
|
770
|
+
declare const EXT_X_MAP = "EXT-X-MAP";
|
|
771
|
+
/**
|
|
772
|
+
* 绝对日期时间
|
|
773
|
+
*
|
|
774
|
+
* Associating the first sample of a Media Segment with an absolute wall-clock time.
|
|
775
|
+
*
|
|
776
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.6 | RFC 8216 §4.3.2.6}
|
|
777
|
+
*/
|
|
778
|
+
declare const EXT_X_PROGRAM_DATE_TIME = "EXT-X-PROGRAM-DATE-TIME";
|
|
779
|
+
/**
|
|
780
|
+
* 日期范围元数据
|
|
781
|
+
*
|
|
782
|
+
* Date Range metadata — carries SCTE-35 and ad-insertion data.
|
|
783
|
+
*
|
|
784
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.7 | RFC 8216 §4.3.2.7}
|
|
785
|
+
*/
|
|
786
|
+
declare const EXT_X_DATERANGE = "EXT-X-DATERANGE";
|
|
787
|
+
/**
|
|
788
|
+
* 广告插播开始
|
|
789
|
+
*
|
|
790
|
+
* Splice-out marker — indicates the start of an ad break.
|
|
791
|
+
*/
|
|
792
|
+
declare const EXT_X_CUE_OUT = "EXT-X-CUE-OUT";
|
|
793
|
+
/**
|
|
794
|
+
* 广告插播结束
|
|
795
|
+
*
|
|
796
|
+
* Splice-in marker — indicates the end of an ad break.
|
|
797
|
+
*/
|
|
798
|
+
declare const EXT_X_CUE_IN = "EXT-X-CUE-IN";
|
|
799
|
+
/**
|
|
800
|
+
* 广告插播延续
|
|
801
|
+
*
|
|
802
|
+
* Splice-out continuation marker.
|
|
803
|
+
*/
|
|
804
|
+
declare const EXT_X_CUE_OUT_CONT = "EXT-X-CUE-OUT-CONT";
|
|
805
|
+
/**
|
|
806
|
+
* 通用提示标记
|
|
807
|
+
*
|
|
808
|
+
* Generic cue marker.
|
|
809
|
+
*/
|
|
810
|
+
declare const EXT_X_CUE = "EXT-X-CUE";
|
|
811
|
+
/**
|
|
812
|
+
* OATCLS SCTE-35 数据
|
|
813
|
+
*
|
|
814
|
+
* OATCLS SCTE-35 payload marker.
|
|
815
|
+
*/
|
|
816
|
+
declare const EXT_OATCLS_SCTE35 = "EXT-OATCLS-SCTE35";
|
|
817
|
+
/**
|
|
818
|
+
* 资产元数据
|
|
819
|
+
*
|
|
820
|
+
* Asset metadata (CAID) marker.
|
|
821
|
+
*/
|
|
822
|
+
declare const EXT_X_ASSET = "EXT-X-ASSET";
|
|
823
|
+
/**
|
|
824
|
+
* SCTE-35 数据
|
|
825
|
+
*
|
|
826
|
+
* SCTE-35 payload marker.
|
|
827
|
+
*/
|
|
828
|
+
declare const EXT_X_SCTE35 = "EXT-X-SCTE35";
|
|
829
|
+
/**
|
|
830
|
+
* LL-HLS 部分片段
|
|
831
|
+
*
|
|
832
|
+
* Partial Segment for Low-Latency HLS.
|
|
833
|
+
*
|
|
834
|
+
* @beta LL-HLS feature
|
|
835
|
+
*/
|
|
836
|
+
declare const EXT_X_PART = "EXT-X-PART";
|
|
837
|
+
/**
|
|
838
|
+
* LL-HLS 预加载提示
|
|
839
|
+
*
|
|
840
|
+
* Preload Hint for Low-Latency HLS — TYPE=PART or TYPE=MAP.
|
|
841
|
+
*
|
|
842
|
+
* @beta LL-HLS feature
|
|
843
|
+
*/
|
|
844
|
+
declare const EXT_X_PRELOAD_HINT = "EXT-X-PRELOAD-HINT";
|
|
845
|
+
/**
|
|
846
|
+
* 间隔片段标记
|
|
847
|
+
*
|
|
848
|
+
* Gap segment marker — indicates a Media Segment without media content.
|
|
849
|
+
* Extends target duration for timing but carries no samples.
|
|
850
|
+
*
|
|
851
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.8 | RFC 8216 §4.3.2.8 (bis)}
|
|
852
|
+
*/
|
|
853
|
+
declare const EXT_X_GAP = "EXT-X-GAP";
|
|
854
|
+
/**
|
|
855
|
+
* 媒体播放列表码率
|
|
856
|
+
*
|
|
857
|
+
* Indicates the segment bitrate of a Media Playlist.
|
|
858
|
+
* Enables ABR without a Master Playlist (RFC 8216bis).
|
|
859
|
+
*
|
|
860
|
+
* @beta
|
|
861
|
+
*/
|
|
862
|
+
declare const EXT_X_BITRATE = "EXT-X-BITRATE";
|
|
863
|
+
/**
|
|
864
|
+
* 最大片段时长 (秒)
|
|
865
|
+
*
|
|
866
|
+
* Maximum Media Segment duration in seconds. REQUIRED for every Media Playlist.
|
|
867
|
+
*
|
|
868
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.1 | RFC 8216 §4.3.3.1}
|
|
869
|
+
*/
|
|
870
|
+
declare const EXT_X_TARGETDURATION = "EXT-X-TARGETDURATION";
|
|
871
|
+
/**
|
|
872
|
+
* 媒体序列号基数
|
|
873
|
+
*
|
|
874
|
+
* Base Media Sequence Number of the first Media Segment.
|
|
875
|
+
*
|
|
876
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.2 | RFC 8216 §4.3.3.2}
|
|
877
|
+
*/
|
|
878
|
+
declare const EXT_X_MEDIA_SEQUENCE = "EXT-X-MEDIA-SEQUENCE";
|
|
879
|
+
/**
|
|
880
|
+
* 不连续序列号基数
|
|
881
|
+
*
|
|
882
|
+
* Base Discontinuity Sequence Number.
|
|
883
|
+
*
|
|
884
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.3 | RFC 8216 §4.3.3.3}
|
|
885
|
+
*/
|
|
886
|
+
declare const EXT_X_DISCONTINUITY_SEQUENCE = "EXT-X-DISCONTINUITY-SEQUENCE";
|
|
887
|
+
/**
|
|
888
|
+
* 播放列表终止标记
|
|
889
|
+
*
|
|
890
|
+
* End-of-playlist marker — no more segments will be added.
|
|
891
|
+
*
|
|
892
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.4 | RFC 8216 §4.3.3.4}
|
|
893
|
+
*/
|
|
894
|
+
declare const EXT_X_ENDLIST = "EXT-X-ENDLIST";
|
|
895
|
+
/**
|
|
896
|
+
* 播放列表类型
|
|
897
|
+
*
|
|
898
|
+
* Playlist type — EVENT or VOD.
|
|
899
|
+
*
|
|
900
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.5 | RFC 8216 §4.3.3.5}
|
|
901
|
+
*/
|
|
902
|
+
declare const EXT_X_PLAYLIST_TYPE = "EXT-X-PLAYLIST-TYPE";
|
|
903
|
+
/**
|
|
904
|
+
* 仅 I 帧播放列表
|
|
905
|
+
*
|
|
906
|
+
* I-frame only playlist — each segment is a single I-frame (trick play).
|
|
907
|
+
*
|
|
908
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.6 | RFC 8216 §4.3.3.6}
|
|
909
|
+
*/
|
|
910
|
+
declare const EXT_X_I_FRAMES_ONLY = "EXT-X-I-FRAMES-ONLY";
|
|
911
|
+
/**
|
|
912
|
+
* LL-HLS 服务端控制参数
|
|
913
|
+
*
|
|
914
|
+
* Low-Latency HLS server control — CAN-BLOCK-RELOAD, CAN-SKIP-UNTIL, HOLD-BACK, PART-HOLD-BACK.
|
|
915
|
+
*
|
|
916
|
+
* @beta LL-HLS feature
|
|
917
|
+
*/
|
|
918
|
+
declare const EXT_X_SERVER_CONTROL = "EXT-X-SERVER-CONTROL";
|
|
919
|
+
/**
|
|
920
|
+
* LL-HLS 部分片段目标时长
|
|
921
|
+
*
|
|
922
|
+
* Partial Segment target duration for Low-Latency HLS — PART-TARGET.
|
|
923
|
+
*
|
|
924
|
+
* @beta LL-HLS feature
|
|
925
|
+
*/
|
|
926
|
+
declare const EXT_X_PART_INF = "EXT-X-PART-INF";
|
|
927
|
+
/**
|
|
928
|
+
* LL-HLS 预取片段
|
|
929
|
+
*
|
|
930
|
+
* Prefetch segment for Low-Latency HLS.
|
|
931
|
+
*
|
|
932
|
+
* @beta LL-HLS feature
|
|
933
|
+
*/
|
|
934
|
+
declare const EXT_X_PREFETCH = "EXT-X-PREFETCH";
|
|
935
|
+
/**
|
|
936
|
+
* LL-HLS 呈现报告
|
|
937
|
+
*
|
|
938
|
+
* Rendition Report for Low-Latency HLS — carries last MSN and last Part of a Rendition.
|
|
939
|
+
*
|
|
940
|
+
* @beta LL-HLS feature
|
|
941
|
+
*/
|
|
942
|
+
declare const EXT_X_RENDITION_REPORT = "EXT-X-RENDITION-REPORT";
|
|
943
|
+
/**
|
|
944
|
+
* LL-HLS 跳过片段
|
|
945
|
+
*
|
|
946
|
+
* Skip indicator for Low-Latency HLS — SKIPPED-SEGMENTS count.
|
|
947
|
+
*
|
|
948
|
+
* @beta LL-HLS feature
|
|
949
|
+
*/
|
|
950
|
+
declare const EXT_X_SKIP = "EXT-X-SKIP";
|
|
951
|
+
/**
|
|
952
|
+
* 替代呈现
|
|
953
|
+
*
|
|
954
|
+
* Alternative Rendition — TYPE: AUDIO | VIDEO | SUBTITLES | CLOSED-CAPTIONS.
|
|
955
|
+
*
|
|
956
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.1 | RFC 8216 §4.3.4.1}
|
|
957
|
+
*/
|
|
958
|
+
declare const EXT_X_MEDIA = "EXT-X-MEDIA";
|
|
959
|
+
/**
|
|
960
|
+
* 变体流
|
|
961
|
+
*
|
|
962
|
+
* Variant Stream — ABR adaptive bitrate stream.
|
|
963
|
+
*
|
|
964
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.2 | RFC 8216 §4.3.4.2}
|
|
965
|
+
*/
|
|
966
|
+
declare const EXT_X_STREAM_INF = "EXT-X-STREAM-INF";
|
|
967
|
+
/**
|
|
968
|
+
* I 帧变体流
|
|
969
|
+
*
|
|
970
|
+
* I-frame Variant Stream — independent I-frame playlist for trick-play.
|
|
971
|
+
*
|
|
972
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.3 | RFC 8216 §4.3.4.3}
|
|
973
|
+
*/
|
|
974
|
+
declare const EXT_X_I_FRAME_STREAM_INF = "EXT-X-I-FRAME-STREAM-INF";
|
|
975
|
+
/**
|
|
976
|
+
* 会话数据
|
|
977
|
+
*
|
|
978
|
+
* Session data — key-value pairs or JSON URI for arbitrary metadata.
|
|
979
|
+
*
|
|
980
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.4 | RFC 8216 §4.3.4.4}
|
|
981
|
+
*/
|
|
982
|
+
declare const EXT_X_SESSION_DATA = "EXT-X-SESSION-DATA";
|
|
983
|
+
/**
|
|
984
|
+
* 会话加密密钥
|
|
985
|
+
*
|
|
986
|
+
* Session-wide encryption key — preloaded keys for the entire Master Playlist.
|
|
987
|
+
*
|
|
988
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.5 | RFC 8216 §4.3.4.5}
|
|
989
|
+
*/
|
|
990
|
+
declare const EXT_X_SESSION_KEY = "EXT-X-SESSION-KEY";
|
|
991
|
+
/**
|
|
992
|
+
* 独立片段声明
|
|
993
|
+
*
|
|
994
|
+
* All Media Segments in the playlist are independently decodable.
|
|
995
|
+
*
|
|
996
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.5.1 | RFC 8216 §4.3.5.1}
|
|
997
|
+
*/
|
|
998
|
+
declare const EXT_X_INDEPENDENT_SEGMENTS = "EXT-X-INDEPENDENT-SEGMENTS";
|
|
999
|
+
/**
|
|
1000
|
+
* 建议起始位置
|
|
1001
|
+
*
|
|
1002
|
+
* Preferred point at which to start playback — TIME-OFFSET.
|
|
1003
|
+
*
|
|
1004
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.5.2 | RFC 8216 §4.3.5.2}
|
|
1005
|
+
*/
|
|
1006
|
+
declare const EXT_X_START = "EXT-X-START";
|
|
1007
|
+
/**
|
|
1008
|
+
* 变量定义
|
|
1009
|
+
*
|
|
1010
|
+
* Variable definition — NAME and VALUE pair for substitution.
|
|
1011
|
+
*/
|
|
1012
|
+
declare const EXT_X_DEFINE = "EXT-X-DEFINE";
|
|
1013
|
+
|
|
1014
|
+
declare const constants_EXTINF: typeof EXTINF;
|
|
1015
|
+
declare const constants_EXTM3U: typeof EXTM3U;
|
|
1016
|
+
declare const constants_EXT_OATCLS_SCTE35: typeof EXT_OATCLS_SCTE35;
|
|
1017
|
+
declare const constants_EXT_X_ASSET: typeof EXT_X_ASSET;
|
|
1018
|
+
declare const constants_EXT_X_BITRATE: typeof EXT_X_BITRATE;
|
|
1019
|
+
declare const constants_EXT_X_BYTERANGE: typeof EXT_X_BYTERANGE;
|
|
1020
|
+
declare const constants_EXT_X_CONTENT_STEERING: typeof EXT_X_CONTENT_STEERING;
|
|
1021
|
+
declare const constants_EXT_X_CUE: typeof EXT_X_CUE;
|
|
1022
|
+
declare const constants_EXT_X_CUE_IN: typeof EXT_X_CUE_IN;
|
|
1023
|
+
declare const constants_EXT_X_CUE_OUT: typeof EXT_X_CUE_OUT;
|
|
1024
|
+
declare const constants_EXT_X_CUE_OUT_CONT: typeof EXT_X_CUE_OUT_CONT;
|
|
1025
|
+
declare const constants_EXT_X_DATERANGE: typeof EXT_X_DATERANGE;
|
|
1026
|
+
declare const constants_EXT_X_DEFINE: typeof EXT_X_DEFINE;
|
|
1027
|
+
declare const constants_EXT_X_DISCONTINUITY: typeof EXT_X_DISCONTINUITY;
|
|
1028
|
+
declare const constants_EXT_X_DISCONTINUITY_SEQUENCE: typeof EXT_X_DISCONTINUITY_SEQUENCE;
|
|
1029
|
+
declare const constants_EXT_X_ENDLIST: typeof EXT_X_ENDLIST;
|
|
1030
|
+
declare const constants_EXT_X_GAP: typeof EXT_X_GAP;
|
|
1031
|
+
declare const constants_EXT_X_INDEPENDENT_SEGMENTS: typeof EXT_X_INDEPENDENT_SEGMENTS;
|
|
1032
|
+
declare const constants_EXT_X_I_FRAMES_ONLY: typeof EXT_X_I_FRAMES_ONLY;
|
|
1033
|
+
declare const constants_EXT_X_I_FRAME_STREAM_INF: typeof EXT_X_I_FRAME_STREAM_INF;
|
|
1034
|
+
declare const constants_EXT_X_KEY: typeof EXT_X_KEY;
|
|
1035
|
+
declare const constants_EXT_X_MAP: typeof EXT_X_MAP;
|
|
1036
|
+
declare const constants_EXT_X_MEDIA: typeof EXT_X_MEDIA;
|
|
1037
|
+
declare const constants_EXT_X_MEDIA_SEQUENCE: typeof EXT_X_MEDIA_SEQUENCE;
|
|
1038
|
+
declare const constants_EXT_X_PART: typeof EXT_X_PART;
|
|
1039
|
+
declare const constants_EXT_X_PART_INF: typeof EXT_X_PART_INF;
|
|
1040
|
+
declare const constants_EXT_X_PLAYLIST_TYPE: typeof EXT_X_PLAYLIST_TYPE;
|
|
1041
|
+
declare const constants_EXT_X_PREFETCH: typeof EXT_X_PREFETCH;
|
|
1042
|
+
declare const constants_EXT_X_PREFETCH_DISCONTINUITY: typeof EXT_X_PREFETCH_DISCONTINUITY;
|
|
1043
|
+
declare const constants_EXT_X_PRELOAD_HINT: typeof EXT_X_PRELOAD_HINT;
|
|
1044
|
+
declare const constants_EXT_X_PROGRAM_DATE_TIME: typeof EXT_X_PROGRAM_DATE_TIME;
|
|
1045
|
+
declare const constants_EXT_X_RENDITION_REPORT: typeof EXT_X_RENDITION_REPORT;
|
|
1046
|
+
declare const constants_EXT_X_SCTE35: typeof EXT_X_SCTE35;
|
|
1047
|
+
declare const constants_EXT_X_SERVER_CONTROL: typeof EXT_X_SERVER_CONTROL;
|
|
1048
|
+
declare const constants_EXT_X_SESSION_DATA: typeof EXT_X_SESSION_DATA;
|
|
1049
|
+
declare const constants_EXT_X_SESSION_KEY: typeof EXT_X_SESSION_KEY;
|
|
1050
|
+
declare const constants_EXT_X_SKIP: typeof EXT_X_SKIP;
|
|
1051
|
+
declare const constants_EXT_X_START: typeof EXT_X_START;
|
|
1052
|
+
declare const constants_EXT_X_STREAM_INF: typeof EXT_X_STREAM_INF;
|
|
1053
|
+
declare const constants_EXT_X_TARGETDURATION: typeof EXT_X_TARGETDURATION;
|
|
1054
|
+
declare const constants_EXT_X_VERSION: typeof EXT_X_VERSION;
|
|
1055
|
+
declare namespace constants {
|
|
1056
|
+
export {
|
|
1057
|
+
constants_EXTINF as EXTINF,
|
|
1058
|
+
constants_EXTM3U as EXTM3U,
|
|
1059
|
+
constants_EXT_OATCLS_SCTE35 as EXT_OATCLS_SCTE35,
|
|
1060
|
+
constants_EXT_X_ASSET as EXT_X_ASSET,
|
|
1061
|
+
constants_EXT_X_BITRATE as EXT_X_BITRATE,
|
|
1062
|
+
constants_EXT_X_BYTERANGE as EXT_X_BYTERANGE,
|
|
1063
|
+
constants_EXT_X_CONTENT_STEERING as EXT_X_CONTENT_STEERING,
|
|
1064
|
+
constants_EXT_X_CUE as EXT_X_CUE,
|
|
1065
|
+
constants_EXT_X_CUE_IN as EXT_X_CUE_IN,
|
|
1066
|
+
constants_EXT_X_CUE_OUT as EXT_X_CUE_OUT,
|
|
1067
|
+
constants_EXT_X_CUE_OUT_CONT as EXT_X_CUE_OUT_CONT,
|
|
1068
|
+
constants_EXT_X_DATERANGE as EXT_X_DATERANGE,
|
|
1069
|
+
constants_EXT_X_DEFINE as EXT_X_DEFINE,
|
|
1070
|
+
constants_EXT_X_DISCONTINUITY as EXT_X_DISCONTINUITY,
|
|
1071
|
+
constants_EXT_X_DISCONTINUITY_SEQUENCE as EXT_X_DISCONTINUITY_SEQUENCE,
|
|
1072
|
+
constants_EXT_X_ENDLIST as EXT_X_ENDLIST,
|
|
1073
|
+
constants_EXT_X_GAP as EXT_X_GAP,
|
|
1074
|
+
constants_EXT_X_INDEPENDENT_SEGMENTS as EXT_X_INDEPENDENT_SEGMENTS,
|
|
1075
|
+
constants_EXT_X_I_FRAMES_ONLY as EXT_X_I_FRAMES_ONLY,
|
|
1076
|
+
constants_EXT_X_I_FRAME_STREAM_INF as EXT_X_I_FRAME_STREAM_INF,
|
|
1077
|
+
constants_EXT_X_KEY as EXT_X_KEY,
|
|
1078
|
+
constants_EXT_X_MAP as EXT_X_MAP,
|
|
1079
|
+
constants_EXT_X_MEDIA as EXT_X_MEDIA,
|
|
1080
|
+
constants_EXT_X_MEDIA_SEQUENCE as EXT_X_MEDIA_SEQUENCE,
|
|
1081
|
+
constants_EXT_X_PART as EXT_X_PART,
|
|
1082
|
+
constants_EXT_X_PART_INF as EXT_X_PART_INF,
|
|
1083
|
+
constants_EXT_X_PLAYLIST_TYPE as EXT_X_PLAYLIST_TYPE,
|
|
1084
|
+
constants_EXT_X_PREFETCH as EXT_X_PREFETCH,
|
|
1085
|
+
constants_EXT_X_PREFETCH_DISCONTINUITY as EXT_X_PREFETCH_DISCONTINUITY,
|
|
1086
|
+
constants_EXT_X_PRELOAD_HINT as EXT_X_PRELOAD_HINT,
|
|
1087
|
+
constants_EXT_X_PROGRAM_DATE_TIME as EXT_X_PROGRAM_DATE_TIME,
|
|
1088
|
+
constants_EXT_X_RENDITION_REPORT as EXT_X_RENDITION_REPORT,
|
|
1089
|
+
constants_EXT_X_SCTE35 as EXT_X_SCTE35,
|
|
1090
|
+
constants_EXT_X_SERVER_CONTROL as EXT_X_SERVER_CONTROL,
|
|
1091
|
+
constants_EXT_X_SESSION_DATA as EXT_X_SESSION_DATA,
|
|
1092
|
+
constants_EXT_X_SESSION_KEY as EXT_X_SESSION_KEY,
|
|
1093
|
+
constants_EXT_X_SKIP as EXT_X_SKIP,
|
|
1094
|
+
constants_EXT_X_START as EXT_X_START,
|
|
1095
|
+
constants_EXT_X_STREAM_INF as EXT_X_STREAM_INF,
|
|
1096
|
+
constants_EXT_X_TARGETDURATION as EXT_X_TARGETDURATION,
|
|
1097
|
+
constants_EXT_X_VERSION as EXT_X_VERSION,
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export { InvalidPlaylistError, constants as TAGS, parse as default, isMasterPlaylist, isMediaPlaylist, parse, resolveUrl };
|
|
1102
|
+
export type { AllowedCpc, Byterange, ContentSteering, DateRange, ExtInfo, Key, LowLatencyCompatibility, MasterPlaylist, MediaInitializationSection, MediaPlaylist, ParseOptions, PartialSegment, Playlist, PrefetchSegment, Rendition, RenditionReport, Resolution, Segment, SessionData, SpliceInfo, StartData, UserAttribute, Variant };
|