int64_t GetAvgRttMs(const std::list<CallStats::RttTime>& reports) {
RTC_DCHECK(!reports.empty());
int64_t sum = 0; for (std::list<CallStats::RttTime>::const_iterator it = reports.begin();
it != reports.end(); ++it) {
sum += it->rtt;
} return sum / reports.size();
}
int64_t cur_rtt_ms = GetAvgRttMs(reports); if (prev_avg_rtt == -1) return cur_rtt_ms; // New initial average value.
// Weight factor to apply to the average rtt. // We weigh the old average at 70% against the new average (30%).
constexpr constfloat kWeightFactor = 0.3f; return prev_avg_rtt * (1.0f - kWeightFactor) + cur_rtt_ms * kWeightFactor;
}
// If there is a valid rtt, update all observers with the max rtt. if (max_rtt_ms_ >= 0) {
RTC_DCHECK_GE(avg_rtt_ms_, 0); for (CallStatsObserver* observer : observers_)
observer->OnRttUpdate(avg_rtt_ms_, max_rtt_ms_); // Sum for Histogram of average RTT reported over the entire call.
sum_avg_rtt_ms_ += avg_rtt_ms_;
++num_avg_rtt_;
}
}
void CallStats::RegisterStatsObserver(CallStatsObserver* observer) {
RTC_DCHECK_RUN_ON(task_queue_); if (!absl::c_linear_search(observers_, observer))
observers_.push_back(observer);
}
int64_t CallStats::LastProcessedRtt() const {
RTC_DCHECK_RUN_ON(task_queue_); // No need for locking since we're on the construction thread. return avg_rtt_ms_;
}
void CallStats::OnRttUpdate(int64_t rtt) { // This callback may for some RtpRtcp module instances (video send stream) be // invoked from a separate task queue, in other cases, we should already be // on the correct TQ.
int64_t now_ms = clock_->TimeInMilliseconds(); auto update = [this, rtt, now_ms]() {
RTC_DCHECK_RUN_ON(task_queue_);
reports_.push_back(RttTime(rtt, now_ms)); if (time_of_first_rtt_ms_ == -1)
time_of_first_rtt_ms_ = now_ms;
UpdateAndReport();
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Eigene Datei ansehen
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.