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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/media/media_canplaytype_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mime_util.cc
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index 9d15256172ff9fc99f2a5c9e27021cfd785a6263..b1bd3ab27570748fd46ef8d492f6f5290370ccd1 100644
--- a/net/base/mime_util.cc
+++ b/net/base/mime_util.cc
@@ -473,7 +473,12 @@ static const MediaFormatStrict format_codec_mappings[] = {
{ "video/ogg", "opus,theora,vorbis" },
{ "audio/ogg", "opus,vorbis" },
{ "application/ogg", "opus,theora,vorbis" },
- { "audio/mpeg", "" },
+ { "audio/mpeg", ",mp3" }, // Note: The comma before the 'mp3'results in an
+ // empty string codec ID and indicates
+ // a missing codecs= parameter is also valid.
+ // The presense of 'mp3' is not RFC compliant,
+ // but is common in the wild so it is a defacto
+ // standard.
{ "audio/mp3", "" },
{ "audio/x-mp3", "" }
};
@@ -519,11 +524,19 @@ bool MimeUtil::AreSupportedCodecs(const MimeMappings& supported_codecs,
if (supported_codecs.empty())
return codecs.empty();
+ // If no codecs are specified in the mimetype, check to see if a missing
+ // codecs parameter is allowed.
+ if (codecs.empty())
+ return supported_codecs.find(std::string()) != supported_codecs.end();
+
for (size_t i = 0; i < codecs.size(); ++i) {
- if (supported_codecs.find(codecs[i]) == supported_codecs.end())
+ if (codecs[i].empty() ||
+ supported_codecs.find(codecs[i]) == supported_codecs.end()) {
return false;
+ }
}
- return !codecs.empty();
+
+ return true;
}
// Checks all the codecs present in the |codecs| against the entries in
« 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