Remove config() getter from AudioReceiveStream().
This reduces the surface of externally accessible state that belongs to the class, which makes it easier to control what state belongs to what thread. In this CL enforcing remote_ssrc() to be conceptually const and sync_group to conceptually belong to the packet delivery thread. Bug: webrtc:11993 Change-Id: I7de9366dc0c2bf451b5c58595c2d073b4016f2e7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261450 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36813}
This commit is contained in:
@ -146,7 +146,7 @@ AudioReceiveStream::AudioReceiveStream(
|
|||||||
|
|
||||||
AudioReceiveStream::~AudioReceiveStream() {
|
AudioReceiveStream::~AudioReceiveStream() {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << config_.rtp.remote_ssrc;
|
RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << remote_ssrc();
|
||||||
Stop();
|
Stop();
|
||||||
channel_receive_->SetAssociatedSendChannel(nullptr);
|
channel_receive_->SetAssociatedSendChannel(nullptr);
|
||||||
channel_receive_->ResetReceiverCongestionControlObjects();
|
channel_receive_->ResetReceiverCongestionControlObjects();
|
||||||
@ -157,7 +157,7 @@ void AudioReceiveStream::RegisterWithTransport(
|
|||||||
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
|
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
|
||||||
RTC_DCHECK(!rtp_stream_receiver_);
|
RTC_DCHECK(!rtp_stream_receiver_);
|
||||||
rtp_stream_receiver_ = receiver_controller->CreateReceiver(
|
rtp_stream_receiver_ = receiver_controller->CreateReceiver(
|
||||||
config_.rtp.remote_ssrc, channel_receive_.get());
|
remote_ssrc(), channel_receive_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioReceiveStream::UnregisterFromTransport() {
|
void AudioReceiveStream::UnregisterFromTransport() {
|
||||||
@ -170,8 +170,8 @@ void AudioReceiveStream::ReconfigureForTesting(
|
|||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
|
|
||||||
// SSRC can't be changed mid-stream.
|
// SSRC can't be changed mid-stream.
|
||||||
RTC_DCHECK_EQ(config_.rtp.remote_ssrc, config.rtp.remote_ssrc);
|
RTC_DCHECK_EQ(remote_ssrc(), config.rtp.remote_ssrc);
|
||||||
RTC_DCHECK_EQ(config_.rtp.local_ssrc, config.rtp.local_ssrc);
|
RTC_DCHECK_EQ(local_ssrc(), config.rtp.local_ssrc);
|
||||||
|
|
||||||
// Configuration parameters which cannot be changed.
|
// Configuration parameters which cannot be changed.
|
||||||
RTC_DCHECK_EQ(config_.rtcp_send_transport, config.rtcp_send_transport);
|
RTC_DCHECK_EQ(config_.rtcp_send_transport, config.rtcp_send_transport);
|
||||||
@ -269,7 +269,7 @@ webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats(
|
|||||||
bool get_and_clear_legacy_stats) const {
|
bool get_and_clear_legacy_stats) const {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
webrtc::AudioReceiveStream::Stats stats;
|
webrtc::AudioReceiveStream::Stats stats;
|
||||||
stats.remote_ssrc = config_.rtp.remote_ssrc;
|
stats.remote_ssrc = remote_ssrc();
|
||||||
|
|
||||||
webrtc::CallReceiveStatistics call_stats =
|
webrtc::CallReceiveStatistics call_stats =
|
||||||
channel_receive_->GetRTCPStatistics();
|
channel_receive_->GetRTCPStatistics();
|
||||||
@ -398,7 +398,7 @@ AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AudioReceiveStream::Ssrc() const {
|
int AudioReceiveStream::Ssrc() const {
|
||||||
return config_.rtp.remote_ssrc;
|
return remote_ssrc();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioReceiveStream::PreferredSampleRate() const {
|
int AudioReceiveStream::PreferredSampleRate() const {
|
||||||
@ -407,7 +407,7 @@ int AudioReceiveStream::PreferredSampleRate() const {
|
|||||||
|
|
||||||
uint32_t AudioReceiveStream::id() const {
|
uint32_t AudioReceiveStream::id() const {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
return config_.rtp.remote_ssrc;
|
return remote_ssrc();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::optional<Syncable::Info> AudioReceiveStream::GetInfo() const {
|
absl::optional<Syncable::Info> AudioReceiveStream::GetInfo() const {
|
||||||
@ -471,9 +471,9 @@ uint32_t AudioReceiveStream::local_ssrc() const {
|
|||||||
return config_.rtp.local_ssrc;
|
return config_.rtp.local_ssrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
|
const std::string& AudioReceiveStream::sync_group() const {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
|
||||||
return config_;
|
return config_.sync_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AudioSendStream* AudioReceiveStream::GetAssociatedSendStreamForTesting()
|
const AudioSendStream* AudioReceiveStream::GetAssociatedSendStreamForTesting()
|
||||||
|
@ -134,7 +134,10 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream,
|
|||||||
return config_.rtp.remote_ssrc;
|
return config_.rtp.remote_ssrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const webrtc::AudioReceiveStream::Config& config() const;
|
// Returns a reference to the currently set sync group of the stream.
|
||||||
|
// Must be called on the packet delivery thread.
|
||||||
|
const std::string& sync_group() const;
|
||||||
|
|
||||||
const AudioSendStream* GetAssociatedSendStreamForTesting() const;
|
const AudioSendStream* GetAssociatedSendStreamForTesting() const;
|
||||||
|
|
||||||
// TODO(tommi): Remove this method.
|
// TODO(tommi): Remove this method.
|
||||||
|
@ -131,6 +131,8 @@ struct ConfigHelper {
|
|||||||
EXPECT_THAT(codecs, ::testing::IsEmpty());
|
EXPECT_THAT(codecs, ::testing::IsEmpty());
|
||||||
}));
|
}));
|
||||||
EXPECT_CALL(*channel_receive_, SetSourceTracker(_));
|
EXPECT_CALL(*channel_receive_, SetSourceTracker(_));
|
||||||
|
EXPECT_CALL(*channel_receive_, GetLocalSsrc())
|
||||||
|
.WillRepeatedly(Return(kLocalSsrc));
|
||||||
|
|
||||||
stream_config_.rtp.local_ssrc = kLocalSsrc;
|
stream_config_.rtp.local_ssrc = kLocalSsrc;
|
||||||
stream_config_.rtp.remote_ssrc = kRemoteSsrc;
|
stream_config_.rtp.remote_ssrc = kRemoteSsrc;
|
||||||
|
@ -1009,8 +1009,9 @@ void Call::DestroyAudioReceiveStream(
|
|||||||
audio_receive_stream->UnregisterFromTransport();
|
audio_receive_stream->UnregisterFromTransport();
|
||||||
|
|
||||||
uint32_t ssrc = audio_receive_stream->remote_ssrc();
|
uint32_t ssrc = audio_receive_stream->remote_ssrc();
|
||||||
const AudioReceiveStream::Config& config = audio_receive_stream->config();
|
receive_side_cc_
|
||||||
receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config.rtp))
|
.GetRemoteBitrateEstimator(
|
||||||
|
UseSendSideBwe(audio_receive_stream->rtp_config()))
|
||||||
->RemoveStream(ssrc);
|
->RemoveStream(ssrc);
|
||||||
|
|
||||||
audio_receive_streams_.erase(audio_receive_stream);
|
audio_receive_streams_.erase(audio_receive_stream);
|
||||||
@ -1018,7 +1019,7 @@ void Call::DestroyAudioReceiveStream(
|
|||||||
// After calling erase(), call ConfigureSync. This will clear associated
|
// After calling erase(), call ConfigureSync. This will clear associated
|
||||||
// video streams or associate them with a different audio stream if one exists
|
// video streams or associate them with a different audio stream if one exists
|
||||||
// for this sync_group.
|
// for this sync_group.
|
||||||
ConfigureSync(audio_receive_stream->config().sync_group);
|
ConfigureSync(audio_receive_stream->sync_group());
|
||||||
|
|
||||||
UnregisterReceiveStream(ssrc);
|
UnregisterReceiveStream(ssrc);
|
||||||
|
|
||||||
@ -1471,7 +1472,7 @@ AudioReceiveStream* Call::FindAudioStreamForSyncGroup(
|
|||||||
RTC_DCHECK_RUN_ON(&receive_11993_checker_);
|
RTC_DCHECK_RUN_ON(&receive_11993_checker_);
|
||||||
if (!sync_group.empty()) {
|
if (!sync_group.empty()) {
|
||||||
for (AudioReceiveStream* stream : audio_receive_streams_) {
|
for (AudioReceiveStream* stream : audio_receive_streams_) {
|
||||||
if (stream->config().sync_group == sync_group)
|
if (stream->sync_group() == sync_group)
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user