Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: net/base/mime_util.cc

Issue 400023002: Fix canPlayType() support for non-RFC compliant mp3 mimetype. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/media/media_canplaytype_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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: The comma before the 'mp3'results in an
477 // empty string codec ID and indicates
478 // a missing codecs= parameter is also valid.
479 // The presense of 'mp3' is not RFC compliant,
480 // but is common in the wild so it is a defacto
481 // standard.
477 { "audio/mp3", "" }, 482 { "audio/mp3", "" },
478 { "audio/x-mp3", "" } 483 { "audio/x-mp3", "" }
479 }; 484 };
480 485
481 // Following is the list of RFC 6381 compliant codecs: 486 // Following is the list of RFC 6381 compliant codecs:
482 // mp4a.6B - MPEG-1 audio 487 // mp4a.6B - MPEG-1 audio
483 // mp4a.69 - MPEG-2 extension to MPEG-1 488 // mp4a.69 - MPEG-2 extension to MPEG-1
484 // mp4a.67 - MPEG-2 AAC 489 // mp4a.67 - MPEG-2 AAC
485 // mp4a.40.2 - MPEG-4 AAC 490 // mp4a.40.2 - MPEG-4 AAC
486 // mp4a.40.5 - MPEG-4 HE-AAC 491 // mp4a.40.5 - MPEG-4 HE-AAC
(...skipping 25 matching lines...) Expand all
512 MimeUtil::MimeUtil() { 517 MimeUtil::MimeUtil() {
513 InitializeMimeTypeMaps(); 518 InitializeMimeTypeMaps();
514 } 519 }
515 520
516 // static 521 // static
517 bool MimeUtil::AreSupportedCodecs(const MimeMappings& supported_codecs, 522 bool MimeUtil::AreSupportedCodecs(const MimeMappings& supported_codecs,
518 const std::vector<std::string>& codecs) { 523 const std::vector<std::string>& codecs) {
519 if (supported_codecs.empty()) 524 if (supported_codecs.empty())
520 return codecs.empty(); 525 return codecs.empty();
521 526
527 // If no codecs are specified in the mimetype, check to see if a missing
528 // codecs parameter is allowed.
529 if (codecs.empty())
530 return supported_codecs.find(std::string()) != supported_codecs.end();
531
522 for (size_t i = 0; i < codecs.size(); ++i) { 532 for (size_t i = 0; i < codecs.size(); ++i) {
523 if (supported_codecs.find(codecs[i]) == supported_codecs.end()) 533 if (codecs[i].empty() ||
534 supported_codecs.find(codecs[i]) == supported_codecs.end()) {
524 return false; 535 return false;
536 }
525 } 537 }
526 return !codecs.empty(); 538
539 return true;
527 } 540 }
528 541
529 // Checks all the codecs present in the |codecs| against the entries in 542 // 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 543 // |supported_codecs|. Returns true only if |codecs| is non-empty and all the
531 // codecs match |supported_codecs| expressions. 544 // codecs match |supported_codecs| expressions.
532 bool MimeUtil::AreSupportedCodecsWithProfile( 545 bool MimeUtil::AreSupportedCodecsWithProfile(
533 const MimeExpressionMappings& supported_codecs, 546 const MimeExpressionMappings& supported_codecs,
534 const std::vector<std::string>& codecs) { 547 const std::vector<std::string>& codecs) {
535 DCHECK(!supported_codecs.empty()); 548 DCHECK(!supported_codecs.empty());
536 for (size_t i = 0; i < codecs.size(); ++i) { 549 for (size_t i = 0; i < codecs.size(); ++i) {
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 post_data->append("\r\n" + value + "\r\n"); 1188 post_data->append("\r\n" + value + "\r\n");
1176 } 1189 }
1177 1190
1178 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, 1191 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary,
1179 std::string* post_data) { 1192 std::string* post_data) {
1180 DCHECK(post_data); 1193 DCHECK(post_data);
1181 post_data->append("--" + mime_boundary + "--\r\n"); 1194 post_data->append("--" + mime_boundary + "--\r\n");
1182 } 1195 }
1183 1196
1184 } // namespace net 1197 } // namespace net
OLDNEW
« no previous file with comments | « content/browser/media/media_canplaytype_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698