Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Side by Side Diff: media/test/data/eme_player_js/player_utils.js

Issue 854633003: Verify heartbeat messages have type 'license-renewal' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove heartbeat Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // The PlayerUtils provides utility functions to binding common media events 5 // The PlayerUtils provides utility functions to binding common media events
6 // to specific player functions. It also provides functions to load media source 6 // to specific player functions. It also provides functions to load media source
7 // base on test configurations. 7 // base on test configurations.
8 var PlayerUtils = new function() { 8 var PlayerUtils = new function() {
9 } 9 }
10 10
(...skipping 26 matching lines...) Expand all
37 }; 37 };
38 38
39 // Register the necessary event handlers needed when playing encrypted content 39 // Register the necessary event handlers needed when playing encrypted content
40 // using the unprefixed API. Returns a promise that resolves to the player. 40 // using the unprefixed API. Returns a promise that resolves to the player.
41 PlayerUtils.registerEMEEventListeners = function(player) { 41 PlayerUtils.registerEMEEventListeners = function(player) {
42 player.video.addEventListener('encrypted', function(message) { 42 player.video.addEventListener('encrypted', function(message) {
43 43
44 function addMediaKeySessionListeners(mediaKeySession) { 44 function addMediaKeySessionListeners(mediaKeySession) {
45 mediaKeySession.addEventListener('message', function(message) { 45 mediaKeySession.addEventListener('message', function(message) {
46 player.video.receivedKeyMessage = true; 46 player.video.receivedKeyMessage = true;
47 if (Utils.isHeartBeatMessage(message.message)) { 47 if (Utils.isRenewalMessage(message)) {
48 Utils.timeLog('MediaKeySession onMessage - heart beat', message); 48 Utils.timeLog('MediaKeySession onMessage - renewal', message);
49 player.video.receivedHeartbeat = true; 49 player.video.receivedRenewalMessage = true;
50 } else {
51 if (message.messageType != 'license-request') {
52 Utils.failTest('Unexpected message type "' + message.messageType +
53 '" received.',
54 KEY_ERROR);
55 }
50 } 56 }
51 player.onMessage(message); 57 player.onMessage(message);
52 }); 58 });
53 mediaKeySession.addEventListener('error', function(error) { 59 mediaKeySession.addEventListener('error', function(error) {
54 Utils.failTest(error, KEY_ERROR); 60 Utils.failTest(error, KEY_ERROR);
55 }); 61 });
56 } 62 }
57 63
58 try { 64 try {
59 if (player.testConfig.sessionToLoad) { 65 if (player.testConfig.sessionToLoad) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 }); 122 });
117 123
118 player.video.addEventListener('webkitkeyerror', function(error) { 124 player.video.addEventListener('webkitkeyerror', function(error) {
119 Utils.timeLog('onWebkitKeyError', error); 125 Utils.timeLog('onWebkitKeyError', error);
120 Utils.failTest(error, KEY_ERROR); 126 Utils.failTest(error, KEY_ERROR);
121 }); 127 });
122 128
123 player.video.addEventListener('webkitkeymessage', function(message) { 129 player.video.addEventListener('webkitkeymessage', function(message) {
124 Utils.timeLog('onWebkitKeyMessage', message); 130 Utils.timeLog('onWebkitKeyMessage', message);
125 message.target.receivedKeyMessage = true; 131 message.target.receivedKeyMessage = true;
126 if (Utils.isHeartBeatMessage(message.message)) { 132 if (Utils.isRenewalMessagePrefixed(message.message)) {
127 Utils.timeLog('onWebkitKeyMessage - heart beat', message); 133 Utils.timeLog('onWebkitKeyMessage - renewal', message);
128 message.target.receivedHeartbeat = true; 134 message.target.receivedRenewalMessage = true;
129 } 135 }
130 }); 136 });
131 137
132 // The prefixed API is all synchronous, so wrap the calls in a promise. 138 // The prefixed API is all synchronous, so wrap the calls in a promise.
133 return new Promise(function(resolve, reject) { 139 return new Promise(function(resolve, reject) {
134 PlayerUtils.registerDefaultEventListeners(player); 140 PlayerUtils.registerDefaultEventListeners(player);
135 resolve(player); 141 resolve(player);
136 }); 142 });
137 }; 143 };
138 144
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 default: 190 default:
185 Utils.timeLog(keySystem + ' is not a known key system'); 191 Utils.timeLog(keySystem + ' is not a known key system');
186 if (usePrefixedEME) 192 if (usePrefixedEME)
187 return PrefixedClearKeyPlayer; 193 return PrefixedClearKeyPlayer;
188 return ClearKeyPlayer; 194 return ClearKeyPlayer;
189 } 195 }
190 } 196 }
191 var Player = getPlayerType(testConfig.keySystem); 197 var Player = getPlayerType(testConfig.keySystem);
192 return new Player(video, testConfig); 198 return new Player(video, testConfig);
193 }; 199 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698