diff --git a/call/BUILD.gn b/call/BUILD.gn index 4bc51922e9..cc81b38e26 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -293,6 +293,7 @@ rtc_library("call") { "../api:sequence_checker", "../api:simulated_network_api", "../api:transport_api", + "../api/environment", "../api/rtc_event_log", "../api/task_queue:pending_task_safety_flag", "../api/transport:network_control", diff --git a/call/call.cc b/call/call.cc index 953fdda399..2e4a25ef78 100644 --- a/call/call.cc +++ b/call/call.cc @@ -1054,7 +1054,7 @@ FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( // OnRtpPacket until the constructor is finished and the object is // in a valid state, since OnRtpPacket runs on the same thread. FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( - &env_.clock(), std::move(config), &video_receiver_controller_, + env_, std::move(config), &video_receiver_controller_, call_stats_->AsRtcpRttStats()); // TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc index e20f1b6ac5..053cf67a96 100644 --- a/call/flexfec_receive_stream_impl.cc +++ b/call/flexfec_receive_stream_impl.cc @@ -18,6 +18,7 @@ #include "api/array_view.h" #include "api/call/transport.h" +#include "api/environment/environment.h" #include "api/rtp_parameters.h" #include "call/rtp_stream_receiver_controller_interface.h" #include "modules/rtp_rtcp/include/flexfec_receiver.h" @@ -25,7 +26,6 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" -#include "system_wrappers/include/clock.h" namespace webrtc { @@ -100,45 +100,33 @@ std::unique_ptr MaybeCreateFlexfecReceiver( recovered_packet_receiver)); } -std::unique_ptr CreateRtpRtcpModule( - Clock* clock, - ReceiveStatistics* receive_statistics, - const FlexfecReceiveStreamImpl::Config& config, - RtcpRttStats* rtt_stats) { - RtpRtcpInterface::Configuration configuration; - configuration.audio = false; - configuration.receiver_only = true; - configuration.clock = clock; - configuration.receive_statistics = receive_statistics; - configuration.outgoing_transport = config.rtcp_send_transport; - configuration.rtt_stats = rtt_stats; - configuration.local_media_ssrc = config.rtp.local_ssrc; - return ModuleRtpRtcpImpl2::Create(configuration); -} - } // namespace FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl( - Clock* clock, + const Environment& env, Config config, RecoveredPacketReceiver* recovered_packet_receiver, RtcpRttStats* rtt_stats) : remote_ssrc_(config.rtp.remote_ssrc), payload_type_(config.payload_type), - receiver_( - MaybeCreateFlexfecReceiver(clock, config, recovered_packet_receiver)), - rtp_receive_statistics_(ReceiveStatistics::Create(clock)), - rtp_rtcp_(CreateRtpRtcpModule(clock, - rtp_receive_statistics_.get(), - config, - rtt_stats)) { + receiver_(MaybeCreateFlexfecReceiver(&env.clock(), + config, + recovered_packet_receiver)), + rtp_receive_statistics_(ReceiveStatistics::Create(&env.clock())), + rtp_rtcp_(env, + {.audio = false, + .receiver_only = true, + .receive_statistics = rtp_receive_statistics_.get(), + .outgoing_transport = config.rtcp_send_transport, + .rtt_stats = rtt_stats, + .local_media_ssrc = config.rtp.local_ssrc}) { RTC_LOG(LS_INFO) << "FlexfecReceiveStreamImpl: " << config.ToString(); RTC_DCHECK_GE(payload_type_, -1); packet_sequence_checker_.Detach(); // RTCP reporting. - rtp_rtcp_->SetRTCPStatus(config.rtcp_mode); + rtp_rtcp_.SetRTCPStatus(config.rtcp_mode); } FlexfecReceiveStreamImpl::~FlexfecReceiveStreamImpl() { @@ -192,10 +180,10 @@ int FlexfecReceiveStreamImpl::payload_type() const { void FlexfecReceiveStreamImpl::SetLocalSsrc(uint32_t local_ssrc) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - if (local_ssrc == rtp_rtcp_->local_media_ssrc()) + if (local_ssrc == rtp_rtcp_.local_media_ssrc()) return; - rtp_rtcp_->SetLocalSsrc(local_ssrc); + rtp_rtcp_.SetLocalSsrc(local_ssrc); } } // namespace webrtc diff --git a/call/flexfec_receive_stream_impl.h b/call/flexfec_receive_stream_impl.h index 5ce2cb6f0e..623560382c 100644 --- a/call/flexfec_receive_stream_impl.h +++ b/call/flexfec_receive_stream_impl.h @@ -14,11 +14,11 @@ #include #include +#include "api/environment/environment.h" #include "call/flexfec_receive_stream.h" #include "call/rtp_packet_sink_interface.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "rtc_base/system/no_unique_address.h" -#include "system_wrappers/include/clock.h" namespace webrtc { @@ -27,13 +27,12 @@ class ReceiveStatistics; class RecoveredPacketReceiver; class RtcpRttStats; class RtpPacketReceived; -class RtpRtcp; class RtpStreamReceiverControllerInterface; class RtpStreamReceiverInterface; class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { public: - FlexfecReceiveStreamImpl(Clock* clock, + FlexfecReceiveStreamImpl(const Environment& env, Config config, RecoveredPacketReceiver* recovered_packet_receiver, RtcpRttStats* rtt_stats); @@ -67,7 +66,7 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { void SetRtcpMode(RtcpMode mode) override { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - rtp_rtcp_->SetRTCPStatus(mode); + rtp_rtcp_.SetRTCPStatus(mode); } const ReceiveStatistics* GetStats() const override { @@ -88,7 +87,7 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { // RTCP reporting. const std::unique_ptr rtp_receive_statistics_; - const std::unique_ptr rtp_rtcp_; + ModuleRtpRtcpImpl2 rtp_rtcp_; std::unique_ptr rtp_stream_receiver_ RTC_GUARDED_BY(packet_sequence_checker_); diff --git a/call/flexfec_receive_stream_unittest.cc b/call/flexfec_receive_stream_unittest.cc index c575a3f41d..b591d5cb9b 100644 --- a/call/flexfec_receive_stream_unittest.cc +++ b/call/flexfec_receive_stream_unittest.cc @@ -16,6 +16,7 @@ #include "api/array_view.h" #include "api/call/transport.h" +#include "api/environment/environment_factory.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" #include "call/flexfec_receive_stream_impl.h" @@ -88,8 +89,7 @@ class FlexfecReceiveStreamTest : public ::testing::Test { FlexfecReceiveStreamTest() : config_(CreateDefaultConfig(&rtcp_send_transport_)) { receive_stream_ = std::make_unique( - Clock::GetRealTimeClock(), config_, &recovered_packet_receiver_, - &rtt_stats_); + CreateEnvironment(), config_, &recovered_packet_receiver_, &rtt_stats_); receive_stream_->RegisterWithTransport(&rtp_stream_receiver_controller_); }