Bug 1354465 P1 - dispatch a mozvideoonlyseekbegin event while starting a video-only seek; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Fri, 07 Apr 2017 16:11:34 +0800
changeset 560257 bc63b56a88dd722252c8c5fe9b63afc3ef83a581
parent 560256 649da44e21340ad03bfef7095a0dcbc50836d617
child 560258 e2c9182cddb13a3b3141e39f03302d629397b846
push id53365
push userjichen@mozilla.com
push dateTue, 11 Apr 2017 08:35:12 +0000
reviewersjwwang
bugs1354465
milestone55.0a1
Bug 1354465 P1 - dispatch a mozvideoonlyseekbegin event while starting a video-only seek; r=jwwang MozReview-Commit-ID: 6PjQs88vUV2
dom/media/MediaDecoder.cpp
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -566,16 +566,19 @@ MediaDecoder::OnPlaybackEvent(MediaEvent
       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::VideoOnlySeekBegin:
+      GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozvideoonlyseekbegin"));
+      break;
     case MediaEventType::VideoOnlySeekCompleted:
       GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozvideoonlyseekcompleted"));
   }
 }
 
 void
 MediaDecoder::OnPlaybackErrorEvent(const MediaResult& aError)
 {
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -939,16 +939,22 @@ class MediaDecoderStateMachine::SeekingS
 public:
   explicit SeekingState(Master* aPtr) : StateObject(aPtr) { }
 
   RefPtr<MediaDecoder::SeekPromise> Enter(SeekJob&& aSeekJob,
                                           EventVisibility aVisibility)
   {
     mSeekJob = Move(aSeekJob);
 
+    // Dispatch a mozvideoonlyseekbegin event to indicate UI for corresponding
+    // changes.
+    if (mSeekJob.mTarget->IsVideoOnly()) {
+      mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekBegin);
+    }
+
     // Always switch off the blank decoder otherwise we might become visible
     // in the middle of seeking and won't have a valid video frame to show
     // when seek is done.
     if (mMaster->mVideoDecodeSuspended) {
       mMaster->mVideoDecodeSuspended = false;
       mMaster->mOnPlaybackEvent.Notify(MediaEventType::ExitVideoSuspend);
       Reader()->SetVideoBlankDecode(false);
     }
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -119,16 +119,17 @@ enum class MediaEventType : int8_t
   PlaybackStopped,
   PlaybackEnded,
   SeekStarted,
   Invalidate,
   EnterVideoSuspend,
   ExitVideoSuspend,
   StartVideoSuspendTimer,
   CancelVideoSuspendTimer,
+  VideoOnlySeekBegin,
   VideoOnlySeekCompleted,
 };
 
 enum class VideoDecodeMode : uint8_t
 {
   Normal,
   Suspend
 };