From 2fa451fa7de55d641b397752a18fd5060b0b131f Mon Sep 17 00:00:00 2001 From: JW Wang Date: Wed, 19 Jul 2017 11:24:51 +0800 Subject: [PATCH] Bug 1316211. P1 - make some functions pure virtual for they will be overridden by MFR. r=gerald MozReview-Commit-ID: 9l8MbDRjLR0 --HG-- extra : rebase_source : f055ef64dfc71e0da709aab69db0049cafe10dae extra : source : 2e5c4ae8b368b605f397455b3fede770d546fe86 --- dom/media/MediaDecoderReader.cpp | 104 ------------------------------- dom/media/MediaDecoderReader.h | 40 +++++------- 2 files changed, 16 insertions(+), 128 deletions(-) diff --git a/dom/media/MediaDecoderReader.cpp b/dom/media/MediaDecoderReader.cpp index 452f57ccdf0f..4ef8e588f4bd 100644 --- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -173,14 +173,6 @@ MediaDecoderReader::DecodeToFirstVideoData() return p.forget(); } -void -MediaDecoderReader::UpdateBuffered() -{ - MOZ_ASSERT(OnTaskQueue()); - NS_ENSURE_TRUE_VOID(!mShutdown); - mBuffered = GetBuffered(); -} - void MediaDecoderReader::VisibilityChanged() {} @@ -198,35 +190,6 @@ MediaDecoderReader::GetBuffered() return GetEstimatedBufferedTimeRanges(stream, mDuration->ToMicroseconds()); } -RefPtr -MediaDecoderReader::AsyncReadMetadata() -{ - MOZ_ASSERT(OnTaskQueue()); - DECODER_LOG("MediaDecoderReader::AsyncReadMetadata"); - - // Attempt to read the metadata. - MetadataHolder metadata; - metadata.mInfo = MakeUnique(); - MetadataTags* tags = nullptr; - nsresult rv = ReadMetadata(metadata.mInfo.get(), &tags); - metadata.mTags.reset(tags); - metadata.mInfo->AssertValid(); - - // Update the buffer ranges before resolving the metadata promise. Bug 1320258. - UpdateBuffered(); - - // We're not waiting for anything. If we didn't get the metadata, that's an - // error. - if (NS_FAILED(rv) || !metadata.mInfo->HasValidMedia()) { - DECODER_WARN("ReadMetadata failed, rv=%" PRIx32 " HasValidMedia=%d", - static_cast(rv), metadata.mInfo->HasValidMedia()); - return MetadataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__); - } - - // Success! - return MetadataPromise::CreateAndResolve(Move(metadata), __func__); -} - class ReRequestVideoWithSkipTask : public Runnable { public: @@ -280,73 +243,6 @@ private: RefPtr mReader; }; -RefPtr -MediaDecoderReader::RequestVideoData(const media::TimeUnit& aTimeThreshold) -{ - RefPtr p = mBaseVideoPromise.Ensure(__func__); - bool skip = false; - while (VideoQueue().GetSize() == 0 && - !VideoQueue().IsFinished()) { - if (!DecodeVideoFrame(skip, aTimeThreshold)) { - VideoQueue().Finish(); - } else if (skip) { - // We still need to decode more data in order to skip to the next - // keyframe. Post another task to the decode task queue to decode - // again. We don't just decode straight in a loop here, as that - // would hog the decode task queue. - RefPtr task( - new ReRequestVideoWithSkipTask(this, aTimeThreshold)); - mTaskQueue->Dispatch(task.forget()); - return p; - } - } - if (VideoQueue().GetSize() > 0) { - RefPtr v = VideoQueue().PopFront(); - mBaseVideoPromise.Resolve(v, __func__); - } else if (VideoQueue().IsFinished()) { - mBaseVideoPromise.Reject(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__); - } else { - MOZ_ASSERT(false, "Dropping this promise on the floor"); - } - - return p; -} - -RefPtr -MediaDecoderReader::RequestAudioData() -{ - RefPtr p = mBaseAudioPromise.Ensure(__func__); - while (AudioQueue().GetSize() == 0 && - !AudioQueue().IsFinished()) { - if (!DecodeAudioData()) { - AudioQueue().Finish(); - break; - } - // AudioQueue size is still zero, post a task to try again. Don't spin - // waiting in this while loop since it somehow prevents audio EOS from - // coming in gstreamer 1.x when there is still video buffer waiting to be - // consumed. (|mVideoSinkBufferCount| > 0) - if (AudioQueue().GetSize() == 0) { - RefPtr task(new ReRequestAudioTask(this)); - mTaskQueue->Dispatch(task.forget()); - return p; - } - } - if (AudioQueue().GetSize() > 0) { - RefPtr a = AudioQueue().PopFront(); - mBaseAudioPromise.Resolve(a, __func__); - } else if (AudioQueue().IsFinished()) { - mBaseAudioPromise.Reject(mHitAudioDecodeError - ? NS_ERROR_DOM_MEDIA_FATAL_ERR - : NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__); - mHitAudioDecodeError = false; - } else { - MOZ_ASSERT(false, "Dropping this promise on the floor"); - } - - return p; -} - RefPtr MediaDecoderReader::Shutdown() { diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index a443cc55eec2..9ba5af65e05b 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -122,7 +122,7 @@ public: // Called by MDSM in dormant state to release resources allocated by this // reader. The reader can resume decoding by calling Seek() to a specific // position. - virtual void ReleaseResources() { } + virtual void ReleaseResources() = 0; // Destroys the decoding state. The reader cannot be made usable again. // This is different from ReleaseMediaResources() as it is irreversable, @@ -137,7 +137,7 @@ public: void UpdateDuration(const media::TimeUnit& aDuration); - virtual void UpdateCompositor(already_AddRefed) {} + virtual void UpdateCompositor(already_AddRefed) = 0; // Resets all state related to decoding, emptying all buffers etc. // Cancels all pending Request*Data() request callbacks, rejects any @@ -158,35 +158,32 @@ public: // // The decode should be performed asynchronously, and the promise should // be resolved when it is complete. - virtual RefPtr RequestAudioData(); + virtual RefPtr RequestAudioData() = 0; // Requests one video sample from the reader. virtual RefPtr - RequestVideoData(const media::TimeUnit& aTimeThreshold); + RequestVideoData(const media::TimeUnit& aTimeThreshold) = 0; // By default, the state machine polls the reader once per second when it's // in buffering mode. Some readers support a promise-based mechanism by which // they notify the state machine when the data arrives. - virtual bool IsWaitForDataSupported() const { return false; } + virtual bool IsWaitForDataSupported() const = 0; - virtual RefPtr WaitForData(MediaData::Type aType) - { - MOZ_CRASH(); - } + virtual RefPtr WaitForData(MediaData::Type aType) = 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. - virtual RefPtr AsyncReadMetadata(); + virtual RefPtr AsyncReadMetadata() = 0; // Fills aInfo with the latest cached data required to present the media, // ReadUpdatedMetadata will always be called once ReadMetadata has succeeded. - virtual void ReadUpdatedMetadata(MediaInfo* aInfo) {} + virtual void ReadUpdatedMetadata(MediaInfo* aInfo) = 0; // Moves the decode head to aTime microseconds. virtual RefPtr Seek(const SeekTarget& aTarget) = 0; - virtual void SetCDMProxy(CDMProxy* aProxy) {} + virtual void SetCDMProxy(CDMProxy* aProxy) = 0; // Tell the reader that the data decoded are not for direct playback, so it // can accept more files, in particular those which have more channels than @@ -200,7 +197,7 @@ public: // raw media data is arriving sequentially from a network channel. This // makes sense in the