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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "media/base/key_system_info.h" | 19 #include "media/base/key_system_info.h" |
| 20 #include "media/base/key_system_names.h" |
20 #include "media/base/key_system_properties.h" | 21 #include "media/base/key_system_properties.h" |
21 #include "media/base/media.h" | 22 #include "media/base/media.h" |
22 #include "media/base/media_client.h" | 23 #include "media/base/media_client.h" |
23 #include "media/cdm/key_system_names.h" | |
24 #include "media/media_features.h" | 24 #include "media/media_features.h" |
25 #include "third_party/widevine/cdm/widevine_cdm_common.h" | 25 #include "third_party/widevine/cdm/widevine_cdm_common.h" |
26 | 26 |
27 namespace media { | 27 namespace media { |
28 | 28 |
29 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | |
30 | |
31 // These names are used by UMA. Do not change them! | 29 // These names are used by UMA. Do not change them! |
32 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; | 30 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; |
33 const char kUnknownKeySystemNameForUMA[] = "Unknown"; | 31 const char kUnknownKeySystemNameForUMA[] = "Unknown"; |
34 | 32 |
35 struct NamedCodec { | 33 struct NamedCodec { |
36 const char* name; | 34 const char* name; |
37 EmeCodec type; | 35 EmeCodec type; |
38 }; | 36 }; |
39 | 37 |
40 // Mapping between containers and their codecs. | 38 // Mapping between containers and their codecs. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (robustness == "HW_SECURE_DECODE") | 77 if (robustness == "HW_SECURE_DECODE") |
80 return EmeRobustness::HW_SECURE_DECODE; | 78 return EmeRobustness::HW_SECURE_DECODE; |
81 if (robustness == "HW_SECURE_ALL") | 79 if (robustness == "HW_SECURE_ALL") |
82 return EmeRobustness::HW_SECURE_ALL; | 80 return EmeRobustness::HW_SECURE_ALL; |
83 return EmeRobustness::INVALID; | 81 return EmeRobustness::INVALID; |
84 } | 82 } |
85 | 83 |
86 static void AddClearKey( | 84 static void AddClearKey( |
87 std::vector<std::unique_ptr<KeySystemProperties>>* key_systems) { | 85 std::vector<std::unique_ptr<KeySystemProperties>>* key_systems) { |
88 KeySystemInfo info; | 86 KeySystemInfo info; |
89 info.key_system = kClearKeyKeySystem; | 87 info.key_system = kClearKey; |
90 | 88 |
91 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: | 89 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: |
92 // http://developer.android.com/guide/appendix/media-formats.html | 90 // http://developer.android.com/guide/appendix/media-formats.html |
93 // VP9 support is device dependent. | 91 // VP9 support is device dependent. |
94 | 92 |
95 info.supported_init_data_types = | 93 info.supported_init_data_types = |
96 kInitDataTypeMaskWebM | kInitDataTypeMaskKeyIds; | 94 kInitDataTypeMaskWebM | kInitDataTypeMaskKeyIds; |
97 info.supported_codecs = EME_CODEC_WEBM_ALL; | 95 info.supported_codecs = EME_CODEC_WEBM_ALL; |
98 | 96 |
99 #if defined(OS_ANDROID) | 97 #if defined(OS_ANDROID) |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma; | 347 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma; |
350 if (GetMediaClient()) | 348 if (GetMediaClient()) |
351 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma); | 349 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma); |
352 | 350 |
353 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) { | 351 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) { |
354 key_system_name_for_uma_map_[info.key_system] = | 352 key_system_name_for_uma_map_[info.key_system] = |
355 info.key_system_name_for_uma; | 353 info.key_system_name_for_uma; |
356 } | 354 } |
357 | 355 |
358 // Clear Key is always supported. | 356 // Clear Key is always supported. |
359 key_system_name_for_uma_map_[kClearKeyKeySystem] = | 357 key_system_name_for_uma_map_[kClearKey] = kClearKeyKeySystemNameForUMA; |
360 kClearKeyKeySystemNameForUMA; | |
361 } | 358 } |
362 | 359 |
363 void KeySystemsImpl::UpdateIfNeeded() { | 360 void KeySystemsImpl::UpdateIfNeeded() { |
364 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded()) | 361 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded()) |
365 UpdateSupportedKeySystems(); | 362 UpdateSupportedKeySystems(); |
366 } | 363 } |
367 | 364 |
368 void KeySystemsImpl::UpdateSupportedKeySystems() { | 365 void KeySystemsImpl::UpdateSupportedKeySystems() { |
369 DCHECK(thread_checker_.CalledOnValidThread()); | 366 DCHECK(thread_checker_.CalledOnValidThread()); |
370 key_system_properties_map_.clear(); | 367 key_system_properties_map_.clear(); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 uint32_t mask) { | 854 uint32_t mask) { |
858 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); | 855 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); |
859 } | 856 } |
860 | 857 |
861 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, | 858 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, |
862 uint32_t mask) { | 859 uint32_t mask) { |
863 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); | 860 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); |
864 } | 861 } |
865 | 862 |
866 } // namespace media | 863 } // namespace media |
OLD | NEW |