Bug 1350852 P1 - add a mozvideoonlyseekcompleted event; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Mon, 27 Mar 2017 18:12:58 +0800
changeset 552912 cc17432d2496f765ee0f9369c58a13323a224a05
parent 552146 5182b2c4b963ed87d038c7d9a4021463917076cd
child 552913 4cc838de49ab9cb55cd2a0cb370eb1c07e4b1248
push id51507
push userbmo:kaku@mozilla.com
push dateWed, 29 Mar 2017 07:32:24 +0000
reviewersjwwang
bugs1350852
milestone55.0a1
Bug 1350852 P1 - add a mozvideoonlyseekcompleted event; r?jwwang MozReview-Commit-ID: wLMawR9Coz
dom/media/MediaDecoder.cpp
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -567,16 +567,19 @@ MediaDecoder::OnPlaybackEvent(MediaEvent
     case MediaEventType::ExitVideoSuspend:
       GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozexitvideosuspend"));
       break;
     case MediaEventType::StartVideoSuspendTimer:
       GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozstartvideosuspendtimer"));
       break;
     case MediaEventType::CancelVideoSuspendTimer:
       GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozcancelvideosuspendtimer"));
+      break;
+    case MediaEventType::VideoOnlySeekCompleted:
+      GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozvideoonlyseekcompleted"));
   }
 }
 
 void
 MediaDecoder::OnPlaybackErrorEvent(const MediaResult& aError)
 {
   DecodeError(aError);
 }
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2393,16 +2393,22 @@ SeekingState::SeekCompleted()
   // Ensure timestamps are up to date.
   if (!target.IsVideoOnly()) {
     // Don't update playback position for video-only seek.
     // Otherwise we might have |newCurrentTime > mMediaSink->GetPosition()|
     // and fail the assertion in GetClock() since we didn't stop MediaSink.
     mMaster->UpdatePlaybackPositionInternal(newCurrentTime);
   }
 
+  // Dispatch an event so that the UI can change in response to the end of
+  // video-only seek
+  if (target.IsVideoOnly()) {
+    mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
+  }
+
   // Try to decode another frame to detect if we're at the end...
   SLOG("Seek completed, mCurrentPosition=%" PRId64,
        mMaster->mCurrentPosition.Ref());
 
   if (mMaster->VideoQueue().PeekFront()) {
     mMaster->mMediaSink->Redraw(Info().mVideo);
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
   }
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -118,17 +118,18 @@ enum class MediaEventType : int8_t
   PlaybackStarted,
   PlaybackStopped,
   PlaybackEnded,
   SeekStarted,
   Invalidate,
   EnterVideoSuspend,
   ExitVideoSuspend,
   StartVideoSuspendTimer,
-  CancelVideoSuspendTimer
+  CancelVideoSuspendTimer,
+  VideoOnlySeekCompleted,
 };
 
 enum class VideoDecodeMode : uint8_t
 {
   Normal,
   Suspend
 };