hls.js 1.5.14-0.canary.10559 → 1.5.15
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/README.md +3 -4
- package/dist/hls-demo.js +38 -41
- package/dist/hls-demo.js.map +1 -1
- package/dist/hls.js +2911 -4558
- package/dist/hls.js.d.ts +112 -186
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +2291 -3311
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +1813 -2835
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +4707 -6356
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/dist/hls.worker.js.map +1 -1
- package/package.json +42 -42
- package/src/config.ts +2 -5
- package/src/controller/abr-controller.ts +25 -39
- package/src/controller/audio-stream-controller.ts +136 -156
- package/src/controller/audio-track-controller.ts +1 -1
- package/src/controller/base-playlist-controller.ts +10 -27
- package/src/controller/base-stream-controller.ts +107 -263
- package/src/controller/buffer-controller.ts +97 -250
- package/src/controller/buffer-operation-queue.ts +19 -16
- package/src/controller/cap-level-controller.ts +2 -3
- package/src/controller/cmcd-controller.ts +14 -51
- package/src/controller/content-steering-controller.ts +15 -29
- package/src/controller/eme-controller.ts +23 -10
- package/src/controller/error-controller.ts +22 -28
- package/src/controller/fps-controller.ts +3 -8
- package/src/controller/fragment-finders.ts +16 -44
- package/src/controller/fragment-tracker.ts +25 -58
- package/src/controller/gap-controller.ts +16 -43
- package/src/controller/id3-track-controller.ts +35 -45
- package/src/controller/latency-controller.ts +13 -18
- package/src/controller/level-controller.ts +19 -37
- package/src/controller/stream-controller.ts +83 -100
- package/src/controller/subtitle-stream-controller.ts +47 -35
- package/src/controller/subtitle-track-controller.ts +3 -5
- package/src/controller/timeline-controller.ts +22 -20
- package/src/crypt/aes-crypto.ts +2 -21
- package/src/crypt/decrypter.ts +16 -32
- package/src/crypt/fast-aes-key.ts +5 -28
- package/src/demux/audio/aacdemuxer.ts +5 -5
- package/src/demux/audio/ac3-demuxer.ts +4 -5
- package/src/demux/audio/adts.ts +4 -9
- package/src/demux/audio/base-audio-demuxer.ts +15 -21
- package/src/demux/audio/mp3demuxer.ts +3 -4
- package/src/demux/audio/mpegaudio.ts +1 -1
- package/src/demux/id3.ts +411 -0
- package/src/demux/inject-worker.ts +4 -38
- package/src/demux/mp4demuxer.ts +8 -17
- package/src/demux/sample-aes.ts +0 -2
- package/src/demux/transmuxer-interface.ts +83 -106
- package/src/demux/transmuxer-worker.ts +77 -111
- package/src/demux/transmuxer.ts +22 -46
- package/src/demux/tsdemuxer.ts +65 -131
- package/src/demux/video/avc-video-parser.ts +156 -219
- package/src/demux/video/base-video-parser.ts +9 -133
- package/src/demux/video/exp-golomb.ts +208 -0
- package/src/errors.ts +0 -2
- package/src/events.ts +1 -8
- package/src/exports-named.ts +1 -1
- package/src/hls.ts +48 -97
- package/src/loader/date-range.ts +5 -71
- package/src/loader/fragment-loader.ts +21 -23
- package/src/loader/fragment.ts +4 -8
- package/src/loader/key-loader.ts +1 -3
- package/src/loader/level-details.ts +6 -6
- package/src/loader/level-key.ts +9 -10
- package/src/loader/m3u8-parser.ts +144 -138
- package/src/loader/playlist-loader.ts +7 -5
- package/src/remux/mp4-generator.ts +1 -196
- package/src/remux/mp4-remuxer.ts +84 -55
- package/src/remux/passthrough-remuxer.ts +8 -23
- package/src/task-loop.ts +2 -5
- package/src/types/component-api.ts +1 -3
- package/src/types/demuxer.ts +1 -3
- package/src/types/events.ts +6 -19
- package/src/types/fragment-tracker.ts +2 -2
- package/src/types/general.ts +6 -0
- package/src/types/media-playlist.ts +1 -9
- package/src/types/remuxer.ts +1 -1
- package/src/utils/attr-list.ts +9 -96
- package/src/utils/buffer-helper.ts +31 -12
- package/src/utils/cea-608-parser.ts +3 -1
- package/src/utils/codecs.ts +5 -34
- package/src/utils/discontinuities.ts +47 -21
- package/src/utils/fetch-loader.ts +1 -1
- package/src/utils/hdr.ts +7 -4
- package/src/utils/imsc1-ttml-parser.ts +1 -1
- package/src/utils/keysystem-util.ts +6 -1
- package/src/utils/level-helper.ts +44 -71
- package/src/utils/logger.ts +23 -58
- package/src/utils/mp4-tools.ts +3 -5
- package/src/utils/rendition-helper.ts +74 -100
- package/src/utils/variable-substitution.ts +19 -0
- package/src/utils/webvtt-parser.ts +12 -2
- package/dist/hls.d.mts +0 -3179
- package/dist/hls.d.ts +0 -3179
- package/src/crypt/decrypter-aes-mode.ts +0 -4
- package/src/demux/video/hevc-video-parser.ts +0 -718
- package/src/utils/encryption-methods-util.ts +0 -21
- package/src/utils/hash.ts +0 -10
- package/src/utils/utf8-utils.ts +0 -18
- package/src/version.ts +0 -1
@@ -148,6 +148,214 @@ class ExpGolomb {
|
|
148
148
|
readUInt(): number {
|
149
149
|
return this.readBits(32);
|
150
150
|
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Advance the ExpGolomb decoder past a scaling list. The scaling
|
154
|
+
* list is optionally transmitted as part of a sequence parameter
|
155
|
+
* set and is not relevant to transmuxing.
|
156
|
+
* @param count the number of entries in this scaling list
|
157
|
+
* @see Recommendation ITU-T H.264, Section 7.3.2.1.1.1
|
158
|
+
*/
|
159
|
+
skipScalingList(count: number): void {
|
160
|
+
let lastScale = 8;
|
161
|
+
let nextScale = 8;
|
162
|
+
let deltaScale;
|
163
|
+
for (let j = 0; j < count; j++) {
|
164
|
+
if (nextScale !== 0) {
|
165
|
+
deltaScale = this.readEG();
|
166
|
+
nextScale = (lastScale + deltaScale + 256) % 256;
|
167
|
+
}
|
168
|
+
lastScale = nextScale === 0 ? lastScale : nextScale;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Read a sequence parameter set and return some interesting video
|
174
|
+
* properties. A sequence parameter set is the H264 metadata that
|
175
|
+
* describes the properties of upcoming video frames.
|
176
|
+
* @returns an object with configuration parsed from the
|
177
|
+
* sequence parameter set, including the dimensions of the
|
178
|
+
* associated video frames.
|
179
|
+
*/
|
180
|
+
readSPS(): {
|
181
|
+
width: number;
|
182
|
+
height: number;
|
183
|
+
pixelRatio: [number, number];
|
184
|
+
} {
|
185
|
+
let frameCropLeftOffset = 0;
|
186
|
+
let frameCropRightOffset = 0;
|
187
|
+
let frameCropTopOffset = 0;
|
188
|
+
let frameCropBottomOffset = 0;
|
189
|
+
let numRefFramesInPicOrderCntCycle;
|
190
|
+
let scalingListCount;
|
191
|
+
let i;
|
192
|
+
const readUByte = this.readUByte.bind(this);
|
193
|
+
const readBits = this.readBits.bind(this);
|
194
|
+
const readUEG = this.readUEG.bind(this);
|
195
|
+
const readBoolean = this.readBoolean.bind(this);
|
196
|
+
const skipBits = this.skipBits.bind(this);
|
197
|
+
const skipEG = this.skipEG.bind(this);
|
198
|
+
const skipUEG = this.skipUEG.bind(this);
|
199
|
+
const skipScalingList = this.skipScalingList.bind(this);
|
200
|
+
|
201
|
+
readUByte();
|
202
|
+
const profileIdc = readUByte(); // profile_idc
|
203
|
+
readBits(5); // profileCompat constraint_set[0-4]_flag, u(5)
|
204
|
+
skipBits(3); // reserved_zero_3bits u(3),
|
205
|
+
readUByte(); // level_idc u(8)
|
206
|
+
skipUEG(); // seq_parameter_set_id
|
207
|
+
// some profiles have more optional data we don't need
|
208
|
+
if (
|
209
|
+
profileIdc === 100 ||
|
210
|
+
profileIdc === 110 ||
|
211
|
+
profileIdc === 122 ||
|
212
|
+
profileIdc === 244 ||
|
213
|
+
profileIdc === 44 ||
|
214
|
+
profileIdc === 83 ||
|
215
|
+
profileIdc === 86 ||
|
216
|
+
profileIdc === 118 ||
|
217
|
+
profileIdc === 128
|
218
|
+
) {
|
219
|
+
const chromaFormatIdc = readUEG();
|
220
|
+
if (chromaFormatIdc === 3) {
|
221
|
+
skipBits(1);
|
222
|
+
} // separate_colour_plane_flag
|
223
|
+
|
224
|
+
skipUEG(); // bit_depth_luma_minus8
|
225
|
+
skipUEG(); // bit_depth_chroma_minus8
|
226
|
+
skipBits(1); // qpprime_y_zero_transform_bypass_flag
|
227
|
+
if (readBoolean()) {
|
228
|
+
// seq_scaling_matrix_present_flag
|
229
|
+
scalingListCount = chromaFormatIdc !== 3 ? 8 : 12;
|
230
|
+
for (i = 0; i < scalingListCount; i++) {
|
231
|
+
if (readBoolean()) {
|
232
|
+
// seq_scaling_list_present_flag[ i ]
|
233
|
+
if (i < 6) {
|
234
|
+
skipScalingList(16);
|
235
|
+
} else {
|
236
|
+
skipScalingList(64);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
skipUEG(); // log2_max_frame_num_minus4
|
243
|
+
const picOrderCntType = readUEG();
|
244
|
+
if (picOrderCntType === 0) {
|
245
|
+
readUEG(); // log2_max_pic_order_cnt_lsb_minus4
|
246
|
+
} else if (picOrderCntType === 1) {
|
247
|
+
skipBits(1); // delta_pic_order_always_zero_flag
|
248
|
+
skipEG(); // offset_for_non_ref_pic
|
249
|
+
skipEG(); // offset_for_top_to_bottom_field
|
250
|
+
numRefFramesInPicOrderCntCycle = readUEG();
|
251
|
+
for (i = 0; i < numRefFramesInPicOrderCntCycle; i++) {
|
252
|
+
skipEG();
|
253
|
+
} // offset_for_ref_frame[ i ]
|
254
|
+
}
|
255
|
+
skipUEG(); // max_num_ref_frames
|
256
|
+
skipBits(1); // gaps_in_frame_num_value_allowed_flag
|
257
|
+
const picWidthInMbsMinus1 = readUEG();
|
258
|
+
const picHeightInMapUnitsMinus1 = readUEG();
|
259
|
+
const frameMbsOnlyFlag = readBits(1);
|
260
|
+
if (frameMbsOnlyFlag === 0) {
|
261
|
+
skipBits(1);
|
262
|
+
} // mb_adaptive_frame_field_flag
|
263
|
+
|
264
|
+
skipBits(1); // direct_8x8_inference_flag
|
265
|
+
if (readBoolean()) {
|
266
|
+
// frame_cropping_flag
|
267
|
+
frameCropLeftOffset = readUEG();
|
268
|
+
frameCropRightOffset = readUEG();
|
269
|
+
frameCropTopOffset = readUEG();
|
270
|
+
frameCropBottomOffset = readUEG();
|
271
|
+
}
|
272
|
+
let pixelRatio: [number, number] = [1, 1];
|
273
|
+
if (readBoolean()) {
|
274
|
+
// vui_parameters_present_flag
|
275
|
+
if (readBoolean()) {
|
276
|
+
// aspect_ratio_info_present_flag
|
277
|
+
const aspectRatioIdc = readUByte();
|
278
|
+
switch (aspectRatioIdc) {
|
279
|
+
case 1:
|
280
|
+
pixelRatio = [1, 1];
|
281
|
+
break;
|
282
|
+
case 2:
|
283
|
+
pixelRatio = [12, 11];
|
284
|
+
break;
|
285
|
+
case 3:
|
286
|
+
pixelRatio = [10, 11];
|
287
|
+
break;
|
288
|
+
case 4:
|
289
|
+
pixelRatio = [16, 11];
|
290
|
+
break;
|
291
|
+
case 5:
|
292
|
+
pixelRatio = [40, 33];
|
293
|
+
break;
|
294
|
+
case 6:
|
295
|
+
pixelRatio = [24, 11];
|
296
|
+
break;
|
297
|
+
case 7:
|
298
|
+
pixelRatio = [20, 11];
|
299
|
+
break;
|
300
|
+
case 8:
|
301
|
+
pixelRatio = [32, 11];
|
302
|
+
break;
|
303
|
+
case 9:
|
304
|
+
pixelRatio = [80, 33];
|
305
|
+
break;
|
306
|
+
case 10:
|
307
|
+
pixelRatio = [18, 11];
|
308
|
+
break;
|
309
|
+
case 11:
|
310
|
+
pixelRatio = [15, 11];
|
311
|
+
break;
|
312
|
+
case 12:
|
313
|
+
pixelRatio = [64, 33];
|
314
|
+
break;
|
315
|
+
case 13:
|
316
|
+
pixelRatio = [160, 99];
|
317
|
+
break;
|
318
|
+
case 14:
|
319
|
+
pixelRatio = [4, 3];
|
320
|
+
break;
|
321
|
+
case 15:
|
322
|
+
pixelRatio = [3, 2];
|
323
|
+
break;
|
324
|
+
case 16:
|
325
|
+
pixelRatio = [2, 1];
|
326
|
+
break;
|
327
|
+
case 255: {
|
328
|
+
pixelRatio = [
|
329
|
+
(readUByte() << 8) | readUByte(),
|
330
|
+
(readUByte() << 8) | readUByte(),
|
331
|
+
];
|
332
|
+
break;
|
333
|
+
}
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}
|
337
|
+
return {
|
338
|
+
width: Math.ceil(
|
339
|
+
(picWidthInMbsMinus1 + 1) * 16 -
|
340
|
+
frameCropLeftOffset * 2 -
|
341
|
+
frameCropRightOffset * 2,
|
342
|
+
),
|
343
|
+
height:
|
344
|
+
(2 - frameMbsOnlyFlag) * (picHeightInMapUnitsMinus1 + 1) * 16 -
|
345
|
+
(frameMbsOnlyFlag ? 2 : 4) *
|
346
|
+
(frameCropTopOffset + frameCropBottomOffset),
|
347
|
+
pixelRatio: pixelRatio,
|
348
|
+
};
|
349
|
+
}
|
350
|
+
|
351
|
+
readSliceType() {
|
352
|
+
// skip NALu type
|
353
|
+
this.readUByte();
|
354
|
+
// discard first_mb_in_slice
|
355
|
+
this.readUEG();
|
356
|
+
// return slice_type
|
357
|
+
return this.readUEG();
|
358
|
+
}
|
151
359
|
}
|
152
360
|
|
153
361
|
export default ExpGolomb;
|
package/src/errors.ts
CHANGED
@@ -85,8 +85,6 @@ export enum ErrorDetails {
|
|
85
85
|
INTERNAL_EXCEPTION = 'internalException',
|
86
86
|
// Identifier for an internal call to abort a loader
|
87
87
|
INTERNAL_ABORTED = 'aborted',
|
88
|
-
// Triggered when attachMedia fails
|
89
|
-
ATTACH_MEDIA_ERROR = 'attachMediaError',
|
90
88
|
// Uncategorized error
|
91
89
|
UNKNOWN = 'unknown',
|
92
90
|
}
|
package/src/events.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
import
|
1
|
+
import {
|
2
2
|
ManifestLoadedData,
|
3
3
|
ManifestLoadingData,
|
4
4
|
MediaAttachedData,
|
5
5
|
MediaAttachingData,
|
6
|
-
MediaEndedData,
|
7
6
|
LevelLoadingData,
|
8
7
|
LevelLoadedData,
|
9
8
|
ManifestParsedData,
|
@@ -61,8 +60,6 @@ export enum Events {
|
|
61
60
|
MEDIA_DETACHING = 'hlsMediaDetaching',
|
62
61
|
// Fired when MediaSource has been detached from media element
|
63
62
|
MEDIA_DETACHED = 'hlsMediaDetached',
|
64
|
-
// Fired when HTMLMediaElement dispatches "ended" event, or stalls at end of VOD program
|
65
|
-
MEDIA_ENDED = 'hlsMediaEnded',
|
66
63
|
// Fired when the buffer is going to be reset
|
67
64
|
BUFFER_RESET = 'hlsBufferReset',
|
68
65
|
// Fired when we know about the codecs that we need buffers for to push into - data: {tracks : { container, codec, levelCodec, initSegment, metadata }}
|
@@ -187,10 +184,6 @@ export interface HlsListeners {
|
|
187
184
|
) => void;
|
188
185
|
[Events.MEDIA_DETACHING]: (event: Events.MEDIA_DETACHING) => void;
|
189
186
|
[Events.MEDIA_DETACHED]: (event: Events.MEDIA_DETACHED) => void;
|
190
|
-
[Events.MEDIA_ENDED]: (
|
191
|
-
event: Events.MEDIA_ENDED,
|
192
|
-
data: MediaEndedData,
|
193
|
-
) => void;
|
194
187
|
[Events.BUFFER_RESET]: (event: Events.BUFFER_RESET) => void;
|
195
188
|
[Events.BUFFER_CODECS]: (
|
196
189
|
event: Events.BUFFER_CODECS,
|
package/src/exports-named.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import Hls from './hls';
|
2
2
|
import { Events } from './events';
|
3
3
|
import { ErrorTypes, ErrorDetails } from './errors';
|
4
|
-
import
|
4
|
+
import { Level } from './types/level';
|
5
5
|
import AbrController from './controller/abr-controller';
|
6
6
|
import AudioTrackController from './controller/audio-track-controller';
|
7
7
|
import AudioStreamController from './controller/audio-stream-controller';
|
package/src/hls.ts
CHANGED
@@ -8,12 +8,11 @@ import KeyLoader from './loader/key-loader';
|
|
8
8
|
import StreamController from './controller/stream-controller';
|
9
9
|
import { isMSESupported, isSupported } from './is-supported';
|
10
10
|
import { getMediaSource } from './utils/mediasource-helper';
|
11
|
-
import {
|
11
|
+
import { logger, enableLogs } from './utils/logger';
|
12
12
|
import { enableStreamingMode, hlsDefaultConfig, mergeConfig } from './config';
|
13
13
|
import { EventEmitter } from 'eventemitter3';
|
14
14
|
import { Events } from './events';
|
15
15
|
import { ErrorTypes, ErrorDetails } from './errors';
|
16
|
-
import { version } from './version';
|
17
16
|
import { isHdcpLevel, type HdcpLevel, type Level } from './types/level';
|
18
17
|
import type { HlsEventEmitter, HlsListeners } from './events';
|
19
18
|
import type AudioTrackController from './controller/audio-track-controller';
|
@@ -60,13 +59,9 @@ export default class Hls implements HlsEventEmitter {
|
|
60
59
|
*/
|
61
60
|
public readonly userConfig: Partial<HlsConfig>;
|
62
61
|
|
63
|
-
/**
|
64
|
-
* The logger functions used by this player instance, configured on player instantiation.
|
65
|
-
*/
|
66
|
-
public readonly logger: ILogger;
|
67
|
-
|
68
62
|
private coreComponents: ComponentAPI[];
|
69
63
|
private networkControllers: NetworkComponentAPI[];
|
64
|
+
private started: boolean = false;
|
70
65
|
private _emitter: HlsEventEmitter = new EventEmitter();
|
71
66
|
private _autoLevelCapping: number = -1;
|
72
67
|
private _maxHdcpLevel: HdcpLevel = null;
|
@@ -81,14 +76,14 @@ export default class Hls implements HlsEventEmitter {
|
|
81
76
|
private emeController: EMEController;
|
82
77
|
private cmcdController: CMCDController;
|
83
78
|
private _media: HTMLMediaElement | null = null;
|
84
|
-
private
|
79
|
+
private url: string | null = null;
|
85
80
|
private triggeringException?: boolean;
|
86
81
|
|
87
82
|
/**
|
88
83
|
* Get the video-dev/hls.js package version.
|
89
84
|
*/
|
90
85
|
static get version(): string {
|
91
|
-
return
|
86
|
+
return __VERSION__;
|
92
87
|
}
|
93
88
|
|
94
89
|
/**
|
@@ -147,19 +142,12 @@ export default class Hls implements HlsEventEmitter {
|
|
147
142
|
* @param userConfig - Configuration options applied over `Hls.DefaultConfig`
|
148
143
|
*/
|
149
144
|
constructor(userConfig: Partial<HlsConfig> = {}) {
|
150
|
-
|
151
|
-
|
152
|
-
'Hls instance',
|
153
|
-
));
|
154
|
-
const config = (this.config = mergeConfig(
|
155
|
-
Hls.DefaultConfig,
|
156
|
-
userConfig,
|
157
|
-
logger,
|
158
|
-
));
|
145
|
+
enableLogs(userConfig.debug || false, 'Hls instance');
|
146
|
+
const config = (this.config = mergeConfig(Hls.DefaultConfig, userConfig));
|
159
147
|
this.userConfig = userConfig;
|
160
148
|
|
161
149
|
if (config.progressive) {
|
162
|
-
enableStreamingMode(config
|
150
|
+
enableStreamingMode(config);
|
163
151
|
}
|
164
152
|
|
165
153
|
// core controllers and network loaders
|
@@ -172,10 +160,8 @@ export default class Hls implements HlsEventEmitter {
|
|
172
160
|
} = config;
|
173
161
|
const errorController = new ConfigErrorController(this);
|
174
162
|
const abrController = (this.abrController = new ConfigAbrController(this));
|
175
|
-
// FragmentTracker must be defined before StreamController because the order of event handling is important
|
176
|
-
const fragmentTracker = new FragmentTracker(this);
|
177
163
|
const bufferController = (this.bufferController =
|
178
|
-
new ConfigBufferController(this
|
164
|
+
new ConfigBufferController(this));
|
179
165
|
const capLevelController = (this.capLevelController =
|
180
166
|
new ConfigCapLevelController(this));
|
181
167
|
|
@@ -184,7 +170,7 @@ export default class Hls implements HlsEventEmitter {
|
|
184
170
|
const id3TrackController = new ID3TrackController(this);
|
185
171
|
|
186
172
|
const ConfigContentSteeringController = config.contentSteeringController;
|
187
|
-
//
|
173
|
+
// ConentSteeringController is defined before LevelController to receive Multivariant Playlist events first
|
188
174
|
const contentSteering = ConfigContentSteeringController
|
189
175
|
? new ConfigContentSteeringController(this)
|
190
176
|
: null;
|
@@ -192,6 +178,8 @@ export default class Hls implements HlsEventEmitter {
|
|
192
178
|
this,
|
193
179
|
contentSteering,
|
194
180
|
));
|
181
|
+
// FragmentTracker must be defined before StreamController because the order of event handling is important
|
182
|
+
const fragmentTracker = new FragmentTracker(this);
|
195
183
|
const keyLoader = new KeyLoader(this.config);
|
196
184
|
const streamController = (this.streamController = new StreamController(
|
197
185
|
this,
|
@@ -233,7 +221,7 @@ export default class Hls implements HlsEventEmitter {
|
|
233
221
|
new AudioStreamControllerClass(this, fragmentTracker, keyLoader),
|
234
222
|
);
|
235
223
|
}
|
236
|
-
//
|
224
|
+
// subtitleTrackController must be defined before subtitleStreamController because the order of event handling is important
|
237
225
|
this.subtitleTrackController = this.createController(
|
238
226
|
config.subtitleTrackController,
|
239
227
|
networkControllers,
|
@@ -332,7 +320,7 @@ export default class Hls implements HlsEventEmitter {
|
|
332
320
|
try {
|
333
321
|
return this.emit(event, event, eventObject);
|
334
322
|
} catch (error) {
|
335
|
-
|
323
|
+
logger.error(
|
336
324
|
'An internal error happened while handling event ' +
|
337
325
|
event +
|
338
326
|
'. Error message: "' +
|
@@ -366,12 +354,12 @@ export default class Hls implements HlsEventEmitter {
|
|
366
354
|
* Dispose of the instance
|
367
355
|
*/
|
368
356
|
destroy() {
|
369
|
-
|
357
|
+
logger.log('destroy');
|
370
358
|
this.trigger(Events.DESTROYING, undefined);
|
371
359
|
this.detachMedia();
|
372
360
|
this.removeAllListeners();
|
373
361
|
this._autoLevelCapping = -1;
|
374
|
-
this.
|
362
|
+
this.url = null;
|
375
363
|
|
376
364
|
this.networkControllers.forEach((component) => component.destroy());
|
377
365
|
this.networkControllers.length = 0;
|
@@ -389,18 +377,7 @@ export default class Hls implements HlsEventEmitter {
|
|
389
377
|
* Attaches Hls.js to a media element
|
390
378
|
*/
|
391
379
|
attachMedia(media: HTMLMediaElement) {
|
392
|
-
|
393
|
-
const error = new Error(`attachMedia failed: media argument is ${media}`);
|
394
|
-
this.trigger(Events.ERROR, {
|
395
|
-
type: ErrorTypes.OTHER_ERROR,
|
396
|
-
details: ErrorDetails.ATTACH_MEDIA_ERROR,
|
397
|
-
fatal: true,
|
398
|
-
error,
|
399
|
-
});
|
400
|
-
return;
|
401
|
-
}
|
402
|
-
|
403
|
-
this.logger.log('attachMedia');
|
380
|
+
logger.log('attachMedia');
|
404
381
|
this._media = media;
|
405
382
|
this.trigger(Events.MEDIA_ATTACHING, { media: media });
|
406
383
|
}
|
@@ -409,7 +386,7 @@ export default class Hls implements HlsEventEmitter {
|
|
409
386
|
* Detach Hls.js from the media
|
410
387
|
*/
|
411
388
|
detachMedia() {
|
412
|
-
|
389
|
+
logger.log('detachMedia');
|
413
390
|
this.trigger(Events.MEDIA_DETACHING, undefined);
|
414
391
|
this._media = null;
|
415
392
|
}
|
@@ -420,8 +397,8 @@ export default class Hls implements HlsEventEmitter {
|
|
420
397
|
loadSource(url: string) {
|
421
398
|
this.stopLoad();
|
422
399
|
const media = this.media;
|
423
|
-
const loadedSource = this.
|
424
|
-
const loadingSource = (this.
|
400
|
+
const loadedSource = this.url;
|
401
|
+
const loadingSource = (this.url = buildAbsoluteURL(
|
425
402
|
self.location.href,
|
426
403
|
url,
|
427
404
|
{
|
@@ -430,7 +407,7 @@ export default class Hls implements HlsEventEmitter {
|
|
430
407
|
));
|
431
408
|
this._autoLevelCapping = -1;
|
432
409
|
this._maxHdcpLevel = null;
|
433
|
-
|
410
|
+
logger.log(`loadSource:${loadingSource}`);
|
434
411
|
if (
|
435
412
|
media &&
|
436
413
|
loadedSource &&
|
@@ -443,13 +420,6 @@ export default class Hls implements HlsEventEmitter {
|
|
443
420
|
this.trigger(Events.MANIFEST_LOADING, { url: url });
|
444
421
|
}
|
445
422
|
|
446
|
-
/**
|
447
|
-
* Gets the currently loaded URL
|
448
|
-
*/
|
449
|
-
public get url(): string | null {
|
450
|
-
return this._url;
|
451
|
-
}
|
452
|
-
|
453
423
|
/**
|
454
424
|
* Start loading data from the stream source.
|
455
425
|
* Depending on default config, client starts loading automatically when a source is set.
|
@@ -458,7 +428,8 @@ export default class Hls implements HlsEventEmitter {
|
|
458
428
|
* Defaults to -1 (None: starts from earliest point)
|
459
429
|
*/
|
460
430
|
startLoad(startPosition: number = -1) {
|
461
|
-
|
431
|
+
logger.log(`startLoad(${startPosition})`);
|
432
|
+
this.started = true;
|
462
433
|
this.networkControllers.forEach((controller) => {
|
463
434
|
controller.startLoad(startPosition);
|
464
435
|
});
|
@@ -468,31 +439,34 @@ export default class Hls implements HlsEventEmitter {
|
|
468
439
|
* Stop loading of any stream data.
|
469
440
|
*/
|
470
441
|
stopLoad() {
|
471
|
-
|
442
|
+
logger.log('stopLoad');
|
443
|
+
this.started = false;
|
472
444
|
this.networkControllers.forEach((controller) => {
|
473
445
|
controller.stopLoad();
|
474
446
|
});
|
475
447
|
}
|
476
448
|
|
477
449
|
/**
|
478
|
-
* Resumes stream controller segment loading
|
450
|
+
* Resumes stream controller segment loading if previously started.
|
479
451
|
*/
|
480
452
|
resumeBuffering() {
|
481
|
-
this.
|
482
|
-
|
483
|
-
controller
|
484
|
-
|
485
|
-
|
453
|
+
if (this.started) {
|
454
|
+
this.networkControllers.forEach((controller) => {
|
455
|
+
if ('fragmentLoader' in controller) {
|
456
|
+
controller.startLoad(-1);
|
457
|
+
}
|
458
|
+
});
|
459
|
+
}
|
486
460
|
}
|
487
461
|
|
488
462
|
/**
|
489
|
-
*
|
463
|
+
* Stops stream controller segment loading without changing 'started' state like stopLoad().
|
490
464
|
* This allows for media buffering to be paused without interupting playlist loading.
|
491
465
|
*/
|
492
466
|
pauseBuffering() {
|
493
467
|
this.networkControllers.forEach((controller) => {
|
494
|
-
if (controller
|
495
|
-
controller.
|
468
|
+
if ('fragmentLoader' in controller) {
|
469
|
+
controller.stopLoad();
|
496
470
|
}
|
497
471
|
});
|
498
472
|
}
|
@@ -501,7 +475,7 @@ export default class Hls implements HlsEventEmitter {
|
|
501
475
|
* Swap through possible audio codecs in the stream (for example to switch from stereo to 5.1)
|
502
476
|
*/
|
503
477
|
swapAudioCodec() {
|
504
|
-
|
478
|
+
logger.log('swapAudioCodec');
|
505
479
|
this.streamController.swapAudioCodec();
|
506
480
|
}
|
507
481
|
|
@@ -512,7 +486,7 @@ export default class Hls implements HlsEventEmitter {
|
|
512
486
|
* Automatic recovery of media-errors by this process is configurable.
|
513
487
|
*/
|
514
488
|
recoverMediaError() {
|
515
|
-
|
489
|
+
logger.log('recoverMediaError');
|
516
490
|
const media = this._media;
|
517
491
|
this.detachMedia();
|
518
492
|
if (media) {
|
@@ -543,7 +517,7 @@ export default class Hls implements HlsEventEmitter {
|
|
543
517
|
* Set quality level index immediately. This will flush the current buffer to replace the quality asap. That means playback will interrupt at least shortly to re-buffer and re-sync eventually. Set to -1 for automatic level selection.
|
544
518
|
*/
|
545
519
|
set currentLevel(newLevel: number) {
|
546
|
-
|
520
|
+
logger.log(`set currentLevel:${newLevel}`);
|
547
521
|
this.levelController.manualLevel = newLevel;
|
548
522
|
this.streamController.immediateLevelSwitch();
|
549
523
|
}
|
@@ -562,7 +536,7 @@ export default class Hls implements HlsEventEmitter {
|
|
562
536
|
* @param newLevel - Pass -1 for automatic level selection
|
563
537
|
*/
|
564
538
|
set nextLevel(newLevel: number) {
|
565
|
-
|
539
|
+
logger.log(`set nextLevel:${newLevel}`);
|
566
540
|
this.levelController.manualLevel = newLevel;
|
567
541
|
this.streamController.nextLevelSwitch();
|
568
542
|
}
|
@@ -581,7 +555,7 @@ export default class Hls implements HlsEventEmitter {
|
|
581
555
|
* @param newLevel - Pass -1 for automatic level selection
|
582
556
|
*/
|
583
557
|
set loadLevel(newLevel: number) {
|
584
|
-
|
558
|
+
logger.log(`set loadLevel:${newLevel}`);
|
585
559
|
this.levelController.manualLevel = newLevel;
|
586
560
|
}
|
587
561
|
|
@@ -612,7 +586,7 @@ export default class Hls implements HlsEventEmitter {
|
|
612
586
|
* Sets "first-level", see getter.
|
613
587
|
*/
|
614
588
|
set firstLevel(newLevel: number) {
|
615
|
-
|
589
|
+
logger.log(`set firstLevel:${newLevel}`);
|
616
590
|
this.levelController.firstLevel = newLevel;
|
617
591
|
}
|
618
592
|
|
@@ -637,7 +611,7 @@ export default class Hls implements HlsEventEmitter {
|
|
637
611
|
* (determined from download of first segment)
|
638
612
|
*/
|
639
613
|
set startLevel(newLevel: number) {
|
640
|
-
|
614
|
+
logger.log(`set startLevel:${newLevel}`);
|
641
615
|
// if not in automatic start level detection, ensure startLevel is greater than minAutoLevel
|
642
616
|
if (newLevel !== -1) {
|
643
617
|
newLevel = Math.max(newLevel, this.minAutoLevel);
|
@@ -712,7 +686,7 @@ export default class Hls implements HlsEventEmitter {
|
|
712
686
|
*/
|
713
687
|
set autoLevelCapping(newLevel: number) {
|
714
688
|
if (this._autoLevelCapping !== newLevel) {
|
715
|
-
|
689
|
+
logger.log(`set autoLevelCapping:${newLevel}`);
|
716
690
|
this._autoLevelCapping = newLevel;
|
717
691
|
this.levelController.checkMaxAutoUpdated();
|
718
692
|
}
|
@@ -821,10 +795,6 @@ export default class Hls implements HlsEventEmitter {
|
|
821
795
|
return this.streamController.getMainFwdBufferInfo();
|
822
796
|
}
|
823
797
|
|
824
|
-
public get maxBufferLength(): number {
|
825
|
-
return this.streamController.maxBufferLength;
|
826
|
-
}
|
827
|
-
|
828
798
|
/**
|
829
799
|
* Find and select the best matching audio track, making a level switch when a Group change is necessary.
|
830
800
|
* Updates `hls.config.audioPreference`. Returns the selected track, or null when no matching track is found.
|
@@ -832,7 +802,7 @@ export default class Hls implements HlsEventEmitter {
|
|
832
802
|
public setAudioOption(
|
833
803
|
audioOption: MediaPlaylist | AudioSelectionOption | undefined,
|
834
804
|
): MediaPlaylist | null {
|
835
|
-
return this.audioTrackController?.setAudioOption(audioOption)
|
805
|
+
return this.audioTrackController?.setAudioOption(audioOption);
|
836
806
|
}
|
837
807
|
/**
|
838
808
|
* Find and select the best matching subtitle track, making a level switch when a Group change is necessary.
|
@@ -841,9 +811,8 @@ export default class Hls implements HlsEventEmitter {
|
|
841
811
|
public setSubtitleOption(
|
842
812
|
subtitleOption: MediaPlaylist | SubtitleSelectionOption | undefined,
|
843
813
|
): MediaPlaylist | null {
|
844
|
-
|
845
|
-
|
846
|
-
);
|
814
|
+
this.subtitleTrackController?.setSubtitleOption(subtitleOption);
|
815
|
+
return null;
|
847
816
|
}
|
848
817
|
|
849
818
|
/**
|
@@ -988,10 +957,6 @@ export default class Hls implements HlsEventEmitter {
|
|
988
957
|
return this.latencyController.targetLatency;
|
989
958
|
}
|
990
959
|
|
991
|
-
set targetLatency(latency: number) {
|
992
|
-
this.latencyController.targetLatency = latency;
|
993
|
-
}
|
994
|
-
|
995
960
|
/**
|
996
961
|
* the rate at which the edge of the current live playlist is advancing or 1 if there is none
|
997
962
|
*/
|
@@ -1005,17 +970,6 @@ export default class Hls implements HlsEventEmitter {
|
|
1005
970
|
get forceStartLoad(): boolean {
|
1006
971
|
return this.streamController.forceStartLoad;
|
1007
972
|
}
|
1008
|
-
|
1009
|
-
/**
|
1010
|
-
* ContentSteering pathwayPriority getter/setter
|
1011
|
-
*/
|
1012
|
-
get pathwayPriority(): string[] | null {
|
1013
|
-
return this.levelController.pathwayPriority;
|
1014
|
-
}
|
1015
|
-
|
1016
|
-
set pathwayPriority(pathwayPriority: string[]) {
|
1017
|
-
this.levelController.pathwayPriority = pathwayPriority;
|
1018
|
-
}
|
1019
973
|
}
|
1020
974
|
|
1021
975
|
export type {
|
@@ -1078,7 +1032,7 @@ export type {
|
|
1078
1032
|
TSDemuxerConfig,
|
1079
1033
|
} from './config';
|
1080
1034
|
export type { MediaKeySessionContext } from './controller/eme-controller';
|
1081
|
-
export type { ILogger
|
1035
|
+
export type { ILogger } from './utils/logger';
|
1082
1036
|
export type {
|
1083
1037
|
PathwayClone,
|
1084
1038
|
SteeringManifest,
|
@@ -1092,7 +1046,7 @@ export type {
|
|
1092
1046
|
KeySystems,
|
1093
1047
|
KeySystemFormats,
|
1094
1048
|
} from './utils/mediakeys-helper';
|
1095
|
-
export type { DateRange
|
1049
|
+
export type { DateRange } from './loader/date-range';
|
1096
1050
|
export type { LoadStats } from './loader/load-stats';
|
1097
1051
|
export type { LevelKey } from './loader/level-key';
|
1098
1052
|
export type { LevelDetails } from './loader/level-details';
|
@@ -1142,7 +1096,6 @@ export type { ChunkMetadata } from './types/transmuxer';
|
|
1142
1096
|
export type {
|
1143
1097
|
BaseSegment,
|
1144
1098
|
Fragment,
|
1145
|
-
MediaFragment,
|
1146
1099
|
Part,
|
1147
1100
|
ElementaryStreams,
|
1148
1101
|
ElementaryStreamTypes,
|
@@ -1194,7 +1147,6 @@ export type {
|
|
1194
1147
|
ManifestParsedData,
|
1195
1148
|
MediaAttachedData,
|
1196
1149
|
MediaAttachingData,
|
1197
|
-
MediaEndedData,
|
1198
1150
|
NonNativeTextTrack,
|
1199
1151
|
NonNativeTextTracksData,
|
1200
1152
|
SteeringManifestLoadedData,
|
@@ -1209,4 +1161,3 @@ export type {
|
|
1209
1161
|
IErrorAction,
|
1210
1162
|
} from './controller/error-controller';
|
1211
1163
|
export type { AttrList } from './utils/attr-list';
|
1212
|
-
export type { ParsedMultivariantPlaylist } from './loader/m3u8-parser';
|