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) const; |
188 | |
189 bool IsSupportedKeySystem(const std::string& key_system); | |
190 | 188 |
191 bool IsSupportedKeySystemWithInitDataType( | 189 bool IsSupportedKeySystemWithInitDataType( |
192 const std::string& key_system, | 190 const std::string& key_system, |
193 const std::string& init_data_type); | 191 const std::string& init_data_type) const; |
192 | |
193 bool PrefixedIsSupportedKeySystemWithMediaMimeType( | |
194 const std::string& mime_type, | |
195 const std::vector<std::string>& codecs, | |
196 const std::string& key_system); | |
194 | 197 |
195 bool IsSupportedKeySystemWithMediaMimeType( | 198 bool IsSupportedKeySystemWithMediaMimeType( |
196 const std::string& mime_type, | 199 const std::string& mime_type, |
197 const std::vector<std::string>& codecs, | 200 const std::vector<std::string>& codecs, |
198 const std::string& key_system, | 201 const std::string& key_system) const; |
199 bool is_prefixed); | |
200 | 202 |
201 std::string GetKeySystemNameForUMA(const std::string& key_system) const; | 203 std::string GetKeySystemNameForUMA(const std::string& key_system) const; |
202 | 204 |
203 bool UseAesDecryptor(const std::string& concrete_key_system); | 205 bool UseAesDecryptor(const std::string& concrete_key_system) const; |
204 | 206 |
205 #if defined(ENABLE_PEPPER_CDMS) | 207 #if defined(ENABLE_PEPPER_CDMS) |
206 std::string GetPepperType(const std::string& concrete_key_system); | 208 std::string GetPepperType(const std::string& concrete_key_system) const; |
207 #endif | 209 #endif |
208 | 210 |
211 void AddContainerMask(const std::string& container, uint32 mask); | |
212 void AddCodecMask(const std::string& codec, uint32 mask); | |
213 | |
214 // Implementation of KeySystems interface. | |
215 bool IsSupportedKeySystem(const std::string& key_system) const override; | |
216 | |
217 bool IsSupportedCodecCombination( | |
218 const std::string& key_system, | |
219 EmeMediaType media_type, | |
220 const std::string& container_mime_type, | |
221 const std::vector<std::string>& codecs) const override; | |
222 | |
209 EmeConfigRule GetRobustnessConfigRule( | 223 EmeConfigRule GetRobustnessConfigRule( |
210 const std::string& key_system, | 224 const std::string& key_system, |
211 EmeMediaType media_type, | 225 EmeMediaType media_type, |
212 EmeRobustness robustness); | 226 EmeRobustness robustness) const override; |
213 | 227 |
214 EmeConfigRule GetPersistentLicenseSessionConfigRule( | 228 EmeConfigRule GetPersistentLicenseSessionConfigRule( |
215 const std::string& key_system); | 229 const std::string& key_system) const override; |
216 | 230 |
217 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( | 231 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( |
218 const std::string& key_system); | 232 const std::string& key_system) const override; |
219 | 233 |
220 EmeConfigRule GetPersistentStateConfigRule( | 234 EmeConfigRule GetPersistentStateConfigRule( |
221 const std::string& key_system, | 235 const std::string& key_system, |
222 EmeFeatureRequirement requirement); | 236 EmeFeatureRequirement requirement) const override; |
223 | 237 |
224 EmeConfigRule GetDistinctiveIdentifierConfigRule( | 238 EmeConfigRule GetDistinctiveIdentifierConfigRule( |
225 const std::string& key_system, | 239 const std::string& key_system, |
226 EmeFeatureRequirement requirement); | 240 EmeFeatureRequirement requirement) const override; |
227 | |
228 void AddContainerMask(const std::string& container, uint32 mask); | |
229 void AddCodecMask(const std::string& codec, uint32 mask); | |
230 | 241 |
231 private: | 242 private: |
232 void InitializeUMAInfo(); | 243 void InitializeUMAInfo(); |
233 | 244 |
234 void UpdateSupportedKeySystems(); | 245 void UpdateSupportedKeySystems(); |
235 | 246 |
236 void AddConcreteSupportedKeySystems( | 247 void AddConcreteSupportedKeySystems( |
237 const std::vector<KeySystemInfo>& concrete_key_systems); | 248 const std::vector<KeySystemInfo>& concrete_key_systems); |
238 | 249 |
239 friend struct base::DefaultLazyInstanceTraits<KeySystems>; | 250 friend struct base::DefaultLazyInstanceTraits<KeySystemsImpl>; |
240 | 251 |
241 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap; | 252 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap; |
242 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; | 253 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; |
243 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; | 254 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; |
244 typedef base::hash_map<std::string, EmeCodec> CodecsMap; | 255 typedef base::hash_map<std::string, EmeCodec> CodecsMap; |
245 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; | 256 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; |
246 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; | 257 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; |
247 | 258 |
248 KeySystems(); | 259 KeySystemsImpl(); |
249 ~KeySystems() {} | 260 ~KeySystemsImpl() {} |
250 | 261 |
251 EmeInitDataType GetInitDataTypeForName( | 262 EmeInitDataType GetInitDataTypeForName( |
252 const std::string& init_data_type) const; | 263 const std::string& init_data_type) const; |
253 // TODO(sandersd): Separate container enum from codec mask value. | 264 // TODO(sandersd): Separate container enum from codec mask value. |
254 // http://crbug.com/417440 | 265 // http://crbug.com/417440 |
255 SupportedCodecs GetCodecMaskForContainer( | 266 SupportedCodecs GetCodecMaskForContainer( |
256 const std::string& container) const; | 267 const std::string& container) const; |
257 EmeCodec GetCodecForString(const std::string& codec) const; | 268 EmeCodec GetCodecForString(const std::string& codec) const; |
258 | 269 |
259 const std::string& PrefixedGetConcreteKeySystemNameFor( | 270 const std::string& PrefixedGetConcreteKeySystemNameFor( |
(...skipping 22 matching lines...) Expand all Loading... | |
282 KeySystemsSupportUMA key_systems_support_uma_; | 293 KeySystemsSupportUMA key_systems_support_uma_; |
283 | 294 |
284 InitDataTypesMap init_data_type_name_map_; | 295 InitDataTypesMap init_data_type_name_map_; |
285 ContainerCodecsMap container_to_codec_mask_map_; | 296 ContainerCodecsMap container_to_codec_mask_map_; |
286 CodecsMap codec_string_map_; | 297 CodecsMap codec_string_map_; |
287 KeySystemNameForUMAMap key_system_name_for_uma_map_; | 298 KeySystemNameForUMAMap key_system_name_for_uma_map_; |
288 | 299 |
289 // Makes sure all methods are called from the same thread. | 300 // Makes sure all methods are called from the same thread. |
290 base::ThreadChecker thread_checker_; | 301 base::ThreadChecker thread_checker_; |
291 | 302 |
292 DISALLOW_COPY_AND_ASSIGN(KeySystems); | 303 DISALLOW_COPY_AND_ASSIGN(KeySystemsImpl); |
293 }; | 304 }; |
294 | 305 |
295 static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; | 306 static base::LazyInstance<KeySystemsImpl> g_key_systems = |
307 LAZY_INSTANCE_INITIALIZER; | |
296 | 308 |
297 KeySystems& KeySystems::GetInstance() { | 309 KeySystemsImpl& KeySystemsImpl::GetInstance() { |
298 KeySystems& key_systems = g_key_systems.Get(); | 310 KeySystemsImpl& key_systems = g_key_systems.Get(); |
299 key_systems.UpdateIfNeeded(); | 311 key_systems.UpdateIfNeeded(); |
300 return key_systems; | 312 return key_systems; |
301 } | 313 } |
302 | 314 |
303 // Because we use a LazyInstance, the key systems info must be populated when | 315 // Because we use a LazyInstance, the key systems info must be populated when |
304 // the instance is lazily initiated. | 316 // the instance is lazily initiated. |
305 KeySystems::KeySystems() { | 317 KeySystemsImpl::KeySystemsImpl() { |
306 for (size_t i = 0; i < arraysize(kInitDataTypeNames); ++i) { | 318 for (size_t i = 0; i < arraysize(kInitDataTypeNames); ++i) { |
307 const std::string& name = kInitDataTypeNames[i].name; | 319 const std::string& name = kInitDataTypeNames[i].name; |
308 DCHECK(!init_data_type_name_map_.count(name)); | 320 DCHECK(!init_data_type_name_map_.count(name)); |
309 init_data_type_name_map_[name] = kInitDataTypeNames[i].type; | 321 init_data_type_name_map_[name] = kInitDataTypeNames[i].type; |
310 } | 322 } |
311 for (size_t i = 0; i < arraysize(kContainerToCodecMasks); ++i) { | 323 for (size_t i = 0; i < arraysize(kContainerToCodecMasks); ++i) { |
312 const std::string& name = kContainerToCodecMasks[i].name; | 324 const std::string& name = kContainerToCodecMasks[i].name; |
313 DCHECK(!container_to_codec_mask_map_.count(name)); | 325 DCHECK(!container_to_codec_mask_map_.count(name)); |
314 container_to_codec_mask_map_[name] = kContainerToCodecMasks[i].type; | 326 container_to_codec_mask_map_[name] = kContainerToCodecMasks[i].type; |
315 } | 327 } |
316 for (size_t i = 0; i < arraysize(kCodecStrings); ++i) { | 328 for (size_t i = 0; i < arraysize(kCodecStrings); ++i) { |
317 const std::string& name = kCodecStrings[i].name; | 329 const std::string& name = kCodecStrings[i].name; |
318 DCHECK(!codec_string_map_.count(name)); | 330 DCHECK(!codec_string_map_.count(name)); |
319 codec_string_map_[name] = kCodecStrings[i].type; | 331 codec_string_map_[name] = kCodecStrings[i].type; |
320 } | 332 } |
321 | 333 |
322 InitializeUMAInfo(); | 334 InitializeUMAInfo(); |
323 | 335 |
324 // Always update supported key systems during construction. | 336 // Always update supported key systems during construction. |
325 UpdateSupportedKeySystems(); | 337 UpdateSupportedKeySystems(); |
326 } | 338 } |
327 | 339 |
328 EmeInitDataType KeySystems::GetInitDataTypeForName( | 340 EmeInitDataType KeySystemsImpl::GetInitDataTypeForName( |
329 const std::string& init_data_type) const { | 341 const std::string& init_data_type) const { |
330 InitDataTypesMap::const_iterator iter = | 342 InitDataTypesMap::const_iterator iter = |
331 init_data_type_name_map_.find(init_data_type); | 343 init_data_type_name_map_.find(init_data_type); |
332 if (iter != init_data_type_name_map_.end()) | 344 if (iter != init_data_type_name_map_.end()) |
333 return iter->second; | 345 return iter->second; |
334 return EME_INIT_DATA_TYPE_NONE; | 346 return EME_INIT_DATA_TYPE_NONE; |
335 } | 347 } |
336 | 348 |
337 SupportedCodecs KeySystems::GetCodecMaskForContainer( | 349 SupportedCodecs KeySystemsImpl::GetCodecMaskForContainer( |
338 const std::string& container) const { | 350 const std::string& container) const { |
339 ContainerCodecsMap::const_iterator iter = | 351 ContainerCodecsMap::const_iterator iter = |
340 container_to_codec_mask_map_.find(container); | 352 container_to_codec_mask_map_.find(container); |
341 if (iter != container_to_codec_mask_map_.end()) | 353 if (iter != container_to_codec_mask_map_.end()) |
342 return iter->second; | 354 return iter->second; |
343 return EME_CODEC_NONE; | 355 return EME_CODEC_NONE; |
344 } | 356 } |
345 | 357 |
346 EmeCodec KeySystems::GetCodecForString(const std::string& codec) const { | 358 EmeCodec KeySystemsImpl::GetCodecForString(const std::string& codec) const { |
347 CodecsMap::const_iterator iter = codec_string_map_.find(codec); | 359 CodecsMap::const_iterator iter = codec_string_map_.find(codec); |
348 if (iter != codec_string_map_.end()) | 360 if (iter != codec_string_map_.end()) |
349 return iter->second; | 361 return iter->second; |
350 return EME_CODEC_NONE; | 362 return EME_CODEC_NONE; |
351 } | 363 } |
352 | 364 |
353 const std::string& KeySystems::PrefixedGetConcreteKeySystemNameFor( | 365 const std::string& KeySystemsImpl::PrefixedGetConcreteKeySystemNameFor( |
354 const std::string& key_system) const { | 366 const std::string& key_system) const { |
355 ParentKeySystemMap::const_iterator iter = | 367 ParentKeySystemMap::const_iterator iter = |
356 parent_key_system_map_.find(key_system); | 368 parent_key_system_map_.find(key_system); |
357 if (iter != parent_key_system_map_.end()) | 369 if (iter != parent_key_system_map_.end()) |
358 return iter->second; | 370 return iter->second; |
359 return key_system; | 371 return key_system; |
360 } | 372 } |
361 | 373 |
362 void KeySystems::InitializeUMAInfo() { | 374 void KeySystemsImpl::InitializeUMAInfo() { |
363 DCHECK(thread_checker_.CalledOnValidThread()); | 375 DCHECK(thread_checker_.CalledOnValidThread()); |
364 DCHECK(key_system_name_for_uma_map_.empty()); | 376 DCHECK(key_system_name_for_uma_map_.empty()); |
365 | 377 |
366 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma; | 378 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma; |
367 if (GetMediaClient()) | 379 if (GetMediaClient()) |
368 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma); | 380 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma); |
369 | 381 |
370 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) { | 382 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) { |
371 key_system_name_for_uma_map_[info.key_system] = | 383 key_system_name_for_uma_map_[info.key_system] = |
372 info.key_system_name_for_uma; | 384 info.key_system_name_for_uma; |
373 if (info.reports_key_system_support_to_uma) | 385 if (info.reports_key_system_support_to_uma) |
374 key_systems_support_uma_.AddKeySystemToReport(info.key_system); | 386 key_systems_support_uma_.AddKeySystemToReport(info.key_system); |
375 } | 387 } |
376 | 388 |
377 // Clear Key is always supported. | 389 // Clear Key is always supported. |
378 key_system_name_for_uma_map_[kClearKeyKeySystem] = | 390 key_system_name_for_uma_map_[kClearKeyKeySystem] = |
379 kClearKeyKeySystemNameForUMA; | 391 kClearKeyKeySystemNameForUMA; |
380 } | 392 } |
381 | 393 |
382 void KeySystems::UpdateIfNeeded() { | 394 void KeySystemsImpl::UpdateIfNeeded() { |
383 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded()) | 395 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded()) |
384 UpdateSupportedKeySystems(); | 396 UpdateSupportedKeySystems(); |
385 } | 397 } |
386 | 398 |
387 void KeySystems::UpdateSupportedKeySystems() { | 399 void KeySystemsImpl::UpdateSupportedKeySystems() { |
388 DCHECK(thread_checker_.CalledOnValidThread()); | 400 DCHECK(thread_checker_.CalledOnValidThread()); |
389 concrete_key_system_map_.clear(); | 401 concrete_key_system_map_.clear(); |
390 parent_key_system_map_.clear(); | 402 parent_key_system_map_.clear(); |
391 | 403 |
392 // Build KeySystemInfo. | 404 // Build KeySystemInfo. |
393 std::vector<KeySystemInfo> key_systems_info; | 405 std::vector<KeySystemInfo> key_systems_info; |
394 | 406 |
395 // Add key systems supported by the MediaClient implementation. | 407 // Add key systems supported by the MediaClient implementation. |
396 if (GetMediaClient()) | 408 if (GetMediaClient()) |
397 GetMediaClient()->AddSupportedKeySystems(&key_systems_info); | 409 GetMediaClient()->AddSupportedKeySystems(&key_systems_info); |
398 | 410 |
399 // Clear Key is always supported. | 411 // Clear Key is always supported. |
400 AddClearKey(&key_systems_info); | 412 AddClearKey(&key_systems_info); |
401 | 413 |
402 AddConcreteSupportedKeySystems(key_systems_info); | 414 AddConcreteSupportedKeySystems(key_systems_info); |
403 } | 415 } |
404 | 416 |
405 void KeySystems::AddConcreteSupportedKeySystems( | 417 void KeySystemsImpl::AddConcreteSupportedKeySystems( |
406 const std::vector<KeySystemInfo>& concrete_key_systems) { | 418 const std::vector<KeySystemInfo>& concrete_key_systems) { |
407 DCHECK(thread_checker_.CalledOnValidThread()); | 419 DCHECK(thread_checker_.CalledOnValidThread()); |
408 DCHECK(concrete_key_system_map_.empty()); | 420 DCHECK(concrete_key_system_map_.empty()); |
409 DCHECK(parent_key_system_map_.empty()); | 421 DCHECK(parent_key_system_map_.empty()); |
410 | 422 |
411 for (const KeySystemInfo& info : concrete_key_systems) { | 423 for (const KeySystemInfo& info : concrete_key_systems) { |
412 DCHECK(!info.key_system.empty()); | 424 DCHECK(!info.key_system.empty()); |
413 DCHECK(info.max_audio_robustness != EmeRobustness::INVALID); | 425 DCHECK(info.max_audio_robustness != EmeRobustness::INVALID); |
414 DCHECK(info.max_video_robustness != EmeRobustness::INVALID); | 426 DCHECK(info.max_video_robustness != EmeRobustness::INVALID); |
415 DCHECK(info.persistent_license_support != EME_SESSION_TYPE_INVALID); | 427 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)) | 491 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) |
480 << "Parent '" << info.parent_key_system << "' " | 492 << "Parent '" << info.parent_key_system << "' " |
481 << "already registered concrete"; | 493 << "already registered concrete"; |
482 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) | 494 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) |
483 << "Parent '" << info.parent_key_system << "' already registered"; | 495 << "Parent '" << info.parent_key_system << "' already registered"; |
484 parent_key_system_map_[info.parent_key_system] = info.key_system; | 496 parent_key_system_map_[info.parent_key_system] = info.key_system; |
485 } | 497 } |
486 } | 498 } |
487 } | 499 } |
488 | 500 |
489 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { | 501 bool KeySystemsImpl::IsConcreteSupportedKeySystem( |
502 const std::string& key_system) const { | |
490 DCHECK(thread_checker_.CalledOnValidThread()); | 503 DCHECK(thread_checker_.CalledOnValidThread()); |
491 return concrete_key_system_map_.count(key_system) != 0; | 504 return concrete_key_system_map_.count(key_system) != 0; |
492 } | 505 } |
493 | 506 |
494 bool KeySystems::IsSupportedContainer( | 507 bool KeySystemsImpl::IsSupportedContainer( |
495 const std::string& container, | 508 const std::string& container, |
496 SupportedCodecs key_system_supported_codecs) const { | 509 SupportedCodecs key_system_supported_codecs) const { |
497 DCHECK(thread_checker_.CalledOnValidThread()); | 510 DCHECK(thread_checker_.CalledOnValidThread()); |
498 DCHECK(!container.empty()); | 511 DCHECK(!container.empty()); |
499 | 512 |
500 // When checking container support for EME, "audio/foo" should be treated the | 513 // When checking container support for EME, "audio/foo" should be treated the |
501 // same as "video/foo". Convert the |container| to achieve this. | 514 // same as "video/foo". Convert the |container| to achieve this. |
502 // TODO(xhwang): Replace this with real checks against supported initDataTypes | 515 // TODO(xhwang): Replace this with real checks against supported initDataTypes |
503 // combined with supported demuxers. | 516 // combined with supported demuxers. |
504 std::string canonical_container = container; | 517 std::string canonical_container = container; |
505 if (container.find("audio/") == 0) | 518 if (container.find("audio/") == 0) |
506 canonical_container.replace(0, 6, "video/"); | 519 canonical_container.replace(0, 6, "video/"); |
507 | 520 |
508 // A container is supported iif at least one codec in that container is | 521 // A container is supported iif at least one codec in that container is |
509 // supported. | 522 // supported. |
510 SupportedCodecs supported_codecs = | 523 SupportedCodecs supported_codecs = |
511 GetCodecMaskForContainer(canonical_container); | 524 GetCodecMaskForContainer(canonical_container); |
512 return (supported_codecs & key_system_supported_codecs) != 0; | 525 return (supported_codecs & key_system_supported_codecs) != 0; |
513 } | 526 } |
514 | 527 |
515 bool KeySystems::IsSupportedContainerAndCodecs( | 528 bool KeySystemsImpl::IsSupportedContainerAndCodecs( |
516 const std::string& container, | 529 const std::string& container, |
517 const std::vector<std::string>& codecs, | 530 const std::vector<std::string>& codecs, |
518 SupportedCodecs key_system_supported_codecs) const { | 531 SupportedCodecs key_system_supported_codecs) const { |
519 DCHECK(thread_checker_.CalledOnValidThread()); | 532 DCHECK(thread_checker_.CalledOnValidThread()); |
520 DCHECK(!container.empty()); | 533 DCHECK(!container.empty()); |
521 DCHECK(!codecs.empty()); | 534 DCHECK(!codecs.empty()); |
522 DCHECK(IsSupportedContainer(container, key_system_supported_codecs)); | 535 DCHECK(IsSupportedContainer(container, key_system_supported_codecs)); |
523 | 536 |
524 SupportedCodecs container_supported_codecs = | 537 SupportedCodecs container_supported_codecs = |
525 GetCodecMaskForContainer(container); | 538 GetCodecMaskForContainer(container); |
(...skipping 11 matching lines...) Expand all Loading... | |
537 return false; | 550 return false; |
538 | 551 |
539 // Unsupported codec/container combination, e.g. "video/webm" and "avc1". | 552 // Unsupported codec/container combination, e.g. "video/webm" and "avc1". |
540 if (!(codec & container_supported_codecs)) | 553 if (!(codec & container_supported_codecs)) |
541 return false; | 554 return false; |
542 } | 555 } |
543 | 556 |
544 return true; | 557 return true; |
545 } | 558 } |
546 | 559 |
547 bool KeySystems::IsSupportedKeySystem(const std::string& key_system) { | 560 bool KeySystemsImpl::IsSupportedKeySystemWithInitDataType( |
548 DCHECK(thread_checker_.CalledOnValidThread()); | |
549 // Unprefixed EME only supports concrete key systems. | |
550 return concrete_key_system_map_.count(key_system) != 0; | |
551 } | |
552 | |
553 bool KeySystems::IsSupportedKeySystemWithInitDataType( | |
554 const std::string& key_system, | 561 const std::string& key_system, |
555 const std::string& init_data_type) { | 562 const std::string& init_data_type) const { |
556 DCHECK(thread_checker_.CalledOnValidThread()); | 563 DCHECK(thread_checker_.CalledOnValidThread()); |
557 | 564 |
558 // Locate |key_system|. Only concrete key systems are supported in unprefixed. | 565 // Locate |key_system|. Only concrete key systems are supported in unprefixed. |
559 KeySystemInfoMap::const_iterator key_system_iter = | 566 KeySystemInfoMap::const_iterator key_system_iter = |
560 concrete_key_system_map_.find(key_system); | 567 concrete_key_system_map_.find(key_system); |
561 if (key_system_iter == concrete_key_system_map_.end()) | 568 if (key_system_iter == concrete_key_system_map_.end()) |
562 return false; | 569 return false; |
563 | 570 |
564 // Check |init_data_type| and |key_system| x |init_data_type|. | 571 // Check |init_data_type| and |key_system| x |init_data_type|. |
565 const KeySystemInfo& info = key_system_iter->second; | 572 const KeySystemInfo& info = key_system_iter->second; |
566 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); | 573 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); |
567 return (info.supported_init_data_types & eme_init_data_type) != 0; | 574 return (info.supported_init_data_types & eme_init_data_type) != 0; |
568 } | 575 } |
569 | 576 |
570 // TODO(sandersd): Reorganize to be more similar to | 577 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, | 578 const std::string& mime_type, |
575 const std::vector<std::string>& codecs, | 579 const std::vector<std::string>& codecs, |
576 const std::string& key_system, | 580 const std::string& key_system) { |
577 bool is_prefixed) { | |
578 DCHECK(thread_checker_.CalledOnValidThread()); | 581 DCHECK(thread_checker_.CalledOnValidThread()); |
579 const bool report_to_uma = is_prefixed; | |
580 | 582 |
581 // If |is_prefixed| and |key_system| is a parent key system, use its concrete | 583 const std::string& concrete_key_system = |
582 // child. | 584 PrefixedGetConcreteKeySystemNameFor(key_system); |
583 const std::string& concrete_key_system = is_prefixed ? | |
584 PrefixedGetConcreteKeySystemNameFor(key_system) : | |
585 key_system; | |
586 | 585 |
587 bool has_type = !mime_type.empty(); | 586 bool has_type = !mime_type.empty(); |
588 | 587 |
589 if (report_to_uma) | 588 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); |
590 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); | |
591 | 589 |
592 // Check key system support. | 590 // Check key system support. |
593 KeySystemInfoMap::const_iterator key_system_iter = | 591 KeySystemInfoMap::const_iterator key_system_iter = |
594 concrete_key_system_map_.find(concrete_key_system); | 592 concrete_key_system_map_.find(concrete_key_system); |
595 if (key_system_iter == concrete_key_system_map_.end()) | 593 if (key_system_iter == concrete_key_system_map_.end()) |
596 return false; | 594 return false; |
597 | 595 |
598 if (report_to_uma) | 596 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); |
599 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); | |
600 | 597 |
601 if (!has_type) { | 598 if (!has_type) { |
602 DCHECK(codecs.empty()); | 599 DCHECK(codecs.empty()); |
603 return true; | 600 return true; |
604 } | 601 } |
605 | 602 |
606 SupportedCodecs key_system_supported_codecs = | 603 SupportedCodecs key_system_supported_codecs = |
607 key_system_iter->second.supported_codecs; | 604 key_system_iter->second.supported_codecs; |
608 | 605 |
609 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) | 606 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) |
610 return false; | 607 return false; |
611 | 608 |
612 if (!codecs.empty() && | 609 if (!codecs.empty() && |
613 !IsSupportedContainerAndCodecs( | 610 !IsSupportedContainerAndCodecs( |
614 mime_type, codecs, key_system_supported_codecs)) { | 611 mime_type, codecs, key_system_supported_codecs)) { |
615 return false; | 612 return false; |
616 } | 613 } |
617 | 614 |
618 if (report_to_uma) | 615 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); |
619 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); | 616 |
620 return true; | 617 return true; |
621 } | 618 } |
622 | 619 |
623 std::string KeySystems::GetKeySystemNameForUMA( | 620 bool KeySystemsImpl::IsSupportedKeySystemWithMediaMimeType( |
621 const std::string& mime_type, | |
622 const std::vector<std::string>& codecs, | |
624 const std::string& key_system) const { | 623 const std::string& key_system) const { |
625 DCHECK(thread_checker_.CalledOnValidThread()); | 624 DCHECK(thread_checker_.CalledOnValidThread()); |
626 | 625 |
626 KeySystemInfoMap::const_iterator key_system_iter = | |
627 concrete_key_system_map_.find(key_system); | |
628 if (key_system_iter == concrete_key_system_map_.end()) | |
629 return false; | |
630 | |
631 if (mime_type.empty()) { | |
632 DCHECK(codecs.empty()); | |
633 return true; | |
634 } | |
635 | |
636 SupportedCodecs key_system_supported_codecs = | |
637 key_system_iter->second.supported_codecs; | |
638 | |
639 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) | |
640 return false; | |
641 | |
642 if (!codecs.empty() && | |
643 !IsSupportedContainerAndCodecs( | |
644 mime_type, codecs, key_system_supported_codecs)) { | |
645 return false; | |
646 } | |
647 | |
648 return true; | |
649 } | |
650 | |
651 std::string KeySystemsImpl::GetKeySystemNameForUMA( | |
652 const std::string& key_system) const { | |
653 DCHECK(thread_checker_.CalledOnValidThread()); | |
654 | |
627 KeySystemNameForUMAMap::const_iterator iter = | 655 KeySystemNameForUMAMap::const_iterator iter = |
628 key_system_name_for_uma_map_.find(key_system); | 656 key_system_name_for_uma_map_.find(key_system); |
629 if (iter == key_system_name_for_uma_map_.end()) | 657 if (iter == key_system_name_for_uma_map_.end()) |
630 return kUnknownKeySystemNameForUMA; | 658 return kUnknownKeySystemNameForUMA; |
631 | 659 |
632 return iter->second; | 660 return iter->second; |
633 } | 661 } |
634 | 662 |
635 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { | 663 bool KeySystemsImpl::UseAesDecryptor( |
664 const std::string& concrete_key_system) const { | |
636 DCHECK(thread_checker_.CalledOnValidThread()); | 665 DCHECK(thread_checker_.CalledOnValidThread()); |
637 | 666 |
638 KeySystemInfoMap::const_iterator key_system_iter = | 667 KeySystemInfoMap::const_iterator key_system_iter = |
639 concrete_key_system_map_.find(concrete_key_system); | 668 concrete_key_system_map_.find(concrete_key_system); |
640 if (key_system_iter == concrete_key_system_map_.end()) { | 669 if (key_system_iter == concrete_key_system_map_.end()) { |
641 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 670 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
642 return false; | 671 return false; |
643 } | 672 } |
644 | 673 |
645 return key_system_iter->second.use_aes_decryptor; | 674 return key_system_iter->second.use_aes_decryptor; |
646 } | 675 } |
647 | 676 |
648 #if defined(ENABLE_PEPPER_CDMS) | 677 #if defined(ENABLE_PEPPER_CDMS) |
649 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { | 678 std::string KeySystemsImpl::GetPepperType( |
679 const std::string& concrete_key_system) const { | |
650 DCHECK(thread_checker_.CalledOnValidThread()); | 680 DCHECK(thread_checker_.CalledOnValidThread()); |
651 | 681 |
652 KeySystemInfoMap::const_iterator key_system_iter = | 682 KeySystemInfoMap::const_iterator key_system_iter = |
653 concrete_key_system_map_.find(concrete_key_system); | 683 concrete_key_system_map_.find(concrete_key_system); |
654 if (key_system_iter == concrete_key_system_map_.end()) { | 684 if (key_system_iter == concrete_key_system_map_.end()) { |
655 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 685 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
656 return std::string(); | 686 return std::string(); |
657 } | 687 } |
658 | 688 |
659 const std::string& type = key_system_iter->second.pepper_type; | 689 const std::string& type = key_system_iter->second.pepper_type; |
660 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 690 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
661 return type; | 691 return type; |
662 } | 692 } |
663 #endif | 693 #endif |
664 | 694 |
665 EmeConfigRule KeySystems::GetRobustnessConfigRule( | 695 void KeySystemsImpl::AddContainerMask(const std::string& container, |
696 uint32 mask) { | |
697 DCHECK(thread_checker_.CalledOnValidThread()); | |
698 DCHECK(!container_to_codec_mask_map_.count(container)); | |
699 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | |
700 } | |
701 | |
702 void KeySystemsImpl::AddCodecMask(const std::string& codec, uint32 mask) { | |
703 DCHECK(thread_checker_.CalledOnValidThread()); | |
704 DCHECK(!codec_string_map_.count(codec)); | |
705 codec_string_map_[codec] = static_cast<EmeCodec>(mask); | |
706 } | |
707 | |
708 bool KeySystemsImpl::IsSupportedKeySystem(const std::string& key_system) const { | |
709 DCHECK(thread_checker_.CalledOnValidThread()); | |
710 return concrete_key_system_map_.count(key_system) != 0; | |
711 } | |
712 | |
713 // TODO(sandersd): Make sure that the codecs also match the |media_type|. | |
ddorwin
2015/03/23 17:22:14
Addressed now?
sandersd (OOO until July 31)
2015/03/23 22:27:59
No, this only covers the container, not the codecs
| |
714 // http://crbug.com/457386 | |
715 bool KeySystemsImpl::IsSupportedCodecCombination( | |
666 const std::string& key_system, | 716 const std::string& key_system, |
667 EmeMediaType media_type, | 717 EmeMediaType media_type, |
668 EmeRobustness robustness) { | 718 const std::string& container_mime_type, |
719 const std::vector<std::string>& codecs) const { | |
720 // Make sure the container matches |media_type|. | |
721 switch (media_type) { | |
722 case EmeMediaType::AUDIO: | |
723 if (!StartsWithASCII(container_mime_type, "audio/", true)) | |
724 return false; | |
725 break; | |
726 case EmeMediaType::VIDEO: | |
727 if (!StartsWithASCII(container_mime_type, "video/", true)) | |
728 return false; | |
729 break; | |
730 } | |
731 return IsSupportedKeySystemWithMediaMimeType( | |
732 container_mime_type, codecs, key_system); | |
733 } | |
734 | |
735 EmeConfigRule KeySystemsImpl::GetRobustnessConfigRule( | |
736 const std::string& key_system, | |
737 EmeMediaType media_type, | |
738 EmeRobustness robustness) const { | |
669 DCHECK(thread_checker_.CalledOnValidThread()); | 739 DCHECK(thread_checker_.CalledOnValidThread()); |
670 | 740 |
671 if (robustness == EmeRobustness::INVALID) | 741 if (robustness == EmeRobustness::INVALID) |
672 return EmeConfigRule::NOT_SUPPORTED; | 742 return EmeConfigRule::NOT_SUPPORTED; |
673 if (robustness == EmeRobustness::EMPTY) | 743 if (robustness == EmeRobustness::EMPTY) |
674 return EmeConfigRule::SUPPORTED; | 744 return EmeConfigRule::SUPPORTED; |
675 | 745 |
676 KeySystemInfoMap::const_iterator key_system_iter = | 746 KeySystemInfoMap::const_iterator key_system_iter = |
677 concrete_key_system_map_.find(key_system); | 747 concrete_key_system_map_.find(key_system); |
678 if (key_system_iter == concrete_key_system_map_.end()) { | 748 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 && | 784 if (media_type == EmeMediaType::VIDEO && |
715 max_robustness == EmeRobustness::HW_SECURE_ALL) { | 785 max_robustness == EmeRobustness::HW_SECURE_ALL) { |
716 return EmeConfigRule::IDENTIFIER_RECOMMENDED; | 786 return EmeConfigRule::IDENTIFIER_RECOMMENDED; |
717 } | 787 } |
718 } | 788 } |
719 #endif // defined(OS_CHROMEOS) | 789 #endif // defined(OS_CHROMEOS) |
720 | 790 |
721 return EmeConfigRule::SUPPORTED; | 791 return EmeConfigRule::SUPPORTED; |
722 } | 792 } |
723 | 793 |
724 EmeConfigRule KeySystems::GetPersistentLicenseSessionConfigRule( | 794 EmeConfigRule KeySystemsImpl::GetPersistentLicenseSessionConfigRule( |
725 const std::string& key_system) { | 795 const std::string& key_system) const { |
726 DCHECK(thread_checker_.CalledOnValidThread()); | 796 DCHECK(thread_checker_.CalledOnValidThread()); |
727 | 797 |
728 KeySystemInfoMap::const_iterator key_system_iter = | 798 KeySystemInfoMap::const_iterator key_system_iter = |
729 concrete_key_system_map_.find(key_system); | 799 concrete_key_system_map_.find(key_system); |
730 if (key_system_iter == concrete_key_system_map_.end()) { | 800 if (key_system_iter == concrete_key_system_map_.end()) { |
731 NOTREACHED(); | 801 NOTREACHED(); |
732 return EmeConfigRule::NOT_SUPPORTED; | 802 return EmeConfigRule::NOT_SUPPORTED; |
733 } | 803 } |
734 return ConvertSessionTypeSupport( | 804 return ConvertSessionTypeSupport( |
735 key_system_iter->second.persistent_license_support); | 805 key_system_iter->second.persistent_license_support); |
736 } | 806 } |
737 | 807 |
738 EmeConfigRule KeySystems::GetPersistentReleaseMessageSessionConfigRule( | 808 EmeConfigRule KeySystemsImpl::GetPersistentReleaseMessageSessionConfigRule( |
739 const std::string& key_system) { | 809 const std::string& key_system) const { |
740 DCHECK(thread_checker_.CalledOnValidThread()); | 810 DCHECK(thread_checker_.CalledOnValidThread()); |
741 | 811 |
742 KeySystemInfoMap::const_iterator key_system_iter = | 812 KeySystemInfoMap::const_iterator key_system_iter = |
743 concrete_key_system_map_.find(key_system); | 813 concrete_key_system_map_.find(key_system); |
744 if (key_system_iter == concrete_key_system_map_.end()) { | 814 if (key_system_iter == concrete_key_system_map_.end()) { |
745 NOTREACHED(); | 815 NOTREACHED(); |
746 return EmeConfigRule::NOT_SUPPORTED; | 816 return EmeConfigRule::NOT_SUPPORTED; |
747 } | 817 } |
748 return ConvertSessionTypeSupport( | 818 return ConvertSessionTypeSupport( |
749 key_system_iter->second.persistent_release_message_support); | 819 key_system_iter->second.persistent_release_message_support); |
750 } | 820 } |
751 | 821 |
752 EmeConfigRule KeySystems::GetPersistentStateConfigRule( | 822 EmeConfigRule KeySystemsImpl::GetPersistentStateConfigRule( |
753 const std::string& key_system, | 823 const std::string& key_system, |
754 EmeFeatureRequirement requirement) { | 824 EmeFeatureRequirement requirement) const { |
755 DCHECK(thread_checker_.CalledOnValidThread()); | 825 DCHECK(thread_checker_.CalledOnValidThread()); |
756 | 826 |
757 KeySystemInfoMap::const_iterator key_system_iter = | 827 KeySystemInfoMap::const_iterator key_system_iter = |
758 concrete_key_system_map_.find(key_system); | 828 concrete_key_system_map_.find(key_system); |
759 if (key_system_iter == concrete_key_system_map_.end()) { | 829 if (key_system_iter == concrete_key_system_map_.end()) { |
760 NOTREACHED(); | 830 NOTREACHED(); |
761 return EmeConfigRule::NOT_SUPPORTED; | 831 return EmeConfigRule::NOT_SUPPORTED; |
762 } | 832 } |
763 | 833 |
764 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we | 834 // 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) { | 854 requirement == EME_FEATURE_NOT_ALLOWED) { |
785 return EmeConfigRule::NOT_SUPPORTED; | 855 return EmeConfigRule::NOT_SUPPORTED; |
786 } | 856 } |
787 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER && | 857 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER && |
788 requirement == EME_FEATURE_REQUIRED) { | 858 requirement == EME_FEATURE_REQUIRED) { |
789 return EmeConfigRule::IDENTIFIER_REQUIRED; | 859 return EmeConfigRule::IDENTIFIER_REQUIRED; |
790 } | 860 } |
791 return EmeConfigRule::SUPPORTED; | 861 return EmeConfigRule::SUPPORTED; |
792 } | 862 } |
793 | 863 |
794 EmeConfigRule KeySystems::GetDistinctiveIdentifierConfigRule( | 864 EmeConfigRule KeySystemsImpl::GetDistinctiveIdentifierConfigRule( |
795 const std::string& key_system, | 865 const std::string& key_system, |
796 EmeFeatureRequirement requirement) { | 866 EmeFeatureRequirement requirement) const { |
797 DCHECK(thread_checker_.CalledOnValidThread()); | 867 DCHECK(thread_checker_.CalledOnValidThread()); |
798 | 868 |
799 KeySystemInfoMap::const_iterator key_system_iter = | 869 KeySystemInfoMap::const_iterator key_system_iter = |
800 concrete_key_system_map_.find(key_system); | 870 concrete_key_system_map_.find(key_system); |
801 if (key_system_iter == concrete_key_system_map_.end()) { | 871 if (key_system_iter == concrete_key_system_map_.end()) { |
802 NOTREACHED(); | 872 NOTREACHED(); |
803 return EmeConfigRule::NOT_SUPPORTED; | 873 return EmeConfigRule::NOT_SUPPORTED; |
804 } | 874 } |
805 | 875 |
806 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL, | 876 // 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) { | 892 requirement == EME_FEATURE_NOT_ALLOWED) { |
823 return EmeConfigRule::NOT_SUPPORTED; | 893 return EmeConfigRule::NOT_SUPPORTED; |
824 } | 894 } |
825 if (support == EME_FEATURE_ALWAYS_ENABLED || | 895 if (support == EME_FEATURE_ALWAYS_ENABLED || |
826 requirement == EME_FEATURE_REQUIRED) { | 896 requirement == EME_FEATURE_REQUIRED) { |
827 return EmeConfigRule::IDENTIFIER_REQUIRED; | 897 return EmeConfigRule::IDENTIFIER_REQUIRED; |
828 } | 898 } |
829 return EmeConfigRule::SUPPORTED; | 899 return EmeConfigRule::SUPPORTED; |
830 } | 900 } |
831 | 901 |
832 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 902 KeySystems& KeySystems::GetInstance() { |
833 DCHECK(thread_checker_.CalledOnValidThread()); | 903 return KeySystemsImpl::GetInstance(); |
834 DCHECK(!container_to_codec_mask_map_.count(container)); | |
835 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | |
836 } | |
837 | |
838 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | |
839 DCHECK(thread_checker_.CalledOnValidThread()); | |
840 DCHECK(!codec_string_map_.count(codec)); | |
841 codec_string_map_[codec] = static_cast<EmeCodec>(mask); | |
842 } | 904 } |
843 | 905 |
844 //------------------------------------------------------------------------------ | 906 //------------------------------------------------------------------------------ |
845 | 907 |
846 std::string GetUnprefixedKeySystemName(const std::string& key_system) { | 908 std::string GetUnprefixedKeySystemName(const std::string& key_system) { |
847 if (key_system == kClearKeyKeySystem) | 909 if (key_system == kClearKeyKeySystem) |
848 return kUnsupportedClearKeyKeySystem; | 910 return kUnsupportedClearKeyKeySystem; |
849 | 911 |
850 if (key_system == kPrefixedClearKeyKeySystem) | 912 if (key_system == kPrefixedClearKeyKeySystem) |
851 return kClearKeyKeySystem; | 913 return kClearKeyKeySystem; |
(...skipping 16 matching lines...) Expand all Loading... | |
868 if (init_data_type == "cenc") { | 930 if (init_data_type == "cenc") { |
869 return container == "audio/mp4" || container == "video/mp4"; | 931 return container == "audio/mp4" || container == "video/mp4"; |
870 } else if (init_data_type == "webm") { | 932 } else if (init_data_type == "webm") { |
871 return container == "audio/webm" || container == "video/webm"; | 933 return container == "audio/webm" || container == "video/webm"; |
872 } else { | 934 } else { |
873 return true; | 935 return true; |
874 } | 936 } |
875 } | 937 } |
876 | 938 |
877 bool PrefixedIsSupportedConcreteKeySystem(const std::string& key_system) { | 939 bool PrefixedIsSupportedConcreteKeySystem(const std::string& key_system) { |
878 return KeySystems::GetInstance().IsConcreteSupportedKeySystem(key_system); | 940 return KeySystemsImpl::GetInstance().IsConcreteSupportedKeySystem(key_system); |
879 } | 941 } |
880 | 942 |
881 bool IsSupportedKeySystem(const std::string& key_system) { | 943 bool IsSupportedKeySystem(const std::string& key_system) { |
882 if (!KeySystems::GetInstance().IsSupportedKeySystem(key_system)) | 944 if (!KeySystemsImpl::GetInstance().IsSupportedKeySystem(key_system)) |
883 return false; | 945 return false; |
884 | 946 |
885 // TODO(ddorwin): Move this to where we add key systems when prefixed EME is | 947 // TODO(ddorwin): Move this to where we add key systems when prefixed EME is |
886 // removed (crbug.com/249976). | 948 // removed (crbug.com/249976). |
887 if (!IsPotentiallySupportedKeySystem(key_system)) { | 949 if (!IsPotentiallySupportedKeySystem(key_system)) { |
888 // If you encounter this path, see the comments for the above function. | 950 // If you encounter this path, see the comments for the above function. |
889 NOTREACHED() << "Unrecognized key system " << key_system | 951 NOTREACHED() << "Unrecognized key system " << key_system |
890 << ". See code comments."; | 952 << ". See code comments."; |
891 return false; | 953 return false; |
892 } | 954 } |
893 | 955 |
894 return true; | 956 return true; |
895 } | 957 } |
896 | 958 |
897 bool IsSupportedKeySystemWithInitDataType( | 959 bool IsSupportedKeySystemWithInitDataType( |
898 const std::string& key_system, | 960 const std::string& key_system, |
899 const std::string& init_data_type) { | 961 const std::string& init_data_type) { |
900 return KeySystems::GetInstance().IsSupportedKeySystemWithInitDataType( | 962 return KeySystemsImpl::GetInstance().IsSupportedKeySystemWithInitDataType( |
901 key_system, init_data_type); | 963 key_system, init_data_type); |
902 } | 964 } |
903 | 965 |
904 bool IsSupportedKeySystemWithMediaMimeType( | 966 bool IsSupportedKeySystemWithMediaMimeType( |
905 const std::string& mime_type, | 967 const std::string& mime_type, |
906 const std::vector<std::string>& codecs, | 968 const std::vector<std::string>& codecs, |
907 const std::string& key_system) { | 969 const std::string& key_system) { |
908 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( | 970 return KeySystemsImpl::GetInstance().IsSupportedKeySystemWithMediaMimeType( |
909 mime_type, codecs, key_system, false); | 971 mime_type, codecs, key_system); |
910 } | 972 } |
911 | 973 |
912 bool PrefixedIsSupportedKeySystemWithMediaMimeType( | 974 bool PrefixedIsSupportedKeySystemWithMediaMimeType( |
913 const std::string& mime_type, | 975 const std::string& mime_type, |
914 const std::vector<std::string>& codecs, | 976 const std::vector<std::string>& codecs, |
915 const std::string& key_system) { | 977 const std::string& key_system) { |
916 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( | 978 return KeySystemsImpl::GetInstance() |
917 mime_type, codecs, key_system, true); | 979 .PrefixedIsSupportedKeySystemWithMediaMimeType(mime_type, codecs, |
980 key_system); | |
918 } | 981 } |
919 | 982 |
920 std::string GetKeySystemNameForUMA(const std::string& key_system) { | 983 std::string GetKeySystemNameForUMA(const std::string& key_system) { |
921 return KeySystems::GetInstance().GetKeySystemNameForUMA(key_system); | 984 return KeySystemsImpl::GetInstance().GetKeySystemNameForUMA(key_system); |
922 } | 985 } |
923 | 986 |
924 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 987 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
925 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 988 return KeySystemsImpl::GetInstance().UseAesDecryptor(concrete_key_system); |
926 } | 989 } |
927 | 990 |
928 #if defined(ENABLE_PEPPER_CDMS) | 991 #if defined(ENABLE_PEPPER_CDMS) |
929 std::string GetPepperType(const std::string& concrete_key_system) { | 992 std::string GetPepperType(const std::string& concrete_key_system) { |
930 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 993 return KeySystemsImpl::GetInstance().GetPepperType(concrete_key_system); |
931 } | 994 } |
932 #endif | 995 #endif |
933 | 996 |
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 | 997 // 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 | 998 // 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 | 999 // 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 | 1000 // "media" where "UNIT_TEST" is not defined. So we need to specify |
972 // "MEDIA_EXPORT" here again so that they are visible to tests. | 1001 // "MEDIA_EXPORT" here again so that they are visible to tests. |
973 | 1002 |
974 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { | 1003 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
975 KeySystems::GetInstance().AddContainerMask(container, mask); | 1004 KeySystemsImpl::GetInstance().AddContainerMask(container, mask); |
976 } | 1005 } |
977 | 1006 |
978 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 1007 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
979 KeySystems::GetInstance().AddCodecMask(codec, mask); | 1008 KeySystemsImpl::GetInstance().AddCodecMask(codec, mask); |
980 } | 1009 } |
981 | 1010 |
982 } // namespace media | 1011 } // namespace media |
OLD | NEW |