OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/crypto/key_systems.h" | 5 #include "content/renderer/media/crypto/key_systems.h" |
6 | 6 |
7 #include <map> | |
8 #include <string> | 7 #include <string> |
9 | 8 |
9 #include "base/containers/hash_tables.h" | |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "content/public/common/content_client.h" | 13 #include "content/public/common/content_client.h" |
14 #include "content/public/renderer/content_renderer_client.h" | 14 #include "content/public/renderer/content_renderer_client.h" |
15 #include "content/public/renderer/key_system_info.h" | 15 #include "content/public/renderer/key_system_info.h" |
16 #include "content/renderer/media/crypto/key_systems_support_uma.h" | 16 #include "content/renderer/media/crypto/key_systems_support_uma.h" |
17 #include "media/cdm/encrypted_media_codecs.h" | |
17 | 18 |
18 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) |
19 #include "media/base/android/media_codec_bridge.h" | 20 #include "media/base/android/media_codec_bridge.h" |
20 #endif | 21 #endif |
21 | 22 |
22 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 23 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 | 26 |
26 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 27 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
27 const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 28 const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
28 const char kUnsupportedClearKeyKeySystem[] = "unsupported-org.w3.clearkey"; | 29 const char kUnsupportedClearKeyKeySystem[] = "unsupported-org.w3.clearkey"; |
29 | 30 |
30 const char kAudioWebM[] = "audio/webm"; | 31 using media::SupportedCodecs; |
31 const char kVideoWebM[] = "video/webm"; | 32 using media::SupportedCodecMask; |
32 const char kVorbis[] = "vorbis"; | |
33 const char kVP8[] = "vp8"; | |
34 const char kVP80[] = "vp8.0"; | |
35 | 33 |
34 struct CodecMaskMap { | |
35 const char* type; | |
36 SupportedCodecMask mask; | |
37 }; | |
38 | |
39 // Mapping between container types and the masks of associated codecs. | |
40 // A container is supported iif a codec that belongs to it is supported. | |
ddorwin
2014/04/22 21:24:41
This is the cause of the problem I mentioned earli
xhwang
2014/04/23 17:29:14
Done.
| |
41 // Only audio codec can belong to a "audio/*" container. Both audio and video | |
42 // codecs can belong to a "video/*" container. | |
43 CodecMaskMap kContainerMasks[] = { | |
44 {"audio/webm", media::WEBM_AUDIO}, | |
45 {"video/webm", media::WEBM_CODECS}, | |
ddorwin
2014/04/22 21:24:41
I mentioned this in the .h file later, but see how
xhwang
2014/04/23 17:29:14
Done.
| |
36 #if defined(USE_PROPRIETARY_CODECS) | 46 #if defined(USE_PROPRIETARY_CODECS) |
37 const char kAudioMp4[] = "audio/mp4"; | 47 {"audio/mp4", media::MP4_AUDIO}, |
38 const char kVideoMp4[] = "video/mp4"; | 48 {"video/mp4", media::MP4_CODECS} |
39 const char kMp4a[] = "mp4a"; | |
40 const char kAvc1[] = "avc1"; | |
41 const char kAvc3[] = "avc3"; | |
42 #endif // defined(USE_PROPRIETARY_CODECS) | 49 #endif // defined(USE_PROPRIETARY_CODECS) |
50 }; | |
51 | |
52 // Mapping between codec types and their masks. | |
53 CodecMaskMap kCodecMasks[] = { | |
54 {"vorbis", media::WEBM_VORBIS}, | |
55 {"vp8", media::WEBM_VP8}, | |
56 {"vp8.0", media::WEBM_VP8}, | |
57 #if defined(USE_PROPRIETARY_CODECS) | |
58 {"mp4a", media::MP4_AAC}, | |
59 {"avc1", media::MP4_AVC1}, | |
60 {"avc3", media::MP4_AVC1} | |
61 #endif // defined(USE_PROPRIETARY_CODECS) | |
62 }; | |
43 | 63 |
44 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { | 64 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { |
45 KeySystemInfo info(kClearKeyKeySystem); | 65 KeySystemInfo info(kClearKeyKeySystem); |
46 | 66 |
47 #if defined(OS_ANDROID) | 67 #if defined(OS_ANDROID) |
48 // If MediaCodecBridge is not available. EME should not be enabled at all. | 68 // If MediaCodecBridge is not available. EME should not be enabled at all. |
49 // See SetRuntimeFeatureDefaultsForPlatform(). | 69 // See SetRuntimeFeatureDefaultsForPlatform(). |
50 // VP8 and AVC1 are supported on all MediaCodec implementations: | 70 // VP8 and AVC1 are supported on all MediaCodec implementations: |
51 // http://developer.android.com/guide/appendix/media-formats.html | 71 // http://developer.android.com/guide/appendix/media-formats.html |
52 DCHECK(media::MediaCodecBridge::IsAvailable()); | 72 DCHECK(media::MediaCodecBridge::IsAvailable()); |
53 #endif | 73 #endif |
54 | 74 |
55 info.supported_types[kAudioWebM].insert(kVorbis); | 75 info.supported_codecs = media::WEBM_CODECS; |
ddorwin
2014/04/22 21:24:41
OOC, what will this look like when we selectively
xhwang
2014/04/23 17:29:14
VP9 will be device dependent on Android. So we rea
| |
56 info.supported_types[kVideoWebM] = info.supported_types[kAudioWebM]; | |
57 info.supported_types[kVideoWebM].insert(kVP8); | |
58 info.supported_types[kVideoWebM].insert(kVP80); | |
59 #if defined(USE_PROPRIETARY_CODECS) | 76 #if defined(USE_PROPRIETARY_CODECS) |
60 info.supported_types[kAudioMp4].insert(kMp4a); | 77 info.supported_codecs |= media::MP4_CODECS; |
61 info.supported_types[kVideoMp4] = info.supported_types[kAudioMp4]; | |
62 info.supported_types[kVideoMp4].insert(kAvc1); | |
63 info.supported_types[kVideoMp4].insert(kAvc3); | |
64 #endif // defined(USE_PROPRIETARY_CODECS) | 78 #endif // defined(USE_PROPRIETARY_CODECS) |
65 | 79 |
66 info.use_aes_decryptor = true; | 80 info.use_aes_decryptor = true; |
67 | 81 |
68 concrete_key_systems->push_back(info); | 82 concrete_key_systems->push_back(info); |
69 } | 83 } |
70 | 84 |
71 class KeySystems { | 85 class KeySystems { |
72 public: | 86 public: |
73 static KeySystems& GetInstance(); | 87 static KeySystems& GetInstance(); |
74 | 88 |
75 bool IsConcreteSupportedKeySystem(const std::string& key_system); | 89 bool IsConcreteSupportedKeySystem(const std::string& key_system); |
76 | 90 |
77 bool IsSupportedKeySystemWithMediaMimeType( | 91 bool IsSupportedKeySystemWithMediaMimeType( |
78 const std::string& mime_type, | 92 const std::string& mime_type, |
79 const std::vector<std::string>& codecs, | 93 const std::vector<std::string>& codecs, |
80 const std::string& key_system); | 94 const std::string& key_system); |
81 | 95 |
82 bool UseAesDecryptor(const std::string& concrete_key_system); | 96 bool UseAesDecryptor(const std::string& concrete_key_system); |
83 | 97 |
84 #if defined(ENABLE_PEPPER_CDMS) | 98 #if defined(ENABLE_PEPPER_CDMS) |
85 std::string GetPepperType(const std::string& concrete_key_system); | 99 std::string GetPepperType(const std::string& concrete_key_system); |
86 #endif | 100 #endif |
87 | 101 |
102 void AddContainerMask(const std::string& container, uint32 mask); | |
103 void AddCodecMask(const std::string& codec, uint32 mask); | |
104 | |
88 private: | 105 private: |
89 typedef KeySystemInfo::CodecSet CodecSet; | |
90 typedef KeySystemInfo::ContainerCodecsMap ContainerCodecsMap; | |
91 | |
92 void AddConcreteSupportedKeySystems( | 106 void AddConcreteSupportedKeySystems( |
93 const std::vector<KeySystemInfo>& concrete_key_systems); | 107 const std::vector<KeySystemInfo>& concrete_key_systems); |
94 | 108 |
95 void AddConcreteSupportedKeySystem( | 109 void AddConcreteSupportedKeySystem( |
96 const std::string& key_system, | 110 const std::string& key_system, |
97 bool use_aes_decryptor, | 111 bool use_aes_decryptor, |
98 #if defined(ENABLE_PEPPER_CDMS) | 112 #if defined(ENABLE_PEPPER_CDMS) |
99 const std::string& pepper_type, | 113 const std::string& pepper_type, |
100 #endif | 114 #endif |
101 const ContainerCodecsMap& supported_types, | 115 const SupportedCodecs& supported_codecs, |
ddorwin
2014/04/22 21:24:41
an integer, so can remove '&'
xhwang
2014/04/23 17:29:14
Done.
| |
102 const std::string& parent_key_system); | 116 const std::string& parent_key_system); |
103 | 117 |
104 friend struct base::DefaultLazyInstanceTraits<KeySystems>; | 118 friend struct base::DefaultLazyInstanceTraits<KeySystems>; |
119 friend class KeySystemsTest; | |
ddorwin
2014/04/22 21:24:41
I don't think this is right. This class is local.
xhwang
2014/04/23 17:29:14
I forgot to remove this. Removed.
| |
105 | 120 |
106 struct KeySystemProperties { | 121 struct KeySystemProperties { |
107 KeySystemProperties() : use_aes_decryptor(false) {} | 122 KeySystemProperties() : use_aes_decryptor(false) {} |
108 | 123 |
109 bool use_aes_decryptor; | 124 bool use_aes_decryptor; |
110 #if defined(ENABLE_PEPPER_CDMS) | 125 #if defined(ENABLE_PEPPER_CDMS) |
111 std::string pepper_type; | 126 std::string pepper_type; |
112 #endif | 127 #endif |
113 ContainerCodecsMap supported_types; | 128 SupportedCodecs supported_codecs; |
114 }; | 129 }; |
115 | 130 |
116 typedef std::map<std::string, KeySystemProperties> KeySystemPropertiesMap; | 131 typedef base::hash_map<std::string, KeySystemProperties> |
117 | 132 KeySystemPropertiesMap; |
118 typedef std::map<std::string, std::string> ParentKeySystemMap; | 133 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; |
134 typedef base::hash_map<std::string, SupportedCodecMask> MaskMap; | |
119 | 135 |
120 KeySystems(); | 136 KeySystems(); |
121 ~KeySystems() {} | 137 ~KeySystems() {} |
122 | 138 |
123 bool IsSupportedKeySystemWithContainerAndCodec(const std::string& mime_type, | 139 bool IsSupportedKeySystemWithContainerAndCodec(const std::string& mime_type, |
124 const std::string& codec, | 140 const std::string& codec, |
125 const std::string& key_system); | 141 const std::string& key_system); |
ddorwin
2014/04/22 21:24:41
Should be const method?
xhwang
2014/04/23 17:29:14
This function has been refactored. The new functio
| |
126 | 142 |
127 // Map from key system string to capabilities. | 143 // Map from key system string to capabilities. |
128 KeySystemPropertiesMap concrete_key_system_map_; | 144 KeySystemPropertiesMap concrete_key_system_map_; |
129 | 145 |
130 // Map from parent key system to the concrete key system that should be used | 146 // Map from parent key system to the concrete key system that should be used |
131 // to represent its capabilities. | 147 // to represent its capabilities. |
132 ParentKeySystemMap parent_key_system_map_; | 148 ParentKeySystemMap parent_key_system_map_; |
133 | 149 |
134 KeySystemsSupportUMA key_systems_support_uma_; | 150 KeySystemsSupportUMA key_systems_support_uma_; |
135 | 151 |
152 MaskMap container_masks_; | |
153 MaskMap codec_masks_; | |
154 | |
136 DISALLOW_COPY_AND_ASSIGN(KeySystems); | 155 DISALLOW_COPY_AND_ASSIGN(KeySystems); |
137 }; | 156 }; |
138 | 157 |
139 static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; | 158 static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; |
140 | 159 |
141 KeySystems& KeySystems::GetInstance() { | 160 KeySystems& KeySystems::GetInstance() { |
142 return g_key_systems.Get(); | 161 return g_key_systems.Get(); |
143 } | 162 } |
144 | 163 |
145 // Because we use a LazyInstance, the key systems info must be populated when | 164 // Because we use a LazyInstance, the key systems info must be populated when |
146 // the instance is lazily initiated. | 165 // the instance is lazily initiated. |
147 KeySystems::KeySystems() { | 166 KeySystems::KeySystems() { |
167 // Build container and codec masks for quick look up. | |
168 for (size_t i = 0; i < arraysize(kContainerMasks); ++i) { | |
169 container_masks_[kContainerMasks[i].type] = kContainerMasks[i].mask; | |
ddorwin
2014/04/22 21:24:41
DCHECK(!find())?
xhwang
2014/04/23 17:29:14
Done.
| |
170 } | |
171 for (size_t i = 0; i < arraysize(kCodecMasks); ++i) { | |
172 codec_masks_[kCodecMasks[i].type] = kCodecMasks[i].mask; | |
173 } | |
174 | |
148 std::vector<KeySystemInfo> key_systems_info; | 175 std::vector<KeySystemInfo> key_systems_info; |
149 GetContentClient()->renderer()->AddKeySystems(&key_systems_info); | 176 GetContentClient()->renderer()->AddKeySystems(&key_systems_info); |
150 // Clear Key is always supported. | 177 // Clear Key is always supported. |
151 AddClearKey(&key_systems_info); | 178 AddClearKey(&key_systems_info); |
152 AddConcreteSupportedKeySystems(key_systems_info); | 179 AddConcreteSupportedKeySystems(key_systems_info); |
153 #if defined(WIDEVINE_CDM_AVAILABLE) | 180 #if defined(WIDEVINE_CDM_AVAILABLE) |
154 key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem); | 181 key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem); |
155 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 182 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
156 } | 183 } |
157 | 184 |
158 void KeySystems::AddConcreteSupportedKeySystems( | 185 void KeySystems::AddConcreteSupportedKeySystems( |
159 const std::vector<KeySystemInfo>& concrete_key_systems) { | 186 const std::vector<KeySystemInfo>& concrete_key_systems) { |
160 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { | 187 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { |
161 const KeySystemInfo& key_system_info = concrete_key_systems[i]; | 188 const KeySystemInfo& key_system_info = concrete_key_systems[i]; |
162 AddConcreteSupportedKeySystem(key_system_info.key_system, | 189 AddConcreteSupportedKeySystem(key_system_info.key_system, |
163 key_system_info.use_aes_decryptor, | 190 key_system_info.use_aes_decryptor, |
164 #if defined(ENABLE_PEPPER_CDMS) | 191 #if defined(ENABLE_PEPPER_CDMS) |
165 key_system_info.pepper_type, | 192 key_system_info.pepper_type, |
166 #endif | 193 #endif |
167 key_system_info.supported_types, | 194 key_system_info.supported_codecs, |
168 key_system_info.parent_key_system); | 195 key_system_info.parent_key_system); |
169 } | 196 } |
170 } | 197 } |
171 | 198 |
172 void KeySystems::AddConcreteSupportedKeySystem( | 199 void KeySystems::AddConcreteSupportedKeySystem( |
173 const std::string& concrete_key_system, | 200 const std::string& concrete_key_system, |
174 bool use_aes_decryptor, | 201 bool use_aes_decryptor, |
175 #if defined(ENABLE_PEPPER_CDMS) | 202 #if defined(ENABLE_PEPPER_CDMS) |
176 const std::string& pepper_type, | 203 const std::string& pepper_type, |
177 #endif | 204 #endif |
178 const ContainerCodecsMap& supported_types, | 205 const SupportedCodecs& supported_codecs, |
179 const std::string& parent_key_system) { | 206 const std::string& parent_key_system) { |
180 DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system)) | 207 DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system)) |
181 << "Key system '" << concrete_key_system << "' already registered"; | 208 << "Key system '" << concrete_key_system << "' already registered"; |
182 DCHECK(parent_key_system_map_.find(concrete_key_system) == | 209 DCHECK(parent_key_system_map_.find(concrete_key_system) == |
183 parent_key_system_map_.end()) | 210 parent_key_system_map_.end()) |
184 << "'" << concrete_key_system << " is already registered as a parent"; | 211 << "'" << concrete_key_system << " is already registered as a parent"; |
185 | 212 |
186 KeySystemProperties properties; | 213 KeySystemProperties properties; |
187 properties.use_aes_decryptor = use_aes_decryptor; | 214 properties.use_aes_decryptor = use_aes_decryptor; |
188 #if defined(ENABLE_PEPPER_CDMS) | 215 #if defined(ENABLE_PEPPER_CDMS) |
189 DCHECK_EQ(use_aes_decryptor, pepper_type.empty()); | 216 DCHECK_EQ(use_aes_decryptor, pepper_type.empty()); |
190 properties.pepper_type = pepper_type; | 217 properties.pepper_type = pepper_type; |
191 #endif | 218 #endif |
192 | 219 |
193 properties.supported_types = supported_types; | 220 properties.supported_codecs = supported_codecs; |
194 | 221 |
195 concrete_key_system_map_[concrete_key_system] = properties; | 222 concrete_key_system_map_[concrete_key_system] = properties; |
196 | 223 |
197 if (!parent_key_system.empty()) { | 224 if (!parent_key_system.empty()) { |
198 DCHECK(!IsConcreteSupportedKeySystem(parent_key_system)) | 225 DCHECK(!IsConcreteSupportedKeySystem(parent_key_system)) |
199 << "Parent '" << parent_key_system << "' already registered concrete"; | 226 << "Parent '" << parent_key_system << "' already registered concrete"; |
200 DCHECK(parent_key_system_map_.find(parent_key_system) == | 227 DCHECK(parent_key_system_map_.find(parent_key_system) == |
201 parent_key_system_map_.end()) | 228 parent_key_system_map_.end()) |
202 << "Parent '" << parent_key_system << "' already registered"; | 229 << "Parent '" << parent_key_system << "' already registered"; |
203 parent_key_system_map_[parent_key_system] = concrete_key_system; | 230 parent_key_system_map_[parent_key_system] = concrete_key_system; |
204 } | 231 } |
205 } | 232 } |
206 | 233 |
207 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { | 234 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { |
208 return concrete_key_system_map_.find(key_system) != | 235 return concrete_key_system_map_.find(key_system) != |
209 concrete_key_system_map_.end(); | 236 concrete_key_system_map_.end(); |
210 } | 237 } |
211 | 238 |
212 bool KeySystems::IsSupportedKeySystemWithContainerAndCodec( | 239 bool KeySystems::IsSupportedKeySystemWithContainerAndCodec( |
213 const std::string& mime_type, | 240 const std::string& mime_type, |
214 const std::string& codec, | 241 const std::string& codec, |
ddorwin
2014/04/22 21:24:41
We query each codec? Maybe we should pass multiple
xhwang
2014/04/23 17:29:14
Done.
| |
215 const std::string& key_system) { | 242 const std::string& key_system) { |
216 bool has_type = !mime_type.empty(); | 243 bool has_type = !mime_type.empty(); |
217 DCHECK(has_type || codec.empty()); | 244 DCHECK(has_type || codec.empty()); |
218 | 245 |
219 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); | 246 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); |
220 | 247 |
221 KeySystemPropertiesMap::const_iterator key_system_iter = | 248 KeySystemPropertiesMap::const_iterator key_system_iter = |
222 concrete_key_system_map_.find(key_system); | 249 concrete_key_system_map_.find(key_system); |
223 if (key_system_iter == concrete_key_system_map_.end()) | 250 if (key_system_iter == concrete_key_system_map_.end()) |
224 return false; | 251 return false; |
225 | 252 |
226 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); | 253 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); |
227 | 254 |
228 if (mime_type.empty()) | 255 if (mime_type.empty()) |
229 return true; | 256 return true; |
230 | 257 |
231 const ContainerCodecsMap& mime_types_map = | 258 const SupportedCodecs& supported_codecs = |
ddorwin
2014/04/22 21:24:41
ditto: '&'.
xhwang
2014/04/23 17:29:14
Done.
| |
232 key_system_iter->second.supported_types; | 259 key_system_iter->second.supported_codecs; |
233 ContainerCodecsMap::const_iterator mime_iter = mime_types_map.find(mime_type); | 260 |
ddorwin
2014/04/22 21:24:41
This code is not obvious. It might help to either
xhwang
2014/04/23 17:29:14
Done.
| |
234 if (mime_iter == mime_types_map.end()) | 261 MaskMap::const_iterator container_iter = container_masks_.find(mime_type); |
262 if (container_iter == container_masks_.end() || | |
263 !(container_iter->second & supported_codecs)) { | |
235 return false; | 264 return false; |
265 } | |
236 | 266 |
237 if (codec.empty()) { | 267 if (codec.empty()) { |
238 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); | 268 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); |
239 return true; | 269 return true; |
240 } | 270 } |
241 | 271 |
242 const CodecSet& codecs = mime_iter->second; | 272 MaskMap::const_iterator codec_iter = codec_masks_.find(codec); |
243 if (codecs.find(codec) == codecs.end()) | 273 if (codec_iter == codec_masks_.end() || |
274 !(codec_iter->second & supported_codecs)) { | |
ddorwin
2014/04/22 21:24:41
Even this is a bit confusing.
xhwang
2014/04/23 17:29:14
Done.
| |
275 return false; | |
276 } | |
277 | |
278 // Unsupported codec/container combination, e.g. "video/webm" and "avc1". | |
279 if (!(codec_iter->second & container_iter->second)) | |
244 return false; | 280 return false; |
245 | 281 |
246 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); | 282 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); |
247 return true; | 283 return true; |
248 } | 284 } |
249 | 285 |
250 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( | 286 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( |
251 const std::string& mime_type, | 287 const std::string& mime_type, |
252 const std::vector<std::string>& codecs, | 288 const std::vector<std::string>& codecs, |
253 const std::string& key_system) { | 289 const std::string& key_system) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 331 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
296 return std::string(); | 332 return std::string(); |
297 } | 333 } |
298 | 334 |
299 const std::string& type = key_system_iter->second.pepper_type; | 335 const std::string& type = key_system_iter->second.pepper_type; |
300 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 336 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
301 return type; | 337 return type; |
302 } | 338 } |
303 #endif | 339 #endif |
304 | 340 |
341 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | |
342 DCHECK(container_masks_.find(container) == container_masks_.end()); | |
343 container_masks_[container] = static_cast<media::SupportedCodecMask>(mask); | |
344 } | |
345 | |
346 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | |
347 DCHECK(codec_masks_.find(codec) == codec_masks_.end()); | |
348 codec_masks_[codec] = static_cast<media::SupportedCodecMask>(mask); | |
349 } | |
350 | |
305 //------------------------------------------------------------------------------ | 351 //------------------------------------------------------------------------------ |
306 | 352 |
307 std::string GetUnprefixedKeySystemName(const std::string& key_system) { | 353 std::string GetUnprefixedKeySystemName(const std::string& key_system) { |
308 if (key_system == kClearKeyKeySystem) | 354 if (key_system == kClearKeyKeySystem) |
309 return kUnsupportedClearKeyKeySystem; | 355 return kUnsupportedClearKeyKeySystem; |
310 | 356 |
311 if (key_system == kPrefixedClearKeyKeySystem) | 357 if (key_system == kPrefixedClearKeyKeySystem) |
312 return kClearKeyKeySystem; | 358 return kClearKeyKeySystem; |
313 | 359 |
314 return key_system; | 360 return key_system; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 394 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
349 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 395 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
350 } | 396 } |
351 | 397 |
352 #if defined(ENABLE_PEPPER_CDMS) | 398 #if defined(ENABLE_PEPPER_CDMS) |
353 std::string GetPepperType(const std::string& concrete_key_system) { | 399 std::string GetPepperType(const std::string& concrete_key_system) { |
354 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 400 return KeySystems::GetInstance().GetPepperType(concrete_key_system); |
355 } | 401 } |
356 #endif | 402 #endif |
357 | 403 |
404 void AddContainerMask(const std::string& container, uint32 mask) { | |
405 KeySystems::GetInstance().AddContainerMask(container, mask); | |
406 } | |
407 | |
408 void AddCodecMask(const std::string& codec, uint32 mask) { | |
409 KeySystems::GetInstance().AddCodecMask(codec, mask); | |
410 } | |
411 | |
358 } // namespace content | 412 } // namespace content |
OLD | NEW |