Skip to content

Commit

Permalink
Handle expired key status correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalch committed Oct 21, 2022
1 parent 7c1346c commit bae6f65
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/controller/eme-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,16 @@ class EMEController implements ComponentAPI {

private renewKeySession(mediaKeySessionContext: MediaKeySessionContext) {
const decryptdata = mediaKeySessionContext.decryptdata;
const keySessionContext = this.createMediaKeySessionContext(
mediaKeySessionContext
);
this.keyUriToKeySessionPromise[decryptdata.uri] =
this.generateRequestWithPreferredKeySession(
mediaKeySessionContext,
keySessionContext,
'cenc',
decryptdata.pssh
);
this.removeSession(mediaKeySessionContext);
}

private handleParsedKeyResponse(
Expand Down Expand Up @@ -1043,6 +1047,7 @@ class EMEController implements ComponentAPI {
LevelKey.clearKeyUriToKeyIdMap();

// Close all sessions and remove media keys from the video element.
const keySessionCount = mediaKeysList.length;
EMEController.CDMCleanupPromise = Promise.all(
mediaKeysList
.map((mediaKeySessionContext) =>
Expand All @@ -1057,7 +1062,7 @@ class EMEController implements ComponentAPI {
)
)
.then(() => {
if (mediaKeysList.length) {
if (keySessionCount) {
this.log('finished closing key sessions and clearing media keys');
mediaKeysList.length = 0;
}
Expand Down Expand Up @@ -1086,6 +1091,10 @@ class EMEController implements ComponentAPI {
mediaKeySessionContext.decryptdata =
mediaKeySessionContext.licenseXhr =
undefined!;
const index = this.mediaKeySessions.indexOf(mediaKeySessionContext);
if (index > -1) {
this.mediaKeySessions.splice(index, 1);
}
return mediaKeysSession
.remove()
.catch((error) => {
Expand Down
7 changes: 5 additions & 2 deletions src/loader/key-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ export default class KeyLoader implements ComponentAPI {
});
}

loadClear(loadingFrag: Fragment, encryptedFragments: Fragment[]): void | Promise<void> {
if (this.emeController && this.config.emeEnabled) {
loadClear(
loadingFrag: Fragment,
encryptedFragments: Fragment[]
): void | Promise<void> {
if (this.emeController && this.config.emeEnabled) {
// access key-system with nearest key on start (loaidng frag is unencrypted)
const { sn, cc } = loadingFrag;
for (let i = 0; i < encryptedFragments.length; i++) {
Expand Down

0 comments on commit bae6f65

Please sign in to comment.