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

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

Issue 2349813002: EME: Update MediaKeySystemConfiguration defaults; require non-empty capabilities (Closed)
Patch Set: Created 4 years, 3 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }); 86 });
87 } 87 }
88 } catch (e) { 88 } catch (e) {
89 Utils.failTest(e); 89 Utils.failTest(e);
90 } 90 }
91 }); 91 });
92 92
93 this.registerDefaultEventListeners(player); 93 this.registerDefaultEventListeners(player);
94 player.video.receivedKeyMessage = false; 94 player.video.receivedKeyMessage = false;
95 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem); 95 Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem);
96 var config = {}; 96
97 var config = {
98 audioCapabilities: [],
99 videoCapabilities: [],
100 persistentState: 'optional',
101 sessionTypes: ['temporary'],
102 };
103
104 // requestMediaKeySystemAccess() requires at least one of 'audioCapabilities'
105 // or 'videoCapabilities' to be specified. It also requires only codecs
106 // specific to the capability, so unlike MSE cannot have both audio and
107 // video codecs in the contentType.
108 if (player.testConfig.mediaType == 'video/webm; codecs="vp8"' ||
109 player.testConfig.mediaType == 'video/webm; codecs="vp9"' ||
110 player.testConfig.mediaType == 'video/mp4; codecs="avc1.4D000C"') {
111 // Video only.
112 config.videoCapabilities = [{contentType: player.testConfig.mediaType}];
113 } else if (
114 player.testConfig.mediaType == 'audio/webm; codecs="vorbis"' ||
115 player.testConfig.mediaType == 'audio/webm; codecs="opus"' ||
116 player.testConfig.mediaType == 'audio/mp4; codecs="mp4a.40.2"') {
117 // Audio only.
118 config.audioCapabilities = [{contentType: player.testConfig.mediaType}];
119 } else if (
120 player.testConfig.mediaType == 'video/webm; codecs="vorbis, vp8"') {
121 // Both audio and video codecs specified.
122 config.audioCapabilities = [{contentType: 'audio/webm; codecs="vorbis"'}];
123 config.videoCapabilities = [{contentType: 'video/webm; codecs="vp8"'}];
124 } else if (player.testConfig.mediaType == 'video/webm; codecs="opus, vp9"') {
125 // Both audio and video codecs specified.
126 config.audioCapabilities = [{contentType: 'audio/webm; codecs="opus"'}];
127 config.videoCapabilities = [{contentType: 'video/webm; codecs="vp9"'}];
128 } else {
129 // Some tests (e.g. mse_different_containers.html) specify audio and
130 // video codecs seperately.
131 if (player.testConfig.videoFormat == 'ENCRYPTED_MP4' ||
132 player.testConfig.videoFormat == 'CLEAR_MP4') {
133 config.videoCapabilities =
134 [{contentType: 'video/mp4; codecs="avc1.4D000C"'}];
135 } else if (
136 player.testConfig.videoFormat == 'ENCRYPTED_WEBM' ||
137 player.testConfig.videoFormat == 'CLEAR_WEBM') {
138 config.videoCapabilities = [{contentType: 'video/webm; codecs="vp8"'}];
139 }
140 if (player.testConfig.audioFormat == 'ENCRYPTED_MP4' ||
141 player.testConfig.audioFormat == 'CLEAR_MP4') {
142 config.audioCapabilities =
143 [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}];
144 } else if (
145 player.testConfig.audioFormat == 'ENCRYPTED_WEBM' ||
146 player.testConfig.audioFormat == 'CLEAR_WEBM') {
147 config.audioCapabilities = [{contentType: 'audio/webm; codecs="vorbis"'}];
148 }
149 }
150
97 // The File IO test requires persistent state support. 151 // The File IO test requires persistent state support.
98 if (player.testConfig.keySystem == 152 if (player.testConfig.keySystem ==
99 'org.chromium.externalclearkey.fileiotest') { 153 'org.chromium.externalclearkey.fileiotest') {
100 config = {persistentState: "required"}; 154 config.persistentState = 'required';
155 } else if (player.testConfig.sessionToLoad) {
156 config.persistentState = 'required';
157 config.sessionTypes = ['temporary', 'persistent-license'];
101 } 158 }
102 if (player.testConfig.sessionToLoad) { 159
103 config = { 160 return navigator
104 persistentState: "required", 161 .requestMediaKeySystemAccess(player.testConfig.keySystem, [config])
105 sessionTypes: ["temporary", "persistent-license"]
106 };
107 }
108 return navigator.requestMediaKeySystemAccess(
109 player.testConfig.keySystem, [config])
110 .then(function(access) { return access.createMediaKeys(); }) 162 .then(function(access) { return access.createMediaKeys(); })
111 .then(function(mediaKeys) { 163 .then(function(mediaKeys) {
112 return player.video.setMediaKeys(mediaKeys); 164 return player.video.setMediaKeys(mediaKeys);
113 }) 165 })
114 .then(function(result) { return player; }) 166 .then(function(result) { return player; })
115 .catch(function(error) { Utils.failTest(error, NOTSUPPORTEDERROR); }); 167 .catch(function(error) { Utils.failTest(error, NOTSUPPORTEDERROR); });
116 }; 168 };
117 169
118 PlayerUtils.setVideoSource = function(player) { 170 PlayerUtils.setVideoSource = function(player) {
119 if (player.testConfig.useMSE) { 171 if (player.testConfig.useMSE) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 case OUTPUT_PROTECTION_TEST_KEYSYSTEM: 204 case OUTPUT_PROTECTION_TEST_KEYSYSTEM:
153 return UnitTestPlayer; 205 return UnitTestPlayer;
154 default: 206 default:
155 Utils.timeLog(keySystem + ' is not a known key system'); 207 Utils.timeLog(keySystem + ' is not a known key system');
156 return ClearKeyPlayer; 208 return ClearKeyPlayer;
157 } 209 }
158 } 210 }
159 var Player = getPlayerType(testConfig.keySystem); 211 var Player = getPlayerType(testConfig.keySystem);
160 return new Player(video, testConfig); 212 return new Player(video, testConfig);
161 }; 213 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698