Index: webrtc/video/receive_statistics_proxy.h |
diff --git a/webrtc/video/receive_statistics_proxy.h b/webrtc/video/receive_statistics_proxy.h |
index 8aff1a254c47ec6c79f50696cb13009350822d98..09ffdc0debf6ac26c1ce52fb59c18876700aa702 100644 |
--- a/webrtc/video/receive_statistics_proxy.h |
+++ b/webrtc/video/receive_statistics_proxy.h |
@@ -11,8 +11,10 @@ |
#ifndef WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ |
#define WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ |
+#include <deque> |
#include <map> |
#include <string> |
+#include <utility> |
#include "webrtc/common_types.h" |
#include "webrtc/common_video/include/frame_callback.h" |
@@ -103,6 +105,27 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, |
struct QpCounters { |
SampleCounter vp8; |
}; |
+ // |time_ms| should never decrease in consecutive calls to Add and MovingMax |
+ // as if it's local time. Not thread-safe. |
+ class MovingMaxCounter { |
+ public: |
+ explicit MovingMaxCounter(int window_length_ms) : |
+ window_length_ms_(window_length_ms) {} |
+ void Add(int sample, int64_t time_ms); |
+ // Returns max sample in window given current time. |
+ // Can be sped-up in case when MovingMax is called many times in a row |
+ // without new elements added (not likely case currently) by removing |
+ // obsolete elements from the beginning of the deque instead of skipping |
+ // them. In that case deque should be marked as mutable. |
+ rtc::Optional<int> MovingMax(int64_t time_ms) const; |
+ void Reset(); |
+ private: |
+ int window_length_ms_; |
+ // Samples in the window are stored as pairs <time, sample> in this deque in |
+ // chronological order. Samples what can't be maximum in any window are |
+ // thrown out - deque always contain decreasing sequence of samples. |
+ std::deque <std::pair<int64_t, int>> samples_; |
+ }; |
sprang_webrtc
2017/08/18 09:06:49
Interesting class. If no equivalent is available i
ilnik
2017/08/18 11:43:01
Done.
|
void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
@@ -152,6 +175,7 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, |
int64_t e2e_delay_max_ms_screenshare_ GUARDED_BY(crit_); |
int64_t interframe_delay_max_ms_video_ GUARDED_BY(crit_); |
int64_t interframe_delay_max_ms_screenshare_ GUARDED_BY(crit_); |
+ MovingMaxCounter interframe_delay_max_moving_ GUARDED_BY(crit_); |
MaxCounter freq_offset_counter_ GUARDED_BY(crit_); |
int64_t first_report_block_time_ms_ GUARDED_BY(crit_); |
ReportBlockStats report_block_stats_ GUARDED_BY(crit_); |