Replace VideoCapturerInput with VideoSinkInterface.
Adds new method VideoSendStream::SetSource(rtc::VideoSourceInterface* and VieEncoder::SetSource(rtc::VideoSourceInterface*)

This is the first step needed in order for the ViEEncoder to request downscaling using rtc::VideoSinkWants instead of separately reporting CPU overuse and internally doing downscaling due to QP values

This cl
Revert "Revert of Replace interface VideoCapturerInput with VideoSinkInterface. (patchset #13 id:280001 of https://codereview.webrtc.org/2257413002/ )"

This reverts commit 9fdbda6aa3f66ea872344c22e79b23361047cbab.

and fix the problem in the original cl in video_quality_test.cc

BUG=webrtc:5687
TBR=mflodman@webrtc.org

Review-Url: https://codereview.webrtc.org/2348533002
Cr-Commit-Position: refs/heads/master@{#14265}
diff --git a/webrtc/test/frame_generator_capturer.cc b/webrtc/test/frame_generator_capturer.cc
index 95ac624..7e92909 100644
--- a/webrtc/test/frame_generator_capturer.cc
+++ b/webrtc/test/frame_generator_capturer.cc
@@ -21,14 +21,12 @@
 namespace webrtc {
 namespace test {
 
-FrameGeneratorCapturer* FrameGeneratorCapturer::Create(VideoCaptureInput* input,
-                                                       size_t width,
+FrameGeneratorCapturer* FrameGeneratorCapturer::Create(size_t width,
                                                        size_t height,
                                                        int target_fps,
                                                        Clock* clock) {
   FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer(
-      clock, input, FrameGenerator::CreateChromaGenerator(width, height),
-      target_fps);
+      clock, FrameGenerator::CreateChromaGenerator(width, height), target_fps);
   if (!capturer->Init()) {
     delete capturer;
     return NULL;
@@ -38,16 +36,14 @@
 }
 
 FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile(
-    VideoCaptureInput* input,
     const std::string& file_name,
     size_t width,
     size_t height,
     int target_fps,
     Clock* clock) {
   FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer(
-      clock, input,
-      FrameGenerator::CreateFromYuvFile(std::vector<std::string>(1, file_name),
-                                        width, height, 1),
+      clock, FrameGenerator::CreateFromYuvFile(
+                 std::vector<std::string>(1, file_name), width, height, 1),
       target_fps);
   if (!capturer->Init()) {
     delete capturer;
@@ -58,20 +54,18 @@
 }
 
 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock,
-                                               VideoCaptureInput* input,
                                                FrameGenerator* frame_generator,
                                                int target_fps)
-    : VideoCapturer(input),
-      clock_(clock),
+    : clock_(clock),
       sending_(false),
+      sink_(nullptr),
       tick_(EventTimerWrapper::Create()),
       thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"),
       frame_generator_(frame_generator),
       target_fps_(target_fps),
       first_frame_capture_time_(-1) {
-  assert(input != NULL);
-  assert(frame_generator != NULL);
-  assert(target_fps > 0);
+  RTC_DCHECK(frame_generator);
+  RTC_DCHECK_GT(target_fps, 0);
 }
 
 FrameGeneratorCapturer::~FrameGeneratorCapturer() {
@@ -113,7 +107,8 @@
       if (first_frame_capture_time_ == -1) {
         first_frame_capture_time_ = frame->ntp_time_ms();
       }
-      input_->IncomingCapturedFrame(*frame);
+      if (sink_)
+        sink_->OnFrame(*frame);
     }
   }
   tick_->Wait(WEBRTC_EVENT_INFINITE);
@@ -129,6 +124,21 @@
   sending_ = false;
 }
 
+void FrameGeneratorCapturer::AddOrUpdateSink(
+    rtc::VideoSinkInterface<VideoFrame>* sink,
+    const rtc::VideoSinkWants& wants) {
+  rtc::CritScope cs(&lock_);
+  RTC_CHECK(!sink_);
+  sink_ = sink;
+}
+
+void FrameGeneratorCapturer::RemoveSink(
+    rtc::VideoSinkInterface<VideoFrame>* sink) {
+  rtc::CritScope cs(&lock_);
+  RTC_CHECK(sink_ == sink);
+  sink_ = nullptr;
+}
+
 void FrameGeneratorCapturer::ForceFrame() {
   tick_->Set();
 }