From 8470d77f34291faf166494b31830d6ba302ab727 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 30 Apr 2012 15:12:50 +1200 Subject: [PATCH] Bug 664918. Part 9: Tentative support for MediaStreamListener::NotifyQueuedTrackChanges. r=jesup --- content/media/MediaStreamGraph.cpp | 7 +++++++ content/media/MediaStreamGraph.h | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/content/media/MediaStreamGraph.cpp b/content/media/MediaStreamGraph.cpp index bc346493326..dae0280010e 100644 --- a/content/media/MediaStreamGraph.cpp +++ b/content/media/MediaStreamGraph.cpp @@ -621,6 +621,13 @@ MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream) finished = aStream->mUpdateFinished; for (PRInt32 i = aStream->mUpdateTracks.Length() - 1; i >= 0; --i) { SourceMediaStream::TrackData* data = &aStream->mUpdateTracks[i]; + for (PRUint32 j = 0; j < aStream->mListeners.Length(); ++j) { + MediaStreamListener* l = aStream->mListeners[j]; + TrackTicks offset = (data->mCommands & SourceMediaStream::TRACK_CREATE) + ? data->mStart : aStream->mBuffer.FindTrack(data->mID)->GetSegment()->GetDuration(); + l->NotifyQueuedTrackChanges(this, data->mID, data->mRate, + offset, data->mCommands, *data->mData); + } if (data->mCommands & SourceMediaStream::TRACK_CREATE) { MediaSegment* segment = data->mData.forget(); LOG(PR_LOG_DEBUG, ("SourceMediaStream %p creating track %d, rate %d, start %lld, initial end %lld", diff --git a/content/media/MediaStreamGraph.h b/content/media/MediaStreamGraph.h index 8d372f9eb5f..23abeafffe0 100644 --- a/content/media/MediaStreamGraph.h +++ b/content/media/MediaStreamGraph.h @@ -108,6 +108,22 @@ public: * Notify that the stream finished. */ virtual void NotifyFinished(MediaStreamGraph* aGraph) {} + + enum { + TRACK_EVENT_CREATED = 0x01, + TRACK_EVENT_ENDED = 0x02 + }; + /** + * Notify that changes to one of the stream tracks have been queued. + * aTrackEvents can be any combination of TRACK_EVENT_CREATED and + * TRACK_EVENT_ENDED. aQueuedMedia is the data being added to the track + * at aTrackOffset (relative to the start of the stream). + */ + virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID, + TrackRate aTrackRate, + TrackTicks aTrackOffset, + PRUint32 aTrackEvents, + const MediaSegment& aQueuedMedia) {} }; class MediaStreamGraphImpl; @@ -419,8 +435,8 @@ public: nsCOMPtr mRunnable; }; enum TrackCommands { - TRACK_CREATE = 0x01, - TRACK_END = 0x02 + TRACK_CREATE = MediaStreamListener::TRACK_EVENT_CREATED, + TRACK_END = MediaStreamListener::TRACK_EVENT_ENDED }; /** * Data for each track that hasn't ended.