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