hls.js 1.6.0-beta.1.0.canary.10809 → 1.6.0-beta.1.0.canary.10811
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.js +26 -17
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +19 -12
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +19 -12
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +26 -17
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/dist/hls.worker.js.map +1 -1
- package/package.json +1 -1
- package/src/controller/audio-track-controller.ts +4 -4
- package/src/controller/interstitials-controller.ts +4 -0
- package/src/controller/stream-controller.ts +4 -4
- package/src/remux/mp4-remuxer.ts +11 -7
- package/src/utils/rendition-helper.ts +5 -0
package/package.json
CHANGED
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
findClosestLevelWithAudioGroup,
|
9
9
|
findMatchingOption,
|
10
10
|
matchesOption,
|
11
|
+
useAlternateAudio,
|
11
12
|
} from '../utils/rendition-helper';
|
12
13
|
import type Hls from '../hls';
|
13
14
|
import type {
|
@@ -401,11 +402,10 @@ class AudioTrackController extends BasePlaylistController {
|
|
401
402
|
if (!this.shouldLoadPlaylist(audioTrack)) {
|
402
403
|
return;
|
403
404
|
}
|
404
|
-
|
405
|
-
|
406
|
-
|
405
|
+
// Do not load audio rendition with URI matching main variant URI
|
406
|
+
if (useAlternateAudio(audioTrack.url, this.hls)) {
|
407
|
+
this.scheduleLoading(audioTrack, hlsUrlParameters);
|
407
408
|
}
|
408
|
-
this.scheduleLoading(audioTrack, hlsUrlParameters);
|
409
409
|
}
|
410
410
|
|
411
411
|
protected loadingPlaylist(
|
@@ -1273,6 +1273,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
|
|
1273
1273
|
}
|
1274
1274
|
|
1275
1275
|
private onLevelUpdated(event: Events.LEVEL_UPDATED, data: LevelUpdatedData) {
|
1276
|
+
if (data.level === -1) {
|
1277
|
+
// level was removed
|
1278
|
+
return;
|
1279
|
+
}
|
1276
1280
|
const main = this.hls.levels[data.level];
|
1277
1281
|
const currentSelection = {
|
1278
1282
|
...(this.mediaSelection || this.altSelection),
|
@@ -11,6 +11,7 @@ import { PlaylistContextType, PlaylistLevelType } from '../types/loader';
|
|
11
11
|
import { ChunkMetadata } from '../types/transmuxer';
|
12
12
|
import { BufferHelper } from '../utils/buffer-helper';
|
13
13
|
import { pickMostCompleteCodecName } from '../utils/codecs';
|
14
|
+
import { useAlternateAudio } from '../utils/rendition-helper';
|
14
15
|
import type { FragmentTracker } from './fragment-tracker';
|
15
16
|
import type Hls from '../hls';
|
16
17
|
import type { Fragment, MediaFragment } from '../loader/fragment';
|
@@ -851,9 +852,10 @@ export default class StreamController
|
|
851
852
|
event: Events.AUDIO_TRACK_SWITCHING,
|
852
853
|
data: AudioTrackSwitchingData,
|
853
854
|
) {
|
855
|
+
const hls = this.hls;
|
854
856
|
// if any URL found on new audio track, it is an alternate audio track
|
855
857
|
const fromAltAudio = this.altAudio === AlternateAudio.SWITCHED;
|
856
|
-
const altAudio =
|
858
|
+
const altAudio = useAlternateAudio(data.url, hls);
|
857
859
|
// if we switch on main audio, ensure that main fragment scheduling is synced with media.buffered
|
858
860
|
// don't do anything if we switch to alt audio: audio stream controller is handling it.
|
859
861
|
// we will just have to change buffer scheduling on audioTrackSwitched
|
@@ -878,7 +880,6 @@ export default class StreamController
|
|
878
880
|
// Reset audio transmuxer so when switching back to main audio we're not still appending where we left off
|
879
881
|
this.resetTransmuxer();
|
880
882
|
}
|
881
|
-
const hls = this.hls;
|
882
883
|
// If switching from alt to main audio, flush all audio and trigger track switched
|
883
884
|
if (fromAltAudio) {
|
884
885
|
hls.trigger(Events.BUFFER_FLUSHING, {
|
@@ -898,8 +899,7 @@ export default class StreamController
|
|
898
899
|
event: Events.AUDIO_TRACK_SWITCHED,
|
899
900
|
data: AudioTrackSwitchedData,
|
900
901
|
) {
|
901
|
-
const
|
902
|
-
const altAudio = !!this.hls.audioTracks[trackId].url;
|
902
|
+
const altAudio = useAlternateAudio(data.url, this.hls);
|
903
903
|
if (altAudio) {
|
904
904
|
const videoBuffer = this.videoBuffer;
|
905
905
|
// if we switched on alternate audio, ensure that main fragment scheduling is synced with video sourcebuffer buffered
|
package/src/remux/mp4-remuxer.ts
CHANGED
@@ -100,20 +100,24 @@ export default class MP4Remuxer implements Remuxer {
|
|
100
100
|
this.videoTrackConfig = undefined;
|
101
101
|
}
|
102
102
|
|
103
|
-
getVideoStartPts(videoSamples) {
|
103
|
+
getVideoStartPts(videoSamples: VideoSample[]) {
|
104
|
+
// Get the minimum PTS value relative to the first sample's PTS, normalized for 33-bit wrapping
|
104
105
|
let rolloverDetected = false;
|
106
|
+
const firstPts = videoSamples[0].pts;
|
105
107
|
const startPTS = videoSamples.reduce((minPTS, sample) => {
|
106
|
-
|
108
|
+
let pts = sample.pts;
|
109
|
+
let delta = pts - minPTS;
|
107
110
|
if (delta < -4294967296) {
|
108
111
|
// 2^32, see PTSNormalize for reasoning, but we're hitting a rollover here, and we don't want that to impact the timeOffset calculation
|
109
112
|
rolloverDetected = true;
|
110
|
-
|
111
|
-
|
113
|
+
pts = normalizePts(pts, firstPts);
|
114
|
+
delta = pts - minPTS;
|
115
|
+
}
|
116
|
+
if (delta > 0) {
|
112
117
|
return minPTS;
|
113
|
-
} else {
|
114
|
-
return sample.pts;
|
115
118
|
}
|
116
|
-
|
119
|
+
return pts;
|
120
|
+
}, firstPts);
|
117
121
|
if (rolloverDetected) {
|
118
122
|
this.logger.debug('PTS rollover detected');
|
119
123
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { codecsSetSelectionPreferenceValue } from './codecs';
|
2
2
|
import { getVideoSelectionOptions } from './hdr';
|
3
3
|
import { logger } from './logger';
|
4
|
+
import type Hls from '../hls';
|
4
5
|
import type { Level, VideoRange } from '../types/level';
|
5
6
|
import type {
|
6
7
|
AudioSelectionOption,
|
@@ -500,3 +501,7 @@ function searchDownAndUpList(
|
|
500
501
|
}
|
501
502
|
return -1;
|
502
503
|
}
|
504
|
+
|
505
|
+
export function useAlternateAudio(audioTrackUrl: string, hls: Hls): boolean {
|
506
|
+
return !!audioTrackUrl && audioTrackUrl !== hls.levels[hls.loadLevel]?.uri;
|
507
|
+
}
|