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.
@@ -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.10871"}`);
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();
@@ -14345,7 +14345,6 @@ function parsePMT(data, offset, typeSupported, isSampleAes, observer, logger) {
14345
14345
  // logger.log('AVC PID:' + pid);
14346
14346
  if (result.videoPid === -1) {
14347
14347
  result.videoPid = pid;
14348
- result.segmentVideoCodec = 'avc';
14349
14348
  }
14350
14349
  break;
14351
14350
 
@@ -14768,7 +14767,7 @@ class MP4 {
14768
14767
  0x00, 0x00]));
14769
14768
  }
14770
14769
  static mdia(track) {
14771
- return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale, track.duration), MP4.hdlr(track.type), MP4.minf(track));
14770
+ return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale || 0, track.duration || 0), MP4.hdlr(track.type), MP4.minf(track));
14772
14771
  }
14773
14772
  static mfhd(sequenceNumber) {
14774
14773
  return MP4.box(MP4.types.mfhd, new Uint8Array([0x00, 0x00, 0x00, 0x00,
@@ -14792,7 +14791,7 @@ class MP4 {
14792
14791
  while (i--) {
14793
14792
  boxes[i] = MP4.trak(tracks[i]);
14794
14793
  }
14795
- return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale, tracks[0].duration)].concat(boxes).concat(MP4.mvex(tracks)));
14794
+ return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale || 0, tracks[0].duration || 0)].concat(boxes).concat(MP4.mvex(tracks)));
14796
14795
  }
14797
14796
  static mvex(tracks) {
14798
14797
  let i = tracks.length;
@@ -14978,7 +14977,7 @@ class MP4 {
14978
14977
  ]);
14979
14978
  }
14980
14979
  static audioStsd(track) {
14981
- const samplerate = track.samplerate;
14980
+ const samplerate = track.samplerate || 0;
14982
14981
  return new Uint8Array([0x00, 0x00, 0x00,
14983
14982
  // reserved
14984
14983
  0x00, 0x00, 0x00,
@@ -14987,7 +14986,7 @@ class MP4 {
14987
14986
  // data_reference_index
14988
14987
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14989
14988
  // reserved
14990
- 0x00, track.channelCount,
14989
+ 0x00, track.channelCount || 0,
14991
14990
  // channelcount
14992
14991
  0x00, 0x10,
14993
14992
  // sampleSize:16bits
@@ -15007,25 +15006,32 @@ class MP4 {
15007
15006
  return MP4.box(MP4.types['ac-3'], MP4.audioStsd(track), MP4.box(MP4.types.dac3, track.config));
15008
15007
  }
15009
15008
  static stsd(track) {
15009
+ const {
15010
+ segmentCodec
15011
+ } = track;
15010
15012
  if (track.type === 'audio') {
15011
- if (track.segmentCodec === 'mp3' && track.codec === 'mp3') {
15012
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp3(track));
15013
+ if (segmentCodec === 'aac') {
15014
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp4a(track));
15013
15015
  }
15014
- if (track.segmentCodec === 'ac3') {
15015
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.ac3(track));
15016
+ if (segmentCodec === 'mp3' && track.codec === 'mp3') {
15017
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp3(track));
15016
15018
  }
15017
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp4a(track));
15018
- } else if (track.segmentCodec === 'avc') {
15019
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.avc1(track));
15020
15019
  } else {
15021
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.hvc1(track));
15020
+ if (track.pps && track.sps) {
15021
+ if (segmentCodec === 'avc') {
15022
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.avc1(track));
15023
+ }
15024
+ } else {
15025
+ throw new Error(`video track missing pps or sps`);
15026
+ }
15022
15027
  }
15028
+ throw new Error(`unsupported ${track.type} segment codec (${segmentCodec}/${track.codec})`);
15023
15029
  }
15024
15030
  static tkhd(track) {
15025
15031
  const id = track.id;
15026
- const duration = track.duration * track.timescale;
15027
- const width = track.width;
15028
- const height = track.height;
15032
+ const duration = (track.duration || 0) * (track.timescale || 0);
15033
+ const width = track.width || 0;
15034
+ const height = track.height || 0;
15029
15035
  const upperWordDuration = Math.floor(duration / (UINT32_MAX + 1));
15030
15036
  const lowerWordDuration = Math.floor(duration % (UINT32_MAX + 1));
15031
15037
  return MP4.box(MP4.types.tkhd, new Uint8Array([0x01,
@@ -15157,82 +15163,9 @@ class MP4 {
15157
15163
  return result;
15158
15164
  }
15159
15165
  static hvc1(track) {
15160
- const ps = track.params;
15161
- const units = [track.vps, track.sps, track.pps];
15162
- const NALuLengthSize = 4;
15163
- const 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]);
15164
-
15165
- // compute hvcC size in bytes
15166
- let length = config.length;
15167
- for (let i = 0; i < units.length; i += 1) {
15168
- length += 3;
15169
- for (let j = 0; j < units[i].length; j += 1) {
15170
- length += 2 + units[i][j].length;
15171
- }
15172
- }
15173
- const hvcC = new Uint8Array(length);
15174
- hvcC.set(config, 0);
15175
- length = config.length;
15176
- // append parameter set units: one vps, one or more sps and pps
15177
- const iMax = units.length - 1;
15178
- for (let i = 0; i < units.length; i += 1) {
15179
- hvcC.set(new Uint8Array([32 + i | (i === iMax ? 128 : 0), 0x00, units[i].length]), length);
15180
- length += 3;
15181
- for (let j = 0; j < units[i].length; j += 1) {
15182
- hvcC.set(new Uint8Array([units[i][j].length >> 8, units[i][j].length & 255]), length);
15183
- length += 2;
15184
- hvcC.set(units[i][j], length);
15185
- length += units[i][j].length;
15186
- }
15187
- }
15188
- const hvcc = MP4.box(MP4.types.hvcC, hvcC);
15189
- const width = track.width;
15190
- const height = track.height;
15191
- const hSpacing = track.pixelRatio[0];
15192
- const vSpacing = track.pixelRatio[1];
15193
- return MP4.box(MP4.types.hvc1, new Uint8Array([0x00, 0x00, 0x00,
15194
- // reserved
15195
- 0x00, 0x00, 0x00,
15196
- // reserved
15197
- 0x00, 0x01,
15198
- // data_reference_index
15199
- 0x00, 0x00,
15200
- // pre_defined
15201
- 0x00, 0x00,
15202
- // reserved
15203
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15204
- // pre_defined
15205
- width >> 8 & 0xff, width & 0xff,
15206
- // width
15207
- height >> 8 & 0xff, height & 0xff,
15208
- // height
15209
- 0x00, 0x48, 0x00, 0x00,
15210
- // horizresolution
15211
- 0x00, 0x48, 0x00, 0x00,
15212
- // vertresolution
15213
- 0x00, 0x00, 0x00, 0x00,
15214
- // reserved
15215
- 0x00, 0x01,
15216
- // frame_count
15217
- 0x12, 0x64, 0x61, 0x69, 0x6c,
15218
- // dailymotion/hls.js
15219
- 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,
15220
- // compressorname
15221
- 0x00, 0x18,
15222
- // depth = 24
15223
- 0x11, 0x11]),
15224
- // pre_defined = -1
15225
- hvcc, MP4.box(MP4.types.btrt, new Uint8Array([0x00, 0x1c, 0x9c, 0x80,
15226
- // bufferSizeDB
15227
- 0x00, 0x2d, 0xc6, 0xc0,
15228
- // maxBitrate
15229
- 0x00, 0x2d, 0xc6, 0xc0])),
15230
- // avgBitrate
15231
- MP4.box(MP4.types.pasp, new Uint8Array([hSpacing >> 24,
15232
- // hSpacing
15233
- hSpacing >> 16 & 0xff, hSpacing >> 8 & 0xff, hSpacing & 0xff, vSpacing >> 24,
15234
- // vSpacing
15235
- vSpacing >> 16 & 0xff, vSpacing >> 8 & 0xff, vSpacing & 0xff])));
15166
+ {
15167
+ return new Uint8Array();
15168
+ }
15236
15169
  }
15237
15170
  }
15238
15171
  MP4.types = void 0;
@@ -15262,6 +15195,21 @@ const MPEG_AUDIO_SAMPLE_PER_FRAME = 1152;
15262
15195
  const AC3_SAMPLES_PER_FRAME = 1536;
15263
15196
  let chromeVersion = null;
15264
15197
  let safariWebkitVersion = null;
15198
+ function createMp4Sample(isKeyframe, duration, size, cts) {
15199
+ return {
15200
+ duration,
15201
+ size,
15202
+ cts,
15203
+ flags: {
15204
+ isLeading: 0,
15205
+ isDependedOn: 0,
15206
+ hasRedundancy: 0,
15207
+ degradPrio: 0,
15208
+ dependsOn: isKeyframe ? 2 : 1,
15209
+ isNonSync: isKeyframe ? 0 : 1
15210
+ }
15211
+ };
15212
+ }
15265
15213
  class MP4Remuxer {
15266
15214
  constructor(observer, config, typeSupported, logger) {
15267
15215
  this.logger = void 0;
@@ -15760,7 +15708,7 @@ class MP4Remuxer {
15760
15708
  maxDtsDelta = Math.max(maxDtsDelta, mp4SampleDuration);
15761
15709
  minPtsDelta = Math.min(minPtsDelta, ptsDelta);
15762
15710
  maxPtsDelta = Math.max(maxPtsDelta, ptsDelta);
15763
- outputSamples.push(new Mp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset));
15711
+ outputSamples.push(createMp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset));
15764
15712
  }
15765
15713
  if (outputSamples.length) {
15766
15714
  if (chromeVersion) {
@@ -15797,7 +15745,7 @@ class MP4Remuxer {
15797
15745
  this.nextAvcDts = nextAvcDts = lastDTS + mp4SampleDuration;
15798
15746
  this.videoSampleDuration = mp4SampleDuration;
15799
15747
  this.isVideoContiguous = true;
15800
- const moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends({}, track, {
15748
+ const moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends(track, {
15801
15749
  samples: outputSamples
15802
15750
  }));
15803
15751
  const type = 'video';
@@ -15999,7 +15947,7 @@ class MP4Remuxer {
15999
15947
  // Default the sample's duration to the computed mp4SampleDuration, which will either be 1024 for AAC or 1152 for MPEG
16000
15948
  // In the case that we have 1 sample, this will be the duration. If we have more than one sample, the duration
16001
15949
  // becomes the PTS diff with the previous sample
16002
- outputSamples.push(new Mp4Sample(true, mp4SampleDuration, unitLen, 0));
15950
+ outputSamples.push(createMp4Sample(true, mp4SampleDuration, unitLen, 0));
16003
15951
  lastPTS = pts;
16004
15952
  }
16005
15953
 
@@ -16105,25 +16053,6 @@ function flushTextTrackUserdataCueSamples(track, timeOffset, initPTS) {
16105
16053
  samples
16106
16054
  };
16107
16055
  }
16108
- class Mp4Sample {
16109
- constructor(isKeyframe, duration, size, cts) {
16110
- this.size = void 0;
16111
- this.duration = void 0;
16112
- this.cts = void 0;
16113
- this.flags = void 0;
16114
- this.duration = duration;
16115
- this.size = size;
16116
- this.cts = cts;
16117
- this.flags = {
16118
- isLeading: 0,
16119
- isDependedOn: 0,
16120
- hasRedundancy: 0,
16121
- degradPrio: 0,
16122
- dependsOn: isKeyframe ? 2 : 1,
16123
- isNonSync: isKeyframe ? 0 : 1
16124
- };
16125
- }
16126
- }
16127
16056
 
16128
16057
  class PassThroughRemuxer {
16129
16058
  constructor(observer, config, typeSupported, logger) {
@@ -16766,7 +16695,6 @@ class FetchLoader {
16766
16695
  }
16767
16696
  stats.loading.start = self.performance.now();
16768
16697
  const initParams = getRequestParameters(context, this.controller.signal);
16769
- const onProgress = callbacks.onProgress;
16770
16698
  const isArrayBuffer = context.responseType === 'arraybuffer';
16771
16699
  const LENGTH = isArrayBuffer ? 'byteLength' : 'length';
16772
16700
  const {
@@ -16780,18 +16708,23 @@ class FetchLoader {
16780
16708
  self.clearTimeout(this.requestTimeout);
16781
16709
  config.timeout = maxTimeToFirstByteMs && isFiniteNumber(maxTimeToFirstByteMs) ? maxTimeToFirstByteMs : maxLoadTimeMs;
16782
16710
  this.requestTimeout = self.setTimeout(() => {
16783
- this.abortInternal();
16784
- callbacks.onTimeout(stats, context, this.response);
16711
+ if (this.callbacks) {
16712
+ this.abortInternal();
16713
+ this.callbacks.onTimeout(stats, context, this.response);
16714
+ }
16785
16715
  }, config.timeout);
16786
16716
  const fetchPromise = isPromise(this.request) ? this.request.then(self.fetch) : self.fetch(this.request);
16787
16717
  fetchPromise.then(response => {
16718
+ var _this$callbacks2;
16788
16719
  this.response = this.loader = response;
16789
16720
  const first = Math.max(self.performance.now(), stats.loading.start);
16790
16721
  self.clearTimeout(this.requestTimeout);
16791
16722
  config.timeout = maxLoadTimeMs;
16792
16723
  this.requestTimeout = self.setTimeout(() => {
16793
- this.abortInternal();
16794
- callbacks.onTimeout(stats, context, this.response);
16724
+ if (this.callbacks) {
16725
+ this.abortInternal();
16726
+ this.callbacks.onTimeout(stats, context, this.response);
16727
+ }
16795
16728
  }, maxLoadTimeMs - (first - stats.loading.start));
16796
16729
  if (!response.ok) {
16797
16730
  const {
@@ -16802,6 +16735,7 @@ class FetchLoader {
16802
16735
  }
16803
16736
  stats.loading.first = first;
16804
16737
  stats.total = getContentLength(response.headers) || stats.total;
16738
+ const onProgress = (_this$callbacks2 = this.callbacks) == null ? void 0 : _this$callbacks2.onProgress;
16805
16739
  if (onProgress && isFiniteNumber(config.highWaterMark)) {
16806
16740
  return this.loadProgressively(response, stats, context, config.highWaterMark, onProgress);
16807
16741
  }
@@ -16813,6 +16747,7 @@ class FetchLoader {
16813
16747
  }
16814
16748
  return response.text();
16815
16749
  }).then(responseData => {
16750
+ var _this$callbacks3, _this$callbacks4;
16816
16751
  const response = this.response;
16817
16752
  if (!response) {
16818
16753
  throw new Error('loader destroyed');
@@ -16828,11 +16763,13 @@ class FetchLoader {
16828
16763
  data: responseData,
16829
16764
  code: response.status
16830
16765
  };
16766
+ const onProgress = (_this$callbacks3 = this.callbacks) == null ? void 0 : _this$callbacks3.onProgress;
16831
16767
  if (onProgress && !isFiniteNumber(config.highWaterMark)) {
16832
16768
  onProgress(stats, context, responseData, response);
16833
16769
  }
16834
- callbacks.onSuccess(loaderResponse, stats, context, response);
16770
+ (_this$callbacks4 = this.callbacks) == null ? void 0 : _this$callbacks4.onSuccess(loaderResponse, stats, context, response);
16835
16771
  }).catch(error => {
16772
+ var _this$callbacks5;
16836
16773
  self.clearTimeout(this.requestTimeout);
16837
16774
  if (stats.aborted) {
16838
16775
  return;
@@ -16841,7 +16778,7 @@ class FetchLoader {
16841
16778
  // when destroying, 'error' itself can be undefined
16842
16779
  const code = !error ? 0 : error.code || 0;
16843
16780
  const text = !error ? null : error.message;
16844
- callbacks.onError({
16781
+ (_this$callbacks5 = this.callbacks) == null ? void 0 : _this$callbacks5.onError({
16845
16782
  code,
16846
16783
  text
16847
16784
  }, context, error ? error.details : null, stats);
@@ -17019,8 +16956,9 @@ class XhrLoader {
17019
16956
  if (this.loader !== xhr || this.stats.aborted) return;
17020
16957
  this.openAndSendXhr(xhr, context, config);
17021
16958
  }).catch(error => {
16959
+ var _this$callbacks2;
17022
16960
  // IE11 throws an exception on xhr.open if attempting to access an HTTP resource over HTTPS
17023
- this.callbacks.onError({
16961
+ (_this$callbacks2 = this.callbacks) == null ? void 0 : _this$callbacks2.onError({
17024
16962
  code: xhr.status,
17025
16963
  text: error.message
17026
16964
  }, context, xhr, stats);
@@ -17094,26 +17032,21 @@ class XhrLoader {
17094
17032
  if (status >= 200 && status < 300) {
17095
17033
  const data = useResponseText != null ? useResponseText : xhr.response;
17096
17034
  if (data != null) {
17035
+ var _this$callbacks3, _this$callbacks4;
17097
17036
  stats.loading.end = Math.max(self.performance.now(), stats.loading.first);
17098
17037
  const len = xhr.responseType === 'arraybuffer' ? data.byteLength : data.length;
17099
17038
  stats.loaded = stats.total = len;
17100
17039
  stats.bwEstimate = stats.total * 8000 / (stats.loading.end - stats.loading.first);
17101
- if (!this.callbacks) {
17102
- return;
17103
- }
17104
- const onProgress = this.callbacks.onProgress;
17040
+ const onProgress = (_this$callbacks3 = this.callbacks) == null ? void 0 : _this$callbacks3.onProgress;
17105
17041
  if (onProgress) {
17106
17042
  onProgress(stats, context, data, xhr);
17107
17043
  }
17108
- if (!this.callbacks) {
17109
- return;
17110
- }
17111
17044
  const _response = {
17112
17045
  url: xhr.responseURL,
17113
17046
  data: data,
17114
17047
  code: status
17115
17048
  };
17116
- this.callbacks.onSuccess(_response, stats, context, xhr);
17049
+ (_this$callbacks4 = this.callbacks) == null ? void 0 : _this$callbacks4.onSuccess(_response, stats, context, xhr);
17117
17050
  return;
17118
17051
  }
17119
17052
  }
@@ -17130,8 +17063,9 @@ class XhrLoader {
17130
17063
  if (shouldRetry(retryConfig, retryCount, false, response)) {
17131
17064
  this.retry(retryConfig);
17132
17065
  } else {
17066
+ var _this$callbacks5;
17133
17067
  logger.error(`${status} while loading ${context.url}`);
17134
- this.callbacks.onError({
17068
+ (_this$callbacks5 = this.callbacks) == null ? void 0 : _this$callbacks5.onError({
17135
17069
  code: status,
17136
17070
  text: xhr.statusText
17137
17071
  }, context, xhr, stats);
@@ -19179,7 +19113,7 @@ class GapController extends Logger {
19179
19113
  }
19180
19114
  }
19181
19115
 
19182
- const version = "1.6.0-beta.2.0.canary.10871";
19116
+ const version = "1.6.0-beta.2.0.canary.10876";
19183
19117
 
19184
19118
  // ensure the worker ends up in the bundle
19185
19119
  // If the worker should not be included this gets aliased to empty.js