NetEq: Create an audio interruption metric

This CL adds a new metric to NetEq, which logs whenever a loss
concealment event has lasted longer than 150 ms (an "interruption").
The number of such events, as well as the sum length of them, is kept
in a SampleCounter, which can be queried at any time.

Any initial PLC at the beginning of a call, before the first packet is
decoded, is ignored.

Unit tests and piping to neteq_rtpplay are included.

Bug: webrtc:10549
Change-Id: I8a224a34254c47c74317617f420f6de997232d88
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132796
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27781}
diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc
index d0f37bc..4ef239a 100644
--- a/modules/audio_coding/neteq/statistics_calculator.cc
+++ b/modules/audio_coding/neteq/statistics_calculator.cc
@@ -29,6 +29,8 @@
                 "int must not be wider than size_t for this to work");
   return (a < 0 && ret > b) ? 0 : ret;
 }
+
+constexpr int kInterruptionLenMs = 150;
 }  // namespace
 
 // Allocating the static const so that it can be passed by reference to
@@ -176,6 +178,24 @@
   ConcealedSamplesCorrection(num_samples, false);
 }
 
+void StatisticsCalculator::DecodedOutputPlayed() {
+  decoded_output_played_ = true;
+}
+
+void StatisticsCalculator::EndExpandEvent(int fs_hz) {
+  RTC_DCHECK_GE(lifetime_stats_.concealed_samples,
+                concealed_samples_at_event_end_);
+  const int event_duration_ms =
+      1000 *
+      (lifetime_stats_.concealed_samples - concealed_samples_at_event_end_) /
+      fs_hz;
+  if (event_duration_ms >= kInterruptionLenMs && decoded_output_played_) {
+    lifetime_stats_.interruption_count++;
+    lifetime_stats_.total_interruption_duration_ms += event_duration_ms;
+  }
+  concealed_samples_at_event_end_ = lifetime_stats_.concealed_samples;
+}
+
 void StatisticsCalculator::ConcealedSamplesCorrection(int num_samples,
                                                       bool is_voice) {
   if (num_samples < 0) {