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

Unified Diff: webrtc/base/rate_statistics.h

Issue 2061423003: Refactor NACK bitrate allocation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moved rate limiter and addressed comments Created 4 years, 6 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/base/rate_statistics.cc » ('j') | webrtc/base/rate_statistics.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/rate_statistics.h
diff --git a/webrtc/base/rate_statistics.h b/webrtc/base/rate_statistics.h
index 3e913cc1bbc310ba9d6b122bf93ea499a592ebfc..a6f8802ee4da3f94d6f900c7f66342ca38bc0683 100644
--- a/webrtc/base/rate_statistics.h
+++ b/webrtc/base/rate_statistics.h
@@ -20,17 +20,35 @@ namespace webrtc {
class RateStatistics {
public:
+ static constexpr float kBpsScale = 8000.0f;
+
// max_window_size_ms = Maximum window size in ms for the rate estimation.
// Initial window size is set to this, but may be changed
// to something lower by calling SetWindowSize().
- // scale = coefficient to convert counts/ms to desired units,
- // ex: if counts represents bytes, use 8*1000 to go to bits/s
+ // scale = coefficient to convert counts/ms to desired unit
+ // ex: kBpsScale (8000) for bits/s if count represents bytes.
RateStatistics(int64_t max_window_size_ms, float scale);
~RateStatistics();
+ // Reset instance to original state.
void Reset();
+
+ // Update rate with a new data point, moving averaging window as needed.
void Update(size_t count, int64_t now_ms);
+
+ // Poll the current rate, moving averaging window as needed.
rtc::Optional<uint32_t> Rate(int64_t now_ms);
+
+ // Utility method for polling rate from a const function. Note that this
+ // still updates the internal state (moves averaging window), but it doesn't
+ // make any alterations that are observable from the other methods, as long as
+ // supplied timestamps are from a monotonic clock. Ie, it doesn't matter if
+ // this call moves the window, since any subsequent call to Update or Rate
+ // would still have moved the window as much or more.
+ rtc::Optional<uint32_t> Rate(int64_t now_ms) const;
+
+ // Update the size of the averaging window. The maximum allowed value for
+ // window_size_ms is max_window_size_ms as supplied in the constructor.
bool SetWindowSize(int64_t window_size_ms, int64_t now_ms);
private:
« no previous file with comments | « no previous file | webrtc/base/rate_statistics.cc » ('j') | webrtc/base/rate_statistics.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698