Bug 1294384 - make video-only attribute orthogonal to the seek type; r?jwwang draft
authorKaku Kuo <tkuo@mozilla.com>
Fri, 12 Aug 2016 11:45:02 +0800
changeset 399809 02141d0351fed13066010a4e1a63835946964725
parent 399490 72457716e9b8347299700b9a4837ffb46b8e0a78
child 399888 b5a6368e79c8579cf099852324785ce05e6a0123
push id26003
push usertkuo@mozilla.com
push dateFri, 12 Aug 2016 06:23:15 +0000
reviewersjwwang
bugs1294384
milestone51.0a1
Bug 1294384 - make video-only attribute orthogonal to the seek type; r?jwwang MozReview-Commit-ID: 2oBjuiN7pLn
dom/media/MediaDecoderStateMachine.cpp
dom/media/SeekTarget.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1139,16 +1139,17 @@ MediaDecoderStateMachine::SetDormant(boo
         // Keep latest seek target
       } else if (mCurrentSeek.Exists()) {
         // Because both audio and video decoders are going to be reset in this
         // method later, we treat a VideoOnly seek task as a normal Accurate
         // seek task so that while it is resumed, both audio and video playback
         // are handled.
         if (mCurrentSeek.mTarget.IsVideoOnly()) {
           mCurrentSeek.mTarget.SetType(SeekTarget::Accurate);
+          mCurrentSeek.mTarget.SetVideoOnly(false);
         }
         mQueuedSeek = Move(mCurrentSeek);
         mSeekTaskRequest.DisconnectIfExists();
       } else {
         mQueuedSeek.mTarget = SeekTarget(mCurrentPosition,
                                          SeekTarget::Accurate,
                                          MediaDecoderEventVisibility::Suppressed);
         // XXXbholley - Nobody is listening to this promise. Do we need to pass it
@@ -1364,18 +1365,19 @@ void MediaDecoderStateMachine::Visibilit
     // one to catch up.
     if (mSeekTask || mQueuedSeek.Exists()) {
       return;
     }
 
     // Start video-only seek to the current time...
     SeekJob seekJob;
     seekJob.mTarget = SeekTarget(GetMediaTime(),
-                                 SeekTarget::Type::AccurateVideoOnly,
-                                 MediaDecoderEventVisibility::Suppressed);
+                                 SeekTarget::Type::Accurate,
+                                 MediaDecoderEventVisibility::Suppressed,
+                                 true /* aVideoOnly */);
     InitiateSeek(Move(seekJob));
   }
 }
 
 void MediaDecoderStateMachine::BufferedRangeUpdated()
 {
   MOZ_ASSERT(OnTaskQueue());
 
@@ -1553,18 +1555,17 @@ MediaDecoderStateMachine::InitiateSeek(S
 
   mSeekTaskRequest.DisconnectIfExists();
 
   // SeekTask will register its callbacks to MediaDecoderReaderWrapper.
   CancelMediaDecoderReaderWrapperCallback();
 
   // Create a new SeekTask instance for the incoming seek task.
   if (aSeekJob.mTarget.IsAccurate() ||
-      aSeekJob.mTarget.IsFast() ||
-      aSeekJob.mTarget.IsVideoOnly()) {
+      aSeekJob.mTarget.IsFast()) {
     mSeekTask = new AccurateSeekTask(mDecoderID, OwnerThread(),
                                      mReader.get(), aSeekJob.mTarget,
                                      mInfo, Duration(), GetMediaTime());
   } else if (aSeekJob.mTarget.IsNextFrame()) {
     mSeekTask = new NextFrameSeekTask(mDecoderID, OwnerThread(), mReader.get(),
                                       aSeekJob.mTarget, mInfo, Duration(),
                                       GetMediaTime(), AudioQueue(), VideoQueue());
   } else {
--- a/dom/media/SeekTarget.h
+++ b/dom/media/SeekTarget.h
@@ -19,86 +19,96 @@ enum class MediaDecoderEventVisibility :
 // Stores the seek target; the time to seek to, and whether an Accurate,
 // "Fast" (nearest keyframe), or "Video Only" (no audio seek) seek was
 // requested.
 struct SeekTarget {
   enum Type {
     Invalid,
     PrevSyncPoint,
     Accurate,
-    AccurateVideoOnly,
     NextFrame,
   };
   SeekTarget()
     : mEventVisibility(MediaDecoderEventVisibility::Observable)
     , mTime(media::TimeUnit::Invalid())
     , mType(SeekTarget::Invalid)
+    , mVideoOnly(false)
   {
   }
   SeekTarget(int64_t aTimeUsecs,
              Type aType,
              MediaDecoderEventVisibility aEventVisibility =
-               MediaDecoderEventVisibility::Observable)
+               MediaDecoderEventVisibility::Observable,
+             bool aVideoOnly = false)
     : mEventVisibility(aEventVisibility)
     , mTime(media::TimeUnit::FromMicroseconds(aTimeUsecs))
     , mType(aType)
+    , mVideoOnly(aVideoOnly)
   {
   }
   SeekTarget(const media::TimeUnit& aTime,
              Type aType,
              MediaDecoderEventVisibility aEventVisibility =
-               MediaDecoderEventVisibility::Observable)
+               MediaDecoderEventVisibility::Observable,
+             bool aVideoOnly = false)
     : mEventVisibility(aEventVisibility)
     , mTime(aTime)
     , mType(aType)
+    , mVideoOnly(aVideoOnly)
   {
   }
   SeekTarget(const SeekTarget& aOther)
     : mEventVisibility(aOther.mEventVisibility)
     , mTime(aOther.mTime)
     , mType(aOther.mType)
+    , mVideoOnly(aOther.mVideoOnly)
   {
   }
   bool IsValid() const {
     return mType != SeekTarget::Invalid;
   }
   void Reset() {
     mTime = media::TimeUnit::Invalid();
     mType = SeekTarget::Invalid;
+    mVideoOnly = false;
   }
   media::TimeUnit GetTime() const {
     NS_ASSERTION(mTime.IsValid(), "Invalid SeekTarget");
     return mTime;
   }
   void SetTime(const media::TimeUnit& aTime) {
     NS_ASSERTION(aTime.IsValid(), "Invalid SeekTarget destination");
     mTime = aTime;
   }
   void SetType(Type aType) {
     mType = aType;
   }
+  void SetVideoOnly(bool aVideoOnly) {
+    mVideoOnly = aVideoOnly;
+  }
   bool IsFast() const {
     return mType == SeekTarget::Type::PrevSyncPoint;
   }
   bool IsAccurate() const {
     return mType == SeekTarget::Type::Accurate;
   }
-  bool IsVideoOnly() const {
-    return mType == SeekTarget::Type::AccurateVideoOnly;
-  }
   bool IsNextFrame() const {
     return mType == SeekTarget::Type::NextFrame;
   }
+  bool IsVideoOnly() const {
+    return mVideoOnly;
+  }
 
   MediaDecoderEventVisibility mEventVisibility;
 
 private:
   // Seek target time.
   media::TimeUnit mTime;
   // Whether we should seek "Fast", or "Accurate".
   // "Fast" seeks to the seek point preceding mTime, whereas
   // "Accurate" seeks as close as possible to mTime.
   Type mType;
+  bool mVideoOnly;
 };
 
 } // namespace mozilla
 
 #endif /* SEEK_TARGET_H */