diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index 25fa3f2dec..6ec5971e56 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -750,6 +750,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 diff --git a/test/media/drm_engine_unit.js b/test/media/drm_engine_unit.js index 9ea2ce18fc..31abc7b3a6 100644 --- a/test/media/drm_engine_unit.js +++ b/test/media/drm_engine_unit.js @@ -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) @@ -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')