Bug 841239 - Have HTMLMediaElement.canPlayType respond affirmatively to codecs=mp3 and audio/x-m4a. r=padenot

This commit is contained in:
Chris Pearce 2013-02-27 09:27:43 +13:00
Родитель 68d9b3d62a
Коммит a96f6b66a2
3 изменённых файлов: 28 добавлений и 8 удалений

Просмотреть файл

@ -2187,6 +2187,11 @@ nsHTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult)
aResult.AssignLiteral("maybe"); aResult.AssignLiteral("maybe");
break; break;
} }
LOG(PR_LOG_DEBUG, ("%p CanPlayType(%s) = \"%s\"", this,
NS_ConvertUTF16toUTF8(aType).get(),
NS_ConvertUTF16toUTF8(aResult).get()));
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -7,6 +7,14 @@ function check_mp4(v, enabled) {
check("video/mp4", "maybe"); check("video/mp4", "maybe");
check("audio/mp4", "maybe"); check("audio/mp4", "maybe");
check("audio/mpeg", "maybe"); check("audio/mpeg", "maybe");
check("audio/mp3", "maybe");
check("audio/x-m4a", "maybe");
// Not the MIME type that other browsers respond to, so we won't either.
check("audio/m4a", "");
// Only Safari responds affirmatively to "audio/aac",
// so we'll let x-m4a cover aac support.
check("audio/aac", "");
check("video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"", "probably"); check("video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"", "probably");
check("video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"", "probably"); check("video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"", "probably");
@ -22,6 +30,14 @@ function check_mp4(v, enabled) {
check("video/mp4; codecs=\"avc1.64001E\"", "probably"); check("video/mp4; codecs=\"avc1.64001E\"", "probably");
check("video/mp4; codecs=\"avc1.64001F\"", "probably"); check("video/mp4; codecs=\"avc1.64001F\"", "probably");
check("audio/mpeg; codecs=\"mp3\"", "probably");
check("audio/mpeg; codecs=mp3", "probably");
check("audio/mp3; codecs=\"mp3\"", "probably");
check("audio/mp3; codecs=mp3", "probably");
check("audio/mp4; codecs=\"mp4a.40.2\"", "probably"); check("audio/mp4; codecs=\"mp4a.40.2\"", "probably");
check("audio/mp4; codecs=mp4a.40.2", "probably"); check("audio/mp4; codecs=mp4a.40.2", "probably");
check("audio/x-m4a; codecs=\"mp4a.40.2\"", "probably");
check("audio/x-m4a; codecs=mp4a.40.2", "probably");
} }

Просмотреть файл

@ -26,19 +26,17 @@ WMFDecoder::GetSupportedCodecs(const nsACString& aType,
NS_FAILED(LoadDLLs())) NS_FAILED(LoadDLLs()))
return false; return false;
// MP3 is specified to have no codecs in its "type" param: // Assume that if LoadDLLs() didn't fail, we can playback the types that
// http://wiki.whatwg.org/wiki/Video_type_parameters#MPEG // we know should be supported on Windows 7+ using WMF.
// So specify an empty codecs list, so that if script specifies
// a "type" param with codecs, it will be reported as not supported
// as per the spec.
static char const *const mp3AudioCodecs[] = { static char const *const mp3AudioCodecs[] = {
"mp3",
nullptr nullptr
}; };
if (aType.EqualsASCII("audio/mpeg")) { if (aType.EqualsASCII("audio/mpeg") ||
aType.EqualsASCII("audio/mp3")) {
if (aCodecList) { if (aCodecList) {
*aCodecList = mp3AudioCodecs; *aCodecList = mp3AudioCodecs;
} }
// Assume that if LoadDLLs() didn't fail, we can decode MP3.
return true; return true;
} }
@ -47,7 +45,8 @@ WMFDecoder::GetSupportedCodecs(const nsACString& aType,
"mp4a.40.2", // AAC-LC "mp4a.40.2", // AAC-LC
nullptr nullptr
}; };
if (aType.EqualsASCII("audio/mp4")) { if (aType.EqualsASCII("audio/mp4") ||
aType.EqualsASCII("audio/x-m4a")) {
if (aCodecList) { if (aCodecList) {
*aCodecList = aacAudioCodecs; *aCodecList = aacAudioCodecs;
} }