From b763f84cf1a651f31b239356541de4c77c4c8ec3 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Sat, 9 Jun 2018 13:22:39 +0200 Subject: [PATCH] Bug 1409664 - P15. Fix canPlayType so that it checks codecs if provided. r=bryce Summary: For flac, mp3 and adts, if a codec was provided but wasn't supported in the container, it would have reported Maybe instead of No Depends on D1628 Tags: #secure-revision Bug #: 1409664 Differential Revision: https://phabricator.services.mozilla.com/D1629 --- dom/media/DecoderTraits.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index 532dc891b175..e4b8d53440b4 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -121,14 +121,29 @@ CanHandleCodecsType(const MediaContainerType& aType, return CANPLAY_NO; } #endif - if (MP3Decoder::IsSupportedType(aType)) { - return CANPLAY_YES; + if (MP3Decoder::IsSupportedType(mimeType)) { + if (MP3Decoder::IsSupportedType(aType)) { + return CANPLAY_YES; + } + // We can only reach this position if a particular codec was requested, + // mp3 is supported and working: the codec must be invalid. + return CANPLAY_NO; } - if (ADTSDecoder::IsSupportedType(aType)) { - return CANPLAY_YES; + if (ADTSDecoder::IsSupportedType(mimeType)) { + if (ADTSDecoder::IsSupportedType(aType)) { + return CANPLAY_YES; + } + // We can only reach this position if a particular codec was requested, + // adts is supported and working: the codec must be invalid. + return CANPLAY_NO; } - if (FlacDecoder::IsSupportedType(aType)) { - return CANPLAY_YES; + if (FlacDecoder::IsSupportedType(mimeType)) { + if (FlacDecoder::IsSupportedType(aType)) { + return CANPLAY_YES; + } + // We can only reach this position if a particular codec was requested, + // flac is supported and working: the codec must be invalid. + return CANPLAY_NO; } return CANPLAY_MAYBE;