Separate reading remote_ssrc from using the rtp_config() getter.
`remote_ssrc` can be considered const while some other state represented
by rtp_config() can not and also is tied to a specific thread.
Separating access to these variables, makes moving things around easier.
Bug: webrtc:11993
Change-Id: I70aa000daab6174a401e01dca163213174e8f284
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261316
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36818}
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index 17691f7..b18e076 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -194,6 +194,11 @@
// Returns current value of base minimum delay in milliseconds.
virtual int GetBaseMinimumPlayoutDelayMs() const = 0;
+ // Synchronization source (stream identifier) to be received.
+ // This member will not change mid-stream and can be assumed to be const
+ // post initialization.
+ virtual uint32_t remote_ssrc() const = 0;
+
protected:
virtual ~AudioReceiveStream() {}
};
diff --git a/call/call.cc b/call/call.cc
index 1a0357f..0703fd4 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -1245,16 +1245,17 @@
// TODO(bugs.webrtc.org/11993): Unregister on the network thread.
receive_stream_impl->UnregisterFromTransport();
- RTC_DCHECK(receive_stream != nullptr);
- const FlexfecReceiveStream::RtpConfig& rtp = receive_stream->rtp_config();
- UnregisterReceiveStream(rtp.remote_ssrc);
+ auto ssrc = receive_stream_impl->remote_ssrc();
+ UnregisterReceiveStream(ssrc);
// Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be
// destroyed.
- receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(rtp))
- ->RemoveStream(rtp.remote_ssrc);
+ receive_side_cc_
+ .GetRemoteBitrateEstimator(
+ UseSendSideBwe(receive_stream_impl->rtp_config()))
+ ->RemoveStream(ssrc);
- delete receive_stream;
+ delete receive_stream_impl;
}
void Call::AddAdaptationResource(rtc::scoped_refptr<Resource> resource) {
diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc
index a784481..6c8378d 100644
--- a/call/flexfec_receive_stream_impl.cc
+++ b/call/flexfec_receive_stream_impl.cc
@@ -204,7 +204,10 @@
void FlexfecReceiveStreamImpl::SetRtpExtensions(
std::vector<RtpExtension> extensions) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
- config_.rtp.extensions = std::move(extensions);
+ // TODO(tommi): Remove this cast once header extensions are managed outside
+ // of the config struct.
+ const_cast<std::vector<RtpExtension>&>(config_.rtp.extensions) =
+ std::move(extensions);
}
} // namespace webrtc
diff --git a/call/flexfec_receive_stream_impl.h b/call/flexfec_receive_stream_impl.h
index c2407cd..c640ac6 100644
--- a/call/flexfec_receive_stream_impl.h
+++ b/call/flexfec_receive_stream_impl.h
@@ -61,12 +61,15 @@
// ReceiveStream impl.
void SetRtpExtensions(std::vector<RtpExtension> extensions) override;
const RtpConfig& rtp_config() const override { return config_.rtp; }
+ uint32_t remote_ssrc() const { return config_.rtp.remote_ssrc; }
private:
RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
- // Config. Mostly const, header extensions may change.
- Config config_ RTC_GUARDED_BY(packet_sequence_checker_);
+ // Config. Mostly const, header extensions may change, which is an exception
+ // case that's specifically handled in `SetRtpExtensions`, which must be
+ // called on the `packet_sequence_checker` thread.
+ const Config config_;
// Erasure code interfacing.
const std::unique_ptr<FlexfecReceiver> receiver_;