| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ClearKeyPlayer responsible for playing media using Clear Key key system. | 5 // ClearKeyPlayer responsible for playing media using Clear Key key system. |
| 6 function ClearKeyPlayer(video, testConfig) { | 6 function ClearKeyPlayer(video, testConfig) { |
| 7 this.video = video; | 7 this.video = video; |
| 8 this.testConfig = testConfig; | 8 this.testConfig = testConfig; |
| 9 } | 9 } |
| 10 | 10 |
| 11 ClearKeyPlayer.prototype.init = function() { | 11 ClearKeyPlayer.prototype.init = function() { |
| 12 // Returns a promise. | 12 // Returns a promise. |
| 13 return PlayerUtils.initEMEPlayer(this); | 13 return PlayerUtils.initEMEPlayer(this); |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 ClearKeyPlayer.prototype.registerEventListeners = function() { | 16 ClearKeyPlayer.prototype.registerEventListeners = function() { |
| 17 // Returns a promise. | 17 // Returns a promise. |
| 18 return PlayerUtils.registerEMEEventListeners(this); | 18 return PlayerUtils.registerEMEEventListeners(this); |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 ClearKeyPlayer.prototype.onMessage = function(message) { | 21 ClearKeyPlayer.prototype.onMessage = function(message) { |
| 22 Utils.timeLog('MediaKeySession onMessage', message); | 22 Utils.timeLog('MediaKeySession onMessage', message); |
| 23 |
| 24 var mediaKeySession = message.target; |
| 23 var keyId = Utils.extractFirstLicenseKeyId(message.message); | 25 var keyId = Utils.extractFirstLicenseKeyId(message.message); |
| 24 var key = Utils.getDefaultKey(this.testConfig.forceInvalidResponse); | 26 var key = Utils.getDefaultKey(this.testConfig.forceInvalidResponse); |
| 25 var jwkSet = Utils.createJWKData(keyId, key); | 27 var jwkSet = Utils.createJWKData(keyId, key); |
| 28 |
| 29 // Number of milliseconds in 100 years, which is approximately |
| 30 // 100 * 365 * 24 * 60 * 60 * 1000. |
| 31 // See clear_key_cdm.cc where this value is set. |
| 32 const ECK_RENEWAL_EXPIRATION = 3153600000000; |
| 33 |
| 26 Utils.timeLog('Calling update: ' + String.fromCharCode.apply(null, jwkSet)); | 34 Utils.timeLog('Calling update: ' + String.fromCharCode.apply(null, jwkSet)); |
| 27 message.target.update(jwkSet).catch(function(error) { | 35 mediaKeySession.update(jwkSet).then(function() { |
| 36 // Check session expiration. |
| 37 // - For CLEARKEY, expiration is not set and is the default value NaN. |
| 38 // - For EXTERNAL_CLEARKEY_RENEWAL, expiration is set to |
| 39 // ECK_RENEWAL_EXPIRATION milliseconds after 01 January 1970 UTC. |
| 40 // - For other EXTERNAL_CLEARKEY variants, expiration is explicitly set to |
| 41 // NaN. |
| 42 var expiration = mediaKeySession.expiration; |
| 43 if (this.testConfig.keySystem == EXTERNAL_CLEARKEY_RENEWAL) { |
| 44 if (isNaN(expiration) || expiration != ECK_RENEWAL_EXPIRATION) { |
| 45 Utils.timeLog('Unexpected expiration: ', expiration); |
| 46 Utils.failTest(error, EME_UPDATE_FAILED); |
| 47 } |
| 48 } else { |
| 49 if (!isNaN(mediaKeySession.expiration)) { |
| 50 Utils.timeLog('Unexpected expiration: ', expiration); |
| 51 Utils.failTest(error, EME_UPDATE_FAILED); |
| 52 } |
| 53 } |
| 54 }).catch(function(error) { |
| 28 // Ignore the error if a crash is expected. This ensures that the decoder | 55 // Ignore the error if a crash is expected. This ensures that the decoder |
| 29 // actually detects and reports the error. | 56 // actually detects and reports the error. |
| 30 if (this.testConfig.keySystem != CRASH_TEST_KEYSYSTEM) { | 57 if (this.testConfig.keySystem != CRASH_TEST_KEYSYSTEM) { |
| 31 Utils.failTest(error, EME_UPDATE_FAILED); | 58 Utils.failTest(error, EME_UPDATE_FAILED); |
| 32 } | 59 } |
| 33 }); | 60 }); |
| 34 }; | 61 }; |
| OLD | NEW |