Restrict access to BaseChannel::previous_demuxer_criteria_.

Make sure previous_demuxer_criteria_ is only accessed on the network
thread and add annotation.

Bug: webrtc:11993, webrtc:12230
Change-Id: I4700fe41c947a3b1cce9649642dcd38ed62f873d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244087
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35618}
This commit is contained in:
Tomas Gunnarsson 2022-01-03 21:30:26 +00:00 committed by WebRTC LUCI CQ
parent 94f0194d5a
commit ddfbf6cc19
2 changed files with 5 additions and 6 deletions

View File

@ -488,11 +488,6 @@ void BaseChannel::UpdateRtpHeaderExtensionMap(
}
bool BaseChannel::RegisterRtpDemuxerSink_w() {
// TODO(bugs.webrtc.org/11993): `previous_demuxer_criteria_` should only be
// accessed on the network thread.
if (demuxer_criteria_ == previous_demuxer_criteria_) {
return true;
}
media_channel_->OnDemuxerCriteriaUpdatePending();
// Copy demuxer criteria, since they're a worker-thread variable
// and we want to pass them to the network thread
@ -500,6 +495,9 @@ bool BaseChannel::RegisterRtpDemuxerSink_w() {
RTC_FROM_HERE, [this, demuxer_criteria = demuxer_criteria_] {
RTC_DCHECK_RUN_ON(network_thread());
RTC_DCHECK(rtp_transport_);
if (demuxer_criteria_ == previous_demuxer_criteria_)
return true;
bool result =
rtp_transport_->RegisterRtpDemuxerSink(demuxer_criteria, this);
if (result) {

View File

@ -357,7 +357,8 @@ class BaseChannel : public ChannelInterface,
webrtc::RtpDemuxerCriteria demuxer_criteria_;
// Accessed on the worker thread, modified on the network thread from
// RegisterRtpDemuxerSink_w's Invoke.
webrtc::RtpDemuxerCriteria previous_demuxer_criteria_;
webrtc::RtpDemuxerCriteria previous_demuxer_criteria_
RTC_GUARDED_BY(network_thread());
// This generator is used to generate SSRCs for local streams.
// This is needed in cases where SSRCs are not negotiated or set explicitly
// like in Simulcast.