Chromium Code Reviews| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 }; | 466 }; |
| 467 | 467 |
| 468 static const MediaFormatStrict format_codec_mappings[] = { | 468 static const MediaFormatStrict format_codec_mappings[] = { |
| 469 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" }, | 469 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" }, |
| 470 { "audio/webm", "opus,vorbis" }, | 470 { "audio/webm", "opus,vorbis" }, |
| 471 { "audio/wav", "1" }, | 471 { "audio/wav", "1" }, |
| 472 { "audio/x-wav", "1" }, | 472 { "audio/x-wav", "1" }, |
| 473 { "video/ogg", "opus,theora,vorbis" }, | 473 { "video/ogg", "opus,theora,vorbis" }, |
| 474 { "audio/ogg", "opus,vorbis" }, | 474 { "audio/ogg", "opus,vorbis" }, |
| 475 { "application/ogg", "opus,theora,vorbis" }, | 475 { "application/ogg", "opus,theora,vorbis" }, |
| 476 { "audio/mpeg", "" }, | 476 { "audio/mpeg", ",mp3" }, // Note: Empty string codec ID indicates |
|
DaleCurtis
2014/07/17 18:41:55
I'm not convinced it's a good idea, but I wonder i
acolwell GONE FROM CHROMIUM
2014/07/17 18:57:00
I agree that this isn't awesome, but I fear some s
| |
| 477 // a missing codecs= parameter is also valid. | |
| 478 // The presense of 'mp3' is not RFC compliant, | |
| 479 // but is common in the wild so it is a defacto | |
| 480 // standard. | |
| 477 { "audio/mp3", "" }, | 481 { "audio/mp3", "" }, |
| 478 { "audio/x-mp3", "" } | 482 { "audio/x-mp3", "" } |
| 479 }; | 483 }; |
| 480 | 484 |
| 481 // Following is the list of RFC 6381 compliant codecs: | 485 // Following is the list of RFC 6381 compliant codecs: |
| 482 // mp4a.6B - MPEG-1 audio | 486 // mp4a.6B - MPEG-1 audio |
| 483 // mp4a.69 - MPEG-2 extension to MPEG-1 | 487 // mp4a.69 - MPEG-2 extension to MPEG-1 |
| 484 // mp4a.67 - MPEG-2 AAC | 488 // mp4a.67 - MPEG-2 AAC |
| 485 // mp4a.40.2 - MPEG-4 AAC | 489 // mp4a.40.2 - MPEG-4 AAC |
| 486 // mp4a.40.5 - MPEG-4 HE-AAC | 490 // mp4a.40.5 - MPEG-4 HE-AAC |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 512 MimeUtil::MimeUtil() { | 516 MimeUtil::MimeUtil() { |
| 513 InitializeMimeTypeMaps(); | 517 InitializeMimeTypeMaps(); |
| 514 } | 518 } |
| 515 | 519 |
| 516 // static | 520 // static |
| 517 bool MimeUtil::AreSupportedCodecs(const MimeMappings& supported_codecs, | 521 bool MimeUtil::AreSupportedCodecs(const MimeMappings& supported_codecs, |
| 518 const std::vector<std::string>& codecs) { | 522 const std::vector<std::string>& codecs) { |
| 519 if (supported_codecs.empty()) | 523 if (supported_codecs.empty()) |
| 520 return codecs.empty(); | 524 return codecs.empty(); |
| 521 | 525 |
| 526 // If no codecs are specified in the mimetype, check to see if a missing | |
| 527 // codecs parameter is allowed. | |
| 528 if (codecs.empty()) | |
| 529 return supported_codecs.find("") != supported_codecs.end(); | |
|
Ryan Sleevi
2014/07/17 18:38:08
.find(std::string())
acolwell GONE FROM CHROMIUM
2014/07/17 18:57:00
Done.
| |
| 530 | |
| 522 for (size_t i = 0; i < codecs.size(); ++i) { | 531 for (size_t i = 0; i < codecs.size(); ++i) { |
| 523 if (supported_codecs.find(codecs[i]) == supported_codecs.end()) | 532 if (supported_codecs.find(codecs[i]) == supported_codecs.end() || |
| 533 codecs[i].empty()) | |
|
Ryan Sleevi
2014/07/17 18:38:08
Do the .empty() check before the .find(), and avoi
acolwell GONE FROM CHROMIUM
2014/07/17 18:57:00
Done.
| |
| 524 return false; | 534 return false; |
| 525 } | 535 } |
| 526 return !codecs.empty(); | 536 |
| 537 return true; | |
| 527 } | 538 } |
| 528 | 539 |
| 529 // Checks all the codecs present in the |codecs| against the entries in | 540 // Checks all the codecs present in the |codecs| against the entries in |
| 530 // |supported_codecs|. Returns true only if |codecs| is non-empty and all the | 541 // |supported_codecs|. Returns true only if |codecs| is non-empty and all the |
| 531 // codecs match |supported_codecs| expressions. | 542 // codecs match |supported_codecs| expressions. |
| 532 bool MimeUtil::AreSupportedCodecsWithProfile( | 543 bool MimeUtil::AreSupportedCodecsWithProfile( |
| 533 const MimeExpressionMappings& supported_codecs, | 544 const MimeExpressionMappings& supported_codecs, |
| 534 const std::vector<std::string>& codecs) { | 545 const std::vector<std::string>& codecs) { |
| 535 DCHECK(!supported_codecs.empty()); | 546 DCHECK(!supported_codecs.empty()); |
| 536 for (size_t i = 0; i < codecs.size(); ++i) { | 547 for (size_t i = 0; i < codecs.size(); ++i) { |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1175 post_data->append("\r\n" + value + "\r\n"); | 1186 post_data->append("\r\n" + value + "\r\n"); |
| 1176 } | 1187 } |
| 1177 | 1188 |
| 1178 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 1189 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
| 1179 std::string* post_data) { | 1190 std::string* post_data) { |
| 1180 DCHECK(post_data); | 1191 DCHECK(post_data); |
| 1181 post_data->append("--" + mime_boundary + "--\r\n"); | 1192 post_data->append("--" + mime_boundary + "--\r\n"); |
| 1182 } | 1193 } |
| 1183 | 1194 |
| 1184 } // namespace net | 1195 } // namespace net |
| OLD | NEW |