1 #include <private/dvr/latency_model.h> 2 3 #include <cmath> 4 5 namespace android { 6 namespace dvr { 7 LatencyModel(size_t window_size)8LatencyModel::LatencyModel(size_t window_size) : window_size_(window_size) {} 9 AddLatency(int64_t latency_ns)10void LatencyModel::AddLatency(int64_t latency_ns) { 11 // Not enough samples yet? 12 if (num_summed_ < window_size_) { 13 // Accumulate. 14 latency_sum_ += latency_ns; 15 16 // Have enough samples for latency estimate? 17 if (++num_summed_ == window_size_) { 18 latency_ = latency_sum_ / window_size_; 19 } 20 } 21 } 22 23 } // namespace dvr 24 } // namespace android 25