Bug 1301675 - Remove MediaStreamTrackSource::mIsRemote. r=jib
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 12 Sep 2016 15:59:58 +0200
changeset 347337 7414623c1788783ddd718459837954691071b109
parent 347336 b52349c52e061676b860e5d89d566003755fa564
child 347338 6000b9799462ddfd2b9a69884408a745dc87e298
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1301675
milestone52.0a1
Bug 1301675 - Remove MediaStreamTrackSource::mIsRemote. r=jib MediaStreamTrack.remote is no longer part of the spec. MozReview-Commit-ID: BgHJ1zNIoWN
dom/html/HTMLMediaElement.cpp
dom/media/MediaManager.cpp
dom/media/MediaStreamTrack.cpp
dom/media/MediaStreamTrack.h
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2200,17 +2200,16 @@ class HTMLMediaElement::StreamCaptureTra
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(StreamCaptureTrackSource,
                                            MediaStreamTrackSource)
 
   explicit StreamCaptureTrackSource(MediaStreamTrackSource* aCapturedTrackSource)
     : MediaStreamTrackSource(aCapturedTrackSource->GetPrincipal(),
-                             true,
                              nsString())
     , mCapturedTrackSource(aCapturedTrackSource)
   {
   }
 
   void Destroy() override
   {
     MOZ_ASSERT(mCapturedTrackSource);
@@ -2234,16 +2233,17 @@ public:
     p->Reject(new dom::MediaStreamError(aWindow,
                                         NS_LITERAL_STRING("OverconstrainedError"),
                                         NS_LITERAL_STRING("")));
     return p.forget();
   }
 
   void Stop() override
   {
+    // XXX fix in later patch
     NS_ERROR("We're reporting remote=true to not be stoppable. "
              "Stop() should not be called.");
   }
 
   void PrincipalChanged() override
   {
     mPrincipal = mCapturedTrackSource->GetPrincipal();
     MediaStreamTrackSource::PrincipalChanged();
@@ -2271,17 +2271,16 @@ class HTMLMediaElement::DecoderCaptureTr
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DecoderCaptureTrackSource,
                                            MediaStreamTrackSource)
 
   explicit DecoderCaptureTrackSource(HTMLMediaElement* aElement)
     : MediaStreamTrackSource(nsCOMPtr<nsIPrincipal>(aElement->GetCurrentPrincipal()).get(),
-                             true,
                              nsString())
     , mElement(aElement)
   {
     MOZ_ASSERT(mElement);
     mElement->AddDecoderPrincipalChangeObserver(this);
   }
 
   void Destroy() override
@@ -2310,16 +2309,17 @@ public:
     p->Reject(new dom::MediaStreamError(aWindow,
                                         NS_LITERAL_STRING("OverconstrainedError"),
                                         NS_LITERAL_STRING("")));
     return p.forget();
   }
 
   void Stop() override
   {
+    // XXX Fix in later patch.
     NS_ERROR("We're reporting remote=true to not be stoppable. "
              "Stop() should not be called.");
   }
 
   void NotifyDecoderPrincipalChanged() override
   {
     nsCOMPtr<nsIPrincipal> newPrincipal = mElement->GetCurrentPrincipal();
     if (nsContentUtils::CombineResourcePrincipals(&mPrincipal, newPrincipal)) {
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1165,17 +1165,17 @@ public:
       {
       public:
         LocalTrackSource(nsIPrincipal* aPrincipal,
                          const nsString& aLabel,
                          GetUserMediaCallbackMediaStreamListener* aListener,
                          const MediaSourceEnum aSource,
                          const TrackID aTrackID,
                          const PeerIdentity* aPeerIdentity)
-          : MediaStreamTrackSource(aPrincipal, false, aLabel), mListener(aListener),
+          : MediaStreamTrackSource(aPrincipal, aLabel), mListener(aListener),
             mSource(aSource), mTrackID(aTrackID), mPeerIdentity(aPeerIdentity) {}
 
         MediaSourceEnum GetMediaSource() const override
         {
           return mSource;
         }
 
         const PeerIdentity* GetPeerIdentity() const override
--- a/dom/media/MediaStreamTrack.cpp
+++ b/dom/media/MediaStreamTrack.cpp
@@ -119,18 +119,17 @@ protected:
 MediaStreamTrack::MediaStreamTrack(DOMMediaStream* aStream, TrackID aTrackID,
                                    TrackID aInputTrackID,
                                    MediaStreamTrackSource* aSource,
                                    const MediaTrackConstraints& aConstraints)
   : mOwningStream(aStream), mTrackID(aTrackID),
     mInputTrackID(aInputTrackID), mSource(aSource),
     mPrincipal(aSource->GetPrincipal()),
     mReadyState(MediaStreamTrackState::Live),
-    mEnabled(true), mRemote(aSource->IsRemote()),
-    mConstraints(aConstraints)
+    mEnabled(true), mConstraints(aConstraints)
 {
 
   GetSource().RegisterSink(this);
 
   mPrincipalHandleListener = new PrincipalHandleListener(this);
   AddListener(mPrincipalHandleListener);
 
   nsresult rv;
@@ -231,21 +230,16 @@ MediaStreamTrack::Stop()
 {
   LOG(LogLevel::Info, ("MediaStreamTrack %p Stop()", this));
 
   if (Ended()) {
     LOG(LogLevel::Warning, ("MediaStreamTrack %p Already ended", this));
     return;
   }
 
-  if (mRemote) {
-    LOG(LogLevel::Warning, ("MediaStreamTrack %p is remote. Can't be stopped.", this));
-    return;
-  }
-
   if (!mSource) {
     MOZ_ASSERT(false);
     return;
   }
 
   mSource->UnregisterSink(this);
 
   MOZ_ASSERT(mOwningStream, "Every MediaStreamTrack needs an owning DOMMediaStream");
--- a/dom/media/MediaStreamTrack.h
+++ b/dom/media/MediaStreamTrack.h
@@ -56,20 +56,18 @@ class MediaStreamTrackSource : public ns
 public:
   class Sink
   {
   public:
     virtual void PrincipalChanged() = 0;
   };
 
   MediaStreamTrackSource(nsIPrincipal* aPrincipal,
-                         const bool aIsRemote,
                          const nsString& aLabel)
     : mPrincipal(aPrincipal),
-      mIsRemote(aIsRemote),
       mLabel(aLabel),
       mStopped(false)
   {
     MOZ_COUNT_CTOR(MediaStreamTrackSource);
   }
 
   /**
    * Use to clean up any resources that have to be cleaned before the
@@ -102,22 +100,16 @@ public:
    * 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; }
-
-  /**
    * MediaStreamTrack::GetLabel (see spec) calls through to here.
    */
   void GetLabel(nsAString& aLabel) { aLabel.Assign(mLabel); }
 
   /**
    * Forwards a photo request to backends that support it. Other backends return
    * NS_ERROR_NOT_IMPLEMENTED to indicate that a MediaStreamGraph-based fallback
    * should be used.
@@ -159,17 +151,17 @@ public:
 
   /**
    * Called by each MediaStreamTrack clone on Stop() if supported by the
    * source (us) or destruction.
    */
   void UnregisterSink(Sink* aSink)
   {
     MOZ_ASSERT(NS_IsMainThread());
-    if (mSinks.RemoveElement(aSink) && mSinks.IsEmpty() && !IsRemote()) {
+    if (mSinks.RemoveElement(aSink) && mSinks.IsEmpty()) {
       Stop();
       mStopped = true;
     }
   }
 
 protected:
   virtual ~MediaStreamTrackSource()
   {
@@ -188,44 +180,40 @@ protected:
   }
 
   // Principal identifying who may access the contents of this source.
   nsCOMPtr<nsIPrincipal> mPrincipal;
 
   // Currently registered sinks.
   nsTArray<Sink*> mSinks;
 
-  // True if this is a remote track source, i.e., a PeerConnection.
-  const bool mIsRemote;
-
   // The label of the track we are the source of per the MediaStreamTrack spec.
   const nsString mLabel;
 
-  // True if this source is not remote, all MediaStreamTrack users have
-  // unregistered from this source and Stop() has been called.
+  // True if all MediaStreamTrack users have unregistered from this source and
+  // Stop() has been called.
   bool mStopped;
 };
 
 /**
  * Basic implementation of MediaStreamTrackSource that ignores Stop().
  */
 class BasicUnstoppableTrackSource : public MediaStreamTrackSource
 {
 public:
   explicit BasicUnstoppableTrackSource(nsIPrincipal* aPrincipal,
                                        const MediaSourceEnum aMediaSource =
                                          MediaSourceEnum::Other)
-    : MediaStreamTrackSource(aPrincipal, true, nsString())
+    : MediaStreamTrackSource(aPrincipal, nsString())
     , mMediaSource(aMediaSource)
   {}
 
   MediaSourceEnum GetMediaSource() const override { return mMediaSource; }
 
-  void
-  GetSettings(dom::MediaTrackSettings& aResult) override {}
+  void GetSettings(dom::MediaTrackSettings& aResult) override {}
 
   void Stop() override {}
 
 protected:
   ~BasicUnstoppableTrackSource() {}
 
   const MediaSourceEnum mMediaSource;
 };
@@ -480,16 +468,15 @@ protected:
   RefPtr<PrincipalHandleListener> mPrincipalHandleListener;
   // Keep tracking MediaStreamTrackListener and DirectMediaStreamTrackListener,
   // so we can remove them in |Destory|.
   nsTArray<RefPtr<MediaStreamTrackListener>> mTrackListeners;
   nsTArray<RefPtr<DirectMediaStreamTrackListener>> mDirectTrackListeners;
   nsString mID;
   MediaStreamTrackState mReadyState;
   bool mEnabled;
-  const bool mRemote;
   dom::MediaTrackConstraints mConstraints;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* MEDIASTREAMTRACK_H_ */
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
@@ -156,28 +156,32 @@ private:
       const std::string& trackId);
 };
 
 #if !defined(MOZILLA_EXTERNAL_LINKAGE)
 class RemoteTrackSource : public dom::MediaStreamTrackSource
 {
 public:
   explicit RemoteTrackSource(nsIPrincipal* aPrincipal, const nsString& aLabel)
-    : dom::MediaStreamTrackSource(aPrincipal, true, aLabel) {}
+    : dom::MediaStreamTrackSource(aPrincipal, aLabel) {}
 
   dom::MediaSourceEnum GetMediaSource() const override
   {
     return dom::MediaSourceEnum::Other;
   }
 
   already_AddRefed<PledgeVoid>
   ApplyConstraints(nsPIDOMWindowInner* aWindow,
                    const dom::MediaTrackConstraints& aConstraints) override;
 
-  void Stop() override { NS_ERROR("Can't stop a remote source!"); }
+  void Stop() override
+  {
+    // XXX Fix in later patch.
+    NS_ERROR("Can't stop a remote source!");
+  }
 
   void SetPrincipal(nsIPrincipal* aPrincipal)
   {
     mPrincipal = aPrincipal;
     PrincipalChanged();
   }
 
 protected: