diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index 55502f622b07..fd30bf7c3d3e 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -373,7 +373,7 @@ DecoderTraits::CreateReader(const MediaContainerType& aType, #ifdef MOZ_ANDROID_OMX if (MediaDecoder::IsAndroidMediaPluginEnabled() && EnsureAndroidMediaPluginHost()->FindDecoder(aType, nullptr)) { - decoderReader = new AndroidMediaReader(aDecoder, aType); + decoderReader = new AndroidMediaReader(aDecoder, aType, aResource); } else #endif if (WebMDecoder::IsSupportedType(aType)) { diff --git a/dom/media/MediaDecoderReader.cpp b/dom/media/MediaDecoderReader.cpp index 82f59cdbb825..3656e2f5f817 100644 --- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -68,7 +68,8 @@ public: size_t mSize; }; -MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder) +MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder, + MediaResource* aResource) : mAudioCompactor(mAudioQueue) , mDecoder(aDecoder) , mTaskQueue(new TaskQueue( @@ -81,6 +82,7 @@ MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder) , mIgnoreAudioOutputFormat(false) , mHitAudioDecodeError(false) , mShutdown(false) + , mResource(aResource) { MOZ_COUNT_CTOR(MediaDecoderReader); MOZ_ASSERT(NS_IsMainThread()); @@ -206,7 +208,7 @@ MediaDecoderReader::GetBuffered() { MOZ_ASSERT(OnTaskQueue()); - AutoPinned stream(mDecoder->GetResource()); + AutoPinned stream(mResource); if (!mDuration.Ref().isSome()) { return TimeIntervals(); diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index 661866be593e..c458f3f33e3f 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -97,7 +97,8 @@ public: // The caller must ensure that Shutdown() is called before aDecoder is // destroyed. - explicit MediaDecoderReader(AbstractMediaDecoder* aDecoder); + explicit MediaDecoderReader(AbstractMediaDecoder* aDecoder, + MediaResource* aResource = nullptr); // Initializes the reader, returns NS_OK on success, or NS_ERROR_FAILURE // on failure. @@ -321,6 +322,8 @@ protected: // Notify if we are waiting for a decryption key. MediaEventProducer mOnTrackWaitingForKey; + RefPtr mResource; + private: virtual nsresult InitInternal() { return NS_OK; } diff --git a/dom/media/android/AndroidMediaDecoder.cpp b/dom/media/android/AndroidMediaDecoder.cpp index 61e40e62e597..bf8cfcb9cc0a 100644 --- a/dom/media/android/AndroidMediaDecoder.cpp +++ b/dom/media/android/AndroidMediaDecoder.cpp @@ -19,7 +19,8 @@ AndroidMediaDecoder::AndroidMediaDecoder(MediaDecoderInit& aInit, MediaDecoderStateMachine* AndroidMediaDecoder::CreateStateMachine() { - return new MediaDecoderStateMachine(this, new AndroidMediaReader(this, mType)); + return new MediaDecoderStateMachine( + this, new AndroidMediaReader(this, mType, mResource)); } } // namespace mozilla diff --git a/dom/media/android/AndroidMediaReader.cpp b/dom/media/android/AndroidMediaReader.cpp index 332e6ee3c0c2..9f2b1a050cdd 100644 --- a/dom/media/android/AndroidMediaReader.cpp +++ b/dom/media/android/AndroidMediaReader.cpp @@ -26,8 +26,9 @@ typedef mozilla::layers::Image Image; typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage; AndroidMediaReader::AndroidMediaReader(AbstractMediaDecoder *aDecoder, - const MediaContainerType& aContainerType) : - MediaDecoderReader(aDecoder), + const MediaContainerType& aContainerType, + MediaResource* aResource) : + MediaDecoderReader(aDecoder, aResource), mType(aContainerType), mPlugin(nullptr), mHasAudio(false), @@ -43,7 +44,7 @@ nsresult AndroidMediaReader::ReadMetadata(MediaInfo* aInfo, MOZ_ASSERT(OnTaskQueue()); if (!mPlugin) { - mPlugin = GetAndroidMediaPluginHost()->CreateDecoder(mDecoder->GetResource(), mType); + mPlugin = GetAndroidMediaPluginHost()->CreateDecoder(mResource, mType); if (!mPlugin) { return NS_ERROR_FAILURE; } @@ -169,7 +170,7 @@ bool AndroidMediaReader::DecodeVideoFrame(bool& aKeyframeSkip, return true; currentImage = bufferCallback.GetImage(); - int64_t pos = mDecoder->GetResource()->Tell(); + int64_t pos = mResource->Tell(); IntRect picture = mPicture; RefPtr v; @@ -274,7 +275,7 @@ bool AndroidMediaReader::DecodeAudioData() MOZ_ASSERT(OnTaskQueue()); // This is the approximate byte position in the stream. - int64_t pos = mDecoder->GetResource()->Tell(); + int64_t pos = mResource->Tell(); // Read next frame MPAPI::AudioFrame source; diff --git a/dom/media/android/AndroidMediaReader.h b/dom/media/android/AndroidMediaReader.h index 34ad57b1fcd8..01e293b653c3 100644 --- a/dom/media/android/AndroidMediaReader.h +++ b/dom/media/android/AndroidMediaReader.h @@ -38,7 +38,8 @@ class AndroidMediaReader : public MediaDecoderReader MozPromiseRequestHolder mSeekRequest; public: AndroidMediaReader(AbstractMediaDecoder* aDecoder, - const MediaContainerType& aContainerType); + const MediaContainerType& aContainerType, + MediaResource* aResource); nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack, TrackInfo::kVideoTrack)) override;