Replace SetCapturer and SetCaptureDevice by SetSource.
Drop return value.

BUG=webrtc:5426

Review URL: https://codereview.webrtc.org/1766653002

Cr-Commit-Position: refs/heads/master@{#12291}
diff --git a/webrtc/api/mediastreaminterface.h b/webrtc/api/mediastreaminterface.h
index 57c0776..7f56325 100644
--- a/webrtc/api/mediastreaminterface.h
+++ b/webrtc/api/mediastreaminterface.h
@@ -31,7 +31,6 @@
 namespace cricket {
 
 class AudioRenderer;
-class VideoCapturer;
 class VideoRenderer;
 class VideoFrame;
 
@@ -113,14 +112,6 @@
     int input_width;
     int input_height;
   };
-  // Get access to the source implementation of cricket::VideoCapturer.
-  // This can be used for receiving frames and state notifications.
-  // But it should not be used for starting or stopping capturing.
-  // TODO(perkj): We are currently trying to replace all internal use of
-  // cricket::VideoCapturer with rtc::VideoSourceInterface. Once that
-  // refactoring is done,
-  // remove this method.
-  virtual cricket::VideoCapturer* GetVideoCapturer() = 0;
 
   virtual void Stop() = 0;
   virtual void Restart() = 0;
diff --git a/webrtc/api/mediastreamprovider.h b/webrtc/api/mediastreamprovider.h
index 6814c41..f3bb3f4 100644
--- a/webrtc/api/mediastreamprovider.h
+++ b/webrtc/api/mediastreamprovider.h
@@ -15,13 +15,12 @@
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/scoped_ptr.h"
 #include "webrtc/media/base/videosinkinterface.h"
+#include "webrtc/media/base/videosourceinterface.h"
 
 namespace cricket {
 
 class AudioSource;
-class VideoCapturer;
 class VideoFrame;
-class VideoRenderer;
 struct AudioOptions;
 struct VideoOptions;
 
@@ -75,8 +74,9 @@
 // of a video track connected to a certain PeerConnection.
 class VideoProviderInterface {
  public:
-  virtual bool SetCaptureDevice(uint32_t ssrc,
-                                cricket::VideoCapturer* camera) = 0;
+  virtual bool SetSource(
+      uint32_t ssrc,
+      rtc::VideoSourceInterface<cricket::VideoFrame>* source) = 0;
   // Enable/disable the video playout of a remote video track with |ssrc|.
   virtual void SetVideoPlayout(
       uint32_t ssrc,
diff --git a/webrtc/api/objc/RTCAVFoundationVideoSource.mm b/webrtc/api/objc/RTCAVFoundationVideoSource.mm
index 1005c7d..94774f7 100644
--- a/webrtc/api/objc/RTCAVFoundationVideoSource.mm
+++ b/webrtc/api/objc/RTCAVFoundationVideoSource.mm
@@ -14,16 +14,21 @@
 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h"
 #import "webrtc/api/objc/RTCVideoSource+Private.h"
 
-@implementation RTCAVFoundationVideoSource
+@implementation RTCAVFoundationVideoSource {
+  webrtc::AVFoundationVideoCapturer *_capturer;
+}
 
 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
                     constraints:(RTCMediaConstraints *)constraints {
   NSParameterAssert(factory);
-  rtc::scoped_ptr<webrtc::AVFoundationVideoCapturer> capturer;
-  capturer.reset(new webrtc::AVFoundationVideoCapturer());
+  // We pass ownership of the capturer to the source, but since we own
+  // the source, it should be ok to keep a raw pointer to the
+  // capturer.
+  _capturer = new webrtc::AVFoundationVideoCapturer();
   rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
       factory.nativeFactory->CreateVideoSource(
-          capturer.release(), constraints.nativeConstraints.get());
+          _capturer, constraints.nativeConstraints.get());
+
   return [super initWithNativeVideoSource:source];
 }
 
@@ -44,12 +49,7 @@
 }
 
 - (webrtc::AVFoundationVideoCapturer *)capturer {
-  cricket::VideoCapturer *capturer = self.nativeVideoSource->GetVideoCapturer();
-  // This should be safe because no one should have changed the underlying video
-  // source.
-  webrtc::AVFoundationVideoCapturer *foundationCapturer =
-      static_cast<webrtc::AVFoundationVideoCapturer *>(capturer);
-  return foundationCapturer;
+  return _capturer;
 }
 
 @end
diff --git a/webrtc/api/rtpsender.cc b/webrtc/api/rtpsender.cc
index 94cea6c..214b4a3 100644
--- a/webrtc/api/rtpsender.cc
+++ b/webrtc/api/rtpsender.cc
@@ -276,18 +276,16 @@
 
   // Update video provider.
   if (can_send_track()) {
-    VideoTrackSourceInterface* source = track_->GetSource();
     // TODO(deadbeef): If SetTrack is called with a disabled track, and the
     // previous track was enabled, this could cause a frame from the new track
-    // to slip out. Really, what we need is for SetCaptureDevice and
-    // SetVideoSend
+    // to slip out. Really, what we need is for SetSource and SetVideoSend
     // to be combined into one atomic operation, all the way down to
     // WebRtcVideoSendStream.
-    provider_->SetCaptureDevice(ssrc_,
-                                source ? source->GetVideoCapturer() : nullptr);
+
+    provider_->SetSource(ssrc_, track_);
     SetVideoSend();
   } else if (prev_can_send_track) {
-    provider_->SetCaptureDevice(ssrc_, nullptr);
+    provider_->SetSource(ssrc_, nullptr);
     provider_->SetVideoSend(ssrc_, false, nullptr);
   }
   return true;
@@ -299,14 +297,12 @@
   }
   // If we are already sending with a particular SSRC, stop sending.
   if (can_send_track()) {
-    provider_->SetCaptureDevice(ssrc_, nullptr);
+    provider_->SetSource(ssrc_, nullptr);
     provider_->SetVideoSend(ssrc_, false, nullptr);
   }
   ssrc_ = ssrc;
   if (can_send_track()) {
-    VideoTrackSourceInterface* source = track_->GetSource();
-    provider_->SetCaptureDevice(ssrc_,
-                                source ? source->GetVideoCapturer() : nullptr);
+    provider_->SetSource(ssrc_, track_);
     SetVideoSend();
   }
 }
@@ -320,7 +316,7 @@
     track_->UnregisterObserver(this);
   }
   if (can_send_track()) {
-    provider_->SetCaptureDevice(ssrc_, nullptr);
+    provider_->SetSource(ssrc_, nullptr);
     provider_->SetVideoSend(ssrc_, false, nullptr);
   }
   stopped_ = true;
diff --git a/webrtc/api/rtpsenderreceiver_unittest.cc b/webrtc/api/rtpsenderreceiver_unittest.cc
index 7f32f29..188264e 100644
--- a/webrtc/api/rtpsenderreceiver_unittest.cc
+++ b/webrtc/api/rtpsenderreceiver_unittest.cc
@@ -70,8 +70,9 @@
 class MockVideoProvider : public VideoProviderInterface {
  public:
   virtual ~MockVideoProvider() {}
-  MOCK_METHOD2(SetCaptureDevice,
-               bool(uint32_t ssrc, cricket::VideoCapturer* camera));
+  MOCK_METHOD2(SetSource,
+               bool(uint32_t ssrc,
+                    rtc::VideoSourceInterface<cricket::VideoFrame>* source));
   MOCK_METHOD3(SetVideoPlayout,
                void(uint32_t ssrc,
                     bool enable,
@@ -111,9 +112,7 @@
 
   void CreateVideoRtpSender() {
     AddVideoTrack();
-    EXPECT_CALL(video_provider_,
-                SetCaptureDevice(
-                    kVideoSsrc, video_track_->GetSource()->GetVideoCapturer()));
+    EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, video_track_.get()));
     EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
     video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0],
                                            stream_->label(), &video_provider_);
@@ -127,7 +126,7 @@
   }
 
   void DestroyVideoRtpSender() {
-    EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1);
+    EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, NULL)).Times(1);
     EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
     video_rtp_sender_ = nullptr;
   }
@@ -345,14 +344,12 @@
   rtc::scoped_refptr<VideoRtpSender> sender =
       new VideoRtpSender(&video_provider_);
   sender->SetSsrc(kVideoSsrc);
-  EXPECT_CALL(video_provider_,
-              SetCaptureDevice(kVideoSsrc,
-                               video_track_->GetSource()->GetVideoCapturer()));
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, video_track_.get()));
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
   sender->SetTrack(video_track_);
 
   // Calls expected from destructor.
-  EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, nullptr)).Times(1);
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
 }
 
@@ -363,14 +360,12 @@
   rtc::scoped_refptr<VideoRtpSender> sender =
       new VideoRtpSender(&video_provider_);
   sender->SetTrack(video_track_);
-  EXPECT_CALL(video_provider_,
-              SetCaptureDevice(kVideoSsrc,
-                               video_track_->GetSource()->GetVideoCapturer()));
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, video_track_.get()));
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
   sender->SetSsrc(kVideoSsrc);
 
   // Calls expected from destructor.
-  EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, nullptr)).Times(1);
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
 }
 
@@ -396,21 +391,19 @@
 // set to 0.
 TEST_F(RtpSenderReceiverTest, VideoSenderSsrcSetToZero) {
   AddVideoTrack();
-  EXPECT_CALL(video_provider_,
-              SetCaptureDevice(kVideoSsrc,
-                               video_track_->GetSource()->GetVideoCapturer()));
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, video_track_.get()));
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
   rtc::scoped_refptr<VideoRtpSender> sender =
       new VideoRtpSender(video_track_, kStreamLabel1, &video_provider_);
   sender->SetSsrc(kVideoSsrc);
 
-  EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, nullptr)).Times(1);
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
   sender->SetSsrc(0);
 
   // Make sure it's SetSsrc that called methods on the provider, and not the
   // destructor.
-  EXPECT_CALL(video_provider_, SetCaptureDevice(_, _)).Times(0);
+  EXPECT_CALL(video_provider_, SetSource(_, _)).Times(0);
   EXPECT_CALL(video_provider_, SetVideoSend(_, _, _)).Times(0);
 }
 
@@ -432,21 +425,19 @@
 
 TEST_F(RtpSenderReceiverTest, VideoSenderTrackSetToNull) {
   AddVideoTrack();
-  EXPECT_CALL(video_provider_,
-              SetCaptureDevice(kVideoSsrc,
-                               video_track_->GetSource()->GetVideoCapturer()));
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, video_track_.get()));
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
   rtc::scoped_refptr<VideoRtpSender> sender =
       new VideoRtpSender(video_track_, kStreamLabel1, &video_provider_);
   sender->SetSsrc(kVideoSsrc);
 
-  EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, nullptr)).Times(1);
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
   EXPECT_TRUE(sender->SetTrack(nullptr));
 
   // Make sure it's SetTrack that called methods on the provider, and not the
   // destructor.
-  EXPECT_CALL(video_provider_, SetCaptureDevice(_, _)).Times(0);
+  EXPECT_CALL(video_provider_, SetSource(_, _)).Times(0);
   EXPECT_CALL(video_provider_, SetVideoSend(_, _, _)).Times(0);
 }
 
@@ -469,24 +460,20 @@
 
 TEST_F(RtpSenderReceiverTest, VideoSenderSsrcChanged) {
   AddVideoTrack();
-  EXPECT_CALL(video_provider_,
-              SetCaptureDevice(kVideoSsrc,
-                               video_track_->GetSource()->GetVideoCapturer()));
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, video_track_.get()));
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _));
   rtc::scoped_refptr<VideoRtpSender> sender =
       new VideoRtpSender(video_track_, kStreamLabel1, &video_provider_);
   sender->SetSsrc(kVideoSsrc);
 
-  EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, nullptr)).Times(1);
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc, nullptr)).Times(1);
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1);
-  EXPECT_CALL(video_provider_,
-              SetCaptureDevice(kVideoSsrc2,
-                               video_track_->GetSource()->GetVideoCapturer()));
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc2, video_track_.get()));
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _));
   sender->SetSsrc(kVideoSsrc2);
 
   // Calls expected from destructor.
-  EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1);
+  EXPECT_CALL(video_provider_, SetSource(kVideoSsrc2, nullptr)).Times(1);
   EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1);
 }
 
diff --git a/webrtc/api/videocapturertracksource.h b/webrtc/api/videocapturertracksource.h
index 96f8bff..2eb7b50 100644
--- a/webrtc/api/videocapturertracksource.h
+++ b/webrtc/api/videocapturertracksource.h
@@ -47,10 +47,6 @@
       cricket::VideoCapturer* capturer,
       bool remote);
 
-  cricket::VideoCapturer* GetVideoCapturer() override {
-    return video_capturer_.get();
-  }
-
   bool is_screencast() const override {
     return video_capturer_->IsScreencast();
   }
diff --git a/webrtc/api/videocapturertracksource_unittest.cc b/webrtc/api/videocapturertracksource_unittest.cc
index 3925293..6b0d07b 100644
--- a/webrtc/api/videocapturertracksource_unittest.cc
+++ b/webrtc/api/videocapturertracksource_unittest.cc
@@ -126,7 +126,6 @@
                                                constraints, false);
 
     ASSERT_TRUE(source_.get() != NULL);
-    EXPECT_EQ(capturer_, source_->GetVideoCapturer());
 
     state_observer_.reset(new StateObserver(source_));
     source_->RegisterObserver(state_observer_.get());
diff --git a/webrtc/api/videosourceproxy.h b/webrtc/api/videosourceproxy.h
index 4d687d4..0a34967 100644
--- a/webrtc/api/videosourceproxy.h
+++ b/webrtc/api/videosourceproxy.h
@@ -23,7 +23,6 @@
 BEGIN_WORKER_PROXY_MAP(VideoTrackSource)
   PROXY_CONSTMETHOD0(SourceState, state)
   PROXY_CONSTMETHOD0(bool, remote)
-  PROXY_METHOD0(cricket::VideoCapturer*, GetVideoCapturer)
   PROXY_METHOD0(void, Stop)
   PROXY_METHOD0(void, Restart)
   PROXY_CONSTMETHOD0(bool, is_screencast)
diff --git a/webrtc/api/videotracksource.h b/webrtc/api/videotracksource.h
index 3d8d502..7100612 100644
--- a/webrtc/api/videotracksource.h
+++ b/webrtc/api/videotracksource.h
@@ -46,8 +46,6 @@
                        const rtc::VideoSinkWants& wants) override;
   void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
 
-  cricket::VideoCapturer* GetVideoCapturer() override { return nullptr; }
-
  private:
   rtc::ThreadChecker worker_thread_checker_;
   rtc::VideoSourceInterface<cricket::VideoFrame>* source_;
diff --git a/webrtc/api/webrtcsession.cc b/webrtc/api/webrtcsession.cc
index f546285..f51d4cd 100644
--- a/webrtc/api/webrtcsession.cc
+++ b/webrtc/api/webrtcsession.cc
@@ -1261,8 +1261,9 @@
   return voice_channel_->SetRtpParameters(ssrc, parameters);
 }
 
-bool WebRtcSession::SetCaptureDevice(uint32_t ssrc,
-                                     cricket::VideoCapturer* camera) {
+bool WebRtcSession::SetSource(
+    uint32_t ssrc,
+    rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
   ASSERT(signaling_thread()->IsCurrent());
 
   if (!video_channel_) {
@@ -1271,13 +1272,7 @@
     LOG(LS_WARNING) << "Video not used in this call.";
     return false;
   }
-  if (!video_channel_->SetCapturer(ssrc, camera)) {
-    // Allow that SetCapturer fail if |camera| is NULL but assert otherwise.
-    // This in the normal case when the underlying media channel has already
-    // been deleted.
-    ASSERT(camera == NULL);
-    return false;
-  }
+  video_channel_->SetSource(ssrc, source);
   return true;
 }
 
diff --git a/webrtc/api/webrtcsession.h b/webrtc/api/webrtcsession.h
index 01ec526..752b20f 100644
--- a/webrtc/api/webrtcsession.h
+++ b/webrtc/api/webrtcsession.h
@@ -34,7 +34,6 @@
 class ChannelManager;
 class DataChannel;
 class StatsReport;
-class VideoCapturer;
 class VideoChannel;
 class VoiceChannel;
 
@@ -250,7 +249,9 @@
                              const RtpParameters& parameters) override;
 
   // Implements VideoMediaProviderInterface.
-  bool SetCaptureDevice(uint32_t ssrc, cricket::VideoCapturer* camera) override;
+  bool SetSource(
+      uint32_t ssrc,
+      rtc::VideoSourceInterface<cricket::VideoFrame>* source) override;
   void SetVideoPlayout(
       uint32_t ssrc,
       bool enable,
diff --git a/webrtc/api/webrtcsession_unittest.cc b/webrtc/api/webrtcsession_unittest.cc
index f4b41d3..28f93df 100644
--- a/webrtc/api/webrtcsession_unittest.cc
+++ b/webrtc/api/webrtcsession_unittest.cc
@@ -246,7 +246,7 @@
 
   using webrtc::WebRtcSession::SetAudioPlayout;
   using webrtc::WebRtcSession::SetAudioSend;
-  using webrtc::WebRtcSession::SetCaptureDevice;
+  using webrtc::WebRtcSession::SetSource;
   using webrtc::WebRtcSession::SetVideoPlayout;
   using webrtc::WebRtcSession::SetVideoSend;
 
diff --git a/webrtc/media/base/fakemediaengine.h b/webrtc/media/base/fakemediaengine.h
index d6d6539..64f4adc 100644
--- a/webrtc/media/base/fakemediaengine.h
+++ b/webrtc/media/base/fakemediaengine.h
@@ -527,12 +527,14 @@
     }
     return true;
   }
-  virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
-    capturers_[ssrc] = capturer;
-    return true;
+  void SetSource(
+      uint32_t ssrc,
+      rtc::VideoSourceInterface<cricket::VideoFrame>* source) override {
+    sources_[ssrc] = source;
   }
-  bool HasCapturer(uint32_t ssrc) const {
-    return capturers_.find(ssrc) != capturers_.end();
+
+  bool HasSource(uint32_t ssrc) const {
+    return sources_.find(ssrc) != sources_.end();
   }
   virtual bool AddRecvStream(const StreamParams& sp) {
     if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp))
@@ -580,7 +582,7 @@
   std::vector<VideoCodec> recv_codecs_;
   std::vector<VideoCodec> send_codecs_;
   std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*> sinks_;
-  std::map<uint32_t, VideoCapturer*> capturers_;
+  std::map<uint32_t, rtc::VideoSourceInterface<VideoFrame>*> sources_;
   VideoOptions options_;
   int max_bps_;
 };
diff --git a/webrtc/media/base/mediachannel.h b/webrtc/media/base/mediachannel.h
index 4166a60..68dc8f4 100644
--- a/webrtc/media/base/mediachannel.h
+++ b/webrtc/media/base/mediachannel.h
@@ -29,6 +29,7 @@
 #include "webrtc/media/base/mediaconstants.h"
 #include "webrtc/media/base/streamparams.h"
 #include "webrtc/media/base/videosinkinterface.h"
+#include "webrtc/media/base/videosourceinterface.h"
 // TODO(juberti): re-evaluate this include
 #include "webrtc/pc/audiomonitor.h"
 
@@ -998,9 +999,10 @@
   // If SSRC is 0, the renderer is used for the 'default' stream.
   virtual bool SetSink(uint32_t ssrc,
                        rtc::VideoSinkInterface<cricket::VideoFrame>* sink) = 0;
-  // If |ssrc| is 0, replace the default capturer (engine capturer) with
-  // |capturer|. If |ssrc| is non zero create a new stream with |ssrc| as SSRC.
-  virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) = 0;
+  // Register a source. The |ssrc| must correspond to a registered send stream.
+  virtual void SetSource(
+      uint32_t ssrc,
+      rtc::VideoSourceInterface<cricket::VideoFrame>* source) = 0;
   // Gets quality stats for the channel.
   virtual bool GetStats(VideoMediaInfo* info) = 0;
 };
diff --git a/webrtc/media/base/videoengine_unittest.h b/webrtc/media/base/videoengine_unittest.h
index 01a4f76..491149c 100644
--- a/webrtc/media/base/videoengine_unittest.h
+++ b/webrtc/media/base/videoengine_unittest.h
@@ -74,27 +74,6 @@
       rtc::kNumNanosecsPerMillisec);
 }
 
-// Fake video engine that makes it possible to test enabling and disabling
-// capturer (checking that the engine state is updated and that the capturer
-// is indeed capturing) without having to create a channel. It also makes it
-// possible to test that the media processors are indeed being called when
-// registered.
-template<class T>
-class VideoEngineOverride : public T {
- public:
-  VideoEngineOverride() : T() {
-  }
-  virtual ~VideoEngineOverride() {
-  }
-  bool is_camera_on() const { return T::GetVideoCapturer()->IsRunning(); }
-
-  void TriggerMediaFrame(uint32_t ssrc,
-                         cricket::VideoFrame* frame,
-                         bool* drop_frame) {
-    T::SignalMediaFrame(ssrc, frame, drop_frame);
-  }
-};
-
 template<class E, class C>
 class VideoMediaChannelTest : public testing::Test,
                               public sigslot::has_slots<> {
@@ -125,7 +104,7 @@
                                 cricket::VideoFormat::FpsToInterval(30),
                                 cricket::FOURCC_I420);
     EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(format));
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
+    channel_->SetSource(kSsrc, video_capturer_.get());
   }
 
   virtual cricket::FakeVideoCapturer* CreateFakeVideoCapturer() {
@@ -162,7 +141,7 @@
                                 cricket::FOURCC_I420);
     EXPECT_EQ(cricket::CS_RUNNING, video_capturer_2_->Start(format));
 
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc + 2, video_capturer_2_.get()));
+    channel_->SetSource(kSsrc + 2, video_capturer_2_.get());
   }
   virtual void TearDown() {
     channel_.reset();
@@ -373,7 +352,7 @@
   // Test that SetSend works.
   void SetSend() {
     EXPECT_FALSE(channel_->sending());
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
+    channel_->SetSource(kSsrc, video_capturer_.get());
     EXPECT_TRUE(SetOneCodec(DefaultCodec()));
     EXPECT_FALSE(channel_->sending());
     EXPECT_TRUE(SetSend(true));
@@ -567,7 +546,7 @@
     EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format));
     EXPECT_TRUE(channel_->AddSendStream(
         cricket::StreamParams::CreateLegacy(5678)));
-    EXPECT_TRUE(channel_->SetCapturer(5678, capturer.get()));
+    channel_->SetSource(5678, capturer.get());
     EXPECT_TRUE(channel_->AddRecvStream(
         cricket::StreamParams::CreateLegacy(5678)));
     EXPECT_TRUE(channel_->SetSink(5678, &renderer2));
@@ -603,7 +582,7 @@
     EXPECT_EQ(kTestWidth, info.senders[1].send_frame_width);
     EXPECT_EQ(kTestHeight, info.senders[1].send_frame_height);
     // The capturer must be unregistered here as it runs out of it's scope next.
-    EXPECT_TRUE(channel_->SetCapturer(5678, NULL));
+    channel_->SetSource(5678, NULL);
   }
 
   // Test that we can set the bandwidth.
@@ -640,7 +619,7 @@
     EXPECT_TRUE(SetDefaultCodec());
     EXPECT_TRUE(channel_->AddSendStream(
         cricket::StreamParams::CreateLegacy(999)));
-    EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get()));
+    channel_->SetSource(999u, video_capturer_.get());
     EXPECT_TRUE(SetSend(true));
     EXPECT_TRUE(WaitAndSendFrame(0));
     EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
@@ -706,7 +685,7 @@
 
     EXPECT_TRUE(channel_->AddSendStream(
         cricket::StreamParams::CreateLegacy(789u)));
-    EXPECT_TRUE(channel_->SetCapturer(789u, video_capturer_.get()));
+    channel_->SetSource(789u, video_capturer_.get());
     EXPECT_EQ(rtp_packets, NumRtpPackets());
     // Wait 30ms to guarantee the engine does not drop the frame.
     EXPECT_TRUE(WaitAndSendFrame(30));
@@ -789,7 +768,7 @@
 
     int captured_frames = 1;
     for (int iterations = 0; iterations < 2; ++iterations) {
-      EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get()));
+      channel_->SetSource(kSsrc, capturer.get());
       rtc::Thread::Current()->ProcessMessages(time_between_send);
       EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height,
                                                cricket::FOURCC_I420));
@@ -804,7 +783,7 @@
       EXPECT_EQ(format.height, renderer_.height());
       captured_frames = renderer_.num_rendered_frames() + 1;
       EXPECT_FALSE(renderer_.black_frame());
-      EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
+      channel_->SetSource(kSsrc, NULL);
       // Make sure a black frame is generated within the specified timeout.
       // The black frame should be the resolution of the previous frame to
       // prevent expensive encoder reconfigurations.
@@ -839,13 +818,12 @@
     // tightly.
     rtc::Thread::Current()->ProcessMessages(30);
     // Remove the capturer.
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
+    channel_->SetSource(kSsrc, NULL);
     // Wait for one black frame for removing the capturer.
     EXPECT_FRAME_WAIT(2, 640, 400, kTimeout);
 
-    // No capturer was added, so this RemoveCapturer should
-    // fail.
-    EXPECT_FALSE(channel_->SetCapturer(kSsrc, NULL));
+    // No capturer was added, so this SetSource should be a NOP.
+    channel_->SetSource(kSsrc, NULL);
     rtc::Thread::Current()->ProcessMessages(300);
     // Verify no more frames were sent.
     EXPECT_EQ(2, renderer_.num_rendered_frames());
@@ -887,11 +865,11 @@
     EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format));
     // State for all the streams.
     EXPECT_TRUE(SetOneCodec(DefaultCodec()));
-    // A limitation in the lmi implementation requires that SetCapturer() is
+    // A limitation in the lmi implementation requires that SetSource() is
     // called after SetOneCodec().
     // TODO(hellner): this seems like an unnecessary constraint, fix it.
-    EXPECT_TRUE(channel_->SetCapturer(1, capturer1.get()));
-    EXPECT_TRUE(channel_->SetCapturer(2, capturer2.get()));
+    channel_->SetSource(1, capturer1.get());
+    channel_->SetSource(2, capturer2.get());
     EXPECT_TRUE(SetSend(true));
     // Test capturer associated with engine.
     const int kTestWidth = 160;
@@ -906,13 +884,13 @@
     EXPECT_FRAME_ON_RENDERER_WAIT(
         renderer2, 1, kTestWidth, kTestHeight, kTimeout);
     // Successfully remove the capturer.
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
+    channel_->SetSource(kSsrc, NULL);
     // Fail to re-remove the capturer.
-    EXPECT_FALSE(channel_->SetCapturer(kSsrc, NULL));
+    channel_->SetSource(kSsrc, NULL);
     // The capturers must be unregistered here as it runs out of it's scope
     // next.
-    EXPECT_TRUE(channel_->SetCapturer(1, NULL));
-    EXPECT_TRUE(channel_->SetCapturer(2, NULL));
+    channel_->SetSource(1, NULL);
+    channel_->SetSource(2, NULL);
   }
 
   void HighAspectHighHeightCapturer() {
@@ -945,13 +923,13 @@
     EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format));
     // Capture frame to not get same frame timestamps as previous capturer.
     capturer->CaptureFrame();
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get()));
+    channel_->SetSource(kSsrc, capturer.get());
     EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
     EXPECT_TRUE(capturer->CaptureCustomFrame(kWidth, kHeight,
                                              cricket::FOURCC_ARGB));
     EXPECT_GT_FRAME_ON_RENDERER_WAIT(
         renderer, 2, kScaledWidth, kScaledHeight, kTimeout);
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
+    channel_->SetSource(kSsrc, NULL);
   }
 
   // Tests that we can adapt video resolution with 16:10 aspect ratio properly.
@@ -1062,57 +1040,6 @@
     EXPECT_FRAME_WAIT(2, codec.width / 2, codec.height / 2, kTimeout);
   }
 
-  // Tests that we can mute and unmute the channel properly.
-  void MuteStream() {
-    EXPECT_TRUE(SetDefaultCodec());
-    cricket::FakeVideoCapturer video_capturer;
-    video_capturer.Start(
-        cricket::VideoFormat(
-            640, 480,
-            cricket::VideoFormat::FpsToInterval(30),
-            cricket::FOURCC_I420));
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, &video_capturer));
-    EXPECT_TRUE(SetSend(true));
-    EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
-    EXPECT_EQ(0, renderer_.num_rendered_frames());
-    // Mute the channel and expect black output frame.
-    int frame_count = 0;
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
-    EXPECT_TRUE(video_capturer.CaptureFrame());
-    ++frame_count;
-    EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
-    EXPECT_TRUE(renderer_.black_frame());
-    // Unmute the channel and expect non-black output frame.
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
-    EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
-    EXPECT_TRUE(video_capturer.CaptureFrame());
-    ++frame_count;
-    EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
-    EXPECT_FALSE(renderer_.black_frame());
-    // Test that we can also Mute using the correct send stream SSRC.
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
-    EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
-    EXPECT_TRUE(video_capturer.CaptureFrame());
-    ++frame_count;
-    EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
-    EXPECT_TRUE(renderer_.black_frame());
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
-    EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
-    EXPECT_TRUE(video_capturer.CaptureFrame());
-    ++frame_count;
-    EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
-    EXPECT_FALSE(renderer_.black_frame());
-    // Test that muting an existing stream succeeds even if it's muted.
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
-    // Test that unmuting an existing stream succeeds even if it's not muted.
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
-    EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
-    // Test that muting an invalid stream fails.
-    EXPECT_FALSE(channel_->SetVideoSend(kSsrc+1, false, nullptr));
-    EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
-  }
-
   // Test that multiple send streams can be created and deleted properly.
   void MultipleSendStreams() {
     // Remove stream added in Setup. I.e. remove stream corresponding to default
@@ -1144,7 +1071,7 @@
   }
 
   const std::unique_ptr<webrtc::Call> call_;
-  VideoEngineOverride<E> engine_;
+  E engine_;
   std::unique_ptr<cricket::FakeVideoCapturer> video_capturer_;
   std::unique_ptr<cricket::FakeVideoCapturer> video_capturer_2_;
   std::unique_ptr<C> channel_;
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc
index 969c6e5..fc87607 100644
--- a/webrtc/media/engine/webrtcvideoengine2.cc
+++ b/webrtc/media/engine/webrtcvideoengine2.cc
@@ -21,7 +21,6 @@
 #include "webrtc/base/timeutils.h"
 #include "webrtc/base/trace_event.h"
 #include "webrtc/call.h"
-#include "webrtc/media/base/videocapturer.h"
 #include "webrtc/media/engine/constants.h"
 #include "webrtc/media/engine/simulcast.h"
 #include "webrtc/media/engine/webrtcmediaengine.h"
@@ -1001,6 +1000,9 @@
   return true;
 }
 
+// TODO(nisse): The enable argument was used for mute logic which has
+// been moved to VideoBroadcaster. So delete this method, and use
+// SetOptions instead.
 bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable,
                                        const VideoOptions* options) {
   TRACE_EVENT0("webrtc", "SetVideoSend");
@@ -1008,11 +1010,6 @@
                << "options: " << (options ? options->ToString() : "nullptr")
                << ").";
 
-  // TODO(solenberg): The state change should be fully rolled back if any one of
-  //                  these calls fail.
-  if (!MuteStream(ssrc, !enable)) {
-    return false;
-  }
   if (enable && options) {
     SetOptions(ssrc, *options);
   }
@@ -1315,22 +1312,21 @@
   video_media_info->bw_estimations.push_back(bwe_info);
 }
 
-bool WebRtcVideoChannel2::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
-  LOG(LS_INFO) << "SetCapturer: " << ssrc << " -> "
-               << (capturer != NULL ? "(capturer)" : "NULL");
+void WebRtcVideoChannel2::SetSource(
+    uint32_t ssrc,
+    rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
+  LOG(LS_INFO) << "SetSource: " << ssrc << " -> "
+               << (source ? "(source)" : "NULL");
   RTC_DCHECK(ssrc != 0);
-  {
-    rtc::CritScope stream_lock(&stream_crit_);
-    const auto& kv = send_streams_.find(ssrc);
-    if (kv == send_streams_.end()) {
-      LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc;
-      return false;
-    }
-    if (!kv->second->SetCapturer(capturer)) {
-      return false;
-    }
+
+  rtc::CritScope stream_lock(&stream_crit_);
+  const auto& kv = send_streams_.find(ssrc);
+  if (kv == send_streams_.end()) {
+    // Allow unknown ssrc only if source is null.
+    RTC_CHECK(source == nullptr);
+  } else {
+    kv->second->SetSource(source);
   }
-  return true;
 }
 
 void WebRtcVideoChannel2::OnPacketReceived(
@@ -1420,21 +1416,6 @@
   // call_->OnNetworkRouteChanged(transport_name, network_route);
 }
 
-bool WebRtcVideoChannel2::MuteStream(uint32_t ssrc, bool mute) {
-  LOG(LS_VERBOSE) << "MuteStream: " << ssrc << " -> "
-                  << (mute ? "mute" : "unmute");
-  RTC_DCHECK(ssrc != 0);
-  rtc::CritScope stream_lock(&stream_crit_);
-  const auto& kv = send_streams_.find(ssrc);
-  if (kv == send_streams_.end()) {
-    LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc;
-    return false;
-  }
-
-  kv->second->MuteStream(mute);
-  return true;
-}
-
 // TODO(pbos): Remove SetOptions in favor of SetSendParameters.
 void WebRtcVideoChannel2::SetOptions(uint32_t ssrc,
                                      const VideoOptions& options) {
@@ -1523,7 +1504,7 @@
       call_(call),
       cpu_restricted_counter_(0),
       number_of_cpu_adapt_changes_(0),
-      capturer_(nullptr),
+      source_(nullptr),
       external_encoder_factory_(external_encoder_factory),
       stream_(nullptr),
       parameters_(config, options, max_bitrate_bps, codec_settings),
@@ -1531,7 +1512,6 @@
       pending_encoder_reconfiguration_(false),
       allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false),
       sending_(false),
-      muted_(false),
       first_frame_timestamp_ms_(0),
       last_frame_timestamp_ms_(0) {
   parameters_.config.rtp.max_packet_size = kVideoMtu;
@@ -1557,7 +1537,7 @@
 }
 
 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() {
-  DisconnectCapturer();
+  DisconnectSource();
   if (stream_ != NULL) {
     call_->DestroyVideoSendStream(stream_);
   }
@@ -1590,14 +1570,6 @@
     return;
   }
 
-  if (muted_) {
-    // Create a black frame to transmit instead.
-    CreateBlackFrame(&video_frame,
-                     frame.width(),
-                     frame.height(),
-                     video_frame.rotation());
-  }
-
   int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec;
   // frame->GetTimeStamp() is essentially a delta, align to webrtc time
   if (first_frame_timestamp_ms_ == 0) {
@@ -1620,13 +1592,14 @@
   stream_->Input()->IncomingCapturedFrame(video_frame);
 }
 
-bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer(
-    VideoCapturer* capturer) {
-  TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer");
+void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource(
+    rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
+  TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource");
   RTC_DCHECK(thread_checker_.CalledOnValidThread());
-  if (!DisconnectCapturer() && capturer == NULL) {
-    return false;
-  }
+
+  if (!source && !source_)
+    return;
+  DisconnectSource();
 
   {
     rtc::CritScope cs(&lock_);
@@ -1635,7 +1608,7 @@
     // new capturer may have a different timestamp delta than the previous one.
     first_frame_timestamp_ms_ = 0;
 
-    if (capturer == NULL) {
+    if (source == NULL) {
       if (stream_ != NULL) {
         LOG(LS_VERBOSE) << "Disabling capturer, sending black frame.";
         webrtc::VideoFrame black_frame;
@@ -1652,39 +1625,31 @@
         black_frame.set_render_time_ms(last_frame_timestamp_ms_);
         stream_->Input()->IncomingCapturedFrame(black_frame);
       }
-
-      capturer_ = NULL;
-      return true;
     }
   }
-  capturer_ = capturer;
-  // |capturer_->AddOrUpdateSink| may not be called while holding |lock_| since
+  source_ = source;
+  // |source_->AddOrUpdateSink| may not be called while holding |lock_| since
   // that might cause a lock order inversion.
-  capturer_->AddOrUpdateSink(this, sink_wants_);
-  return true;
+  if (source_) {
+    source_->AddOrUpdateSink(this, sink_wants_);
+  }
 }
 
-void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) {
-  rtc::CritScope cs(&lock_);
-  muted_ = mute;
-}
-
-bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() {
+void WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectSource() {
   RTC_DCHECK(thread_checker_.CalledOnValidThread());
-  if (capturer_ == NULL) {
-    return false;
+  if (source_ == NULL) {
+    return;
   }
 
-  // |capturer_->RemoveSink| may not be called while holding |lock_| since
+  // |source_->RemoveSink| may not be called while holding |lock_| since
   // that might cause a lock order inversion.
-  capturer_->RemoveSink(this);
-  capturer_ = NULL;
+  source_->RemoveSink(this);
+  source_ = nullptr;
   // Reset |cpu_restricted_counter_| if the capturer is changed. It is not
   // possible to know if the video resolution is restricted by CPU usage after
   // the capturer is changed since the next capturer might be screen capture
   // with another resolution and frame rate.
   cpu_restricted_counter_ = 0;
-  return true;
 }
 
 const std::vector<uint32_t>&
@@ -1845,8 +1810,8 @@
   if (params.rtp_header_extensions) {
     sink_wants_.rotation_applied = !ContainsHeaderExtension(
         *params.rtp_header_extensions, kRtpVideoRotationHeaderExtension);
-    if (capturer_) {
-      capturer_->AddOrUpdateSink(this, sink_wants_);
+    if (source_) {
+      source_->AddOrUpdateSink(this, sink_wants_);
     }
   }
 }
@@ -2011,7 +1976,7 @@
     return;
   }
   RTC_DCHECK(thread_checker_.CalledOnValidThread());
-  if (!capturer_) {
+  if (!source_) {
     return;
   }
   {
@@ -2067,9 +2032,9 @@
     sink_wants_.max_pixel_count = max_pixel_count;
     sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up;
   }
-  // |capturer_->AddOrUpdateSink| may not be called while holding |lock_| since
+  // |source_->AddOrUpdateSink| may not be called while holding |lock_| since
   // that might cause a lock order inversion.
-  capturer_->AddOrUpdateSink(this, sink_wants_);
+  source_->AddOrUpdateSink(this, sink_wants_);
 }
 
 VideoSenderInfo
diff --git a/webrtc/media/engine/webrtcvideoengine2.h b/webrtc/media/engine/webrtcvideoengine2.h
index ba2dbd8..b9ab0b7 100644
--- a/webrtc/media/engine/webrtcvideoengine2.h
+++ b/webrtc/media/engine/webrtcvideoengine2.h
@@ -161,7 +161,9 @@
   bool SetSink(uint32_t ssrc,
                rtc::VideoSinkInterface<VideoFrame>* sink) override;
   bool GetStats(VideoMediaInfo* info) override;
-  bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override;
+  void SetSource(
+      uint32_t ssrc,
+      rtc::VideoSourceInterface<cricket::VideoFrame>* source) override;
 
   void OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
                         const rtc::PacketTime& packet_time) override;
@@ -217,8 +219,6 @@
   bool GetChangedRecvParameters(const VideoRecvParameters& params,
                                 ChangedRecvParameters* changed_params) const;
 
-  bool MuteStream(uint32_t ssrc, bool mute);
-
   void SetMaxSendBandwidth(int bps);
   void SetOptions(uint32_t ssrc, const VideoOptions& options);
 
@@ -235,7 +235,7 @@
   static std::string CodecSettingsVectorToString(
       const std::vector<VideoCodecSettings>& codecs);
 
-  // Wrapper for the sender part, this is where the capturer is connected and
+  // Wrapper for the sender part, this is where the source is connected and
   // frames are then converted from cricket frames to webrtc frames.
   class WebRtcVideoSendStream
       : public rtc::VideoSinkInterface<cricket::VideoFrame>,
@@ -261,9 +261,8 @@
     webrtc::RtpParameters GetRtpParameters() const;
 
     void OnFrame(const cricket::VideoFrame& frame) override;
-    bool SetCapturer(VideoCapturer* capturer);
-    void MuteStream(bool mute);
-    bool DisconnectCapturer();
+    void SetSource(rtc::VideoSourceInterface<cricket::VideoFrame>* source);
+    void DisconnectSource();
 
     void SetSend(bool send);
 
@@ -365,12 +364,12 @@
     webrtc::Call* const call_;
     rtc::VideoSinkWants sink_wants_;
     // Counter used for deciding if the video resolution is currently
-    // restricted by CPU usage. It is reset if |capturer_| is changed.
+    // restricted by CPU usage. It is reset if |source_| is changed.
     int cpu_restricted_counter_;
     // Total number of times resolution as been requested to be changed due to
     // CPU adaptation.
     int number_of_cpu_adapt_changes_;
-    VideoCapturer* capturer_;
+    rtc::VideoSourceInterface<cricket::VideoFrame>* source_;
     WebRtcVideoEncoderFactory* const external_encoder_factory_
         GUARDED_BY(lock_);
 
@@ -393,14 +392,13 @@
         webrtc::kVideoRotation_0;
 
     bool sending_ GUARDED_BY(lock_);
-    bool muted_ GUARDED_BY(lock_);
 
     // The timestamp of the first frame received
     // Used to generate the timestamps of subsequent frames
     int64_t first_frame_timestamp_ms_ GUARDED_BY(lock_);
 
     // The timestamp of the last frame received
-    // Used to generate timestamp for the black frame when capturer is removed
+    // Used to generate timestamp for the black frame when source is removed
     int64_t last_frame_timestamp_ms_ GUARDED_BY(lock_);
   };
 
diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
index e1f5406..63aae9a 100644
--- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
@@ -241,7 +241,7 @@
   EXPECT_TRUE(channel->SetSendParameters(parameters));
 
   // Set capturer.
-  EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
+  channel->SetSource(kSsrc, &capturer);
 
   // Verify capturer has turned off applying rotation.
   EXPECT_FALSE(capturer.GetApplyRotation());
@@ -272,7 +272,7 @@
   EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
 
   // Set capturer.
-  EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
+  channel->SetSource(kSsrc, &capturer);
 
   // Verify capturer has turned off applying rotation.
   EXPECT_FALSE(capturer.GetApplyRotation());
@@ -293,7 +293,7 @@
   EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
 
   // Set capturer.
-  EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
+  channel->SetSource(kSsrc, &capturer);
 
   // Verify capturer has turned on applying rotation.
   EXPECT_TRUE(capturer.GetApplyRotation());
@@ -352,7 +352,7 @@
   EXPECT_TRUE(channel->SetSend(true));
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
+  channel->SetSource(kSsrc, &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -439,7 +439,7 @@
       channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
 
   FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
+  channel->SetSource(kSsrc, &capturer);
   capturer.Start(cricket::VideoFormat(1280, 720,
                                       cricket::VideoFormat::FpsToInterval(60),
                                       cricket::FOURCC_I420));
@@ -501,7 +501,7 @@
   FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
 
   FakeVideoCapturer capturer1;
-  EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1));
+  channel->SetSource(kSsrc, &capturer1);
 
   cricket::CapturedFrame frame;
   frame.width = 1280;
@@ -526,7 +526,7 @@
   // Reset input source, should still be continuous even though input-frame
   // timestamp is less than before.
   FakeVideoCapturer capturer2;
-  EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer2));
+  channel->SetSource(kSsrc, &capturer2);
 
   rtc::Thread::Current()->SleepMs(1);
   // Deliver with a timestamp (10 seconds) before the previous initial one,
@@ -586,7 +586,7 @@
   EXPECT_TRUE(channel->SetSend(true));
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), &capturer));
+  channel->SetSource(ssrcs.front(), &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -604,7 +604,7 @@
     prev_width = codec_settings.width;
   }
 
-  EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), NULL));
+  channel->SetSource(ssrcs.front(), NULL);
 
   channel.reset();
   ASSERT_EQ(0u, encoder_factory.encoders().size());
@@ -667,7 +667,7 @@
   // encoder adapter at a low-enough size that it'll only create a single
   // encoder layer.
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), &capturer));
+  channel->SetSource(ssrcs.front(), &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -721,7 +721,7 @@
   cricket::VideoFormat format(
       1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420);
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel->SetCapturer(ssrcs[0], &capturer));
+  channel->SetSource(ssrcs[0], &capturer);
   EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format));
   EXPECT_TRUE(capturer.CaptureFrame());
 
@@ -729,7 +729,7 @@
   FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0];
   EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType);
   EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams);
-  EXPECT_TRUE(channel->SetCapturer(ssrcs[0], nullptr));
+  channel->SetSource(ssrcs[0], nullptr);
 }
 
 // Test that external codecs are added to the end of the supported codec list.
@@ -849,8 +849,6 @@
 
 WEBRTC_BASE_TEST(SendsLowerResolutionOnSmallerFrames);
 
-WEBRTC_BASE_TEST(MuteStream);
-
 WEBRTC_BASE_TEST(MultipleSendStreams);
 
 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) {
@@ -1538,7 +1536,7 @@
   EXPECT_EQ(144u, streams[0].height);
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -1550,7 +1548,7 @@
   // No frames should have been actually put in there though.
   EXPECT_EQ(0, stream->GetNumberOfSwappedFrames());
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
@@ -1567,7 +1565,7 @@
   channel_->SetVideoSend(last_ssrc_, true, &min_bitrate_options);
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   cricket::VideoFormat capture_format_hd =
       capturer.GetSupportedFormats()->front();
   EXPECT_EQ(1280, capture_format_hd.width);
@@ -1591,10 +1589,10 @@
   EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
       << "Non-screenshare shouldn't use min-transmit bitrate.";
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr));
+  channel_->SetSource(last_ssrc_, nullptr);
   // Removing a capturer triggers a black frame to be sent.
   EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   VideoOptions screencast_options;
   screencast_options.is_screencast = rtc::Optional<bool>(true);
   EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &screencast_options));
@@ -1614,7 +1612,7 @@
   EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
   EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty());
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) {
@@ -1624,7 +1622,7 @@
   EXPECT_TRUE(channel_->SetSend(true));
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(kSsrc, &capturer));
+  channel_->SetSource(kSsrc, &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -1665,7 +1663,7 @@
   EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
             encoder_config.content_type);
 
-  EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
+  channel_->SetSource(kSsrc, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test,
@@ -1680,7 +1678,7 @@
   options.is_screencast = rtc::Optional<bool>(true);
   channel_->SetVideoSend(last_ssrc_, true, &options);
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   cricket::VideoFormat capture_format_hd =
       capturer.GetSupportedFormats()->front();
   EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
@@ -1702,7 +1700,7 @@
   EXPECT_EQ(kConferenceScreencastTemporalBitrateBps,
             encoder_config.streams[0].temporal_layer_thresholds_bps[0]);
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) {
@@ -1752,7 +1750,7 @@
   cricket::FakeVideoCapturer capturer;
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   channel_->SetSend(true);
 
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -1776,9 +1774,9 @@
   EXPECT_TRUE(vp8_settings.automaticResizeOn);
   EXPECT_TRUE(vp8_settings.frameDroppingOn);
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
   stream = SetUpSimulcast(true, false);
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   channel_->SetSend(true);
   EXPECT_TRUE(capturer.CaptureFrame());
 
@@ -1809,7 +1807,7 @@
   EXPECT_FALSE(vp8_settings.automaticResizeOn);
   EXPECT_FALSE(vp8_settings.frameDroppingOn);
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 // Test that setting the same options doesn't result in the encoder being
@@ -1819,7 +1817,7 @@
   cricket::FakeVideoCapturer capturer;
 
   FakeVideoSendStream* send_stream = AddSendStream();
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options));
@@ -1833,7 +1831,7 @@
   EXPECT_TRUE(capturer.CaptureFrame());
   EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr));
+  channel_->SetSource(last_ssrc_, nullptr);
 }
 
 class Vp9SettingsTest : public WebRtcVideoChannel2Test {
@@ -1871,7 +1869,7 @@
   cricket::FakeVideoCapturer capturer;
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   channel_->SetSend(true);
 
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -1912,7 +1910,7 @@
   EXPECT_FALSE(vp9_settings.denoisingOn);
   EXPECT_FALSE(vp9_settings.frameDroppingOn);
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest {
@@ -1931,7 +1929,7 @@
     cricket::FakeVideoCapturer capturer;
     EXPECT_EQ(cricket::CS_RUNNING,
               capturer.Start(capturer.GetSupportedFormats()->front()));
-    EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+    channel_->SetSource(last_ssrc_, &capturer);
     channel_->SetSend(true);
 
     EXPECT_TRUE(capturer.CaptureFrame());
@@ -1941,7 +1939,7 @@
     EXPECT_EQ(num_spatial_layers, vp9_settings.numberOfSpatialLayers);
     EXPECT_EQ(num_temporal_layers, vp9_settings.numberOfTemporalLayers);
 
-    EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+    channel_->SetSource(last_ssrc_, NULL);
   }
 };
 
@@ -2006,7 +2004,7 @@
   AddSendStream();
 
   cricket::FakeVideoCapturer capturer;
-  ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   ASSERT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   ASSERT_TRUE(channel_->SetSend(true));
@@ -2064,7 +2062,7 @@
   EXPECT_EQ(1284, send_stream->GetLastWidth());
   EXPECT_EQ(724, send_stream->GetLastHeight());
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) {
@@ -2080,7 +2078,7 @@
   AddSendStream();
 
   cricket::FakeVideoCapturer capturer;
-  ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   ASSERT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   ASSERT_TRUE(channel_->SetSend(true));
@@ -2109,7 +2107,7 @@
   cricket::FakeVideoCapturer screen_share(true);
   ASSERT_EQ(cricket::CS_RUNNING,
             screen_share.Start(screen_share.GetSupportedFormats()->front()));
-  ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &screen_share));
+  channel_->SetSource(last_ssrc_, &screen_share);
   cricket::VideoOptions screenshare_options;
   screenshare_options.is_screencast = rtc::Optional<bool>(true);
   channel_->SetVideoSend(last_ssrc_, true /* enable */, &screenshare_options);
@@ -2119,14 +2117,14 @@
   EXPECT_EQ(724, send_stream->GetLastHeight());
 
   // Switch back to the normal capturer. Expect the frame to be CPU adapted.
-  ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options);
   EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
   EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames());
   EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
   EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
@@ -2151,7 +2149,7 @@
   EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options));
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
 
@@ -2172,7 +2170,7 @@
     EXPECT_EQ(codec.width, send_stream->GetLastWidth());
     EXPECT_EQ(codec.height, send_stream->GetLastHeight());
 
-    EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+    channel_->SetSource(last_ssrc_, NULL);
     return;
   }
 
@@ -2201,7 +2199,7 @@
   EXPECT_EQ(codec.width, send_stream->GetLastWidth());
   EXPECT_EQ(codec.height, send_stream->GetLastHeight());
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) {
@@ -2332,7 +2330,7 @@
   FakeVideoSendStream* stream = AddSendStream();
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -2347,7 +2345,7 @@
   streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams();
   EXPECT_EQ(kVp8Codec360p.width, streams[0].width);
   EXPECT_EQ(kVp8Codec360p.height, streams[0].height);
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) {
@@ -2411,7 +2409,7 @@
   FakeVideoSendStream* stream = AddSendStream();
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
 
@@ -2425,7 +2423,7 @@
   EXPECT_TRUE(capturer.CaptureFrame());
   streams = stream->GetVideoStreams();
   EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps);
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr));
+  channel_->SetSource(last_ssrc_, nullptr);
 }
 
 TEST_F(WebRtcVideoChannel2Test,
@@ -2440,7 +2438,7 @@
 
   // Send a frame to make sure this scales up to >1 stream (simulcast).
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &capturer));
+  channel_->SetSource(kSsrcs3[0], &capturer);
   EXPECT_EQ(cricket::CS_RUNNING,
             capturer.Start(capturer.GetSupportedFormats()->front()));
   EXPECT_TRUE(capturer.CaptureFrame());
@@ -2459,7 +2457,7 @@
   int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
   EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps);
 
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr));
+  channel_->SetSource(kSsrcs3[0], nullptr);
 }
 
 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) {
@@ -2829,7 +2827,7 @@
       video_capturer_vga.GetSupportedFormats();
   cricket::VideoFormat capture_format_vga = (*formats)[1];
   EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga));
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga));
+  channel_->SetSource(kSsrcs3[0], &video_capturer_vga);
   EXPECT_TRUE(video_capturer_vga.CaptureFrame());
 
   cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0);
@@ -2866,7 +2864,7 @@
             info.senders[0].adapt_reason);
 
   // No capturer (no adapter). Adapt changes from old adapter should be kept.
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], NULL));
+  channel_->SetSource(kSsrcs3[0], NULL);
   info.Clear();
   EXPECT_TRUE(channel_->GetStats(&info));
   ASSERT_EQ(1U, info.senders.size());
@@ -2878,7 +2876,7 @@
   cricket::FakeVideoCapturer video_capturer_hd;
   cricket::VideoFormat capture_format_hd = (*formats)[0];
   EXPECT_EQ(cricket::CS_RUNNING, video_capturer_hd.Start(capture_format_hd));
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_hd));
+  channel_->SetSource(kSsrcs3[0], &video_capturer_hd);
   EXPECT_TRUE(video_capturer_hd.CaptureFrame());
 
   // Trigger overuse, HD -> adapt (OnCpuResolutionRequest downgrade) -> HD/2.
@@ -2890,7 +2888,7 @@
   EXPECT_EQ(3, info.senders[0].adapt_changes);
   EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_CPU, info.senders[0].adapt_reason);
 
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], NULL));
+  channel_->SetSource(kSsrcs3[0], NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationAndBandwidthStats) {
@@ -2902,7 +2900,7 @@
       video_capturer_vga.GetSupportedFormats();
   cricket::VideoFormat capture_format_vga = (*formats)[1];
   EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga));
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga));
+  channel_->SetSource(kSsrcs3[0], &video_capturer_vga);
   EXPECT_TRUE(video_capturer_vga.CaptureFrame());
 
   cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0);
@@ -2954,7 +2952,7 @@
   EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_NONE,
             info.senders[0].adapt_reason);
 
-  EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], NULL));
+  channel_->SetSource(kSsrcs3[0], NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test,
@@ -3316,7 +3314,7 @@
   AddSendStream();
 
   cricket::FakeVideoCapturer capturer;
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
+  channel_->SetSource(last_ssrc_, &capturer);
   cricket::VideoFormat capture_format_hd =
       capturer.GetSupportedFormats()->front();
   EXPECT_EQ(1280, capture_format_hd.width);
@@ -3341,7 +3339,7 @@
   SetAndExpectMaxBitrate(capturer, 0, 800, 800);
   SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate);
 
-  EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
+  channel_->SetSource(last_ssrc_, NULL);
 }
 
 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) {
@@ -3475,7 +3473,7 @@
     // Send a full-size frame to trigger a stream reconfiguration to use all
     // expected simulcast layers.
     cricket::FakeVideoCapturer capturer;
-    EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), &capturer));
+    channel_->SetSource(ssrcs.front(), &capturer);
     EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat(
                                        codec.width, codec.height,
                                        cricket::VideoFormat::FpsToInterval(30),
@@ -3532,7 +3530,7 @@
     ASSERT_EQ(1u, info.senders.size());
     EXPECT_EQ(total_max_bitrate_bps, info.senders[0].preferred_bitrate);
 
-    EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), NULL));
+    channel_->SetSource(ssrcs.front(), NULL);
   }
 
   FakeVideoSendStream* AddSendStream() {
diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc
index 9556beb..497610d 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -1690,9 +1690,11 @@
   return true;
 }
 
-bool VideoChannel::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
-  return InvokeOnWorker(Bind(&VideoMediaChannel::SetCapturer,
-                             media_channel(), ssrc, capturer));
+void VideoChannel::SetSource(
+    uint32_t ssrc,
+    rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
+  worker_thread()->Invoke<void>(
+      Bind(&VideoMediaChannel::SetSource, media_channel(), ssrc, source));
 }
 
 bool VideoChannel::SetVideoSend(uint32_t ssrc,
diff --git a/webrtc/pc/channel.h b/webrtc/pc/channel.h
index e05b6e5..4518301 100644
--- a/webrtc/pc/channel.h
+++ b/webrtc/pc/channel.h
@@ -27,8 +27,8 @@
 #include "webrtc/media/base/mediachannel.h"
 #include "webrtc/media/base/mediaengine.h"
 #include "webrtc/media/base/streamparams.h"
-#include "webrtc/media/base/videocapturer.h"
 #include "webrtc/media/base/videosinkinterface.h"
+#include "webrtc/media/base/videosourceinterface.h"
 #include "webrtc/p2p/base/transportcontroller.h"
 #include "webrtc/p2p/client/socketmonitor.h"
 #include "webrtc/pc/audiomonitor.h"
@@ -449,7 +449,10 @@
   }
 
   bool SetSink(uint32_t ssrc, rtc::VideoSinkInterface<VideoFrame>* sink);
-  bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer);
+  // Register a source. The |ssrc| must correspond to a registered
+  // send stream.
+  void SetSource(uint32_t ssrc,
+                 rtc::VideoSourceInterface<cricket::VideoFrame>* source);
   // Get statistics about the current media session.
   bool GetStats(VideoMediaInfo* stats);