OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "media/base/mime_util_internal.h" | 5 #include "media/base/mime_util_internal.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 for (size_t i = 0; i < codecs.size(); ++i) { | 195 for (size_t i = 0; i < codecs.size(); ++i) { |
196 // Parse the string. | 196 // Parse the string. |
197 bool ambiguous_codec_string = false; | 197 bool ambiguous_codec_string = false; |
198 Codec codec = INVALID_CODEC; | 198 Codec codec = INVALID_CODEC; |
199 VideoCodecProfile video_profile = VIDEO_CODEC_PROFILE_UNKNOWN; | 199 VideoCodecProfile video_profile = VIDEO_CODEC_PROFILE_UNKNOWN; |
200 uint8_t video_level = 0; | 200 uint8_t video_level = 0; |
201 VideoColorSpace color_space; | 201 VideoColorSpace color_space; |
202 if (!ParseCodecString(mime_type_lower_case, codecs[i], &codec, | 202 if (!ParseCodecString(mime_type_lower_case, codecs[i], &codec, |
203 &ambiguous_codec_string, &video_profile, &video_level, | 203 &ambiguous_codec_string, &video_profile, &video_level, |
204 &color_space)) { | 204 &color_space)) { |
| 205 DVLOG(2) << __func__ << " Failed to parse codec string:" << codecs[i]; |
205 return IsNotSupported; | 206 return IsNotSupported; |
206 } | 207 } |
207 | 208 |
208 // Bail if codec not in supported list for given container. | 209 // Bail if codec not in supported list for given container. |
209 if (supported_codecs.find(codec) == supported_codecs.end()) | 210 if (supported_codecs.find(codec) == supported_codecs.end()) { |
| 211 DVLOG(2) << __func__ << " Codec " << codecs[i] |
| 212 << " not supported in container " << mime_type_lower_case; |
210 return IsNotSupported; | 213 return IsNotSupported; |
| 214 } |
211 | 215 |
212 // Make conservative guesses to resolve ambiguity before checking platform | 216 // Make conservative guesses to resolve ambiguity before checking platform |
213 // support. H264 and VP9 are the only allowed ambiguous video codec. DO NOT | 217 // support. H264 and VP9 are the only allowed ambiguous video codec. DO NOT |
214 // ADD SUPPORT FOR MORE AMIBIGUOUS STRINGS. | 218 // ADD SUPPORT FOR MORE AMIBIGUOUS STRINGS. |
215 if (codec == MimeUtil::H264 && ambiguous_codec_string) { | 219 if (codec == MimeUtil::H264 && ambiguous_codec_string) { |
216 if (video_profile == VIDEO_CODEC_PROFILE_UNKNOWN) | 220 if (video_profile == VIDEO_CODEC_PROFILE_UNKNOWN) |
217 video_profile = H264PROFILE_BASELINE; | 221 video_profile = H264PROFILE_BASELINE; |
218 if (!IsValidH264Level(video_level)) | 222 if (!IsValidH264Level(video_level)) |
219 video_level = 10; | 223 video_level = 10; |
220 } else if (codec == MimeUtil::VP9 && video_level == 0) { | 224 } else if (codec == MimeUtil::VP9 && video_level == 0) { |
221 // Original VP9 content type (codecs="vp9") does not specify the level. | 225 // Original VP9 content type (codecs="vp9") does not specify the level. |
222 // TODO(chcunningham): Mark this string as ambiguous when new multi-part | 226 // TODO(chcunningham): Mark this string as ambiguous when new multi-part |
223 // VP9 content type is published. | 227 // VP9 content type is published. |
224 video_level = 10; | 228 video_level = 10; |
225 } | 229 } |
226 | 230 |
227 // Check platform support. | 231 // Check platform support. |
228 SupportsType result = | 232 SupportsType result = |
229 IsCodecSupported(mime_type_lower_case, codec, video_profile, | 233 IsCodecSupported(mime_type_lower_case, codec, video_profile, |
230 video_level, color_space, is_encrypted); | 234 video_level, color_space, is_encrypted); |
231 if (result == IsNotSupported) | 235 if (result == IsNotSupported) { |
| 236 DVLOG(2) << __func__ << " Codec " << codecs[i] |
| 237 << " not supported by platform"; |
232 return IsNotSupported; | 238 return IsNotSupported; |
| 239 } |
233 | 240 |
234 // If any codec is "MayBeSupported", return Maybe for the combined result. | 241 // If any codec is "MayBeSupported", return Maybe for the combined result. |
235 // Downgrade to MayBeSupported if we had to guess the meaning of one of the | 242 // Downgrade to MayBeSupported if we had to guess the meaning of one of the |
236 // codec strings. | 243 // codec strings. |
237 if (result == MayBeSupported || | 244 if (result == MayBeSupported || |
238 (result == IsSupported && ambiguous_codec_string)) | 245 (result == IsSupported && ambiguous_codec_string)) |
239 combined_result = MayBeSupported; | 246 combined_result = MayBeSupported; |
240 } | 247 } |
241 | 248 |
242 return combined_result; | 249 return combined_result; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 SupportsType MimeUtil::IsDefaultCodecSupported(const std::string& mime_type, | 834 SupportsType MimeUtil::IsDefaultCodecSupported(const std::string& mime_type, |
828 bool is_encrypted) const { | 835 bool is_encrypted) const { |
829 Codec default_codec = Codec::INVALID_CODEC; | 836 Codec default_codec = Codec::INVALID_CODEC; |
830 if (!GetDefaultCodec(mime_type, &default_codec)) | 837 if (!GetDefaultCodec(mime_type, &default_codec)) |
831 return IsNotSupported; | 838 return IsNotSupported; |
832 return IsSimpleCodecSupported(mime_type, default_codec, is_encrypted); | 839 return IsSimpleCodecSupported(mime_type, default_codec, is_encrypted); |
833 } | 840 } |
834 | 841 |
835 } // namespace internal | 842 } // namespace internal |
836 } // namespace media | 843 } // namespace media |
OLD | NEW |