| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 return static_cast<float>(dropped_packets_) / | 140 return static_cast<float>(dropped_packets_) / |
| 141 (sent_packets_ + dropped_packets_); | 141 (sent_packets_ + dropped_packets_); |
| 142 } | 142 } |
| 143 | 143 |
| 144 int FakeNetworkPipe::AverageDelay() { | 144 int FakeNetworkPipe::AverageDelay() { |
| 145 rtc::CritScope crit(&lock_); | 145 rtc::CritScope crit(&lock_); |
| 146 if (sent_packets_ == 0) | 146 if (sent_packets_ == 0) |
| 147 return 0; | 147 return 0; |
| 148 | 148 |
| 149 return total_packet_delay_ / static_cast<int>(sent_packets_); | 149 return total_packet_delay_ / static_cast<int64_t>(sent_packets_); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void FakeNetworkPipe::Process() { | 152 void FakeNetworkPipe::Process() { |
| 153 int64_t time_now = clock_->TimeInMilliseconds(); | 153 int64_t time_now = clock_->TimeInMilliseconds(); |
| 154 std::queue<NetworkPacket*> packets_to_deliver; | 154 std::queue<NetworkPacket*> packets_to_deliver; |
| 155 { | 155 { |
| 156 rtc::CritScope crit(&lock_); | 156 rtc::CritScope crit(&lock_); |
| 157 // Check the capacity link first. | 157 // Check the capacity link first. |
| 158 while (capacity_link_.size() > 0 && | 158 while (capacity_link_.size() > 0 && |
| 159 time_now >= capacity_link_.front()->arrival_time()) { | 159 time_now >= capacity_link_.front()->arrival_time()) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { | 209 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { |
| 210 rtc::CritScope crit(&lock_); | 210 rtc::CritScope crit(&lock_); |
| 211 const int64_t kDefaultProcessIntervalMs = 30; | 211 const int64_t kDefaultProcessIntervalMs = 30; |
| 212 if (capacity_link_.size() == 0 || delay_link_.size() == 0) | 212 if (capacity_link_.size() == 0 || delay_link_.size() == 0) |
| 213 return kDefaultProcessIntervalMs; | 213 return kDefaultProcessIntervalMs; |
| 214 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), | 214 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), |
| 215 0); | 215 0); |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace webrtc | 218 } // namespace webrtc |
| OLD | NEW |