Bug 1423241 - Implement MediaStreamTrackListener::NotifyOutput. r=padenot
authorAndreas Pehrson <apehrson@mozilla.com>
Fri, 23 Nov 2018 15:00:31 +0000
changeset 504259 de66629a4a2057724d381b2538b5ee1e885e90c2
parent 504258 befba547fb5850fd62d4e31784aa4b5198404500
child 504260 5bd5b88080df0880ae3b6fffdb95a724b3374dd8
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1423241
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1423241 - Implement MediaStreamTrackListener::NotifyOutput. r=padenot Differential Revision: https://phabricator.services.mozilla.com/D9094
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamListener.h
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -183,32 +183,42 @@ void MediaStreamGraphImpl::UpdateCurrent
     if (isAnyUnblocked) {
       NS_ASSERTION(
           !stream->mNotifiedFinished,
           "Shouldn't have already notified of finish *and* have output!");
       for (uint32_t j = 0; j < stream->mListeners.Length(); ++j) {
         MediaStreamListener* l = stream->mListeners[j];
         l->NotifyOutput(this, mProcessedTime);
       }
-
-      for (StreamTracks::TrackIter track(stream->mTracks); !track.IsEnded();
-           track.Next()) {
-        if (track->IsEnded() &&
-            track->GetEnd() <=
-                stream->GraphTimeToStreamTime(mStateComputedTime) &&
-            !track->NotifiedEnded()) {
+    }
+
+    for (StreamTracks::TrackIter track(stream->mTracks); !track.IsEnded();
+         track.Next()) {
+      StreamTime streamCurrentTime =
+          stream->GraphTimeToStreamTime(mStateComputedTime);
+      if (track->IsEnded() && track->GetEnd() <= streamCurrentTime) {
+        if (!track->NotifiedEnded()) {
           // Playout of this track ended and listeners have not been notified.
+          track->NotifyEnded();
           for (const TrackBound<MediaStreamTrackListener>& listener :
                stream->mTrackListeners) {
             if (listener.mTrackID == track->GetID()) {
-              track->NotifyEnded();
+              listener.mListener->NotifyOutput(this, track->GetEnd());
               listener.mListener->NotifyEnded();
             }
           }
         }
+      } else {
+        for (const TrackBound<MediaStreamTrackListener>& listener :
+             stream->mTrackListeners) {
+          if (listener.mTrackID == track->GetID()) {
+            listener.mListener->NotifyOutput(
+                this, streamCurrentTime - track->GetStart());
+          }
+        }
       }
     }
 
     // The stream is fully finished when all of its track data has been played
     // out.
     if (stream->mFinished && !stream->mNotifiedFinished &&
         mProcessedTime >= stream->StreamTimeToGraphTime(
                               stream->GetStreamTracks().GetAllTracksEnd())) {
--- a/dom/media/MediaStreamListener.h
+++ b/dom/media/MediaStreamListener.h
@@ -153,16 +153,19 @@ class MediaStreamTrackListener {
 
   virtual void NotifyQueuedChanges(MediaStreamGraph* aGraph,
                                    StreamTime aTrackOffset,
                                    const MediaSegment& aQueuedMedia) {}
 
   virtual void NotifyPrincipalHandleChanged(
       MediaStreamGraph* aGraph, const PrincipalHandle& aNewPrincipalHandle) {}
 
+  virtual void NotifyOutput(MediaStreamGraph* aGraph,
+                            StreamTime aCurrentTrackTime) {}
+
   virtual void NotifyEnded() {}
 
   virtual void NotifyRemoved() {}
 
  protected:
   virtual ~MediaStreamTrackListener() {}
 };