Bug 1421875. P2 - move MediaDecoder::NotifyDataArrived() down the class hierarchy. draft
authorJW Wang <jwwang@mozilla.com>
Thu, 30 Nov 2017 11:07:13 +0800
changeset 706012 efb0dfc09be2031b35b512417bae840961ee1b0f
parent 706011 3dc725ad54a7c0e5ac3331976905fe09bc0f1e74
child 706013 210b84992c56056ce4018e087d95d7caecc89b35
push id91664
push userjwwang@mozilla.com
push dateFri, 01 Dec 2017 01:21:04 +0000
bugs1421875
milestone59.0a1
Bug 1421875. P2 - move MediaDecoder::NotifyDataArrived() down the class hierarchy. For it is never used by ChannelMediaDecoder. MozReview-Commit-ID: Jtvlj0iwTm7
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
dom/media/hls/HLSDecoder.cpp
dom/media/hls/HLSDecoder.h
dom/media/mediasource/MediaSourceDecoder.cpp
dom/media/mediasource/MediaSourceDecoder.h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1398,23 +1398,16 @@ MediaDecoder::NotifyReaderDataArrived()
 
   nsresult rv = mReader->OwnerThread()->Dispatch(
     NewRunnableMethod("MediaFormatReader::NotifyDataArrived",
                       mReader.get(),
                       &MediaFormatReader::NotifyDataArrived));
   MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
 }
 
-void
-MediaDecoder::NotifyDataArrived()
-{
-  NotifyReaderDataArrived();
-  DownloadProgressed();
-}
-
 // 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
@@ -172,20 +172,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.
   bool IsInfinite() const;
 
-  // 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;
 
   // Return true if the decoder has reached the end of playback.
   bool IsEnded() const;
 
   // True if we are playing a MediaSource object.
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -236,9 +236,17 @@ HLSDecoder::Shutdown()
   }
   if (mJavaCallbacks) {
     HLSResourceCallbacksSupport::DisposeNative(mJavaCallbacks);
     mJavaCallbacks = nullptr;
   }
   MediaDecoder::Shutdown();
 }
 
+void
+HLSDecoder::NotifyDataArrived()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  NotifyReaderDataArrived();
+  DownloadProgressed();
+}
+
 } // namespace mozilla
--- a/dom/media/hls/HLSDecoder.h
+++ b/dom/media/hls/HLSDecoder.h
@@ -36,16 +36,19 @@ public:
 
   void AddSizeOfResources(ResourceSizes* aSizes) override;
   already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override;
   bool IsTransportSeekable() override { return true; }
   void Suspend() override;
   void Resume() override;
   void Shutdown() override;
 
+  // Called as data arrives on the underlying HLS player. Main thread only.
+  void NotifyDataArrived();
+
 private:
   friend class HLSResourceCallbacksSupport;
 
   void PinForSeek() override {}
   void UnpinForSeek() override {}
 
   MediaDecoderStateMachine* CreateStateMachine();
 
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -347,16 +347,24 @@ MediaSourceDecoder::NotifyInitDataArrive
   MOZ_ASSERT(NS_IsMainThread());
   AbstractThread::AutoEnter context(AbstractMainThread());
 
   if (mDemuxer) {
     mDemuxer->NotifyInitDataArrived();
   }
 }
 
+void
+MediaSourceDecoder::NotifyDataArrived()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  NotifyReaderDataArrived();
+  DownloadProgressed();
+}
+
 already_AddRefed<nsIPrincipal>
 MediaSourceDecoder::GetCurrentPrincipal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   return do_AddRef(mPrincipal);
 }
 
 #undef MSE_DEBUG
--- a/dom/media/mediasource/MediaSourceDecoder.h
+++ b/dom/media/mediasource/MediaSourceDecoder.h
@@ -59,16 +59,20 @@ public:
   void AddSizeOfResources(ResourceSizes* aSizes) override;
 
   MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;
 
   bool IsMSE() const override { return true; }
 
   void NotifyInitDataArrived();
 
+  // Called as data appended to the source buffer or EOS is called on the media
+  // source. Main thread only.
+  void NotifyDataArrived();
+
 private:
   void PinForSeek() override {}
   void UnpinForSeek() override {}
   MediaDecoderStateMachine* CreateStateMachine();
   void DoSetMediaSourceDuration(double aDuration);
   media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);
   bool CanPlayThroughImpl() override;
   bool IsLiveStream() override final { return !mEnded; }