NetEq: Use TickTimer in DelayManager

This change replaces packet_iat_count_ms_ and max_timer_ms_, two
time-counting member variables in DelayManager, with Stopwatch objects
obtained from a TickTimer.

BUG=webrtc:5608

Review-Url: https://codereview.webrtc.org/1929863002
Cr-Commit-Position: refs/heads/master@{#12554}
diff --git a/webrtc/modules/audio_coding/neteq/delay_manager.h b/webrtc/modules/audio_coding/neteq/delay_manager.h
index 785fced..6f3c14a 100644
--- a/webrtc/modules/audio_coding/neteq/delay_manager.h
+++ b/webrtc/modules/audio_coding/neteq/delay_manager.h
@@ -13,10 +13,12 @@
 
 #include <string.h>  // Provide access to size_t.
 
+#include <memory>
 #include <vector>
 
 #include "webrtc/base/constructormagic.h"
 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
+#include "webrtc/modules/audio_coding/neteq/tick_timer.h"
 #include "webrtc/typedefs.h"
 
 namespace webrtc {
@@ -32,7 +34,9 @@
   // buffer can hold no more than |max_packets_in_buffer| packets (i.e., this
   // is the number of packet slots in the buffer). Supply a PeakDetector
   // object to the DelayManager.
-  DelayManager(size_t max_packets_in_buffer, DelayPeakDetector* peak_detector);
+  DelayManager(size_t max_packets_in_buffer,
+               DelayPeakDetector* peak_detector,
+               const TickTimer* tick_timer);
 
   virtual ~DelayManager();
 
@@ -75,10 +79,6 @@
   // DelayPeakDetector object.
   virtual bool PeakFound() const;
 
-  // Notifies the counters in DelayManager and DelayPeakDetector that
-  // |elapsed_time_ms| have elapsed.
-  virtual void UpdateCounters(int elapsed_time_ms);
-
   // Reset the inter-arrival time counter to 0.
   virtual void ResetPacketIatCount();
 
@@ -135,7 +135,9 @@
   const size_t max_packets_in_buffer_;  // Capacity of the packet buffer.
   IATVector iat_vector_;  // Histogram of inter-arrival times.
   int iat_factor_;  // Forgetting factor for updating the IAT histogram (Q15).
-  int packet_iat_count_ms_;  // Milliseconds elapsed since last packet.
+  const TickTimer* tick_timer_;
+  // Time elapsed since last packet.
+  std::unique_ptr<TickTimer::Stopwatch> packet_iat_stopwatch_;
   int base_target_level_;   // Currently preferred buffer level before peak
                             // detection and streaming mode (Q0).
   // TODO(turajs) change the comment according to the implementation of
@@ -153,7 +155,8 @@
   int maximum_delay_ms_;  // Externally set maximum allowed delay.
   int iat_cumulative_sum_;  // Cumulative sum of delta inter-arrival times.
   int max_iat_cumulative_sum_;  // Max of |iat_cumulative_sum_|.
-  int max_timer_ms_;  // Time elapsed since maximum was observed.
+  // Time elapsed since maximum was observed.
+  std::unique_ptr<TickTimer::Stopwatch> max_iat_stopwatch_;
   DelayPeakDetector& peak_detector_;
   int last_pack_cng_or_dtmf_;