mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
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
This commit is contained in:
committed by
Gerrit Code Review
parent
18a843eef7
commit
eb660e89c6
@@ -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
|
||||
*/
|
||||
|
||||
|
||||
@@ -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.'
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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.'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user