hls.js 1.5.12-0.canary.10351 → 1.5.12-0.canary.10352
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 +32 -20
- package/dist/hls.js.d.ts +1 -0
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +32 -20
- 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 +30 -18
- 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 +30 -18
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +1 -1
- package/src/controller/abr-controller.ts +15 -5
- package/src/hls.ts +4 -3
- package/src/types/media-playlist.ts +9 -1
- package/src/utils/hdr.ts +4 -7
- package/src/utils/rendition-helper.ts +26 -5
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { AttrList } from '../utils/attr-list';
|
2
2
|
import type { LevelDetails } from '../loader/level-details';
|
3
|
-
import type { VideoRange } from './level';
|
3
|
+
import type { Level, VideoRange } from './level';
|
4
|
+
import type { PlaylistLevelType } from './loader';
|
4
5
|
|
5
6
|
export type AudioPlaylistType = 'AUDIO';
|
6
7
|
|
@@ -10,9 +11,16 @@ export type SubtitlePlaylistType = 'SUBTITLES' | 'CLOSED-CAPTIONS';
|
|
10
11
|
|
11
12
|
export type MediaPlaylistType = MainPlaylistType | SubtitlePlaylistType;
|
12
13
|
|
14
|
+
export type MediaSelection = {
|
15
|
+
[PlaylistLevelType.MAIN]: Level;
|
16
|
+
[PlaylistLevelType.AUDIO]?: MediaPlaylist;
|
17
|
+
[PlaylistLevelType.SUBTITLE]?: MediaPlaylist;
|
18
|
+
};
|
19
|
+
|
13
20
|
export type VideoSelectionOption = {
|
14
21
|
preferHDR?: boolean;
|
15
22
|
allowedVideoRanges?: Array<VideoRange>;
|
23
|
+
videoCodec?: string;
|
16
24
|
};
|
17
25
|
|
18
26
|
export type AudioSelectionOption = {
|
package/src/utils/hdr.ts
CHANGED
@@ -49,16 +49,13 @@ export function getVideoSelectionOptions(
|
|
49
49
|
if (videoPreference) {
|
50
50
|
allowedVideoRanges =
|
51
51
|
videoPreference.allowedVideoRanges || VideoRangeValues.slice(0);
|
52
|
+
const allowAutoPreferHDR =
|
53
|
+
allowedVideoRanges.join('') !== 'SDR' && !videoPreference.videoCodec;
|
52
54
|
preferHDR =
|
53
55
|
videoPreference.preferHDR !== undefined
|
54
56
|
? videoPreference.preferHDR
|
55
|
-
: isHdrSupported();
|
56
|
-
|
57
|
-
if (preferHDR) {
|
58
|
-
allowedVideoRanges = allowedVideoRanges.filter(
|
59
|
-
(range: VideoRange) => range !== 'SDR',
|
60
|
-
);
|
61
|
-
} else {
|
57
|
+
: allowAutoPreferHDR && isHdrSupported();
|
58
|
+
if (!preferHDR) {
|
62
59
|
allowedVideoRanges = ['SDR'];
|
63
60
|
}
|
64
61
|
}
|
@@ -13,6 +13,7 @@ export type CodecSetTier = {
|
|
13
13
|
minBitrate: number;
|
14
14
|
minHeight: number;
|
15
15
|
minFramerate: number;
|
16
|
+
minIndex: number;
|
16
17
|
maxScore: number;
|
17
18
|
videoRanges: Record<string, number>;
|
18
19
|
channels: Record<string, number>;
|
@@ -32,6 +33,7 @@ type StartParameters = {
|
|
32
33
|
preferHDR: boolean;
|
33
34
|
minFramerate: number;
|
34
35
|
minBitrate: number;
|
36
|
+
minIndex: number;
|
35
37
|
};
|
36
38
|
|
37
39
|
export function getStartCodecTier(
|
@@ -44,13 +46,15 @@ export function getStartCodecTier(
|
|
44
46
|
const codecSets = Object.keys(codecTiers);
|
45
47
|
const channelsPreference = audioPreference?.channels;
|
46
48
|
const audioCodecPreference = audioPreference?.audioCodec;
|
49
|
+
const videoCodecPreference = videoPreference?.videoCodec;
|
47
50
|
const preferStereo = channelsPreference && parseInt(channelsPreference) === 2;
|
48
51
|
// Use first level set to determine stereo, and minimum resolution and framerate
|
49
|
-
let hasStereo =
|
52
|
+
let hasStereo = false;
|
50
53
|
let hasCurrentVideoRange = false;
|
51
54
|
let minHeight = Infinity;
|
52
55
|
let minFramerate = Infinity;
|
53
56
|
let minBitrate = Infinity;
|
57
|
+
let minIndex = Infinity;
|
54
58
|
let selectedScore = 0;
|
55
59
|
let videoRanges: Array<VideoRange> = [];
|
56
60
|
|
@@ -61,7 +65,7 @@ export function getStartCodecTier(
|
|
61
65
|
|
62
66
|
for (let i = codecSets.length; i--; ) {
|
63
67
|
const tier = codecTiers[codecSets[i]];
|
64
|
-
hasStereo
|
68
|
+
hasStereo ||= tier.channels[2] > 0;
|
65
69
|
minHeight = Math.min(minHeight, tier.minHeight);
|
66
70
|
minFramerate = Math.min(minFramerate, tier.minFramerate);
|
67
71
|
minBitrate = Math.min(minBitrate, tier.minBitrate);
|
@@ -70,7 +74,6 @@ export function getStartCodecTier(
|
|
70
74
|
);
|
71
75
|
if (matchingVideoRanges.length > 0) {
|
72
76
|
hasCurrentVideoRange = true;
|
73
|
-
videoRanges = matchingVideoRanges;
|
74
77
|
}
|
75
78
|
}
|
76
79
|
minHeight = Number.isFinite(minHeight) ? minHeight : 0;
|
@@ -82,7 +85,6 @@ export function getStartCodecTier(
|
|
82
85
|
// If there are no variants with matching preference, set currentVideoRange to undefined
|
83
86
|
if (!hasCurrentVideoRange) {
|
84
87
|
currentVideoRange = undefined;
|
85
|
-
videoRanges = [];
|
86
88
|
}
|
87
89
|
const codecSet = codecSets.reduce(
|
88
90
|
(selected: string | undefined, candidate: string) => {
|
@@ -91,6 +93,11 @@ export function getStartCodecTier(
|
|
91
93
|
if (candidate === selected) {
|
92
94
|
return selected;
|
93
95
|
}
|
96
|
+
videoRanges = hasCurrentVideoRange
|
97
|
+
? allowedVideoRanges.filter(
|
98
|
+
(range) => candidateTier.videoRanges[range] > 0,
|
99
|
+
)
|
100
|
+
: [];
|
94
101
|
if (candidateTier.minBitrate > currentBw) {
|
95
102
|
logStartCodecCandidateIgnored(
|
96
103
|
candidate,
|
@@ -159,6 +166,16 @@ export function getStartCodecTier(
|
|
159
166
|
);
|
160
167
|
return selected;
|
161
168
|
}
|
169
|
+
if (
|
170
|
+
videoCodecPreference &&
|
171
|
+
candidate.indexOf(videoCodecPreference.substring(0, 4)) % 5 !== 0
|
172
|
+
) {
|
173
|
+
logStartCodecCandidateIgnored(
|
174
|
+
candidate,
|
175
|
+
`video codec preference "${videoCodecPreference}" not found`,
|
176
|
+
);
|
177
|
+
return selected;
|
178
|
+
}
|
162
179
|
if (candidateTier.maxScore < selectedScore) {
|
163
180
|
logStartCodecCandidateIgnored(
|
164
181
|
candidate,
|
@@ -175,6 +192,7 @@ export function getStartCodecTier(
|
|
175
192
|
) {
|
176
193
|
return selected;
|
177
194
|
}
|
195
|
+
minIndex = candidateTier.minIndex;
|
178
196
|
selectedScore = candidateTier.maxScore;
|
179
197
|
return candidate;
|
180
198
|
},
|
@@ -186,6 +204,7 @@ export function getStartCodecTier(
|
|
186
204
|
preferHDR,
|
187
205
|
minFramerate,
|
188
206
|
minBitrate,
|
207
|
+
minIndex,
|
189
208
|
};
|
190
209
|
}
|
191
210
|
|
@@ -243,7 +262,7 @@ export function getCodecTiers(
|
|
243
262
|
): Record<string, CodecSetTier> {
|
244
263
|
return levels
|
245
264
|
.slice(minAutoLevel, maxAutoLevel + 1)
|
246
|
-
.reduce((tiers: Record<string, CodecSetTier>, level) => {
|
265
|
+
.reduce((tiers: Record<string, CodecSetTier>, level, index) => {
|
247
266
|
if (!level.codecSet) {
|
248
267
|
return tiers;
|
249
268
|
}
|
@@ -254,6 +273,7 @@ export function getCodecTiers(
|
|
254
273
|
minBitrate: Infinity,
|
255
274
|
minHeight: Infinity,
|
256
275
|
minFramerate: Infinity,
|
276
|
+
minIndex: index,
|
257
277
|
maxScore: 0,
|
258
278
|
videoRanges: { SDR: 0 },
|
259
279
|
channels: { '2': 0 },
|
@@ -265,6 +285,7 @@ export function getCodecTiers(
|
|
265
285
|
const lesserWidthOrHeight = Math.min(level.height, level.width);
|
266
286
|
tier.minHeight = Math.min(tier.minHeight, lesserWidthOrHeight);
|
267
287
|
tier.minFramerate = Math.min(tier.minFramerate, level.frameRate);
|
288
|
+
tier.minIndex = Math.min(tier.minIndex, index);
|
268
289
|
tier.maxScore = Math.max(tier.maxScore, level.score);
|
269
290
|
tier.fragmentError += level.fragmentError;
|
270
291
|
tier.videoRanges[level.videoRange] =
|