diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index 7c64bd44b4d2..032382a02093 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -165,9 +165,6 @@ public: // upon calls to Request{Audio,Video}Data. virtual void SetDemuxOnly(bool /*aDemuxedOnly*/) {} - virtual bool HasAudio() = 0; - virtual bool HasVideo() = 0; - // The default implementation of AsyncReadMetadata is implemented in terms of // synchronous ReadMetadata() calls. Implementations may also // override AsyncReadMetadata to create a more proper async implementation. @@ -255,21 +252,9 @@ public: UpdateBuffered(); } - // Notify the reader that data from the resource was evicted - // (MediaSource only). - virtual void NotifyDataRemoved() {} - virtual MediaQueue& AudioQueue() { return mAudioQueue; } virtual MediaQueue& VideoQueue() { return mVideoQueue; } - // Returns a pointer to the decoder. - AbstractMediaDecoder* GetDecoder() - { - return mDecoder; - } - - MediaInfo GetMediaInfo() { return mInfo; } - AbstractCanonical* CanonicalBuffered() { return &mBuffered; diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 13f4a1acc1bd..89f79fdbfe41 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -1544,11 +1544,8 @@ MediaFormatReader::NotifyDemuxer(uint32_t aLength, int64_t aOffset) return; } - if (aLength || aOffset) { - mDemuxer->NotifyDataArrived(); - } else { - mDemuxer->NotifyDataRemoved(); - } + mDemuxer->NotifyDataArrived(); + if (!mInitDone) { return; } @@ -1571,14 +1568,6 @@ MediaFormatReader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) NotifyDemuxer(aLength, aOffset); } -void -MediaFormatReader::NotifyDataRemoved() -{ - MOZ_ASSERT(OnTaskQueue()); - - NotifyDemuxer(0, 0); -} - bool MediaFormatReader::ForceZeroStartTime() const { diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index 6b71edc1565d..f14552ceca4c 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -42,16 +42,6 @@ public: RefPtr RequestAudioData() override; - bool HasVideo() override - { - return mVideo.mTrackDemuxer; - } - - bool HasAudio() override - { - return mAudio.mTrackDemuxer; - } - RefPtr AsyncReadMetadata() override; void ReadUpdatedMetadata(MediaInfo* aInfo) override; @@ -66,9 +56,8 @@ public: protected: void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override; -public: - void NotifyDataRemoved() override; +public: media::TimeIntervals GetBuffered() override; virtual bool ForceZeroStartTime() const override; @@ -113,6 +102,9 @@ public: #endif private: + bool HasVideo() { return mVideo.mTrackDemuxer; } + bool HasAudio() { return mAudio.mTrackDemuxer; } + bool IsWaitingOnCDMResource(); bool InitDemuxer(); diff --git a/dom/media/android/AndroidMediaReader.h b/dom/media/android/AndroidMediaReader.h index 9f1888181be5..9e43b817e215 100644 --- a/dom/media/android/AndroidMediaReader.h +++ b/dom/media/android/AndroidMediaReader.h @@ -48,16 +48,6 @@ public: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold); - virtual bool HasAudio() - { - return mHasAudio; - } - - virtual bool HasVideo() - { - return mHasVideo; - } - virtual bool IsMediaSeekable() { // not used diff --git a/dom/media/apple/AppleMP3Reader.cpp b/dom/media/apple/AppleMP3Reader.cpp index 6480248bdf61..c5c7a6b006da 100644 --- a/dom/media/apple/AppleMP3Reader.cpp +++ b/dom/media/apple/AppleMP3Reader.cpp @@ -303,21 +303,6 @@ AppleMP3Reader::DecodeVideoFrame(bool &aKeyframeSkip, return false; } - -bool -AppleMP3Reader::HasAudio() -{ - MOZ_ASSERT(OnTaskQueue()); - return mStreamReady; -} - -bool -AppleMP3Reader::HasVideo() -{ - MOZ_ASSERT(OnTaskQueue()); - return false; -} - bool AppleMP3Reader::IsMediaSeekable() { diff --git a/dom/media/apple/AppleMP3Reader.h b/dom/media/apple/AppleMP3Reader.h index dffa6bf5d500..f718a02528cb 100644 --- a/dom/media/apple/AppleMP3Reader.h +++ b/dom/media/apple/AppleMP3Reader.h @@ -28,9 +28,6 @@ public: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override; - virtual bool HasAudio() override; - virtual bool HasVideo() override; - virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override; diff --git a/dom/media/directshow/DirectShowReader.cpp b/dom/media/directshow/DirectShowReader.cpp index a475ff03b4ea..7d493b0a079c 100644 --- a/dom/media/directshow/DirectShowReader.cpp +++ b/dom/media/directshow/DirectShowReader.cpp @@ -341,20 +341,6 @@ DirectShowReader::DecodeVideoFrame(bool &aKeyframeSkip, return false; } -bool -DirectShowReader::HasAudio() -{ - MOZ_ASSERT(OnTaskQueue()); - return true; -} - -bool -DirectShowReader::HasVideo() -{ - MOZ_ASSERT(OnTaskQueue()); - return false; -} - RefPtr DirectShowReader::Seek(int64_t aTargetUs, int64_t aEndTime) { diff --git a/dom/media/directshow/DirectShowReader.h b/dom/media/directshow/DirectShowReader.h index 8d80125ed23b..31ca2f64bc0e 100644 --- a/dom/media/directshow/DirectShowReader.h +++ b/dom/media/directshow/DirectShowReader.h @@ -47,9 +47,6 @@ public: bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override; - bool HasAudio() override; - bool HasVideo() override; - nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override; diff --git a/dom/media/gstreamer/GStreamerReader.h b/dom/media/gstreamer/GStreamerReader.h index 6210af6cf38e..e34028e274e6 100644 --- a/dom/media/gstreamer/GStreamerReader.h +++ b/dom/media/gstreamer/GStreamerReader.h @@ -56,21 +56,13 @@ protected: virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override; public: - - virtual bool HasAudio() override { - return mInfo.HasAudio(); - } - - virtual bool HasVideo() override { - return mInfo.HasVideo(); - } - layers::ImageContainer* GetImageContainer() { return mDecoder->GetImageContainer(); } virtual bool IsMediaSeekable() override; private: - + bool HasAudio() { return mInfo.HasAudio(); } + bool HasVideo() { return mInfo.HasVideo(); } void ReadAndPushData(guint aLength); RefPtr GetImageFromBuffer(GstBuffer* aBuffer); void CopyIntoImageBuffer(GstBuffer *aBuffer, GstBuffer** aOutBuffer, RefPtr &image); diff --git a/dom/media/ogg/OggReader.h b/dom/media/ogg/OggReader.h index 5397e5296e07..bb715d4ced1a 100644 --- a/dom/media/ogg/OggReader.h +++ b/dom/media/ogg/OggReader.h @@ -60,15 +60,6 @@ public: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override; - virtual bool HasAudio() override { - return (mVorbisState != 0 && mVorbisState->mActive) || - (mOpusState != 0 && mOpusState->mActive); - } - - virtual bool HasVideo() override { - return mTheoraState != 0 && mTheoraState->mActive; - } - virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override; virtual RefPtr @@ -78,6 +69,15 @@ public: virtual bool IsMediaSeekable() override; private: + bool HasAudio() { + return (mVorbisState != 0 && mVorbisState->mActive) || + (mOpusState != 0 && mOpusState->mActive); + } + + bool HasVideo() { + return mTheoraState != 0 && mTheoraState->mActive; + } + // TODO: DEPRECATED. This uses synchronous decoding. // Stores the presentation time of the first frame we'd be able to play if // we started playback at the current position. Returns the first video diff --git a/dom/media/omx/MediaCodecReader.h b/dom/media/omx/MediaCodecReader.h index f3be13e4adc3..3e8c86350afd 100644 --- a/dom/media/omx/MediaCodecReader.h +++ b/dom/media/omx/MediaCodecReader.h @@ -86,9 +86,6 @@ public: // Disptach a DecodeAduioDataTask to decode video data. virtual RefPtr RequestAudioData() override; - virtual bool HasAudio(); - virtual bool HasVideo(); - virtual RefPtr AsyncReadMetadata() override; // Moves the decode head to aTime microseconds. aStartTime and aEndTime @@ -181,6 +178,8 @@ protected: MozPromiseHolder mMediaResourcePromise; private: + virtual bool HasAudio() override; + virtual bool HasVideo() override; // An intermediary class that can be managed by android::sp. // Redirect codecReserved() and codecCanceled() to MediaCodecReader. diff --git a/dom/media/omx/MediaOmxCommonReader.h b/dom/media/omx/MediaOmxCommonReader.h index d70f3c7cea52..022ff52f37ae 100644 --- a/dom/media/omx/MediaOmxCommonReader.h +++ b/dom/media/omx/MediaOmxCommonReader.h @@ -49,6 +49,10 @@ protected: android::MediaStreamSource* mStreamSource; // Get value from the preferece, if true, we stop the audio offload. bool IsMonoAudioEnabled(); + +private: + virtual bool HasAudio() = 0; + virtual bool HasVideo() = 0; }; } // namespace mozilla diff --git a/dom/media/omx/MediaOmxReader.h b/dom/media/omx/MediaOmxReader.h index 155d66b05d82..2922adb4f967 100644 --- a/dom/media/omx/MediaOmxReader.h +++ b/dom/media/omx/MediaOmxReader.h @@ -85,16 +85,6 @@ public: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold); - virtual bool HasAudio() - { - return mHasAudio; - } - - virtual bool HasVideo() - { - return mHasVideo; - } - virtual void ReleaseMediaResources() override; virtual RefPtr AsyncReadMetadata() override; @@ -118,6 +108,9 @@ private: class ProcessCachedDataTask; class NotifyDataArrivedRunnable; + virtual bool HasAudio() override { return mHasAudio; } + virtual bool HasVideo() override { return mHasVideo; } + bool IsShutdown() { MutexAutoLock lock(mShutdownMutex); return mIsShutdown; diff --git a/dom/media/raw/RawReader.h b/dom/media/raw/RawReader.h index e0481e901329..d4ff7f72e76d 100644 --- a/dom/media/raw/RawReader.h +++ b/dom/media/raw/RawReader.h @@ -26,16 +26,6 @@ public: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override; - virtual bool HasAudio() override - { - return false; - } - - virtual bool HasVideo() override - { - return true; - } - virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override; virtual RefPtr diff --git a/dom/media/wave/WaveReader.h b/dom/media/wave/WaveReader.h index 468e20a3fcf1..cc9708152db5 100644 --- a/dom/media/wave/WaveReader.h +++ b/dom/media/wave/WaveReader.h @@ -26,16 +26,6 @@ public: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override; - virtual bool HasAudio() override - { - return true; - } - - virtual bool HasVideo() override - { - return false; - } - virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override; virtual RefPtr diff --git a/dom/media/webm/WebMReader.h b/dom/media/webm/WebMReader.h index 3434eef9618c..ea14e5ecbc35 100644 --- a/dom/media/webm/WebMReader.h +++ b/dom/media/webm/WebMReader.h @@ -69,6 +69,14 @@ protected: ~WebMReader(); public: + // Returns a pointer to the decoder. + AbstractMediaDecoder* GetDecoder() + { + return mDecoder; + } + + MediaInfo GetMediaInfo() { return mInfo; } + virtual RefPtr Shutdown() override; virtual nsresult Init() override; virtual nsresult ResetDecode() override; @@ -77,18 +85,6 @@ public: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override; - virtual bool HasAudio() override - { - MOZ_ASSERT(OnTaskQueue()); - return mHasAudio; - } - - virtual bool HasVideo() override - { - MOZ_ASSERT(OnTaskQueue()); - return mHasVideo; - } - virtual RefPtr AsyncReadMetadata() override; virtual RefPtr