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 <algorithm> | 5 #include <algorithm> |
6 #include <iterator> | 6 #include <iterator> |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
917 } | 917 } |
918 | 918 |
919 void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() { | 919 void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() { |
920 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) { | 920 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) { |
921 non_image_map_.erase(proprietary_media_types[i]); | 921 non_image_map_.erase(proprietary_media_types[i]); |
922 media_map_.erase(proprietary_media_types[i]); | 922 media_map_.erase(proprietary_media_types[i]); |
923 } | 923 } |
924 allow_proprietary_codecs_ = false; | 924 allow_proprietary_codecs_ = false; |
925 } | 925 } |
926 | 926 |
927 // Returns true iff |profile_str| conforms to hex string "42y0": y >= 8. Taken | |
DaleCurtis
2014/10/03 21:54:07
Since this is just 8,9 -- why not explicitly enume
wolenetz
2014/10/03 22:27:52
(replying again, in context):
This is actually 8,9
DaleCurtis
2014/10/03 22:33:56
Ahh, sorry the CL description makes it clear, but
wolenetz
2014/10/03 22:42:10
Done.
xhwang
2014/10/03 23:08:06
It's hex, so it can be 'c', 'e' etc.
| |
928 // from Annex A and constraint_set0 in ISO-14496-10. | |
xhwang
2014/10/03 23:08:06
Can you mention 7.3.2.1 and 7.4.2.1 in the spec.
wolenetz
2014/10/04 01:36:40
Done.
| |
929 static bool IsValidH264BaselineProfile(const std::string& profile_str) { | |
930 uint32 constraint_set_bits; | |
931 if (profile_str.size() != 4 || | |
932 profile_str.substr(0, 2) != "42" || | |
933 profile_str.substr(3, 1) != "0" || | |
xhwang
2014/10/03 23:08:06
The substr is a bit overkill; will this work?
ret
xhwang
2014/10/03 23:10:28
Sorry, you still need to convert string to int, fo
wolenetz
2014/10/03 23:51:04
Masking with 0xF1 instead of 0xFF means that we wo
wolenetz
2014/10/04 01:36:40
I'm keeping to just >= 8 (which requires constrain
| |
934 !base::HexStringToUInt(profile_str.substr(2, 1), &constraint_set_bits)) { | |
935 return false; | |
936 } | |
937 | |
938 return (constraint_set_bits & 0x8); | |
DaleCurtis
2014/10/03 22:33:56
Just use >= 8. Let the compiler handle such an opt
wolenetz
2014/10/03 22:42:10
Done.
| |
939 } | |
940 | |
927 static bool IsValidH264Level(const std::string& level_str) { | 941 static bool IsValidH264Level(const std::string& level_str) { |
928 uint32 level; | 942 uint32 level; |
929 if (level_str.size() != 2 || !base::HexStringToUInt(level_str, &level)) | 943 if (level_str.size() != 2 || !base::HexStringToUInt(level_str, &level)) |
930 return false; | 944 return false; |
931 | 945 |
932 // Valid levels taken from Table A-1 in ISO-14496-10. | 946 // Valid levels taken from Table A-1 in ISO-14496-10. |
933 // Essentially |level_str| is toHex(10 * level). | 947 // Essentially |level_str| is toHex(10 * level). |
934 return ((level >= 10 && level <= 13) || | 948 return ((level >= 10 && level <= 13) || |
935 (level >= 20 && level <= 22) || | 949 (level >= 20 && level <= 22) || |
936 (level >= 30 && level <= 32) || | 950 (level >= 30 && level <= 32) || |
937 (level >= 40 && level <= 42) || | 951 (level >= 40 && level <= 42) || |
938 (level >= 50 && level <= 51)); | 952 (level >= 50 && level <= 51)); |
939 } | 953 } |
940 | 954 |
941 // Handle parsing H.264 codec IDs as outlined in RFC 6381 | 955 // Handle parsing H.264 codec IDs as outlined in RFC 6381 |
xhwang
2014/10/03 23:08:06
The suffix strings are really defined in ISO-14496
wolenetz
2014/10/04 01:36:40
Done.
| |
942 // avc1.42E0xx - H.264 Baseline | 956 // avc1.42y0xx, y >= 8 - H.264 Baseline |
943 // avc1.4D40xx - H.264 Main | 957 // avc1.4D40xx - H.264 Main |
944 // avc1.6400xx - H.264 High | 958 // avc1.6400xx - H.264 High |
945 // | 959 // |
946 // avc1.xxxxxx & avc3.xxxxxx are considered ambiguous forms that | 960 // avc1.xxxxxx & avc3.xxxxxx are considered ambiguous forms that |
947 // are trying to signal H.264 Baseline. | 961 // are trying to signal H.264 Baseline. |
948 static bool ParseH264CodecID(const std::string& codec_id, | 962 static bool ParseH264CodecID(const std::string& codec_id, |
949 MimeUtil::Codec* codec, | 963 MimeUtil::Codec* codec, |
950 bool* is_ambiguous) { | 964 bool* is_ambiguous) { |
951 // Make sure we have avc1.xxxxxx or avc3.xxxxxx | 965 // Make sure we have avc1.xxxxxx or avc3.xxxxxx |
952 if (codec_id.size() != 11 || | 966 if (codec_id.size() != 11 || |
953 (!StartsWithASCII(codec_id, "avc1.", true) && | 967 (!StartsWithASCII(codec_id, "avc1.", true) && |
954 !StartsWithASCII(codec_id, "avc3.", true))) { | 968 !StartsWithASCII(codec_id, "avc3.", true))) { |
955 return false; | 969 return false; |
956 } | 970 } |
957 | 971 |
958 std::string profile = StringToUpperASCII(codec_id.substr(5, 4)); | 972 std::string profile = StringToUpperASCII(codec_id.substr(5, 4)); |
959 if (profile == "42E0") { | 973 if (IsValidH264BaselineProfile(profile)) { |
960 *codec = MimeUtil::H264_BASELINE; | 974 *codec = MimeUtil::H264_BASELINE; |
961 } else if (profile == "4D40") { | 975 } else if (profile == "4D40") { |
962 *codec = MimeUtil::H264_MAIN; | 976 *codec = MimeUtil::H264_MAIN; |
963 } else if (profile == "6400") { | 977 } else if (profile == "6400") { |
964 *codec = MimeUtil::H264_HIGH; | 978 *codec = MimeUtil::H264_HIGH; |
965 } else { | 979 } else { |
966 *codec = MimeUtil::H264_BASELINE; | 980 *codec = MimeUtil::H264_BASELINE; |
967 *is_ambiguous = true; | 981 *is_ambiguous = true; |
968 return true; | 982 return true; |
969 } | 983 } |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1362 post_data->append("\r\n" + value + "\r\n"); | 1376 post_data->append("\r\n" + value + "\r\n"); |
1363 } | 1377 } |
1364 | 1378 |
1365 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 1379 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
1366 std::string* post_data) { | 1380 std::string* post_data) { |
1367 DCHECK(post_data); | 1381 DCHECK(post_data); |
1368 post_data->append("--" + mime_boundary + "--\r\n"); | 1382 post_data->append("--" + mime_boundary + "--\r\n"); |
1369 } | 1383 } |
1370 | 1384 |
1371 } // namespace net | 1385 } // namespace net |
OLD | NEW |