From 612c25e7afad62675510cf3269701b28dc053605 Mon Sep 17 00:00:00 2001 From: "henrik.lundin" Date: Wed, 25 May 2016 08:21:04 -0700 Subject: [PATCH] NetEq: Fix stats counting in muted mode The NetEqNetworkStatistics::expand_rate was not incremented during muted state, which caused under-reporting of that metric. This change fixes that. BUG=chromium:613321, webrtc:5608 Review-Url: https://codereview.webrtc.org/2003203004 Cr-Commit-Position: refs/heads/master@{#12894} --- webrtc/modules/audio_coding/neteq/neteq_impl.cc | 1 + webrtc/modules/audio_coding/neteq/neteq_unittest.cc | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc index 7aeeb73f39..87d12f51f1 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -832,6 +832,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) { : timestamp_scaler_->ToExternal(playout_timestamp_) - static_cast(audio_frame->samples_per_channel_); audio_frame->num_channels_ = sync_buffer_->Channels(); + stats_.ExpandedNoiseSamples(output_size_samples_); *muted = true; return 0; } diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc index d17936757a..783c7ff53e 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc @@ -1609,6 +1609,15 @@ TEST_F(NetEqDecodingTestWithMutedState, MutedState) { // packet. Verify that normal operation resumes. InsertPacket(kSamples * counter_); GetAudioUntilNormal(); + + NetEqNetworkStatistics stats; + EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); + // NetEqNetworkStatistics::expand_rate tells the fraction of samples that were + // concealment samples, in Q14 (16384 = 100%) .The vast majority should be + // concealment samples in this test. + EXPECT_GT(stats.expand_rate, 14000); + // And, it should be greater than the speech_expand_rate. + EXPECT_GT(stats.expand_rate, stats.speech_expand_rate); } // Verifies that NetEq goes out of muted state when given a delayed packet.