Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r=roc
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:27 +0800
changeset 292107 ffa89f45c70e43ae5ca204d9e85b878123d69ec0
parent 292106 47197660d76d6f9ce2bd28d5456274a57580d788
child 292108 1e531196e0855ec396847065b8c3b706f977646f
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 - Add convenience method for forwarding a track to an MSG-stream. r=roc MozReview-Commit-ID: 5NDThQWgSoP
dom/media/MediaStreamTrack.cpp
dom/media/MediaStreamTrack.h
--- a/dom/media/MediaStreamTrack.cpp
+++ b/dom/media/MediaStreamTrack.cpp
@@ -252,10 +252,19 @@ void
 MediaStreamTrack::RemoveListener(MediaStreamTrackListener* aListener)
 {
   LOG(LogLevel::Debug, ("MediaStreamTrack %p removing listener %p",
                         this, aListener));
 
   GetOwnedStream()->RemoveTrackListener(aListener, mTrackID);
 }
 
+already_AddRefed<MediaInputPort>
+MediaStreamTrack::ForwardTrackContentsTo(ProcessedMediaStream* aStream)
+{
+  MOZ_RELEASE_ASSERT(aStream);
+  RefPtr<MediaInputPort> port =
+    aStream->AllocateInputPort(GetOwnedStream(), mTrackID);
+  return port.forget();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/MediaStreamTrack.h
+++ b/dom/media/MediaStreamTrack.h
@@ -13,16 +13,17 @@
 #include "MediaTrackConstraints.h"
 #include "mozilla/CORSMode.h"
 #include "PrincipalChangeObserver.h"
 
 namespace mozilla {
 
 class DOMMediaStream;
 class MediaEnginePhotoCallback;
+class MediaInputPort;
 class MediaStream;
 class MediaStreamGraph;
 class MediaStreamTrackListener;
 class PeerConnectionImpl;
 class ProcessedMediaStream;
 class RemoteSourceStreamInfo;
 
 namespace dom {
@@ -278,16 +279,22 @@ public:
   void AddListener(MediaStreamTrackListener* aListener);
 
   /**
    * Removes a MediaStreamTrackListener from the MediaStreamGraph representation
    * of this track.
    */
   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);
+
 protected:
   virtual ~MediaStreamTrack();
 
   // Returns the original DOMMediaStream's underlying input stream.
   MediaStream* GetInputStream();
 
   // Returns the owning DOMMediaStream's underlying owned stream.
   ProcessedMediaStream* GetOwnedStream();