From 0451648c60831f8cfc1bf5f2eb232e86e6373d68 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 17 Oct 2023 13:31:40 +0200 Subject: Issue #2346 - Remove MDSM "Wait for CDM" state Without EME we don't need the machinery to wait for an external CDM module to be ready in our mediadecoder. --- dom/media/MediaDecoderStateMachine.cpp | 82 +--------------------------------- dom/media/MediaDecoderStateMachine.h | 2 - 2 files changed, 2 insertions(+), 82 deletions(-) diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 218bddc4ac..dc82e89e34 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -271,7 +271,6 @@ protected: * * Transition to other states when decoding metadata is done: * SHUTDOWN if failing to decode metadata. - * WAIT_FOR_CDM if the media is encrypted and CDM is not available. * DECODING_FIRSTFRAME otherwise. */ class MediaDecoderStateMachine::DecodeMetadataState @@ -341,60 +340,6 @@ private: MozPromiseRequestHolder mMetadataRequest; }; -/** - * Purpose: wait for the CDM to start decoding. - * - * Transition to other states when CDM is ready: - * DECODING_FIRSTFRAME otherwise. - */ -class MediaDecoderStateMachine::WaitForCDMState - : public MediaDecoderStateMachine::StateObject -{ -public: - explicit WaitForCDMState(Master* aPtr) : StateObject(aPtr) {} - - void Enter() - { - MOZ_ASSERT(!mMaster->mVideoDecodeSuspended); - } - - void Exit() override - { - // mPendingSeek is either moved in HandleCDMProxyReady() or should be - // rejected here before transition to SHUTDOWN. - mPendingSeek.RejectIfExists(__func__); - } - - State GetState() const override - { - return DECODER_STATE_WAIT_FOR_CDM; - } - - void HandleCDMProxyReady() override; - - RefPtr HandleSeek(SeekTarget aTarget) override - { - SLOG("Not Enough Data to seek at this stage, queuing seek"); - mPendingSeek.RejectIfExists(__func__); - mPendingSeek.mTarget = aTarget; - return mPendingSeek.mPromise.Ensure(__func__); - } - - void HandleVideoSuspendTimeout() override - { - // Do nothing since no decoders are created yet. - } - - void HandleResumeVideoDecoding() override - { - // We never suspend video decoding in this state. - MOZ_ASSERT(false, "Shouldn't have suspended video decoding."); - } - -private: - SeekJob mPendingSeek; -}; - /** * Purpose: release decoder resources to save memory and hardware resources. * @@ -1231,29 +1176,14 @@ DecodeMetadataState::OnMetadataRead(MetadataHolder* aMetadata) mMaster->GetAmpleVideoFrames()); } - // In general, we wait until we know the duration before notifying the decoder. - // However, we notify unconditionally in this case without waiting for the start - // time, since the caller might be waiting on metadataloaded to be fired before - // feeding in the CDM, which we need to decode the first frame (and - // thus get the metadata). We could fix this if we could compute the start - // time by demuxing without necessaring decoding. - bool waitingForCDM = - false; - mMaster->mNotifyMetadataBeforeFirstFrame = - mMaster->mDuration.Ref().isSome() || waitingForCDM; + mMaster->mDuration.Ref().isSome(); if (mMaster->mNotifyMetadataBeforeFirstFrame) { mMaster->EnqueueLoadedMetadataEvent(); } - if (waitingForCDM) { - // Metadata parsing was successful but we're still waiting for CDM caps - // to become available so that we can build the correct decryptor/decoder. - SetState(); - } else { - SetState(SeekJob{}); - } + SetState(SeekJob{}); } void @@ -1267,13 +1197,6 @@ DormantState::HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) } } -void -MediaDecoderStateMachine:: -WaitForCDMState::HandleCDMProxyReady() -{ - SetState(Move(mPendingSeek)); -} - void MediaDecoderStateMachine:: DecodingFirstFrameState::Enter(SeekJob aPendingSeek) @@ -2249,7 +2172,6 @@ MediaDecoderStateMachine::ToStateStr(State aState) { switch (aState) { case DECODER_STATE_DECODING_METADATA: return "DECODING_METADATA"; - case DECODER_STATE_WAIT_FOR_CDM: return "WAIT_FOR_CDM"; case DECODER_STATE_DORMANT: return "DORMANT"; case DECODER_STATE_DECODING_FIRSTFRAME: return "DECODING_FIRSTFRAME"; case DECODER_STATE_DECODING: return "DECODING"; diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 6391c85740..ba9034e4fa 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -155,7 +155,6 @@ public: // Enumeration for the valid decoding states enum State { DECODER_STATE_DECODING_METADATA, - DECODER_STATE_WAIT_FOR_CDM, DECODER_STATE_DORMANT, DECODER_STATE_DECODING_FIRSTFRAME, DECODER_STATE_DECODING, @@ -263,7 +262,6 @@ public: private: class StateObject; class DecodeMetadataState; - class WaitForCDMState; class DormantState; class DecodingFirstFrameState; class DecodingState; -- cgit v1.2.3