Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/crypto/key_systems.h" | 5 #include "content/renderer/media/crypto/key_systems.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "content/public/common/content_client.h" | 13 #include "content/public/common/content_client.h" |
| 14 #include "content/public/common/eme_codec.h" | 14 #include "content/public/common/eme_codec.h" |
| 15 #include "content/public/renderer/content_renderer_client.h" | 15 #include "content/public/renderer/content_renderer_client.h" |
| 16 #include "content/public/renderer/key_system_info.h" | 16 #include "content/public/renderer/key_system_info.h" |
| 17 #include "content/public/renderer/render_thread.h" | |
| 17 #include "content/renderer/media/crypto/key_systems_support_uma.h" | 18 #include "content/renderer/media/crypto/key_systems_support_uma.h" |
| 18 | 19 |
| 19 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
| 21 #include "content/common/media/encrypted_media_messages_android.h" | |
| 20 #include "media/base/android/media_codec_bridge.h" | 22 #include "media/base/android/media_codec_bridge.h" |
| 21 #endif | 23 #endif |
| 22 | 24 |
| 23 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 25 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| 27 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 29 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 28 const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 30 const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| 29 const char kUnsupportedClearKeyKeySystem[] = "unsupported-org.w3.clearkey"; | 31 const char kUnsupportedClearKeyKeySystem[] = "unsupported-org.w3.clearkey"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 info.supported_codecs = EME_CODEC_WEBM_ALL; | 69 info.supported_codecs = EME_CODEC_WEBM_ALL; |
| 68 #if defined(USE_PROPRIETARY_CODECS) | 70 #if defined(USE_PROPRIETARY_CODECS) |
| 69 info.supported_codecs |= EME_CODEC_MP4_ALL; | 71 info.supported_codecs |= EME_CODEC_MP4_ALL; |
| 70 #endif // defined(USE_PROPRIETARY_CODECS) | 72 #endif // defined(USE_PROPRIETARY_CODECS) |
| 71 | 73 |
| 72 info.use_aes_decryptor = true; | 74 info.use_aes_decryptor = true; |
| 73 | 75 |
| 74 concrete_key_systems->push_back(info); | 76 concrete_key_systems->push_back(info); |
| 75 } | 77 } |
| 76 | 78 |
| 79 #if defined(OS_ANDROID) | |
| 80 static void AddAndroidWidevine( | |
| 81 std::vector<KeySystemInfo>* concrete_key_systems) { | |
| 82 static const char kKeySystemSuffixHrNonCompositing[] = ".hrnoncompositing"; | |
|
Tom Sepez
2014/04/28 18:21:52
nit: kinda wish this constant wasn't buried so dee
| |
| 83 SupportedKeySystemRequest request; | |
| 84 SupportedKeySystemResponse response; | |
| 85 | |
| 86 request.key_system = kWidevineKeySystem; | |
| 87 request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL; | |
| 88 content::RenderThread::Get()->Send( | |
| 89 new ViewHostMsg_GetSupportedKeySystems(request, &response)); | |
| 90 DCHECK(response.compositing_codecs & content::EME_CODEC_ALL) | |
| 91 << "unrecognized codec"; | |
| 92 DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL) | |
| 93 << "unrecognized codec"; | |
| 94 if (response.compositing_codecs != content::EME_CODEC_NONE) { | |
| 95 concrete_key_systems->push_back(KeySystemInfo::Build( | |
| 96 kWidevineKeySystem, | |
| 97 true, // has_parent | |
| 98 NULL, // suffix | |
| 99 static_cast<SupportedCodecs>(response.compositing_codecs))); | |
| 100 } | |
| 101 | |
| 102 if (response.non_compositing_codecs != content::EME_CODEC_NONE) { | |
| 103 concrete_key_systems->push_back(KeySystemInfo::Build( | |
| 104 kWidevineKeySystem, | |
| 105 false, // has_parent | |
| 106 kKeySystemSuffixHrNonCompositing, // suffix | |
| 107 static_cast<SupportedCodecs>(response.non_compositing_codecs))); | |
| 108 } | |
| 109 } | |
| 110 #endif | |
| 111 | |
| 77 class KeySystems { | 112 class KeySystems { |
| 78 public: | 113 public: |
| 79 static KeySystems& GetInstance(); | 114 static KeySystems& GetInstance(); |
| 80 | 115 |
| 81 bool IsConcreteSupportedKeySystem(const std::string& key_system); | 116 bool IsConcreteSupportedKeySystem(const std::string& key_system); |
| 82 | 117 |
| 83 bool IsSupportedKeySystemWithMediaMimeType( | 118 bool IsSupportedKeySystemWithMediaMimeType( |
| 84 const std::string& mime_type, | 119 const std::string& mime_type, |
| 85 const std::vector<std::string>& codecs, | 120 const std::vector<std::string>& codecs, |
| 86 const std::string& key_system); | 121 const std::string& key_system); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 container_codec_masks_[container_codec_mask.type] = | 207 container_codec_masks_[container_codec_mask.type] = |
| 173 container_codec_mask.mask; | 208 container_codec_mask.mask; |
| 174 } | 209 } |
| 175 for (size_t i = 0; i < arraysize(kCodecMasks); ++i) { | 210 for (size_t i = 0; i < arraysize(kCodecMasks); ++i) { |
| 176 const CodecMask& codec_mask = kCodecMasks[i]; | 211 const CodecMask& codec_mask = kCodecMasks[i]; |
| 177 DCHECK(codec_masks_.find(codec_mask.type) == codec_masks_.end()); | 212 DCHECK(codec_masks_.find(codec_mask.type) == codec_masks_.end()); |
| 178 codec_masks_[codec_mask.type] = codec_mask.mask; | 213 codec_masks_[codec_mask.type] = codec_mask.mask; |
| 179 } | 214 } |
| 180 | 215 |
| 181 std::vector<KeySystemInfo> key_systems_info; | 216 std::vector<KeySystemInfo> key_systems_info; |
| 182 GetContentClient()->renderer()->AddKeySystems(&key_systems_info); | 217 GetContentClient()->renderer()->AddKeySystems(&key_systems_info); |
|
ddorwin
2014/04/28 18:47:45
I think we should not make (or compile support for
| |
| 183 // Clear Key is always supported. | 218 // Clear Key is always supported. |
| 184 AddClearKey(&key_systems_info); | 219 AddClearKey(&key_systems_info); |
| 185 AddConcreteSupportedKeySystems(key_systems_info); | 220 AddConcreteSupportedKeySystems(key_systems_info); |
| 221 #if defined(OS_ANDROID) | |
| 222 AddAndroidWidevine(&key_systems_info); | |
|
ddorwin
2014/04/28 18:47:45
Like desktop, this should be in chrome/, but on th
| |
| 223 #endif // defined(OS_ANDROID) | |
| 186 #if defined(WIDEVINE_CDM_AVAILABLE) | 224 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 187 key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem); | 225 key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem); |
| 188 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 226 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 189 } | 227 } |
| 190 | 228 |
| 191 void KeySystems::AddConcreteSupportedKeySystems( | 229 void KeySystems::AddConcreteSupportedKeySystems( |
| 192 const std::vector<KeySystemInfo>& concrete_key_systems) { | 230 const std::vector<KeySystemInfo>& concrete_key_systems) { |
| 193 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { | 231 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { |
| 194 const KeySystemInfo& key_system_info = concrete_key_systems[i]; | 232 const KeySystemInfo& key_system_info = concrete_key_systems[i]; |
| 195 AddConcreteSupportedKeySystem(key_system_info.key_system, | 233 AddConcreteSupportedKeySystem(key_system_info.key_system, |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 CONTENT_EXPORT void AddContainerMask(const std::string& container, | 483 CONTENT_EXPORT void AddContainerMask(const std::string& container, |
| 446 uint32 mask) { | 484 uint32 mask) { |
| 447 KeySystems::GetInstance().AddContainerMask(container, mask); | 485 KeySystems::GetInstance().AddContainerMask(container, mask); |
| 448 } | 486 } |
| 449 | 487 |
| 450 CONTENT_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 488 CONTENT_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
| 451 KeySystems::GetInstance().AddCodecMask(codec, mask); | 489 KeySystems::GetInstance().AddCodecMask(codec, mask); |
| 452 } | 490 } |
| 453 | 491 |
| 454 } // namespace content | 492 } // namespace content |
| OLD | NEW |