diff --git a/dom/media/ADTSDecoder.cpp b/dom/media/ADTSDecoder.cpp index 2db9488342a2..5192b03ab492 100644 --- a/dom/media/ADTSDecoder.cpp +++ b/dom/media/ADTSDecoder.cpp @@ -11,15 +11,6 @@ namespace mozilla { -ChannelMediaDecoder* -ADTSDecoder::CloneImpl(MediaDecoderInit& aInit) -{ - if (!IsEnabled()) - return nullptr; - - return new ADTSDecoder(aInit); -} - /* static */ bool ADTSDecoder::IsEnabled() { diff --git a/dom/media/ADTSDecoder.h b/dom/media/ADTSDecoder.h index 809178fea77e..2b92706a5439 100644 --- a/dom/media/ADTSDecoder.h +++ b/dom/media/ADTSDecoder.h @@ -13,22 +13,13 @@ namespace mozilla { class MediaContainerType; -class ADTSDecoder : public ChannelMediaDecoder +class ADTSDecoder { public: - // MediaDecoder interface. - explicit ADTSDecoder(MediaDecoderInit& aInit) - : ChannelMediaDecoder(aInit) - { - } - // Returns true if the ADTS backend is pref'ed on, and we're running on a // platform that is likely to have decoders for the format. static bool IsEnabled(); static bool IsSupportedType(const MediaContainerType& aContainerType); - -private: - ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override; }; } // namespace mozilla diff --git a/dom/media/ChannelMediaDecoder.cpp b/dom/media/ChannelMediaDecoder.cpp index df6ec058eb82..3a49b301ea5d 100644 --- a/dom/media/ChannelMediaDecoder.cpp +++ b/dom/media/ChannelMediaDecoder.cpp @@ -174,10 +174,10 @@ ChannelMediaDecoder::CanClone() already_AddRefed ChannelMediaDecoder::Clone(MediaDecoderInit& aInit) { - if (!mResource) { + if (!mResource || !DecoderTraits::IsSupportedType(aInit.mContainerType)) { return nullptr; } - RefPtr decoder = CloneImpl(aInit); + RefPtr decoder = new ChannelMediaDecoder(aInit); if (!decoder) { return nullptr; } diff --git a/dom/media/ChannelMediaDecoder.h b/dom/media/ChannelMediaDecoder.h index 4c21d15366e8..bcd889f384b2 100644 --- a/dom/media/ChannelMediaDecoder.h +++ b/dom/media/ChannelMediaDecoder.h @@ -88,7 +88,6 @@ private: // Create a new state machine to run this decoder. MediaDecoderStateMachine* CreateStateMachine(); - virtual ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) = 0; nsresult OpenResource(nsIStreamListener** aStreamListener); nsresult Load(BaseMediaResource* aOriginal); diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index 2aa37322d292..cd7756b914d6 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -233,36 +233,8 @@ InstantiateDecoder(MediaDecoderInit& aInit, RefPtr decoder; const MediaContainerType& type = aInit.mContainerType; - -#ifdef MOZ_FMP4 - if (MP4Decoder::IsSupportedType(type, aDiagnostics)) { - decoder = new MP4Decoder(aInit); - return decoder.forget(); - } -#endif - if (MP3Decoder::IsSupportedType(type)) { - decoder = new MP3Decoder(aInit); - return decoder.forget(); - } - if (ADTSDecoder::IsSupportedType(type)) { - decoder = new ADTSDecoder(aInit); - return decoder.forget(); - } - if (OggDecoder::IsSupportedType(type)) { - decoder = new OggDecoder(aInit); - return decoder.forget(); - } - if (WaveDecoder::IsSupportedType(type)) { - decoder = new WaveDecoder(aInit); - return decoder.forget(); - } - if (FlacDecoder::IsSupportedType(type)) { - decoder = new FlacDecoder(aInit); - return decoder.forget(); - } - - if (WebMDecoder::IsSupportedType(type)) { - decoder = new WebMDecoder(aInit); + if (DecoderTraits::IsSupportedType(type)) { + decoder = new ChannelMediaDecoder(aInit); return decoder.forget(); } diff --git a/dom/media/flac/FlacDecoder.cpp b/dom/media/flac/FlacDecoder.cpp index 15fd11b6190f..f127f5b949bf 100644 --- a/dom/media/flac/FlacDecoder.cpp +++ b/dom/media/flac/FlacDecoder.cpp @@ -11,16 +11,6 @@ namespace mozilla { -ChannelMediaDecoder* -FlacDecoder::CloneImpl(MediaDecoderInit& aInit) -{ - if (!IsEnabled()) { - return nullptr; - } - - return new FlacDecoder(aInit); -} - /* static */ bool FlacDecoder::IsEnabled() { diff --git a/dom/media/flac/FlacDecoder.h b/dom/media/flac/FlacDecoder.h index 7640d8a3650b..04a758cd1147 100644 --- a/dom/media/flac/FlacDecoder.h +++ b/dom/media/flac/FlacDecoder.h @@ -13,22 +13,13 @@ namespace mozilla { class MediaContainerType; -class FlacDecoder : public ChannelMediaDecoder +class FlacDecoder { public: - // MediaDecoder interface. - explicit FlacDecoder(MediaDecoderInit& aInit) - : ChannelMediaDecoder(aInit) - { - } - // Returns true if the Flac backend is pref'ed on, and we're running on a // platform that is likely to have decoders for the format. static bool IsEnabled(); static bool IsSupportedType(const MediaContainerType& aContainerType); - -private: - ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override; }; } // namespace mozilla diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index 70be8c55fd6c..50d5dab332e3 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -25,11 +25,6 @@ namespace mozilla { -MP4Decoder::MP4Decoder(MediaDecoderInit& aInit) - : ChannelMediaDecoder(aInit) -{ -} - static bool IsWhitelistedH264Codec(const nsAString& aCodec) { diff --git a/dom/media/fmp4/MP4Decoder.h b/dom/media/fmp4/MP4Decoder.h index 347f3dee95d4..12c4973dceae 100644 --- a/dom/media/fmp4/MP4Decoder.h +++ b/dom/media/fmp4/MP4Decoder.h @@ -15,11 +15,9 @@ namespace mozilla { class MediaContainerType; // Decoder that uses a bundled MP4 demuxer and platform decoders to play MP4. -class MP4Decoder : public ChannelMediaDecoder +class MP4Decoder { public: - explicit MP4Decoder(MediaDecoderInit& aInit); - // Returns true if aContainerType is an MP4 type that we think we can render // with the a platform decoder backend. // If provided, codecs are checked for support. @@ -45,14 +43,6 @@ public: static already_AddRefed IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent); -private: - ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override - { - if (!IsEnabled()) { - return nullptr; - } - return new MP4Decoder(aInit); - } }; } // namespace mozilla diff --git a/dom/media/mp3/MP3Decoder.cpp b/dom/media/mp3/MP3Decoder.cpp index e0172b184f07..30c829f5f802 100644 --- a/dom/media/mp3/MP3Decoder.cpp +++ b/dom/media/mp3/MP3Decoder.cpp @@ -13,15 +13,6 @@ namespace mozilla { -ChannelMediaDecoder* -MP3Decoder::CloneImpl(MediaDecoderInit& aInit) -{ - if (!IsEnabled()) { - return nullptr; - } - return new MP3Decoder(aInit); -} - /* static */ bool MP3Decoder::IsEnabled() { diff --git a/dom/media/mp3/MP3Decoder.h b/dom/media/mp3/MP3Decoder.h index ff10eff9b639..9ce49291b4ec 100644 --- a/dom/media/mp3/MP3Decoder.h +++ b/dom/media/mp3/MP3Decoder.h @@ -12,22 +12,13 @@ namespace mozilla { class MediaContainerType; -class MP3Decoder : public ChannelMediaDecoder +class MP3Decoder { public: - // MediaDecoder interface. - explicit MP3Decoder(MediaDecoderInit& aInit) - : ChannelMediaDecoder(aInit) - { - } - // Returns true if the MP3 backend is preffed on, and we're running on a // platform that is likely to have decoders for the format. static bool IsEnabled(); static bool IsSupportedType(const MediaContainerType& aContainerType); - -private: - ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override; }; } // namespace mozilla diff --git a/dom/media/ogg/OggDecoder.cpp b/dom/media/ogg/OggDecoder.cpp index cac3534d5162..c65f5f17c278 100644 --- a/dom/media/ogg/OggDecoder.cpp +++ b/dom/media/ogg/OggDecoder.cpp @@ -37,7 +37,7 @@ OggDecoder::IsSupportedType(const MediaContainerType& aContainerType) // Verify that all the codecs specified are ones that we expect that // we can play. for (const auto& codec : codecs.Range()) { - if ((IsOpusEnabled() && codec.EqualsLiteral("opus")) || + if ((MediaDecoder::IsOpusEnabled() && codec.EqualsLiteral("opus")) || codec.EqualsLiteral("vorbis") || (MediaPrefs::FlacInOgg() && codec.EqualsLiteral("flac"))) { continue; diff --git a/dom/media/ogg/OggDecoder.h b/dom/media/ogg/OggDecoder.h index 088452bc382c..965b9dfc7989 100644 --- a/dom/media/ogg/OggDecoder.h +++ b/dom/media/ogg/OggDecoder.h @@ -12,26 +12,13 @@ namespace mozilla { class MediaContainerType; -class OggDecoder : public ChannelMediaDecoder +class OggDecoder { public: - explicit OggDecoder(MediaDecoderInit& aInit) - : ChannelMediaDecoder(aInit) - {} - // Returns true if aContainerType is an Ogg type that we think we can render // with an enabled platform decoder backend. // If provided, codecs are checked for support. static bool IsSupportedType(const MediaContainerType& aContainerType); - -private: - ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override - { - if (!IsOggEnabled()) { - return nullptr; - } - return new OggDecoder(aInit); - } }; } // namespace mozilla diff --git a/dom/media/wave/WaveDecoder.cpp b/dom/media/wave/WaveDecoder.cpp index 2a44ec898a3c..dee2b858a0bb 100644 --- a/dom/media/wave/WaveDecoder.cpp +++ b/dom/media/wave/WaveDecoder.cpp @@ -11,16 +11,10 @@ namespace mozilla { -ChannelMediaDecoder* -WaveDecoder::CloneImpl(MediaDecoderInit& aInit) -{ - return new WaveDecoder(aInit); -} - /* static */ bool WaveDecoder::IsSupportedType(const MediaContainerType& aContainerType) { - if (!IsWaveEnabled()) { + if (!MediaDecoder::IsWaveEnabled()) { return false; } if (aContainerType.Type() == MEDIAMIMETYPE("audio/wave") diff --git a/dom/media/wave/WaveDecoder.h b/dom/media/wave/WaveDecoder.h index 745d9e45cdf9..67aeb11084a4 100644 --- a/dom/media/wave/WaveDecoder.h +++ b/dom/media/wave/WaveDecoder.h @@ -12,21 +12,12 @@ namespace mozilla { class MediaContainerType; -class WaveDecoder : public ChannelMediaDecoder +class WaveDecoder { public: - // MediaDecoder interface. - explicit WaveDecoder(MediaDecoderInit& aInit) - : ChannelMediaDecoder(aInit) - { - } - // Returns true if the Wave backend is pref'ed on, and we're running on a // platform that is likely to have decoders for the format. static bool IsSupportedType(const MediaContainerType& aContainerType); - -private: - ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override; }; } // namespace mozilla diff --git a/dom/media/webm/WebMDecoder.h b/dom/media/webm/WebMDecoder.h index 91dea0eba219..657d2e2d5de6 100644 --- a/dom/media/webm/WebMDecoder.h +++ b/dom/media/webm/WebMDecoder.h @@ -12,27 +12,15 @@ namespace mozilla { class MediaContainerType; -class WebMDecoder : public ChannelMediaDecoder +class WebMDecoder { public: - explicit WebMDecoder(MediaDecoderInit& aInit) - : ChannelMediaDecoder(aInit) - { - } // Returns true if aContainerType is a WebM type that we think we can render // with an enabled platform decoder backend. // If provided, codecs are checked for support. static bool IsSupportedType(const MediaContainerType& aContainerType); -private: - ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override - { - if (!IsWebMEnabled()) { - return nullptr; - } - return new WebMDecoder(aInit); - } }; } // namespace mozilla