Bug 1498440 - part2 : implement state transition. r=jya

If looping is on, decoding state will be 'loopingDecoding' state.

Differential Revision: https://phabricator.services.mozilla.com/D9187

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2018-11-05 22:02:58 +00:00
Родитель 9cce4dc5eb
Коммит 75004e489e
1 изменённых файлов: 27 добавлений и 8 удалений

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

@ -225,6 +225,8 @@ public:
virtual nsCString GetDebugInfo() { return nsCString(); }
virtual void HandleLoopingChanged() {}
private:
template <class S, typename R, typename... As>
auto ReturnTypeHelper(R(S::*)(As...)) -> R;
@ -305,6 +307,8 @@ protected:
RefPtr<MediaDecoder::SeekPromise>
SetSeekingState(SeekJob&& aSeekJob, EventVisibility aVisibility);
void SetDecodingState();
// Take a raw pointer in order not to change the life cycle of MDSM.
// It is guaranteed to be valid by MDSM.
Master* mMaster;
@ -706,6 +710,11 @@ public:
return nsPrintfCString("mIsPrerolling=%d", mIsPrerolling);
}
void HandleLoopingChanged() override
{
SetDecodingState();
}
protected:
virtual void EnsureAudioDecodeTaskQueued();
@ -828,7 +837,9 @@ class MediaDecoderStateMachine::LoopingDecodingState
public:
explicit LoopingDecodingState(Master* aPtr)
: DecodingState(aPtr)
{}
{
MOZ_ASSERT(mMaster->mLooping);
}
void Exit() override
{
@ -1018,7 +1029,7 @@ protected:
virtual void DoSeek() = 0;
// Transition to the next state (defined by the subclass) when seek is completed.
virtual void GoToNextState() { SetState<DecodingState>(); }
virtual void GoToNextState() { SetDecodingState(); }
void SeekCompleted();
virtual TimeUnit CalculateNewCurrentTime() const = 0;
};
@ -2297,6 +2308,16 @@ StateObject::SetSeekingState(SeekJob&& aSeekJob, EventVisibility aVisibility)
return nullptr;
}
void
MediaDecoderStateMachine::StateObject::SetDecodingState()
{
if (mMaster->mLooping) {
SetState<LoopingDecodingState>();
return;
}
SetState<DecodingState>();
}
void
MediaDecoderStateMachine::
DecodeMetadataState::OnMetadataRead(MetadataHolder&& aMetadata)
@ -2367,7 +2388,7 @@ DecodingFirstFrameState::Enter()
{
// Transition to DECODING if we've decoded first frames.
if (mMaster->mSentFirstFrameLoadedEvent) {
SetState<DecodingState>();
SetDecodingState();
return;
}
@ -2397,7 +2418,7 @@ DecodingFirstFrameState::MaybeFinishDecodeFirstFrame()
if (mPendingSeek.Exists()) {
SetSeekingState(std::move(mPendingSeek), EventVisibility::Observable);
} else {
SetState<DecodingState>();
SetDecodingState();
}
}
@ -2713,7 +2734,7 @@ BufferingState::Step()
}
SLOG("Buffered for %.3lfs", (now - mBufferingStart).ToSeconds());
SetState<DecodingState>();
SetDecodingState();
}
void
@ -3786,9 +3807,7 @@ void
MediaDecoderStateMachine::LoopingChanged()
{
MOZ_ASSERT(OnTaskQueue());
if (mSeamlessLoopingAllowed) {
mReader->SetSeamlessLoopingEnabled(mLooping);
}
mStateObj->HandleLoopingChanged();
}
RefPtr<GenericPromise>