NetEq/Stats: Don't let concealed_samples decrease
When NetEq performs a merge operation, it will usually have to correct
the stats for number of concealment samples produced, sometimes with
decreasing it.
This does not make sense in the context of the stats spec, and
stats-consuming applications may not be prepared for it. With this
change, only positive corrections are allowed for the
concealed_samples value. This will sometimes lead to a small positive
bias, but it will be negligible over time.
Bug: webrtc:8253
Change-Id: Ie9de311ab16401f1a4b435f6269725901b8cf561
Reviewed-on: https://webrtc-review.googlesource.com/1583
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19941}
diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc
index 764a505..5b92217 100644
--- a/modules/audio_coding/neteq/neteq_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_unittest.cc
@@ -368,6 +368,8 @@
packet_ = rtp_source_->NextPacket();
int i = 0;
+ uint64_t last_concealed_samples = 0;
+ uint64_t last_total_samples_received = 0;
while (packet_) {
std::ostringstream ss;
ss << "Lap number " << i++ << " in DecodeAndCompare while loop";
@@ -387,6 +389,20 @@
EXPECT_EQ(current_network_stats.current_buffer_size_ms,
neteq_->CurrentDelayMs());
+ // Verify that liftime stats and network stats report similar loss
+ // concealment rates.
+ auto lifetime_stats = neteq_->GetLifetimeStatistics();
+ const uint64_t delta_concealed_samples =
+ lifetime_stats.concealed_samples - last_concealed_samples;
+ last_concealed_samples = lifetime_stats.concealed_samples;
+ const uint64_t delta_total_samples_received =
+ lifetime_stats.total_samples_received - last_total_samples_received;
+ last_total_samples_received = lifetime_stats.total_samples_received;
+ // The tolerance is 1% but expressed in Q14.
+ EXPECT_NEAR(
+ (delta_concealed_samples << 14) / delta_total_samples_received,
+ current_network_stats.expand_rate, (2 << 14) / 100.0);
+
// Process RTCPstat.
RtcpStatistics current_rtcp_stats;
neteq_->GetRtcpStatistics(¤t_rtcp_stats);