Skip to content

Commit

Permalink
fix(DRM): Fix persistent licenses not working for online playback (#7457
Browse files Browse the repository at this point in the history
)

Fixes #7429
  • Loading branch information
avelad authored and joeyparrish committed Oct 21, 2024
1 parent fb44a92 commit 0b7ff0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
11 changes: 11 additions & 0 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,17 @@ shaka.media.DrmEngine = class {
return;
}
}
let duplicate = false;
this.storedPersistentSessions_.forEach((metadata, sessionId) => {
if (!duplicate &&
shaka.util.BufferUtils.equal(initData, metadata.initData)) {
duplicate = true;
}
});
if (duplicate) {
shaka.log.debug('Ignoring duplicate init data.');
return;
}
}

// If there are pre-existing sessions that have all been loaded
Expand Down
20 changes: 1 addition & 19 deletions test/media/drm_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,20 +1286,7 @@ describe('DrmEngine', () => {

await Util.shortDelay();

session3.on['message']({
target: session3,
message: new Uint8Array(0),
messageType: 'license-request'});

session3.keyStatuses.forEach.and.callFake((callback) => {
callback(keyId1, 'usable');
});

session3.on['keystatuseschange']({target: session3});

await Util.shortDelay();

expect(mockMediaKeys.createSession).toHaveBeenCalledTimes(3);
expect(mockMediaKeys.createSession).toHaveBeenCalledTimes(2);
expect(mockMediaKeys.createSession)
.toHaveBeenCalledWith('persistent-license');
expect(session1.load)
Expand All @@ -1309,11 +1296,6 @@ describe('DrmEngine', () => {
.toHaveBeenCalledWith('persistent-license');
expect(session2.load)
.toHaveBeenCalledWith('persistent-session-id-2');

expect(mockMediaKeys.createSession)
.toHaveBeenCalledWith('temporary');
expect(session3.generateRequest)
.toHaveBeenCalledWith('cenc', initData1);
});
}); // describe('attach')

Expand Down

0 comments on commit 0b7ff0c

Please sign in to comment.