hls.js 1.6.6-0.canary.11352 → 1.6.6-0.canary.11353
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.d.mts +1 -0
- package/dist/hls.d.ts +1 -0
- package/dist/hls.js +126 -72
- package/dist/hls.js.d.ts +1 -0
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +135 -89
- 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 +125 -80
- 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 +117 -68
- 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 +21 -7
- package/src/utils/mediacapabilities-helper.ts +135 -81
package/dist/hls.light.js
CHANGED
@@ -1165,7 +1165,7 @@
|
|
1165
1165
|
// Some browsers don't allow to use bind on console object anyway
|
1166
1166
|
// fallback to default if needed
|
1167
1167
|
try {
|
1168
|
-
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.6-0.canary.
|
1168
|
+
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.6-0.canary.11353");
|
1169
1169
|
} catch (e) {
|
1170
1170
|
/* log fn threw an exception. All logger methods are no-ops. */
|
1171
1171
|
return createLogger();
|
@@ -1196,6 +1196,27 @@
|
|
1196
1196
|
var emptyExports = requireEmpty();
|
1197
1197
|
var Cues = /*@__PURE__*/getDefaultExportFromCjs(emptyExports);
|
1198
1198
|
|
1199
|
+
function getMediaSource(preferManagedMediaSource) {
|
1200
|
+
if (preferManagedMediaSource === void 0) {
|
1201
|
+
preferManagedMediaSource = true;
|
1202
|
+
}
|
1203
|
+
if (typeof self === 'undefined') return undefined;
|
1204
|
+
var mms = (preferManagedMediaSource || !self.MediaSource) && self.ManagedMediaSource;
|
1205
|
+
return mms || self.MediaSource || self.WebKitMediaSource;
|
1206
|
+
}
|
1207
|
+
function isManagedMediaSource(source) {
|
1208
|
+
return typeof self !== 'undefined' && source === self.ManagedMediaSource;
|
1209
|
+
}
|
1210
|
+
function isCompatibleTrackChange(currentTracks, requiredTracks) {
|
1211
|
+
var trackNames = Object.keys(currentTracks);
|
1212
|
+
var requiredTrackNames = Object.keys(requiredTracks);
|
1213
|
+
var trackCount = trackNames.length;
|
1214
|
+
var requiredTrackCount = requiredTrackNames.length;
|
1215
|
+
return !trackCount || !requiredTrackCount || trackCount === requiredTrackCount && !trackNames.some(function (name) {
|
1216
|
+
return requiredTrackNames.indexOf(name) === -1;
|
1217
|
+
});
|
1218
|
+
}
|
1219
|
+
|
1199
1220
|
// http://stackoverflow.com/questions/8936984/uint8array-to-string-in-javascript/22373197
|
1200
1221
|
// http://www.onicos.com/staff/iz/amuse/javascript/expert/utf.txt
|
1201
1222
|
/* utf.js - UTF-8 <=> UTF-16 convertion
|
@@ -2757,27 +2778,6 @@
|
|
2757
2778
|
};
|
2758
2779
|
}
|
2759
2780
|
|
2760
|
-
function getMediaSource(preferManagedMediaSource) {
|
2761
|
-
if (preferManagedMediaSource === void 0) {
|
2762
|
-
preferManagedMediaSource = true;
|
2763
|
-
}
|
2764
|
-
if (typeof self === 'undefined') return undefined;
|
2765
|
-
var mms = (preferManagedMediaSource || !self.MediaSource) && self.ManagedMediaSource;
|
2766
|
-
return mms || self.MediaSource || self.WebKitMediaSource;
|
2767
|
-
}
|
2768
|
-
function isManagedMediaSource(source) {
|
2769
|
-
return typeof self !== 'undefined' && source === self.ManagedMediaSource;
|
2770
|
-
}
|
2771
|
-
function isCompatibleTrackChange(currentTracks, requiredTracks) {
|
2772
|
-
var trackNames = Object.keys(currentTracks);
|
2773
|
-
var requiredTrackNames = Object.keys(requiredTracks);
|
2774
|
-
var trackCount = trackNames.length;
|
2775
|
-
var requiredTrackCount = requiredTrackNames.length;
|
2776
|
-
return !trackCount || !requiredTrackCount || trackCount === requiredTrackCount && !trackNames.some(function (name) {
|
2777
|
-
return requiredTrackNames.indexOf(name) === -1;
|
2778
|
-
});
|
2779
|
-
}
|
2780
|
-
|
2781
2781
|
var userAgentHevcSupportIsInaccurate = function userAgentHevcSupportIsInaccurate() {
|
2782
2782
|
return /\(Windows.+Firefox\//i.test(navigator.userAgent);
|
2783
2783
|
};
|
@@ -3534,6 +3534,7 @@
|
|
3534
3534
|
_this.partCurrent = null;
|
3535
3535
|
_this.bitrateTestDelay = 0;
|
3536
3536
|
_this.rebufferNotice = -1;
|
3537
|
+
_this.supportedCache = {};
|
3537
3538
|
_this.bwEstimator = void 0;
|
3538
3539
|
/*
|
3539
3540
|
This method monitors the download rate of the current fragment, and will downswitch if that fragment will not load
|
@@ -3730,13 +3731,14 @@
|
|
3730
3731
|
this.unregisterListeners();
|
3731
3732
|
this.clearTimer();
|
3732
3733
|
// @ts-ignore
|
3733
|
-
this.hls = this._abandonRulesCheck = null;
|
3734
|
+
this.hls = this._abandonRulesCheck = this.supportedCache = null;
|
3734
3735
|
this.fragCurrent = this.partCurrent = null;
|
3735
3736
|
};
|
3736
3737
|
_proto.onManifestLoading = function onManifestLoading(event, data) {
|
3737
3738
|
this.lastLoadedFragLevel = -1;
|
3738
3739
|
this.firstSelection = -1;
|
3739
3740
|
this.lastLevelLoadSec = 0;
|
3741
|
+
this.supportedCache = {};
|
3740
3742
|
this.fragCurrent = this.partCurrent = null;
|
3741
3743
|
this.onLevelsUpdated();
|
3742
3744
|
this.clearTimer();
|
@@ -4030,7 +4032,7 @@
|
|
4030
4032
|
var ttfbEstimateSec = this.bwEstimator.getEstimateTTFB() / 1000;
|
4031
4033
|
var levelsSkipped = [];
|
4032
4034
|
var _loop = function _loop() {
|
4033
|
-
var _levelInfo$supportedR;
|
4035
|
+
var _levelInfo$supportedR, _levelInfo$supportedR2;
|
4034
4036
|
var levelInfo = levels[i];
|
4035
4037
|
var upSwitch = i > selectionBaseLevel;
|
4036
4038
|
if (!levelInfo) {
|
@@ -4039,7 +4041,9 @@
|
|
4039
4041
|
|
4040
4042
|
// skip candidates which change codec-family or video-range,
|
4041
4043
|
// and which decrease or increase frame-rate for up and down-switch respectfully
|
4042
|
-
if (currentCodecSet && levelInfo.codecSet !== currentCodecSet || currentVideoRange && levelInfo.videoRange !== currentVideoRange || upSwitch && currentFrameRate > levelInfo.frameRate || !upSwitch && currentFrameRate > 0 && currentFrameRate < levelInfo.frameRate || levelInfo.supportedResult &&
|
4044
|
+
if (currentCodecSet && levelInfo.codecSet !== currentCodecSet || currentVideoRange && levelInfo.videoRange !== currentVideoRange || upSwitch && currentFrameRate > levelInfo.frameRate || !upSwitch && currentFrameRate > 0 && currentFrameRate < levelInfo.frameRate || (_levelInfo$supportedR = levelInfo.supportedResult) != null && (_levelInfo$supportedR2 = _levelInfo$supportedR.decodingInfoResults) != null && _levelInfo$supportedR2.some(function (info) {
|
4045
|
+
return info.smooth === false;
|
4046
|
+
})) {
|
4043
4047
|
if (!firstSelection || i !== minStartIndex) {
|
4044
4048
|
levelsSkipped.push(i);
|
4045
4049
|
return 0; // continue
|
@@ -20518,7 +20522,7 @@
|
|
20518
20522
|
return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
|
20519
20523
|
}
|
20520
20524
|
|
20521
|
-
var version = "1.6.6-0.canary.
|
20525
|
+
var version = "1.6.6-0.canary.11353";
|
20522
20526
|
|
20523
20527
|
// ensure the worker ends up in the bundle
|
20524
20528
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -23032,74 +23036,48 @@
|
|
23032
23036
|
error: error
|
23033
23037
|
};
|
23034
23038
|
}
|
23035
|
-
|
23036
|
-
|
23039
|
+
function getMediaDecodingInfoPromise(level, audioTracksByGroup, mediaCapabilities, cache) {
|
23040
|
+
if (cache === void 0) {
|
23041
|
+
cache = {};
|
23042
|
+
}
|
23037
23043
|
var videoCodecs = level.videoCodec;
|
23038
|
-
|
23039
|
-
if (!videoCodecs && !audioCodecs || !mediaCapabilities) {
|
23044
|
+
if (!videoCodecs && !level.audioCodec || !mediaCapabilities) {
|
23040
23045
|
return Promise.resolve(SUPPORTED_INFO_DEFAULT);
|
23041
23046
|
}
|
23042
23047
|
var configurations = [];
|
23043
|
-
|
23044
|
-
|
23045
|
-
|
23046
|
-
|
23047
|
-
|
23048
|
-
|
23049
|
-
|
23048
|
+
var videoDecodeList = makeVideoConfigurations(level);
|
23049
|
+
var videoCount = videoDecodeList.length;
|
23050
|
+
var audioDecodeList = makeAudioConfigurations(level, audioTracksByGroup, videoCount > 0);
|
23051
|
+
var audioCount = audioDecodeList.length;
|
23052
|
+
for (var i = videoCount || 1 * audioCount || 1; i--;) {
|
23053
|
+
var configuration = {
|
23054
|
+
type: 'media-source'
|
23050
23055
|
};
|
23051
|
-
|
23052
|
-
|
23053
|
-
baseVideoConfiguration.transferFunction = videoRange.toLowerCase();
|
23056
|
+
if (videoCount) {
|
23057
|
+
configuration.video = videoDecodeList[i % videoCount];
|
23054
23058
|
}
|
23055
|
-
|
23059
|
+
if (audioCount) {
|
23060
|
+
configuration.audio = audioDecodeList[i % audioCount];
|
23061
|
+
var audioBitrate = configuration.audio.bitrate;
|
23062
|
+
if (configuration.video && audioBitrate) {
|
23063
|
+
configuration.video.bitrate -= audioBitrate;
|
23064
|
+
}
|
23065
|
+
}
|
23066
|
+
configurations.push(configuration);
|
23067
|
+
}
|
23068
|
+
if (videoCodecs) {
|
23056
23069
|
// Override Windows Firefox HEVC MediaCapabilities result (https://github.com/video-dev/hls.js/issues/7046)
|
23057
23070
|
var ua = navigator.userAgent;
|
23058
|
-
if (
|
23071
|
+
if (videoCodecs.split(',').some(function (videoCodec) {
|
23059
23072
|
return isHEVC(videoCodec);
|
23060
23073
|
}) && userAgentHevcSupportIsInaccurate()) {
|
23061
|
-
return Promise.resolve(getUnsupportedResult(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent
|
23074
|
+
return Promise.resolve(getUnsupportedResult(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (" + ua + ")"), configurations));
|
23062
23075
|
}
|
23063
|
-
configurations.push.apply(configurations, videoCodecsArray.map(function (videoCodec) {
|
23064
|
-
return {
|
23065
|
-
type: 'media-source',
|
23066
|
-
video: _objectSpread2(_objectSpread2({}, baseVideoConfiguration), {}, {
|
23067
|
-
contentType: mimeTypeForCodec(fillInMissingAV01Params(videoCodec), 'video')
|
23068
|
-
})
|
23069
|
-
};
|
23070
|
-
}));
|
23071
|
-
}
|
23072
|
-
if (audioCodecs && level.audioGroups) {
|
23073
|
-
level.audioGroups.forEach(function (audioGroupId) {
|
23074
|
-
var _audioTracksByGroup$g;
|
23075
|
-
if (!audioGroupId) {
|
23076
|
-
return;
|
23077
|
-
}
|
23078
|
-
(_audioTracksByGroup$g = audioTracksByGroup.groups[audioGroupId]) == null ? void 0 : _audioTracksByGroup$g.tracks.forEach(function (audioTrack) {
|
23079
|
-
if (audioTrack.groupId === audioGroupId) {
|
23080
|
-
var channels = audioTrack.channels || '';
|
23081
|
-
var channelsNumber = parseFloat(channels);
|
23082
|
-
if (isFiniteNumber(channelsNumber) && channelsNumber > 2) {
|
23083
|
-
configurations.push.apply(configurations, audioCodecs.split(',').map(function (audioCodec) {
|
23084
|
-
return {
|
23085
|
-
type: 'media-source',
|
23086
|
-
audio: {
|
23087
|
-
contentType: mimeTypeForCodec(audioCodec, 'audio'),
|
23088
|
-
channels: '' + channelsNumber
|
23089
|
-
// spatialRendering:
|
23090
|
-
// audioCodec === 'ec-3' && channels.indexOf('JOC'),
|
23091
|
-
}
|
23092
|
-
};
|
23093
|
-
}));
|
23094
|
-
}
|
23095
|
-
}
|
23096
|
-
});
|
23097
|
-
});
|
23098
23076
|
}
|
23099
23077
|
return Promise.all(configurations.map(function (configuration) {
|
23100
23078
|
// Cache MediaCapabilities promises
|
23101
23079
|
var decodingInfoKey = getMediaDecodingInfoKey(configuration);
|
23102
|
-
return
|
23080
|
+
return cache[decodingInfoKey] || (cache[decodingInfoKey] = mediaCapabilities.decodingInfo(configuration));
|
23103
23081
|
})).then(function (decodingInfoResults) {
|
23104
23082
|
return {
|
23105
23083
|
supported: !decodingInfoResults.some(function (info) {
|
@@ -23117,20 +23095,88 @@
|
|
23117
23095
|
};
|
23118
23096
|
});
|
23119
23097
|
}
|
23098
|
+
function makeVideoConfigurations(level) {
|
23099
|
+
var _level$videoCodec;
|
23100
|
+
var videoCodecs = (_level$videoCodec = level.videoCodec) == null ? void 0 : _level$videoCodec.split(',');
|
23101
|
+
var bitrate = getVariantDecodingBitrate(level);
|
23102
|
+
var width = level.width || 640;
|
23103
|
+
var height = level.height || 480;
|
23104
|
+
// Assume a framerate of 30fps since MediaCapabilities will not accept Level default of 0.
|
23105
|
+
var framerate = level.frameRate || 30;
|
23106
|
+
var videoRange = level.videoRange.toLowerCase();
|
23107
|
+
return videoCodecs ? videoCodecs.map(function (videoCodec) {
|
23108
|
+
var videoConfiguration = {
|
23109
|
+
contentType: mimeTypeForCodec(fillInMissingAV01Params(videoCodec), 'video'),
|
23110
|
+
width: width,
|
23111
|
+
height: height,
|
23112
|
+
bitrate: bitrate,
|
23113
|
+
framerate: framerate
|
23114
|
+
};
|
23115
|
+
if (videoRange !== 'sdr') {
|
23116
|
+
videoConfiguration.transferFunction = videoRange;
|
23117
|
+
}
|
23118
|
+
return videoConfiguration;
|
23119
|
+
}) : [];
|
23120
|
+
}
|
23121
|
+
function makeAudioConfigurations(level, audioTracksByGroup, hasVideo) {
|
23122
|
+
var _level$audioCodec;
|
23123
|
+
var audioCodecs = (_level$audioCodec = level.audioCodec) == null ? void 0 : _level$audioCodec.split(',');
|
23124
|
+
var combinedBitrate = getVariantDecodingBitrate(level);
|
23125
|
+
if (audioCodecs && level.audioGroups) {
|
23126
|
+
return level.audioGroups.reduce(function (configurations, audioGroupId) {
|
23127
|
+
var _audioTracksByGroup$g;
|
23128
|
+
var tracks = audioGroupId ? (_audioTracksByGroup$g = audioTracksByGroup.groups[audioGroupId]) == null ? void 0 : _audioTracksByGroup$g.tracks : null;
|
23129
|
+
if (tracks) {
|
23130
|
+
return tracks.reduce(function (configs, audioTrack) {
|
23131
|
+
if (audioTrack.groupId === audioGroupId) {
|
23132
|
+
var channelsNumber = parseFloat(audioTrack.channels || '');
|
23133
|
+
audioCodecs.forEach(function (audioCodec) {
|
23134
|
+
var audioConfiguration = {
|
23135
|
+
contentType: mimeTypeForCodec(audioCodec, 'audio'),
|
23136
|
+
bitrate: hasVideo ? estimatedAudioBitrate(audioCodec, combinedBitrate) : combinedBitrate
|
23137
|
+
};
|
23138
|
+
if (channelsNumber) {
|
23139
|
+
audioConfiguration.channels = '' + channelsNumber;
|
23140
|
+
}
|
23141
|
+
configs.push(audioConfiguration);
|
23142
|
+
});
|
23143
|
+
}
|
23144
|
+
return configs;
|
23145
|
+
}, configurations);
|
23146
|
+
}
|
23147
|
+
return configurations;
|
23148
|
+
}, []);
|
23149
|
+
}
|
23150
|
+
return [];
|
23151
|
+
}
|
23152
|
+
function estimatedAudioBitrate(audioCodec, levelBitrate) {
|
23153
|
+
if (levelBitrate <= 1) {
|
23154
|
+
return 1;
|
23155
|
+
}
|
23156
|
+
var audioBitrate = 128000;
|
23157
|
+
if (audioCodec === 'ec-3') {
|
23158
|
+
audioBitrate = 768000;
|
23159
|
+
} else if (audioCodec === 'ac-3') {
|
23160
|
+
audioBitrate = 640000;
|
23161
|
+
}
|
23162
|
+
return Math.min(levelBitrate / 2, audioBitrate); // Don't exceed some % of level bitrate
|
23163
|
+
}
|
23164
|
+
function getVariantDecodingBitrate(level) {
|
23165
|
+
return Math.ceil(Math.max(level.bitrate * 0.9, level.averageBitrate) / 1000) * 1000 || 1;
|
23166
|
+
}
|
23120
23167
|
function getMediaDecodingInfoKey(config) {
|
23168
|
+
var key = '';
|
23121
23169
|
var audio = config.audio,
|
23122
23170
|
video = config.video;
|
23123
|
-
|
23124
|
-
|
23125
|
-
|
23126
|
-
|
23127
|
-
|
23128
|
-
|
23129
|
-
|
23130
|
-
return "c" + audio.channels + (audio.spatialRendering ? 's' : 'n') + "_" + codec;
|
23131
|
-
}
|
23171
|
+
if (video) {
|
23172
|
+
var codec = getCodecsForMimeType(video.contentType);
|
23173
|
+
key += codec + "_r" + video.height + "x" + video.width + "f" + Math.ceil(video.framerate) + (video.transferFunction || 'sd') + "_" + Math.ceil(video.bitrate / 1e5);
|
23174
|
+
}
|
23175
|
+
if (audio) {
|
23176
|
+
var _codec = getCodecsForMimeType(audio.contentType);
|
23177
|
+
key += "" + (video ? '_' : '') + _codec + "_c" + audio.channels;
|
23132
23178
|
}
|
23133
|
-
return
|
23179
|
+
return key;
|
23134
23180
|
}
|
23135
23181
|
|
23136
23182
|
/**
|