Routing BitrateAllocationUpdate to audio codec.
This will be used in a later CL to use the link capacity field in the
update to control the Opus encoder.
Bug: webrtc:9718
Change-Id: If2ad16a8f4656e8cdf10c33f5fb060ef7ca5caba
Reviewed-on: https://webrtc-review.googlesource.com/c/111510
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25761}
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc
index cc25ee4..3ac7e36 100644
--- a/audio/audio_send_stream.cc
+++ b/audio/audio_send_stream.cc
@@ -475,8 +475,7 @@
if (update.target_bitrate > max_bitrate)
update.target_bitrate = max_bitrate;
- channel_send_->SetBitrate(update.target_bitrate.bps(),
- update.bwe_period.ms());
+ channel_send_->OnBitrateAllocation(update);
// The amount of audio protection is not exposed by the encoder, hence
// always returning 0.
diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc
index d89acd5..5d4966c 100644
--- a/audio/audio_send_stream_unittest.cc
+++ b/audio/audio_send_stream_unittest.cc
@@ -42,6 +42,7 @@
using testing::_;
using testing::Eq;
using testing::Ne;
+using testing::Field;
using testing::Invoke;
using testing::Return;
using testing::StrEq;
@@ -472,7 +473,9 @@
ConfigHelper helper(false, true);
auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(),
- SetBitrate(helper.config().max_bitrate_bps, _));
+ OnBitrateAllocation(
+ Field(&BitrateAllocationUpdate::target_bitrate,
+ Eq(DataRate::bps(helper.config().max_bitrate_bps)))));
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(helper.config().max_bitrate_bps + 5000);
update.packet_loss_ratio = 0;
@@ -484,7 +487,10 @@
TEST(AudioSendStreamTest, ProbingIntervalOnBitrateUpdated) {
ConfigHelper helper(false, true);
auto send_stream = helper.CreateAudioSendStream();
- EXPECT_CALL(*helper.channel_send(), SetBitrate(_, 5000));
+
+ EXPECT_CALL(*helper.channel_send(),
+ OnBitrateAllocation(Field(&BitrateAllocationUpdate::bwe_period,
+ Eq(TimeDelta::ms(5000)))));
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(helper.config().max_bitrate_bps + 5000);
update.packet_loss_ratio = 0;
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index e8b7b32..31fe25f 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -111,7 +111,7 @@
void StopSend() override;
// Codecs
- void SetBitrate(int bitrate_bps, int64_t probing_interval_ms) override;
+ void OnBitrateAllocation(BitrateAllocationUpdate update) override;
int GetBitrate() const override;
// Network
@@ -898,7 +898,7 @@
audio_coding_->ModifyEncoder(modifier);
}
-void ChannelSend::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) {
+void ChannelSend::OnBitrateAllocation(BitrateAllocationUpdate update) {
// This method can be called on the worker thread, module process thread
// or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged.
// TODO(solenberg): Figure out a good way to check this or enforce calling
@@ -909,11 +909,11 @@
audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
if (*encoder) {
- (*encoder)->OnReceivedUplinkBandwidth(bitrate_bps, probing_interval_ms);
+ (*encoder)->OnReceivedUplinkAllocation(update);
}
});
- retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
- configured_bitrate_bps_ = bitrate_bps;
+ retransmission_rate_limiter_->SetMaxRate(update.target_bitrate.bps());
+ configured_bitrate_bps_ = update.target_bitrate.bps();
}
int ChannelSend::GetBitrate() const {
diff --git a/audio/channel_send.h b/audio/channel_send.h
index cbef365..231fda6 100644
--- a/audio/channel_send.h
+++ b/audio/channel_send.h
@@ -80,7 +80,7 @@
virtual bool SetSendTelephoneEventPayloadType(int payload_type,
int payload_frequency) = 0;
virtual bool SendTelephoneEventOutband(int event, int duration_ms) = 0;
- virtual void SetBitrate(int bitrate_bps, int64_t probing_interval_ms) = 0;
+ virtual void OnBitrateAllocation(BitrateAllocationUpdate update) = 0;
virtual int GetBitrate() const = 0;
virtual void SetInputMute(bool muted) = 0;
diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h
index 03c26c9..fe49359 100644
--- a/audio/mock_voe_channel_proxy.h
+++ b/audio/mock_voe_channel_proxy.h
@@ -88,7 +88,7 @@
MOCK_METHOD2(SetSendTelephoneEventPayloadType,
bool(int payload_type, int payload_frequency));
MOCK_METHOD2(SendTelephoneEventOutband, bool(int event, int duration_ms));
- MOCK_METHOD2(SetBitrate, void(int bitrate_bps, int64_t probing_interval_ms));
+ MOCK_METHOD1(OnBitrateAllocation, void(BitrateAllocationUpdate update));
MOCK_METHOD1(SetInputMute, void(bool muted));
MOCK_METHOD1(RegisterTransport, void(Transport* transport));
MOCK_METHOD2(ReceivedRTCPPacket, bool(const uint8_t* packet, size_t length));