Skip to content

Commit

Permalink
Replace "+" and "/" with "-" and "_" when generating B64 representati…
Browse files Browse the repository at this point in the history
…on of KID to be compliant to EME spec (#4026)
  • Loading branch information
dsilhavy authored Aug 15, 2022
1 parent 91db0fa commit 46f331f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/streaming/protection/drm/KeySystemClearKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function KeySystemClearKey(config) {

if (!initData && cencContentProtection) {
const cencDefaultKid = cencDefaultKidToBase64Representation(cencContentProtection['cenc:default_KID']);
const data = {kids: [cencDefaultKid]};
const data = { kids: [cencDefaultKid] };
initData = new TextEncoder().encode(JSON.stringify(data));
}

Expand All @@ -97,7 +97,9 @@ function KeySystemClearKey(config) {
kid = btoa(kid.match(/\w{2}/g).map((a) => {
return String.fromCharCode(parseInt(a, 16));
}).join(''));
return kid.replace(/=/g, '');
return kid.replace(/=/g, '')
.replace(/\//g, '_')
.replace(/\+/g, '-');
} catch (e) {
return null;
}
Expand Down

0 comments on commit 46f331f

Please sign in to comment.