| Index: webrtc/video/stats_counter.h
|
| diff --git a/webrtc/video/stats_counter.h b/webrtc/video/stats_counter.h
|
| index c272b6278d0961b69362748ab7272ba5c4b2af71..71db7b2144f9669726c7d45097079a407fea5da3 100644
|
| --- a/webrtc/video/stats_counter.h
|
| +++ b/webrtc/video/stats_counter.h
|
| @@ -78,10 +78,22 @@ class StatsCounter {
|
| public:
|
| virtual ~StatsCounter();
|
|
|
| + // Gets metric within an interval. Returns true on success false otherwise.
|
| virtual bool GetMetric(int* metric) const = 0;
|
|
|
| + // Gets the value to use for an interval without samples.
|
| + virtual int GetValueForEmptyInterval() const = 0;
|
| +
|
| + // Gets aggregated stats (i.e. aggregate of periodically computed metrics).
|
| AggregatedStats GetStats();
|
|
|
| + // Reports metrics for elapsed intervals to AggregatedCounter and GetStats.
|
| + AggregatedStats ProcessAndGetStats();
|
| +
|
| + // Reports metrics for elapsed intervals to AggregatedCounter and pauses stats
|
| + // (i.e. empty intervals will be discarded until next sample is added).
|
| + void ProcessAndPause();
|
| +
|
| protected:
|
| StatsCounter(Clock* clock,
|
| bool include_empty_intervals,
|
| @@ -95,15 +107,19 @@ class StatsCounter {
|
| int64_t num_samples_;
|
| int64_t last_sum_;
|
|
|
| + const std::unique_ptr<AggregatedCounter> aggregated_counter_;
|
| +
|
| private:
|
| - bool TimeToProcess();
|
| + bool TimeToProcess(int* num_elapsed_intervals);
|
| void TryProcess();
|
| + void ReportMetricToAggregatedCounter(int value, int num_values_to_add) const;
|
| + bool IncludeEmptyIntervals() const;
|
|
|
| Clock* const clock_;
|
| const bool include_empty_intervals_;
|
| const std::unique_ptr<StatsCounterObserver> observer_;
|
| - const std::unique_ptr<AggregatedCounter> aggregated_counter_;
|
| int64_t last_process_time_ms_;
|
| + bool paused_;
|
| };
|
|
|
| // AvgCounter: average of samples
|
| @@ -112,9 +128,15 @@ class StatsCounter {
|
| // | Add(5) Add(1) Add(6) | Add(5) Add(5) |
|
| // GetMetric | (5 + 1 + 6) / 3 | (5 + 5) / 2 |
|
| //
|
| +// |include_empty_intervals|: If set, intervals without samples will be included
|
| +// in the stats. The value for an interval is
|
| +// determined by GetValueForEmptyInterval().
|
| +//
|
| class AvgCounter : public StatsCounter {
|
| public:
|
| - AvgCounter(Clock* clock, StatsCounterObserver* observer);
|
| + AvgCounter(Clock* clock,
|
| + StatsCounterObserver* observer,
|
| + bool include_empty_intervals);
|
| ~AvgCounter() override {}
|
|
|
| void Add(int sample);
|
| @@ -122,6 +144,9 @@ class AvgCounter : public StatsCounter {
|
| private:
|
| bool GetMetric(int* metric) const override;
|
|
|
| + // Returns the last computed metric (i.e. from GetMetric).
|
| + int GetValueForEmptyInterval() const override;
|
| +
|
| RTC_DISALLOW_COPY_AND_ASSIGN(AvgCounter);
|
| };
|
|
|
| @@ -140,6 +165,7 @@ class MaxCounter : public StatsCounter {
|
|
|
| private:
|
| bool GetMetric(int* metric) const override;
|
| + int GetValueForEmptyInterval() const override;
|
|
|
| RTC_DISALLOW_COPY_AND_ASSIGN(MaxCounter);
|
| };
|
| @@ -159,6 +185,7 @@ class PercentCounter : public StatsCounter {
|
|
|
| private:
|
| bool GetMetric(int* metric) const override;
|
| + int GetValueForEmptyInterval() const override;
|
|
|
| RTC_DISALLOW_COPY_AND_ASSIGN(PercentCounter);
|
| };
|
| @@ -178,6 +205,7 @@ class PermilleCounter : public StatsCounter {
|
|
|
| private:
|
| bool GetMetric(int* metric) const override;
|
| + int GetValueForEmptyInterval() const override;
|
|
|
| RTC_DISALLOW_COPY_AND_ASSIGN(PermilleCounter);
|
| };
|
| @@ -189,6 +217,10 @@ class PermilleCounter : public StatsCounter {
|
| // |<------ 2 sec ------->| |
|
| // GetMetric | (5 + 1 + 6) / 2 | (5 + 5) / 2 |
|
| //
|
| +// |include_empty_intervals|: If set, intervals without samples will be included
|
| +// in the stats. The value for an interval is
|
| +// determined by GetValueForEmptyInterval().
|
| +//
|
| class RateCounter : public StatsCounter {
|
| public:
|
| RateCounter(Clock* clock,
|
| @@ -200,6 +232,7 @@ class RateCounter : public StatsCounter {
|
|
|
| private:
|
| bool GetMetric(int* metric) const override;
|
| + int GetValueForEmptyInterval() const override; // Returns zero.
|
|
|
| RTC_DISALLOW_COPY_AND_ASSIGN(RateCounter);
|
| };
|
| @@ -211,6 +244,10 @@ class RateCounter : public StatsCounter {
|
| // |<------ 2 sec ------->| |
|
| // GetMetric | 8 / 2 | (13 - 8) / 2 |
|
| //
|
| +// |include_empty_intervals|: If set, intervals without samples will be included
|
| +// in the stats. The value for an interval is
|
| +// determined by GetValueForEmptyInterval().
|
| +//
|
| class RateAccCounter : public StatsCounter {
|
| public:
|
| RateAccCounter(Clock* clock,
|
| @@ -222,6 +259,7 @@ class RateAccCounter : public StatsCounter {
|
|
|
| private:
|
| bool GetMetric(int* metric) const override;
|
| + int GetValueForEmptyInterval() const override; // Returns zero.
|
|
|
| RTC_DISALLOW_COPY_AND_ASSIGN(RateAccCounter);
|
| };
|
|
|