Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r=mt
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:28 +0800
changeset 348458 f52964d42db87545103023b049fa41cb86463093
parent 348457 9f55c5fc20f9574722c0fe13e3ad1cc06f1ab9c5
child 348459 15de05d6a316b2ce2793b7ce12ec84dcb174fb3f
push id14828
push userpehrsons@gmail.com
push dateThu, 07 Apr 2016 12:57:27 +0000
reviewersmt
bugs1208371
milestone48.0a1
Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r=mt MozReview-Commit-ID: CsiUYQVb8LO
dom/media/MediaStreamTrack.h
--- a/dom/media/MediaStreamTrack.h
+++ b/dom/media/MediaStreamTrack.h
@@ -18,16 +18,17 @@ namespace mozilla {
 
 class DOMMediaStream;
 class MediaEnginePhotoCallback;
 class MediaInputPort;
 class MediaStream;
 class MediaStreamGraph;
 class MediaStreamTrackListener;
 class PeerConnectionImpl;
+class PeerIdentity;
 class ProcessedMediaStream;
 class RemoteSourceStreamInfo;
 
 namespace dom {
 
 class AudioStreamTrack;
 class VideoStreamTrack;
 
@@ -71,16 +72,27 @@ public:
   /**
    * Get the source's current CORSMode. If not applicable CORS_NONE is returned.
    * The sink will be notified of changes to our CORSMode through
    * NotifyPrincipalChanged().
    */
   virtual CORSMode GetCORSMode() const { return CORS_NONE; }
 
   /**
+   * This is used in WebRTC. A peerIdentity constrained MediaStreamTrack cannot
+   * be sent across the network to anything other than a peer with the provided
+   * identity. If this is set, then GetPrincipal() should return an instance of
+   * nsNullPrincipal.
+   *
+   * A track's PeerIdentity is immutable and will not change during the track's
+   * lifetime.
+   */
+  virtual const PeerIdentity* GetPeerIdentity() const { return nullptr; }
+
+  /**
    * Indicates whether the track is remote or not per the MediaCapture and
    * Streams spec.
    */
   virtual bool IsRemote() const { return mIsRemote; }
 
   /**
    * Forwards a photo request to backends that support it. Other backends return
    * NS_ERROR_NOT_IMPLEMENTED to indicate that a MediaStreamGraph-based fallback
@@ -235,16 +247,21 @@ public:
    */
   nsIPrincipal* GetPrincipal() const { return GetSource().GetPrincipal(); }
 
   /**
    * Get this track's CORS mode.
    */
   CORSMode GetCORSMode() const { return GetSource().GetCORSMode(); }
 
+  /**
+   * Get this track's PeerIdentity.
+   */
+  const PeerIdentity* GetPeerIdentity() const { return GetSource().GetPeerIdentity(); }
+
   MediaStreamGraph* Graph();
 
   MediaStreamTrackSource& GetSource() const
   {
     MOZ_RELEASE_ASSERT(mSource, "The track source is only removed on destruction");
     return *mSource;
   }