diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index b310a01471c3..051416f4ac28 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -188,22 +188,32 @@ void MediaStreamGraphImpl::UpdateCurrentTimeForStreams( 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& listener : stream->mTrackListeners) { if (listener.mTrackID == track->GetID()) { - track->NotifyEnded(); + listener.mListener->NotifyOutput(this, track->GetEnd()); listener.mListener->NotifyEnded(); } } } + } else { + for (const TrackBound& listener : + stream->mTrackListeners) { + if (listener.mTrackID == track->GetID()) { + listener.mListener->NotifyOutput( + this, streamCurrentTime - track->GetStart()); + } + } } } diff --git a/dom/media/MediaStreamListener.h b/dom/media/MediaStreamListener.h index becb1ca4f154..a2fb7331920c 100644 --- a/dom/media/MediaStreamListener.h +++ b/dom/media/MediaStreamListener.h @@ -158,6 +158,9 @@ class MediaStreamTrackListener { virtual void NotifyPrincipalHandleChanged( MediaStreamGraph* aGraph, const PrincipalHandle& aNewPrincipalHandle) {} + virtual void NotifyOutput(MediaStreamGraph* aGraph, + StreamTime aCurrentTrackTime) {} + virtual void NotifyEnded() {} virtual void NotifyRemoved() {}