blob: ec4d9d82e0c795f349dd57db294e5b4be9825599 [file] [log] [blame]
Henrik Boströmf2047872019-05-16 11:32:201/*
2 * Copyright 2019 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "modules/rtp_rtcp/include/report_block_data.h"
12
13namespace webrtc {
14
15ReportBlockData::ReportBlockData()
16 : report_block_(),
17 report_block_timestamp_utc_us_(0),
18 last_rtt_ms_(0),
19 min_rtt_ms_(0),
20 max_rtt_ms_(0),
21 sum_rtt_ms_(0),
22 num_rtts_(0) {}
23
24double ReportBlockData::AvgRttMs() const {
25 return num_rtts_ ? static_cast<double>(sum_rtt_ms_) / num_rtts_ : 0.0;
26}
27
28void ReportBlockData::SetReportBlock(RTCPReportBlock report_block,
29 int64_t report_block_timestamp_utc_us) {
30 report_block_ = report_block;
31 report_block_timestamp_utc_us_ = report_block_timestamp_utc_us;
32}
33
34void ReportBlockData::AddRoundTripTimeSample(int64_t rtt_ms) {
35 if (rtt_ms > max_rtt_ms_)
36 max_rtt_ms_ = rtt_ms;
37 if (num_rtts_ == 0 || rtt_ms < min_rtt_ms_)
38 min_rtt_ms_ = rtt_ms;
39 last_rtt_ms_ = rtt_ms;
40 sum_rtt_ms_ += rtt_ms;
41 ++num_rtts_;
42}
43
44} // namespace webrtc