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 "media/base/key_systems.h" | 5 #include "media/base/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" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // True is always returned for a |key_system| that begins with "x-". | 133 // True is always returned for a |key_system| that begins with "x-". |
| 134 // | 134 // |
| 135 // As with other web platform features, advertising support for a key system | 135 // As with other web platform features, advertising support for a key system |
| 136 // implies that it adheres to a defined and interoperable specification. | 136 // implies that it adheres to a defined and interoperable specification. |
| 137 // | 137 // |
| 138 // To ensure interoperability, implementations of a specific |key_system| string | 138 // To ensure interoperability, implementations of a specific |key_system| string |
| 139 // must conform to a specification for that identifier that defines | 139 // must conform to a specification for that identifier that defines |
| 140 // key system-specific behaviors not fully defined by the EME specification. | 140 // key system-specific behaviors not fully defined by the EME specification. |
| 141 // That specification should be provided by the owner of the domain that is the | 141 // That specification should be provided by the owner of the domain that is the |
| 142 // reverse of the |key_system| string. | 142 // reverse of the |key_system| string. |
| 143 // This involves more than calling a library, SDK, or platform API. KeySystems | 143 // This involves more than calling a library, SDK, or platform API. |
| 144 // must be populated appropriately, and there will likely be glue code to adapt | 144 // KeySystemsImpl must be populated appropriately, and there will likely be glue |
| 145 // to the API of the library, SDK, or platform API. | 145 // code to adapt to the API of the library, SDK, or platform API. |
| 146 // | 146 // |
| 147 // Chromium mainline contains this data and glue code for specific key systems, | 147 // Chromium mainline contains this data and glue code for specific key systems, |
| 148 // which should help ensure interoperability with other implementations using | 148 // which should help ensure interoperability with other implementations using |
| 149 // these key systems. | 149 // these key systems. |
| 150 // | 150 // |
| 151 // If you need to add support for other key systems, ensure that you have | 151 // If you need to add support for other key systems, ensure that you have |
| 152 // obtained the specification for how to integrate it with EME, implemented the | 152 // obtained the specification for how to integrate it with EME, implemented the |
| 153 // appropriate glue/adapter code, and added all the appropriate data to | 153 // appropriate glue/adapter code, and added all the appropriate data to |
| 154 // KeySystems. Only then should you change this function. | 154 // KeySystemsImpl. Only then should you change this function. |
| 155 static bool IsPotentiallySupportedKeySystem(const std::string& key_system) { | 155 static bool IsPotentiallySupportedKeySystem(const std::string& key_system) { |
| 156 // Known and supported key systems. | 156 // Known and supported key systems. |
| 157 if (key_system == kWidevineKeySystem) | 157 if (key_system == kWidevineKeySystem) |
| 158 return true; | 158 return true; |
| 159 if (key_system == kClearKey) | 159 if (key_system == kClearKey) |
| 160 return true; | 160 return true; |
| 161 | 161 |
| 162 // External Clear Key is known and supports suffixes for testing. | 162 // External Clear Key is known and supports suffixes for testing. |
| 163 if (IsExternalClearKey(key_system)) | 163 if (IsExternalClearKey(key_system)) |
| 164 return true; | 164 return true; |
| 165 | 165 |
| 166 // Chromecast defines behaviors for Cast clients within its reverse domain. | 166 // Chromecast defines behaviors for Cast clients within its reverse domain. |
| 167 const char kChromecastRoot[] = "com.chromecast"; | 167 const char kChromecastRoot[] = "com.chromecast"; |
| 168 if (IsParentKeySystemOf(kChromecastRoot, key_system)) | 168 if (IsParentKeySystemOf(kChromecastRoot, key_system)) |
| 169 return true; | 169 return true; |
| 170 | 170 |
| 171 // Implementations that do not have a specification or appropriate glue code | 171 // Implementations that do not have a specification or appropriate glue code |
| 172 // can use the "x-" prefix to avoid conflicting with and advertising support | 172 // can use the "x-" prefix to avoid conflicting with and advertising support |
| 173 // for real key system names. Use is discouraged. | 173 // for real key system names. Use is discouraged. |
| 174 const char kExcludedPrefix[] = "x-"; | 174 const char kExcludedPrefix[] = "x-"; |
| 175 if (key_system.find(kExcludedPrefix, 0, arraysize(kExcludedPrefix) - 1) == 0) | 175 if (key_system.find(kExcludedPrefix, 0, arraysize(kExcludedPrefix) - 1) == 0) |
| 176 return true; | 176 return true; |
| 177 | 177 |
| 178 return false; | 178 return false; |
| 179 } | 179 } |
| 180 | 180 |
| 181 class KeySystems { | 181 class KeySystemsImpl : public KeySystems { |
| 182 public: | 182 public: |
| 183 static KeySystems& GetInstance(); | 183 static KeySystemsImpl& GetInstance(); |
| 184 | 184 |
| 185 void UpdateIfNeeded(); | 185 void UpdateIfNeeded(); |
| 186 | 186 |
| 187 bool IsConcreteSupportedKeySystem(const std::string& key_system); | 187 bool IsConcreteSupportedKeySystem(const std::string& key_system); |
|
ddorwin
2015/03/20 00:55:03
const on most of these?
sandersd (OOO until July 31)
2015/03/20 22:53:19
Done.
| |
| 188 | 188 |
| 189 bool IsSupportedKeySystem(const std::string& key_system); | 189 bool IsSupportedKeySystem(const std::string& key_system); |
| 190 | 190 |
| 191 bool IsSupportedKeySystemWithInitDataType( | 191 bool IsSupportedKeySystemWithInitDataType( |
| 192 const std::string& key_system, | 192 const std::string& key_system, |
| 193 const std::string& init_data_type); | 193 const std::string& init_data_type); |
| 194 | 194 |
| 195 bool PrefixedIsSupportedKeySystemWithMediaMimeType( | |
| 196 const std::string& mime_type, | |
| 197 const std::vector<std::string>& codecs, | |
| 198 const std::string& key_system); | |
| 199 | |
| 195 bool IsSupportedKeySystemWithMediaMimeType( | 200 bool IsSupportedKeySystemWithMediaMimeType( |
| 196 const std::string& mime_type, | 201 const std::string& mime_type, |
| 197 const std::vector<std::string>& codecs, | 202 const std::vector<std::string>& codecs, |
| 198 const std::string& key_system, | 203 const std::string& key_system) const; |
| 199 bool is_prefixed); | |
| 200 | 204 |
| 201 std::string GetKeySystemNameForUMA(const std::string& key_system) const; | 205 std::string GetKeySystemNameForUMA(const std::string& key_system) const; |
| 202 | 206 |
| 203 bool UseAesDecryptor(const std::string& concrete_key_system); | 207 bool UseAesDecryptor(const std::string& concrete_key_system); |
| 204 | 208 |
| 205 #if defined(ENABLE_PEPPER_CDMS) | 209 #if defined(ENABLE_PEPPER_CDMS) |
| 206 std::string GetPepperType(const std::string& concrete_key_system); | 210 std::string GetPepperType(const std::string& concrete_key_system); |
| 207 #endif | 211 #endif |
| 208 | 212 |
| 213 bool IsSupportedCodecCombination( | |
| 214 const std::string& key_system, | |
| 215 EmeMediaType media_type, | |
| 216 const std::string& container_mime_type, | |
| 217 const std::vector<std::string>& codecs) const override; | |
| 218 | |
| 209 EmeConfigRule GetRobustnessConfigRule( | 219 EmeConfigRule GetRobustnessConfigRule( |
| 210 const std::string& key_system, | 220 const std::string& key_system, |
| 211 EmeMediaType media_type, | 221 EmeMediaType media_type, |
| 212 EmeRobustness robustness); | 222 EmeRobustness robustness) const override; |
| 213 | 223 |
| 214 EmeConfigRule GetPersistentLicenseSessionConfigRule( | 224 EmeConfigRule GetPersistentLicenseSessionConfigRule( |
| 215 const std::string& key_system); | 225 const std::string& key_system) const override; |
| 216 | 226 |
| 217 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( | 227 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( |
| 218 const std::string& key_system); | 228 const std::string& key_system) const override; |
| 219 | 229 |
| 220 EmeConfigRule GetPersistentStateConfigRule( | 230 EmeConfigRule GetPersistentStateConfigRule( |
| 221 const std::string& key_system, | 231 const std::string& key_system, |
| 222 EmeFeatureRequirement requirement); | 232 EmeFeatureRequirement requirement) const override; |
| 223 | 233 |
| 224 EmeConfigRule GetDistinctiveIdentifierConfigRule( | 234 EmeConfigRule GetDistinctiveIdentifierConfigRule( |
| 225 const std::string& key_system, | 235 const std::string& key_system, |
| 226 EmeFeatureRequirement requirement); | 236 EmeFeatureRequirement requirement) const override; |
| 227 | 237 |
| 228 void AddContainerMask(const std::string& container, uint32 mask); | 238 void AddContainerMask(const std::string& container, uint32 mask); |
| 229 void AddCodecMask(const std::string& codec, uint32 mask); | 239 void AddCodecMask(const std::string& codec, uint32 mask); |
| 230 | 240 |
| 231 private: | 241 private: |
| 232 void InitializeUMAInfo(); | 242 void InitializeUMAInfo(); |
| 233 | 243 |
| 234 void UpdateSupportedKeySystems(); | 244 void UpdateSupportedKeySystems(); |
| 235 | 245 |
| 236 void AddConcreteSupportedKeySystems( | 246 void AddConcreteSupportedKeySystems( |
| 237 const std::vector<KeySystemInfo>& concrete_key_systems); | 247 const std::vector<KeySystemInfo>& concrete_key_systems); |
| 238 | 248 |
| 239 friend struct base::DefaultLazyInstanceTraits<KeySystems>; | 249 friend struct base::DefaultLazyInstanceTraits<KeySystemsImpl>; |
| 240 | 250 |
| 241 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap; | 251 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap; |
| 242 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; | 252 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; |
| 243 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; | 253 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; |
| 244 typedef base::hash_map<std::string, EmeCodec> CodecsMap; | 254 typedef base::hash_map<std::string, EmeCodec> CodecsMap; |
| 245 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; | 255 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; |
| 246 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; | 256 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; |
| 247 | 257 |
| 248 KeySystems(); | 258 KeySystemsImpl(); |
| 249 ~KeySystems() {} | 259 ~KeySystemsImpl() {} |
| 250 | 260 |
| 251 EmeInitDataType GetInitDataTypeForName( | 261 EmeInitDataType GetInitDataTypeForName( |
| 252 const std::string& init_data_type) const; | 262 const std::string& init_data_type) const; |
| 253 // TODO(sandersd): Separate container enum from codec mask value. | 263 // TODO(sandersd): Separate container enum from codec mask value. |
| 254 // http://crbug.com/417440 | 264 // http://crbug.com/417440 |
| 255 SupportedCodecs GetCodecMaskForContainer( | 265 SupportedCodecs GetCodecMaskForContainer( |
| 256 const std::string& container) const; | 266 const std::string& container) const; |
| 257 EmeCodec GetCodecForString(const std::string& codec) const; | 267 EmeCodec GetCodecForString(const std::string& codec) const; |
| 258 | 268 |
| 259 const std::string& PrefixedGetConcreteKeySystemNameFor( | 269 const std::string& PrefixedGetConcreteKeySystemNameFor( |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 282 KeySystemsSupportUMA key_systems_support_uma_; | 292 KeySystemsSupportUMA key_systems_support_uma_; |
| 283 | 293 |
| 284 InitDataTypesMap init_data_type_name_map_; | 294 InitDataTypesMap init_data_type_name_map_; |
| 285 ContainerCodecsMap container_to_codec_mask_map_; | 295 ContainerCodecsMap container_to_codec_mask_map_; |
| 286 CodecsMap codec_string_map_; | 296 CodecsMap codec_string_map_; |
| 287 KeySystemNameForUMAMap key_system_name_for_uma_map_; | 297 KeySystemNameForUMAMap key_system_name_for_uma_map_; |
| 288 | 298 |
| 289 // Makes sure all methods are called from the same thread. | 299 // Makes sure all methods are called from the same thread. |
| 290 base::ThreadChecker thread_checker_; | 300 base::ThreadChecker thread_checker_; |
| 291 | 301 |
| 292 DISALLOW_COPY_AND_ASSIGN(KeySystems); | 302 DISALLOW_COPY_AND_ASSIGN(KeySystemsImpl); |
| 293 }; | 303 }; |
| 294 | 304 |
| 295 static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; | 305 static base::LazyInstance<KeySystemsImpl> g_key_systems = |
| 306 LAZY_INSTANCE_INITIALIZER; | |
| 296 | 307 |
| 297 KeySystems& KeySystems::GetInstance() { | 308 KeySystemsImpl& KeySystemsImpl::GetInstance() { |
| 298 KeySystems& key_systems = g_key_systems.Get(); | 309 KeySystemsImpl& key_systems = g_key_systems.Get(); |
| 299 key_systems.UpdateIfNeeded(); | 310 key_systems.UpdateIfNeeded(); |
| 300 return key_systems; | 311 return key_systems; |
| 301 } | 312 } |
| 302 | 313 |
| 303 // Because we use a LazyInstance, the key systems info must be populated when | 314 // Because we use a LazyInstance, the key systems info must be populated when |
| 304 // the instance is lazily initiated. | 315 // the instance is lazily initiated. |
| 305 KeySystems::KeySystems() { | 316 KeySystemsImpl::KeySystemsImpl() { |
| 306 for (size_t i = 0; i < arraysize(kInitDataTypeNames); ++i) { | 317 for (size_t i = 0; i < arraysize(kInitDataTypeNames); ++i) { |
| 307 const std::string& name = kInitDataTypeNames[i].name; | 318 const std::string& name = kInitDataTypeNames[i].name; |
| 308 DCHECK(!init_data_type_name_map_.count(name)); | 319 DCHECK(!init_data_type_name_map_.count(name)); |
| 309 init_data_type_name_map_[name] = kInitDataTypeNames[i].type; | 320 init_data_type_name_map_[name] = kInitDataTypeNames[i].type; |
| 310 } | 321 } |
| 311 for (size_t i = 0; i < arraysize(kContainerToCodecMasks); ++i) { | 322 for (size_t i = 0; i < arraysize(kContainerToCodecMasks); ++i) { |
| 312 const std::string& name = kContainerToCodecMasks[i].name; | 323 const std::string& name = kContainerToCodecMasks[i].name; |
| 313 DCHECK(!container_to_codec_mask_map_.count(name)); | 324 DCHECK(!container_to_codec_mask_map_.count(name)); |
| 314 container_to_codec_mask_map_[name] = kContainerToCodecMasks[i].type; | 325 container_to_codec_mask_map_[name] = kContainerToCodecMasks[i].type; |
| 315 } | 326 } |
| 316 for (size_t i = 0; i < arraysize(kCodecStrings); ++i) { | 327 for (size_t i = 0; i < arraysize(kCodecStrings); ++i) { |
| 317 const std::string& name = kCodecStrings[i].name; | 328 const std::string& name = kCodecStrings[i].name; |
| 318 DCHECK(!codec_string_map_.count(name)); | 329 DCHECK(!codec_string_map_.count(name)); |
| 319 codec_string_map_[name] = kCodecStrings[i].type; | 330 codec_string_map_[name] = kCodecStrings[i].type; |
| 320 } | 331 } |
| 321 | 332 |
| 322 InitializeUMAInfo(); | 333 InitializeUMAInfo(); |
| 323 | 334 |
| 324 // Always update supported key systems during construction. | 335 // Always update supported key systems during construction. |
| 325 UpdateSupportedKeySystems(); | 336 UpdateSupportedKeySystems(); |
| 326 } | 337 } |
| 327 | 338 |
| 328 EmeInitDataType KeySystems::GetInitDataTypeForName( | 339 EmeInitDataType KeySystemsImpl::GetInitDataTypeForName( |
| 329 const std::string& init_data_type) const { | 340 const std::string& init_data_type) const { |
| 330 InitDataTypesMap::const_iterator iter = | 341 InitDataTypesMap::const_iterator iter = |
| 331 init_data_type_name_map_.find(init_data_type); | 342 init_data_type_name_map_.find(init_data_type); |
| 332 if (iter != init_data_type_name_map_.end()) | 343 if (iter != init_data_type_name_map_.end()) |
| 333 return iter->second; | 344 return iter->second; |
| 334 return EME_INIT_DATA_TYPE_NONE; | 345 return EME_INIT_DATA_TYPE_NONE; |
| 335 } | 346 } |
| 336 | 347 |
| 337 SupportedCodecs KeySystems::GetCodecMaskForContainer( | 348 SupportedCodecs KeySystemsImpl::GetCodecMaskForContainer( |
| 338 const std::string& container) const { | 349 const std::string& container) const { |
| 339 ContainerCodecsMap::const_iterator iter = | 350 ContainerCodecsMap::const_iterator iter = |
| 340 container_to_codec_mask_map_.find(container); | 351 container_to_codec_mask_map_.find(container); |
| 341 if (iter != container_to_codec_mask_map_.end()) | 352 if (iter != container_to_codec_mask_map_.end()) |
| 342 return iter->second; | 353 return iter->second; |
| 343 return EME_CODEC_NONE; | 354 return EME_CODEC_NONE; |
| 344 } | 355 } |
| 345 | 356 |
| 346 EmeCodec KeySystems::GetCodecForString(const std::string& codec) const { | 357 EmeCodec KeySystemsImpl::GetCodecForString(const std::string& codec) const { |
| 347 CodecsMap::const_iterator iter = codec_string_map_.find(codec); | 358 CodecsMap::const_iterator iter = codec_string_map_.find(codec); |
| 348 if (iter != codec_string_map_.end()) | 359 if (iter != codec_string_map_.end()) |
| 349 return iter->second; | 360 return iter->second; |
| 350 return EME_CODEC_NONE; | 361 return EME_CODEC_NONE; |
| 351 } | 362 } |
| 352 | 363 |
| 353 const std::string& KeySystems::PrefixedGetConcreteKeySystemNameFor( | 364 const std::string& KeySystemsImpl::PrefixedGetConcreteKeySystemNameFor( |
| 354 const std::string& key_system) const { | 365 const std::string& key_system) const { |
| 355 ParentKeySystemMap::const_iterator iter = | 366 ParentKeySystemMap::const_iterator iter = |
| 356 parent_key_system_map_.find(key_system); | 367 parent_key_system_map_.find(key_system); |
| 357 if (iter != parent_key_system_map_.end()) | 368 if (iter != parent_key_system_map_.end()) |
| 358 return iter->second; | 369 return iter->second; |
| 359 return key_system; | 370 return key_system; |
| 360 } | 371 } |
| 361 | 372 |
| 362 void KeySystems::InitializeUMAInfo() { | 373 void KeySystemsImpl::InitializeUMAInfo() { |
| 363 DCHECK(thread_checker_.CalledOnValidThread()); | 374 DCHECK(thread_checker_.CalledOnValidThread()); |
| 364 DCHECK(key_system_name_for_uma_map_.empty()); | 375 DCHECK(key_system_name_for_uma_map_.empty()); |
| 365 | 376 |
| 366 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma; | 377 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma; |
| 367 if (GetMediaClient()) | 378 if (GetMediaClient()) |
| 368 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma); | 379 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma); |
| 369 | 380 |
| 370 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) { | 381 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) { |
| 371 key_system_name_for_uma_map_[info.key_system] = | 382 key_system_name_for_uma_map_[info.key_system] = |
| 372 info.key_system_name_for_uma; | 383 info.key_system_name_for_uma; |
| 373 if (info.reports_key_system_support_to_uma) | 384 if (info.reports_key_system_support_to_uma) |
| 374 key_systems_support_uma_.AddKeySystemToReport(info.key_system); | 385 key_systems_support_uma_.AddKeySystemToReport(info.key_system); |
| 375 } | 386 } |
| 376 | 387 |
| 377 // Clear Key is always supported. | 388 // Clear Key is always supported. |
| 378 key_system_name_for_uma_map_[kClearKeyKeySystem] = | 389 key_system_name_for_uma_map_[kClearKeyKeySystem] = |
| 379 kClearKeyKeySystemNameForUMA; | 390 kClearKeyKeySystemNameForUMA; |
| 380 } | 391 } |
| 381 | 392 |
| 382 void KeySystems::UpdateIfNeeded() { | 393 void KeySystemsImpl::UpdateIfNeeded() { |
| 383 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded()) | 394 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded()) |
| 384 UpdateSupportedKeySystems(); | 395 UpdateSupportedKeySystems(); |
| 385 } | 396 } |
| 386 | 397 |
| 387 void KeySystems::UpdateSupportedKeySystems() { | 398 void KeySystemsImpl::UpdateSupportedKeySystems() { |
| 388 DCHECK(thread_checker_.CalledOnValidThread()); | 399 DCHECK(thread_checker_.CalledOnValidThread()); |
| 389 concrete_key_system_map_.clear(); | 400 concrete_key_system_map_.clear(); |
| 390 parent_key_system_map_.clear(); | 401 parent_key_system_map_.clear(); |
| 391 | 402 |
| 392 // Build KeySystemInfo. | 403 // Build KeySystemInfo. |
| 393 std::vector<KeySystemInfo> key_systems_info; | 404 std::vector<KeySystemInfo> key_systems_info; |
| 394 | 405 |
| 395 // Add key systems supported by the MediaClient implementation. | 406 // Add key systems supported by the MediaClient implementation. |
| 396 if (GetMediaClient()) | 407 if (GetMediaClient()) |
| 397 GetMediaClient()->AddSupportedKeySystems(&key_systems_info); | 408 GetMediaClient()->AddSupportedKeySystems(&key_systems_info); |
| 398 | 409 |
| 399 // Clear Key is always supported. | 410 // Clear Key is always supported. |
| 400 AddClearKey(&key_systems_info); | 411 AddClearKey(&key_systems_info); |
| 401 | 412 |
| 402 AddConcreteSupportedKeySystems(key_systems_info); | 413 AddConcreteSupportedKeySystems(key_systems_info); |
| 403 } | 414 } |
| 404 | 415 |
| 405 void KeySystems::AddConcreteSupportedKeySystems( | 416 void KeySystemsImpl::AddConcreteSupportedKeySystems( |
| 406 const std::vector<KeySystemInfo>& concrete_key_systems) { | 417 const std::vector<KeySystemInfo>& concrete_key_systems) { |
| 407 DCHECK(thread_checker_.CalledOnValidThread()); | 418 DCHECK(thread_checker_.CalledOnValidThread()); |
| 408 DCHECK(concrete_key_system_map_.empty()); | 419 DCHECK(concrete_key_system_map_.empty()); |
| 409 DCHECK(parent_key_system_map_.empty()); | 420 DCHECK(parent_key_system_map_.empty()); |
| 410 | 421 |
| 411 for (const KeySystemInfo& info : concrete_key_systems) { | 422 for (const KeySystemInfo& info : concrete_key_systems) { |
| 412 DCHECK(!info.key_system.empty()); | 423 DCHECK(!info.key_system.empty()); |
| 413 DCHECK(info.max_audio_robustness != EmeRobustness::INVALID); | 424 DCHECK(info.max_audio_robustness != EmeRobustness::INVALID); |
| 414 DCHECK(info.max_video_robustness != EmeRobustness::INVALID); | 425 DCHECK(info.max_video_robustness != EmeRobustness::INVALID); |
| 415 DCHECK(info.persistent_license_support != EME_SESSION_TYPE_INVALID); | 426 DCHECK(info.persistent_license_support != EME_SESSION_TYPE_INVALID); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) | 490 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) |
| 480 << "Parent '" << info.parent_key_system << "' " | 491 << "Parent '" << info.parent_key_system << "' " |
| 481 << "already registered concrete"; | 492 << "already registered concrete"; |
| 482 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) | 493 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) |
| 483 << "Parent '" << info.parent_key_system << "' already registered"; | 494 << "Parent '" << info.parent_key_system << "' already registered"; |
| 484 parent_key_system_map_[info.parent_key_system] = info.key_system; | 495 parent_key_system_map_[info.parent_key_system] = info.key_system; |
| 485 } | 496 } |
| 486 } | 497 } |
| 487 } | 498 } |
| 488 | 499 |
| 489 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { | 500 bool KeySystemsImpl::IsConcreteSupportedKeySystem( |
| 501 const std::string& key_system) { | |
| 490 DCHECK(thread_checker_.CalledOnValidThread()); | 502 DCHECK(thread_checker_.CalledOnValidThread()); |
| 491 return concrete_key_system_map_.count(key_system) != 0; | 503 return concrete_key_system_map_.count(key_system) != 0; |
| 492 } | 504 } |
| 493 | 505 |
| 494 bool KeySystems::IsSupportedContainer( | 506 bool KeySystemsImpl::IsSupportedContainer( |
| 495 const std::string& container, | 507 const std::string& container, |
| 496 SupportedCodecs key_system_supported_codecs) const { | 508 SupportedCodecs key_system_supported_codecs) const { |
| 497 DCHECK(thread_checker_.CalledOnValidThread()); | 509 DCHECK(thread_checker_.CalledOnValidThread()); |
| 498 DCHECK(!container.empty()); | 510 DCHECK(!container.empty()); |
| 499 | 511 |
| 500 // When checking container support for EME, "audio/foo" should be treated the | 512 // When checking container support for EME, "audio/foo" should be treated the |
| 501 // same as "video/foo". Convert the |container| to achieve this. | 513 // same as "video/foo". Convert the |container| to achieve this. |
| 502 // TODO(xhwang): Replace this with real checks against supported initDataTypes | 514 // TODO(xhwang): Replace this with real checks against supported initDataTypes |
| 503 // combined with supported demuxers. | 515 // combined with supported demuxers. |
| 504 std::string canonical_container = container; | 516 std::string canonical_container = container; |
| 505 if (container.find("audio/") == 0) | 517 if (container.find("audio/") == 0) |
| 506 canonical_container.replace(0, 6, "video/"); | 518 canonical_container.replace(0, 6, "video/"); |
| 507 | 519 |
| 508 // A container is supported iif at least one codec in that container is | 520 // A container is supported iif at least one codec in that container is |
| 509 // supported. | 521 // supported. |
| 510 SupportedCodecs supported_codecs = | 522 SupportedCodecs supported_codecs = |
| 511 GetCodecMaskForContainer(canonical_container); | 523 GetCodecMaskForContainer(canonical_container); |
| 512 return (supported_codecs & key_system_supported_codecs) != 0; | 524 return (supported_codecs & key_system_supported_codecs) != 0; |
| 513 } | 525 } |
| 514 | 526 |
| 515 bool KeySystems::IsSupportedContainerAndCodecs( | 527 bool KeySystemsImpl::IsSupportedContainerAndCodecs( |
| 516 const std::string& container, | 528 const std::string& container, |
| 517 const std::vector<std::string>& codecs, | 529 const std::vector<std::string>& codecs, |
| 518 SupportedCodecs key_system_supported_codecs) const { | 530 SupportedCodecs key_system_supported_codecs) const { |
| 519 DCHECK(thread_checker_.CalledOnValidThread()); | 531 DCHECK(thread_checker_.CalledOnValidThread()); |
| 520 DCHECK(!container.empty()); | 532 DCHECK(!container.empty()); |
| 521 DCHECK(!codecs.empty()); | 533 DCHECK(!codecs.empty()); |
| 522 DCHECK(IsSupportedContainer(container, key_system_supported_codecs)); | 534 DCHECK(IsSupportedContainer(container, key_system_supported_codecs)); |
| 523 | 535 |
| 524 SupportedCodecs container_supported_codecs = | 536 SupportedCodecs container_supported_codecs = |
| 525 GetCodecMaskForContainer(container); | 537 GetCodecMaskForContainer(container); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 537 return false; | 549 return false; |
| 538 | 550 |
| 539 // Unsupported codec/container combination, e.g. "video/webm" and "avc1". | 551 // Unsupported codec/container combination, e.g. "video/webm" and "avc1". |
| 540 if (!(codec & container_supported_codecs)) | 552 if (!(codec & container_supported_codecs)) |
| 541 return false; | 553 return false; |
| 542 } | 554 } |
| 543 | 555 |
| 544 return true; | 556 return true; |
| 545 } | 557 } |
| 546 | 558 |
| 547 bool KeySystems::IsSupportedKeySystem(const std::string& key_system) { | 559 bool KeySystemsImpl::IsSupportedKeySystem(const std::string& key_system) { |
| 548 DCHECK(thread_checker_.CalledOnValidThread()); | 560 DCHECK(thread_checker_.CalledOnValidThread()); |
| 549 // Unprefixed EME only supports concrete key systems. | 561 // Unprefixed EME only supports concrete key systems. |
| 550 return concrete_key_system_map_.count(key_system) != 0; | 562 return concrete_key_system_map_.count(key_system) != 0; |
| 551 } | 563 } |
| 552 | 564 |
| 553 bool KeySystems::IsSupportedKeySystemWithInitDataType( | 565 bool KeySystemsImpl::IsSupportedKeySystemWithInitDataType( |
| 554 const std::string& key_system, | 566 const std::string& key_system, |
| 555 const std::string& init_data_type) { | 567 const std::string& init_data_type) { |
| 556 DCHECK(thread_checker_.CalledOnValidThread()); | 568 DCHECK(thread_checker_.CalledOnValidThread()); |
| 557 | 569 |
| 558 // Locate |key_system|. Only concrete key systems are supported in unprefixed. | 570 // Locate |key_system|. Only concrete key systems are supported in unprefixed. |
| 559 KeySystemInfoMap::const_iterator key_system_iter = | 571 KeySystemInfoMap::const_iterator key_system_iter = |
| 560 concrete_key_system_map_.find(key_system); | 572 concrete_key_system_map_.find(key_system); |
| 561 if (key_system_iter == concrete_key_system_map_.end()) | 573 if (key_system_iter == concrete_key_system_map_.end()) |
| 562 return false; | 574 return false; |
| 563 | 575 |
| 564 // Check |init_data_type| and |key_system| x |init_data_type|. | 576 // Check |init_data_type| and |key_system| x |init_data_type|. |
| 565 const KeySystemInfo& info = key_system_iter->second; | 577 const KeySystemInfo& info = key_system_iter->second; |
| 566 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); | 578 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); |
| 567 return (info.supported_init_data_types & eme_init_data_type) != 0; | 579 return (info.supported_init_data_types & eme_init_data_type) != 0; |
| 568 } | 580 } |
| 569 | 581 |
| 570 // TODO(sandersd): Reorganize to be more similar to | 582 bool KeySystemsImpl::PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 571 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be | |
| 572 // required; http://crbug.com/417461. | |
| 573 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( | |
| 574 const std::string& mime_type, | 583 const std::string& mime_type, |
| 575 const std::vector<std::string>& codecs, | 584 const std::vector<std::string>& codecs, |
| 576 const std::string& key_system, | 585 const std::string& key_system) { |
| 577 bool is_prefixed) { | |
| 578 DCHECK(thread_checker_.CalledOnValidThread()); | 586 DCHECK(thread_checker_.CalledOnValidThread()); |
| 579 const bool report_to_uma = is_prefixed; | |
| 580 | 587 |
| 581 // If |is_prefixed| and |key_system| is a parent key system, use its concrete | 588 const std::string& concrete_key_system = |
| 582 // child. | 589 PrefixedGetConcreteKeySystemNameFor(key_system); |
| 583 const std::string& concrete_key_system = is_prefixed ? | |
| 584 PrefixedGetConcreteKeySystemNameFor(key_system) : | |
| 585 key_system; | |
| 586 | 590 |
| 587 bool has_type = !mime_type.empty(); | 591 bool has_type = !mime_type.empty(); |
| 588 | 592 |
| 589 if (report_to_uma) | 593 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); |
| 590 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); | |
| 591 | 594 |
| 592 // Check key system support. | 595 // Check key system support. |
| 593 KeySystemInfoMap::const_iterator key_system_iter = | 596 KeySystemInfoMap::const_iterator key_system_iter = |
| 594 concrete_key_system_map_.find(concrete_key_system); | 597 concrete_key_system_map_.find(concrete_key_system); |
| 595 if (key_system_iter == concrete_key_system_map_.end()) | 598 if (key_system_iter == concrete_key_system_map_.end()) |
| 596 return false; | 599 return false; |
| 597 | 600 |
| 598 if (report_to_uma) | 601 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); |
| 599 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); | |
| 600 | 602 |
| 601 if (!has_type) { | 603 if (!has_type) { |
| 602 DCHECK(codecs.empty()); | 604 DCHECK(codecs.empty()); |
| 603 return true; | 605 return true; |
| 604 } | 606 } |
| 605 | 607 |
| 606 SupportedCodecs key_system_supported_codecs = | 608 SupportedCodecs key_system_supported_codecs = |
| 607 key_system_iter->second.supported_codecs; | 609 key_system_iter->second.supported_codecs; |
| 608 | 610 |
| 609 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) | 611 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) |
| 610 return false; | 612 return false; |
| 611 | 613 |
| 612 if (!codecs.empty() && | 614 if (!codecs.empty() && |
| 613 !IsSupportedContainerAndCodecs( | 615 !IsSupportedContainerAndCodecs( |
| 614 mime_type, codecs, key_system_supported_codecs)) { | 616 mime_type, codecs, key_system_supported_codecs)) { |
| 615 return false; | 617 return false; |
| 616 } | 618 } |
| 617 | 619 |
| 618 if (report_to_uma) | 620 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); |
| 619 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); | 621 |
| 620 return true; | 622 return true; |
| 621 } | 623 } |
| 622 | 624 |
| 623 std::string KeySystems::GetKeySystemNameForUMA( | 625 bool KeySystemsImpl::IsSupportedKeySystemWithMediaMimeType( |
| 626 const std::string& mime_type, | |
| 627 const std::vector<std::string>& codecs, | |
| 624 const std::string& key_system) const { | 628 const std::string& key_system) const { |
| 625 DCHECK(thread_checker_.CalledOnValidThread()); | 629 DCHECK(thread_checker_.CalledOnValidThread()); |
| 626 | 630 |
| 631 KeySystemInfoMap::const_iterator key_system_iter = | |
| 632 concrete_key_system_map_.find(key_system); | |
| 633 if (key_system_iter == concrete_key_system_map_.end()) | |
| 634 return false; | |
| 635 | |
| 636 if (!mime_type.empty()) { | |
|
ddorwin
2015/03/20 00:55:03
invert
sandersd (OOO until July 31)
2015/03/20 22:53:19
Done.
| |
| 637 DCHECK(codecs.empty()); | |
| 638 return true; | |
| 639 } | |
| 640 | |
| 641 SupportedCodecs key_system_supported_codecs = | |
| 642 key_system_iter->second.supported_codecs; | |
| 643 | |
| 644 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) | |
| 645 return false; | |
| 646 | |
| 647 if (!codecs.empty() && | |
| 648 !IsSupportedContainerAndCodecs( | |
| 649 mime_type, codecs, key_system_supported_codecs)) { | |
| 650 return false; | |
| 651 } | |
| 652 | |
| 653 return true; | |
| 654 } | |
| 655 | |
| 656 std::string KeySystemsImpl::GetKeySystemNameForUMA( | |
| 657 const std::string& key_system) const { | |
| 658 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 659 | |
| 627 KeySystemNameForUMAMap::const_iterator iter = | 660 KeySystemNameForUMAMap::const_iterator iter = |
| 628 key_system_name_for_uma_map_.find(key_system); | 661 key_system_name_for_uma_map_.find(key_system); |
| 629 if (iter == key_system_name_for_uma_map_.end()) | 662 if (iter == key_system_name_for_uma_map_.end()) |
| 630 return kUnknownKeySystemNameForUMA; | 663 return kUnknownKeySystemNameForUMA; |
| 631 | 664 |
| 632 return iter->second; | 665 return iter->second; |
| 633 } | 666 } |
| 634 | 667 |
| 635 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { | 668 bool KeySystemsImpl::UseAesDecryptor(const std::string& concrete_key_system) { |
| 636 DCHECK(thread_checker_.CalledOnValidThread()); | 669 DCHECK(thread_checker_.CalledOnValidThread()); |
| 637 | 670 |
| 638 KeySystemInfoMap::const_iterator key_system_iter = | 671 KeySystemInfoMap::const_iterator key_system_iter = |
| 639 concrete_key_system_map_.find(concrete_key_system); | 672 concrete_key_system_map_.find(concrete_key_system); |
| 640 if (key_system_iter == concrete_key_system_map_.end()) { | 673 if (key_system_iter == concrete_key_system_map_.end()) { |
| 641 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 674 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
| 642 return false; | 675 return false; |
| 643 } | 676 } |
| 644 | 677 |
| 645 return key_system_iter->second.use_aes_decryptor; | 678 return key_system_iter->second.use_aes_decryptor; |
| 646 } | 679 } |
| 647 | 680 |
| 648 #if defined(ENABLE_PEPPER_CDMS) | 681 #if defined(ENABLE_PEPPER_CDMS) |
| 649 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { | 682 std::string KeySystemsImpl::GetPepperType( |
| 683 const std::string& concrete_key_system) { | |
| 650 DCHECK(thread_checker_.CalledOnValidThread()); | 684 DCHECK(thread_checker_.CalledOnValidThread()); |
| 651 | 685 |
| 652 KeySystemInfoMap::const_iterator key_system_iter = | 686 KeySystemInfoMap::const_iterator key_system_iter = |
| 653 concrete_key_system_map_.find(concrete_key_system); | 687 concrete_key_system_map_.find(concrete_key_system); |
| 654 if (key_system_iter == concrete_key_system_map_.end()) { | 688 if (key_system_iter == concrete_key_system_map_.end()) { |
| 655 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 689 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
| 656 return std::string(); | 690 return std::string(); |
| 657 } | 691 } |
| 658 | 692 |
| 659 const std::string& type = key_system_iter->second.pepper_type; | 693 const std::string& type = key_system_iter->second.pepper_type; |
| 660 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 694 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
| 661 return type; | 695 return type; |
| 662 } | 696 } |
| 663 #endif | 697 #endif |
| 664 | 698 |
| 665 EmeConfigRule KeySystems::GetRobustnessConfigRule( | 699 bool KeySystemsImpl::IsSupportedCodecCombination( |
| 666 const std::string& key_system, | 700 const std::string& key_system, |
| 667 EmeMediaType media_type, | 701 EmeMediaType media_type, |
| 668 EmeRobustness robustness) { | 702 const std::string& container_mime_type, |
| 703 const std::vector<std::string>& codecs) const { | |
| 704 return IsSupportedKeySystemWithMediaMimeType( | |
|
ddorwin
2015/03/20 00:55:03
TODO to check/use media_type?
sandersd (OOO until July 31)
2015/03/20 22:53:19
Done.
| |
| 705 container_mime_type, codecs, key_system); | |
| 706 } | |
| 707 | |
| 708 EmeConfigRule KeySystemsImpl::GetRobustnessConfigRule( | |
| 709 const std::string& key_system, | |
| 710 EmeMediaType media_type, | |
| 711 EmeRobustness robustness) const { | |
| 669 DCHECK(thread_checker_.CalledOnValidThread()); | 712 DCHECK(thread_checker_.CalledOnValidThread()); |
| 670 | 713 |
| 671 if (robustness == EmeRobustness::INVALID) | 714 if (robustness == EmeRobustness::INVALID) |
| 672 return EmeConfigRule::NOT_SUPPORTED; | 715 return EmeConfigRule::NOT_SUPPORTED; |
| 673 if (robustness == EmeRobustness::EMPTY) | 716 if (robustness == EmeRobustness::EMPTY) |
| 674 return EmeConfigRule::SUPPORTED; | 717 return EmeConfigRule::SUPPORTED; |
| 675 | 718 |
| 676 KeySystemInfoMap::const_iterator key_system_iter = | 719 KeySystemInfoMap::const_iterator key_system_iter = |
| 677 concrete_key_system_map_.find(key_system); | 720 concrete_key_system_map_.find(key_system); |
| 678 if (key_system_iter == concrete_key_system_map_.end()) { | 721 if (key_system_iter == concrete_key_system_map_.end()) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 714 if (media_type == EmeMediaType::VIDEO && | 757 if (media_type == EmeMediaType::VIDEO && |
| 715 max_robustness == EmeRobustness::HW_SECURE_ALL) { | 758 max_robustness == EmeRobustness::HW_SECURE_ALL) { |
| 716 return EmeConfigRule::IDENTIFIER_RECOMMENDED; | 759 return EmeConfigRule::IDENTIFIER_RECOMMENDED; |
| 717 } | 760 } |
| 718 } | 761 } |
| 719 #endif // defined(OS_CHROMEOS) | 762 #endif // defined(OS_CHROMEOS) |
| 720 | 763 |
| 721 return EmeConfigRule::SUPPORTED; | 764 return EmeConfigRule::SUPPORTED; |
| 722 } | 765 } |
| 723 | 766 |
| 724 EmeConfigRule KeySystems::GetPersistentLicenseSessionConfigRule( | 767 EmeConfigRule KeySystemsImpl::GetPersistentLicenseSessionConfigRule( |
| 725 const std::string& key_system) { | 768 const std::string& key_system) const { |
| 726 DCHECK(thread_checker_.CalledOnValidThread()); | 769 DCHECK(thread_checker_.CalledOnValidThread()); |
| 727 | 770 |
| 728 KeySystemInfoMap::const_iterator key_system_iter = | 771 KeySystemInfoMap::const_iterator key_system_iter = |
| 729 concrete_key_system_map_.find(key_system); | 772 concrete_key_system_map_.find(key_system); |
| 730 if (key_system_iter == concrete_key_system_map_.end()) { | 773 if (key_system_iter == concrete_key_system_map_.end()) { |
| 731 NOTREACHED(); | 774 NOTREACHED(); |
| 732 return EmeConfigRule::NOT_SUPPORTED; | 775 return EmeConfigRule::NOT_SUPPORTED; |
| 733 } | 776 } |
| 734 return ConvertSessionTypeSupport( | 777 return ConvertSessionTypeSupport( |
| 735 key_system_iter->second.persistent_license_support); | 778 key_system_iter->second.persistent_license_support); |
| 736 } | 779 } |
| 737 | 780 |
| 738 EmeConfigRule KeySystems::GetPersistentReleaseMessageSessionConfigRule( | 781 EmeConfigRule KeySystemsImpl::GetPersistentReleaseMessageSessionConfigRule( |
| 739 const std::string& key_system) { | 782 const std::string& key_system) const { |
| 740 DCHECK(thread_checker_.CalledOnValidThread()); | 783 DCHECK(thread_checker_.CalledOnValidThread()); |
| 741 | 784 |
| 742 KeySystemInfoMap::const_iterator key_system_iter = | 785 KeySystemInfoMap::const_iterator key_system_iter = |
| 743 concrete_key_system_map_.find(key_system); | 786 concrete_key_system_map_.find(key_system); |
| 744 if (key_system_iter == concrete_key_system_map_.end()) { | 787 if (key_system_iter == concrete_key_system_map_.end()) { |
| 745 NOTREACHED(); | 788 NOTREACHED(); |
| 746 return EmeConfigRule::NOT_SUPPORTED; | 789 return EmeConfigRule::NOT_SUPPORTED; |
| 747 } | 790 } |
| 748 return ConvertSessionTypeSupport( | 791 return ConvertSessionTypeSupport( |
| 749 key_system_iter->second.persistent_release_message_support); | 792 key_system_iter->second.persistent_release_message_support); |
| 750 } | 793 } |
| 751 | 794 |
| 752 EmeConfigRule KeySystems::GetPersistentStateConfigRule( | 795 EmeConfigRule KeySystemsImpl::GetPersistentStateConfigRule( |
| 753 const std::string& key_system, | 796 const std::string& key_system, |
| 754 EmeFeatureRequirement requirement) { | 797 EmeFeatureRequirement requirement) const { |
| 755 DCHECK(thread_checker_.CalledOnValidThread()); | 798 DCHECK(thread_checker_.CalledOnValidThread()); |
| 756 | 799 |
| 757 KeySystemInfoMap::const_iterator key_system_iter = | 800 KeySystemInfoMap::const_iterator key_system_iter = |
| 758 concrete_key_system_map_.find(key_system); | 801 concrete_key_system_map_.find(key_system); |
| 759 if (key_system_iter == concrete_key_system_map_.end()) { | 802 if (key_system_iter == concrete_key_system_map_.end()) { |
| 760 NOTREACHED(); | 803 NOTREACHED(); |
| 761 return EmeConfigRule::NOT_SUPPORTED; | 804 return EmeConfigRule::NOT_SUPPORTED; |
| 762 } | 805 } |
| 763 | 806 |
| 764 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we | 807 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 784 requirement == EME_FEATURE_NOT_ALLOWED) { | 827 requirement == EME_FEATURE_NOT_ALLOWED) { |
| 785 return EmeConfigRule::NOT_SUPPORTED; | 828 return EmeConfigRule::NOT_SUPPORTED; |
| 786 } | 829 } |
| 787 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER && | 830 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER && |
| 788 requirement == EME_FEATURE_REQUIRED) { | 831 requirement == EME_FEATURE_REQUIRED) { |
| 789 return EmeConfigRule::IDENTIFIER_REQUIRED; | 832 return EmeConfigRule::IDENTIFIER_REQUIRED; |
| 790 } | 833 } |
| 791 return EmeConfigRule::SUPPORTED; | 834 return EmeConfigRule::SUPPORTED; |
| 792 } | 835 } |
| 793 | 836 |
| 794 EmeConfigRule KeySystems::GetDistinctiveIdentifierConfigRule( | 837 EmeConfigRule KeySystemsImpl::GetDistinctiveIdentifierConfigRule( |
| 795 const std::string& key_system, | 838 const std::string& key_system, |
| 796 EmeFeatureRequirement requirement) { | 839 EmeFeatureRequirement requirement) const { |
| 797 DCHECK(thread_checker_.CalledOnValidThread()); | 840 DCHECK(thread_checker_.CalledOnValidThread()); |
| 798 | 841 |
| 799 KeySystemInfoMap::const_iterator key_system_iter = | 842 KeySystemInfoMap::const_iterator key_system_iter = |
| 800 concrete_key_system_map_.find(key_system); | 843 concrete_key_system_map_.find(key_system); |
| 801 if (key_system_iter == concrete_key_system_map_.end()) { | 844 if (key_system_iter == concrete_key_system_map_.end()) { |
| 802 NOTREACHED(); | 845 NOTREACHED(); |
| 803 return EmeConfigRule::NOT_SUPPORTED; | 846 return EmeConfigRule::NOT_SUPPORTED; |
| 804 } | 847 } |
| 805 | 848 |
| 806 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL, | 849 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 822 requirement == EME_FEATURE_NOT_ALLOWED) { | 865 requirement == EME_FEATURE_NOT_ALLOWED) { |
| 823 return EmeConfigRule::NOT_SUPPORTED; | 866 return EmeConfigRule::NOT_SUPPORTED; |
| 824 } | 867 } |
| 825 if (support == EME_FEATURE_ALWAYS_ENABLED || | 868 if (support == EME_FEATURE_ALWAYS_ENABLED || |
| 826 requirement == EME_FEATURE_REQUIRED) { | 869 requirement == EME_FEATURE_REQUIRED) { |
| 827 return EmeConfigRule::IDENTIFIER_REQUIRED; | 870 return EmeConfigRule::IDENTIFIER_REQUIRED; |
| 828 } | 871 } |
| 829 return EmeConfigRule::SUPPORTED; | 872 return EmeConfigRule::SUPPORTED; |
| 830 } | 873 } |
| 831 | 874 |
| 832 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 875 void KeySystemsImpl::AddContainerMask(const std::string& container, |
| 876 uint32 mask) { | |
| 833 DCHECK(thread_checker_.CalledOnValidThread()); | 877 DCHECK(thread_checker_.CalledOnValidThread()); |
| 834 DCHECK(!container_to_codec_mask_map_.count(container)); | 878 DCHECK(!container_to_codec_mask_map_.count(container)); |
| 835 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | 879 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); |
| 836 } | 880 } |
| 837 | 881 |
| 838 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | 882 void KeySystemsImpl::AddCodecMask(const std::string& codec, uint32 mask) { |
| 839 DCHECK(thread_checker_.CalledOnValidThread()); | 883 DCHECK(thread_checker_.CalledOnValidThread()); |
| 840 DCHECK(!codec_string_map_.count(codec)); | 884 DCHECK(!codec_string_map_.count(codec)); |
| 841 codec_string_map_[codec] = static_cast<EmeCodec>(mask); | 885 codec_string_map_[codec] = static_cast<EmeCodec>(mask); |
| 842 } | 886 } |
| 843 | 887 |
| 844 //------------------------------------------------------------------------------ | 888 //------------------------------------------------------------------------------ |
|
ddorwin
2015/03/20 00:55:03
nit: This should either be at 893 or duplicated th
| |
| 845 | 889 |
| 890 KeySystems& KeySystems::GetInstance() { | |
| 891 return KeySystemsImpl::GetInstance(); | |
| 892 } | |
| 893 | |
| 846 std::string GetUnprefixedKeySystemName(const std::string& key_system) { | 894 std::string GetUnprefixedKeySystemName(const std::string& key_system) { |
| 847 if (key_system == kClearKeyKeySystem) | 895 if (key_system == kClearKeyKeySystem) |
| 848 return kUnsupportedClearKeyKeySystem; | 896 return kUnsupportedClearKeyKeySystem; |
| 849 | 897 |
| 850 if (key_system == kPrefixedClearKeyKeySystem) | 898 if (key_system == kPrefixedClearKeyKeySystem) |
| 851 return kClearKeyKeySystem; | 899 return kClearKeyKeySystem; |
| 852 | 900 |
| 853 return key_system; | 901 return key_system; |
| 854 } | 902 } |
| 855 | 903 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 868 if (init_data_type == "cenc") { | 916 if (init_data_type == "cenc") { |
| 869 return container == "audio/mp4" || container == "video/mp4"; | 917 return container == "audio/mp4" || container == "video/mp4"; |
| 870 } else if (init_data_type == "webm") { | 918 } else if (init_data_type == "webm") { |
| 871 return container == "audio/webm" || container == "video/webm"; | 919 return container == "audio/webm" || container == "video/webm"; |
| 872 } else { | 920 } else { |
| 873 return true; | 921 return true; |
| 874 } | 922 } |
| 875 } | 923 } |
| 876 | 924 |
| 877 bool PrefixedIsSupportedConcreteKeySystem(const std::string& key_system) { | 925 bool PrefixedIsSupportedConcreteKeySystem(const std::string& key_system) { |
| 878 return KeySystems::GetInstance().IsConcreteSupportedKeySystem(key_system); | 926 return KeySystemsImpl::GetInstance().IsConcreteSupportedKeySystem(key_system); |
| 879 } | 927 } |
| 880 | 928 |
| 881 bool IsSupportedKeySystem(const std::string& key_system) { | 929 bool IsSupportedKeySystem(const std::string& key_system) { |
| 882 if (!KeySystems::GetInstance().IsSupportedKeySystem(key_system)) | 930 if (!KeySystemsImpl::GetInstance().IsSupportedKeySystem(key_system)) |
| 883 return false; | 931 return false; |
| 884 | 932 |
| 885 // TODO(ddorwin): Move this to where we add key systems when prefixed EME is | 933 // TODO(ddorwin): Move this to where we add key systems when prefixed EME is |
| 886 // removed (crbug.com/249976). | 934 // removed (crbug.com/249976). |
| 887 if (!IsPotentiallySupportedKeySystem(key_system)) { | 935 if (!IsPotentiallySupportedKeySystem(key_system)) { |
| 888 // If you encounter this path, see the comments for the above function. | 936 // If you encounter this path, see the comments for the above function. |
| 889 NOTREACHED() << "Unrecognized key system " << key_system | 937 NOTREACHED() << "Unrecognized key system " << key_system |
| 890 << ". See code comments."; | 938 << ". See code comments."; |
| 891 return false; | 939 return false; |
| 892 } | 940 } |
| 893 | 941 |
| 894 return true; | 942 return true; |
| 895 } | 943 } |
| 896 | 944 |
| 897 bool IsSupportedKeySystemWithInitDataType( | 945 bool IsSupportedKeySystemWithInitDataType( |
| 898 const std::string& key_system, | 946 const std::string& key_system, |
| 899 const std::string& init_data_type) { | 947 const std::string& init_data_type) { |
| 900 return KeySystems::GetInstance().IsSupportedKeySystemWithInitDataType( | 948 return KeySystemsImpl::GetInstance().IsSupportedKeySystemWithInitDataType( |
| 901 key_system, init_data_type); | 949 key_system, init_data_type); |
| 902 } | 950 } |
| 903 | 951 |
| 904 bool IsSupportedKeySystemWithMediaMimeType( | 952 bool IsSupportedKeySystemWithMediaMimeType( |
| 905 const std::string& mime_type, | 953 const std::string& mime_type, |
| 906 const std::vector<std::string>& codecs, | 954 const std::vector<std::string>& codecs, |
| 907 const std::string& key_system) { | 955 const std::string& key_system) { |
|
ddorwin
2015/03/20 00:55:03
Eventually, we should make the parameters have a c
sandersd (OOO until July 31)
2015/03/20 22:53:19
Acknowledged.
| |
| 908 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( | 956 return KeySystemsImpl::GetInstance().IsSupportedKeySystemWithMediaMimeType( |
| 909 mime_type, codecs, key_system, false); | 957 mime_type, codecs, key_system); |
| 910 } | 958 } |
| 911 | 959 |
| 912 bool PrefixedIsSupportedKeySystemWithMediaMimeType( | 960 bool PrefixedIsSupportedKeySystemWithMediaMimeType( |
| 913 const std::string& mime_type, | 961 const std::string& mime_type, |
| 914 const std::vector<std::string>& codecs, | 962 const std::vector<std::string>& codecs, |
| 915 const std::string& key_system) { | 963 const std::string& key_system) { |
| 916 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( | 964 return KeySystemsImpl::GetInstance() |
| 917 mime_type, codecs, key_system, true); | 965 .PrefixedIsSupportedKeySystemWithMediaMimeType(mime_type, codecs, |
| 966 key_system); | |
| 918 } | 967 } |
| 919 | 968 |
| 920 std::string GetKeySystemNameForUMA(const std::string& key_system) { | 969 std::string GetKeySystemNameForUMA(const std::string& key_system) { |
| 921 return KeySystems::GetInstance().GetKeySystemNameForUMA(key_system); | 970 return KeySystemsImpl::GetInstance().GetKeySystemNameForUMA(key_system); |
| 922 } | 971 } |
| 923 | 972 |
| 924 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 973 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
| 925 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 974 return KeySystemsImpl::GetInstance().UseAesDecryptor(concrete_key_system); |
| 926 } | 975 } |
| 927 | 976 |
| 928 #if defined(ENABLE_PEPPER_CDMS) | 977 #if defined(ENABLE_PEPPER_CDMS) |
| 929 std::string GetPepperType(const std::string& concrete_key_system) { | 978 std::string GetPepperType(const std::string& concrete_key_system) { |
| 930 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 979 return KeySystemsImpl::GetInstance().GetPepperType(concrete_key_system); |
| 931 } | 980 } |
| 932 #endif | 981 #endif |
| 933 | 982 |
| 934 EmeConfigRule GetRobustnessConfigRule( | |
| 935 const std::string& key_system, | |
| 936 EmeMediaType media_type, | |
| 937 EmeRobustness robustness) { | |
| 938 return KeySystems::GetInstance().GetRobustnessConfigRule( | |
| 939 key_system, media_type, robustness); | |
| 940 } | |
| 941 | |
| 942 EmeConfigRule GetPersistentLicenseSessionConfigRule( | |
| 943 const std::string& key_system) { | |
| 944 return KeySystems::GetInstance().GetPersistentLicenseSessionConfigRule( | |
| 945 key_system); | |
| 946 } | |
| 947 | |
| 948 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( | |
| 949 const std::string& key_system) { | |
| 950 return KeySystems::GetInstance().GetPersistentReleaseMessageSessionConfigRule( | |
| 951 key_system); | |
| 952 } | |
| 953 | |
| 954 EmeConfigRule GetPersistentStateConfigRule( | |
| 955 const std::string& key_system, | |
| 956 EmeFeatureRequirement requirement) { | |
| 957 return KeySystems::GetInstance().GetPersistentStateConfigRule( | |
| 958 key_system, requirement); | |
| 959 } | |
| 960 | |
| 961 EmeConfigRule GetDistinctiveIdentifierConfigRule( | |
| 962 const std::string& key_system, | |
| 963 EmeFeatureRequirement requirement) { | |
| 964 return KeySystems::GetInstance().GetDistinctiveIdentifierConfigRule( | |
| 965 key_system, requirement); | |
| 966 } | |
| 967 | |
| 968 // These two functions are for testing purpose only. The declaration in the | 983 // These two functions are for testing purpose only. The declaration in the |
| 969 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used | 984 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used |
| 970 // by tests but not non-test code. However, this .cc file is compiled as part of | 985 // by tests but not non-test code. However, this .cc file is compiled as part of |
| 971 // "media" where "UNIT_TEST" is not defined. So we need to specify | 986 // "media" where "UNIT_TEST" is not defined. So we need to specify |
| 972 // "MEDIA_EXPORT" here again so that they are visible to tests. | 987 // "MEDIA_EXPORT" here again so that they are visible to tests. |
| 973 | 988 |
| 974 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { | 989 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
| 975 KeySystems::GetInstance().AddContainerMask(container, mask); | 990 KeySystemsImpl::GetInstance().AddContainerMask(container, mask); |
| 976 } | 991 } |
| 977 | 992 |
| 978 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 993 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
| 979 KeySystems::GetInstance().AddCodecMask(codec, mask); | 994 KeySystemsImpl::GetInstance().AddCodecMask(codec, mask); |
| 980 } | 995 } |
| 981 | 996 |
| 982 } // namespace media | 997 } // namespace media |
| OLD | NEW |