hls.js 1.5.13-0.canary.10408 → 1.5.13-0.canary.10411

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.mjs CHANGED
@@ -420,7 +420,7 @@ function enableLogs(debugConfig, context, id) {
420
420
  // Some browsers don't allow to use bind on console object anyway
421
421
  // fallback to default if needed
422
422
  try {
423
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.13-0.canary.10408"}`);
423
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.13-0.canary.10411"}`);
424
424
  } catch (e) {
425
425
  /* log fn threw an exception. All logger methods are no-ops. */
426
426
  return createLogger();
@@ -2896,14 +2896,18 @@ function pickMostCompleteCodecName(parsedCodec, levelCodec) {
2896
2896
  }
2897
2897
  function convertAVC1ToAVCOTI(codec) {
2898
2898
  // Convert avc1 codec string from RFC-4281 to RFC-6381 for MediaSource.isTypeSupported
2899
- const avcdata = codec.split('.');
2900
- if (avcdata.length > 2) {
2901
- let result = avcdata.shift() + '.';
2902
- result += parseInt(avcdata.shift()).toString(16);
2903
- result += ('000' + parseInt(avcdata.shift()).toString(16)).slice(-4);
2904
- return result;
2899
+ // Examples: avc1.66.30 to avc1.42001e and avc1.77.30,avc1.66.30 to avc1.4d001e,avc1.42001e.
2900
+ const codecs = codec.split(',');
2901
+ for (let i = 0; i < codecs.length; i++) {
2902
+ const avcdata = codecs[i].split('.');
2903
+ if (avcdata.length > 2) {
2904
+ let result = avcdata.shift() + '.';
2905
+ result += parseInt(avcdata.shift()).toString(16);
2906
+ result += ('000' + parseInt(avcdata.shift()).toString(16)).slice(-4);
2907
+ codecs[i] = result;
2908
+ }
2905
2909
  }
2906
- return codec;
2910
+ return codecs.join(',');
2907
2911
  }
2908
2912
  function getM2TSSupportedAudioTypes(preferManagedMediaSource) {
2909
2913
  const MediaSource = getMediaSource(preferManagedMediaSource) || {
@@ -15740,40 +15744,6 @@ class MP4Remuxer {
15740
15744
  this.isAudioContiguous = true;
15741
15745
  return audioData;
15742
15746
  }
15743
- remuxEmptyAudio(track, timeOffset, contiguous, videoData) {
15744
- const inputTimeScale = track.inputTimeScale;
15745
- const mp4timeScale = track.samplerate ? track.samplerate : inputTimeScale;
15746
- const scaleFactor = inputTimeScale / mp4timeScale;
15747
- const nextAudioPts = this.nextAudioPts;
15748
- // sync with video's timestamp
15749
- const initDTS = this._initDTS;
15750
- const init90kHz = initDTS.baseTime * 90000 / initDTS.timescale;
15751
- const startDTS = (nextAudioPts !== null ? nextAudioPts : videoData.startDTS * inputTimeScale) + init90kHz;
15752
- const endDTS = videoData.endDTS * inputTimeScale + init90kHz;
15753
- // one sample's duration value
15754
- const frameDuration = scaleFactor * AAC_SAMPLES_PER_FRAME;
15755
- // samples count of this segment's duration
15756
- const nbSamples = Math.ceil((endDTS - startDTS) / frameDuration);
15757
- // silent frame
15758
- const silentFrame = AAC.getSilentFrame(track.parsedCodec || track.manifestCodec || track.codec, track.channelCount);
15759
- logger.warn('[mp4-remuxer]: remux empty Audio');
15760
- // Can't remux if we can't generate a silent frame...
15761
- if (!silentFrame) {
15762
- logger.trace('[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec');
15763
- return;
15764
- }
15765
- const samples = [];
15766
- for (let i = 0; i < nbSamples; i++) {
15767
- const stamp = startDTS + i * frameDuration;
15768
- samples.push({
15769
- unit: silentFrame,
15770
- pts: stamp,
15771
- dts: stamp
15772
- });
15773
- }
15774
- track.samples = samples;
15775
- return this.remuxAudio(track, timeOffset, contiguous, false);
15776
- }
15777
15747
  }
15778
15748
  function normalizePts(value, reference) {
15779
15749
  let offset;
@@ -17337,6 +17307,7 @@ class AudioStreamController extends BaseStreamController {
17337
17307
  this.lastCurrentTime = media.currentTime;
17338
17308
  }
17339
17309
  doTickIdle() {
17310
+ var _this$mainFragLoading;
17340
17311
  const {
17341
17312
  hls,
17342
17313
  levels,
@@ -17415,12 +17386,24 @@ class AudioStreamController extends BaseStreamController {
17415
17386
  this.bufferFlushed = true;
17416
17387
  return;
17417
17388
  }
17418
- if (this.startFragRequested && (!trackDetails.live || targetBufferTime < this.hls.liveSyncPosition)) {
17419
- // Request audio segments up to one fragment ahead of main buffer
17420
- const mainFragLoading = this.mainFragLoading;
17421
- const mainTargetBufferEnd = mainFragLoading ? (mainFragLoading.part || mainFragLoading.frag).end : null;
17422
- const atBufferSyncLimit = mainTargetBufferEnd !== null && frag.start > mainTargetBufferEnd;
17423
- if (atBufferSyncLimit && !frag.endList) {
17389
+
17390
+ // Request audio segments up to one fragment ahead of main stream-controller
17391
+ const mainFragLoading = (_this$mainFragLoading = this.mainFragLoading) == null ? void 0 : _this$mainFragLoading.frag;
17392
+ if (this.startFragRequested && mainFragLoading && mainFragLoading.sn !== 'initSegment' && frag.sn !== 'initSegment' && !frag.endList && (!trackDetails.live || !this.loadingParts && targetBufferTime < this.hls.liveSyncPosition)) {
17393
+ let mainFrag = mainFragLoading;
17394
+ if (frag.start > mainFrag.end) {
17395
+ // Get buffered frag at target position from tracker (loaded out of sequence)
17396
+ const mainFragAtPos = this.fragmentTracker.getFragAtPos(targetBufferTime, PlaylistLevelType.MAIN);
17397
+ if (mainFragAtPos && mainFragAtPos.end > mainFragLoading.end) {
17398
+ mainFrag = mainFragAtPos;
17399
+ this.mainFragLoading = {
17400
+ frag: mainFragAtPos,
17401
+ targetBufferTime: null
17402
+ };
17403
+ }
17404
+ }
17405
+ const atBufferSyncLimit = frag.start > mainFrag.end;
17406
+ if (atBufferSyncLimit) {
17424
17407
  return;
17425
17408
  }
17426
17409
  }
@@ -29285,7 +29268,7 @@ class Hls {
29285
29268
  * Get the video-dev/hls.js package version.
29286
29269
  */
29287
29270
  static get version() {
29288
- return "1.5.13-0.canary.10408";
29271
+ return "1.5.13-0.canary.10411";
29289
29272
  }
29290
29273
 
29291
29274
  /**