Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:29 +0800
changeset 342141 179d12231b70f8f39ba7076d4fa8f18ef53086f4
parent 342140 78176849b556837d945b61ae63fdbbea088d1aea
child 342142 6e3eb4a750be137c11f79f287621236788fb3b5c
push id13352
push userpehrsons@gmail.com
push dateFri, 18 Mar 2016 13:49:47 +0000
reviewersmt
bugs1208371
milestone47.0a1
Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt MozReview-Commit-ID: FhEyMxreaIx
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -796,25 +796,31 @@ public:
       window->SetAudioCapture(true);
     } else {
       class LocalTrackSource : public MediaStreamTrackSource
       {
       public:
         LocalTrackSource(nsIPrincipal* aPrincipal,
                          GetUserMediaCallbackMediaStreamListener* aListener,
                          const MediaSourceEnum aSource,
-                         const TrackID aTrackID)
+                         const TrackID aTrackID,
+                         const PeerIdentity* aPeerIdentity)
           : MediaStreamTrackSource(aPrincipal, false), mListener(aListener),
-            mSource(aSource), mTrackID(aTrackID) {}
+            mSource(aSource), mTrackID(aTrackID), mPeerIdentity(aPeerIdentity) {}
 
         MediaSourceEnum GetMediaSource() const override
         {
           return mSource;
         }
 
+        const PeerIdentity* GetPeerIdentity() const override
+        {
+          return mPeerIdentity;
+        }
+
         already_AddRefed<Promise>
         ApplyConstraints(nsPIDOMWindowInner* aWindow,
                          const MediaTrackConstraints& aConstraints,
                          ErrorResult &aRv) override
         {
           nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(aWindow);
           RefPtr<Promise> promise = Promise::Create(go, aRv);
 
@@ -848,52 +854,51 @@ public:
         }
 
       protected:
         ~LocalTrackSource() {}
 
         RefPtr<GetUserMediaCallbackMediaStreamListener> mListener;
         const MediaSourceEnum mSource;
         const TrackID mTrackID;
+        const RefPtr<const PeerIdentity> mPeerIdentity;
       };
 
       nsCOMPtr<nsIPrincipal> principal;
       if (mPeerIdentity) {
         principal = nsNullPrincipal::Create();
       } else {
         principal = window->GetExtantDoc()->NodePrincipal();
       }
 
       // Normal case, connect the source stream to the track union stream to
       // avoid us blocking. Pass a null TrackSourceGetter since gUM should never
       // add tracks dynamically.
       domStream =
         DOMLocalMediaStream::CreateSourceStream(window, msg, nullptr);
 
-      if (mPeerIdentity) {
-        domStream->SetPeerIdentity(mPeerIdentity);
-      }
-
       if (mAudioDevice) {
         nsString audioDeviceName;
         mAudioDevice->GetName(audioDeviceName);
         const MediaSourceEnum source =
           mAudioDevice->GetSource()->GetMediaSource();
         RefPtr<MediaStreamTrackSource> audioSource =
-          new LocalTrackSource(principal, mListener, source, kAudioTrack);
+          new LocalTrackSource(principal, mListener, source, kAudioTrack,
+                               mPeerIdentity);
         domStream->CreateDOMTrack(kAudioTrack, MediaSegment::AUDIO,
                                   audioDeviceName, audioSource);
       }
       if (mVideoDevice) {
         nsString videoDeviceName;
         mVideoDevice->GetName(videoDeviceName);
         const MediaSourceEnum source =
           mVideoDevice->GetSource()->GetMediaSource();
         RefPtr<MediaStreamTrackSource> videoSource =
-          new LocalTrackSource(principal, mListener, source, kVideoTrack);
+          new LocalTrackSource(principal, mListener, source, kVideoTrack,
+                               mPeerIdentity);
         domStream->CreateDOMTrack(kVideoTrack, MediaSegment::VIDEO,
                                   videoDeviceName, videoSource);
       }
       stream = domStream->GetInputStream()->AsSourceStream();
     }
 
     if (!domStream || sInShutdown) {
       nsCOMPtr<nsIDOMGetUserMediaErrorCallback> onFailure = mOnFailure.forget();