Bug 1390748 - Remove ChannelMediaDecoder::CloneImpl() and remove subclasses of ChannelMediaDecoder. r=jwwang

MozReview-Commit-ID: 6nlBArYgwEJ

--HG--
extra : rebase_source : 5a669544b7a9c6f2d4d27a47c621c21b9317f789
This commit is contained in:
Chris Pearce 2017-08-15 17:52:17 +12:00
Родитель fa780c5329
Коммит d22c79dd24
16 изменённых файлов: 13 добавлений и 152 удалений

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

@ -11,15 +11,6 @@
namespace mozilla { namespace mozilla {
ChannelMediaDecoder*
ADTSDecoder::CloneImpl(MediaDecoderInit& aInit)
{
if (!IsEnabled())
return nullptr;
return new ADTSDecoder(aInit);
}
/* static */ bool /* static */ bool
ADTSDecoder::IsEnabled() ADTSDecoder::IsEnabled()
{ {

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

@ -13,22 +13,13 @@ namespace mozilla {
class MediaContainerType; class MediaContainerType;
class ADTSDecoder : public ChannelMediaDecoder class ADTSDecoder
{ {
public: 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 // 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. // platform that is likely to have decoders for the format.
static bool IsEnabled(); static bool IsEnabled();
static bool IsSupportedType(const MediaContainerType& aContainerType); static bool IsSupportedType(const MediaContainerType& aContainerType);
private:
ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override;
}; };
} // namespace mozilla } // namespace mozilla

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

@ -174,10 +174,10 @@ ChannelMediaDecoder::CanClone()
already_AddRefed<ChannelMediaDecoder> already_AddRefed<ChannelMediaDecoder>
ChannelMediaDecoder::Clone(MediaDecoderInit& aInit) ChannelMediaDecoder::Clone(MediaDecoderInit& aInit)
{ {
if (!mResource) { if (!mResource || !DecoderTraits::IsSupportedType(aInit.mContainerType)) {
return nullptr; return nullptr;
} }
RefPtr<ChannelMediaDecoder> decoder = CloneImpl(aInit); RefPtr<ChannelMediaDecoder> decoder = new ChannelMediaDecoder(aInit);
if (!decoder) { if (!decoder) {
return nullptr; return nullptr;
} }

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

@ -88,7 +88,6 @@ private:
// Create a new state machine to run this decoder. // Create a new state machine to run this decoder.
MediaDecoderStateMachine* CreateStateMachine(); MediaDecoderStateMachine* CreateStateMachine();
virtual ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) = 0;
nsresult OpenResource(nsIStreamListener** aStreamListener); nsresult OpenResource(nsIStreamListener** aStreamListener);
nsresult Load(BaseMediaResource* aOriginal); nsresult Load(BaseMediaResource* aOriginal);

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

@ -233,36 +233,8 @@ InstantiateDecoder(MediaDecoderInit& aInit,
RefPtr<ChannelMediaDecoder> decoder; RefPtr<ChannelMediaDecoder> decoder;
const MediaContainerType& type = aInit.mContainerType; const MediaContainerType& type = aInit.mContainerType;
if (DecoderTraits::IsSupportedType(type)) {
#ifdef MOZ_FMP4 decoder = new ChannelMediaDecoder(aInit);
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);
return decoder.forget(); return decoder.forget();
} }

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

@ -11,16 +11,6 @@
namespace mozilla { namespace mozilla {
ChannelMediaDecoder*
FlacDecoder::CloneImpl(MediaDecoderInit& aInit)
{
if (!IsEnabled()) {
return nullptr;
}
return new FlacDecoder(aInit);
}
/* static */ bool /* static */ bool
FlacDecoder::IsEnabled() FlacDecoder::IsEnabled()
{ {

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

@ -13,22 +13,13 @@ namespace mozilla {
class MediaContainerType; class MediaContainerType;
class FlacDecoder : public ChannelMediaDecoder class FlacDecoder
{ {
public: 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 // 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. // platform that is likely to have decoders for the format.
static bool IsEnabled(); static bool IsEnabled();
static bool IsSupportedType(const MediaContainerType& aContainerType); static bool IsSupportedType(const MediaContainerType& aContainerType);
private:
ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override;
}; };
} // namespace mozilla } // namespace mozilla

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

@ -25,11 +25,6 @@
namespace mozilla { namespace mozilla {
MP4Decoder::MP4Decoder(MediaDecoderInit& aInit)
: ChannelMediaDecoder(aInit)
{
}
static bool static bool
IsWhitelistedH264Codec(const nsAString& aCodec) IsWhitelistedH264Codec(const nsAString& aCodec)
{ {

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

@ -15,11 +15,9 @@ namespace mozilla {
class MediaContainerType; class MediaContainerType;
// Decoder that uses a bundled MP4 demuxer and platform decoders to play MP4. // Decoder that uses a bundled MP4 demuxer and platform decoders to play MP4.
class MP4Decoder : public ChannelMediaDecoder class MP4Decoder
{ {
public: public:
explicit MP4Decoder(MediaDecoderInit& aInit);
// Returns true if aContainerType is an MP4 type that we think we can render // Returns true if aContainerType is an MP4 type that we think we can render
// with the a platform decoder backend. // with the a platform decoder backend.
// If provided, codecs are checked for support. // If provided, codecs are checked for support.
@ -45,14 +43,6 @@ public:
static already_AddRefed<dom::Promise> static already_AddRefed<dom::Promise>
IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent); IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent);
private:
ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override
{
if (!IsEnabled()) {
return nullptr;
}
return new MP4Decoder(aInit);
}
}; };
} // namespace mozilla } // namespace mozilla

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

@ -13,15 +13,6 @@
namespace mozilla { namespace mozilla {
ChannelMediaDecoder*
MP3Decoder::CloneImpl(MediaDecoderInit& aInit)
{
if (!IsEnabled()) {
return nullptr;
}
return new MP3Decoder(aInit);
}
/* static */ /* static */
bool bool
MP3Decoder::IsEnabled() { MP3Decoder::IsEnabled() {

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

@ -12,22 +12,13 @@ namespace mozilla {
class MediaContainerType; class MediaContainerType;
class MP3Decoder : public ChannelMediaDecoder class MP3Decoder
{ {
public: public:
// MediaDecoder interface.
explicit MP3Decoder(MediaDecoderInit& aInit)
: ChannelMediaDecoder(aInit)
{
}
// Returns true if the MP3 backend is preffed on, and we're running on a // 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. // platform that is likely to have decoders for the format.
static bool IsEnabled(); static bool IsEnabled();
static bool IsSupportedType(const MediaContainerType& aContainerType); static bool IsSupportedType(const MediaContainerType& aContainerType);
private:
ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override;
}; };
} // namespace mozilla } // namespace mozilla

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

@ -37,7 +37,7 @@ OggDecoder::IsSupportedType(const MediaContainerType& aContainerType)
// Verify that all the codecs specified are ones that we expect that // Verify that all the codecs specified are ones that we expect that
// we can play. // we can play.
for (const auto& codec : codecs.Range()) { for (const auto& codec : codecs.Range()) {
if ((IsOpusEnabled() && codec.EqualsLiteral("opus")) || if ((MediaDecoder::IsOpusEnabled() && codec.EqualsLiteral("opus")) ||
codec.EqualsLiteral("vorbis") || codec.EqualsLiteral("vorbis") ||
(MediaPrefs::FlacInOgg() && codec.EqualsLiteral("flac"))) { (MediaPrefs::FlacInOgg() && codec.EqualsLiteral("flac"))) {
continue; continue;

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

@ -12,26 +12,13 @@ namespace mozilla {
class MediaContainerType; class MediaContainerType;
class OggDecoder : public ChannelMediaDecoder class OggDecoder
{ {
public: public:
explicit OggDecoder(MediaDecoderInit& aInit)
: ChannelMediaDecoder(aInit)
{}
// Returns true if aContainerType is an Ogg type that we think we can render // Returns true if aContainerType is an Ogg type that we think we can render
// with an enabled platform decoder backend. // with an enabled platform decoder backend.
// If provided, codecs are checked for support. // If provided, codecs are checked for support.
static bool IsSupportedType(const MediaContainerType& aContainerType); static bool IsSupportedType(const MediaContainerType& aContainerType);
private:
ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override
{
if (!IsOggEnabled()) {
return nullptr;
}
return new OggDecoder(aInit);
}
}; };
} // namespace mozilla } // namespace mozilla

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

@ -11,16 +11,10 @@
namespace mozilla { namespace mozilla {
ChannelMediaDecoder*
WaveDecoder::CloneImpl(MediaDecoderInit& aInit)
{
return new WaveDecoder(aInit);
}
/* static */ bool /* static */ bool
WaveDecoder::IsSupportedType(const MediaContainerType& aContainerType) WaveDecoder::IsSupportedType(const MediaContainerType& aContainerType)
{ {
if (!IsWaveEnabled()) { if (!MediaDecoder::IsWaveEnabled()) {
return false; return false;
} }
if (aContainerType.Type() == MEDIAMIMETYPE("audio/wave") if (aContainerType.Type() == MEDIAMIMETYPE("audio/wave")

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

@ -12,21 +12,12 @@ namespace mozilla {
class MediaContainerType; class MediaContainerType;
class WaveDecoder : public ChannelMediaDecoder class WaveDecoder
{ {
public: 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 // 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. // platform that is likely to have decoders for the format.
static bool IsSupportedType(const MediaContainerType& aContainerType); static bool IsSupportedType(const MediaContainerType& aContainerType);
private:
ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override;
}; };
} // namespace mozilla } // namespace mozilla

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

@ -12,27 +12,15 @@ namespace mozilla {
class MediaContainerType; class MediaContainerType;
class WebMDecoder : public ChannelMediaDecoder class WebMDecoder
{ {
public: public:
explicit WebMDecoder(MediaDecoderInit& aInit)
: ChannelMediaDecoder(aInit)
{
}
// Returns true if aContainerType is a WebM type that we think we can render // Returns true if aContainerType is a WebM type that we think we can render
// with an enabled platform decoder backend. // with an enabled platform decoder backend.
// If provided, codecs are checked for support. // If provided, codecs are checked for support.
static bool IsSupportedType(const MediaContainerType& aContainerType); static bool IsSupportedType(const MediaContainerType& aContainerType);
private:
ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override
{
if (!IsWebMEnabled()) {
return nullptr;
}
return new WebMDecoder(aInit);
}
}; };
} // namespace mozilla } // namespace mozilla