diff options
-rw-r--r-- | content/renderer/renderer_blink_platform_impl.cc | 5 | ||||
-rw-r--r-- | media/base/key_systems.cc | 25 | ||||
-rw-r--r-- | media/base/key_systems.h | 9 | ||||
-rw-r--r-- | media/base/key_systems_unittest.cc | 18 |
4 files changed, 49 insertions, 8 deletions
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc index d0c1d88..974e60b 100644 --- a/content/renderer/renderer_blink_platform_impl.cc +++ b/content/renderer/renderer_blink_platform_impl.cc @@ -419,7 +419,7 @@ RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType( std::vector<std::string> strict_codecs; net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, true); - if (!media::IsSupportedKeySystemWithMediaMimeType( + if (!media::PrefixedIsSupportedKeySystemWithMediaMimeType( mime_type_ascii, strict_codecs, key_system_ascii)) { return IsNotSupported; } @@ -458,6 +458,9 @@ bool RendererBlinkPlatformImpl::MimeRegistry::supportsMediaSourceMIMEType( mime_type_ascii, parsed_codec_ids); } +// TODO(jrummell): This method is only used by unprefixed EME, and should not +// be called when http://crbug.com/385874 is fixed. Remove this method once +// that happens. bool RendererBlinkPlatformImpl::MimeRegistry::supportsEncryptedMediaMIMEType( const WebString& key_system, const WebString& mime_type, diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc index f97660c..d4f4387 100644 --- a/media/base/key_systems.cc +++ b/media/base/key_systems.cc @@ -120,7 +120,8 @@ class KeySystems { bool IsSupportedKeySystemWithMediaMimeType( const std::string& mime_type, const std::vector<std::string>& codecs, - const std::string& key_system); + const std::string& key_system, + bool reportToUma); std::string GetKeySystemNameForUMA(const std::string& key_system) const; @@ -475,7 +476,8 @@ bool KeySystems::IsSupportedKeySystemWithInitDataType( bool KeySystems::IsSupportedKeySystemWithMediaMimeType( const std::string& mime_type, const std::vector<std::string>& codecs, - const std::string& key_system) { + const std::string& key_system, + bool reportToUma) { DCHECK(thread_checker_.CalledOnValidThread()); // If |key_system| is a parent key system, use its concrete child. @@ -483,7 +485,8 @@ bool KeySystems::IsSupportedKeySystemWithMediaMimeType( bool has_type = !mime_type.empty(); - key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); + if (reportToUma) + key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); // Check key system support. KeySystemPropertiesMap::const_iterator key_system_iter = @@ -491,7 +494,8 @@ bool KeySystems::IsSupportedKeySystemWithMediaMimeType( if (key_system_iter == concrete_key_system_map_.end()) return false; - key_systems_support_uma_.ReportKeySystemSupport(key_system, false); + if (reportToUma) + key_systems_support_uma_.ReportKeySystemSupport(key_system, false); if (!has_type) { DCHECK(codecs.empty()); @@ -510,7 +514,8 @@ bool KeySystems::IsSupportedKeySystemWithMediaMimeType( return false; } - key_systems_support_uma_.ReportKeySystemSupport(key_system, true); + if (reportToUma) + key_systems_support_uma_.ReportKeySystemSupport(key_system, true); return true; } @@ -621,7 +626,15 @@ bool IsSupportedKeySystemWithMediaMimeType( const std::vector<std::string>& codecs, const std::string& key_system) { return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( - mime_type, codecs, key_system); + mime_type, codecs, key_system, false); +} + +bool PrefixedIsSupportedKeySystemWithMediaMimeType( + const std::string& mime_type, + const std::vector<std::string>& codecs, + const std::string& key_system) { + return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( + mime_type, codecs, key_system, true); } std::string GetKeySystemNameForUMA(const std::string& key_system) { diff --git a/media/base/key_systems.h b/media/base/key_systems.h index 4eea042..d761abf 100644 --- a/media/base/key_systems.h +++ b/media/base/key_systems.h @@ -52,12 +52,19 @@ MEDIA_EXPORT bool IsSupportedKeySystemWithInitDataType( // systems. MEDIA_EXPORT bool IsConcreteSupportedKeySystem(const std::string& key_system); -// Returns whether |key_sytem| supports the specified media type and codec(s). +// Returns whether |key_system| supports the specified media type and codec(s). MEDIA_EXPORT bool IsSupportedKeySystemWithMediaMimeType( const std::string& mime_type, const std::vector<std::string>& codecs, const std::string& key_system); +// Returns whether |key_system| supports the specified media type and codec(s). +// To be used with prefixed EME only as it generates UMAs based on the query. +MEDIA_EXPORT bool PrefixedIsSupportedKeySystemWithMediaMimeType( + const std::string& mime_type, + const std::vector<std::string>& codecs, + const std::string& key_system); + // Returns a name for |key_system| suitable to UMA logging. MEDIA_EXPORT std::string GetKeySystemNameForUMA(const std::string& key_system); diff --git a/media/base/key_systems_unittest.cc b/media/base/key_systems_unittest.cc index afd9dc0..07bc5ec 100644 --- a/media/base/key_systems_unittest.cc +++ b/media/base/key_systems_unittest.cc @@ -718,4 +718,22 @@ TEST_F(KeySystemsTest, KeySystemsUpdate) { kVideoWebM, no_codecs(), kExternal)); } +TEST_F(KeySystemsTest, PrefixedKeySystemsUpdate) { + EXPECT_TRUE(IsConcreteSupportedKeySystem(kUsesAes)); + EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( + kVideoWebM, no_codecs(), kUsesAes)); + EXPECT_TRUE(IsConcreteSupportedKeySystem(kExternal)); + EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( + kVideoWebM, no_codecs(), kExternal)); + + UpdateClientKeySystems(); + + EXPECT_TRUE(IsConcreteSupportedKeySystem(kUsesAes)); + EXPECT_TRUE(PrefixedIsSupportedKeySystemWithMediaMimeType( + kVideoWebM, no_codecs(), kUsesAes)); + EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternal)); + EXPECT_FALSE(PrefixedIsSupportedKeySystemWithMediaMimeType( + kVideoWebM, no_codecs(), kExternal)); +} + } // namespace media |