summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 23:49:47 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 23:49:47 +0000
commit2f181679e2b25ffb4564e6b2a4b827565cb63a70 (patch)
tree18095dd13776202597bdaa209edfade1a59a702a
parent871e095dc506cf63752cca1fb4c2d47dc4043fa5 (diff)
downloadchromium_src-2f181679e2b25ffb4564e6b2a4b827565cb63a70.zip
chromium_src-2f181679e2b25ffb4564e6b2a4b827565cb63a70.tar.gz
chromium_src-2f181679e2b25ffb4564e6b2a4b827565cb63a70.tar.bz2
Fix canPlayType() support for non-RFC compliant mp3 mimetype.
The 'audio/mpeg; codecs="mp3"' mimetype is not RFC 3003 compliant, but a bunch of sites apparently use it. This change restores the behavior that was in M35 and earlier and returns "probably" for this mimetype. The changes are intentionally kept small so they can be easily be merged to the M36 & M37 branches. BUG=393720,386073 TEST=MediaCanPlayTypeTest.CodecSupportTest_mp3 Review URL: https://codereview.chromium.org/400023002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283929 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/media/media_canplaytype_browsertest.cc6
-rw-r--r--net/base/mime_util.cc19
2 files changed, 21 insertions, 4 deletions
diff --git a/content/browser/media/media_canplaytype_browsertest.cc b/content/browser/media/media_canplaytype_browsertest.cc
index 7897d78..8f064df 100644
--- a/content/browser/media/media_canplaytype_browsertest.cc
+++ b/content/browser/media/media_canplaytype_browsertest.cc
@@ -345,9 +345,13 @@ IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_mp3) {
EXPECT_EQ(kNot, CanPlay("'video/mpeg'"));
EXPECT_EQ(kNot, CanPlay("'video/x-mp3'"));
- // audio/mpeg does not allow any codecs parameter
+ // audio/mpeg without a codecs parameter (RFC 3003 compliant)
EXPECT_EQ(kPropProbably, CanPlay("'audio/mpeg'"));
+ // audio/mpeg with mp3 in codecs parameter. (Not RFC compliant, but
+ // very common in the wild so it is a defacto standard).
+ EXPECT_EQ(kPropProbably, CanPlay("'audio/mpeg; codecs=\"mp3\"'"));
+
EXPECT_EQ(kNot, CanPlay("'audio/mpeg; codecs=\"avc1\"'"));
EXPECT_EQ(kNot, CanPlay("'audio/mpeg; codecs=\"avc3\"'"));
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index 9d15256..b1bd3ab2 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