hls.js 1.5.14-0.canary.10565 → 1.5.14-0.canary.10569

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.
@@ -421,7 +421,7 @@ function enableLogs(debugConfig, context, id) {
421
421
  // Some browsers don't allow to use bind on console object anyway
422
422
  // fallback to default if needed
423
423
  try {
424
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.14-0.canary.10565"}`);
424
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.14-0.canary.10569"}`);
425
425
  } catch (e) {
426
426
  /* log fn threw an exception. All logger methods are no-ops. */
427
427
  return createLogger();
@@ -13864,7 +13864,7 @@ function changeTypeSupported() {
13864
13864
  return typeof (sourceBuffer == null ? void 0 : (_sourceBuffer$prototy = sourceBuffer.prototype) == null ? void 0 : _sourceBuffer$prototy.changeType) === 'function';
13865
13865
  }
13866
13866
 
13867
- const version = "1.5.14-0.canary.10565";
13867
+ const version = "1.5.14-0.canary.10569";
13868
13868
 
13869
13869
  // ensure the worker ends up in the bundle
13870
13870
  // If the worker should not be included this gets aliased to empty.js
@@ -14182,23 +14182,11 @@ const initPTSFn = (timestamp, timeOffset, initPTS) => {
14182
14182
  return timeOffset * 90000 + init90kHz;
14183
14183
  };
14184
14184
 
14185
- /**
14186
- * ADTS parser helper
14187
- * @link https://wiki.multimedia.cx/index.php?title=ADTS
14188
- */
14189
- function getAudioConfig(observer, data, offset, audioCodec) {
14190
- let adtsObjectType;
14191
- let originalAdtsObjectType;
14192
- let adtsExtensionSamplingIndex;
14193
- let adtsChannelConfig;
14194
- let config;
14195
- const userAgent = navigator.userAgent.toLowerCase();
14196
- const manifestCodec = audioCodec;
14185
+ function getAudioConfig(observer, data, offset, manifestCodec) {
14197
14186
  const adtsSamplingRates = [96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350];
14198
- // byte 2
14199
- adtsObjectType = originalAdtsObjectType = ((data[offset + 2] & 0xc0) >>> 6) + 1;
14200
- const adtsSamplingIndex = (data[offset + 2] & 0x3c) >>> 2;
14201
- if (adtsSamplingIndex > adtsSamplingRates.length - 1) {
14187
+ const byte2 = data[offset + 2];
14188
+ const adtsSamplingIndex = byte2 >> 2 & 0xf;
14189
+ if (adtsSamplingIndex > 12) {
14202
14190
  const error = new Error(`invalid ADTS sampling index:${adtsSamplingIndex}`);
14203
14191
  observer.emit(Events.ERROR, Events.ERROR, {
14204
14192
  type: ErrorTypes.MEDIA_ERROR,
@@ -14209,53 +14197,12 @@ function getAudioConfig(observer, data, offset, audioCodec) {
14209
14197
  });
14210
14198
  return;
14211
14199
  }
14212
- adtsChannelConfig = (data[offset + 2] & 0x01) << 2;
14213
- // byte 3
14214
- adtsChannelConfig |= (data[offset + 3] & 0xc0) >>> 6;
14215
- logger.log(`manifest codec:${audioCodec}, ADTS type:${adtsObjectType}, samplingIndex:${adtsSamplingIndex}`);
14216
- // Firefox and Pale Moon: freq less than 24kHz = AAC SBR (HE-AAC)
14217
- if (/firefox|palemoon/i.test(userAgent)) {
14218
- if (adtsSamplingIndex >= 6) {
14219
- adtsObjectType = 5;
14220
- config = new Array(4);
14221
- // HE-AAC uses SBR (Spectral Band Replication) , high frequencies are constructed from low frequencies
14222
- // there is a factor 2 between frame sample rate and output sample rate
14223
- // multiply frequency by 2 (see table below, equivalent to substract 3)
14224
- adtsExtensionSamplingIndex = adtsSamplingIndex - 3;
14225
- } else {
14226
- adtsObjectType = 2;
14227
- config = new Array(2);
14228
- adtsExtensionSamplingIndex = adtsSamplingIndex;
14229
- }
14230
- // Android : always use AAC
14231
- } else if (userAgent.indexOf('android') !== -1) {
14232
- adtsObjectType = 2;
14233
- config = new Array(2);
14234
- adtsExtensionSamplingIndex = adtsSamplingIndex;
14235
- } else {
14236
- /* for other browsers (Chrome/Vivaldi/Opera ...)
14237
- always force audio type to be HE-AAC SBR, as some browsers do not support audio codec switch properly (like Chrome ...)
14238
- */
14239
- adtsObjectType = 5;
14240
- config = new Array(4);
14241
- // if (manifest codec is HE-AAC or HE-AACv2) OR (manifest codec not specified AND frequency less than 24kHz)
14242
- if (audioCodec && (audioCodec.indexOf('mp4a.40.29') !== -1 || audioCodec.indexOf('mp4a.40.5') !== -1) || !audioCodec && adtsSamplingIndex >= 6) {
14243
- // HE-AAC uses SBR (Spectral Band Replication) , high frequencies are constructed from low frequencies
14244
- // there is a factor 2 between frame sample rate and output sample rate
14245
- // multiply frequency by 2 (see table below, equivalent to substract 3)
14246
- adtsExtensionSamplingIndex = adtsSamplingIndex - 3;
14247
- } else {
14248
- // if (manifest codec is AAC) AND (frequency less than 24kHz AND nb channel is 1) OR (manifest codec not specified and mono audio)
14249
- // Chrome fails to play back with low frequency AAC LC mono when initialized with HE-AAC. This is not a problem with stereo.
14250
- if (audioCodec && audioCodec.indexOf('mp4a.40.2') !== -1 && (adtsSamplingIndex >= 6 && adtsChannelConfig === 1 || /vivaldi/i.test(userAgent)) || !audioCodec && adtsChannelConfig === 1) {
14251
- adtsObjectType = 2;
14252
- config = new Array(2);
14253
- }
14254
- adtsExtensionSamplingIndex = adtsSamplingIndex;
14255
- }
14256
- }
14200
+ // MPEG-4 Audio Object Type (profile_ObjectType+1)
14201
+ const adtsObjectType = (byte2 >> 6 & 0x3) + 1;
14202
+ const channelCount = data[offset + 3] >> 6 & 0x3 | (byte2 & 1) << 2;
14203
+ const codec = 'mp4a.40.' + adtsObjectType;
14257
14204
  /* refer to http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio#Audio_Specific_Config
14258
- ISO 14496-3 (AAC).pdf - Table 1.13 — Syntax of AudioSpecificConfig()
14205
+ ISO/IEC 14496-3 - Table 1.13 — Syntax of AudioSpecificConfig()
14259
14206
  Audio Profile / Audio Object Type
14260
14207
  0: Null
14261
14208
  1: AAC Main
@@ -14288,27 +14235,22 @@ function getAudioConfig(observer, data, offset, audioCodec) {
14288
14235
  2: 2 channels: front-left, front-right
14289
14236
  */
14290
14237
  // audioObjectType = profile => profile, the MPEG-4 Audio Object Type minus 1
14291
- config[0] = adtsObjectType << 3;
14292
- // samplingFrequencyIndex
14293
- config[0] |= (adtsSamplingIndex & 0x0e) >> 1;
14294
- config[1] |= (adtsSamplingIndex & 0x01) << 7;
14295
- // channelConfiguration
14296
- config[1] |= adtsChannelConfig << 3;
14297
- if (adtsObjectType === 5) {
14298
- // adtsExtensionSamplingIndex
14299
- config[1] |= (adtsExtensionSamplingIndex & 0x0e) >> 1;
14300
- config[2] = (adtsExtensionSamplingIndex & 0x01) << 7;
14301
- // adtsObjectType (force to 2, chrome is checking that object type is less than 5 ???
14302
- // https://chromium.googlesource.com/chromium/src.git/+/master/media/formats/mp4/aac.cc
14303
- config[2] |= 2 << 2;
14304
- config[3] = 0;
14305
- }
14238
+ const samplerate = adtsSamplingRates[adtsSamplingIndex];
14239
+ let aacSampleIndex = adtsSamplingIndex;
14240
+ if (adtsObjectType === 5 || adtsObjectType === 29) {
14241
+ // HE-AAC uses SBR (Spectral Band Replication) , high frequencies are constructed from low frequencies
14242
+ // there is a factor 2 between frame sample rate and output sample rate
14243
+ // multiply frequency by 2 (see table above, equivalent to substract 3)
14244
+ aacSampleIndex -= 3;
14245
+ }
14246
+ const config = [adtsObjectType << 3 | (aacSampleIndex & 0x0e) >> 1, (aacSampleIndex & 0x01) << 7 | channelCount << 3];
14247
+ logger.log(`manifest codec:${manifestCodec}, parsed codec:${codec}, channels:${channelCount}, rate:${samplerate} (ADTS object type:${adtsObjectType} sampling index:${adtsSamplingIndex})`);
14306
14248
  return {
14307
14249
  config,
14308
- samplerate: adtsSamplingRates[adtsSamplingIndex],
14309
- channelCount: adtsChannelConfig,
14310
- codec: 'mp4a.40.' + adtsObjectType,
14311
- parsedCodec: 'mp4a.40.' + originalAdtsObjectType,
14250
+ samplerate,
14251
+ channelCount,
14252
+ codec,
14253
+ parsedCodec: codec,
14312
14254
  manifestCodec
14313
14255
  };
14314
14256
  }
@@ -14358,13 +14300,7 @@ function initTrackConfig(track, observer, data, offset, audioCodec) {
14358
14300
  if (!config) {
14359
14301
  return;
14360
14302
  }
14361
- track.config = config.config;
14362
- track.samplerate = config.samplerate;
14363
- track.channelCount = config.channelCount;
14364
- track.codec = config.codec;
14365
- track.manifestCodec = config.manifestCodec;
14366
- track.parsedCodec = config.parsedCodec;
14367
- logger.log(`parsed codec:${track.parsedCodec}, codec:${track.codec}, rate:${config.samplerate}, channels:${config.channelCount}`);
14303
+ _extends(track, config);
14368
14304
  }
14369
14305
  }
14370
14306
  function getFrameDuration(samplerate) {
@@ -16776,7 +16712,7 @@ class MP4 {
16776
16712
  vSpacing >> 16 & 0xff, vSpacing >> 8 & 0xff, vSpacing & 0xff])));
16777
16713
  }
16778
16714
  static esds(track) {
16779
- const configlen = track.config.length;
16715
+ const config = track.config;
16780
16716
  return new Uint8Array([0x00,
16781
16717
  // version 0
16782
16718
  0x00, 0x00, 0x00,
@@ -16784,16 +16720,18 @@ class MP4 {
16784
16720
 
16785
16721
  0x03,
16786
16722
  // descriptor_type
16787
- 0x17 + configlen,
16723
+ 0x19,
16788
16724
  // length
16725
+
16789
16726
  0x00, 0x01,
16790
16727
  // es_id
16728
+
16791
16729
  0x00,
16792
16730
  // stream_priority
16793
16731
 
16794
16732
  0x04,
16795
16733
  // descriptor_type
16796
- 0x0f + configlen,
16734
+ 0x11,
16797
16735
  // length
16798
16736
  0x40,
16799
16737
  // codec : mpeg4_audio
@@ -16806,8 +16744,12 @@ class MP4 {
16806
16744
  0x00, 0x00, 0x00, 0x00,
16807
16745
  // avgBitrate
16808
16746
 
16809
- 0x05 // descriptor_type
16810
- ].concat([configlen]).concat(track.config).concat([0x06, 0x01, 0x02])); // GASpecificConfig)); // length + audio config descriptor
16747
+ 0x05,
16748
+ // descriptor_type
16749
+ 0x02,
16750
+ // length
16751
+ ...config, 0x06, 0x01, 0x02 // GASpecificConfig)); // length + audio config descriptor
16752
+ ]);
16811
16753
  }
16812
16754
  static audioStsd(track) {
16813
16755
  const samplerate = track.samplerate;