From 359d60a5941ecae36d257f9e8d20d867f9b5bdb1 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Thu, 25 Oct 2018 16:22:02 +0200 Subject: [PATCH] Adds target rate to audio send stream stats. Bug: webrtc:9510 Change-Id: I8bd74fc115e3006f477b289edc58fa1f9d7b6bc6 Reviewed-on: https://webrtc-review.googlesource.com/c/107652 Commit-Queue: Sebastian Jansson Reviewed-by: Oskar Sundbom Cr-Commit-Position: refs/heads/master@{#25370} --- audio/audio_send_stream.cc | 1 + audio/audio_send_stream_unittest.cc | 1 + audio/channel_send.cc | 5 +++++ audio/channel_send.h | 2 ++ audio/channel_send_proxy.cc | 4 ++++ audio/channel_send_proxy.h | 1 + audio/mock_voe_channel_proxy.h | 1 + call/audio_send_stream.h | 2 ++ test/scenario/audio_stream.cc | 10 ++++++++++ test/scenario/audio_stream.h | 1 + 10 files changed, 28 insertions(+) diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index c8af43ea4e..3c9daffee8 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -367,6 +367,7 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats( RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); webrtc::AudioSendStream::Stats stats; stats.local_ssrc = config_.rtp.ssrc; + stats.target_bitrate_bps = channel_proxy_->GetBitrate(); webrtc::CallSendStatistics call_stats = channel_proxy_->GetRTCPStatistics(); stats.bytes_sent = call_stats.bytesSent; diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 30d2c54f95..c5e4060c92 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -278,6 +278,7 @@ struct ConfigHelper { .WillRepeatedly(Return(report_blocks)); EXPECT_CALL(*channel_proxy_, GetANAStatistics()) .WillRepeatedly(Return(ANAStats())); + EXPECT_CALL(*channel_proxy_, GetBitrate()).WillRepeatedly(Return(0)); audio_processing_stats_.echo_return_loss = kEchoReturnLoss; audio_processing_stats_.echo_return_loss_enhancement = diff --git a/audio/channel_send.cc b/audio/channel_send.cc index bdabe8f2b5..83350c4a4b 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -572,6 +572,11 @@ void ChannelSend::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) { } }); retransmission_rate_limiter_->SetMaxRate(bitrate_bps); + configured_bitrate_bps_ = bitrate_bps; +} + +int ChannelSend::GetBitRate() const { + return configured_bitrate_bps_; } void ChannelSend::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) { diff --git a/audio/channel_send.h b/audio/channel_send.h index 306d6a8b3e..7c3f1cd31f 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -139,6 +139,7 @@ class ChannelSend // Codecs void SetBitRate(int bitrate_bps, int64_t probing_interval_ms); + int GetBitRate() const; bool EnableAudioNetworkAdaptor(const std::string& config_string); void DisableAudioNetworkAdaptor(); @@ -302,6 +303,7 @@ class ChannelSend FrameEncryptorInterface* frame_encryptor_ = nullptr; // E2EE Frame Encryption Options webrtc::CryptoOptions crypto_options_; + int configured_bitrate_bps_ = 0; }; } // namespace voe diff --git a/audio/channel_send_proxy.cc b/audio/channel_send_proxy.cc index 661e1e4f71..097ee9e1b4 100644 --- a/audio/channel_send_proxy.cc +++ b/audio/channel_send_proxy.cc @@ -147,6 +147,10 @@ void ChannelSendProxy::SetBitrate(int bitrate_bps, channel_->SetBitRate(bitrate_bps, probing_interval_ms); } +int ChannelSendProxy::GetBitrate() const { + return channel_->GetBitRate(); +} + void ChannelSendProxy::SetInputMute(bool muted) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel_->SetInputMute(muted); diff --git a/audio/channel_send_proxy.h b/audio/channel_send_proxy.h index 1b8b4a02ce..55cf3e2588 100644 --- a/audio/channel_send_proxy.h +++ b/audio/channel_send_proxy.h @@ -70,6 +70,7 @@ class ChannelSendProxy { int payload_frequency); virtual bool SendTelephoneEventOutband(int event, int duration_ms); virtual void SetBitrate(int bitrate_bps, int64_t probing_interval_ms); + virtual int GetBitrate() const; virtual void SetInputMute(bool muted); virtual void ProcessAndEncodeAudio(std::unique_ptr audio_frame); diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index 910858fe13..50b202e542 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -99,6 +99,7 @@ class MockChannelSendProxy : public voe::ChannelSendProxy { void(std::unique_ptr* audio_frame)); MOCK_METHOD1(SetTransportOverhead, void(int transport_overhead_per_packet)); MOCK_CONST_METHOD0(GetRtpRtcp, RtpRtcp*()); + MOCK_CONST_METHOD0(GetBitrate, int()); MOCK_METHOD1(OnTwccBasedUplinkPacketLossRate, void(float packet_loss_rate)); MOCK_METHOD1(OnRecoverableUplinkPacketLossRate, void(float recoverable_packet_loss_rate)); diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index 61d2f5c48d..fb431e0cd8 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -58,6 +58,8 @@ class AudioSendStream { ANAStats ana_statistics; AudioProcessingStats apm_statistics; + + int64_t target_bitrate_bps = 0; }; struct Config { diff --git a/test/scenario/audio_stream.cc b/test/scenario/audio_stream.cc index 8871728988..132998b579 100644 --- a/test/scenario/audio_stream.cc +++ b/test/scenario/audio_stream.cc @@ -149,6 +149,16 @@ void SendAudioStream::Start() { send_stream_->Start(); } +ColumnPrinter SendAudioStream::StatsPrinter() { + return ColumnPrinter::Lambda( + "audio_target_rate", + [this](rtc::SimpleStringBuilder& sb) { + AudioSendStream::Stats stats = send_stream_->GetStats(); + sb.AppendFormat("%.0lf", stats.target_bitrate_bps / 8.0); + }, + 64); +} + ReceiveAudioStream::ReceiveAudioStream( CallClient* receiver, AudioStreamConfig config, diff --git a/test/scenario/audio_stream.h b/test/scenario/audio_stream.h index 06a91dbd2e..601a375a26 100644 --- a/test/scenario/audio_stream.h +++ b/test/scenario/audio_stream.h @@ -29,6 +29,7 @@ class SendAudioStream { RTC_DISALLOW_COPY_AND_ASSIGN(SendAudioStream); ~SendAudioStream(); void Start(); + ColumnPrinter StatsPrinter(); private: friend class Scenario;