Bug 1300956. Part 4 - Implement DecodingFirstFrameState.
MozReview-Commit-ID: DXMv6pGbo7N
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -268,16 +268,33 @@ public:
}
State GetState() const override
{
return DECODER_STATE_DORMANT;
}
};
+class MediaDecoderStateMachine::DecodingFirstFrameState
+ : public MediaDecoderStateMachine::StateObject
+{
+public:
+ explicit DecodingFirstFrameState(Master* aPtr) : StateObject(aPtr) {}
+
+ void Enter() override
+ {
+ mMaster->DecodeFirstFrame();
+ }
+
+ State GetState() const override
+ {
+ return DECODER_STATE_DECODING_FIRSTFRAME;
+ }
+};
+
#define INIT_WATCHABLE(name, val) \
name(val, "MediaDecoderStateMachine::" #name)
#define INIT_MIRROR(name, val) \
name(mTaskQueue, val, "MediaDecoderStateMachine::" #name " (Mirror)")
#define INIT_CANONICAL(name, val) \
name(mTaskQueue, val, "MediaDecoderStateMachine::" #name " (Canonical)")
MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
@@ -1141,16 +1158,19 @@ MediaDecoderStateMachine::SetState(State
mStateObj = MakeUnique<DecodeMetadataState>(this);
break;
case DECODER_STATE_WAIT_FOR_CDM:
mStateObj = MakeUnique<WaitForCDMState>(this);
break;
case DECODER_STATE_DORMANT:
mStateObj = MakeUnique<DormantState>(this);
break;
+ case DECODER_STATE_DECODING_FIRSTFRAME:
+ mStateObj = MakeUnique<DecodingFirstFrameState>(this);
+ break;
default:
mStateObj = nullptr;
break;
}
EnterState();
}
@@ -1184,19 +1204,16 @@ MediaDecoderStateMachine::EnterState()
if (mStateObj) {
MOZ_ASSERT(mState == mStateObj->GetState());
mStateObj->Enter();
return;
}
switch (mState) {
- case DECODER_STATE_DECODING_FIRSTFRAME:
- DecodeFirstFrame();
- break;
case DECODER_STATE_DECODING:
StartDecoding();
break;
case DECODER_STATE_BUFFERING:
StartBuffering();
break;
case DECODER_STATE_COMPLETED:
ScheduleStateMachine();