hls.js 1.5.18 → 1.5.20
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 +303 -250
- package/dist/hls.js.d.ts +3 -4
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +24 -29
- 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 +23 -28
- 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 +252 -206
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +1 -1
- package/src/controller/audio-stream-controller.ts +21 -29
- package/src/controller/eme-controller.ts +184 -124
- package/src/loader/key-loader.ts +6 -1
- package/src/loader/level-key.ts +6 -30
- package/src/utils/level-helper.ts +37 -38
- package/src/utils/mediakeys-helper.ts +34 -1
- package/src/utils/rendition-helper.ts +6 -10
package/dist/hls.js
CHANGED
@@ -552,7 +552,7 @@
|
|
552
552
|
// Some browsers don't allow to use bind on console object anyway
|
553
553
|
// fallback to default if needed
|
554
554
|
try {
|
555
|
-
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.5.
|
555
|
+
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.5.20");
|
556
556
|
} catch (e) {
|
557
557
|
exportedLogger = fakeLogger;
|
558
558
|
}
|
@@ -1378,6 +1378,27 @@
|
|
1378
1378
|
};
|
1379
1379
|
return [baseConfig];
|
1380
1380
|
}
|
1381
|
+
function parsePlayReadyWRM(keyBytes) {
|
1382
|
+
var keyBytesUtf16 = new Uint16Array(keyBytes.buffer, keyBytes.byteOffset, keyBytes.byteLength / 2);
|
1383
|
+
var keyByteStr = String.fromCharCode.apply(null, Array.from(keyBytesUtf16));
|
1384
|
+
|
1385
|
+
// Parse Playready WRMHeader XML
|
1386
|
+
var xmlKeyBytes = keyByteStr.substring(keyByteStr.indexOf('<'), keyByteStr.length);
|
1387
|
+
var parser = new DOMParser();
|
1388
|
+
var xmlDoc = parser.parseFromString(xmlKeyBytes, 'text/xml');
|
1389
|
+
var keyData = xmlDoc.getElementsByTagName('KID')[0];
|
1390
|
+
if (keyData) {
|
1391
|
+
var keyId = keyData.childNodes[0] ? keyData.childNodes[0].nodeValue : keyData.getAttribute('VALUE');
|
1392
|
+
if (keyId) {
|
1393
|
+
var keyIdArray = base64Decode(keyId).subarray(0, 16);
|
1394
|
+
// KID value in PRO is a base64-encoded little endian GUID interpretation of UUID
|
1395
|
+
// KID value in ‘tenc’ is a big endian UUID GUID interpretation of UUID
|
1396
|
+
changeEndianness(keyIdArray);
|
1397
|
+
return keyIdArray;
|
1398
|
+
}
|
1399
|
+
}
|
1400
|
+
return null;
|
1401
|
+
}
|
1381
1402
|
|
1382
1403
|
function sliceUint8(array, start, end) {
|
1383
1404
|
// @ts-expect-error This polyfills IE11 usage of Uint8Array slice.
|
@@ -3011,6 +3032,8 @@
|
|
3011
3032
|
if (keyBytes) {
|
3012
3033
|
switch (this.keyFormat) {
|
3013
3034
|
case KeySystemFormats.WIDEVINE:
|
3035
|
+
// Setting `pssh` on this LevelKey/DecryptData allows HLS.js to generate a session using
|
3036
|
+
// the playlist-key before the "encrypted" event. (Comment out to only use "encrypted" path.)
|
3014
3037
|
this.pssh = keyBytes;
|
3015
3038
|
// In case of widevine keyID is embedded in PSSH box. Read Key ID.
|
3016
3039
|
if (keyBytes.length >= 22) {
|
@@ -3020,25 +3043,11 @@
|
|
3020
3043
|
case KeySystemFormats.PLAYREADY:
|
3021
3044
|
{
|
3022
3045
|
var PlayReadyKeySystemUUID = new Uint8Array([0x9a, 0x04, 0xf0, 0x79, 0x98, 0x40, 0x42, 0x86, 0xab, 0x92, 0xe6, 0x5b, 0xe0, 0x88, 0x5f, 0x95]);
|
3046
|
+
|
3047
|
+
// Setting `pssh` on this LevelKey/DecryptData allows HLS.js to generate a session using
|
3048
|
+
// the playlist-key before the "encrypted" event. (Comment out to only use "encrypted" path.)
|
3023
3049
|
this.pssh = mp4pssh(PlayReadyKeySystemUUID, null, keyBytes);
|
3024
|
-
|
3025
|
-
var keyByteStr = String.fromCharCode.apply(null, Array.from(keyBytesUtf16));
|
3026
|
-
|
3027
|
-
// Parse Playready WRMHeader XML
|
3028
|
-
var xmlKeyBytes = keyByteStr.substring(keyByteStr.indexOf('<'), keyByteStr.length);
|
3029
|
-
var parser = new DOMParser();
|
3030
|
-
var xmlDoc = parser.parseFromString(xmlKeyBytes, 'text/xml');
|
3031
|
-
var keyData = xmlDoc.getElementsByTagName('KID')[0];
|
3032
|
-
if (keyData) {
|
3033
|
-
var keyId = keyData.childNodes[0] ? keyData.childNodes[0].nodeValue : keyData.getAttribute('VALUE');
|
3034
|
-
if (keyId) {
|
3035
|
-
var keyIdArray = base64Decode(keyId).subarray(0, 16);
|
3036
|
-
// KID value in PRO is a base64-encoded little endian GUID interpretation of UUID
|
3037
|
-
// KID value in ‘tenc’ is a big endian UUID GUID interpretation of UUID
|
3038
|
-
changeEndianness(keyIdArray);
|
3039
|
-
this.keyId = keyIdArray;
|
3040
|
-
}
|
3041
|
-
}
|
3050
|
+
this.keyId = parsePlayReadyWRM(keyBytes);
|
3042
3051
|
break;
|
3043
3052
|
}
|
3044
3053
|
default:
|
@@ -3057,15 +3066,15 @@
|
|
3057
3066
|
|
3058
3067
|
// Default behavior: assign a new keyId for each uri
|
3059
3068
|
if (!this.keyId || this.keyId.byteLength !== 16) {
|
3060
|
-
var
|
3061
|
-
if (!
|
3069
|
+
var keyId = keyUriToKeyIdMap[this.uri];
|
3070
|
+
if (!keyId) {
|
3062
3071
|
var val = Object.keys(keyUriToKeyIdMap).length % Number.MAX_SAFE_INTEGER;
|
3063
|
-
|
3064
|
-
var dv = new DataView(
|
3072
|
+
keyId = new Uint8Array(16);
|
3073
|
+
var dv = new DataView(keyId.buffer, 12, 4); // Just set the last 4 bytes
|
3065
3074
|
dv.setUint32(0, val);
|
3066
|
-
keyUriToKeyIdMap[this.uri] =
|
3075
|
+
keyUriToKeyIdMap[this.uri] = keyId;
|
3067
3076
|
}
|
3068
|
-
this.keyId =
|
3077
|
+
this.keyId = keyId;
|
3069
3078
|
}
|
3070
3079
|
return this;
|
3071
3080
|
};
|
@@ -5543,15 +5552,16 @@
|
|
5543
5552
|
delete oldDetails.fragmentHint.endPTS;
|
5544
5553
|
}
|
5545
5554
|
// check if old/new playlists have fragments in common
|
5546
|
-
// loop through overlapping SN and update startPTS
|
5547
|
-
var ccOffset = 0;
|
5555
|
+
// loop through overlapping SN and update startPTS, cc, and duration if any found
|
5548
5556
|
var PTSFrag;
|
5549
|
-
mapFragmentIntersection(oldDetails, newDetails, function (oldFrag, newFrag) {
|
5550
|
-
if (
|
5551
|
-
|
5552
|
-
|
5553
|
-
|
5554
|
-
|
5557
|
+
mapFragmentIntersection(oldDetails, newDetails, function (oldFrag, newFrag, newFragIndex, newFragments) {
|
5558
|
+
if (newDetails.skippedSegments) {
|
5559
|
+
if (newFrag.cc !== oldFrag.cc) {
|
5560
|
+
var ccOffset = oldFrag.cc - newFrag.cc;
|
5561
|
+
for (var _i = newFragIndex; _i < newFragments.length; _i++) {
|
5562
|
+
newFragments[_i].cc += ccOffset;
|
5563
|
+
}
|
5564
|
+
}
|
5555
5565
|
}
|
5556
5566
|
if (isFiniteNumber(oldFrag.startPTS) && isFiniteNumber(oldFrag.endPTS)) {
|
5557
5567
|
newFrag.start = newFrag.startPTS = oldFrag.startPTS;
|
@@ -5576,8 +5586,9 @@
|
|
5576
5586
|
currentInitSegment = oldFrag.initSegment;
|
5577
5587
|
}
|
5578
5588
|
});
|
5589
|
+
var newFragments = newDetails.fragments;
|
5579
5590
|
if (currentInitSegment) {
|
5580
|
-
var fragmentsToCheck = newDetails.fragmentHint ?
|
5591
|
+
var fragmentsToCheck = newDetails.fragmentHint ? newFragments.concat(newDetails.fragmentHint) : newFragments;
|
5581
5592
|
fragmentsToCheck.forEach(function (frag) {
|
5582
5593
|
var _currentInitSegment;
|
5583
5594
|
if (frag && (!frag.initSegment || frag.initSegment.relurl === ((_currentInitSegment = currentInitSegment) == null ? void 0 : _currentInitSegment.relurl))) {
|
@@ -5586,29 +5597,22 @@
|
|
5586
5597
|
});
|
5587
5598
|
}
|
5588
5599
|
if (newDetails.skippedSegments) {
|
5589
|
-
newDetails.deltaUpdateFailed =
|
5600
|
+
newDetails.deltaUpdateFailed = newFragments.some(function (frag) {
|
5590
5601
|
return !frag;
|
5591
5602
|
});
|
5592
5603
|
if (newDetails.deltaUpdateFailed) {
|
5593
5604
|
logger.warn('[level-helper] Previous playlist missing segments skipped in delta playlist');
|
5594
|
-
for (var
|
5595
|
-
|
5605
|
+
for (var _i2 = newDetails.skippedSegments; _i2--;) {
|
5606
|
+
newFragments.shift();
|
5607
|
+
}
|
5608
|
+
newDetails.startSN = newFragments[0].sn;
|
5609
|
+
} else {
|
5610
|
+
if (newDetails.canSkipDateRanges) {
|
5611
|
+
newDetails.dateRanges = mergeDateRanges(oldDetails.dateRanges, newDetails.dateRanges, newDetails.recentlyRemovedDateranges);
|
5596
5612
|
}
|
5597
|
-
newDetails.startSN = newDetails.fragments[0].sn;
|
5598
|
-
newDetails.startCC = newDetails.fragments[0].cc;
|
5599
|
-
} else if (newDetails.canSkipDateRanges) {
|
5600
|
-
newDetails.dateRanges = mergeDateRanges(oldDetails.dateRanges, newDetails.dateRanges, newDetails.recentlyRemovedDateranges);
|
5601
|
-
}
|
5602
|
-
}
|
5603
|
-
var newFragments = newDetails.fragments;
|
5604
|
-
if (ccOffset) {
|
5605
|
-
logger.warn('discontinuity sliding from playlist, take drift into account');
|
5606
|
-
for (var _i2 = 0; _i2 < newFragments.length; _i2++) {
|
5607
|
-
newFragments[_i2].cc += ccOffset;
|
5608
5613
|
}
|
5609
|
-
}
|
5610
|
-
if (newDetails.skippedSegments) {
|
5611
5614
|
newDetails.startCC = newDetails.fragments[0].cc;
|
5615
|
+
newDetails.endCC = newFragments[newFragments.length - 1].cc;
|
5612
5616
|
}
|
5613
5617
|
|
5614
5618
|
// Merge parts
|
@@ -5692,7 +5696,7 @@
|
|
5692
5696
|
_newFrag = newDetails.fragments[i] = _oldFrag;
|
5693
5697
|
}
|
5694
5698
|
if (_oldFrag && _newFrag) {
|
5695
|
-
intersectionFn(_oldFrag, _newFrag);
|
5699
|
+
intersectionFn(_oldFrag, _newFrag, i, newFrags);
|
5696
5700
|
}
|
5697
5701
|
}
|
5698
5702
|
}
|
@@ -7170,10 +7174,9 @@
|
|
7170
7174
|
name = option.name,
|
7171
7175
|
lang = option.lang,
|
7172
7176
|
assocLang = option.assocLang,
|
7173
|
-
characteristics = option.characteristics,
|
7174
7177
|
isDefault = option.default;
|
7175
7178
|
var forced = option.forced;
|
7176
|
-
return (groupId === undefined || track.groupId === groupId) && (name === undefined || track.name === name) && (lang === undefined || track.lang === lang) && (lang === undefined || track.assocLang === assocLang) && (isDefault === undefined || track.default === isDefault) && (forced === undefined || track.forced === forced) && (characteristics
|
7179
|
+
return (groupId === undefined || track.groupId === groupId) && (name === undefined || track.name === name) && (lang === undefined || track.lang === lang) && (lang === undefined || track.assocLang === assocLang) && (isDefault === undefined || track.default === isDefault) && (forced === undefined || track.forced === forced) && (!('characteristics' in option) || characteristicsMatch(option.characteristics || '', track.characteristics)) && (matchPredicate === undefined || matchPredicate(option, track));
|
7177
7180
|
}
|
7178
7181
|
function characteristicsMatch(characteristicsA, characteristicsB) {
|
7179
7182
|
if (characteristicsB === void 0) {
|
@@ -16259,32 +16262,6 @@
|
|
16259
16262
|
return TransmuxerInterface;
|
16260
16263
|
}();
|
16261
16264
|
|
16262
|
-
function subtitleOptionsIdentical(trackList1, trackList2) {
|
16263
|
-
if (trackList1.length !== trackList2.length) {
|
16264
|
-
return false;
|
16265
|
-
}
|
16266
|
-
for (var i = 0; i < trackList1.length; i++) {
|
16267
|
-
if (!mediaAttributesIdentical(trackList1[i].attrs, trackList2[i].attrs)) {
|
16268
|
-
return false;
|
16269
|
-
}
|
16270
|
-
}
|
16271
|
-
return true;
|
16272
|
-
}
|
16273
|
-
function mediaAttributesIdentical(attrs1, attrs2, customAttributes) {
|
16274
|
-
// Media options with the same rendition ID must be bit identical
|
16275
|
-
var stableRenditionId = attrs1['STABLE-RENDITION-ID'];
|
16276
|
-
if (stableRenditionId && !customAttributes) {
|
16277
|
-
return stableRenditionId === attrs2['STABLE-RENDITION-ID'];
|
16278
|
-
}
|
16279
|
-
// When rendition ID is not present, compare attributes
|
16280
|
-
return !(customAttributes || ['LANGUAGE', 'NAME', 'CHARACTERISTICS', 'AUTOSELECT', 'DEFAULT', 'FORCED', 'ASSOC-LANGUAGE']).some(function (subtitleAttribute) {
|
16281
|
-
return attrs1[subtitleAttribute] !== attrs2[subtitleAttribute];
|
16282
|
-
});
|
16283
|
-
}
|
16284
|
-
function subtitleTrackMatchesTextTrack(subtitleTrack, textTrack) {
|
16285
|
-
return textTrack.label.toLowerCase() === subtitleTrack.name.toLowerCase() && (!textTrack.language || textTrack.language.toLowerCase() === (subtitleTrack.lang || '').toLowerCase());
|
16286
|
-
}
|
16287
|
-
|
16288
16265
|
var TICK_INTERVAL$2 = 100; // how often to tick in ms
|
16289
16266
|
var AudioStreamController = /*#__PURE__*/function (_BaseStreamController) {
|
16290
16267
|
_inheritsLoose(AudioStreamController, _BaseStreamController);
|
@@ -16522,9 +16499,7 @@
|
|
16522
16499
|
if (bufferInfo === null) {
|
16523
16500
|
return;
|
16524
16501
|
}
|
16525
|
-
|
16526
|
-
switchingTrack = this.switchingTrack;
|
16527
|
-
if (!switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
|
16502
|
+
if (!this.switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
|
16528
16503
|
hls.trigger(Events.BUFFER_EOS, {
|
16529
16504
|
type: 'audio'
|
16530
16505
|
});
|
@@ -16536,13 +16511,10 @@
|
|
16536
16511
|
var maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len);
|
16537
16512
|
var fragments = trackDetails.fragments;
|
16538
16513
|
var start = fragments[0].start;
|
16539
|
-
var
|
16540
|
-
|
16541
|
-
|
16542
|
-
|
16543
|
-
if (bufferedTrack && !mediaAttributesIdentical(switchingTrack.attrs, bufferedTrack.attrs)) {
|
16544
|
-
targetBufferTime = pos;
|
16545
|
-
}
|
16514
|
+
var loadPosition = this.getLoadPosition();
|
16515
|
+
var targetBufferTime = this.flushing ? loadPosition : bufferInfo.end;
|
16516
|
+
if (this.switchingTrack && media) {
|
16517
|
+
var pos = loadPosition;
|
16546
16518
|
// if currentTime (pos) is less than alt audio playlist start time, it means that alt audio is ahead of currentTime
|
16547
16519
|
if (trackDetails.PTSKnown && pos < start) {
|
16548
16520
|
// if everything is buffered from pos to start or if audio buffer upfront, let's seek to start
|
@@ -16554,7 +16526,7 @@
|
|
16554
16526
|
}
|
16555
16527
|
|
16556
16528
|
// if buffer length is less than maxBufLen, or near the end, find a fragment to load
|
16557
|
-
if (bufferLen >= maxBufLen && !switchingTrack && targetBufferTime < fragments[fragments.length - 1].start) {
|
16529
|
+
if (bufferLen >= maxBufLen && !this.switchingTrack && targetBufferTime < fragments[fragments.length - 1].start) {
|
16558
16530
|
return;
|
16559
16531
|
}
|
16560
16532
|
var frag = this.getNextFragment(targetBufferTime, trackDetails);
|
@@ -17009,14 +16981,26 @@
|
|
17009
16981
|
}
|
17010
16982
|
};
|
17011
16983
|
_proto.flushAudioIfNeeded = function flushAudioIfNeeded(switchingTrack) {
|
17012
|
-
|
17013
|
-
bufferedTrack = this.bufferedTrack
|
17014
|
-
|
17015
|
-
|
17016
|
-
|
17017
|
-
|
17018
|
-
|
17019
|
-
|
16984
|
+
if (this.media && this.bufferedTrack) {
|
16985
|
+
var _this$bufferedTrack = this.bufferedTrack,
|
16986
|
+
name = _this$bufferedTrack.name,
|
16987
|
+
lang = _this$bufferedTrack.lang,
|
16988
|
+
assocLang = _this$bufferedTrack.assocLang,
|
16989
|
+
characteristics = _this$bufferedTrack.characteristics,
|
16990
|
+
audioCodec = _this$bufferedTrack.audioCodec,
|
16991
|
+
channels = _this$bufferedTrack.channels;
|
16992
|
+
if (!matchesOption({
|
16993
|
+
name: name,
|
16994
|
+
lang: lang,
|
16995
|
+
assocLang: assocLang,
|
16996
|
+
characteristics: characteristics,
|
16997
|
+
audioCodec: audioCodec,
|
16998
|
+
channels: channels
|
16999
|
+
}, switchingTrack, audioMatchPredicate)) {
|
17000
|
+
this.log('Switching audio track : flushing all audio');
|
17001
|
+
_BaseStreamController.prototype.flushMainBuffer.call(this, 0, Number.POSITIVE_INFINITY, 'audio');
|
17002
|
+
this.bufferedTrack = null;
|
17003
|
+
}
|
17020
17004
|
}
|
17021
17005
|
};
|
17022
17006
|
_proto.completeAudioSwitch = function completeAudioSwitch(switchingTrack) {
|
@@ -17029,6 +17013,32 @@
|
|
17029
17013
|
return AudioStreamController;
|
17030
17014
|
}(BaseStreamController);
|
17031
17015
|
|
17016
|
+
function subtitleOptionsIdentical(trackList1, trackList2) {
|
17017
|
+
if (trackList1.length !== trackList2.length) {
|
17018
|
+
return false;
|
17019
|
+
}
|
17020
|
+
for (var i = 0; i < trackList1.length; i++) {
|
17021
|
+
if (!mediaAttributesIdentical(trackList1[i].attrs, trackList2[i].attrs)) {
|
17022
|
+
return false;
|
17023
|
+
}
|
17024
|
+
}
|
17025
|
+
return true;
|
17026
|
+
}
|
17027
|
+
function mediaAttributesIdentical(attrs1, attrs2, customAttributes) {
|
17028
|
+
// Media options with the same rendition ID must be bit identical
|
17029
|
+
var stableRenditionId = attrs1['STABLE-RENDITION-ID'];
|
17030
|
+
if (stableRenditionId && !customAttributes) {
|
17031
|
+
return stableRenditionId === attrs2['STABLE-RENDITION-ID'];
|
17032
|
+
}
|
17033
|
+
// When rendition ID is not present, compare attributes
|
17034
|
+
return !(customAttributes || ['LANGUAGE', 'NAME', 'CHARACTERISTICS', 'AUTOSELECT', 'DEFAULT', 'FORCED', 'ASSOC-LANGUAGE']).some(function (subtitleAttribute) {
|
17035
|
+
return attrs1[subtitleAttribute] !== attrs2[subtitleAttribute];
|
17036
|
+
});
|
17037
|
+
}
|
17038
|
+
function subtitleTrackMatchesTextTrack(subtitleTrack, textTrack) {
|
17039
|
+
return textTrack.label.toLowerCase() === subtitleTrack.name.toLowerCase() && (!textTrack.language || textTrack.language.toLowerCase() === (subtitleTrack.lang || '').toLowerCase());
|
17040
|
+
}
|
17041
|
+
|
17032
17042
|
var AudioTrackController = /*#__PURE__*/function (_BasePlaylistControll) {
|
17033
17043
|
_inheritsLoose(AudioTrackController, _BasePlaylistControll);
|
17034
17044
|
function AudioTrackController(hls) {
|
@@ -22598,6 +22608,7 @@
|
|
22598
22608
|
*/
|
22599
22609
|
var EMEController = /*#__PURE__*/function () {
|
22600
22610
|
function EMEController(hls) {
|
22611
|
+
var _this = this;
|
22601
22612
|
this.hls = void 0;
|
22602
22613
|
this.config = void 0;
|
22603
22614
|
this.media = null;
|
@@ -22607,12 +22618,161 @@
|
|
22607
22618
|
this.mediaKeySessions = [];
|
22608
22619
|
this.keyIdToKeySessionPromise = {};
|
22609
22620
|
this.setMediaKeysQueue = EMEController.CDMCleanupPromise ? [EMEController.CDMCleanupPromise] : [];
|
22610
|
-
this.onMediaEncrypted = this._onMediaEncrypted.bind(this);
|
22611
|
-
this.onWaitingForKey = this._onWaitingForKey.bind(this);
|
22612
22621
|
this.debug = logger.debug.bind(logger, LOGGER_PREFIX);
|
22613
22622
|
this.log = logger.log.bind(logger, LOGGER_PREFIX);
|
22614
22623
|
this.warn = logger.warn.bind(logger, LOGGER_PREFIX);
|
22615
22624
|
this.error = logger.error.bind(logger, LOGGER_PREFIX);
|
22625
|
+
this.onMediaEncrypted = function (event) {
|
22626
|
+
var initDataType = event.initDataType,
|
22627
|
+
initData = event.initData;
|
22628
|
+
var logMessage = "\"" + event.type + "\" event: init data type: \"" + initDataType + "\"";
|
22629
|
+
_this.debug(logMessage);
|
22630
|
+
|
22631
|
+
// Ignore event when initData is null
|
22632
|
+
if (initData === null) {
|
22633
|
+
return;
|
22634
|
+
}
|
22635
|
+
if (!_this.keyFormatPromise) {
|
22636
|
+
var keySystems = Object.keys(_this.keySystemAccessPromises);
|
22637
|
+
if (!keySystems.length) {
|
22638
|
+
keySystems = getKeySystemsForConfig(_this.config);
|
22639
|
+
}
|
22640
|
+
var keyFormats = keySystems.map(keySystemDomainToKeySystemFormat).filter(function (k) {
|
22641
|
+
return !!k;
|
22642
|
+
});
|
22643
|
+
_this.keyFormatPromise = _this.getKeyFormatPromise(keyFormats);
|
22644
|
+
}
|
22645
|
+
_this.keyFormatPromise.then(function (keySystemFormat) {
|
22646
|
+
var keySystem = keySystemFormatToKeySystemDomain(keySystemFormat);
|
22647
|
+
var keyId;
|
22648
|
+
var keySystemDomain;
|
22649
|
+
if (initDataType === 'sinf') {
|
22650
|
+
if (keySystem !== KeySystems.FAIRPLAY) {
|
22651
|
+
_this.warn("Ignoring unexpected \"" + event.type + "\" event with init data type: \"" + initDataType + "\" for selected key-system " + keySystem);
|
22652
|
+
return;
|
22653
|
+
}
|
22654
|
+
// Match sinf keyId to playlist skd://keyId=
|
22655
|
+
var json = bin2str(new Uint8Array(initData));
|
22656
|
+
try {
|
22657
|
+
var sinf = base64Decode(JSON.parse(json).sinf);
|
22658
|
+
var tenc = parseSinf(sinf);
|
22659
|
+
if (!tenc) {
|
22660
|
+
throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");
|
22661
|
+
}
|
22662
|
+
keyId = tenc.subarray(8, 24);
|
22663
|
+
keySystemDomain = KeySystems.FAIRPLAY;
|
22664
|
+
} catch (error) {
|
22665
|
+
_this.warn(logMessage + " Failed to parse sinf: " + error);
|
22666
|
+
return;
|
22667
|
+
}
|
22668
|
+
} else {
|
22669
|
+
if (keySystem !== KeySystems.WIDEVINE && keySystem !== KeySystems.PLAYREADY) {
|
22670
|
+
_this.warn("Ignoring unexpected \"" + event.type + "\" event with init data type: \"" + initDataType + "\" for selected key-system " + keySystem);
|
22671
|
+
return;
|
22672
|
+
}
|
22673
|
+
// Support Widevine/PlayReady clear-lead key-session creation (otherwise depend on playlist keys)
|
22674
|
+
var psshResults = parseMultiPssh(initData);
|
22675
|
+
var psshInfos = psshResults.filter(function (pssh) {
|
22676
|
+
return !!pssh.systemId && keySystemIdToKeySystemDomain(pssh.systemId) === keySystem;
|
22677
|
+
});
|
22678
|
+
if (psshInfos.length > 1) {
|
22679
|
+
_this.warn(logMessage + " Using first of " + psshInfos.length + " pssh found for selected key-system " + keySystem);
|
22680
|
+
}
|
22681
|
+
var psshInfo = psshInfos[0];
|
22682
|
+
if (!psshInfo) {
|
22683
|
+
if (psshResults.length === 0 || psshResults.some(function (pssh) {
|
22684
|
+
return !pssh.systemId;
|
22685
|
+
})) {
|
22686
|
+
_this.warn(logMessage + " contains incomplete or invalid pssh data");
|
22687
|
+
} else {
|
22688
|
+
_this.log("ignoring " + logMessage + " for " + psshResults.map(function (pssh) {
|
22689
|
+
return keySystemIdToKeySystemDomain(pssh.systemId);
|
22690
|
+
}).join(',') + " pssh data in favor of playlist keys");
|
22691
|
+
}
|
22692
|
+
return;
|
22693
|
+
}
|
22694
|
+
keySystemDomain = keySystemIdToKeySystemDomain(psshInfo.systemId);
|
22695
|
+
if (psshInfo.version === 0 && psshInfo.data) {
|
22696
|
+
if (keySystemDomain === KeySystems.WIDEVINE) {
|
22697
|
+
var offset = psshInfo.data.length - 22;
|
22698
|
+
keyId = psshInfo.data.subarray(offset, offset + 16);
|
22699
|
+
} else if (keySystemDomain === KeySystems.PLAYREADY) {
|
22700
|
+
keyId = parsePlayReadyWRM(psshInfo.data);
|
22701
|
+
}
|
22702
|
+
}
|
22703
|
+
}
|
22704
|
+
if (!keySystemDomain || !keyId) {
|
22705
|
+
_this.log("Unable to handle " + logMessage + " with key-system " + keySystem);
|
22706
|
+
return;
|
22707
|
+
}
|
22708
|
+
var keyIdHex = Hex.hexDump(keyId);
|
22709
|
+
var keyIdToKeySessionPromise = _this.keyIdToKeySessionPromise,
|
22710
|
+
mediaKeySessions = _this.mediaKeySessions;
|
22711
|
+
var keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex];
|
22712
|
+
var _loop = function _loop() {
|
22713
|
+
// Match playlist key
|
22714
|
+
var keyContext = mediaKeySessions[i];
|
22715
|
+
var decryptdata = keyContext.decryptdata;
|
22716
|
+
if (!decryptdata.keyId) {
|
22717
|
+
return 0; // continue
|
22718
|
+
}
|
22719
|
+
var oldKeyIdHex = Hex.hexDump(decryptdata.keyId);
|
22720
|
+
if (keyIdHex === oldKeyIdHex || decryptdata.uri.replace(/-/g, '').indexOf(keyIdHex) !== -1) {
|
22721
|
+
keySessionContextPromise = keyIdToKeySessionPromise[oldKeyIdHex];
|
22722
|
+
if (decryptdata.pssh) {
|
22723
|
+
return 1; // break
|
22724
|
+
}
|
22725
|
+
delete keyIdToKeySessionPromise[oldKeyIdHex];
|
22726
|
+
decryptdata.pssh = new Uint8Array(initData);
|
22727
|
+
decryptdata.keyId = keyId;
|
22728
|
+
keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = keySessionContextPromise.then(function () {
|
22729
|
+
return _this.generateRequestWithPreferredKeySession(keyContext, initDataType, initData, 'encrypted-event-key-match');
|
22730
|
+
});
|
22731
|
+
keySessionContextPromise.catch(function (error) {
|
22732
|
+
return _this.handleError(error);
|
22733
|
+
});
|
22734
|
+
return 1; // break
|
22735
|
+
}
|
22736
|
+
},
|
22737
|
+
_ret;
|
22738
|
+
for (var i = 0; i < mediaKeySessions.length; i++) {
|
22739
|
+
_ret = _loop();
|
22740
|
+
if (_ret === 0) continue;
|
22741
|
+
if (_ret === 1) break;
|
22742
|
+
}
|
22743
|
+
if (!keySessionContextPromise) {
|
22744
|
+
if (keySystemDomain !== keySystem) {
|
22745
|
+
_this.log("Ignoring \"" + logMessage + "\" with " + keySystemDomain + " init data for selected key-system " + keySystem);
|
22746
|
+
return;
|
22747
|
+
}
|
22748
|
+
// "Clear-lead" (misc key not encountered in playlist)
|
22749
|
+
keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = _this.getKeySystemSelectionPromise([keySystemDomain]).then(function (_ref) {
|
22750
|
+
var _keySystemToKeySystem;
|
22751
|
+
var keySystem = _ref.keySystem,
|
22752
|
+
mediaKeys = _ref.mediaKeys;
|
22753
|
+
_this.throwIfDestroyed();
|
22754
|
+
var decryptdata = new LevelKey('ISO-23001-7', keyIdHex, (_keySystemToKeySystem = keySystemDomainToKeySystemFormat(keySystem)) != null ? _keySystemToKeySystem : '');
|
22755
|
+
decryptdata.pssh = new Uint8Array(initData);
|
22756
|
+
decryptdata.keyId = keyId;
|
22757
|
+
return _this.attemptSetMediaKeys(keySystem, mediaKeys).then(function () {
|
22758
|
+
_this.throwIfDestroyed();
|
22759
|
+
var keySessionContext = _this.createMediaKeySessionContext({
|
22760
|
+
decryptdata: decryptdata,
|
22761
|
+
keySystem: keySystem,
|
22762
|
+
mediaKeys: mediaKeys
|
22763
|
+
});
|
22764
|
+
return _this.generateRequestWithPreferredKeySession(keySessionContext, initDataType, initData, 'encrypted-event-no-match');
|
22765
|
+
});
|
22766
|
+
});
|
22767
|
+
keySessionContextPromise.catch(function (error) {
|
22768
|
+
return _this.handleError(error);
|
22769
|
+
});
|
22770
|
+
}
|
22771
|
+
});
|
22772
|
+
};
|
22773
|
+
this.onWaitingForKey = function (event) {
|
22774
|
+
_this.log("\"" + event.type + "\" event");
|
22775
|
+
};
|
22616
22776
|
this.hls = hls;
|
22617
22777
|
this.config = hls.config;
|
22618
22778
|
this.registerListeners();
|
@@ -22627,9 +22787,9 @@
|
|
22627
22787
|
config.licenseXhrSetup = config.licenseResponseCallback = undefined;
|
22628
22788
|
config.drmSystems = config.drmSystemOptions = {};
|
22629
22789
|
// @ts-ignore
|
22630
|
-
this.hls = this.
|
22790
|
+
this.hls = this.config = this.keyIdToKeySessionPromise = null;
|
22631
22791
|
// @ts-ignore
|
22632
|
-
this.
|
22792
|
+
this.onMediaEncrypted = this.onWaitingForKey = null;
|
22633
22793
|
};
|
22634
22794
|
_proto.registerListeners = function registerListeners() {
|
22635
22795
|
this.hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
|
@@ -22656,7 +22816,13 @@
|
|
22656
22816
|
if (keySystem === KeySystems.WIDEVINE && widevineLicenseUrl) {
|
22657
22817
|
return widevineLicenseUrl;
|
22658
22818
|
}
|
22659
|
-
|
22819
|
+
};
|
22820
|
+
_proto.getLicenseServerUrlOrThrow = function getLicenseServerUrlOrThrow(keySystem) {
|
22821
|
+
var url = this.getLicenseServerUrl(keySystem);
|
22822
|
+
if (url === undefined) {
|
22823
|
+
throw new Error("no license server URL configured for key-system \"" + keySystem + "\"");
|
22824
|
+
}
|
22825
|
+
return url;
|
22660
22826
|
};
|
22661
22827
|
_proto.getServerCertificateUrl = function getServerCertificateUrl(keySystem) {
|
22662
22828
|
var drmSystems = this.config.drmSystems;
|
@@ -22668,7 +22834,7 @@
|
|
22668
22834
|
}
|
22669
22835
|
};
|
22670
22836
|
_proto.attemptKeySystemAccess = function attemptKeySystemAccess(keySystemsToAttempt) {
|
22671
|
-
var
|
22837
|
+
var _this2 = this;
|
22672
22838
|
var levels = this.hls.levels;
|
22673
22839
|
var uniqueCodec = function uniqueCodec(value, i, a) {
|
22674
22840
|
return !!value && a.indexOf(value) === i;
|
@@ -22685,7 +22851,7 @@
|
|
22685
22851
|
return new Promise(function (resolve, reject) {
|
22686
22852
|
var attempt = function attempt(keySystems) {
|
22687
22853
|
var keySystem = keySystems.shift();
|
22688
|
-
|
22854
|
+
_this2.getMediaKeysPromise(keySystem, audioCodecs, videoCodecs).then(function (mediaKeys) {
|
22689
22855
|
return resolve({
|
22690
22856
|
keySystem: keySystem,
|
22691
22857
|
mediaKeys: mediaKeys
|
@@ -22720,7 +22886,7 @@
|
|
22720
22886
|
return requestMediaKeySystemAccessFunc(keySystem, supportedConfigurations);
|
22721
22887
|
};
|
22722
22888
|
_proto.getMediaKeysPromise = function getMediaKeysPromise(keySystem, audioCodecs, videoCodecs) {
|
22723
|
-
var
|
22889
|
+
var _this3 = this;
|
22724
22890
|
// This can throw, but is caught in event handler callpath
|
22725
22891
|
var mediaKeySystemConfigs = getSupportedMediaKeySystemConfigurations(keySystem, audioCodecs, videoCodecs, this.config.drmSystemOptions);
|
22726
22892
|
var keySystemAccessPromises = this.keySystemAccessPromises[keySystem];
|
@@ -22732,23 +22898,23 @@
|
|
22732
22898
|
keySystemAccess: keySystemAccess
|
22733
22899
|
};
|
22734
22900
|
keySystemAccess.catch(function (error) {
|
22735
|
-
|
22901
|
+
_this3.log("Failed to obtain access to key-system \"" + keySystem + "\": " + error);
|
22736
22902
|
});
|
22737
22903
|
return keySystemAccess.then(function (mediaKeySystemAccess) {
|
22738
|
-
|
22739
|
-
var certificateRequest =
|
22740
|
-
|
22904
|
+
_this3.log("Access for key-system \"" + mediaKeySystemAccess.keySystem + "\" obtained");
|
22905
|
+
var certificateRequest = _this3.fetchServerCertificate(keySystem);
|
22906
|
+
_this3.log("Create media-keys for \"" + keySystem + "\"");
|
22741
22907
|
_keySystemAccessPromises.mediaKeys = mediaKeySystemAccess.createMediaKeys().then(function (mediaKeys) {
|
22742
|
-
|
22908
|
+
_this3.log("Media-keys created for \"" + keySystem + "\"");
|
22743
22909
|
return certificateRequest.then(function (certificate) {
|
22744
22910
|
if (certificate) {
|
22745
|
-
return
|
22911
|
+
return _this3.setMediaKeysServerCertificate(mediaKeys, keySystem, certificate);
|
22746
22912
|
}
|
22747
22913
|
return mediaKeys;
|
22748
22914
|
});
|
22749
22915
|
});
|
22750
22916
|
_keySystemAccessPromises.mediaKeys.catch(function (error) {
|
22751
|
-
|
22917
|
+
_this3.error("Failed to create media-keys for \"" + keySystem + "\"}: " + error);
|
22752
22918
|
});
|
22753
22919
|
return _keySystemAccessPromises.mediaKeys;
|
22754
22920
|
});
|
@@ -22757,10 +22923,10 @@
|
|
22757
22923
|
return keySystemAccessPromises.mediaKeys;
|
22758
22924
|
});
|
22759
22925
|
};
|
22760
|
-
_proto.createMediaKeySessionContext = function createMediaKeySessionContext(
|
22761
|
-
var decryptdata =
|
22762
|
-
keySystem =
|
22763
|
-
mediaKeys =
|
22926
|
+
_proto.createMediaKeySessionContext = function createMediaKeySessionContext(_ref2) {
|
22927
|
+
var decryptdata = _ref2.decryptdata,
|
22928
|
+
keySystem = _ref2.keySystem,
|
22929
|
+
mediaKeys = _ref2.mediaKeys;
|
22764
22930
|
this.log("Creating key-system session \"" + keySystem + "\" keyId: " + Hex.hexDump(decryptdata.keyId || []));
|
22765
22931
|
var mediaKeysSession = mediaKeys.createSession();
|
22766
22932
|
var mediaKeySessionContext = {
|
@@ -22809,14 +22975,14 @@
|
|
22809
22975
|
return this.keyFormatPromise;
|
22810
22976
|
};
|
22811
22977
|
_proto.getKeyFormatPromise = function getKeyFormatPromise(keyFormats) {
|
22812
|
-
var
|
22978
|
+
var _this4 = this;
|
22813
22979
|
return new Promise(function (resolve, reject) {
|
22814
|
-
var keySystemsInConfig = getKeySystemsForConfig(
|
22980
|
+
var keySystemsInConfig = getKeySystemsForConfig(_this4.config);
|
22815
22981
|
var keySystemsToAttempt = keyFormats.map(keySystemFormatToKeySystemDomain).filter(function (value) {
|
22816
22982
|
return !!value && keySystemsInConfig.indexOf(value) !== -1;
|
22817
22983
|
});
|
22818
|
-
return
|
22819
|
-
var keySystem =
|
22984
|
+
return _this4.getKeySystemSelectionPromise(keySystemsToAttempt).then(function (_ref3) {
|
22985
|
+
var keySystem = _ref3.keySystem;
|
22820
22986
|
var keySystemFormat = keySystemDomainToKeySystemFormat(keySystem);
|
22821
22987
|
if (keySystemFormat) {
|
22822
22988
|
resolve(keySystemFormat);
|
@@ -22827,31 +22993,31 @@
|
|
22827
22993
|
});
|
22828
22994
|
};
|
22829
22995
|
_proto.loadKey = function loadKey(data) {
|
22830
|
-
var
|
22996
|
+
var _this5 = this;
|
22831
22997
|
var decryptdata = data.keyInfo.decryptdata;
|
22832
22998
|
var keyId = this.getKeyIdString(decryptdata);
|
22833
22999
|
var keyDetails = "(keyId: " + keyId + " format: \"" + decryptdata.keyFormat + "\" method: " + decryptdata.method + " uri: " + decryptdata.uri + ")";
|
22834
23000
|
this.log("Starting session for key " + keyDetails);
|
22835
23001
|
var keySessionContextPromise = this.keyIdToKeySessionPromise[keyId];
|
22836
23002
|
if (!keySessionContextPromise) {
|
22837
|
-
keySessionContextPromise = this.keyIdToKeySessionPromise[keyId] = this.getKeySystemForKeyPromise(decryptdata).then(function (
|
22838
|
-
var keySystem =
|
22839
|
-
mediaKeys =
|
22840
|
-
|
22841
|
-
|
22842
|
-
return
|
22843
|
-
|
22844
|
-
var keySessionContext =
|
23003
|
+
keySessionContextPromise = this.keyIdToKeySessionPromise[keyId] = this.getKeySystemForKeyPromise(decryptdata).then(function (_ref4) {
|
23004
|
+
var keySystem = _ref4.keySystem,
|
23005
|
+
mediaKeys = _ref4.mediaKeys;
|
23006
|
+
_this5.throwIfDestroyed();
|
23007
|
+
_this5.log("Handle encrypted media sn: " + data.frag.sn + " " + data.frag.type + ": " + data.frag.level + " using key " + keyDetails);
|
23008
|
+
return _this5.attemptSetMediaKeys(keySystem, mediaKeys).then(function () {
|
23009
|
+
_this5.throwIfDestroyed();
|
23010
|
+
var keySessionContext = _this5.createMediaKeySessionContext({
|
22845
23011
|
keySystem: keySystem,
|
22846
23012
|
mediaKeys: mediaKeys,
|
22847
23013
|
decryptdata: decryptdata
|
22848
23014
|
});
|
22849
23015
|
var scheme = 'cenc';
|
22850
|
-
return
|
23016
|
+
return _this5.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh, 'playlist-key');
|
22851
23017
|
});
|
22852
23018
|
});
|
22853
23019
|
keySessionContextPromise.catch(function (error) {
|
22854
|
-
return
|
23020
|
+
return _this5.handleError(error);
|
22855
23021
|
});
|
22856
23022
|
}
|
22857
23023
|
return keySessionContextPromise;
|
@@ -22902,121 +23068,6 @@
|
|
22902
23068
|
}
|
22903
23069
|
return this.attemptKeySystemAccess(keySystemsToAttempt);
|
22904
23070
|
};
|
22905
|
-
_proto._onMediaEncrypted = function _onMediaEncrypted(event) {
|
22906
|
-
var _this5 = this;
|
22907
|
-
var initDataType = event.initDataType,
|
22908
|
-
initData = event.initData;
|
22909
|
-
var logMessage = "\"" + event.type + "\" event: init data type: \"" + initDataType + "\"";
|
22910
|
-
this.debug(logMessage);
|
22911
|
-
|
22912
|
-
// Ignore event when initData is null
|
22913
|
-
if (initData === null) {
|
22914
|
-
return;
|
22915
|
-
}
|
22916
|
-
var keyId;
|
22917
|
-
var keySystemDomain;
|
22918
|
-
if (initDataType === 'sinf' && this.config.drmSystems[KeySystems.FAIRPLAY]) {
|
22919
|
-
// Match sinf keyId to playlist skd://keyId=
|
22920
|
-
var json = bin2str(new Uint8Array(initData));
|
22921
|
-
try {
|
22922
|
-
var sinf = base64Decode(JSON.parse(json).sinf);
|
22923
|
-
var tenc = parseSinf(new Uint8Array(sinf));
|
22924
|
-
if (!tenc) {
|
22925
|
-
throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");
|
22926
|
-
}
|
22927
|
-
keyId = tenc.subarray(8, 24);
|
22928
|
-
keySystemDomain = KeySystems.FAIRPLAY;
|
22929
|
-
} catch (error) {
|
22930
|
-
this.warn(logMessage + " Failed to parse sinf: " + error);
|
22931
|
-
return;
|
22932
|
-
}
|
22933
|
-
} else {
|
22934
|
-
// Support Widevine clear-lead key-session creation (otherwise depend on playlist keys)
|
22935
|
-
var psshResults = parseMultiPssh(initData);
|
22936
|
-
var psshInfo = psshResults.filter(function (pssh) {
|
22937
|
-
return pssh.systemId === KeySystemIds.WIDEVINE;
|
22938
|
-
})[0];
|
22939
|
-
if (!psshInfo) {
|
22940
|
-
if (psshResults.length === 0 || psshResults.some(function (pssh) {
|
22941
|
-
return !pssh.systemId;
|
22942
|
-
})) {
|
22943
|
-
this.warn(logMessage + " contains incomplete or invalid pssh data");
|
22944
|
-
} else {
|
22945
|
-
this.log("ignoring " + logMessage + " for " + psshResults.map(function (pssh) {
|
22946
|
-
return keySystemIdToKeySystemDomain(pssh.systemId);
|
22947
|
-
}).join(',') + " pssh data in favor of playlist keys");
|
22948
|
-
}
|
22949
|
-
return;
|
22950
|
-
}
|
22951
|
-
keySystemDomain = keySystemIdToKeySystemDomain(psshInfo.systemId);
|
22952
|
-
if (psshInfo.version === 0 && psshInfo.data) {
|
22953
|
-
var offset = psshInfo.data.length - 22;
|
22954
|
-
keyId = psshInfo.data.subarray(offset, offset + 16);
|
22955
|
-
}
|
22956
|
-
}
|
22957
|
-
if (!keySystemDomain || !keyId) {
|
22958
|
-
return;
|
22959
|
-
}
|
22960
|
-
var keyIdHex = Hex.hexDump(keyId);
|
22961
|
-
var keyIdToKeySessionPromise = this.keyIdToKeySessionPromise,
|
22962
|
-
mediaKeySessions = this.mediaKeySessions;
|
22963
|
-
var keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex];
|
22964
|
-
var _loop = function _loop() {
|
22965
|
-
// Match playlist key
|
22966
|
-
var keyContext = mediaKeySessions[i];
|
22967
|
-
var decryptdata = keyContext.decryptdata;
|
22968
|
-
if (!decryptdata.keyId) {
|
22969
|
-
return 0; // continue
|
22970
|
-
}
|
22971
|
-
var oldKeyIdHex = Hex.hexDump(decryptdata.keyId);
|
22972
|
-
if (keyIdHex === oldKeyIdHex || decryptdata.uri.replace(/-/g, '').indexOf(keyIdHex) !== -1) {
|
22973
|
-
keySessionContextPromise = keyIdToKeySessionPromise[oldKeyIdHex];
|
22974
|
-
if (decryptdata.pssh) {
|
22975
|
-
return 1; // break
|
22976
|
-
}
|
22977
|
-
delete keyIdToKeySessionPromise[oldKeyIdHex];
|
22978
|
-
decryptdata.pssh = new Uint8Array(initData);
|
22979
|
-
decryptdata.keyId = keyId;
|
22980
|
-
keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = keySessionContextPromise.then(function () {
|
22981
|
-
return _this5.generateRequestWithPreferredKeySession(keyContext, initDataType, initData, 'encrypted-event-key-match');
|
22982
|
-
});
|
22983
|
-
return 1; // break
|
22984
|
-
}
|
22985
|
-
},
|
22986
|
-
_ret;
|
22987
|
-
for (var i = 0; i < mediaKeySessions.length; i++) {
|
22988
|
-
_ret = _loop();
|
22989
|
-
if (_ret === 0) continue;
|
22990
|
-
if (_ret === 1) break;
|
22991
|
-
}
|
22992
|
-
if (!keySessionContextPromise) {
|
22993
|
-
// Clear-lead key (not encountered in playlist)
|
22994
|
-
keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = this.getKeySystemSelectionPromise([keySystemDomain]).then(function (_ref4) {
|
22995
|
-
var _keySystemToKeySystem;
|
22996
|
-
var keySystem = _ref4.keySystem,
|
22997
|
-
mediaKeys = _ref4.mediaKeys;
|
22998
|
-
_this5.throwIfDestroyed();
|
22999
|
-
var decryptdata = new LevelKey('ISO-23001-7', keyIdHex, (_keySystemToKeySystem = keySystemDomainToKeySystemFormat(keySystem)) != null ? _keySystemToKeySystem : '');
|
23000
|
-
decryptdata.pssh = new Uint8Array(initData);
|
23001
|
-
decryptdata.keyId = keyId;
|
23002
|
-
return _this5.attemptSetMediaKeys(keySystem, mediaKeys).then(function () {
|
23003
|
-
_this5.throwIfDestroyed();
|
23004
|
-
var keySessionContext = _this5.createMediaKeySessionContext({
|
23005
|
-
decryptdata: decryptdata,
|
23006
|
-
keySystem: keySystem,
|
23007
|
-
mediaKeys: mediaKeys
|
23008
|
-
});
|
23009
|
-
return _this5.generateRequestWithPreferredKeySession(keySessionContext, initDataType, initData, 'encrypted-event-no-match');
|
23010
|
-
});
|
23011
|
-
});
|
23012
|
-
}
|
23013
|
-
keySessionContextPromise.catch(function (error) {
|
23014
|
-
return _this5.handleError(error);
|
23015
|
-
});
|
23016
|
-
};
|
23017
|
-
_proto._onWaitingForKey = function _onWaitingForKey(event) {
|
23018
|
-
this.log("\"" + event.type + "\" event");
|
23019
|
-
};
|
23020
23071
|
_proto.attemptSetMediaKeys = function attemptSetMediaKeys(keySystem, mediaKeys) {
|
23021
23072
|
var _this6 = this;
|
23022
23073
|
var queue = this.setMediaKeysQueue.slice();
|
@@ -23319,7 +23370,7 @@
|
|
23319
23370
|
var _this12 = this;
|
23320
23371
|
var keyLoadPolicy = this.config.keyLoadPolicy.default;
|
23321
23372
|
return new Promise(function (resolve, reject) {
|
23322
|
-
var url = _this12.
|
23373
|
+
var url = _this12.getLicenseServerUrlOrThrow(keySessionContext.keySystem);
|
23323
23374
|
_this12.log("Sending license request to URL: " + url);
|
23324
23375
|
var xhr = new XMLHttpRequest();
|
23325
23376
|
xhr.responseType = 'arraybuffer';
|
@@ -23388,6 +23439,8 @@
|
|
23388
23439
|
|
23389
23440
|
// keep reference of media
|
23390
23441
|
this.media = media;
|
23442
|
+
media.removeEventListener('encrypted', this.onMediaEncrypted);
|
23443
|
+
media.removeEventListener('waitingforkey', this.onWaitingForKey);
|
23391
23444
|
media.addEventListener('encrypted', this.onMediaEncrypted);
|
23392
23445
|
media.addEventListener('waitingforkey', this.onWaitingForKey);
|
23393
23446
|
};
|
@@ -26807,7 +26860,7 @@
|
|
26807
26860
|
};
|
26808
26861
|
_proto.load = function load(frag) {
|
26809
26862
|
var _this2 = this;
|
26810
|
-
if (!frag.decryptdata && frag.encrypted && this.emeController) {
|
26863
|
+
if (!frag.decryptdata && frag.encrypted && this.emeController && this.config.emeEnabled) {
|
26811
26864
|
// Multiple keys, but none selected, resolve in eme-controller
|
26812
26865
|
return this.emeController.selectKeySystemFormat(frag).then(function (keySystemFormat) {
|
26813
26866
|
return _this2.loadInternal(frag, keySystemFormat);
|
@@ -29322,7 +29375,7 @@
|
|
29322
29375
|
* Get the video-dev/hls.js package version.
|
29323
29376
|
*/
|
29324
29377
|
function get() {
|
29325
|
-
return "1.5.
|
29378
|
+
return "1.5.20";
|
29326
29379
|
}
|
29327
29380
|
}, {
|
29328
29381
|
key: "Events",
|