Modernize RtpRtcp factory function: use unique_ptr as return type

to clearly signal passed ownership.
Drop support for accepting nullptr clock to avoid copying the Configuration structure.
Update all calls in webrtc to the new factory function

Bug: None
Change-Id: Ic5a78da8e59ba3988a757a9d9634fa31499ce0db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125901
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26994}
This commit is contained in:
Danil Chapovalov 2019-03-06 11:31:09 +01:00 committed by Commit Bot
parent ede7cb2ec1
commit c44f6cc5fe
10 changed files with 19 additions and 11 deletions

View file

@ -489,7 +489,7 @@ ChannelReceive::ChannelReceive(
configuration.event_log = event_log_; configuration.event_log = event_log_;
_rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); _rtpRtcpModule = RtpRtcp::Create(configuration);
_rtpRtcpModule->SetSendingMediaStatus(false); _rtpRtcpModule->SetSendingMediaStatus(false);
_rtpRtcpModule->SetRemoteSSRC(remote_ssrc_); _rtpRtcpModule->SetRemoteSSRC(remote_ssrc_);

View file

@ -700,7 +700,7 @@ ChannelSend::ChannelSend(Clock* clock,
configuration.extmap_allow_mixed = extmap_allow_mixed; configuration.extmap_allow_mixed = extmap_allow_mixed;
configuration.rtcp_report_interval_ms = rtcp_report_interval_ms; configuration.rtcp_report_interval_ms = rtcp_report_interval_ms;
_rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); _rtpRtcpModule = RtpRtcp::Create(configuration);
_rtpRtcpModule->SetSendingMediaStatus(false); _rtpRtcpModule->SetSendingMediaStatus(false);
// We want to invoke the 'TargetRateObserver' and |OnOverheadChanged| // We want to invoke the 'TargetRateObserver' and |OnOverheadChanged|

View file

@ -130,8 +130,7 @@ std::unique_ptr<RtpRtcp> CreateRtpRtcpModule(
configuration.receive_statistics = receive_statistics; configuration.receive_statistics = receive_statistics;
configuration.outgoing_transport = rtcp_send_transport; configuration.outgoing_transport = rtcp_send_transport;
configuration.rtt_stats = rtt_stats; configuration.rtt_stats = rtt_stats;
std::unique_ptr<RtpRtcp> rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration)); return RtpRtcp::Create(configuration);
return rtp_rtcp;
} }
} // namespace } // namespace

View file

@ -119,7 +119,7 @@ std::vector<RtpStreamSender> CreateRtpStreamSenders(
auto playout_delay_oracle = absl::make_unique<PlayoutDelayOracle>(); auto playout_delay_oracle = absl::make_unique<PlayoutDelayOracle>();
configuration.ack_observer = playout_delay_oracle.get(); 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->SetSendingStatus(false);
rtp_rtcp->SetSendingMediaStatus(false); rtp_rtcp->SetSendingMediaStatus(false);
rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);

View file

@ -11,6 +11,7 @@
#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ #ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
#define MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ #define MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
#include <memory>
#include <set> #include <set>
#include <string> #include <string>
#include <utility> #include <utility>
@ -119,8 +120,10 @@ class RtpRtcp : public Module, public RtcpFeedbackSenderInterface {
RTC_DISALLOW_COPY_AND_ASSIGN(Configuration); RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
}; };
// Create a RTP/RTCP module object using the system clock. // Creates an RTP/RTCP module object using provided |configuration|.
// |configuration| - Configuration of the RTP/RTCP module. static std::unique_ptr<RtpRtcp> Create(const Configuration& configuration);
// Prefer factory function just above.
RTC_DEPRECATED
static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration); static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
// ************************************************************************** // **************************************************************************

View file

@ -136,7 +136,7 @@ class RtpRtcpRtxNackTest : public ::testing::Test {
configuration.receive_statistics = receive_statistics_.get(); configuration.receive_statistics = receive_statistics_.get();
configuration.outgoing_transport = &transport_; configuration.outgoing_transport = &transport_;
configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; 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<RTPSenderVideo>( rtp_sender_video_ = absl::make_unique<RTPSenderVideo>(
&fake_clock, rtp_rtcp_module_->RtpSender(), nullptr, &fake_clock, rtp_rtcp_module_->RtpSender(), nullptr,
&playout_delay_oracle_, nullptr, false, FieldTrialBasedConfig()); &playout_delay_oracle_, nullptr, false, FieldTrialBasedConfig());

View file

@ -41,6 +41,11 @@ constexpr int32_t kDefaultAudioReportInterval = 5000;
RtpRtcp::Configuration::Configuration() = default; RtpRtcp::Configuration::Configuration() = default;
std::unique_ptr<RtpRtcp> RtpRtcp::Create(const Configuration& configuration) {
RTC_DCHECK(configuration.clock);
return absl::make_unique<ModuleRtpRtcpImpl>(configuration);
}
RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) { RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) {
if (configuration.clock) { if (configuration.clock) {
return new ModuleRtpRtcpImpl(configuration); return new ModuleRtpRtcpImpl(configuration);

View file

@ -193,7 +193,7 @@ TEST_F(BandwidthEndToEndTest, RembWithSendSideBwe) {
config.clock = clock_; config.clock = clock_;
config.outgoing_transport = receive_transport_; config.outgoing_transport = receive_transport_;
config.retransmission_rate_limiter = &retransmission_rate_limiter_; 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_->SetRemoteSSRC((*receive_configs)[0].rtp.remote_ssrc);
rtp_rtcp_->SetSSRC((*receive_configs)[0].rtp.local_ssrc); rtp_rtcp_->SetSSRC((*receive_configs)[0].rtp.local_ssrc);
rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize); rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize);

View file

@ -76,7 +76,7 @@ std::unique_ptr<RtpRtcp> CreateRtpRtcpModule(
configuration.bandwidth_callback = nullptr; configuration.bandwidth_callback = nullptr;
configuration.transport_feedback_callback = nullptr; configuration.transport_feedback_callback = nullptr;
std::unique_ptr<RtpRtcp> rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration)); std::unique_ptr<RtpRtcp> rtp_rtcp = RtpRtcp::Create(configuration);
rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
return rtp_rtcp; return rtp_rtcp;

View file

@ -1619,9 +1619,10 @@ TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) {
const std::vector<VideoReceiveStream*>& receive_streams) override { const std::vector<VideoReceiveStream*>& receive_streams) override {
stream_ = send_stream; stream_ = send_stream;
RtpRtcp::Configuration config; RtpRtcp::Configuration config;
config.clock = Clock::GetRealTimeClock();
config.outgoing_transport = feedback_transport_.get(); config.outgoing_transport = feedback_transport_.get();
config.retransmission_rate_limiter = &retranmission_rate_limiter_; config.retransmission_rate_limiter = &retranmission_rate_limiter_;
rtp_rtcp_.reset(RtpRtcp::CreateRtpRtcp(config)); rtp_rtcp_ = RtpRtcp::Create(config);
rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize); rtp_rtcp_->SetRTCPStatus(RtcpMode::kReducedSize);
} }