diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index cc25ee4697..3ac7e36a97 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -475,8 +475,7 @@ uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) { 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 d89acd5753..5d4966c522 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -42,6 +42,7 @@ namespace { using testing::_; using testing::Eq; using testing::Ne; +using testing::Field; using testing::Invoke; using testing::Return; using testing::StrEq; @@ -472,7 +473,9 @@ TEST(AudioSendStreamTest, DoesNotPassHigherBitrateThanMaxBitrate) { 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, DoesNotPassHigherBitrateThanMaxBitrate) { 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 e8b7b32d0b..31fe25f6ea 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -111,7 +111,7 @@ class ChannelSend 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 @@ void ChannelSend::ModifyEncoder( 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 @@ void ChannelSend::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) { audio_coding_->ModifyEncoder([&](std::unique_ptr* 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 cbef3659ce..231fda674f 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -80,7 +80,7 @@ class ChannelSendInterface { 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 03c26c98b0..fe49359880 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -88,7 +88,7 @@ class MockChannelSend : public voe::ChannelSendInterface { 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));