diff --git a/webrtc/audio/DEPS b/webrtc/audio/DEPS index 66f66f4ee4..476d463e6a 100644 --- a/webrtc/audio/DEPS +++ b/webrtc/audio/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+webrtc/modules/audio_coding/codecs/mock", "+webrtc/call", "+webrtc/logging/rtc_event_log", + "+webrtc/modules/audio_processing/include", "+webrtc/modules/bitrate_controller", "+webrtc/modules/congestion_controller", "+webrtc/modules/pacing", diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc index 70bb6a9072..a96eaf83f8 100644 --- a/webrtc/audio/audio_send_stream.cc +++ b/webrtc/audio/audio_send_stream.cc @@ -197,34 +197,16 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { stats.audio_level = static_cast(level); } - bool echo_metrics_on = false; - int error = processing->GetEcMetricsStatus(echo_metrics_on); - RTC_DCHECK_EQ(0, error); - if (echo_metrics_on) { - // These can also be negative, but in practice -1 is only used to signal - // insufficient data, since the resolution is limited to multiples of 4 ms. - int median = -1; - int std = -1; - float dummy = 0.0f; - error = processing->GetEcDelayMetrics(median, std, dummy); - RTC_DCHECK_EQ(0, error); - stats.echo_delay_median_ms = median; - stats.echo_delay_std_ms = std; - - // These can take on valid negative values, so use the lowest possible level - // as default rather than -1. - int erl = -100; - int erle = -100; - int dummy1 = 0; - int dummy2 = 0; - error = processing->GetEchoMetrics(erl, erle, dummy1, dummy2); - RTC_DCHECK_EQ(0, error); - stats.echo_return_loss = erl; - stats.echo_return_loss_enhancement = erle; - } - - // TODO(ivoc): Hook this up to the residual echo detector. - stats.residual_echo_likelihood = 0.0f; + ScopedVoEInterface base(voice_engine()); + RTC_DCHECK(base->audio_processing()); + auto audio_processing_stats = base->audio_processing()->GetStatistics(); + stats.echo_delay_median_ms = audio_processing_stats.delay_median; + stats.echo_delay_std_ms = audio_processing_stats.delay_standard_deviation; + stats.echo_return_loss = audio_processing_stats.echo_return_loss.instant(); + stats.echo_return_loss_enhancement = + audio_processing_stats.echo_return_loss_enhancement.instant(); + stats.residual_echo_likelihood = + audio_processing_stats.residual_echo_likelihood; internal::AudioState* audio_state = static_cast(audio_state_.get()); diff --git a/webrtc/audio/audio_send_stream_unittest.cc b/webrtc/audio/audio_send_stream_unittest.cc index fc7bbb0b80..2cb1275021 100644 --- a/webrtc/audio/audio_send_stream_unittest.cc +++ b/webrtc/audio/audio_send_stream_unittest.cc @@ -16,6 +16,7 @@ #include "webrtc/audio/conversion.h" #include "webrtc/base/task_queue.h" #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" +#include "webrtc/modules/audio_processing/include/mock_audio_processing.h" #include "webrtc/modules/congestion_controller/include/congestion_controller.h" #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h" #include "webrtc/modules/pacing/paced_sender.h" @@ -40,7 +41,7 @@ const int kEchoDelayMedian = 254; const int kEchoDelayStdDev = -3; const int kEchoReturnLoss = -65; const int kEchoReturnLossEnhancement = 101; -const float kResidualEchoLikelihood = 0.0f; +const float kResidualEchoLikelihood = -1.0f; const unsigned int kSpeechInputLevel = 96; const CallStatistics kCallStats = { 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; @@ -182,15 +183,21 @@ struct ConfigHelper { .WillRepeatedly(DoAll(SetArgReferee<1>(kIsacCodec), Return(0))); EXPECT_CALL(voice_engine_, GetSpeechInputLevelFullRange(_)) .WillRepeatedly(DoAll(SetArgReferee<0>(kSpeechInputLevel), Return(0))); - EXPECT_CALL(voice_engine_, GetEcMetricsStatus(_)) - .WillRepeatedly(DoAll(SetArgReferee<0>(true), Return(0))); - EXPECT_CALL(voice_engine_, GetEchoMetrics(_, _, _, _)) - .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoReturnLoss), - SetArgReferee<1>(kEchoReturnLossEnhancement), - Return(0))); - EXPECT_CALL(voice_engine_, GetEcDelayMetrics(_, _, _)) - .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoDelayMedian), - SetArgReferee<1>(kEchoDelayStdDev), Return(0))); + EXPECT_CALL(voice_engine_, audio_processing()) + .WillRepeatedly(Return(&audio_processing_)); + + // We have to set the instantaneous value, the average, min and max. We only + // care about the instantaneous value, so we set all to the same value. + audio_processing_stats_.echo_return_loss.Set( + kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); + audio_processing_stats_.echo_return_loss_enhancement.Set( + kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, + kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); + audio_processing_stats_.delay_median = kEchoDelayMedian; + audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; + + EXPECT_CALL(audio_processing_, GetStatistics()) + .WillRepeatedly(Return(audio_processing_stats_)); } private: @@ -201,6 +208,8 @@ struct ConfigHelper { testing::StrictMock* channel_proxy_ = nullptr; testing::NiceMock bitrate_observer_; testing::NiceMock remote_bitrate_observer_; + MockAudioProcessing audio_processing_; + AudioProcessing::AudioProcessingStatistics audio_processing_stats_; CongestionController congestion_controller_; MockRtcEventLog event_log_; testing::NiceMock limit_observer_; diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h index 3225a4cdbb..c899e803e1 100644 --- a/webrtc/modules/audio_processing/include/audio_processing.h +++ b/webrtc/modules/audio_processing/include/audio_processing.h @@ -486,10 +486,6 @@ class AudioProcessing { Set(other.instant, other.average, other.maximum, other.minimum); } void Set(float instant, float average, float maximum, float minimum) { - RTC_DCHECK_LE(instant, maximum); - RTC_DCHECK_GE(instant, minimum); - RTC_DCHECK_LE(average, maximum); - RTC_DCHECK_GE(average, minimum); instant_ = instant; average_ = average; maximum_ = maximum;