Index: webrtc/video/stats_counter.h |
diff --git a/webrtc/video/stats_counter.h b/webrtc/video/stats_counter.h |
index c272b6278d0961b69362748ab7272ba5c4b2af71..cad5a63de74760f3f4f899a04402b38333d616e8 100644 |
--- a/webrtc/video/stats_counter.h |
+++ b/webrtc/video/stats_counter.h |
@@ -11,6 +11,8 @@ |
#ifndef WEBRTC_VIDEO_STATS_COUNTER_H_ |
#define WEBRTC_VIDEO_STATS_COUNTER_H_ |
+#include <limits> |
+#include <map> |
#include <memory> |
#include "webrtc/base/constructormagic.h" |
@@ -82,25 +84,34 @@ class StatsCounter { |
AggregatedStats GetStats(); |
+ // Holds gathered samples within a process interval. |
+ struct Samples { |
+ void Add(int sample); |
+ void Set(int sample); |
+ void Reset(); |
+ |
+ int max_ = std::numeric_limits<int>::min(); |
+ int64_t num_ = 0; |
+ int64_t sum_ = 0; |
+ int64_t last_sum_ = 0; |
+ }; |
+ |
protected: |
StatsCounter(Clock* clock, |
bool include_empty_intervals, |
StatsCounterObserver* observer); |
void Add(int sample); |
- void Set(int sample); |
+ void Set(int sample, uint32_t ssrc); |
- int max_; |
- int64_t sum_; |
- int64_t num_samples_; |
- int64_t last_sum_; |
+ const bool include_empty_intervals_; |
+ std::map<uint32_t, Samples> samples_; // Gathered samples mapped by SSRC. |
private: |
bool TimeToProcess(); |
void TryProcess(); |
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_; |
@@ -218,7 +229,7 @@ class RateAccCounter : public StatsCounter { |
bool include_empty_intervals); |
~RateAccCounter() override {} |
- void Set(int sample); |
+ void Set(int sample, uint32_t ssrc); |
private: |
bool GetMetric(int* metric) const override; |