Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Unified Diff: webrtc/video/stats_counter.h

Issue 2235223002: Add ability to handle data from multiple streams in RateAccCounter. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/video/stats_counter.cc » ('j') | webrtc/video/stats_counter.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | webrtc/video/stats_counter.cc » ('j') | webrtc/video/stats_counter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698