Bug 1214989. Part 2 - add MediaDecoderOwner to Clone() and overrides. r=gerald.

This commit is contained in:
JW Wang 2015-10-15 11:37:47 +08:00
parent 31039842e1
commit 78f4511dfc
24 changed files with 40 additions and 36 deletions

View File

@ -2758,7 +2758,7 @@ nsresult HTMLMediaElement::InitializeDecoderAsClone(MediaDecoder* aOriginal)
MediaResource* originalResource = aOriginal->GetResource(); MediaResource* originalResource = aOriginal->GetResource();
if (!originalResource) if (!originalResource)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsRefPtr<MediaDecoder> decoder = aOriginal->Clone(); nsRefPtr<MediaDecoder> decoder = aOriginal->Clone(this);
if (!decoder) if (!decoder)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@ -15,11 +15,11 @@
namespace mozilla { namespace mozilla {
MediaDecoder* MediaDecoder*
MP3Decoder::Clone() { MP3Decoder::Clone(MediaDecoderOwner* aOwner) {
if (!IsEnabled()) { if (!IsEnabled()) {
return nullptr; return nullptr;
} }
return new MP3Decoder(); return new MP3Decoder(aOwner);
} }
MediaDecoderStateMachine* MediaDecoderStateMachine*

View File

@ -14,7 +14,7 @@ class MP3Decoder : public MediaDecoder {
public: public:
// MediaDecoder interface. // MediaDecoder interface.
explicit MP3Decoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {} explicit MP3Decoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
MediaDecoder* Clone() override; MediaDecoder* Clone(MediaDecoderOwner* aOwner) override;
MediaDecoderStateMachine* CreateStateMachine() override; MediaDecoderStateMachine* CreateStateMachine() override;
// 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

View File

@ -306,7 +306,7 @@ public:
virtual void ResetConnectionState(); virtual void ResetConnectionState();
// Create a new decoder of the same type as this one. // Create a new decoder of the same type as this one.
// Subclasses must implement this. // Subclasses must implement this.
virtual MediaDecoder* Clone() = 0; virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) = 0;
// Create a new state machine to run this decoder. // Create a new state machine to run this decoder.
// Subclasses must implement this. // Subclasses must implement this.
virtual MediaDecoderStateMachine* CreateStateMachine() = 0; virtual MediaDecoderStateMachine* CreateStateMachine() = 0;

View File

@ -22,7 +22,9 @@ public:
return NS_OK; return NS_OK;
} }
virtual MediaDecoder* Clone() { return new AndroidMediaDecoder(mType); } virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) {
return new AndroidMediaDecoder(aOwner, mType);
}
virtual MediaDecoderStateMachine* CreateStateMachine(); virtual MediaDecoderStateMachine* CreateStateMachine();
}; };

View File

@ -15,9 +15,9 @@ AppleDecoder::AppleDecoder(MediaDecoderOwner* aOwner)
} }
MediaDecoder * MediaDecoder *
AppleDecoder::Clone() AppleDecoder::Clone(MediaDecoderOwner* aOwner)
{ {
return new AppleDecoder(); return new AppleDecoder(aOwner);
} }
MediaDecoderStateMachine * MediaDecoderStateMachine *

View File

@ -14,7 +14,7 @@ class AppleDecoder : public MediaDecoder
public: public:
explicit AppleDecoder(MediaDecoderOwner* aOwner); explicit AppleDecoder(MediaDecoderOwner* aOwner);
virtual MediaDecoder* Clone() override; virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) override;
virtual MediaDecoderStateMachine* CreateStateMachine() override; virtual MediaDecoderStateMachine* CreateStateMachine() override;
}; };

View File

@ -19,11 +19,11 @@ public:
explicit DirectShowDecoder(MediaDecoderOwner* aOwner); explicit DirectShowDecoder(MediaDecoderOwner* aOwner);
virtual ~DirectShowDecoder(); virtual ~DirectShowDecoder();
MediaDecoder* Clone() override { MediaDecoder* Clone(MediaDecoderOwner* aOwner) override {
if (!IsEnabled()) { if (!IsEnabled()) {
return nullptr; return nullptr;
} }
return new DirectShowDecoder(); return new DirectShowDecoder(aOwner);
} }
MediaDecoderStateMachine* CreateStateMachine() override; MediaDecoderStateMachine* CreateStateMachine() override;

View File

@ -16,11 +16,11 @@ class MP4Decoder : public MediaDecoder
public: public:
explicit MP4Decoder(MediaDecoderOwner* aOwner); explicit MP4Decoder(MediaDecoderOwner* aOwner);
virtual MediaDecoder* Clone() override { virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) override {
if (!IsEnabled()) { if (!IsEnabled()) {
return nullptr; return nullptr;
} }
return new MP4Decoder(); return new MP4Decoder(aOwner);
} }
virtual MediaDecoderStateMachine* CreateStateMachine() override; virtual MediaDecoderStateMachine* CreateStateMachine() override;

View File

@ -16,7 +16,9 @@ class GStreamerDecoder : public MediaDecoder
{ {
public: public:
explicit GStreamerDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {} explicit GStreamerDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
virtual MediaDecoder* Clone() { return new GStreamerDecoder(); } virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) {
return new GStreamerDecoder(aOwner);
}
virtual MediaDecoderStateMachine* CreateStateMachine(); virtual MediaDecoderStateMachine* CreateStateMachine();
static bool CanHandleMediaType(const nsACString& aMIMEType, const nsAString* aCodecs); static bool CanHandleMediaType(const nsACString& aMIMEType, const nsAString* aCodecs);
}; };

View File

@ -35,7 +35,7 @@ MediaSourceDecoder::MediaSourceDecoder(dom::HTMLMediaElement* aElement)
} }
MediaDecoder* MediaDecoder*
MediaSourceDecoder::Clone() MediaSourceDecoder::Clone(MediaDecoderOwner* aOwner)
{ {
// TODO: Sort out cloning. // TODO: Sort out cloning.
return nullptr; return nullptr;

View File

@ -36,7 +36,7 @@ class MediaSourceDecoder : public MediaDecoder
public: public:
explicit MediaSourceDecoder(dom::HTMLMediaElement* aElement); explicit MediaSourceDecoder(dom::HTMLMediaElement* aElement);
virtual MediaDecoder* Clone() override; virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) override;
virtual MediaDecoderStateMachine* CreateStateMachine() override; virtual MediaDecoderStateMachine* CreateStateMachine() override;
virtual nsresult Load(nsIStreamListener**) override; virtual nsresult Load(nsIStreamListener**) override;
virtual media::TimeIntervals GetSeekable() override; virtual media::TimeIntervals GetSeekable() override;

View File

@ -19,11 +19,11 @@ public:
, mShutdownBit(false) , mShutdownBit(false)
{} {}
virtual MediaDecoder* Clone() override { virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) override {
if (!IsOggEnabled()) { if (!IsOggEnabled()) {
return nullptr; return nullptr;
} }
return new OggDecoder(); return new OggDecoder(aOwner);
} }
virtual MediaDecoderStateMachine* CreateStateMachine() override; virtual MediaDecoderStateMachine* CreateStateMachine() override;

View File

@ -12,9 +12,9 @@
namespace mozilla { namespace mozilla {
MediaDecoder* MediaDecoder*
MediaCodecDecoder::Clone() MediaCodecDecoder::Clone(MediaDecoderOwner* aOwner)
{ {
return new MediaCodecDecoder(); return new MediaCodecDecoder(aOwner);
} }
MediaOmxCommonReader* MediaOmxCommonReader*

View File

@ -18,7 +18,7 @@ public:
explicit MediaCodecDecoder(MediaDecoderOwner* aOwner) explicit MediaCodecDecoder(MediaDecoderOwner* aOwner)
: MediaOmxCommonDecoder(aOwner) {} : MediaOmxCommonDecoder(aOwner) {}
virtual MediaDecoder* Clone(); virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner);
virtual MediaOmxCommonReader* CreateReader(); virtual MediaOmxCommonReader* CreateReader();

View File

@ -13,9 +13,9 @@ using namespace android;
namespace mozilla { namespace mozilla {
MediaDecoder* MediaDecoder*
MediaOmxDecoder::Clone() MediaOmxDecoder::Clone(MediaDecoderOwner* aOwner)
{ {
return new MediaOmxDecoder(); return new MediaOmxDecoder(aOwner);
} }
MediaOmxCommonReader* MediaOmxCommonReader*

View File

@ -15,7 +15,7 @@ class MediaOmxDecoder : public MediaOmxCommonDecoder
public: public:
explicit MediaOmxDecoder(MediaDecoderOwner* aOwner) explicit MediaOmxDecoder(MediaDecoderOwner* aOwner)
: MediaOmxCommonDecoder(aOwner) {} : MediaOmxCommonDecoder(aOwner) {}
virtual MediaDecoder* Clone(); virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner);
virtual MediaOmxCommonReader* CreateReader(); virtual MediaOmxCommonReader* CreateReader();
virtual MediaDecoderStateMachine* CreateStateMachineFromReader(MediaOmxCommonReader* aReader); virtual MediaDecoderStateMachine* CreateStateMachineFromReader(MediaOmxCommonReader* aReader);
}; };

View File

@ -13,9 +13,9 @@
namespace mozilla { namespace mozilla {
MediaDecoder* MediaDecoder*
RtspMediaCodecDecoder::Clone() RtspMediaCodecDecoder::Clone(MediaDecoderOwner* aOwner)
{ {
return new RtspMediaCodecDecoder(); return new RtspMediaCodecDecoder(aOwner);
} }
MediaOmxCommonReader* MediaOmxCommonReader*

View File

@ -17,7 +17,7 @@ public:
explicit RtspMediaCodecDecoder(MediaDecoderOwner* aOwner) explicit RtspMediaCodecDecoder(MediaDecoderOwner* aOwner)
: MediaOmxCommonDecoder(aOwner) {} : MediaOmxCommonDecoder(aOwner) {}
virtual MediaDecoder* Clone() override; virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) override;
virtual MediaOmxCommonReader* CreateReader() override; virtual MediaOmxCommonReader* CreateReader() override;

View File

@ -11,9 +11,9 @@
namespace mozilla { namespace mozilla {
MediaDecoder* RtspOmxDecoder::Clone() MediaDecoder* RtspOmxDecoder::Clone(MediaDecoderOwner* aOwner)
{ {
return new RtspOmxDecoder(); return new RtspOmxDecoder(aOwner);
} }
MediaDecoderStateMachine* MediaDecoderStateMachine*

View File

@ -29,7 +29,7 @@ public:
MOZ_COUNT_DTOR(RtspOmxDecoder); MOZ_COUNT_DTOR(RtspOmxDecoder);
} }
virtual MediaDecoder* Clone() override final; virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) override final;
virtual MediaDecoderStateMachine* CreateStateMachine() override final; virtual MediaDecoderStateMachine* CreateStateMachine() override final;
virtual void ChangeState(PlayState aState) override final; virtual void ChangeState(PlayState aState) override final;
}; };

View File

@ -13,11 +13,11 @@ class RawDecoder : public MediaDecoder
{ {
public: public:
explicit RawDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {} explicit RawDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
virtual MediaDecoder* Clone() { virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) {
if (!IsRawEnabled()) { if (!IsRawEnabled()) {
return nullptr; return nullptr;
} }
return new RawDecoder(); return new RawDecoder(aOwner);
} }
virtual MediaDecoderStateMachine* CreateStateMachine(); virtual MediaDecoderStateMachine* CreateStateMachine();
}; };

View File

@ -25,11 +25,11 @@ class WaveDecoder : public MediaDecoder
{ {
public: public:
explicit WaveDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {} explicit WaveDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
virtual MediaDecoder* Clone() { virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) {
if (!IsWaveEnabled()) { if (!IsWaveEnabled()) {
return nullptr; return nullptr;
} }
return new WaveDecoder(); return new WaveDecoder(aOwner);
} }
virtual MediaDecoderStateMachine* CreateStateMachine(); virtual MediaDecoderStateMachine* CreateStateMachine();
}; };

View File

@ -14,11 +14,11 @@ class WebMDecoder : public MediaDecoder
{ {
public: public:
explicit WebMDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {} explicit WebMDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
virtual MediaDecoder* Clone() { virtual MediaDecoder* Clone(MediaDecoderOwner* aOwner) {
if (!IsWebMEnabled()) { if (!IsWebMEnabled()) {
return nullptr; return nullptr;
} }
return new WebMDecoder(); return new WebMDecoder(aOwner);
} }
virtual MediaDecoderStateMachine* CreateStateMachine(); virtual MediaDecoderStateMachine* CreateStateMachine();
}; };