Skip to content

Commit

Permalink
refactor: 💡 (xgplayer-hls) DRM支持更多的identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
gemxx committed May 16, 2024
1 parent 0df22b1 commit f7845e9
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions packages/xgplayer-hls/src/hls/manifest-loader/parser/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@ const MediaType = {
}

// #EXT-X-KEY KEYFORMAT values
// urn:uuid: https://dashif.org/identifiers/content_protection/
const KeySystems = {
CLEAR_KEY: 'org.w3.clearkey',
FAIRPLAY: 'com.apple.streamingkeydelivery',
WIDEVINE: 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed',
PLAYREADY: 'com.microsoft.playready'
FAIRPLAY: ['urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2', 'com.apple.streamingkeydelivery'],
WIDEVINE: ['urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed', 'com.widevine.alpha', 'com.widevine'],
PLAYREADY: ['urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95', 'com.microsoft.playready']
}

function flatArray (arr) {
let ret = []

for (let i = 0; i < arr.length; i++) {
if (Array.isArray(arr[i])) {
ret = ret.concat(flatArray(arr[i]))
} else {
ret.push(arr[i])
}
}

return ret
}

export class MediaStream {
Expand Down Expand Up @@ -185,12 +200,12 @@ export class MediaSegmentKey {

isValidKeySystem () {
const isKeyFormatValid =
[
KeySystems.CLEAR_KEY,
KeySystems.FAIRPLAY,
KeySystems.WIDEVINE,
KeySystems.PLAYREADY
].indexOf(this.keyFormat) > -1
flatArray([
KeySystems.CLEAR_KEY,
KeySystems.FAIRPLAY,
KeySystems.WIDEVINE,
KeySystems.PLAYREADY
]).indexOf(this.keyFormat) > -1
if (!isKeyFormatValid) {
return false
}
Expand Down

0 comments on commit f7845e9

Please sign in to comment.