VideoRtpReceiver: factor out VideoRtpTrackSource.

This change factors out VideoRtpTrackSource in preparation
of building the class out.

Bug: chromium:1013590
Change-Id: I015e285b9fcc10b39428dea9f74e0e8648385f62
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159925
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29870}
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 19994eb..83318b5 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -212,6 +212,8 @@
     "track_media_info_map.h",
     "video_rtp_receiver.cc",
     "video_rtp_receiver.h",
+    "video_rtp_track_source.cc",
+    "video_rtp_track_source.h",
     "video_track.cc",
     "video_track.h",
     "video_track_source.cc",
@@ -539,6 +541,7 @@
       "test/fake_audio_capture_module_unittest.cc",
       "test/test_sdp_strings.h",
       "track_media_info_map_unittest.cc",
+      "video_rtp_track_source_unittest.cc",
       "video_track_unittest.cc",
       "webrtc_sdp_unittest.cc",
     ]
diff --git a/pc/video_rtp_receiver.h b/pc/video_rtp_receiver.h
index 1f33f11..d5543a2 100644
--- a/pc/video_rtp_receiver.h
+++ b/pc/video_rtp_receiver.h
@@ -27,10 +27,9 @@
 #include "api/video/video_sink_interface.h"
 #include "api/video/video_source_interface.h"
 #include "media/base/media_channel.h"
-#include "media/base/video_broadcaster.h"
 #include "pc/jitter_buffer_delay_interface.h"
 #include "pc/rtp_receiver.h"
-#include "pc/video_track_source.h"
+#include "pc/video_rtp_track_source.h"
 #include "rtc_base/ref_counted_object.h"
 #include "rtc_base/thread.h"
 
@@ -110,22 +109,6 @@
   std::vector<RtpSource> GetSources() const override;
 
  private:
-  class VideoRtpTrackSource : public VideoTrackSource {
-   public:
-    VideoRtpTrackSource() : VideoTrackSource(true /* remote */) {}
-
-    rtc::VideoSourceInterface<VideoFrame>* source() override {
-      return &broadcaster_;
-    }
-    rtc::VideoSinkInterface<VideoFrame>* sink() { return &broadcaster_; }
-
-   private:
-    // |broadcaster_| is needed since the decoder can only handle one sink.
-    // It might be better if the decoder can handle multiple sinks and consider
-    // the VideoSinkWants.
-    rtc::VideoBroadcaster broadcaster_;
-  };
-
   void RestartMediaChannel(absl::optional<uint32_t> ssrc);
   bool SetSink(rtc::VideoSinkInterface<VideoFrame>* sink);
 
diff --git a/pc/video_rtp_track_source.cc b/pc/video_rtp_track_source.cc
new file mode 100644
index 0000000..02c334d
--- /dev/null
+++ b/pc/video_rtp_track_source.cc
@@ -0,0 +1,25 @@
+/*
+ *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "pc/video_rtp_track_source.h"
+
+namespace webrtc {
+
+VideoRtpTrackSource::VideoRtpTrackSource()
+    : VideoTrackSource(true /* remote */) {}
+
+rtc::VideoSourceInterface<VideoFrame>* VideoRtpTrackSource::source() {
+  return &broadcaster_;
+}
+rtc::VideoSinkInterface<VideoFrame>* VideoRtpTrackSource::sink() {
+  return &broadcaster_;
+}
+
+}  // namespace webrtc
diff --git a/pc/video_rtp_track_source.h b/pc/video_rtp_track_source.h
new file mode 100644
index 0000000..becdc8e
--- /dev/null
+++ b/pc/video_rtp_track_source.h
@@ -0,0 +1,39 @@
+/*
+ *  Copyright 2019 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef PC_VIDEO_RTP_TRACK_SOURCE_H_
+#define PC_VIDEO_RTP_TRACK_SOURCE_H_
+
+#include "media/base/video_broadcaster.h"
+#include "pc/video_track_source.h"
+
+namespace webrtc {
+
+// Video track source in use by VideoRtpReceiver
+class VideoRtpTrackSource : public VideoTrackSource {
+ public:
+  VideoRtpTrackSource();
+
+  // VideoTrackSource
+  rtc::VideoSourceInterface<VideoFrame>* source() override;
+  rtc::VideoSinkInterface<VideoFrame>* sink();
+
+ private:
+  // |broadcaster_| is needed since the decoder can only handle one sink.
+  // It might be better if the decoder can handle multiple sinks and consider
+  // the VideoSinkWants.
+  rtc::VideoBroadcaster broadcaster_;
+
+  RTC_DISALLOW_COPY_AND_ASSIGN(VideoRtpTrackSource);
+};
+
+}  // namespace webrtc
+
+#endif  // PC_VIDEO_RTP_TRACK_SOURCE_H_
diff --git a/pc/video_rtp_track_source_unittest.cc b/pc/video_rtp_track_source_unittest.cc
new file mode 100644
index 0000000..e1b6a2d
--- /dev/null
+++ b/pc/video_rtp_track_source_unittest.cc
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "pc/video_rtp_track_source.h"
+
+#include "rtc_base/ref_counted_object.h"
+#include "test/gmock.h"
+#include "test/gtest.h"
+
+namespace webrtc {
+namespace {
+
+TEST(VideoRtpTrackSourceTest, CreatesWithRemoteAtttributeSet) {
+  rtc::scoped_refptr<VideoRtpTrackSource> source(
+      new rtc::RefCountedObject<VideoRtpTrackSource>());
+  EXPECT_TRUE(source->remote());
+}
+
+}  // namespace
+}  // namespace webrtc