Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r=roc
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:29 +0800
changeset 329991 8cff901ef29d52f43957dbd39e18f8fc71c46942
parent 329990 50da13b5c50742086300b1da153b6a32b336de80
child 329992 2b448b06d6aac44d20659184aa4270023fe5c01c
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [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 - Add convenience method for checking track forwarding to MediaStreamTrack. r=roc MozReview-Commit-ID: 2rhLzZi72Yh
dom/media/MediaStreamTrack.cpp
dom/media/MediaStreamTrack.h
--- a/dom/media/MediaStreamTrack.cpp
+++ b/dom/media/MediaStreamTrack.cpp
@@ -255,16 +255,29 @@ MediaStreamTrack::RemoveListener(MediaSt
                         this, aListener));
 
   GetOwnedStream()->RemoveTrackListener(aListener, mTrackID);
 }
 
 already_AddRefed<MediaInputPort>
 MediaStreamTrack::ForwardTrackContentsTo(ProcessedMediaStream* aStream)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   MOZ_RELEASE_ASSERT(aStream);
   RefPtr<MediaInputPort> port =
     aStream->AllocateInputPort(GetOwnedStream(), mTrackID);
   return port.forget();
 }
 
+bool
+MediaStreamTrack::IsForwardedThrough(MediaInputPort* aPort)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(aPort);
+  if (!aPort) {
+    return false;
+  }
+  return aPort->GetSource() == GetOwnedStream() &&
+         aPort->PassTrackThrough(mTrackID);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/MediaStreamTrack.h
+++ b/dom/media/MediaStreamTrack.h
@@ -302,16 +302,22 @@ public:
   void RemoveListener(MediaStreamTrackListener* aListener);
 
   /**
    * Sets up a MediaInputPort from the underlying track that this
    * MediaStreamTrack represents, to aStream, and returns it.
    */
   already_AddRefed<MediaInputPort> ForwardTrackContentsTo(ProcessedMediaStream* aStream);
 
+  /**
+   * Returns true if this track is connected to aPort and forwarded to aPort's
+   * output stream.
+   */
+  bool IsForwardedThrough(MediaInputPort* aPort);
+
 protected:
   virtual ~MediaStreamTrack();
 
   // Returns the original DOMMediaStream's underlying input stream.
   MediaStream* GetInputStream();
 
   // Returns the owning DOMMediaStream's underlying owned stream.
   ProcessedMediaStream* GetOwnedStream();