Index: webrtc/modules/audio_coding/neteq/statistics_calculator.h |
diff --git a/webrtc/modules/audio_coding/neteq/statistics_calculator.h b/webrtc/modules/audio_coding/neteq/statistics_calculator.h |
index bd14530f0e3aa813a59f2e6c9a55cf8bcb83e38b..6280c4e20e93001ea12ec43e1cf2ed07ff94b4fb 100644 |
--- a/webrtc/modules/audio_coding/neteq/statistics_calculator.h |
+++ b/webrtc/modules/audio_coding/neteq/statistics_calculator.h |
@@ -11,6 +11,7 @@ |
#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ |
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ |
+#include <string> |
#include <vector> |
#include "webrtc/base/constructormagic.h" |
@@ -96,39 +97,58 @@ class StatisticsCalculator { |
static const int kMaxReportPeriod = 60; // Seconds before auto-reset. |
static const int kLenWaitingTimes = 100; |
- class DelayedPacketOutagesPerMinuteCounter { |
+ class PeriodicUmaLogger { |
public: |
+ PeriodicUmaLogger(const std::string& uma_name, |
+ int report_interval_ms, |
+ int max_value); |
+ virtual ~PeriodicUmaLogger(); |
+ void AdvanceClock(int step_ms); |
+ |
+ protected: |
+ void LogToUma(int value) const; |
+ virtual int Metric() const = 0; |
+ virtual void Reset() = 0; |
+ |
+ const std::string uma_name_; |
+ const int report_interval_ms_; |
+ const int max_value_; |
+ int timer_ = 0; |
+ }; |
+ |
+ class DelayedPacketOutagesPerMinuteCounter final : public PeriodicUmaLogger { |
+ public: |
+ DelayedPacketOutagesPerMinuteCounter(); |
~DelayedPacketOutagesPerMinuteCounter() { |
- LogToUma(); // Log the count for the current (incomplete) interval. |
+ // Log the count for the current (incomplete) interval. |
+ LogToUma(Metric()); |
} |
void RegisterEvent(); |
- void AdvanceClock(int step_ms); |
- private: |
- static const int kReportIntervalMs = 60 * 1000; // One minute. |
- |
- void LogToUma() const; |
+ protected: |
+ int Metric() const override; |
+ void Reset() override; |
+ private: |
int counter_ = 0; |
- int timer_ = 0; |
}; |
- class AverageExcessBufferDelayMs { |
+ class AverageExcessBufferDelayMs final : public PeriodicUmaLogger { |
public: |
+ AverageExcessBufferDelayMs(); |
~AverageExcessBufferDelayMs() { |
- LogToUma(); // Log the average for the current (incomplete) interval. |
+ // Log the average for the current (incomplete) interval. |
+ LogToUma(Metric()); |
} |
void RegisterPacketWaitingTime(int time_ms); |
- void AdvanceClock(int step_ms); |
- private: |
- static const int kReportIntervalMs = 60 * 1000; // One minute. |
- |
- void LogToUma(); |
+ protected: |
+ int Metric() const override; |
+ void Reset() override; |
+ private: |
double sum_ = 0.0; |
int num_packets_ = 0; |
- int timer_ = 0; |
}; |
// Calculates numerator / denominator, and returns the value in Q14. |