1 #ifndef ANDROID_DVR_LATENCY_MODEL_H_ 2 #define ANDROID_DVR_LATENCY_MODEL_H_ 3 4 #include <vector> 5 6 namespace android { 7 namespace dvr { 8 9 // This class models the latency from sensors. It will look at the first 10 // window_size measurements and return their average after that. 11 class LatencyModel { 12 public: 13 explicit LatencyModel(size_t window_size); 14 ~LatencyModel() = default; 15 16 void AddLatency(int64_t latency_ns); CurrentLatencyEstimate()17 int64_t CurrentLatencyEstimate() const { return latency_; } 18 19 private: 20 size_t window_size_; 21 int64_t latency_sum_ = 0; 22 size_t num_summed_ = 0; 23 int64_t latency_ = 0; 24 }; 25 26 } // namespace dvr 27 } // namespace android 28 29 #endif // ANDROID_DVR_LATENCY_MODEL_H_ 30