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 "base/threading/thread_checker.h" | |
| 14 #include "base/time/time.h" | |
| 13 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
| 14 #include "content/public/common/eme_codec.h" | 16 #include "content/public/common/eme_codec.h" |
| 15 #include "content/public/renderer/content_renderer_client.h" | 17 #include "content/public/renderer/content_renderer_client.h" |
| 16 #include "content/public/renderer/key_system_info.h" | 18 #include "content/public/renderer/key_system_info.h" |
| 17 #include "content/renderer/media/crypto/key_systems_support_uma.h" | 19 #include "content/renderer/media/crypto/key_systems_support_uma.h" |
| 18 | 20 |
| 19 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
| 20 #include "media/base/android/media_codec_bridge.h" | 22 #include "media/base/android/media_codec_bridge.h" |
| 21 #endif | 23 #endif |
| 22 | 24 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 | 82 |
| 81 info.use_aes_decryptor = true; | 83 info.use_aes_decryptor = true; |
| 82 | 84 |
| 83 concrete_key_systems->push_back(info); | 85 concrete_key_systems->push_back(info); |
| 84 } | 86 } |
| 85 | 87 |
| 86 class KeySystems { | 88 class KeySystems { |
| 87 public: | 89 public: |
| 88 static KeySystems& GetInstance(); | 90 static KeySystems& GetInstance(); |
| 89 | 91 |
| 92 void UpdateIfNeeded(); | |
| 93 | |
| 90 bool IsConcreteSupportedKeySystem(const std::string& key_system); | 94 bool IsConcreteSupportedKeySystem(const std::string& key_system); |
| 91 | 95 |
| 92 bool IsSupportedKeySystemWithMediaMimeType( | 96 bool IsSupportedKeySystemWithMediaMimeType( |
| 93 const std::string& mime_type, | 97 const std::string& mime_type, |
| 94 const std::vector<std::string>& codecs, | 98 const std::vector<std::string>& codecs, |
| 95 const std::string& key_system); | 99 const std::string& key_system); |
| 96 | 100 |
| 97 bool UseAesDecryptor(const std::string& concrete_key_system); | 101 bool UseAesDecryptor(const std::string& concrete_key_system); |
| 98 | 102 |
| 99 #if defined(ENABLE_PEPPER_CDMS) | 103 #if defined(ENABLE_PEPPER_CDMS) |
| 100 std::string GetPepperType(const std::string& concrete_key_system); | 104 std::string GetPepperType(const std::string& concrete_key_system); |
| 101 #endif | 105 #endif |
| 102 | 106 |
| 103 void AddContainerMask(const std::string& container, uint32 mask); | 107 void AddContainerMask(const std::string& container, uint32 mask); |
| 104 void AddCodecMask(const std::string& codec, uint32 mask); | 108 void AddCodecMask(const std::string& codec, uint32 mask); |
| 105 | 109 |
| 106 private: | 110 private: |
| 111 void UpdateSupportedKeySystems(); | |
| 112 | |
| 107 void AddConcreteSupportedKeySystems( | 113 void AddConcreteSupportedKeySystems( |
| 108 const std::vector<KeySystemInfo>& concrete_key_systems); | 114 const std::vector<KeySystemInfo>& concrete_key_systems); |
| 109 | 115 |
| 110 void AddConcreteSupportedKeySystem( | 116 void AddConcreteSupportedKeySystem( |
| 111 const std::string& key_system, | 117 const std::string& key_system, |
| 112 bool use_aes_decryptor, | 118 bool use_aes_decryptor, |
| 113 #if defined(ENABLE_PEPPER_CDMS) | 119 #if defined(ENABLE_PEPPER_CDMS) |
| 114 const std::string& pepper_type, | 120 const std::string& pepper_type, |
| 115 #endif | 121 #endif |
| 116 SupportedCodecs supported_codecs, | 122 SupportedCodecs supported_codecs, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 142 bool IsSupportedContainer(const std::string& container, | 148 bool IsSupportedContainer(const std::string& container, |
| 143 SupportedCodecs key_system_supported_codecs) const; | 149 SupportedCodecs key_system_supported_codecs) const; |
| 144 | 150 |
| 145 // Returns true if all |codecs| are supported in |container| by checking | 151 // Returns true if all |codecs| are supported in |container| by checking |
| 146 // |key_system_supported_codecs|. | 152 // |key_system_supported_codecs|. |
| 147 bool IsSupportedContainerAndCodecs( | 153 bool IsSupportedContainerAndCodecs( |
| 148 const std::string& container, | 154 const std::string& container, |
| 149 const std::vector<std::string>& codecs, | 155 const std::vector<std::string>& codecs, |
| 150 SupportedCodecs key_system_supported_codecs) const; | 156 SupportedCodecs key_system_supported_codecs) const; |
| 151 | 157 |
| 158 | |
|
ddorwin
2014/07/20 15:47:26
extra line
xhwang
2014/07/21 18:07:27
Done.
| |
| 152 // Map from key system string to capabilities. | 159 // Map from key system string to capabilities. |
| 153 KeySystemPropertiesMap concrete_key_system_map_; | 160 KeySystemPropertiesMap concrete_key_system_map_; |
| 154 | 161 |
| 155 // Map from parent key system to the concrete key system that should be used | 162 // Map from parent key system to the concrete key system that should be used |
| 156 // to represent its capabilities. | 163 // to represent its capabilities. |
| 157 ParentKeySystemMap parent_key_system_map_; | 164 ParentKeySystemMap parent_key_system_map_; |
| 158 | 165 |
| 159 KeySystemsSupportUMA key_systems_support_uma_; | 166 KeySystemsSupportUMA key_systems_support_uma_; |
| 160 | 167 |
| 161 CodecMaskMap container_codec_masks_; | 168 CodecMaskMap container_codec_masks_; |
| 162 CodecMaskMap codec_masks_; | 169 CodecMaskMap codec_masks_; |
| 163 | 170 |
| 171 bool needs_update_; | |
| 172 base::Time last_update_time_; | |
| 173 | |
| 174 // Makes sure all methods are called from the same thread. | |
| 175 base::ThreadChecker thread_checker_; | |
| 176 | |
| 164 DISALLOW_COPY_AND_ASSIGN(KeySystems); | 177 DISALLOW_COPY_AND_ASSIGN(KeySystems); |
| 165 }; | 178 }; |
| 166 | 179 |
| 167 static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; | 180 static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; |
| 168 | 181 |
| 169 KeySystems& KeySystems::GetInstance() { | 182 KeySystems& KeySystems::GetInstance() { |
| 170 return g_key_systems.Get(); | 183 KeySystems& key_systems = g_key_systems.Get(); |
| 184 key_systems.UpdateIfNeeded(); | |
| 185 return key_systems; | |
| 171 } | 186 } |
| 172 | 187 |
| 173 // Because we use a LazyInstance, the key systems info must be populated when | 188 // Because we use a LazyInstance, the key systems info must be populated when |
| 174 // the instance is lazily initiated. | 189 // the instance is lazily initiated. |
| 175 KeySystems::KeySystems() { | 190 KeySystems::KeySystems() : needs_update_(true) { |
| 176 // Build container and codec masks for quick look up. | 191 // Build container and codec masks for quick look up. |
| 177 for (size_t i = 0; i < arraysize(kContainerCodecMasks); ++i) { | 192 for (size_t i = 0; i < arraysize(kContainerCodecMasks); ++i) { |
| 178 const CodecMask& container_codec_mask = kContainerCodecMasks[i]; | 193 const CodecMask& container_codec_mask = kContainerCodecMasks[i]; |
| 179 DCHECK(container_codec_masks_.find(container_codec_mask.type) == | 194 DCHECK(container_codec_masks_.find(container_codec_mask.type) == |
| 180 container_codec_masks_.end()); | 195 container_codec_masks_.end()); |
| 181 container_codec_masks_[container_codec_mask.type] = | 196 container_codec_masks_[container_codec_mask.type] = |
| 182 container_codec_mask.mask; | 197 container_codec_mask.mask; |
| 183 } | 198 } |
| 184 for (size_t i = 0; i < arraysize(kCodecMasks); ++i) { | 199 for (size_t i = 0; i < arraysize(kCodecMasks); ++i) { |
| 185 const CodecMask& codec_mask = kCodecMasks[i]; | 200 const CodecMask& codec_mask = kCodecMasks[i]; |
| 186 DCHECK(codec_masks_.find(codec_mask.type) == codec_masks_.end()); | 201 DCHECK(codec_masks_.find(codec_mask.type) == codec_masks_.end()); |
| 187 codec_masks_[codec_mask.type] = codec_mask.mask; | 202 codec_masks_[codec_mask.type] = codec_mask.mask; |
| 188 } | 203 } |
| 189 | 204 |
| 190 std::vector<KeySystemInfo> key_systems_info; | 205 UpdateSupportedKeySystems(); |
| 191 GetContentClient()->renderer()->AddKeySystems(&key_systems_info); | 206 |
| 192 // Clear Key is always supported. | |
| 193 AddClearKey(&key_systems_info); | |
| 194 AddConcreteSupportedKeySystems(key_systems_info); | |
| 195 #if defined(WIDEVINE_CDM_AVAILABLE) | 207 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 196 key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem); | 208 key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem); |
| 197 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 209 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 198 } | 210 } |
| 199 | 211 |
| 212 void KeySystems::UpdateIfNeeded() { | |
| 213 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | |
| 214 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 215 if (!needs_update_) | |
| 216 return; | |
| 217 | |
| 218 // The update could involve a sync IPC to the browser process. Use a minimum | |
| 219 // update interval to avoid unnecessary frequent IPC to the browser. | |
| 220 static const int kMinUpdateIntervalInSeconds = 5; | |
| 221 base::Time now = base::Time::Now(); | |
| 222 if (now - last_update_time_ < | |
| 223 base::TimeDelta::FromSeconds(kMinUpdateIntervalInSeconds)) { | |
| 224 return; | |
| 225 } | |
| 226 | |
| 227 UpdateSupportedKeySystems(); | |
| 228 #endif | |
| 229 } | |
| 230 | |
| 231 void KeySystems::UpdateSupportedKeySystems() { | |
| 232 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 233 DCHECK(needs_update_); | |
| 234 concrete_key_system_map_.clear(); | |
| 235 parent_key_system_map_.clear(); | |
| 236 | |
| 237 // Build KeySystemInfo. | |
| 238 std::vector<KeySystemInfo> key_systems_info; | |
| 239 GetContentClient()->renderer()->AddKeySystems(&key_systems_info); | |
| 240 // Clear Key is always supported. | |
| 241 AddClearKey(&key_systems_info); | |
| 242 | |
| 243 AddConcreteSupportedKeySystems(key_systems_info); | |
| 244 | |
| 245 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | |
| 246 if (IsConcreteSupportedKeySystem(kWidevineKeySystem)) | |
| 247 needs_update_ = false; | |
| 248 #endif | |
| 249 | |
| 250 last_update_time_ = base::Time::Now(); | |
| 251 } | |
| 252 | |
| 200 void KeySystems::AddConcreteSupportedKeySystems( | 253 void KeySystems::AddConcreteSupportedKeySystems( |
| 201 const std::vector<KeySystemInfo>& concrete_key_systems) { | 254 const std::vector<KeySystemInfo>& concrete_key_systems) { |
| 255 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 256 DCHECK(concrete_key_system_map_.empty()); | |
| 257 DCHECK(parent_key_system_map_.empty()); | |
| 258 | |
| 202 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { | 259 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { |
| 203 const KeySystemInfo& key_system_info = concrete_key_systems[i]; | 260 const KeySystemInfo& key_system_info = concrete_key_systems[i]; |
| 204 AddConcreteSupportedKeySystem(key_system_info.key_system, | 261 AddConcreteSupportedKeySystem(key_system_info.key_system, |
| 205 key_system_info.use_aes_decryptor, | 262 key_system_info.use_aes_decryptor, |
| 206 #if defined(ENABLE_PEPPER_CDMS) | 263 #if defined(ENABLE_PEPPER_CDMS) |
| 207 key_system_info.pepper_type, | 264 key_system_info.pepper_type, |
| 208 #endif | 265 #endif |
| 209 key_system_info.supported_codecs, | 266 key_system_info.supported_codecs, |
| 210 key_system_info.parent_key_system); | 267 key_system_info.parent_key_system); |
| 211 } | 268 } |
| 212 } | 269 } |
| 213 | 270 |
| 214 void KeySystems::AddConcreteSupportedKeySystem( | 271 void KeySystems::AddConcreteSupportedKeySystem( |
| 215 const std::string& concrete_key_system, | 272 const std::string& concrete_key_system, |
| 216 bool use_aes_decryptor, | 273 bool use_aes_decryptor, |
| 217 #if defined(ENABLE_PEPPER_CDMS) | 274 #if defined(ENABLE_PEPPER_CDMS) |
| 218 const std::string& pepper_type, | 275 const std::string& pepper_type, |
| 219 #endif | 276 #endif |
| 220 SupportedCodecs supported_codecs, | 277 SupportedCodecs supported_codecs, |
| 221 const std::string& parent_key_system) { | 278 const std::string& parent_key_system) { |
| 279 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 222 DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system)) | 280 DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system)) |
| 223 << "Key system '" << concrete_key_system << "' already registered"; | 281 << "Key system '" << concrete_key_system << "' already registered"; |
| 224 DCHECK(parent_key_system_map_.find(concrete_key_system) == | 282 DCHECK(parent_key_system_map_.find(concrete_key_system) == |
| 225 parent_key_system_map_.end()) | 283 parent_key_system_map_.end()) |
| 226 << "'" << concrete_key_system << " is already registered as a parent"; | 284 << "'" << concrete_key_system << " is already registered as a parent"; |
| 227 | 285 |
| 228 KeySystemProperties properties; | 286 KeySystemProperties properties; |
| 229 properties.use_aes_decryptor = use_aes_decryptor; | 287 properties.use_aes_decryptor = use_aes_decryptor; |
| 230 #if defined(ENABLE_PEPPER_CDMS) | 288 #if defined(ENABLE_PEPPER_CDMS) |
| 231 DCHECK_EQ(use_aes_decryptor, pepper_type.empty()); | 289 DCHECK_EQ(use_aes_decryptor, pepper_type.empty()); |
| 232 properties.pepper_type = pepper_type; | 290 properties.pepper_type = pepper_type; |
| 233 #endif | 291 #endif |
| 234 | 292 |
| 235 properties.supported_codecs = supported_codecs; | 293 properties.supported_codecs = supported_codecs; |
| 236 | 294 |
| 237 concrete_key_system_map_[concrete_key_system] = properties; | 295 concrete_key_system_map_[concrete_key_system] = properties; |
| 238 | 296 |
| 239 if (!parent_key_system.empty()) { | 297 if (!parent_key_system.empty()) { |
| 240 DCHECK(!IsConcreteSupportedKeySystem(parent_key_system)) | 298 DCHECK(!IsConcreteSupportedKeySystem(parent_key_system)) |
| 241 << "Parent '" << parent_key_system << "' already registered concrete"; | 299 << "Parent '" << parent_key_system << "' already registered concrete"; |
| 242 DCHECK(parent_key_system_map_.find(parent_key_system) == | 300 DCHECK(parent_key_system_map_.find(parent_key_system) == |
| 243 parent_key_system_map_.end()) | 301 parent_key_system_map_.end()) |
| 244 << "Parent '" << parent_key_system << "' already registered"; | 302 << "Parent '" << parent_key_system << "' already registered"; |
| 245 parent_key_system_map_[parent_key_system] = concrete_key_system; | 303 parent_key_system_map_[parent_key_system] = concrete_key_system; |
| 246 } | 304 } |
| 247 } | 305 } |
| 248 | 306 |
| 249 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { | 307 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { |
| 308 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 250 return concrete_key_system_map_.find(key_system) != | 309 return concrete_key_system_map_.find(key_system) != |
| 251 concrete_key_system_map_.end(); | 310 concrete_key_system_map_.end(); |
| 252 } | 311 } |
| 253 | 312 |
| 254 bool KeySystems::IsSupportedContainer( | 313 bool KeySystems::IsSupportedContainer( |
| 255 const std::string& container, | 314 const std::string& container, |
| 256 SupportedCodecs key_system_supported_codecs) const { | 315 SupportedCodecs key_system_supported_codecs) const { |
| 316 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 257 DCHECK(!container.empty()); | 317 DCHECK(!container.empty()); |
| 258 | 318 |
| 259 // When checking container support for EME, "audio/foo" should be treated the | 319 // When checking container support for EME, "audio/foo" should be treated the |
| 260 // same as "video/foo". Convert the |container| to achieve this. | 320 // same as "video/foo". Convert the |container| to achieve this. |
| 261 // TODO(xhwang): Replace this with real checks against supported initDataTypes | 321 // TODO(xhwang): Replace this with real checks against supported initDataTypes |
| 262 // combined with supported demuxers. | 322 // combined with supported demuxers. |
| 263 std::string canonical_container = container; | 323 std::string canonical_container = container; |
| 264 if (container.find("audio/") == 0) | 324 if (container.find("audio/") == 0) |
| 265 canonical_container.replace(0, 6, "video/"); | 325 canonical_container.replace(0, 6, "video/"); |
| 266 | 326 |
| 267 CodecMaskMap::const_iterator container_iter = | 327 CodecMaskMap::const_iterator container_iter = |
| 268 container_codec_masks_.find(canonical_container); | 328 container_codec_masks_.find(canonical_container); |
| 269 // Unrecognized container. | 329 // Unrecognized container. |
| 270 if (container_iter == container_codec_masks_.end()) | 330 if (container_iter == container_codec_masks_.end()) |
| 271 return false; | 331 return false; |
| 272 | 332 |
| 273 EmeCodec container_codec_mask = container_iter->second; | 333 EmeCodec container_codec_mask = container_iter->second; |
| 274 // A container is supported iif at least one codec in that container is | 334 // A container is supported iif at least one codec in that container is |
| 275 // supported. | 335 // supported. |
| 276 return (container_codec_mask & key_system_supported_codecs) != 0; | 336 return (container_codec_mask & key_system_supported_codecs) != 0; |
| 277 } | 337 } |
| 278 | 338 |
| 279 bool KeySystems::IsSupportedContainerAndCodecs( | 339 bool KeySystems::IsSupportedContainerAndCodecs( |
| 280 const std::string& container, | 340 const std::string& container, |
| 281 const std::vector<std::string>& codecs, | 341 const std::vector<std::string>& codecs, |
| 282 SupportedCodecs key_system_supported_codecs) const { | 342 SupportedCodecs key_system_supported_codecs) const { |
| 343 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 283 DCHECK(!container.empty()); | 344 DCHECK(!container.empty()); |
| 284 DCHECK(!codecs.empty()); | 345 DCHECK(!codecs.empty()); |
| 285 DCHECK(IsSupportedContainer(container, key_system_supported_codecs)); | 346 DCHECK(IsSupportedContainer(container, key_system_supported_codecs)); |
| 286 | 347 |
| 287 CodecMaskMap::const_iterator container_iter = | 348 CodecMaskMap::const_iterator container_iter = |
| 288 container_codec_masks_.find(container); | 349 container_codec_masks_.find(container); |
| 289 EmeCodec container_codec_mask = container_iter->second; | 350 EmeCodec container_codec_mask = container_iter->second; |
| 290 | 351 |
| 291 for (size_t i = 0; i < codecs.size(); ++i) { | 352 for (size_t i = 0; i < codecs.size(); ++i) { |
| 292 const std::string& codec = codecs[i]; | 353 const std::string& codec = codecs[i]; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 305 return false; | 366 return false; |
| 306 } | 367 } |
| 307 | 368 |
| 308 return true; | 369 return true; |
| 309 } | 370 } |
| 310 | 371 |
| 311 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( | 372 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( |
| 312 const std::string& mime_type, | 373 const std::string& mime_type, |
| 313 const std::vector<std::string>& codecs, | 374 const std::vector<std::string>& codecs, |
| 314 const std::string& key_system) { | 375 const std::string& key_system) { |
| 376 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 377 | |
| 315 // If |key_system| is a parent key_system, use its concrete child. | 378 // If |key_system| is a parent key_system, use its concrete child. |
| 316 // Otherwise, use |key_system|. | 379 // Otherwise, use |key_system|. |
| 317 std::string concrete_key_system; | 380 std::string concrete_key_system; |
| 318 ParentKeySystemMap::iterator parent_key_system_iter = | 381 ParentKeySystemMap::iterator parent_key_system_iter = |
| 319 parent_key_system_map_.find(key_system); | 382 parent_key_system_map_.find(key_system); |
| 320 if (parent_key_system_iter != parent_key_system_map_.end()) | 383 if (parent_key_system_iter != parent_key_system_map_.end()) |
| 321 concrete_key_system = parent_key_system_iter->second; | 384 concrete_key_system = parent_key_system_iter->second; |
| 322 else | 385 else |
| 323 concrete_key_system = key_system; | 386 concrete_key_system = key_system; |
| 324 | 387 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 349 !IsSupportedContainerAndCodecs( | 412 !IsSupportedContainerAndCodecs( |
| 350 mime_type, codecs, key_system_supported_codecs)) { | 413 mime_type, codecs, key_system_supported_codecs)) { |
| 351 return false; | 414 return false; |
| 352 } | 415 } |
| 353 | 416 |
| 354 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); | 417 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); |
| 355 return true; | 418 return true; |
| 356 } | 419 } |
| 357 | 420 |
| 358 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { | 421 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { |
| 422 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 423 | |
| 359 KeySystemPropertiesMap::iterator key_system_iter = | 424 KeySystemPropertiesMap::iterator key_system_iter = |
| 360 concrete_key_system_map_.find(concrete_key_system); | 425 concrete_key_system_map_.find(concrete_key_system); |
| 361 if (key_system_iter == concrete_key_system_map_.end()) { | 426 if (key_system_iter == concrete_key_system_map_.end()) { |
| 362 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 427 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
| 363 return false; | 428 return false; |
| 364 } | 429 } |
| 365 | 430 |
| 366 return key_system_iter->second.use_aes_decryptor; | 431 return key_system_iter->second.use_aes_decryptor; |
| 367 } | 432 } |
| 368 | 433 |
| 369 #if defined(ENABLE_PEPPER_CDMS) | 434 #if defined(ENABLE_PEPPER_CDMS) |
| 370 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { | 435 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { |
| 436 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 437 | |
| 371 KeySystemPropertiesMap::iterator key_system_iter = | 438 KeySystemPropertiesMap::iterator key_system_iter = |
| 372 concrete_key_system_map_.find(concrete_key_system); | 439 concrete_key_system_map_.find(concrete_key_system); |
| 373 if (key_system_iter == concrete_key_system_map_.end()) { | 440 if (key_system_iter == concrete_key_system_map_.end()) { |
| 374 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 441 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
| 375 return std::string(); | 442 return std::string(); |
| 376 } | 443 } |
| 377 | 444 |
| 378 const std::string& type = key_system_iter->second.pepper_type; | 445 const std::string& type = key_system_iter->second.pepper_type; |
| 379 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 446 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
| 380 return type; | 447 return type; |
| 381 } | 448 } |
| 382 #endif | 449 #endif |
| 383 | 450 |
| 384 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 451 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { |
| 452 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 385 DCHECK(container_codec_masks_.find(container) == | 453 DCHECK(container_codec_masks_.find(container) == |
| 386 container_codec_masks_.end()); | 454 container_codec_masks_.end()); |
| 455 | |
| 387 container_codec_masks_[container] = static_cast<EmeCodec>(mask); | 456 container_codec_masks_[container] = static_cast<EmeCodec>(mask); |
| 388 } | 457 } |
| 389 | 458 |
| 390 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | 459 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { |
| 460 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 391 DCHECK(codec_masks_.find(codec) == codec_masks_.end()); | 461 DCHECK(codec_masks_.find(codec) == codec_masks_.end()); |
| 462 | |
| 392 codec_masks_[codec] = static_cast<EmeCodec>(mask); | 463 codec_masks_[codec] = static_cast<EmeCodec>(mask); |
| 393 } | 464 } |
| 394 | 465 |
| 395 //------------------------------------------------------------------------------ | 466 //------------------------------------------------------------------------------ |
| 396 | 467 |
| 397 std::string GetUnprefixedKeySystemName(const std::string& key_system) { | 468 std::string GetUnprefixedKeySystemName(const std::string& key_system) { |
| 398 if (key_system == kClearKeyKeySystem) | 469 if (key_system == kClearKeyKeySystem) |
| 399 return kUnsupportedClearKeyKeySystem; | 470 return kUnsupportedClearKeyKeySystem; |
| 400 | 471 |
| 401 if (key_system == kPrefixedClearKeyKeySystem) | 472 if (key_system == kPrefixedClearKeyKeySystem) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 CONTENT_EXPORT void AddContainerMask(const std::string& container, | 525 CONTENT_EXPORT void AddContainerMask(const std::string& container, |
| 455 uint32 mask) { | 526 uint32 mask) { |
| 456 KeySystems::GetInstance().AddContainerMask(container, mask); | 527 KeySystems::GetInstance().AddContainerMask(container, mask); |
| 457 } | 528 } |
| 458 | 529 |
| 459 CONTENT_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 530 CONTENT_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
| 460 KeySystems::GetInstance().AddCodecMask(codec, mask); | 531 KeySystems::GetInstance().AddCodecMask(codec, mask); |
| 461 } | 532 } |
| 462 | 533 |
| 463 } // namespace content | 534 } // namespace content |
| OLD | NEW |