Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r=roc
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:25 +0800
changeset 292092 69e3123ba0cc337acd7dabd1b42a59006a48e16e
parent 292091 938ccbd14acbc5d5fd523131dd6780250bc1af97
child 292093 9b9a6dbb6eeaa61763d80c6211aefa390916dcfe
push id30152
push userkwierso@gmail.com
push dateThu, 07 Apr 2016 20:42:20 +0000
treeherdermozilla-central@06678484909c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1208371
milestone48.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 1208371 - Fix DOMMediaStream::OwnsTrack. r=roc MozReview-Commit-ID: 3uPqOYJZq2k
dom/media/DOMMediaStream.cpp
dom/media/DOMMediaStream.h
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -628,17 +628,17 @@ bool
 DOMMediaStream::HasTrack(const MediaStreamTrack& aTrack) const
 {
   return !!FindPlaybackTrackPort(aTrack);
 }
 
 bool
 DOMMediaStream::OwnsTrack(const MediaStreamTrack& aTrack) const
 {
-  return (aTrack.GetStream() == this) && HasTrack(aTrack);
+  return !!FindOwnedTrackPort(aTrack);
 }
 
 bool
 DOMMediaStream::IsFinished()
 {
   return !mPlaybackStream || mPlaybackStream->IsFinished();
 }
 
@@ -890,16 +890,28 @@ DOMMediaStream::FindOwnedDOMTrack(MediaS
         info->GetTrack()->GetInputTrackID() == aInputTrackID) {
       // This track is owned externally but in our playback stream.
       return info->GetTrack();
     }
   }
   return nullptr;
 }
 
+DOMMediaStream::TrackPort*
+DOMMediaStream::FindOwnedTrackPort(const MediaStreamTrack& aTrack) const
+{
+  for (const RefPtr<TrackPort>& info : mOwnedTracks) {
+    if (info->GetTrack() == &aTrack) {
+      return info;
+    }
+  }
+  return nullptr;
+}
+
+
 MediaStreamTrack*
 DOMMediaStream::FindPlaybackDOMTrack(MediaStream* aInputStream, TrackID aInputTrackID) const
 {
   MOZ_RELEASE_ASSERT(mPlaybackStream);
 
   for (const RefPtr<TrackPort>& info : mTracks) {
     if (info->GetInputPort() == mPlaybackPort &&
         aInputStream == mOwnedStream &&
--- a/dom/media/DOMMediaStream.h
+++ b/dom/media/DOMMediaStream.h
@@ -381,16 +381,22 @@ public:
   /**
    * Returns the corresponding MediaStreamTrack if it's in our mOwnedStream.
    * aInputTrackID should match the track's TrackID in its input stream.
    */
   MediaStreamTrack* FindOwnedDOMTrack(MediaStream* aOwningStream,
                                       TrackID aInputTrackID) const;
 
   /**
+   * Returns the TrackPort connecting aTrack's input stream to mOwnedStream,
+   * or nullptr if aTrack is not owned by this DOMMediaStream.
+   */
+  TrackPort* FindOwnedTrackPort(const MediaStreamTrack& aTrack) const;
+
+  /**
    * Returns the corresponding MediaStreamTrack if it's in our mPlaybackStream.
    * aInputTrackID should match the track's TrackID in its owned stream.
    */
   MediaStreamTrack* FindPlaybackDOMTrack(MediaStream* aOwningStream,
                                          TrackID aInputTrackID) const;
 
   /**
    * Returns the TrackPort connecting mOwnedStream to mPlaybackStream for aTrack.