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

Unified Diff: third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp

Issue 1911953003: EME: Correctly handle container-only contentType strings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
index fbeffbbd610019dfd1d6c4bb317d754e1ea229bb..9755602d3707b92b53f457a288af7708db543008 100644
--- a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
+++ b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
@@ -111,6 +111,12 @@ private:
// See http://crbug.com/482277
void checkVideoCapabilityRobustness() const;
+ // 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
+ // contentType string.
+ // TODO(jrummell): Remove once this is no longer allowed.
+ // See http://crbug.com/605661.
+ void checkNoContainerOnlyContentTypeStrings(const WebMediaKeySystemConfiguration&);
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.
+
Member<ScriptPromiseResolver> m_resolver;
const String m_keySystem;
WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations;
@@ -154,6 +160,8 @@ MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer(ScriptState* sc
void MediaKeySystemAccessInitializer::requestSucceeded(WebContentDecryptionModuleAccess* access)
{
+ checkNoContainerOnlyContentTypeStrings(access->getConfiguration());
+
m_resolver->resolve(new MediaKeySystemAccess(m_keySystem, adoptPtr(access)));
m_resolver.clear();
}
@@ -202,6 +210,46 @@ void MediaKeySystemAccessInitializer::checkVideoCapabilityRobustness() const
}
}
+void MediaKeySystemAccessInitializer::checkNoContainerOnlyContentTypeStrings(const WebMediaKeySystemConfiguration& config)
+{
+ // This is only checking for empty codecs in the selected configuration,
+ // 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.
+ // with other systems.
ddorwin 2016/04/25 22:58:51 s/systems/implementations/
jrummell 2016/04/26 21:23:56 Done.
+ bool emptyAudioCodecs = false;
ddorwin 2016/04/25 22:58:51 How about isAudioCodecsEmpty?
jrummell 2016/04/26 21:23:56 Done.
+ 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.
+ for (const auto& audio : config.audioCapabilities) {
+ if (audio.codecs.isEmpty()) {
+ 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
+ break;
+ }
+ }
+
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, emptyAudioCodecsHistogram,
+ new EnumerationHistogram("Media.EME.RequestMediaKeySystemAccess.HasEmptyAudioCodecs", 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.
+ emptyAudioCodecsHistogram.count(emptyAudioCodecs);
+ }
+
+ bool emptyVideoCodecs = false;
+ if (!config.videoCapabilities.isEmpty()) {
+ for (const auto& video : config.videoCapabilities) {
+ if (video.codecs.isEmpty()) {
+ emptyVideoCodecs = true;
+ break;
+ }
+ }
+
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, emptyVideoCodecsHistogram,
+ new EnumerationHistogram("Media.EME.RequestMediaKeySystemAccess.HasEmptyVideoCodecs", 2));
+ emptyVideoCodecsHistogram.count(emptyVideoCodecs);
+ }
+
+ if (emptyAudioCodecs || emptyVideoCodecs) {
+ m_resolver->getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel,
+ "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.
+ "supported in the future. Please specify the desired codec as part of the contentType."));
ddorwin 2016/04/25 22:58:51 "codec(s)"
jrummell 2016/04/26 21:23:56 Done.
+ }
+}
+
} // namespace
ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess(

Powered by Google App Engine
This is Rietveld 408576698