Skip to content

Commit

Permalink
Fix v01b EME polyfill expiration.
Browse files Browse the repository at this point in the history
Fix the definition of expiration to be consistent with the details in
w3c/encrypted-media#58 .  In particular, never use infinity.

This means using key status to check if a session is new, rather than
comparing the expiration time to NaN.

Change-Id: Ib1917a34d4dfd0fd29b1c578c6ce60fd996c2698
  • Loading branch information
joeyparrish committed May 22, 2015
1 parent 49e7858 commit 894295d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/polyfill/patchedmediakeys_v01b.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeys.prototype.onWebkitKeyMessage_ =
return;
}

var isNew = isNaN(session.expiration);
var isNew = session.keyStatuses.getStatus() == undefined;

var event2 = shaka.util.FakeEvent.create({
type: 'message',
Expand Down Expand Up @@ -556,10 +556,6 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeySession.prototype.ready =
function() {
shaka.log.debug('v01b.MediaKeySession.ready');

// There is no expiration info in v0.1b, but we want to signal, at least
// internally, that the session is no longer new. This allows us to set
// the messageType attribute of 'message' events.
this.expiration = Number.POSITIVE_INFINITY;
this.updateKeyStatus_('usable');

if (this.updatePromise_) {
Expand Down Expand Up @@ -908,6 +904,16 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeyStatusMap.prototype.setStatus =
};


/**
* An internal method used by the session to get key status.
* @return {string|undefined}
*/
shaka.polyfill.PatchedMediaKeys.v01b.MediaKeyStatusMap.prototype.getStatus =
function() {
return this.status_;
};


/**
* Array entry 0 is the key, 1 is the value.
* @return {Iterator.<Array.<!BufferSource|string>>}
Expand Down

0 comments on commit 894295d

Please sign in to comment.