Bug 1274221 - Make FindOwnedDOMTrack look for (optionally) unique tracks. r=ctai

MozReview-Commit-ID: 1y8YuwJWIS5

--HG--
extra : rebase_source : eb5c6a4ddd2a3d2395870d1f94751e06991fe46f
extra : intermediate-source : 795bcfd6223de68845075d0987cb8f3268893918
extra : source : c2154e0e122ac3981d1c5c7e748633a64111cbf7
This commit is contained in:
Andreas Pehrson 2016-05-24 13:26:25 +02:00
parent 8fe09d4c19
commit 577b207b43
2 changed files with 19 additions and 9 deletions

View File

@ -142,7 +142,7 @@ public:
}
MediaStreamTrack* track =
mStream->FindOwnedDOMTrack(aInputStream, aInputTrackID);
mStream->FindOwnedDOMTrack(aInputStream, aInputTrackID, aTrackID);
if (!track) {
// Track had not been created on main thread before, create it now.
NS_WARN_IF_FALSE(!mStream->mTracks.IsEmpty(),
@ -165,7 +165,8 @@ public:
}
}
void DoNotifyTrackEnded(MediaStream* aInputStream, TrackID aInputTrackID)
void DoNotifyTrackEnded(MediaStream* aInputStream, TrackID aInputTrackID,
TrackID aTrackID)
{
MOZ_ASSERT(NS_IsMainThread());
@ -174,7 +175,7 @@ public:
}
RefPtr<MediaStreamTrack> track =
mStream->FindOwnedDOMTrack(aInputStream, aInputTrackID);
mStream->FindOwnedDOMTrack(aInputStream, aInputTrackID, aTrackID);
NS_ASSERTION(track, "Owned MediaStreamTracks must be known by the DOMMediaStream");
if (track) {
LOG(LogLevel::Debug, ("DOMMediaStream %p MediaStreamTrack %p ended at the source. Marking it ended.",
@ -197,9 +198,9 @@ public:
aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget());
} else if (aTrackEvents & TRACK_EVENT_ENDED) {
nsCOMPtr<nsIRunnable> runnable =
NewRunnableMethod<MediaStream*, TrackID>(
NewRunnableMethod<MediaStream*, TrackID, TrackID>(
this, &OwnedStreamListener::DoNotifyTrackEnded,
aInputStream, aInputTrackID);
aInputStream, aInputTrackID, aID);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget());
}
}
@ -1064,14 +1065,16 @@ FindTrackPortAmongTracks(const MediaStreamTrack& aTrack,
MediaStreamTrack*
DOMMediaStream::FindOwnedDOMTrack(MediaStream* aInputStream,
TrackID aInputTrackID) const
TrackID aInputTrackID,
TrackID aTrackID) const
{
MOZ_RELEASE_ASSERT(mOwnedStream);
for (const RefPtr<TrackPort>& info : mOwnedTracks) {
if (info->GetInputPort() &&
info->GetInputPort()->GetSource() == aInputStream &&
info->GetTrack()->mInputTrackID == aInputTrackID) {
info->GetTrack()->mInputTrackID == aInputTrackID &&
(aTrackID == TRACK_ANY || info->GetTrack()->mTrackID == aTrackID)) {
// This track is owned externally but in our playback stream.
return info->GetTrack();
}

View File

@ -393,10 +393,17 @@ public:
/**
* Returns the corresponding MediaStreamTrack if it's in our mOwnedStream.
* aInputTrackID should match the track's TrackID in its input stream.
* aInputTrackID should match the track's TrackID in its input stream,
* and aTrackID the TrackID in mOwnedStream.
*
* When aTrackID is not supplied or set to TRACK_ANY, we return the first
* MediaStreamTrack that matches the given input track. Note that there may
* be multiple MediaStreamTracks matching the same input track, but that they
* in that case all share the same MediaStreamTrackSource.
*/
MediaStreamTrack* FindOwnedDOMTrack(MediaStream* aInputStream,
TrackID aInputTrackID) const;
TrackID aInputTrackID,
TrackID aTrackID = TRACK_ANY) const;
/**
* Returns the TrackPort connecting aTrack's input stream to mOwnedStream,