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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 static bool ParseH264CodecID(const std::string& codec_id, | 526 static bool ParseH264CodecID(const std::string& codec_id, |
527 MimeUtil::Codec* codec, | 527 MimeUtil::Codec* codec, |
528 bool* is_ambiguous) { | 528 bool* is_ambiguous) { |
529 // Make sure we have avc1.xxxxxx or avc3.xxxxxx | 529 // Make sure we have avc1.xxxxxx or avc3.xxxxxx |
530 if (codec_id.size() != 11 || | 530 if (codec_id.size() != 11 || |
531 (!base::StartsWith(codec_id, "avc1.", base::CompareCase::SENSITIVE) && | 531 (!base::StartsWith(codec_id, "avc1.", base::CompareCase::SENSITIVE) && |
532 !base::StartsWith(codec_id, "avc3.", base::CompareCase::SENSITIVE))) { | 532 !base::StartsWith(codec_id, "avc3.", base::CompareCase::SENSITIVE))) { |
533 return false; | 533 return false; |
534 } | 534 } |
535 | 535 |
536 std::string profile = base::StringToUpperASCII(codec_id.substr(5, 4)); | 536 std::string profile = base::ToUpperASCII(codec_id.substr(5, 4)); |
537 if (IsValidH264BaselineProfile(profile)) { | 537 if (IsValidH264BaselineProfile(profile)) { |
538 *codec = MimeUtil::H264_BASELINE; | 538 *codec = MimeUtil::H264_BASELINE; |
539 } else if (profile == "4D40") { | 539 } else if (profile == "4D40") { |
540 *codec = MimeUtil::H264_MAIN; | 540 *codec = MimeUtil::H264_MAIN; |
541 } else if (profile == "6400") { | 541 } else if (profile == "6400") { |
542 *codec = MimeUtil::H264_HIGH; | 542 *codec = MimeUtil::H264_HIGH; |
543 } else { | 543 } else { |
544 *codec = MimeUtil::H264_BASELINE; | 544 *codec = MimeUtil::H264_BASELINE; |
545 *is_ambiguous = true; | 545 *is_ambiguous = true; |
546 return true; | 546 return true; |
547 } | 547 } |
548 | 548 |
549 *is_ambiguous = | 549 *is_ambiguous = !IsValidH264Level(base::ToUpperASCII(codec_id.substr(9))); |
550 !IsValidH264Level(base::StringToUpperASCII(codec_id.substr(9))); | |
551 return true; | 550 return true; |
552 } | 551 } |
553 | 552 |
554 bool MimeUtil::StringToCodec(const std::string& codec_id, | 553 bool MimeUtil::StringToCodec(const std::string& codec_id, |
555 Codec* codec, | 554 Codec* codec, |
556 bool* is_ambiguous) const { | 555 bool* is_ambiguous) const { |
557 StringToCodecMappings::const_iterator itr = | 556 StringToCodecMappings::const_iterator itr = |
558 string_to_codec_map_.find(codec_id); | 557 string_to_codec_map_.find(codec_id); |
559 if (itr != string_to_codec_map_.end()) { | 558 if (itr != string_to_codec_map_.end()) { |
560 *codec = itr->second.codec; | 559 *codec = itr->second.codec; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 std::vector<std::string>* codecs_out, | 648 std::vector<std::string>* codecs_out, |
650 const bool strip) { | 649 const bool strip) { |
651 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); | 650 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); |
652 } | 651 } |
653 | 652 |
654 void RemoveProprietaryMediaTypesAndCodecsForTests() { | 653 void RemoveProprietaryMediaTypesAndCodecsForTests() { |
655 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); | 654 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); |
656 } | 655 } |
657 | 656 |
658 } // namespace media | 657 } // namespace media |
OLD | NEW |