diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 679666e3e1..b3d771a6ac 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -489,7 +489,7 @@ ChannelReceive::ChannelReceive( configuration.event_log = event_log_; - _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); + _rtpRtcpModule = RtpRtcp::Create(configuration); _rtpRtcpModule->SetSendingMediaStatus(false); _rtpRtcpModule->SetRemoteSSRC(remote_ssrc_); diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 8269fd545c..705827dec0 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -700,7 +700,7 @@ ChannelSend::ChannelSend(Clock* clock, configuration.extmap_allow_mixed = extmap_allow_mixed; configuration.rtcp_report_interval_ms = rtcp_report_interval_ms; - _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); + _rtpRtcpModule = RtpRtcp::Create(configuration); _rtpRtcpModule->SetSendingMediaStatus(false); // We want to invoke the 'TargetRateObserver' and |OnOverheadChanged| diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc index 645df784ce..fedb64d299 100644 --- a/call/flexfec_receive_stream_impl.cc +++ b/call/flexfec_receive_stream_impl.cc @@ -130,8 +130,7 @@ std::unique_ptr CreateRtpRtcpModule( configuration.receive_statistics = receive_statistics; configuration.outgoing_transport = rtcp_send_transport; configuration.rtt_stats = rtt_stats; - std::unique_ptr rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration)); - return rtp_rtcp; + return RtpRtcp::Create(configuration); } } // namespace diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index e5098dba21..9dc3003f18 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -119,7 +119,7 @@ std::vector CreateRtpStreamSenders( auto playout_delay_oracle = absl::make_unique(); configuration.ack_observer = playout_delay_oracle.get(); - auto rtp_rtcp = absl::WrapUnique(RtpRtcp::CreateRtpRtcp(configuration)); + auto rtp_rtcp = RtpRtcp::Create(configuration); rtp_rtcp->SetSendingStatus(false); rtp_rtcp->SetSendingMediaStatus(false); rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); diff --git a/modules/rtp_rtcp/include/rtp_rtcp.h b/modules/rtp_rtcp/include/rtp_rtcp.h index 6e1b4a5e62..8e1f98bbb4 100644 --- a/modules/rtp_rtcp/include/rtp_rtcp.h +++ b/modules/rtp_rtcp/include/rtp_rtcp.h @@ -11,6 +11,7 @@ #ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ #define MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ +#include #include #include #include @@ -119,8 +120,10 @@ class RtpRtcp : public Module, public RtcpFeedbackSenderInterface { RTC_DISALLOW_COPY_AND_ASSIGN(Configuration); }; - // Create a RTP/RTCP module object using the system clock. - // |configuration| - Configuration of the RTP/RTCP module. + // Creates an RTP/RTCP module object using provided |configuration|. + static std::unique_ptr Create(const Configuration& configuration); + // Prefer factory function just above. + RTC_DEPRECATED static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration); // ************************************************************************** diff --git a/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/modules/rtp_rtcp/source/nack_rtx_unittest.cc index 864befe979..b47ef85cfc 100644 --- a/modules/rtp_rtcp/source/nack_rtx_unittest.cc +++ b/modules/rtp_rtcp/source/nack_rtx_unittest.cc @@ -136,7 +136,7 @@ class RtpRtcpRtxNackTest : public ::testing::Test { configuration.receive_statistics = receive_statistics_.get(); configuration.outgoing_transport = &transport_; configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; - rtp_rtcp_module_ = absl::WrapUnique(RtpRtcp::CreateRtpRtcp(configuration)); + rtp_rtcp_module_ = RtpRtcp::Create(configuration); rtp_sender_video_ = absl::make_unique( &fake_clock, rtp_rtcp_module_->RtpSender(), nullptr, &playout_delay_oracle_, nullptr, false, FieldTrialBasedConfig()); diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 2adddff0bf..4e0600222d 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -41,6 +41,11 @@ constexpr int32_t kDefaultAudioReportInterval = 5000; RtpRtcp::Configuration::Configuration() = default; +std::unique_ptr RtpRtcp::Create(const Configuration& configuration) { + RTC_DCHECK(configuration.clock); + return absl::make_unique(configuration); +} + RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) { if (configuration.clock) { return new ModuleRtpRtcpImpl(configuration); diff --git a/video/end_to_end_tests/bandwidth_tests.cc b/video/end_to_end_tests/bandwidth_tests.cc index e7550a46af..3ee0e2b7ac 100644 --- a/video/end_to_end_tests/bandwidth_tests.cc +++ b/video/end_to_end_tests/bandwidth_tests.cc @@ -193,7 +193,7 @@ TEST_F(BandwidthEndToEndTest, RembWithSendSideBwe) { config.clock = clock_; config.outgoing_transport = receive_transport_; config.retransmission_rate_limiter = &retransmission_rate_limiter_; - rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); + rtp_rtcp_ = RtpRtcp::Create(config); rtp_rtcp_->SetRemoteSSRC((*receive_configs)[0].rtp.remote_ssrc); rtp_rtcp_->SetSSRC((*receive_configs)[0].rtp.local_ssrc); rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize); diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index 65ec75db8e..de8e2dcb46 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -76,7 +76,7 @@ std::unique_ptr CreateRtpRtcpModule( configuration.bandwidth_callback = nullptr; configuration.transport_feedback_callback = nullptr; - std::unique_ptr rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration)); + std::unique_ptr rtp_rtcp = RtpRtcp::Create(configuration); rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); return rtp_rtcp; diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 4aa68f7d59..a5f5c1ac3f 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -1619,9 +1619,10 @@ TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) { const std::vector& receive_streams) override { stream_ = send_stream; RtpRtcp::Configuration config; + config.clock = Clock::GetRealTimeClock(); config.outgoing_transport = feedback_transport_.get(); config.retransmission_rate_limiter = &retranmission_rate_limiter_; - rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); + rtp_rtcp_ = RtpRtcp::Create(config); rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize); }