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/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  "url-toolkit": "2.2.5",
131
131
  "wrangler": "3.62.0"
132
132
  },
133
- "version": "1.5.13-0.canary.10408"
133
+ "version": "1.5.13-0.canary.10411"
134
134
  }
@@ -403,18 +403,34 @@ class AudioStreamController
403
403
  return;
404
404
  }
405
405
 
406
+ // Request audio segments up to one fragment ahead of main stream-controller
407
+ const mainFragLoading = this.mainFragLoading?.frag;
406
408
  if (
407
409
  this.startFragRequested &&
408
- (!trackDetails.live || targetBufferTime < this.hls.liveSyncPosition!)
410
+ mainFragLoading &&
411
+ mainFragLoading.sn !== 'initSegment' &&
412
+ frag.sn !== 'initSegment' &&
413
+ !frag.endList &&
414
+ (!trackDetails.live ||
415
+ (!this.loadingParts && targetBufferTime < this.hls.liveSyncPosition!))
409
416
  ) {
410
- // Request audio segments up to one fragment ahead of main buffer
411
- const mainFragLoading = this.mainFragLoading;
412
- const mainTargetBufferEnd = mainFragLoading
413
- ? (mainFragLoading.part || mainFragLoading.frag).end
414
- : null;
415
- const atBufferSyncLimit =
416
- mainTargetBufferEnd !== null && frag.start > mainTargetBufferEnd;
417
- if (atBufferSyncLimit && !frag.endList) {
417
+ let mainFrag = mainFragLoading;
418
+ if (frag.start > mainFrag.end) {
419
+ // Get buffered frag at target position from tracker (loaded out of sequence)
420
+ const mainFragAtPos = this.fragmentTracker.getFragAtPos(
421
+ targetBufferTime,
422
+ PlaylistLevelType.MAIN,
423
+ );
424
+ if (mainFragAtPos && mainFragAtPos.end > mainFragLoading.end) {
425
+ mainFrag = mainFragAtPos;
426
+ this.mainFragLoading = {
427
+ frag: mainFragAtPos,
428
+ targetBufferTime: null,
429
+ };
430
+ }
431
+ }
432
+ const atBufferSyncLimit = frag.start > mainFrag.end;
433
+ if (atBufferSyncLimit) {
418
434
  return;
419
435
  }
420
436
  }
@@ -101,7 +101,7 @@ export default class BaseStreamController
101
101
  protected decrypter: Decrypter;
102
102
  protected initPTS: RationalTimestamp[] = [];
103
103
  protected buffering: boolean = true;
104
- private loadingParts: boolean = false;
104
+ protected loadingParts: boolean = false;
105
105
  private loopSn?: string | number;
106
106
 
107
107
  constructor(
@@ -1069,56 +1069,6 @@ export default class MP4Remuxer implements Remuxer {
1069
1069
  this.isAudioContiguous = true;
1070
1070
  return audioData;
1071
1071
  }
1072
-
1073
- remuxEmptyAudio(
1074
- track: DemuxedAudioTrack,
1075
- timeOffset: number,
1076
- contiguous: boolean,
1077
- videoData: Fragment,
1078
- ): RemuxedTrack | undefined {
1079
- const inputTimeScale: number = track.inputTimeScale;
1080
- const mp4timeScale: number = track.samplerate
1081
- ? track.samplerate
1082
- : inputTimeScale;
1083
- const scaleFactor: number = inputTimeScale / mp4timeScale;
1084
- const nextAudioPts: number | null = this.nextAudioPts;
1085
- // sync with video's timestamp
1086
- const initDTS = this._initDTS as RationalTimestamp;
1087
- const init90kHz = (initDTS.baseTime * 90000) / initDTS.timescale;
1088
- const startDTS: number =
1089
- (nextAudioPts !== null
1090
- ? nextAudioPts
1091
- : (videoData.startDTS as number) * inputTimeScale) + init90kHz;
1092
- const endDTS: number =
1093
- (videoData.endDTS as number) * inputTimeScale + init90kHz;
1094
- // one sample's duration value
1095
- const frameDuration: number = scaleFactor * AAC_SAMPLES_PER_FRAME;
1096
- // samples count of this segment's duration
1097
- const nbSamples: number = Math.ceil((endDTS - startDTS) / frameDuration);
1098
- // silent frame
1099
- const silentFrame: Uint8Array | undefined = AAC.getSilentFrame(
1100
- track.parsedCodec || track.manifestCodec || track.codec,
1101
- track.channelCount,
1102
- );
1103
-
1104
- logger.warn('[mp4-remuxer]: remux empty Audio');
1105
- // Can't remux if we can't generate a silent frame...
1106
- if (!silentFrame) {
1107
- logger.trace(
1108
- '[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec',
1109
- );
1110
- return;
1111
- }
1112
-
1113
- const samples: Array<any> = [];
1114
- for (let i = 0; i < nbSamples; i++) {
1115
- const stamp = startDTS + i * frameDuration;
1116
- samples.push({ unit: silentFrame, pts: stamp, dts: stamp });
1117
- }
1118
- track.samples = samples;
1119
-
1120
- return this.remuxAudio(track, timeOffset, contiguous, false);
1121
- }
1122
1072
  }
1123
1073
 
1124
1074
  export function normalizePts(value: number, reference: number | null): number {
@@ -206,16 +206,20 @@ export function pickMostCompleteCodecName(
206
206
 
207
207
  export function convertAVC1ToAVCOTI(codec: string) {
208
208
  // Convert avc1 codec string from RFC-4281 to RFC-6381 for MediaSource.isTypeSupported
209
- const avcdata = codec.split('.');
210
- if (avcdata.length > 2) {
211
- let result = avcdata.shift() + '.';
212
- result += parseInt(avcdata.shift() as string).toString(16);
213
- result += ('000' + parseInt(avcdata.shift() as string).toString(16)).slice(
214
- -4,
215
- );
216
- return result;
209
+ // Examples: avc1.66.30 to avc1.42001e and avc1.77.30,avc1.66.30 to avc1.4d001e,avc1.42001e.
210
+ const codecs = codec.split(',');
211
+ for (let i = 0; i < codecs.length; i++) {
212
+ const avcdata = codecs[i].split('.');
213
+ if (avcdata.length > 2) {
214
+ let result = avcdata.shift() + '.';
215
+ result += parseInt(avcdata.shift() as string).toString(16);
216
+ result += (
217
+ '000' + parseInt(avcdata.shift() as string).toString(16)
218
+ ).slice(-4);
219
+ codecs[i] = result;
220
+ }
217
221
  }
218
- return codec;
222
+ return codecs.join(',');
219
223
  }
220
224
 
221
225
  export interface TypeSupported {