| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); | 389 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); |
| 390 DCHECK(!is_ambiguous); | 390 DCHECK(!is_ambiguous); |
| 391 codecs.insert(codec); | 391 codecs.insert(codec); |
| 392 } | 392 } |
| 393 | 393 |
| 394 strict_format_map_[format_codec_mappings[i].mime_type] = codecs; | 394 strict_format_map_[format_codec_mappings[i].mime_type] = codecs; |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { | 398 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { |
| 399 return media_map_.find(base::StringToLowerASCII(mime_type)) != | 399 return media_map_.find(base::ToLowerASCII(mime_type)) != media_map_.end(); |
| 400 media_map_.end(); | |
| 401 } | 400 } |
| 402 | 401 |
| 403 | 402 |
| 404 bool MimeUtil::AreSupportedMediaCodecs( | 403 bool MimeUtil::AreSupportedMediaCodecs( |
| 405 const std::vector<std::string>& codecs) const { | 404 const std::vector<std::string>& codecs) const { |
| 406 for (size_t i = 0; i < codecs.size(); ++i) { | 405 for (size_t i = 0; i < codecs.size(); ++i) { |
| 407 Codec codec = INVALID_CODEC; | 406 Codec codec = INVALID_CODEC; |
| 408 bool is_ambiguous = true; | 407 bool is_ambiguous = true; |
| 409 if (!StringToCodec(codecs[i], &codec, &is_ambiguous) || | 408 if (!StringToCodec(codecs[i], &codec, &is_ambiguous) || |
| 410 !IsCodecSupported(codec)) { | 409 !IsCodecSupported(codec)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 432 for (std::vector<std::string>::iterator it = codecs_out->begin(); | 431 for (std::vector<std::string>::iterator it = codecs_out->begin(); |
| 433 it != codecs_out->end(); | 432 it != codecs_out->end(); |
| 434 ++it) { | 433 ++it) { |
| 435 size_t found = it->find_first_of('.'); | 434 size_t found = it->find_first_of('.'); |
| 436 if (found != std::string::npos) | 435 if (found != std::string::npos) |
| 437 it->resize(found); | 436 it->resize(found); |
| 438 } | 437 } |
| 439 } | 438 } |
| 440 | 439 |
| 441 bool MimeUtil::IsStrictMediaMimeType(const std::string& mime_type) const { | 440 bool MimeUtil::IsStrictMediaMimeType(const std::string& mime_type) const { |
| 442 return strict_format_map_.find(base::StringToLowerASCII(mime_type)) != | 441 return strict_format_map_.find(base::ToLowerASCII(mime_type)) != |
| 443 strict_format_map_.end(); | 442 strict_format_map_.end(); |
| 444 } | 443 } |
| 445 | 444 |
| 446 SupportsType MimeUtil::IsSupportedStrictMediaMimeType( | 445 SupportsType MimeUtil::IsSupportedStrictMediaMimeType( |
| 447 const std::string& mime_type, | 446 const std::string& mime_type, |
| 448 const std::vector<std::string>& codecs) const { | 447 const std::vector<std::string>& codecs) const { |
| 449 const std::string mime_type_lower_case = base::StringToLowerASCII(mime_type); | 448 const std::string mime_type_lower_case = base::ToLowerASCII(mime_type); |
| 450 StrictMappings::const_iterator it_strict_map = | 449 StrictMappings::const_iterator it_strict_map = |
| 451 strict_format_map_.find(mime_type_lower_case); | 450 strict_format_map_.find(mime_type_lower_case); |
| 452 if (it_strict_map == strict_format_map_.end()) | 451 if (it_strict_map == strict_format_map_.end()) |
| 453 return codecs.empty() ? MayBeSupported : IsNotSupported; | 452 return codecs.empty() ? MayBeSupported : IsNotSupported; |
| 454 | 453 |
| 455 if (it_strict_map->second.empty()) { | 454 if (it_strict_map->second.empty()) { |
| 456 // We get here if the mimetype does not expect a codecs parameter. | 455 // We get here if the mimetype does not expect a codecs parameter. |
| 457 return (codecs.empty() && | 456 return (codecs.empty() && |
| 458 IsDefaultCodecSupportedLowerCase(mime_type_lower_case)) | 457 IsDefaultCodecSupportedLowerCase(mime_type_lower_case)) |
| 459 ? IsSupported | 458 ? IsSupported |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 std::vector<std::string>* codecs_out, | 651 std::vector<std::string>* codecs_out, |
| 653 const bool strip) { | 652 const bool strip) { |
| 654 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); | 653 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); |
| 655 } | 654 } |
| 656 | 655 |
| 657 void RemoveProprietaryMediaTypesAndCodecsForTests() { | 656 void RemoveProprietaryMediaTypesAndCodecsForTests() { |
| 658 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); | 657 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); |
| 659 } | 658 } |
| 660 | 659 |
| 661 } // namespace media | 660 } // namespace media |
| OLD | NEW |