[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 <brandtr@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37027}
This commit is contained in:
Tommi 2022-05-25 20:54:24 +02:00 committed by WebRTC LUCI CQ
parent 34fb92f09a
commit fc2c24ef44
2 changed files with 13 additions and 17 deletions

View File

@ -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&>(config_);
c.rtp.local_ssrc = local_ssrc;
rtp_rtcp_->SetLocalSsrc(local_ssrc);
}

View File

@ -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<FlexfecReceiver> receiver_;