Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:28 +0800
changeset 342140 78176849b556837d945b61ae63fdbbea088d1aea
parent 342139 4b9a4373acb815d82e937e59d7145d8af0ca8473
child 342141 179d12231b70f8f39ba7076d4fa8f18ef53086f4
push id13352
push userpehrsons@gmail.com
push dateFri, 18 Mar 2016 13:49:47 +0000
reviewersmt
bugs1208371
milestone47.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;
   }