Bug 1320466 part 2 - implement media data decoded/not-decoded handlers in SeekTask; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Sat, 26 Nov 2016 13:26:46 +0800
changeset 324928 3af879aacac7069f3ba3fdf72c6add8b162957df
parent 324927 d8a14192979c6bd3c14f55d312dfa3e1f63d63e2
child 324929 b40ed2eb5cb52584da45233c96398ada0118ceac
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1320466
milestone53.0a1
Bug 1320466 part 2 - implement media data decoded/not-decoded handlers in SeekTask; r=jwwang MozReview-Commit-ID: ImzEoZQUOtT
dom/media/AccurateSeekTask.cpp
dom/media/AccurateSeekTask.h
dom/media/NextFrameSeekTask.cpp
dom/media/NextFrameSeekTask.h
dom/media/SeekTask.h
--- a/dom/media/AccurateSeekTask.cpp
+++ b/dom/media/AccurateSeekTask.cpp
@@ -107,16 +107,37 @@ AccurateSeekTask::CalculateNewCurrentTim
     const int64_t videoGap = std::abs(videoStart - seekTime);
     return audioGap <= videoGap ? audioStart : videoStart;
   }
 
   MOZ_ASSERT(false, "AccurateSeekTask doesn't handle other seek types.");
   return 0;
 }
 
+void
+AccurateSeekTask::HandleAudioDecoded(MediaData* aAudio)
+{
+  AssertOwnerThread();
+  OnAudioDecoded(aAudio);
+}
+
+void
+AccurateSeekTask::HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart)
+{
+  AssertOwnerThread();
+  OnVideoDecoded(aVideo);
+}
+
+void
+AccurateSeekTask::HandleNotDecoded(MediaData::Type aType, const MediaResult& aError)
+{
+  AssertOwnerThread();
+  OnNotDecoded(aType, aError);
+}
+
 RefPtr<AccurateSeekTask::SeekTaskPromise>
 AccurateSeekTask::Seek(const media::TimeUnit& aDuration)
 {
   AssertOwnerThread();
 
   // Do the seek.
   mSeekRequest.Begin(mReader->Seek(mTarget, aDuration)
     ->Then(OwnerThread(), __func__, this,
--- a/dom/media/AccurateSeekTask.h
+++ b/dom/media/AccurateSeekTask.h
@@ -26,16 +26,22 @@ public:
   void Discard() override;
 
   RefPtr<SeekTaskPromise> Seek(const media::TimeUnit& aDuration) override;
 
   bool NeedToResetMDSM() const override;
 
   int64_t CalculateNewCurrentTime() const override;
 
+  void HandleAudioDecoded(MediaData* aAudio) override;
+
+  void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override;
+
+  void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override;
+
 private:
   ~AccurateSeekTask();
 
   void RequestVideoData();
 
   void RequestAudioData();
 
   nsresult DropAudioUpToSeekTarget(MediaData* aSample);
--- a/dom/media/NextFrameSeekTask.cpp
+++ b/dom/media/NextFrameSeekTask.cpp
@@ -73,16 +73,46 @@ NextFrameSeekTask::CalculateNewCurrentTi
 {
   AssertOwnerThread();
 
   // The HTMLMediaElement.currentTime should be updated to the seek target
   // which has been updated to the next frame's time.
   return mTarget.GetTime().ToMicroseconds();
 }
 
+void
+NextFrameSeekTask::HandleAudioDecoded(MediaData* aAudio)
+{
+  AssertOwnerThread();
+  OnAudioDecoded(aAudio);
+}
+
+void
+NextFrameSeekTask::HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart)
+{
+  AssertOwnerThread();
+  OnVideoDecoded(aVideo);
+}
+
+void
+NextFrameSeekTask::HandleNotDecoded(MediaData::Type aType, const MediaResult& aError)
+{
+  AssertOwnerThread();
+  switch (aType) {
+  case MediaData::AUDIO_DATA:
+    OnAudioNotDecoded(aError);
+    break;
+  case MediaData::VIDEO_DATA:
+    OnVideoNotDecoded(aError);
+    break;
+  default:
+    MOZ_ASSERT_UNREACHABLE("We cannot handle RAW_DATA or NULL_DATA here.");
+  }
+}
+
 /*
  * Remove samples from the queue until aCompare() returns false.
  * aCompare A function object with the signature bool(int64_t) which returns
  *          true for samples that should be removed.
  */
 template <typename Function> static void
 DiscardFrames(MediaQueue<MediaData>& aQueue, const Function& aCompare)
 {
--- a/dom/media/NextFrameSeekTask.h
+++ b/dom/media/NextFrameSeekTask.h
@@ -37,16 +37,22 @@ public:
   void Discard() override;
 
   RefPtr<SeekTaskPromise> Seek(const media::TimeUnit& aDuration) override;
 
   bool NeedToResetMDSM() const override;
 
   int64_t CalculateNewCurrentTime() const override;
 
+  void HandleAudioDecoded(MediaData* aAudio) override;
+
+  void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override;
+
+  void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override;
+
 private:
   ~NextFrameSeekTask();
 
   void RequestVideoData();
 
   bool NeedMoreVideo() const;
 
   bool IsVideoRequestPending() const;
--- a/dom/media/SeekTask.h
+++ b/dom/media/SeekTask.h
@@ -57,16 +57,22 @@ public:
   virtual RefPtr<SeekTaskPromise> Seek(const media::TimeUnit& aDuration) = 0;
 
   virtual bool NeedToResetMDSM() const = 0;
 
   virtual int64_t CalculateNewCurrentTime() const = 0;
 
   const SeekTarget& GetSeekTarget();
 
+  virtual void HandleAudioDecoded(MediaData* aAudio) = 0;
+
+  virtual void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) = 0;
+
+  virtual void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) = 0;
+
 protected:
   SeekTask(const void* aDecoderID,
            AbstractThread* aThread,
            MediaDecoderReaderWrapper* aReader,
            const SeekTarget& aTarget);
 
   virtual ~SeekTask();