OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "webkit/media/crypto/key_systems.h" | 7 #include "webkit/media/crypto/key_systems.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 kSupportedFormatKeySystemCombinations[i]; | 59 kSupportedFormatKeySystemCombinations[i]; |
60 std::vector<std::string> mime_type_codecs; | 60 std::vector<std::string> mime_type_codecs; |
61 net::ParseCodecString(combination.codecs_list, | 61 net::ParseCodecString(combination.codecs_list, |
62 &mime_type_codecs, | 62 &mime_type_codecs, |
63 false); | 63 false); |
64 | 64 |
65 CodecMappings codecs; | 65 CodecMappings codecs; |
66 for (size_t j = 0; j < mime_type_codecs.size(); ++j) | 66 for (size_t j = 0; j < mime_type_codecs.size(); ++j) |
67 codecs.insert(mime_type_codecs[j]); | 67 codecs.insert(mime_type_codecs[j]); |
68 // Support the MIME type string alone, without codec(s) specified. | 68 // Support the MIME type string alone, without codec(s) specified. |
69 codecs.insert(""); | 69 codecs.insert(std::string()); |
70 | 70 |
71 // Key systems can be repeated, so there may already be an entry. | 71 // Key systems can be repeated, so there may already be an entry. |
72 KeySystemMappings::iterator key_system_iter = | 72 KeySystemMappings::iterator key_system_iter = |
73 key_system_map_.find(combination.key_system); | 73 key_system_map_.find(combination.key_system); |
74 if (key_system_iter == key_system_map_.end()) { | 74 if (key_system_iter == key_system_map_.end()) { |
75 MimeTypeMappings mime_types_map; | 75 MimeTypeMappings mime_types_map; |
76 mime_types_map[combination.mime_type] = codecs; | 76 mime_types_map[combination.mime_type] = codecs; |
77 key_system_map_[combination.key_system] = mime_types_map; | 77 key_system_map_[combination.key_system] = mime_types_map; |
78 } else { | 78 } else { |
79 MimeTypeMappings& mime_types_map = key_system_iter->second; | 79 MimeTypeMappings& mime_types_map = key_system_iter->second; |
(...skipping 26 matching lines...) Expand all Loading... |
106 | 106 |
107 const CodecMappings& codecs = mime_iter->second; | 107 const CodecMappings& codecs = mime_iter->second; |
108 return (codecs.find(codec) != codecs.end()) && IsSystemCompatible(key_system); | 108 return (codecs.find(codec) != codecs.end()) && IsSystemCompatible(key_system); |
109 } | 109 } |
110 | 110 |
111 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( | 111 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( |
112 const std::string& mime_type, | 112 const std::string& mime_type, |
113 const std::vector<std::string>& codecs, | 113 const std::vector<std::string>& codecs, |
114 const std::string& key_system) { | 114 const std::string& key_system) { |
115 if (codecs.empty()) | 115 if (codecs.empty()) |
116 return IsSupportedKeySystemWithContainerAndCodec(mime_type, "", key_system); | 116 return IsSupportedKeySystemWithContainerAndCodec( |
| 117 mime_type, std::string(), key_system); |
117 | 118 |
118 for (size_t i = 0; i < codecs.size(); ++i) { | 119 for (size_t i = 0; i < codecs.size(); ++i) { |
119 if (!IsSupportedKeySystemWithContainerAndCodec( | 120 if (!IsSupportedKeySystemWithContainerAndCodec( |
120 mime_type, codecs[i], key_system)) | 121 mime_type, codecs[i], key_system)) |
121 return false; | 122 return false; |
122 } | 123 } |
123 | 124 |
124 return true; | 125 return true; |
125 } | 126 } |
126 | 127 |
(...skipping 24 matching lines...) Expand all Loading... |
151 std::string GetPluginType(const std::string& key_system) { | 152 std::string GetPluginType(const std::string& key_system) { |
152 for (int i = 0; i < kNumKeySystemToPluginTypeMapping; ++i) { | 153 for (int i = 0; i < kNumKeySystemToPluginTypeMapping; ++i) { |
153 if (kKeySystemToPluginTypeMapping[i].key_system == key_system) | 154 if (kKeySystemToPluginTypeMapping[i].key_system == key_system) |
154 return kKeySystemToPluginTypeMapping[i].plugin_type; | 155 return kKeySystemToPluginTypeMapping[i].plugin_type; |
155 } | 156 } |
156 | 157 |
157 return std::string(); | 158 return std::string(); |
158 } | 159 } |
159 | 160 |
160 } // namespace webkit_media | 161 } // namespace webkit_media |
OLD | NEW |