diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 19994ebca2..83318b5d0b 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -212,6 +212,8 @@ rtc_library("peerconnection") { "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 @@ if (rtc_include_tests) { "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 1f33f114fe..d5543a2270 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 @@ class VideoRtpReceiver : public rtc::RefCountedObject { std::vector GetSources() const override; private: - class VideoRtpTrackSource : public VideoTrackSource { - public: - VideoRtpTrackSource() : VideoTrackSource(true /* remote */) {} - - rtc::VideoSourceInterface* source() override { - return &broadcaster_; - } - rtc::VideoSinkInterface* 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 ssrc); bool SetSink(rtc::VideoSinkInterface* sink); diff --git a/pc/video_rtp_track_source.cc b/pc/video_rtp_track_source.cc new file mode 100644 index 0000000000..02c334dcea --- /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* VideoRtpTrackSource::source() { + return &broadcaster_; +} +rtc::VideoSinkInterface* 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 0000000000..becdc8e562 --- /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* source() override; + rtc::VideoSinkInterface* 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 0000000000..e1b6a2d19c --- /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 source( + new rtc::RefCountedObject()); + EXPECT_TRUE(source->remote()); +} + +} // namespace +} // namespace webrtc