Bug 1296531 - Remove MediaStream blocking logic from HTMLMediaElement. r?jesup draft
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 08 May 2017 18:41:28 +0200
changeset 670313 41ccce50c2a305e25d662986839931489d2338fb
parent 670312 a0895616749089280bfbc63f843be949935e86b6
child 670314 b99f08db97240d20a0d4cc9c47c929d75ea92e8e
push id81598
push userbmo:apehrson@mozilla.com
push dateTue, 26 Sep 2017 09:13:19 +0000
reviewersjesup
bugs1296531
milestone58.0a1
Bug 1296531 - Remove MediaStream blocking logic from HTMLMediaElement. r?jesup MediaStreamGraph only implements the blocking notifications for SourceMediaStreams, but the MediaStream that gets attached as srcObject on a media element is always a TrackUnionStream. Hence, this code is unused and can be removed. MozReview-Commit-ID: 6DKtCGNsZec
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4887,17 +4887,16 @@ HTMLMediaElement::FinishDecoderSetup(Med
 class HTMLMediaElement::StreamListener : public MediaStreamListener,
                                          public WatchTarget
 {
 public:
   StreamListener(HTMLMediaElement* aElement, const char* aName) :
     WatchTarget(aName),
     mElement(aElement),
     mHaveCurrentData(false),
-    mBlocked(false),
     mFinished(false),
     mMutex(aName),
     mPendingNotifyOutput(false)
   {}
   void Forget()
   {
     mElement = nullptr;
     NotifyWatchers();
@@ -4905,31 +4904,19 @@ public:
 
   // Main thread
 
   MediaDecoderOwner::NextFrameStatus NextFrameStatus()
   {
     if (!mElement || !mHaveCurrentData || mFinished) {
       return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
     }
-    return mBlocked
-        ? MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING
-        : MediaDecoderOwner::NEXT_FRAME_AVAILABLE;
-  }
-
-  void DoNotifyBlocked()
-  {
-    mBlocked = true;
-    NotifyWatchers();
-  }
-  void DoNotifyUnblocked()
-  {
-    mBlocked = false;
-    NotifyWatchers();
-  }
+    return MediaDecoderOwner::NEXT_FRAME_AVAILABLE;
+  }
+
   void DoNotifyOutput()
   {
     {
       MutexAutoLock lock(mMutex);
       mPendingNotifyOutput = false;
     }
     if (mElement && mHaveCurrentData) {
       RefPtr<HTMLMediaElement> kungFuDeathGrip = mElement;
@@ -4944,32 +4931,16 @@ public:
       kungFuDeathGrip->FirstFrameLoaded();
     }
     NotifyWatchers();
     DoNotifyOutput();
   }
 
   // These notifications run on the media graph thread so we need to
   // dispatch events to the main thread.
-  virtual void NotifyBlockingChanged(MediaStreamGraph* aGraph, Blocking aBlocked) override
-  {
-    nsCOMPtr<nsIRunnable> event;
-    if (aBlocked == BLOCKED) {
-      event = NewRunnableMethod(
-        "dom::HTMLMediaElement::StreamListener::DoNotifyBlocked",
-        this,
-        &StreamListener::DoNotifyBlocked);
-    } else {
-      event = NewRunnableMethod(
-        "dom::HTMLMediaElement::StreamListener::DoNotifyUnblocked",
-        this,
-        &StreamListener::DoNotifyUnblocked);
-    }
-    aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget());
-  }
   virtual void NotifyHasCurrentData(MediaStreamGraph* aGraph) override
   {
     MutexAutoLock lock(mMutex);
     aGraph->DispatchToMainThreadAfterStreamStateUpdate(
       NewRunnableMethod(
         "dom::HTMLMediaElement::StreamListener::DoNotifyHaveCurrentData",
         this,
         &StreamListener::DoNotifyHaveCurrentData));
@@ -4986,17 +4957,16 @@ public:
                         this,
                         &StreamListener::DoNotifyOutput));
   }
 
 private:
   // These fields may only be accessed on the main thread
   HTMLMediaElement* mElement;
   bool mHaveCurrentData;
-  bool mBlocked;
   bool mFinished;
 
   // mMutex protects the fields below; they can be accessed on any thread
   Mutex mMutex;
   bool mPendingNotifyOutput;
 };
 
 class HTMLMediaElement::MediaStreamTracksAvailableCallback: