From eb660e89c68db1cb7224dcfdde2f75c8cc19bb26 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Fri, 13 Mar 2015 14:43:56 -0700 Subject: [PATCH] Update EME polyfill to the latest draft spec. Fixes the session type strings for persistent sessions. Adds a comment about the key statuses we deliberately ignore. Change-Id: I698bc91e46b863cc8cccd0e7509c503d1410d814 --- externs/mediakeys.js | 2 +- lib/media/eme_manager.js | 1 + lib/polyfill/patchedmediakeys_nop.js | 4 ++-- lib/polyfill/patchedmediakeys_v01b.js | 20 ++++++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/externs/mediakeys.js b/externs/mediakeys.js index f763bdcae..a3b3da70f 100644 --- a/externs/mediakeys.js +++ b/externs/mediakeys.js @@ -14,7 +14,7 @@ * limitations under the License. * * @fileoverview MediaKey externs. - * Based on {@link http://goo.gl/5gifok EME draft 09 February 2015}. + * Based on {@link http://goo.gl/blgtZZ EME draft 12 March 2015}. * @externs */ diff --git a/lib/media/eme_manager.js b/lib/media/eme_manager.js index eba1cc68e..440f5fdab 100644 --- a/lib/media/eme_manager.js +++ b/lib/media/eme_manager.js @@ -500,6 +500,7 @@ shaka.media.EmeManager.prototype.requestLicense_ = * @const */ shaka.media.EmeManager.KEY_STATUS_ERROR_MAP_ = { + // usable, output-downscaled, and status-pending do not result in errors. 'output-not-allowed': 'The required output protection is not available.', 'expired': 'A required key has expired and the content cannot be decrypted.', 'internal-error': 'An unknown error has occurred in the CDM.' diff --git a/lib/polyfill/patchedmediakeys_nop.js b/lib/polyfill/patchedmediakeys_nop.js index 67351c069..7ed01ee27 100644 --- a/lib/polyfill/patchedmediakeys_nop.js +++ b/lib/polyfill/patchedmediakeys_nop.js @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * @fileoverview A polyfill to stub out {@link http://goo.gl/5gifok EME draft - * 09 February 2015} on browsers without EME. All methods will fail. + * @fileoverview A polyfill to stub out {@link http://goo.gl/blgtZZ EME draft + * 12 March 2015} on browsers without EME. All methods will fail. * * @see http://enwp.org/polyfill */ diff --git a/lib/polyfill/patchedmediakeys_v01b.js b/lib/polyfill/patchedmediakeys_v01b.js index 2783d6409..4cb3672fa 100644 --- a/lib/polyfill/patchedmediakeys_v01b.js +++ b/lib/polyfill/patchedmediakeys_v01b.js @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * @fileoverview A polyfill to implement {@link http://goo.gl/5gifok EME draft - * 09 February 2015} on top of {@link http://goo.gl/FSpoAo EME v0.1b}. + * @fileoverview A polyfill to implement {@link http://goo.gl/blgtZZ EME draft + * 12 March 2015} on top of {@link http://goo.gl/FSpoAo EME v0.1b}. * * @see http://enwp.org/polyfill */ @@ -326,7 +326,11 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeys.prototype.createSession = shaka.log.debug('v01b.MediaKeys.createSession'); var sessionType = opt_sessionType || 'temporary'; - if (sessionType != 'temporary' && sessionType != 'persistent') { + // TODO: Consider adding support for persistent-release once Chrome has + // implemented it natively. http://crbug.com/448888 + // This is a non-issue if we've deprecated the polyfill by then, since + // prefixed EME is on its way out. + if (sessionType != 'temporary' && sessionType != 'persistent-license') { throw new TypeError('Session type ' + opt_sessionType + ' is unsupported on this platform.'); } @@ -621,7 +625,7 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeySession.prototype.generate_ = /** @type {Uint8Array} */ var mangledInitData; - if (this.type_ == 'persistent') { + if (this.type_ == 'persistent-license') { var Uint8ArrayUtils = shaka.util.Uint8ArrayUtils; if (!offlineSessionId) { // Persisting the initial license. @@ -767,12 +771,12 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeySession.prototype.generateRequest = shaka.polyfill.PatchedMediaKeys.v01b.MediaKeySession.prototype.load = function(sessionId) { shaka.log.debug('v01b.MediaKeySession.load'); - if (this.type_ == 'persistent') { + if (this.type_ == 'persistent-license') { var nextGeneratePromise = new shaka.util.PublicPromise(); this.generate_(nextGeneratePromise, null, sessionId); return nextGeneratePromise; } else { - return Promise.reject(new Error('The session type is not "persistent".')); + return Promise.reject(new Error('Not a persistent session.')); } }; @@ -796,7 +800,7 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeySession.prototype.close = // This will remove a persistent session, but it's also the only way to // free CDM resources on v0.1b. - if (this.type_ != 'persistent') { + if (this.type_ != 'persistent-license') { // sessionId may reasonably be null if no key request has been generated // yet. Unprefixed EME will return a rejected promise in this case. // We will use the same error message that Chrome 41 uses in its EME @@ -819,7 +823,7 @@ shaka.polyfill.PatchedMediaKeys.v01b.MediaKeySession.prototype.remove = function() { shaka.log.debug('v01b.MediaKeySession.remove'); - if (this.type_ != 'persistent') { + if (this.type_ != 'persistent-license') { return Promise.reject(new Error('Not a persistent session.')); }