Bug 1322800 part 5 - move NextFrameSeekTask::RequestVideoData(); r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 14 Dec 2016 15:04:00 +0800
changeset 450260 3933568cc266355e16b50d6010158bd7931a2d19
parent 450259 3f6d8fe1b3e88b844488c9c325cbf20b42869120
child 450261 8032fb9b691df1eaba58d1b69ee8f44e56444236
push id38817
push userbmo:kaku@mozilla.com
push dateFri, 16 Dec 2016 08:40:33 +0000
reviewersjwwang
bugs1322800
milestone53.0a1
Bug 1322800 part 5 - move NextFrameSeekTask::RequestVideoData(); r?jwwang MozReview-Commit-ID: 8MH6Ztbsxxd
dom/media/MediaDecoderStateMachine.cpp
dom/media/NextFrameSeekTask.cpp
dom/media/NextFrameSeekTask.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1392,17 +1392,17 @@ private:
              [this] (const SeekTaskResolveValue& aValue) {
                OnSeekTaskResolved(aValue);
              },
              [this] (const SeekTaskRejectValue& aValue) {
                OnSeekTaskRejected(aValue);
              }));
 
     if (!mTask->IsVideoRequestPending() && mTask->NeedMoreVideo()) {
-      mTask->RequestVideoData();
+      RequestVideoData();
     }
     MaybeFinishSeek(); // Might resolve mSeekTaskPromise and modify audio queue.
   }
 
   void HandleAudioDecoded(MediaData* aAudio) override
   {
     MOZ_ASSERT(aAudio);
     MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
@@ -1428,17 +1428,17 @@ private:
 
     SSAMPLELOG("OnVideoDecoded [%lld,%lld]", aVideo->mTime, aVideo->GetEndTime());
 
     if (aVideo->mTime > mTask->mCurrentTime) {
       mTask->mSeekedVideoData = aVideo;
     }
 
     if (mTask->NeedMoreVideo()) {
-      mTask->RequestVideoData();
+      RequestVideoData();
       return;
     }
 
     MaybeFinishSeek();
   }
 
   void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override
   {
@@ -1468,17 +1468,17 @@ private:
 
       // Video seek not finished.
       if (mTask->NeedMoreVideo()) {
         switch (aError.Code()) {
           case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
             Reader()->WaitForData(MediaData::VIDEO_DATA);
             break;
           case NS_ERROR_DOM_MEDIA_CANCELED:
-            mTask->RequestVideoData();
+            RequestVideoData();
             break;
           case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
             MOZ_ASSERT(false, "Shouldn't want more data for ended video.");
             break;
           default:
             // Reject the promise since we can't finish video seek anyway.
             mTask->RejectIfExist(aError, __func__);
             break;
@@ -1503,17 +1503,17 @@ private:
     MaybeFinishSeek();
   }
 
   void HandleVideoWaited(MediaData::Type aType) override
   {
     MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
 
     if (mTask->NeedMoreVideo()) {
-      mTask->RequestVideoData();
+      RequestVideoData();
       return;
     }
     MaybeFinishSeek();
   }
 
   void HandleNotWaited(const WaitForDataRejectValue& aRejection) override
   {
     MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
@@ -1585,16 +1585,21 @@ private:
 
     if (aValue.mIsVideoQueueFinished) {
       VideoQueue().Finish();
     }
 
     mMaster->DecodeError(aValue.mError);
   }
 
+  void RequestVideoData()
+  {
+    Reader()->RequestVideoData(false, media::TimeUnit());
+  }
+
   void MaybeFinishSeek()
   {
     if (mTask->IsAudioSeekComplete() && mTask->IsVideoSeekComplete()) {
       mTask->UpdateSeekTargetTime();
 
       auto time = mTask->mTarget.GetTime().ToMicroseconds();
       DiscardFrames(mTask->mAudioQueue, [time] (int64_t aSampleTime) {
         return aSampleTime < time;
--- a/dom/media/NextFrameSeekTask.cpp
+++ b/dom/media/NextFrameSeekTask.cpp
@@ -97,23 +97,16 @@ NextFrameSeekTask::Seek(const media::Tim
 {
   AssertOwnerThread();
 
   RefPtr<SeekTaskPromise> promise = mSeekTaskPromise.Ensure(__func__);
 
   return promise;
 }
 
-void
-NextFrameSeekTask::RequestVideoData()
-{
-  AssertOwnerThread();
-  mReader->RequestVideoData(false, media::TimeUnit());
-}
-
 bool
 NextFrameSeekTask::NeedMoreVideo() const
 {
   AssertOwnerThread();
   // Need to request video when we have none and video queue is not finished.
   return mVideoQueue.GetSize() == 0 &&
          !mSeekedVideoData &&
          !mVideoQueue.IsFinished() &&
--- a/dom/media/NextFrameSeekTask.h
+++ b/dom/media/NextFrameSeekTask.h
@@ -49,18 +49,16 @@ public:
   void HandleAudioWaited(MediaData::Type aType) override;
 
   void HandleVideoWaited(MediaData::Type aType) override;
 
   void HandleNotWaited(const WaitForDataRejectValue& aRejection) override;
 
   ~NextFrameSeekTask();
 
-  void RequestVideoData();
-
   bool NeedMoreVideo() const;
 
   bool IsVideoRequestPending() const;
 
   bool IsAudioSeekComplete() const;
 
   bool IsVideoSeekComplete() const;