From 0aad1cf1d9abf2192d7307e0062d6dfed462ab60 Mon Sep 17 00:00:00 2001 From: gemstone Date: Thu, 16 May 2024 22:40:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20(xgplayer-hls)=20DRM?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E5=A4=9A=E7=9A=84identifiers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/hls/manifest-loader/parser/model.js | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/xgplayer-hls/src/hls/manifest-loader/parser/model.js b/packages/xgplayer-hls/src/hls/manifest-loader/parser/model.js index b70424b8..11569293 100644 --- a/packages/xgplayer-hls/src/hls/manifest-loader/parser/model.js +++ b/packages/xgplayer-hls/src/hls/manifest-loader/parser/model.js @@ -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 { @@ -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 }