Bug 1320466 part 4 - delegate OnAudioWaited, OnVideoWaited and OnNotWaited events to state objects; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Sat, 26 Nov 2016 14:12:01 +0800
changeset 324930 e102e1d94504b6e93256a1613a0f9a9240ae941c
parent 324929 b40ed2eb5cb52584da45233c96398ada0118ceac
child 324931 38c2d58de393339a8ffc76e188f0e4ff68844229
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1320466
milestone53.0a1
Bug 1320466 part 4 - delegate OnAudioWaited, OnVideoWaited and OnNotWaited events to state objects; r=jwwang MozReview-Commit-ID: I5tFVziVE02
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -192,16 +192,19 @@ public:
   virtual void Step() {}   // Perform a 'cycle' of this state object.
   virtual State GetState() const = 0;
 
   // Event handlers for various events.
   virtual void HandleCDMProxyReady() {}
   virtual void HandleAudioDecoded(MediaData* aAudio) {}
   virtual void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) {}
   virtual void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError);
+  virtual void HandleAudioWaited(MediaData::Type aType);
+  virtual void HandleVideoWaited(MediaData::Type aType);
+  virtual void HandleNotWaited(const WaitForDataRejectValue& aRejection);
   virtual void HandleEndOfStream() {}
   virtual void HandleWaitingForData() {}
   virtual void HandleAudioCaptured() {}
 
   virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget);
 
   virtual RefPtr<ShutdownPromise> HandleShutdown();
 
@@ -1184,16 +1187,37 @@ StateObject::HandleNotDecoded(MediaData:
     AudioQueue().Finish();
   } else {
     VideoQueue().Finish();
   }
 
   HandleEndOfStream();
 }
 
+void
+MediaDecoderStateMachine::
+StateObject::HandleAudioWaited(MediaData::Type aType)
+{
+  mMaster->EnsureAudioDecodeTaskQueued();
+}
+
+void
+MediaDecoderStateMachine::
+StateObject::HandleVideoWaited(MediaData::Type aType)
+{
+  mMaster->EnsureVideoDecodeTaskQueued();
+}
+
+void
+MediaDecoderStateMachine::
+StateObject::HandleNotWaited(const WaitForDataRejectValue& aRejection)
+{
+
+}
+
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::
 StateObject::HandleSeek(SeekTarget aTarget)
 {
   SLOG("Changed state to SEEKING (to %lld)", aTarget.GetTime().ToMicroseconds());
   SeekJob seekJob;
   seekJob.mTarget = aTarget;
   return SetState<SeekingState>(Move(seekJob), EventVisibility::Observable);
@@ -1998,31 +2022,32 @@ MediaDecoderStateMachine::OnVideoDecoded
   mStateObj->HandleVideoDecoded(aVideo, aDecodeStartTime);
 }
 
 void
 MediaDecoderStateMachine::OnAudioWaited(MediaData::Type aType)
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(aType == MediaData::AUDIO_DATA);
-  EnsureAudioDecodeTaskQueued();
+  mStateObj->HandleAudioWaited(aType);
 }
 
 void
 MediaDecoderStateMachine::OnVideoWaited(MediaData::Type aType)
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(aType == MediaData::VIDEO_DATA);
-  EnsureVideoDecodeTaskQueued();
+  mStateObj->HandleVideoWaited(aType);
 }
 
 void
 MediaDecoderStateMachine::OnNotWaited(const WaitForDataRejectValue& aRejection)
 {
   MOZ_ASSERT(OnTaskQueue());
+  mStateObj->HandleNotWaited(aRejection);
 }
 
 bool
 MediaDecoderStateMachine::IsAudioDecoding()
 {
   MOZ_ASSERT(OnTaskQueue());
   return HasAudio() && !AudioQueue().IsFinished();
 }