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 #include "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" | 5 #include "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 } | 104 } |
105 | 105 |
106 private: | 106 private: |
107 // For widevine key system, generate warning and report to UMA if | 107 // For widevine key system, generate warning and report to UMA if |
108 // |m_supportedConfigurations| contains any video capability with empty | 108 // |m_supportedConfigurations| contains any video capability with empty |
109 // robustness string. | 109 // robustness string. |
110 // TODO(xhwang): Remove after we handle empty robustness correctly. | 110 // TODO(xhwang): Remove after we handle empty robustness correctly. |
111 // See http://crbug.com/482277 | 111 // See http://crbug.com/482277 |
112 void checkVideoCapabilityRobustness() const; | 112 void checkVideoCapabilityRobustness() const; |
113 | 113 |
114 // Generate warning and report to UMA if |config| contains a container-only | |
xhwang
2016/04/25 22:14:08
Can't find |config| in the declaration :)
ddorwin
2016/04/25 22:58:52
nit: I think it's clearer with "to" removed.
jrummell
2016/04/26 21:23:56
Done.
jrummell
2016/04/26 21:23:56
presubmit checks made me remove |config| as the pa
| |
115 // contentType string. | |
116 // TODO(jrummell): Remove once this is no longer allowed. | |
117 // See http://crbug.com/605661. | |
118 void checkNoContainerOnlyContentTypeStrings(const WebMediaKeySystemConfigura tion&); | |
xhwang
2016/04/25 22:14:08
The function name is a bit hard to read.. How abou
jrummell
2016/04/26 21:23:56
Done.
| |
119 | |
114 Member<ScriptPromiseResolver> m_resolver; | 120 Member<ScriptPromiseResolver> m_resolver; |
115 const String m_keySystem; | 121 const String m_keySystem; |
116 WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations; | 122 WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations; |
117 }; | 123 }; |
118 | 124 |
119 MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer(ScriptState* sc riptState, const String& keySystem, const HeapVector<MediaKeySystemConfiguration >& supportedConfigurations) | 125 MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer(ScriptState* sc riptState, const String& keySystem, const HeapVector<MediaKeySystemConfiguration >& supportedConfigurations) |
120 : m_resolver(ScriptPromiseResolver::create(scriptState)) | 126 : m_resolver(ScriptPromiseResolver::create(scriptState)) |
121 , m_keySystem(keySystem) | 127 , m_keySystem(keySystem) |
122 , m_supportedConfigurations(supportedConfigurations.size()) | 128 , m_supportedConfigurations(supportedConfigurations.size()) |
123 { | 129 { |
(...skipping 23 matching lines...) Expand all Loading... | |
147 // If |label| is not present, it will be a null string. | 153 // If |label| is not present, it will be a null string. |
148 webConfig.label = config.label(); | 154 webConfig.label = config.label(); |
149 m_supportedConfigurations[i] = webConfig; | 155 m_supportedConfigurations[i] = webConfig; |
150 } | 156 } |
151 | 157 |
152 checkVideoCapabilityRobustness(); | 158 checkVideoCapabilityRobustness(); |
153 } | 159 } |
154 | 160 |
155 void MediaKeySystemAccessInitializer::requestSucceeded(WebContentDecryptionModul eAccess* access) | 161 void MediaKeySystemAccessInitializer::requestSucceeded(WebContentDecryptionModul eAccess* access) |
156 { | 162 { |
163 checkNoContainerOnlyContentTypeStrings(access->getConfiguration()); | |
164 | |
157 m_resolver->resolve(new MediaKeySystemAccess(m_keySystem, adoptPtr(access))) ; | 165 m_resolver->resolve(new MediaKeySystemAccess(m_keySystem, adoptPtr(access))) ; |
158 m_resolver.clear(); | 166 m_resolver.clear(); |
159 } | 167 } |
160 | 168 |
161 void MediaKeySystemAccessInitializer::requestNotSupported(const WebString& error Message) | 169 void MediaKeySystemAccessInitializer::requestNotSupported(const WebString& error Message) |
162 { | 170 { |
163 m_resolver->reject(DOMException::create(NotSupportedError, errorMessage)); | 171 m_resolver->reject(DOMException::create(NotSupportedError, errorMessage)); |
164 m_resolver.clear(); | 172 m_resolver.clear(); |
165 } | 173 } |
166 | 174 |
(...skipping 28 matching lines...) Expand all Loading... | |
195 emptyRobustnessHistogram.count(hasEmptyRobustness); | 203 emptyRobustnessHistogram.count(hasEmptyRobustness); |
196 } | 204 } |
197 | 205 |
198 if (hasEmptyRobustness) { | 206 if (hasEmptyRobustness) { |
199 m_resolver->getExecutionContext()->addConsoleMessage(ConsoleMessage::cre ate(JSMessageSource, WarningMessageLevel, | 207 m_resolver->getExecutionContext()->addConsoleMessage(ConsoleMessage::cre ate(JSMessageSource, WarningMessageLevel, |
200 "It is recommended that a robustness level be specified. Not specify ing the robustness level could " | 208 "It is recommended that a robustness level be specified. Not specify ing the robustness level could " |
201 "result in unexpected behavior in the future, potentially including failure to play.")); | 209 "result in unexpected behavior in the future, potentially including failure to play.")); |
202 } | 210 } |
203 } | 211 } |
204 | 212 |
213 void MediaKeySystemAccessInitializer::checkNoContainerOnlyContentTypeStrings(con st WebMediaKeySystemConfiguration& config) | |
214 { | |
215 // This is only checking for empty codecs in the selected configuration, | |
216 // as users may pass container only contentType strings for compatibility | |
ddorwin
2016/04/25 22:58:51
s/users/apps/
jrummell
2016/04/26 21:23:56
Done.
| |
217 // with other systems. | |
ddorwin
2016/04/25 22:58:51
s/systems/implementations/
jrummell
2016/04/26 21:23:56
Done.
| |
218 bool emptyAudioCodecs = false; | |
ddorwin
2016/04/25 22:58:51
How about isAudioCodecsEmpty?
jrummell
2016/04/26 21:23:56
Done.
| |
219 if (!config.audioCapabilities.isEmpty()) { | |
xhwang
2016/04/25 22:14:08
The logic here is good.
Just to be clear, this ch
jrummell
2016/04/26 21:23:56
Added additional check to make it clearer.
| |
220 for (const auto& audio : config.audioCapabilities) { | |
221 if (audio.codecs.isEmpty()) { | |
222 emptyAudioCodecs = true; | |
ddorwin
2016/04/25 22:58:51
This will currently trigger if there is capabiliti
jrummell
2016/04/26 21:23:56
Changed to only track if all returned capabilities
| |
223 break; | |
224 } | |
225 } | |
226 | |
227 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, emptyAudioCodecsHi stogram, | |
228 new EnumerationHistogram("Media.EME.RequestMediaKeySystemAccess.HasE mptyAudioCodecs", 2)); | |
ddorwin
2016/04/25 22:58:51
We might want to rename this to something like Sel
jrummell
2016/04/26 21:23:56
Done.
| |
229 emptyAudioCodecsHistogram.count(emptyAudioCodecs); | |
230 } | |
231 | |
232 bool emptyVideoCodecs = false; | |
233 if (!config.videoCapabilities.isEmpty()) { | |
234 for (const auto& video : config.videoCapabilities) { | |
235 if (video.codecs.isEmpty()) { | |
236 emptyVideoCodecs = true; | |
237 break; | |
238 } | |
239 } | |
240 | |
241 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, emptyVideoCodecsHi stogram, | |
242 new EnumerationHistogram("Media.EME.RequestMediaKeySystemAccess.HasE mptyVideoCodecs", 2)); | |
243 emptyVideoCodecsHistogram.count(emptyVideoCodecs); | |
244 } | |
245 | |
246 if (emptyAudioCodecs || emptyVideoCodecs) { | |
247 m_resolver->getExecutionContext()->addConsoleMessage(ConsoleMessage::cre ate(JSMessageSource, WarningMessageLevel, | |
248 "Container only contentType strings that do not imply a specific set of codecs will not be " | |
ddorwin
2016/04/25 22:58:51
Since this is a deprecation message, we can be mor
jrummell
2016/04/26 21:23:56
Done.
| |
249 "supported in the future. Please specify the desired codec as part o f the contentType.")); | |
ddorwin
2016/04/25 22:58:51
"codec(s)"
jrummell
2016/04/26 21:23:56
Done.
| |
250 } | |
251 } | |
252 | |
205 } // namespace | 253 } // namespace |
206 | 254 |
207 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( | 255 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( |
208 ScriptState* scriptState, | 256 ScriptState* scriptState, |
209 Navigator& navigator, | 257 Navigator& navigator, |
210 const String& keySystem, | 258 const String& keySystem, |
211 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) | 259 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) |
212 { | 260 { |
213 WTF_LOG(Media, "NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemA ccess()"); | 261 WTF_LOG(Media, "NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemA ccess()"); |
214 | 262 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 // initialize the MediaKeySystemAccess object. | 305 // initialize the MediaKeySystemAccess object. |
258 MediaKeysController* controller = MediaKeysController::from(document->page() ); | 306 MediaKeysController* controller = MediaKeysController::from(document->page() ); |
259 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec utionContext); | 307 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec utionContext); |
260 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize r)); | 308 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize r)); |
261 | 309 |
262 // 8. Return promise. | 310 // 8. Return promise. |
263 return promise; | 311 return promise; |
264 } | 312 } |
265 | 313 |
266 } // namespace blink | 314 } // namespace blink |
OLD | NEW |