From fc2c24ef4406484a2e6bec4d7aa44a2c78e6cdd0 Mon Sep 17 00:00:00 2001 From: Tommi Date: Wed, 25 May 2022 20:54:24 +0200 Subject: [PATCH] [FlexfecReceiveStream] Use explicit member variables for state. This changes FlexfecReceiveStreamImpl so that instead of holding on to the entire config structure, the state is broken down into member variables whose constness and thread access can be individually set. Bug: none Change-Id: I497b5816d40678774dee76d8a97012e8539629b8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/263723 Reviewed-by: Rasmus Brandt Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#37027} --- call/flexfec_receive_stream_impl.cc | 20 +++++++++----------- call/flexfec_receive_stream_impl.h | 10 ++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc index 90bb3f3189..b962f670ae 100644 --- a/call/flexfec_receive_stream_impl.cc +++ b/call/flexfec_receive_stream_impl.cc @@ -133,25 +133,25 @@ FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl( RecoveredPacketReceiver* recovered_packet_receiver, RtcpRttStats* rtt_stats) : extension_map_(std::move(config.rtp.extensions)), - config_(std::move(config)), - receiver_(MaybeCreateFlexfecReceiver(clock, - config_, - recovered_packet_receiver)), + remote_ssrc_(config.rtp.remote_ssrc), + transport_cc_(config.rtp.transport_cc), + receiver_( + MaybeCreateFlexfecReceiver(clock, config, recovered_packet_receiver)), rtp_receive_statistics_(ReceiveStatistics::Create(clock)), rtp_rtcp_(CreateRtpRtcpModule(clock, rtp_receive_statistics_.get(), - config_, + config, rtt_stats)) { - RTC_LOG(LS_INFO) << "FlexfecReceiveStreamImpl: " << config_.ToString(); + RTC_LOG(LS_INFO) << "FlexfecReceiveStreamImpl: " << config.ToString(); packet_sequence_checker_.Detach(); // RTCP reporting. - rtp_rtcp_->SetRTCPStatus(config_.rtcp_mode); + rtp_rtcp_->SetRTCPStatus(config.rtcp_mode); } FlexfecReceiveStreamImpl::~FlexfecReceiveStreamImpl() { - RTC_LOG(LS_INFO) << "~FlexfecReceiveStreamImpl: " << config_.ToString(); + RTC_DLOG(LS_INFO) << "~FlexfecReceiveStreamImpl: ssrc: " << remote_ssrc_; } void FlexfecReceiveStreamImpl::RegisterWithTransport( @@ -201,11 +201,9 @@ RtpHeaderExtensionMap FlexfecReceiveStreamImpl::GetRtpExtensionMap() const { void FlexfecReceiveStreamImpl::SetLocalSsrc(uint32_t local_ssrc) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - if (local_ssrc == config_.rtp.local_ssrc) + if (local_ssrc == rtp_rtcp_->local_media_ssrc()) return; - auto& c = const_cast(config_); - c.rtp.local_ssrc = local_ssrc; rtp_rtcp_->SetLocalSsrc(local_ssrc); } diff --git a/call/flexfec_receive_stream_impl.h b/call/flexfec_receive_stream_impl.h index 5bfe5cae40..fe8675468f 100644 --- a/call/flexfec_receive_stream_impl.h +++ b/call/flexfec_receive_stream_impl.h @@ -63,10 +63,10 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { // sender has been created, changed or removed. void SetLocalSsrc(uint32_t local_ssrc); - uint32_t remote_ssrc() const { return config_.rtp.remote_ssrc; } + uint32_t remote_ssrc() const { return remote_ssrc_; } bool transport_cc() const override { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - return config_.rtp.transport_cc; + return transport_cc_; } private: @@ -74,10 +74,8 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { RtpHeaderExtensionMap extension_map_; - // Config. Mostly const, local_ssrc may change, which is an exception - // case that's specifically handled in `SetLocalSsrc`, which must be - // called on the `packet_sequence_checker` thread. - const Config config_; + const uint32_t remote_ssrc_; + bool transport_cc_ RTC_GUARDED_BY(packet_sequence_checker_); // Erasure code interfacing. const std::unique_ptr receiver_;