1 /* 2 * Copyright (c) 2018 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/congestion_controller/pcc/rtt_tracker.h" 12 13 #include <algorithm> 14 15 namespace webrtc { 16 namespace pcc { 17 RttTracker(TimeDelta initial_rtt,double alpha)18RttTracker::RttTracker(TimeDelta initial_rtt, double alpha) 19 : rtt_estimate_(initial_rtt), alpha_(alpha) {} 20 OnPacketsFeedback(const std::vector<PacketResult> & packet_feedbacks,Timestamp feedback_received_time)21void RttTracker::OnPacketsFeedback( 22 const std::vector<PacketResult>& packet_feedbacks, 23 Timestamp feedback_received_time) { 24 TimeDelta packet_rtt = TimeDelta::MinusInfinity(); 25 for (const PacketResult& packet_result : packet_feedbacks) { 26 if (packet_result.receive_time.IsInfinite()) 27 continue; 28 packet_rtt = std::max<TimeDelta>( 29 packet_rtt, 30 feedback_received_time - packet_result.sent_packet.send_time); 31 } 32 if (packet_rtt.IsFinite()) 33 rtt_estimate_ = (1 - alpha_) * rtt_estimate_ + alpha_ * packet_rtt; 34 } 35 GetRtt() const36TimeDelta RttTracker::GetRtt() const { 37 return rtt_estimate_; 38 } 39 40 } // namespace pcc 41 } // namespace webrtc 42