From 62fa458f40bf5847c9a381080dd4181a4e202e88 Mon Sep 17 00:00:00 2001 From: alwu Date: Mon, 1 Mar 2021 20:30:58 +0000 Subject: [PATCH] Bug 1690661 - use `CanHandleContainerType()` for asking if the container type is supported. r=bryce Doing that allows us to accquire the error information from the `DecoderDoctorDiagnostics`. Differential Revision: https://phabricator.services.mozilla.com/D106676 --- dom/media/ChannelMediaDecoder.cpp | 8 ++++---- dom/media/DecoderTraits.cpp | 22 ---------------------- dom/media/DecoderTraits.h | 2 -- dom/media/mp4/MP4Decoder.cpp | 6 ------ dom/media/mp4/MP4Decoder.h | 3 --- 5 files changed, 4 insertions(+), 37 deletions(-) diff --git a/dom/media/ChannelMediaDecoder.cpp b/dom/media/ChannelMediaDecoder.cpp index 83ac41377e79..7d3ad7922f24 100644 --- a/dom/media/ChannelMediaDecoder.cpp +++ b/dom/media/ChannelMediaDecoder.cpp @@ -172,9 +172,8 @@ already_AddRefed ChannelMediaDecoder::Create( MediaDecoderInit& aInit, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(NS_IsMainThread()); RefPtr decoder; - - const MediaContainerType& type = aInit.mContainerType; - if (DecoderTraits::IsSupportedType(type)) { + if (DecoderTraits::CanHandleContainerType(aInit.mContainerType, + aDiagnostics) != CANPLAY_NO) { decoder = new ChannelMediaDecoder(aInit); return decoder.forget(); } @@ -189,7 +188,8 @@ bool ChannelMediaDecoder::CanClone() { already_AddRefed ChannelMediaDecoder::Clone( MediaDecoderInit& aInit) { - if (!mResource || !DecoderTraits::IsSupportedType(aInit.mContainerType)) { + if (!mResource || DecoderTraits::CanHandleContainerType( + aInit.mContainerType, nullptr) == CANPLAY_NO) { return nullptr; } RefPtr decoder = new ChannelMediaDecoder(aInit); diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index a300cd8c3ccd..e99bc2561511 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -281,28 +281,6 @@ MediaFormatReader* DecoderTraits::CreateReader(const MediaContainerType& aType, return decoderReader; } -/* static */ -bool DecoderTraits::IsSupportedType(const MediaContainerType& aType) { - typedef bool (*IsSupportedFunction)(const MediaContainerType& aType); - static const IsSupportedFunction funcs[] = { - &ADTSDecoder::IsSupportedType, - &FlacDecoder::IsSupportedType, - &MP3Decoder::IsSupportedType, -#ifdef MOZ_FMP4 - &MP4Decoder::IsSupportedTypeWithoutDiagnostics, -#endif - &OggDecoder::IsSupportedType, - &WaveDecoder::IsSupportedType, - &WebMDecoder::IsSupportedType, - }; - for (IsSupportedFunction func : funcs) { - if (func(aType)) { - return true; - } - } - return false; -} - /* static */ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType) { // Forbid playing media in video documents if the user has opted diff --git a/dom/media/DecoderTraits.h b/dom/media/DecoderTraits.h index 63876404a657..291d3c11928a 100644 --- a/dom/media/DecoderTraits.h +++ b/dom/media/DecoderTraits.h @@ -63,8 +63,6 @@ class DecoderTraits { // Returns true if aType is matroska type. static bool IsMatroskaType(const MediaContainerType& aType); - static bool IsSupportedType(const MediaContainerType& aType); - // Returns an array of all TrackInfo objects described by this type. static nsTArray> GetTracksInfo( const MediaContainerType& aType); diff --git a/dom/media/mp4/MP4Decoder.cpp b/dom/media/mp4/MP4Decoder.cpp index 029199460cda..c38ed09d8ae4 100644 --- a/dom/media/mp4/MP4Decoder.cpp +++ b/dom/media/mp4/MP4Decoder.cpp @@ -39,12 +39,6 @@ static bool IsWhitelistedH264Codec(const nsAString& aCodec) { profile == H264_PROFILE_EXTENDED || profile == H264_PROFILE_HIGH); } -/* static */ -bool MP4Decoder::IsSupportedTypeWithoutDiagnostics( - const MediaContainerType& aContainerType) { - return IsSupportedType(aContainerType, nullptr); -} - static bool IsTypeValid(const MediaContainerType& aType) { // Whitelist MP4 types, so they explicitly match what we encounter on // the web, as opposed to what we use internally (i.e. what our demuxers diff --git a/dom/media/mp4/MP4Decoder.h b/dom/media/mp4/MP4Decoder.h index acb871f6fc29..07b085929b67 100644 --- a/dom/media/mp4/MP4Decoder.h +++ b/dom/media/mp4/MP4Decoder.h @@ -26,9 +26,6 @@ class MP4Decoder { static bool IsSupportedType(const MediaContainerType& aContainerType, DecoderDoctorDiagnostics* aDiagnostics); - static bool IsSupportedTypeWithoutDiagnostics( - const MediaContainerType& aContainerType); - // Return true if aMimeType is a one of the strings used by our demuxers to // identify H264. Does not parse general content type strings, i.e. white // space matters.