From c4ef19aea8b1e81651b908d58a6bb01a7f804a23 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Fri, 23 Nov 2018 15:00:14 +0000 Subject: [PATCH] Bug 1423241 - Implement NotifyPull for MediaStreamTrackListener. r=padenot Differential Revision: https://phabricator.services.mozilla.com/D12267 --HG-- extra : moz-landing-system : lando --- dom/media/MediaStreamGraph.cpp | 15 +++++++++++++++ dom/media/MediaStreamGraph.h | 2 +- dom/media/MediaStreamListener.h | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index 6c0f70888988..3adaf3f48200 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -2629,6 +2629,21 @@ bool SourceMediaStream::PullNewData(StreamTime aDesiredUpToTime) { l->NotifyPull(GraphImpl(), t); } } + for (const TrackData& track : mUpdateTracks) { + if (track.mCommands & TrackEventCommand::TRACK_EVENT_ENDED) { + continue; + } + current = track.mEndOfFlushedData + track.mData->GetDuration(); + if (t <= current) { + continue; + } + MutexAutoUnlock unlock(mMutex); + for (TrackBound& l : mTrackListeners) { + if (l.mTrackID == track.mID) { + l.mListener->NotifyPull(Graph(), current, t); + } + } + } return true; } diff --git a/dom/media/MediaStreamGraph.h b/dom/media/MediaStreamGraph.h index 2998e43e1f09..e27eb9ef25dc 100644 --- a/dom/media/MediaStreamGraph.h +++ b/dom/media/MediaStreamGraph.h @@ -673,7 +673,7 @@ class SourceMediaStream : public MediaStream { /** * Enable or disable pulling. When pulling is enabled, NotifyPull - * gets called on MediaStreamListeners for this stream during the + * gets called on MediaStream/TrackListeners for this stream during the * MediaStreamGraph control loop. Pulling is initially disabled. * Due to unavoidable race conditions, after a call to SetPullEnabled(false) * it is still possible for a NotifyPull to occur. diff --git a/dom/media/MediaStreamListener.h b/dom/media/MediaStreamListener.h index 24be34882378..becb1ca4f154 100644 --- a/dom/media/MediaStreamListener.h +++ b/dom/media/MediaStreamListener.h @@ -147,6 +147,10 @@ class MediaStreamTrackListener { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStreamTrackListener) public: + virtual void NotifyPull(MediaStreamGraph* aGraph, + StreamTime aEndOfAppendedData, + StreamTime aDesiredTime) {} + virtual void NotifyQueuedChanges(MediaStreamGraph* aGraph, StreamTime aTrackOffset, const MediaSegment& aQueuedMedia) {}