Bug 1322800 part 14 - remove SeekTask and NextFrameSeekTask; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Fri, 16 Dec 2016 15:29:50 +0800
changeset 450342 1b951a5436d6f1c176d9f129a81b107231b82b55
parent 450341 1b38e6931e5c8f6acbb11dd348beddf373bc7d11
child 450838 11d45f4df5a496f98c6aac53b1eda91957025eaf
push id38836
push userbmo:kaku@mozilla.com
push dateFri, 16 Dec 2016 10:40:27 +0000
reviewersjwwang
bugs1322800
milestone53.0a1
Bug 1322800 part 14 - remove SeekTask and NextFrameSeekTask; r?jwwang MozReview-Commit-ID: 1oHKukYqLO4
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
dom/media/NextFrameSeekTask.cpp
dom/media/NextFrameSeekTask.h
dom/media/SeekTask.cpp
dom/media/SeekTask.h
dom/media/moz.build
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -42,17 +42,16 @@
 #include "ImageContainer.h"
 #include "MediaDecoder.h"
 #include "MediaDecoderReader.h"
 #include "MediaDecoderReaderWrapper.h"
 #include "MediaDecoderStateMachine.h"
 #include "MediaShutdownManager.h"
 #include "MediaPrefs.h"
 #include "MediaTimer.h"
-#include "NextFrameSeekTask.h"
 #include "TimeUnits.h"
 #include "VideoSegment.h"
 #include "VideoUtils.h"
 #include "gfxPrefs.h"
 
 namespace mozilla {
 
 using namespace mozilla::dom;
@@ -791,73 +790,48 @@ public:
 
     ResetMDSM();
 
     DoSeek();
 
     return mSeekJob.mPromise.Ensure(__func__);
   }
 
-  virtual void Exit() override
-  {
-    mSeekTaskRequest.DisconnectIfExists();
-    mSeekJob.RejectIfExists(__func__);
-    mSeekTask->Discard();
-  }
+  virtual void Exit() override = 0;
 
   State GetState() const override
   {
     return DECODER_STATE_SEEKING;
   }
 
-  void HandleAudioDecoded(MediaData* aAudio) override
-  {
-    mSeekTask->HandleAudioDecoded(aAudio);
-  }
-
-  void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override
-  {
-    mSeekTask->HandleVideoDecoded(aVideo, aDecodeStart);
-  }
-
-  void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override
-  {
-    mSeekTask->HandleNotDecoded(aType, aError);
-  }
-
-  void HandleAudioWaited(MediaData::Type aType) override
-  {
-    mSeekTask->HandleAudioWaited(aType);
-  }
-
-  void HandleVideoWaited(MediaData::Type aType) override
-  {
-    mSeekTask->HandleVideoWaited(aType);
-  }
-
-  void HandleNotWaited(const WaitForDataRejectValue& aRejection) override
-  {
-    mSeekTask->HandleNotWaited(aRejection);
-  }
+  void HandleAudioDecoded(MediaData* aAudio) override = 0;
+
+  void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override = 0;
+
+  void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override = 0;
+
+  void HandleAudioWaited(MediaData::Type aType) override = 0;
+
+  void HandleVideoWaited(MediaData::Type aType) override = 0;
+
+  void HandleNotWaited(const WaitForDataRejectValue& aRejection) override = 0;
 
   void HandleVideoSuspendTimeout() override
   {
     // Do nothing since we want a valid video frame to show when seek is done.
   }
 
   void HandleResumeVideoDecoding() override
   {
     // We set mVideoDecodeSuspended to false in Enter().
     MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
   }
 
 protected:
   SeekJob mSeekJob;
-  RefPtr<SeekTask> mSeekTask;
-  MozPromiseRequestHolder<SeekTask::SeekTaskPromise> mSeekTaskRequest;
 
   void SeekCompleted();
 
 private:
   virtual void CreateSeekTask() = 0;
 
   virtual void ResetMDSM() = 0;
 
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -92,17 +92,16 @@ hardware (via AudioStream).
 #include "MediaDecoderReader.h"
 #include "MediaDecoderOwner.h"
 #include "MediaEventSource.h"
 #include "MediaMetadataManager.h"
 #include "MediaStatistics.h"
 #include "MediaTimer.h"
 #include "ImageContainer.h"
 #include "SeekJob.h"
-#include "SeekTask.h"
 
 namespace mozilla {
 
 namespace media {
 class MediaSink;
 }
 
 class AudioSegment;
deleted file mode 100644
--- a/dom/media/NextFrameSeekTask.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "NextFrameSeekTask.h"
-#include "MediaDecoderReaderWrapper.h"
-#include "mozilla/AbstractThread.h"
-#include "mozilla/Assertions.h"
-#include "nsPrintfCString.h"
-
-namespace mozilla {
-
-extern LazyLogModule gMediaSampleLog;
-
-#define SAMPLE_LOG(x, ...) MOZ_LOG(gMediaSampleLog, LogLevel::Debug, \
-  ("[NextFrameSeekTask] Decoder=%p " x, mDecoderID, ##__VA_ARGS__))
-
-namespace media {
-
-NextFrameSeekTask::NextFrameSeekTask(const void* aDecoderID,
-                                     AbstractThread* aThread,
-                                     MediaDecoderReaderWrapper* aReader,
-                                     const SeekTarget& aTarget,
-                                     const MediaInfo& aInfo,
-                                     const media::TimeUnit& aDuration,
-                                     int64_t aCurrentTime,
-                                     MediaQueue<MediaData>& aAudioQueue,
-                                     MediaQueue<MediaData>& aVideoQueue)
-  : SeekTask(aDecoderID, aThread, aReader, aTarget)
-{
-  AssertOwnerThread();
-  MOZ_ASSERT(aInfo.HasVideo());
-}
-
-NextFrameSeekTask::~NextFrameSeekTask()
-{
-  AssertOwnerThread();
-  MOZ_ASSERT(mIsDiscarded);
-}
-
-void
-NextFrameSeekTask::Discard()
-{
-  AssertOwnerThread();
-
-  // Disconnect MDSM.
-  RejectIfExist(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
-
-  mIsDiscarded = true;
-}
-
-int64_t
-NextFrameSeekTask::CalculateNewCurrentTime() const
-{
-  AssertOwnerThread();
-  return 0;
-}
-
-void
-NextFrameSeekTask::HandleAudioDecoded(MediaData* aAudio)
-{
-}
-
-void
-NextFrameSeekTask::HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart)
-{
-}
-
-void
-NextFrameSeekTask::HandleNotDecoded(MediaData::Type aType, const MediaResult& aError)
-{
-}
-
-void
-NextFrameSeekTask::HandleAudioWaited(MediaData::Type aType)
-{
-}
-
-void
-NextFrameSeekTask::HandleVideoWaited(MediaData::Type aType)
-{
-}
-
-void
-NextFrameSeekTask::HandleNotWaited(const WaitForDataRejectValue& aRejection)
-{
-}
-
-RefPtr<NextFrameSeekTask::SeekTaskPromise>
-NextFrameSeekTask::Seek(const media::TimeUnit&)
-{
-  AssertOwnerThread();
-
-  RefPtr<SeekTaskPromise> promise = mSeekTaskPromise.Ensure(__func__);
-
-  return promise;
-}
-
-} // namespace media
-} // namespace mozilla
deleted file mode 100644
--- a/dom/media/NextFrameSeekTask.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef NEXTFRAME_SEEK_TASK_H
-#define NEXTFRAME_SEEK_TASK_H
-
-#include "SeekTask.h"
-#include "MediaDecoderReader.h"
-
-namespace mozilla {
-namespace media {
-
-/*
- * While invoking a NextFrameSeekTask, we don't know the seek target time, what
- * we know is the media's currant position. We use the media's currant position
- * to find out what the next frame is, by traversing through the video queue or
- * asking the decoder to decode more video frames. Once we confirm the next
- * frame, we then know the target time of the NextFrameSeekTask and we update it
- * so that the MDSM will be able to update the media element's position.
- */
-
-class NextFrameSeekTask final : public SeekTask {
-public:
-  NextFrameSeekTask(const void* aDecoderID,
-                   AbstractThread* aThread,
-                   MediaDecoderReaderWrapper* aReader,
-                   const SeekTarget& aTarget,
-                   const MediaInfo& aInfo,
-                   const media::TimeUnit& aDuration,
-                   int64_t aCurrentTime,
-                   MediaQueue<MediaData>& aAudioQueue,
-                   MediaQueue<MediaData>& aVideoQueue);
-
-  void Discard() override;
-
-  RefPtr<SeekTaskPromise> Seek(const media::TimeUnit& aDuration) 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;
-
-  void HandleAudioWaited(MediaData::Type aType) override;
-
-  void HandleVideoWaited(MediaData::Type aType) override;
-
-  void HandleNotWaited(const WaitForDataRejectValue& aRejection) override;
-
-  ~NextFrameSeekTask();
-};
-
-} // namespace media
-} // namespace mozilla
-
-#endif /* NEXTFRAME_SEEK_TASK_H */
deleted file mode 100644
--- a/dom/media/SeekTask.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "SeekTask.h"
-#include "MediaDecoderReaderWrapper.h"
-#include "mozilla/AbstractThread.h"
-
-namespace mozilla {
-
-SeekTask::SeekTask(const void* aDecoderID,
-                   AbstractThread* aThread,
-                   MediaDecoderReaderWrapper* aReader,
-                   const SeekTarget& aTarget)
-  : mDecoderID(aDecoderID)
-  , mOwnerThread(aThread)
-  , mReader(aReader)
-  , mTarget(aTarget)
-  , mIsDiscarded(false)
-  , mIsAudioQueueFinished(false)
-  , mIsVideoQueueFinished(false)
-{
-  AssertOwnerThread();
-}
-
-SeekTask::~SeekTask()
-{
-  AssertOwnerThread();
-  MOZ_ASSERT(mIsDiscarded);
-}
-
-void
-SeekTask::Resolve(const char* aCallSite)
-{
-  AssertOwnerThread();
-
-  SeekTaskResolveValue val;
-  val.mSeekedAudioData = mSeekedAudioData;
-  val.mSeekedVideoData = mSeekedVideoData;
-  val.mIsAudioQueueFinished = mIsAudioQueueFinished;
-  val.mIsVideoQueueFinished = mIsVideoQueueFinished;
-
-  mSeekTaskPromise.Resolve(val, aCallSite);
-}
-
-void
-SeekTask::RejectIfExist(const MediaResult& aError, const char* aCallSite)
-{
-  AssertOwnerThread();
-
-  SeekTaskRejectValue val;
-  val.mIsAudioQueueFinished = mIsAudioQueueFinished;
-  val.mIsVideoQueueFinished = mIsVideoQueueFinished;
-  val.mError = aError;
-
-  mSeekTaskPromise.RejectIfExists(val, aCallSite);
-}
-
-void
-SeekTask::AssertOwnerThread() const
-{
-  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
-}
-
-AbstractThread*
-SeekTask::OwnerThread() const
-{
-  AssertOwnerThread();
-  return mOwnerThread;
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/dom/media/SeekTask.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef SEEK_TASK_H
-#define SEEK_TASK_H
-
-#include "mozilla/MozPromise.h"
-#include "MediaData.h"          // For MediaData::Type.
-#include "MediaDecoderReader.h" // For WaitForDataRejectValue.
-#include "MediaResult.h"
-#include "SeekTarget.h"
-
-namespace mozilla {
-
-class AbstractThread;
-class MediaData;
-class MediaDecoderReaderWrapper;
-
-namespace media {
-class TimeUnit;
-}
-
-struct SeekTaskResolveValue
-{
-  RefPtr<MediaData> mSeekedAudioData;
-  RefPtr<MediaData> mSeekedVideoData;
-  bool mIsAudioQueueFinished;
-  bool mIsVideoQueueFinished;
-};
-
-struct SeekTaskRejectValue
-{
-  SeekTaskRejectValue()
-    : mIsAudioQueueFinished(false)
-    , mIsVideoQueueFinished(false)
-    , mError(NS_ERROR_DOM_MEDIA_FATAL_ERR)
-  {
-  }
-  bool mIsAudioQueueFinished;
-  bool mIsVideoQueueFinished;
-  MediaResult mError;
-};
-
-class SeekTask {
-
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SeekTask)
-
-public:
-  static const bool IsExclusive = true;
-
-  using SeekTaskPromise =
-    MozPromise<SeekTaskResolveValue, SeekTaskRejectValue, IsExclusive>;
-
-  virtual void Discard() = 0;
-
-  virtual RefPtr<SeekTaskPromise> Seek(const media::TimeUnit& aDuration) = 0;
-
-  virtual int64_t CalculateNewCurrentTime() const = 0;
-
-  virtual void HandleAudioDecoded(MediaData* aAudio) = 0;
-
-  virtual void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) = 0;
-
-  virtual void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) = 0;
-
-  virtual void HandleAudioWaited(MediaData::Type aType) = 0;
-
-  virtual void HandleVideoWaited(MediaData::Type aType) = 0;
-
-  virtual void HandleNotWaited(const WaitForDataRejectValue& aRejection) = 0;
-
-protected:
-  SeekTask(const void* aDecoderID,
-           AbstractThread* aThread,
-           MediaDecoderReaderWrapper* aReader,
-           const SeekTarget& aTarget);
-
-  virtual ~SeekTask();
-
-public:
-  void Resolve(const char* aCallSite);
-
-  void RejectIfExist(const MediaResult& aError, const char* aCallSite);
-
-  void AssertOwnerThread() const;
-
-  AbstractThread* OwnerThread() const;
-
-  /*
-   * Data shared with MDSM.
-   */
-  const void* mDecoderID; // For logging.
-  const RefPtr<AbstractThread> mOwnerThread;
-  const RefPtr<MediaDecoderReaderWrapper> mReader;
-
-  /*
-   * Internal state.
-   */
-  SeekTarget mTarget;
-  MozPromiseHolder<SeekTaskPromise> mSeekTaskPromise;
-  bool mIsDiscarded;
-
-  /*
-   * Information which are going to be returned to MDSM.
-   */
-  RefPtr<MediaData> mSeekedAudioData;
-  RefPtr<MediaData> mSeekedVideoData;
-  bool mIsAudioQueueFinished;
-  bool mIsVideoQueueFinished;
-};
-
-} // namespace mozilla
-
-#endif /* SEEK_TASK_H */
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -123,23 +123,21 @@ EXPORTS += [
     'MediaStreamListener.h',
     'MediaStreamVideoSink.h',
     'MediaTimer.h',
     'MediaTrack.h',
     'MediaTrackList.h',
     'MP3Decoder.h',
     'MP3Demuxer.h',
     'MP3FrameParser.h',
-    'NextFrameSeekTask.h',
     'nsIDocumentActivity.h',
     'PrincipalChangeObserver.h',
     'QueueObject.h',
     'SeekJob.h',
     'SeekTarget.h',
-    'SeekTask.h',
     'SelfRef.h',
     'SharedBuffer.h',
     'StreamTracks.h',
     'ThreadPoolCOMListener.h',
     'TimeUnits.h',
     'TrackUnionStream.h',
     'VideoFrameContainer.h',
     'VideoSegment.h',
@@ -230,20 +228,18 @@ UNIFIED_SOURCES += [
     'MediaStreamTrack.cpp',
     'MediaStreamVideoSink.cpp',
     'MediaTimer.cpp',
     'MediaTrack.cpp',
     'MediaTrackList.cpp',
     'MP3Decoder.cpp',
     'MP3Demuxer.cpp',
     'MP3FrameParser.cpp',
-    'NextFrameSeekTask.cpp',
     'QueueObject.cpp',
     'SeekJob.cpp',
-    'SeekTask.cpp',
     'StreamTracks.cpp',
     'TextTrack.cpp',
     'TextTrackCue.cpp',
     'TextTrackCueList.cpp',
     'TextTrackList.cpp',
     'TextTrackRegion.cpp',
     'TrackUnionStream.cpp',
     'VideoFrameContainer.cpp',