Commit 2f181679 authored by acolwell@chromium.org's avatar acolwell@chromium.org

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
parent 871e095d
...@@ -345,9 +345,13 @@ IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_mp3) { ...@@ -345,9 +345,13 @@ IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_mp3) {
EXPECT_EQ(kNot, CanPlay("'video/mpeg'")); EXPECT_EQ(kNot, CanPlay("'video/mpeg'"));
EXPECT_EQ(kNot, CanPlay("'video/x-mp3'")); 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'")); 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=\"avc1\"'"));
EXPECT_EQ(kNot, CanPlay("'audio/mpeg; codecs=\"avc3\"'")); EXPECT_EQ(kNot, CanPlay("'audio/mpeg; codecs=\"avc3\"'"));
......
...@@ -473,7 +473,12 @@ static const MediaFormatStrict format_codec_mappings[] = { ...@@ -473,7 +473,12 @@ static const MediaFormatStrict format_codec_mappings[] = {
{ "video/ogg", "opus,theora,vorbis" }, { "video/ogg", "opus,theora,vorbis" },
{ "audio/ogg", "opus,vorbis" }, { "audio/ogg", "opus,vorbis" },
{ "application/ogg", "opus,theora,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/mp3", "" },
{ "audio/x-mp3", "" } { "audio/x-mp3", "" }
}; };
...@@ -519,11 +524,19 @@ bool MimeUtil::AreSupportedCodecs(const MimeMappings& supported_codecs, ...@@ -519,11 +524,19 @@ bool MimeUtil::AreSupportedCodecs(const MimeMappings& supported_codecs,
if (supported_codecs.empty()) if (supported_codecs.empty())
return 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) { 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 false;
}
} }
return !codecs.empty();
return true;
} }
// Checks all the codecs present in the |codecs| against the entries in // Checks all the codecs present in the |codecs| against the entries in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment