OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "webencryptedmediaclient_impl.h" | 5 #include "webencryptedmediaclient_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 static bool IsSupportedContentType( | 129 static bool IsSupportedContentType( |
130 const KeySystems& key_systems, | 130 const KeySystems& key_systems, |
131 const std::string& key_system, | 131 const std::string& key_system, |
132 EmeMediaType media_type, | 132 EmeMediaType media_type, |
133 const std::string& container_mime_type, | 133 const std::string& container_mime_type, |
134 const std::string& codecs) { | 134 const std::string& codecs) { |
135 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid | 135 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid |
136 // parameters can be rejected. http://crbug.com/417561 | 136 // parameters can be rejected. http://crbug.com/417561 |
137 std::string container_lower = base::StringToLowerASCII(container_mime_type); | 137 std::string container_lower = base::StringToLowerASCII(container_mime_type); |
138 | 138 |
139 // Check that |codecs| are supported by the CDM. This check does not handle | 139 // Check that |container_mime_type| and |codecs| are supported by the CDM. |
140 // extended codecs, so extended codec information is stripped. | 140 // This check does not handle extended codecs, so extended codec information |
| 141 // is stripped. |
141 std::vector<std::string> codec_vector; | 142 std::vector<std::string> codec_vector; |
142 net::ParseCodecString(codecs, &codec_vector, true); | 143 net::ParseCodecString(codecs, &codec_vector, true); |
143 if (!key_systems.IsSupportedCodecCombination( | 144 if (!key_systems.IsSupportedCodecCombination( |
144 key_system, media_type, container_lower, codec_vector)) { | 145 key_system, media_type, container_lower, codec_vector)) { |
145 return false; | 146 return false; |
146 } | 147 } |
147 | 148 |
| 149 if (codec_vector.empty()) |
| 150 return true; |
| 151 |
148 // Check that |codecs| are supported by Chrome. This is done primarily to | 152 // Check that |codecs| are supported by Chrome. This is done primarily to |
149 // validate extended codecs, but it also ensures that the CDM cannot support | 153 // validate extended codecs, but it also ensures that the CDM cannot support |
150 // codecs that Chrome does not (which would be bad because it would require | 154 // codecs that Chrome does not (which could complicate the robustness |
151 // considering the accumulated configuration, and could affect whether secure | 155 // algorithm). |
152 // decode is required). | |
153 codec_vector.clear(); | 156 codec_vector.clear(); |
154 net::ParseCodecString(codecs, &codec_vector, false); | 157 net::ParseCodecString(codecs, &codec_vector, false); |
155 return (net::IsSupportedStrictMediaMimeType(container_lower, codec_vector) == | 158 return (net::IsSupportedStrictMediaMimeType(container_lower, codec_vector) == |
156 net::IsSupported); | 159 net::IsSupported); |
157 } | 160 } |
158 | 161 |
159 static bool GetSupportedCapabilities( | 162 static bool GetSupportedCapabilities( |
160 const KeySystems& key_systems, | 163 const KeySystems& key_systems, |
161 const std::string& key_system, | 164 const std::string& key_system, |
162 EmeMediaType media_type, | 165 EmeMediaType media_type, |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 return reporter; | 692 return reporter; |
690 | 693 |
691 // Reporter not found, so create one. | 694 // Reporter not found, so create one. |
692 auto result = | 695 auto result = |
693 reporters_.add(uma_name, make_scoped_ptr(new Reporter(uma_name))); | 696 reporters_.add(uma_name, make_scoped_ptr(new Reporter(uma_name))); |
694 DCHECK(result.second); | 697 DCHECK(result.second); |
695 return result.first->second; | 698 return result.first->second; |
696 } | 699 } |
697 | 700 |
698 } // namespace media | 701 } // namespace media |
OLD | NEW |