hls.js 1.6.0-beta.2.0.canary.10871 → 1.6.0-beta.2.0.canary.10876
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/dist/hls.js +74 -60
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +65 -131
- 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 +67 -133
- 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 +76 -62
- 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 +1 -1
- package/src/demux/audio/base-audio-demuxer.ts +6 -6
- package/src/demux/tsdemuxer.ts +2 -3
- package/src/demux/video/hevc-video-parser.ts +12 -12
- package/src/remux/mp4-generator.ts +99 -45
- package/src/remux/mp4-remuxer.ts +24 -38
- package/src/types/demuxer.ts +41 -1
- package/src/types/remuxer.ts +25 -0
- package/src/utils/fetch-loader.ts +12 -8
- package/src/utils/xhr-loader.ts +4 -11
package/dist/hls.mjs
CHANGED
@@ -401,7 +401,7 @@ function enableLogs(debugConfig, context, id) {
|
|
401
401
|
// Some browsers don't allow to use bind on console object anyway
|
402
402
|
// fallback to default if needed
|
403
403
|
try {
|
404
|
-
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.
|
404
|
+
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10876"}`);
|
405
405
|
} catch (e) {
|
406
406
|
/* log fn threw an exception. All logger methods are no-ops. */
|
407
407
|
return createLogger();
|
@@ -9847,7 +9847,7 @@ var eventemitter3 = {exports: {}};
|
|
9847
9847
|
var eventemitter3Exports = eventemitter3.exports;
|
9848
9848
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
9849
9849
|
|
9850
|
-
const version = "1.6.0-beta.2.0.canary.
|
9850
|
+
const version = "1.6.0-beta.2.0.canary.10876";
|
9851
9851
|
|
9852
9852
|
// ensure the worker ends up in the bundle
|
9853
9853
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -12257,9 +12257,7 @@ class HevcVideoParser extends BaseVideoParser {
|
|
12257
12257
|
track.params[prop] = config.params[prop];
|
12258
12258
|
}
|
12259
12259
|
}
|
12260
|
-
|
12261
|
-
track.sps.push(unit.data);
|
12262
|
-
}
|
12260
|
+
this.pushParameterSet(track.sps, unit.data, track.vps);
|
12263
12261
|
if (!VideoSample) {
|
12264
12262
|
VideoSample = this.VideoSample = this.createVideoSample(true, pes.pts, pes.dts);
|
12265
12263
|
}
|
@@ -12277,9 +12275,7 @@ class HevcVideoParser extends BaseVideoParser {
|
|
12277
12275
|
track.params[prop] = config[prop];
|
12278
12276
|
}
|
12279
12277
|
}
|
12280
|
-
|
12281
|
-
track.pps.push(unit.data);
|
12282
|
-
}
|
12278
|
+
this.pushParameterSet(track.pps, unit.data, track.vps);
|
12283
12279
|
}
|
12284
12280
|
break;
|
12285
12281
|
|
@@ -12310,6 +12306,11 @@ class HevcVideoParser extends BaseVideoParser {
|
|
12310
12306
|
this.VideoSample = null;
|
12311
12307
|
}
|
12312
12308
|
}
|
12309
|
+
pushParameterSet(parameterSets, data, vps) {
|
12310
|
+
if (vps && vps[0] === this.initVPS || !vps && !parameterSets.length) {
|
12311
|
+
parameterSets.push(data);
|
12312
|
+
}
|
12313
|
+
}
|
12313
12314
|
getNALuType(data, offset) {
|
12314
12315
|
return (data[offset] & 0x7e) >>> 1;
|
12315
12316
|
}
|
@@ -13375,7 +13376,6 @@ function parsePMT(data, offset, typeSupported, isSampleAes, observer, logger) {
|
|
13375
13376
|
// logger.log('AVC PID:' + pid);
|
13376
13377
|
if (result.videoPid === -1) {
|
13377
13378
|
result.videoPid = pid;
|
13378
|
-
result.segmentVideoCodec = 'avc';
|
13379
13379
|
}
|
13380
13380
|
break;
|
13381
13381
|
|
@@ -13812,7 +13812,7 @@ class MP4 {
|
|
13812
13812
|
0x00, 0x00]));
|
13813
13813
|
}
|
13814
13814
|
static mdia(track) {
|
13815
|
-
return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale, track.duration), MP4.hdlr(track.type), MP4.minf(track));
|
13815
|
+
return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale || 0, track.duration || 0), MP4.hdlr(track.type), MP4.minf(track));
|
13816
13816
|
}
|
13817
13817
|
static mfhd(sequenceNumber) {
|
13818
13818
|
return MP4.box(MP4.types.mfhd, new Uint8Array([0x00, 0x00, 0x00, 0x00,
|
@@ -13836,7 +13836,7 @@ class MP4 {
|
|
13836
13836
|
while (i--) {
|
13837
13837
|
boxes[i] = MP4.trak(tracks[i]);
|
13838
13838
|
}
|
13839
|
-
return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale, tracks[0].duration)].concat(boxes).concat(MP4.mvex(tracks)));
|
13839
|
+
return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale || 0, tracks[0].duration || 0)].concat(boxes).concat(MP4.mvex(tracks)));
|
13840
13840
|
}
|
13841
13841
|
static mvex(tracks) {
|
13842
13842
|
let i = tracks.length;
|
@@ -14022,7 +14022,7 @@ class MP4 {
|
|
14022
14022
|
]);
|
14023
14023
|
}
|
14024
14024
|
static audioStsd(track) {
|
14025
|
-
const samplerate = track.samplerate;
|
14025
|
+
const samplerate = track.samplerate || 0;
|
14026
14026
|
return new Uint8Array([0x00, 0x00, 0x00,
|
14027
14027
|
// reserved
|
14028
14028
|
0x00, 0x00, 0x00,
|
@@ -14031,7 +14031,7 @@ class MP4 {
|
|
14031
14031
|
// data_reference_index
|
14032
14032
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
14033
14033
|
// reserved
|
14034
|
-
0x00, track.channelCount,
|
14034
|
+
0x00, track.channelCount || 0,
|
14035
14035
|
// channelcount
|
14036
14036
|
0x00, 0x10,
|
14037
14037
|
// sampleSize:16bits
|
@@ -14051,25 +14051,38 @@ class MP4 {
|
|
14051
14051
|
return MP4.box(MP4.types['ac-3'], MP4.audioStsd(track), MP4.box(MP4.types.dac3, track.config));
|
14052
14052
|
}
|
14053
14053
|
static stsd(track) {
|
14054
|
+
const {
|
14055
|
+
segmentCodec
|
14056
|
+
} = track;
|
14054
14057
|
if (track.type === 'audio') {
|
14055
|
-
if (
|
14056
|
-
return MP4.box(MP4.types.stsd, MP4.STSD, MP4.
|
14058
|
+
if (segmentCodec === 'aac') {
|
14059
|
+
return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp4a(track));
|
14057
14060
|
}
|
14058
|
-
if (
|
14061
|
+
if (segmentCodec === 'ac3' && track.config) {
|
14059
14062
|
return MP4.box(MP4.types.stsd, MP4.STSD, MP4.ac3(track));
|
14060
14063
|
}
|
14061
|
-
|
14062
|
-
|
14063
|
-
|
14064
|
+
if (segmentCodec === 'mp3' && track.codec === 'mp3') {
|
14065
|
+
return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp3(track));
|
14066
|
+
}
|
14064
14067
|
} else {
|
14065
|
-
|
14068
|
+
if (track.pps && track.sps) {
|
14069
|
+
if (segmentCodec === 'avc') {
|
14070
|
+
return MP4.box(MP4.types.stsd, MP4.STSD, MP4.avc1(track));
|
14071
|
+
}
|
14072
|
+
if (segmentCodec === 'hevc' && track.vps) {
|
14073
|
+
return MP4.box(MP4.types.stsd, MP4.STSD, MP4.hvc1(track));
|
14074
|
+
}
|
14075
|
+
} else {
|
14076
|
+
throw new Error(`video track missing pps or sps`);
|
14077
|
+
}
|
14066
14078
|
}
|
14079
|
+
throw new Error(`unsupported ${track.type} segment codec (${segmentCodec}/${track.codec})`);
|
14067
14080
|
}
|
14068
14081
|
static tkhd(track) {
|
14069
14082
|
const id = track.id;
|
14070
|
-
const duration = track.duration * track.timescale;
|
14071
|
-
const width = track.width;
|
14072
|
-
const height = track.height;
|
14083
|
+
const duration = (track.duration || 0) * (track.timescale || 0);
|
14084
|
+
const width = track.width || 0;
|
14085
|
+
const height = track.height || 0;
|
14073
14086
|
const upperWordDuration = Math.floor(duration / (UINT32_MAX + 1));
|
14074
14087
|
const lowerWordDuration = Math.floor(duration % (UINT32_MAX + 1));
|
14075
14088
|
return MP4.box(MP4.types.tkhd, new Uint8Array([0x01,
|
@@ -14312,6 +14325,21 @@ const MPEG_AUDIO_SAMPLE_PER_FRAME = 1152;
|
|
14312
14325
|
const AC3_SAMPLES_PER_FRAME = 1536;
|
14313
14326
|
let chromeVersion = null;
|
14314
14327
|
let safariWebkitVersion = null;
|
14328
|
+
function createMp4Sample(isKeyframe, duration, size, cts) {
|
14329
|
+
return {
|
14330
|
+
duration,
|
14331
|
+
size,
|
14332
|
+
cts,
|
14333
|
+
flags: {
|
14334
|
+
isLeading: 0,
|
14335
|
+
isDependedOn: 0,
|
14336
|
+
hasRedundancy: 0,
|
14337
|
+
degradPrio: 0,
|
14338
|
+
dependsOn: isKeyframe ? 2 : 1,
|
14339
|
+
isNonSync: isKeyframe ? 0 : 1
|
14340
|
+
}
|
14341
|
+
};
|
14342
|
+
}
|
14315
14343
|
class MP4Remuxer {
|
14316
14344
|
constructor(observer, config, typeSupported, logger) {
|
14317
14345
|
this.logger = void 0;
|
@@ -14810,7 +14838,7 @@ class MP4Remuxer {
|
|
14810
14838
|
maxDtsDelta = Math.max(maxDtsDelta, mp4SampleDuration);
|
14811
14839
|
minPtsDelta = Math.min(minPtsDelta, ptsDelta);
|
14812
14840
|
maxPtsDelta = Math.max(maxPtsDelta, ptsDelta);
|
14813
|
-
outputSamples.push(
|
14841
|
+
outputSamples.push(createMp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset));
|
14814
14842
|
}
|
14815
14843
|
if (outputSamples.length) {
|
14816
14844
|
if (chromeVersion) {
|
@@ -14847,7 +14875,7 @@ class MP4Remuxer {
|
|
14847
14875
|
this.nextAvcDts = nextAvcDts = lastDTS + mp4SampleDuration;
|
14848
14876
|
this.videoSampleDuration = mp4SampleDuration;
|
14849
14877
|
this.isVideoContiguous = true;
|
14850
|
-
const moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends(
|
14878
|
+
const moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends(track, {
|
14851
14879
|
samples: outputSamples
|
14852
14880
|
}));
|
14853
14881
|
const type = 'video';
|
@@ -15049,7 +15077,7 @@ class MP4Remuxer {
|
|
15049
15077
|
// Default the sample's duration to the computed mp4SampleDuration, which will either be 1024 for AAC or 1152 for MPEG
|
15050
15078
|
// In the case that we have 1 sample, this will be the duration. If we have more than one sample, the duration
|
15051
15079
|
// becomes the PTS diff with the previous sample
|
15052
|
-
outputSamples.push(
|
15080
|
+
outputSamples.push(createMp4Sample(true, mp4SampleDuration, unitLen, 0));
|
15053
15081
|
lastPTS = pts;
|
15054
15082
|
}
|
15055
15083
|
|
@@ -15155,25 +15183,6 @@ function flushTextTrackUserdataCueSamples(track, timeOffset, initPTS) {
|
|
15155
15183
|
samples
|
15156
15184
|
};
|
15157
15185
|
}
|
15158
|
-
class Mp4Sample {
|
15159
|
-
constructor(isKeyframe, duration, size, cts) {
|
15160
|
-
this.size = void 0;
|
15161
|
-
this.duration = void 0;
|
15162
|
-
this.cts = void 0;
|
15163
|
-
this.flags = void 0;
|
15164
|
-
this.duration = duration;
|
15165
|
-
this.size = size;
|
15166
|
-
this.cts = cts;
|
15167
|
-
this.flags = {
|
15168
|
-
isLeading: 0,
|
15169
|
-
isDependedOn: 0,
|
15170
|
-
hasRedundancy: 0,
|
15171
|
-
degradPrio: 0,
|
15172
|
-
dependsOn: isKeyframe ? 2 : 1,
|
15173
|
-
isNonSync: isKeyframe ? 0 : 1
|
15174
|
-
};
|
15175
|
-
}
|
15176
|
-
}
|
15177
15186
|
|
15178
15187
|
class PassThroughRemuxer {
|
15179
15188
|
constructor(observer, config, typeSupported, logger) {
|
@@ -28828,7 +28837,6 @@ class FetchLoader {
|
|
28828
28837
|
}
|
28829
28838
|
stats.loading.start = self.performance.now();
|
28830
28839
|
const initParams = getRequestParameters(context, this.controller.signal);
|
28831
|
-
const onProgress = callbacks.onProgress;
|
28832
28840
|
const isArrayBuffer = context.responseType === 'arraybuffer';
|
28833
28841
|
const LENGTH = isArrayBuffer ? 'byteLength' : 'length';
|
28834
28842
|
const {
|
@@ -28842,18 +28850,23 @@ class FetchLoader {
|
|
28842
28850
|
self.clearTimeout(this.requestTimeout);
|
28843
28851
|
config.timeout = maxTimeToFirstByteMs && isFiniteNumber(maxTimeToFirstByteMs) ? maxTimeToFirstByteMs : maxLoadTimeMs;
|
28844
28852
|
this.requestTimeout = self.setTimeout(() => {
|
28845
|
-
this.
|
28846
|
-
|
28853
|
+
if (this.callbacks) {
|
28854
|
+
this.abortInternal();
|
28855
|
+
this.callbacks.onTimeout(stats, context, this.response);
|
28856
|
+
}
|
28847
28857
|
}, config.timeout);
|
28848
28858
|
const fetchPromise = isPromise(this.request) ? this.request.then(self.fetch) : self.fetch(this.request);
|
28849
28859
|
fetchPromise.then(response => {
|
28860
|
+
var _this$callbacks2;
|
28850
28861
|
this.response = this.loader = response;
|
28851
28862
|
const first = Math.max(self.performance.now(), stats.loading.start);
|
28852
28863
|
self.clearTimeout(this.requestTimeout);
|
28853
28864
|
config.timeout = maxLoadTimeMs;
|
28854
28865
|
this.requestTimeout = self.setTimeout(() => {
|
28855
|
-
this.
|
28856
|
-
|
28866
|
+
if (this.callbacks) {
|
28867
|
+
this.abortInternal();
|
28868
|
+
this.callbacks.onTimeout(stats, context, this.response);
|
28869
|
+
}
|
28857
28870
|
}, maxLoadTimeMs - (first - stats.loading.start));
|
28858
28871
|
if (!response.ok) {
|
28859
28872
|
const {
|
@@ -28864,6 +28877,7 @@ class FetchLoader {
|
|
28864
28877
|
}
|
28865
28878
|
stats.loading.first = first;
|
28866
28879
|
stats.total = getContentLength(response.headers) || stats.total;
|
28880
|
+
const onProgress = (_this$callbacks2 = this.callbacks) == null ? void 0 : _this$callbacks2.onProgress;
|
28867
28881
|
if (onProgress && isFiniteNumber(config.highWaterMark)) {
|
28868
28882
|
return this.loadProgressively(response, stats, context, config.highWaterMark, onProgress);
|
28869
28883
|
}
|
@@ -28875,6 +28889,7 @@ class FetchLoader {
|
|
28875
28889
|
}
|
28876
28890
|
return response.text();
|
28877
28891
|
}).then(responseData => {
|
28892
|
+
var _this$callbacks3, _this$callbacks4;
|
28878
28893
|
const response = this.response;
|
28879
28894
|
if (!response) {
|
28880
28895
|
throw new Error('loader destroyed');
|
@@ -28890,11 +28905,13 @@ class FetchLoader {
|
|
28890
28905
|
data: responseData,
|
28891
28906
|
code: response.status
|
28892
28907
|
};
|
28908
|
+
const onProgress = (_this$callbacks3 = this.callbacks) == null ? void 0 : _this$callbacks3.onProgress;
|
28893
28909
|
if (onProgress && !isFiniteNumber(config.highWaterMark)) {
|
28894
28910
|
onProgress(stats, context, responseData, response);
|
28895
28911
|
}
|
28896
|
-
callbacks.onSuccess(loaderResponse, stats, context, response);
|
28912
|
+
(_this$callbacks4 = this.callbacks) == null ? void 0 : _this$callbacks4.onSuccess(loaderResponse, stats, context, response);
|
28897
28913
|
}).catch(error => {
|
28914
|
+
var _this$callbacks5;
|
28898
28915
|
self.clearTimeout(this.requestTimeout);
|
28899
28916
|
if (stats.aborted) {
|
28900
28917
|
return;
|
@@ -28903,7 +28920,7 @@ class FetchLoader {
|
|
28903
28920
|
// when destroying, 'error' itself can be undefined
|
28904
28921
|
const code = !error ? 0 : error.code || 0;
|
28905
28922
|
const text = !error ? null : error.message;
|
28906
|
-
callbacks.onError({
|
28923
|
+
(_this$callbacks5 = this.callbacks) == null ? void 0 : _this$callbacks5.onError({
|
28907
28924
|
code,
|
28908
28925
|
text
|
28909
28926
|
}, context, error ? error.details : null, stats);
|
@@ -29081,8 +29098,9 @@ class XhrLoader {
|
|
29081
29098
|
if (this.loader !== xhr || this.stats.aborted) return;
|
29082
29099
|
this.openAndSendXhr(xhr, context, config);
|
29083
29100
|
}).catch(error => {
|
29101
|
+
var _this$callbacks2;
|
29084
29102
|
// IE11 throws an exception on xhr.open if attempting to access an HTTP resource over HTTPS
|
29085
|
-
this.callbacks.onError({
|
29103
|
+
(_this$callbacks2 = this.callbacks) == null ? void 0 : _this$callbacks2.onError({
|
29086
29104
|
code: xhr.status,
|
29087
29105
|
text: error.message
|
29088
29106
|
}, context, xhr, stats);
|
@@ -29156,26 +29174,21 @@ class XhrLoader {
|
|
29156
29174
|
if (status >= 200 && status < 300) {
|
29157
29175
|
const data = useResponseText != null ? useResponseText : xhr.response;
|
29158
29176
|
if (data != null) {
|
29177
|
+
var _this$callbacks3, _this$callbacks4;
|
29159
29178
|
stats.loading.end = Math.max(self.performance.now(), stats.loading.first);
|
29160
29179
|
const len = xhr.responseType === 'arraybuffer' ? data.byteLength : data.length;
|
29161
29180
|
stats.loaded = stats.total = len;
|
29162
29181
|
stats.bwEstimate = stats.total * 8000 / (stats.loading.end - stats.loading.first);
|
29163
|
-
|
29164
|
-
return;
|
29165
|
-
}
|
29166
|
-
const onProgress = this.callbacks.onProgress;
|
29182
|
+
const onProgress = (_this$callbacks3 = this.callbacks) == null ? void 0 : _this$callbacks3.onProgress;
|
29167
29183
|
if (onProgress) {
|
29168
29184
|
onProgress(stats, context, data, xhr);
|
29169
29185
|
}
|
29170
|
-
if (!this.callbacks) {
|
29171
|
-
return;
|
29172
|
-
}
|
29173
29186
|
const _response = {
|
29174
29187
|
url: xhr.responseURL,
|
29175
29188
|
data: data,
|
29176
29189
|
code: status
|
29177
29190
|
};
|
29178
|
-
this.callbacks.onSuccess(_response, stats, context, xhr);
|
29191
|
+
(_this$callbacks4 = this.callbacks) == null ? void 0 : _this$callbacks4.onSuccess(_response, stats, context, xhr);
|
29179
29192
|
return;
|
29180
29193
|
}
|
29181
29194
|
}
|
@@ -29192,8 +29205,9 @@ class XhrLoader {
|
|
29192
29205
|
if (shouldRetry(retryConfig, retryCount, false, response)) {
|
29193
29206
|
this.retry(retryConfig);
|
29194
29207
|
} else {
|
29208
|
+
var _this$callbacks5;
|
29195
29209
|
logger.error(`${status} while loading ${context.url}`);
|
29196
|
-
this.callbacks.onError({
|
29210
|
+
(_this$callbacks5 = this.callbacks) == null ? void 0 : _this$callbacks5.onError({
|
29197
29211
|
code: status,
|
29198
29212
|
text: xhr.statusText
|
29199
29213
|
}, context, xhr, stats);
|