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.light.js CHANGED
@@ -1029,7 +1029,7 @@
1029
1029
  // Some browsers don't allow to use bind on console object anyway
1030
1030
  // fallback to default if needed
1031
1031
  try {
1032
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.2.0.canary.10871");
1032
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.2.0.canary.10876");
1033
1033
  } catch (e) {
1034
1034
  /* log fn threw an exception. All logger methods are no-ops. */
1035
1035
  return createLogger();
@@ -12041,7 +12041,6 @@
12041
12041
  // logger.log('AVC PID:' + pid);
12042
12042
  if (result.videoPid === -1) {
12043
12043
  result.videoPid = pid;
12044
- result.segmentVideoCodec = 'avc';
12045
12044
  }
12046
12045
  break;
12047
12046
 
@@ -12469,7 +12468,7 @@
12469
12468
  0x00, 0x00]));
12470
12469
  };
12471
12470
  MP4.mdia = function mdia(track) {
12472
- return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale, track.duration), MP4.hdlr(track.type), MP4.minf(track));
12471
+ return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale || 0, track.duration || 0), MP4.hdlr(track.type), MP4.minf(track));
12473
12472
  };
12474
12473
  MP4.mfhd = function mfhd(sequenceNumber) {
12475
12474
  return MP4.box(MP4.types.mfhd, new Uint8Array([0x00, 0x00, 0x00, 0x00,
@@ -12493,7 +12492,7 @@
12493
12492
  while (i--) {
12494
12493
  boxes[i] = MP4.trak(tracks[i]);
12495
12494
  }
12496
- return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale, tracks[0].duration)].concat(boxes).concat(MP4.mvex(tracks)));
12495
+ return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale || 0, tracks[0].duration || 0)].concat(boxes).concat(MP4.mvex(tracks)));
12497
12496
  };
12498
12497
  MP4.mvex = function mvex(tracks) {
12499
12498
  var i = tracks.length;
@@ -12677,7 +12676,7 @@
12677
12676
  ]));
12678
12677
  };
12679
12678
  MP4.audioStsd = function audioStsd(track) {
12680
- var samplerate = track.samplerate;
12679
+ var samplerate = track.samplerate || 0;
12681
12680
  return new Uint8Array([0x00, 0x00, 0x00,
12682
12681
  // reserved
12683
12682
  0x00, 0x00, 0x00,
@@ -12686,7 +12685,7 @@
12686
12685
  // data_reference_index
12687
12686
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12688
12687
  // reserved
12689
- 0x00, track.channelCount,
12688
+ 0x00, track.channelCount || 0,
12690
12689
  // channelcount
12691
12690
  0x00, 0x10,
12692
12691
  // sampleSize:16bits
@@ -12706,25 +12705,30 @@
12706
12705
  return MP4.box(MP4.types['ac-3'], MP4.audioStsd(track), MP4.box(MP4.types.dac3, track.config));
12707
12706
  };
12708
12707
  MP4.stsd = function stsd(track) {
12708
+ var segmentCodec = track.segmentCodec;
12709
12709
  if (track.type === 'audio') {
12710
- if (track.segmentCodec === 'mp3' && track.codec === 'mp3') {
12711
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp3(track));
12710
+ if (segmentCodec === 'aac') {
12711
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp4a(track));
12712
12712
  }
12713
- if (track.segmentCodec === 'ac3') {
12714
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.ac3(track));
12713
+ if (segmentCodec === 'mp3' && track.codec === 'mp3') {
12714
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp3(track));
12715
12715
  }
12716
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp4a(track));
12717
- } else if (track.segmentCodec === 'avc') {
12718
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.avc1(track));
12719
12716
  } else {
12720
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.hvc1(track));
12717
+ if (track.pps && track.sps) {
12718
+ if (segmentCodec === 'avc') {
12719
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.avc1(track));
12720
+ }
12721
+ } else {
12722
+ throw new Error("video track missing pps or sps");
12723
+ }
12721
12724
  }
12725
+ throw new Error("unsupported " + track.type + " segment codec (" + segmentCodec + "/" + track.codec + ")");
12722
12726
  };
12723
12727
  MP4.tkhd = function tkhd(track) {
12724
12728
  var id = track.id;
12725
- var duration = track.duration * track.timescale;
12726
- var width = track.width;
12727
- var height = track.height;
12729
+ var duration = (track.duration || 0) * (track.timescale || 0);
12730
+ var width = track.width || 0;
12731
+ var height = track.height || 0;
12728
12732
  var upperWordDuration = Math.floor(duration / (UINT32_MAX + 1));
12729
12733
  var lowerWordDuration = Math.floor(duration % (UINT32_MAX + 1));
12730
12734
  return MP4.box(MP4.types.tkhd, new Uint8Array([0x01,
@@ -12856,82 +12860,9 @@
12856
12860
  return result;
12857
12861
  };
12858
12862
  MP4.hvc1 = function hvc1(track) {
12859
- var ps = track.params;
12860
- var units = [track.vps, track.sps, track.pps];
12861
- var NALuLengthSize = 4;
12862
- var config = new Uint8Array([0x01, ps.general_profile_space << 6 | (ps.general_tier_flag ? 32 : 0) | ps.general_profile_idc, ps.general_profile_compatibility_flags[0], ps.general_profile_compatibility_flags[1], ps.general_profile_compatibility_flags[2], ps.general_profile_compatibility_flags[3], ps.general_constraint_indicator_flags[0], ps.general_constraint_indicator_flags[1], ps.general_constraint_indicator_flags[2], ps.general_constraint_indicator_flags[3], ps.general_constraint_indicator_flags[4], ps.general_constraint_indicator_flags[5], ps.general_level_idc, 240 | ps.min_spatial_segmentation_idc >> 8, 255 & ps.min_spatial_segmentation_idc, 252 | ps.parallelismType, 252 | ps.chroma_format_idc, 248 | ps.bit_depth_luma_minus8, 248 | ps.bit_depth_chroma_minus8, 0x00, parseInt(ps.frame_rate.fps), NALuLengthSize - 1 | ps.temporal_id_nested << 2 | ps.num_temporal_layers << 3 | (ps.frame_rate.fixed ? 64 : 0), units.length]);
12863
-
12864
- // compute hvcC size in bytes
12865
- var length = config.length;
12866
- for (var i = 0; i < units.length; i += 1) {
12867
- length += 3;
12868
- for (var j = 0; j < units[i].length; j += 1) {
12869
- length += 2 + units[i][j].length;
12870
- }
12871
- }
12872
- var hvcC = new Uint8Array(length);
12873
- hvcC.set(config, 0);
12874
- length = config.length;
12875
- // append parameter set units: one vps, one or more sps and pps
12876
- var iMax = units.length - 1;
12877
- for (var _i = 0; _i < units.length; _i += 1) {
12878
- hvcC.set(new Uint8Array([32 + _i | (_i === iMax ? 128 : 0), 0x00, units[_i].length]), length);
12879
- length += 3;
12880
- for (var _j = 0; _j < units[_i].length; _j += 1) {
12881
- hvcC.set(new Uint8Array([units[_i][_j].length >> 8, units[_i][_j].length & 255]), length);
12882
- length += 2;
12883
- hvcC.set(units[_i][_j], length);
12884
- length += units[_i][_j].length;
12885
- }
12886
- }
12887
- var hvcc = MP4.box(MP4.types.hvcC, hvcC);
12888
- var width = track.width;
12889
- var height = track.height;
12890
- var hSpacing = track.pixelRatio[0];
12891
- var vSpacing = track.pixelRatio[1];
12892
- return MP4.box(MP4.types.hvc1, new Uint8Array([0x00, 0x00, 0x00,
12893
- // reserved
12894
- 0x00, 0x00, 0x00,
12895
- // reserved
12896
- 0x00, 0x01,
12897
- // data_reference_index
12898
- 0x00, 0x00,
12899
- // pre_defined
12900
- 0x00, 0x00,
12901
- // reserved
12902
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12903
- // pre_defined
12904
- width >> 8 & 0xff, width & 0xff,
12905
- // width
12906
- height >> 8 & 0xff, height & 0xff,
12907
- // height
12908
- 0x00, 0x48, 0x00, 0x00,
12909
- // horizresolution
12910
- 0x00, 0x48, 0x00, 0x00,
12911
- // vertresolution
12912
- 0x00, 0x00, 0x00, 0x00,
12913
- // reserved
12914
- 0x00, 0x01,
12915
- // frame_count
12916
- 0x12, 0x64, 0x61, 0x69, 0x6c,
12917
- // dailymotion/hls.js
12918
- 0x79, 0x6d, 0x6f, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x68, 0x6c, 0x73, 0x2e, 0x6a, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12919
- // compressorname
12920
- 0x00, 0x18,
12921
- // depth = 24
12922
- 0x11, 0x11]),
12923
- // pre_defined = -1
12924
- hvcc, MP4.box(MP4.types.btrt, new Uint8Array([0x00, 0x1c, 0x9c, 0x80,
12925
- // bufferSizeDB
12926
- 0x00, 0x2d, 0xc6, 0xc0,
12927
- // maxBitrate
12928
- 0x00, 0x2d, 0xc6, 0xc0])),
12929
- // avgBitrate
12930
- MP4.box(MP4.types.pasp, new Uint8Array([hSpacing >> 24,
12931
- // hSpacing
12932
- hSpacing >> 16 & 0xff, hSpacing >> 8 & 0xff, hSpacing & 0xff, vSpacing >> 24,
12933
- // vSpacing
12934
- vSpacing >> 16 & 0xff, vSpacing >> 8 & 0xff, vSpacing & 0xff])));
12863
+ {
12864
+ return new Uint8Array();
12865
+ }
12935
12866
  };
12936
12867
  return MP4;
12937
12868
  }();
@@ -12965,6 +12896,21 @@
12965
12896
  var AC3_SAMPLES_PER_FRAME = 1536;
12966
12897
  var chromeVersion = null;
12967
12898
  var safariWebkitVersion = null;
12899
+ function createMp4Sample(isKeyframe, duration, size, cts) {
12900
+ return {
12901
+ duration: duration,
12902
+ size: size,
12903
+ cts: cts,
12904
+ flags: {
12905
+ isLeading: 0,
12906
+ isDependedOn: 0,
12907
+ hasRedundancy: 0,
12908
+ degradPrio: 0,
12909
+ dependsOn: isKeyframe ? 2 : 1,
12910
+ isNonSync: isKeyframe ? 0 : 1
12911
+ }
12912
+ };
12913
+ }
12968
12914
  var MP4Remuxer = /*#__PURE__*/function () {
12969
12915
  function MP4Remuxer(observer, config, typeSupported, logger) {
12970
12916
  this.logger = void 0;
@@ -13464,7 +13410,7 @@
13464
13410
  maxDtsDelta = Math.max(maxDtsDelta, mp4SampleDuration);
13465
13411
  minPtsDelta = Math.min(minPtsDelta, ptsDelta);
13466
13412
  maxPtsDelta = Math.max(maxPtsDelta, ptsDelta);
13467
- outputSamples.push(new Mp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset));
13413
+ outputSamples.push(createMp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset));
13468
13414
  }
13469
13415
  if (outputSamples.length) {
13470
13416
  if (chromeVersion) {
@@ -13501,7 +13447,7 @@
13501
13447
  this.nextAvcDts = nextAvcDts = lastDTS + mp4SampleDuration;
13502
13448
  this.videoSampleDuration = mp4SampleDuration;
13503
13449
  this.isVideoContiguous = true;
13504
- var moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends({}, track, {
13450
+ var moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends(track, {
13505
13451
  samples: outputSamples
13506
13452
  }));
13507
13453
  var type = 'video';
@@ -13705,7 +13651,7 @@
13705
13651
  // Default the sample's duration to the computed mp4SampleDuration, which will either be 1024 for AAC or 1152 for MPEG
13706
13652
  // In the case that we have 1 sample, this will be the duration. If we have more than one sample, the duration
13707
13653
  // becomes the PTS diff with the previous sample
13708
- outputSamples.push(new Mp4Sample(true, mp4SampleDuration, unitLen, 0));
13654
+ outputSamples.push(createMp4Sample(true, mp4SampleDuration, unitLen, 0));
13709
13655
  lastPTS = _pts2;
13710
13656
  }
13711
13657
 
@@ -13814,23 +13760,6 @@
13814
13760
  samples: samples
13815
13761
  };
13816
13762
  }
13817
- var Mp4Sample = function Mp4Sample(isKeyframe, duration, size, cts) {
13818
- this.size = void 0;
13819
- this.duration = void 0;
13820
- this.cts = void 0;
13821
- this.flags = void 0;
13822
- this.duration = duration;
13823
- this.size = size;
13824
- this.cts = cts;
13825
- this.flags = {
13826
- isLeading: 0,
13827
- isDependedOn: 0,
13828
- hasRedundancy: 0,
13829
- degradPrio: 0,
13830
- dependsOn: isKeyframe ? 2 : 1,
13831
- isNonSync: isKeyframe ? 0 : 1
13832
- };
13833
- };
13834
13763
 
13835
13764
  var PassThroughRemuxer = /*#__PURE__*/function () {
13836
13765
  function PassThroughRemuxer(observer, config, typeSupported, logger) {
@@ -14454,7 +14383,6 @@
14454
14383
  }
14455
14384
  stats.loading.start = self.performance.now();
14456
14385
  var initParams = getRequestParameters(context, this.controller.signal);
14457
- var onProgress = callbacks.onProgress;
14458
14386
  var isArrayBuffer = context.responseType === 'arraybuffer';
14459
14387
  var LENGTH = isArrayBuffer ? 'byteLength' : 'length';
14460
14388
  var _config$loadPolicy = config.loadPolicy,
@@ -14467,18 +14395,23 @@
14467
14395
  self.clearTimeout(this.requestTimeout);
14468
14396
  config.timeout = maxTimeToFirstByteMs && isFiniteNumber(maxTimeToFirstByteMs) ? maxTimeToFirstByteMs : maxLoadTimeMs;
14469
14397
  this.requestTimeout = self.setTimeout(function () {
14470
- _this.abortInternal();
14471
- callbacks.onTimeout(stats, context, _this.response);
14398
+ if (_this.callbacks) {
14399
+ _this.abortInternal();
14400
+ _this.callbacks.onTimeout(stats, context, _this.response);
14401
+ }
14472
14402
  }, config.timeout);
14473
14403
  var fetchPromise = isPromise(this.request) ? this.request.then(self.fetch) : self.fetch(this.request);
14474
14404
  fetchPromise.then(function (response) {
14405
+ var _this$callbacks2;
14475
14406
  _this.response = _this.loader = response;
14476
14407
  var first = Math.max(self.performance.now(), stats.loading.start);
14477
14408
  self.clearTimeout(_this.requestTimeout);
14478
14409
  config.timeout = maxLoadTimeMs;
14479
14410
  _this.requestTimeout = self.setTimeout(function () {
14480
- _this.abortInternal();
14481
- callbacks.onTimeout(stats, context, _this.response);
14411
+ if (_this.callbacks) {
14412
+ _this.abortInternal();
14413
+ _this.callbacks.onTimeout(stats, context, _this.response);
14414
+ }
14482
14415
  }, maxLoadTimeMs - (first - stats.loading.start));
14483
14416
  if (!response.ok) {
14484
14417
  var status = response.status,
@@ -14487,6 +14420,7 @@
14487
14420
  }
14488
14421
  stats.loading.first = first;
14489
14422
  stats.total = getContentLength(response.headers) || stats.total;
14423
+ var onProgress = (_this$callbacks2 = _this.callbacks) == null ? void 0 : _this$callbacks2.onProgress;
14490
14424
  if (onProgress && isFiniteNumber(config.highWaterMark)) {
14491
14425
  return _this.loadProgressively(response, stats, context, config.highWaterMark, onProgress);
14492
14426
  }
@@ -14498,6 +14432,7 @@
14498
14432
  }
14499
14433
  return response.text();
14500
14434
  }).then(function (responseData) {
14435
+ var _this$callbacks3, _this$callbacks4;
14501
14436
  var response = _this.response;
14502
14437
  if (!response) {
14503
14438
  throw new Error('loader destroyed');
@@ -14513,11 +14448,13 @@
14513
14448
  data: responseData,
14514
14449
  code: response.status
14515
14450
  };
14451
+ var onProgress = (_this$callbacks3 = _this.callbacks) == null ? void 0 : _this$callbacks3.onProgress;
14516
14452
  if (onProgress && !isFiniteNumber(config.highWaterMark)) {
14517
14453
  onProgress(stats, context, responseData, response);
14518
14454
  }
14519
- callbacks.onSuccess(loaderResponse, stats, context, response);
14455
+ (_this$callbacks4 = _this.callbacks) == null ? void 0 : _this$callbacks4.onSuccess(loaderResponse, stats, context, response);
14520
14456
  }).catch(function (error) {
14457
+ var _this$callbacks5;
14521
14458
  self.clearTimeout(_this.requestTimeout);
14522
14459
  if (stats.aborted) {
14523
14460
  return;
@@ -14526,7 +14463,7 @@
14526
14463
  // when destroying, 'error' itself can be undefined
14527
14464
  var code = !error ? 0 : error.code || 0;
14528
14465
  var text = !error ? null : error.message;
14529
- callbacks.onError({
14466
+ (_this$callbacks5 = _this.callbacks) == null ? void 0 : _this$callbacks5.onError({
14530
14467
  code: code,
14531
14468
  text: text
14532
14469
  }, context, error ? error.details : null, stats);
@@ -14712,8 +14649,9 @@
14712
14649
  if (_this.loader !== xhr || _this.stats.aborted) return;
14713
14650
  _this.openAndSendXhr(xhr, context, config);
14714
14651
  }).catch(function (error) {
14652
+ var _this$callbacks2;
14715
14653
  // IE11 throws an exception on xhr.open if attempting to access an HTTP resource over HTTPS
14716
- _this.callbacks.onError({
14654
+ (_this$callbacks2 = _this.callbacks) == null ? void 0 : _this$callbacks2.onError({
14717
14655
  code: xhr.status,
14718
14656
  text: error.message
14719
14657
  }, context, xhr, stats);
@@ -14784,26 +14722,21 @@
14784
14722
  if (_status >= 200 && _status < 300) {
14785
14723
  var data = useResponseText != null ? useResponseText : xhr.response;
14786
14724
  if (data != null) {
14725
+ var _this$callbacks3, _this$callbacks4;
14787
14726
  stats.loading.end = Math.max(self.performance.now(), stats.loading.first);
14788
14727
  var len = xhr.responseType === 'arraybuffer' ? data.byteLength : data.length;
14789
14728
  stats.loaded = stats.total = len;
14790
14729
  stats.bwEstimate = stats.total * 8000 / (stats.loading.end - stats.loading.first);
14791
- if (!this.callbacks) {
14792
- return;
14793
- }
14794
- var onProgress = this.callbacks.onProgress;
14730
+ var onProgress = (_this$callbacks3 = this.callbacks) == null ? void 0 : _this$callbacks3.onProgress;
14795
14731
  if (onProgress) {
14796
14732
  onProgress(stats, context, data, xhr);
14797
14733
  }
14798
- if (!this.callbacks) {
14799
- return;
14800
- }
14801
14734
  var _response = {
14802
14735
  url: xhr.responseURL,
14803
14736
  data: data,
14804
14737
  code: _status
14805
14738
  };
14806
- this.callbacks.onSuccess(_response, stats, context, xhr);
14739
+ (_this$callbacks4 = this.callbacks) == null ? void 0 : _this$callbacks4.onSuccess(_response, stats, context, xhr);
14807
14740
  return;
14808
14741
  }
14809
14742
  }
@@ -14820,8 +14753,9 @@
14820
14753
  if (shouldRetry(retryConfig, retryCount, false, response)) {
14821
14754
  this.retry(retryConfig);
14822
14755
  } else {
14756
+ var _this$callbacks5;
14823
14757
  logger.error(_status + " while loading " + context.url);
14824
- this.callbacks.onError({
14758
+ (_this$callbacks5 = this.callbacks) == null ? void 0 : _this$callbacks5.onError({
14825
14759
  code: _status,
14826
14760
  text: xhr.statusText
14827
14761
  }, context, xhr, stats);
@@ -19801,7 +19735,7 @@
19801
19735
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
19802
19736
  }
19803
19737
 
19804
- var version = "1.6.0-beta.2.0.canary.10871";
19738
+ var version = "1.6.0-beta.2.0.canary.10876";
19805
19739
 
19806
19740
  // ensure the worker ends up in the bundle
19807
19741
  // If the worker should not be included this gets aliased to empty.js