Bug 1374184. P2 - merge NotifyDataArrived() and NotifyDownloadProgressed(). draft
authorJW Wang <jwwang@mozilla.com>
Mon, 19 Jun 2017 14:24:40 +0800
changeset 597060 25947f7d9be8d2f2817b14e80054bf0dcb5d85e9
parent 597059 9c64d0a93f5f22b804d97c9dabaa7e9df80386c2
child 597061 7332d8076ec36179547fade023eab511b1c317d9
push id64816
push userjwwang@mozilla.com
push dateTue, 20 Jun 2017 03:04:06 +0000
bugs1374184
milestone56.0a1
Bug 1374184. P2 - merge NotifyDataArrived() and NotifyDownloadProgressed(). We also move NotifyDownloadProgressed() to private since it won't be called outside MediaDecoder. MozReview-Commit-ID: GISbJEW7wwx
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
dom/media/mediasource/SourceBuffer.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1546,16 +1546,17 @@ MediaDecoder::NotifyDataArrivedInternal(
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
   mDataArrivedEvent.Notify();
 }
 
 void
 MediaDecoder::NotifyDataArrived()
 {
   NotifyDataArrivedInternal();
+  NotifyDownloadProgressed();
 }
 
 // Provide access to the state machine object
 MediaDecoderStateMachine*
 MediaDecoder::GetStateMachine() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   return mDecoderStateMachine;
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -248,20 +248,16 @@ public:
   virtual void RemoveOutputStream(MediaStream* aStream);
 
   // Return the duration of the video in seconds.
   virtual double GetDuration();
 
   // Return true if the stream is infinite (see SetInfinite).
   bool IsInfinite() const;
 
-  // Called by MediaResource when some data has been received.
-  // Call on the main thread only.
-  void NotifyDownloadProgressed();
-
   // Called as data arrives on the stream and is read into the cache.  Called
   // on the main thread only.
   void NotifyDataArrived();
 
   // Return true if we are currently seeking in the media resource.
   // Call on the main thread only.
   bool IsSeeking() const;
 
@@ -586,16 +582,20 @@ protected:
   // the next frame is available.
   // An arbitrary value of 250ms is used.
   static constexpr auto DEFAULT_NEXT_FRAME_AVAILABLE_BUFFERED =
     media::TimeUnit::FromMicroseconds(250000);
 
 private:
   void NotifyDataArrivedInternal();
 
+  // Called by MediaResource when some data has been received.
+  // Call on the main thread only.
+  void NotifyDownloadProgressed();
+
   nsCString GetDebugInfo();
 
   // Called when the metadata from the media file has been loaded by the
   // state machine. Call on the main thread only.
   void MetadataLoaded(UniquePtr<MediaInfo> aInfo,
                       UniquePtr<MetadataTags> aTags,
                       MediaDecoderEventVisibility aEventVisibility);
 
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -442,20 +442,19 @@ SourceBuffer::AppendDataCompletedWithSuc
                  MSE_DEBUG("Complete AppendBuffer operation");
                  mCompletionPromise.Complete();
                  StopUpdating();
                })
         ->Track(mCompletionPromise);
     }
   }
   if (mActive) {
-    // Tell our parent decoder that we have received new data.
+    // Tell our parent decoder that we have received new data
+    // and send progress event.
     mMediaSource->GetDecoder()->NotifyDataArrived();
-    // Send progress event.
-    mMediaSource->GetDecoder()->NotifyDownloadProgressed();
   }
 
   mCurrentAttributes = aResult.second();
 
   CheckEndTime();
 
   if (!mCompletionPromise.Exists()) {
     StopUpdating();