Audio: Apply ABWENoTWCC trial to ReconfigureBitrateObserver The Start() path short-circuits the BitrateAllocator registration gate on `allocate_audio_without_feedback_`, but ReconfigureBitrateObserver() does not. As a result, a Reconfigure() with an SDP that does not negotiate transport-cc for audio unregisters the stream from the BitrateAllocator, defeating the field trial. Mirror the Start() condition so the trial behaves consistently across the stream lifecycle. Bug: None Change-Id: I047bbf19827f907dd45c8fb3aefe61edab191b91 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/478860 Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47910}
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index e9e72b4..11b62eb 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc
@@ -787,7 +787,8 @@ if (!new_config.has_dscp && new_config.min_bitrate_bps != -1 && new_config.max_bitrate_bps != -1 && - new_config.include_in_congestion_control_allocation) { + (allocate_audio_without_feedback_ || + new_config.include_in_congestion_control_allocation)) { rtp_transport_->AccountForAudioPacketsInPacedSender(true); rtp_transport_->IncludeOverheadInPacedSender(); // We may get a callback immediately as the observer is registered, so
diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 7857882..60f10ca 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc
@@ -1074,5 +1074,41 @@ send_stream->Stop(); } +// Verifies that ReconfigureBitrateObserver() preserves the +// BitrateAllocator registration when the WebRTC-Audio-ABWENoTWCC field trial +// is enabled and TWCC is not negotiated for audio (i.e. +// `include_in_congestion_control_allocation` is false). The Start() path +// already short-circuits on `allocate_audio_without_feedback_`; this test +// ensures the Reconfigure() path applies the same short-circuit. +TEST(AudioSendStreamTest, AbweNoTwccTrialKeepsBaRegistrationOnReconfigure) { + ConfigHelper helper(/*audio_bwe_enabled=*/false, + /*expect_set_encoder_call=*/true, + /*use_null_audio_processing=*/true); + helper.field_trials().Set("WebRTC-Audio-ABWENoTWCC", "Enabled"); + auto send_stream = helper.CreateAudioSendStream(); + + // Start() registers the stream with the BitrateAllocator. + EXPECT_CALL(*helper.bitrate_allocator(), AddObserver(send_stream.get(), _)) + .Times(1); + EXPECT_CALL(*helper.channel_send(), StartSend()); + send_stream->Start(); + + // Reconfigure with a different bitrate range. The observer should be + // re-added (update path) and must not be removed. + auto new_config = helper.config(); + new_config.min_bitrate_bps = 12000; + new_config.max_bitrate_bps = 80000; + EXPECT_CALL(*helper.bitrate_allocator(), AddObserver(send_stream.get(), _)) + .Times(1); + EXPECT_CALL(*helper.bitrate_allocator(), RemoveObserver(send_stream.get())) + .Times(0); + send_stream->Reconfigure(new_config, nullptr); + + EXPECT_CALL(*helper.bitrate_allocator(), RemoveObserver(send_stream.get())) + .Times(1); + EXPECT_CALL(*helper.channel_send(), StopSend()); + send_stream->Stop(); +} + } // namespace test } // namespace webrtc