| 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 13 matching lines...) Expand all Loading... |
| 24 namespace webrtc { | 24 namespace webrtc { |
| 25 | 25 |
| 26 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, | 26 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| 27 const FakeNetworkPipe::Config& config) | 27 const FakeNetworkPipe::Config& config) |
| 28 : FakeNetworkPipe(clock, config, 1) {} | 28 : FakeNetworkPipe(clock, config, 1) {} |
| 29 | 29 |
| 30 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, | 30 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| 31 const FakeNetworkPipe::Config& config, | 31 const FakeNetworkPipe::Config& config, |
| 32 uint64_t seed) | 32 uint64_t seed) |
| 33 : clock_(clock), | 33 : clock_(clock), |
| 34 packet_receiver_(NULL), | 34 packet_receiver_(nullptr), |
| 35 random_(seed), | 35 random_(seed), |
| 36 config_(config), | 36 config_(config), |
| 37 dropped_packets_(0), | 37 dropped_packets_(0), |
| 38 sent_packets_(0), | 38 sent_packets_(0), |
| 39 total_packet_delay_(0), | 39 total_packet_delay_(0), |
| 40 bursting_(false), | 40 bursting_(false), |
| 41 next_process_time_(clock_->TimeInMilliseconds()), | 41 next_process_time_(clock_->TimeInMilliseconds()), |
| 42 last_log_time_(clock_->TimeInMilliseconds()) { | 42 last_log_time_(clock_->TimeInMilliseconds()) { |
| 43 double prob_loss = config.loss_percent / 100.0; | 43 double prob_loss = config.loss_percent / 100.0; |
| 44 if (config_.avg_burst_loss_length == -1) { | 44 if (config_.avg_burst_loss_length == -1) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 74 void FakeNetworkPipe::SetReceiver(PacketReceiver* receiver) { | 74 void FakeNetworkPipe::SetReceiver(PacketReceiver* receiver) { |
| 75 packet_receiver_ = receiver; | 75 packet_receiver_ = receiver; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void FakeNetworkPipe::SetConfig(const FakeNetworkPipe::Config& config) { | 78 void FakeNetworkPipe::SetConfig(const FakeNetworkPipe::Config& config) { |
| 79 rtc::CritScope crit(&lock_); | 79 rtc::CritScope crit(&lock_); |
| 80 config_ = config; // Shallow copy of the struct. | 80 config_ = config; // Shallow copy of the struct. |
| 81 } | 81 } |
| 82 | 82 |
| 83 void FakeNetworkPipe::SendPacket(const uint8_t* data, size_t data_length) { | 83 void FakeNetworkPipe::SendPacket(const uint8_t* data, size_t data_length) { |
| 84 // A NULL packet_receiver_ means that this pipe will terminate the flow of | 84 // A null packet_receiver_ means that this pipe will terminate the flow of |
| 85 // packets. | 85 // packets. |
| 86 if (packet_receiver_ == NULL) | 86 if (packet_receiver_ == nullptr) |
| 87 return; | 87 return; |
| 88 rtc::CritScope crit(&lock_); | 88 rtc::CritScope crit(&lock_); |
| 89 if (config_.queue_length_packets > 0 && | 89 if (config_.queue_length_packets > 0 && |
| 90 capacity_link_.size() >= config_.queue_length_packets) { | 90 capacity_link_.size() >= config_.queue_length_packets) { |
| 91 // Too many packet on the link, drop this one. | 91 // Too many packet on the link, drop this one. |
| 92 ++dropped_packets_; | 92 ++dropped_packets_; |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 | 95 |
| 96 int64_t time_now = clock_->TimeInMilliseconds(); | 96 int64_t time_now = clock_->TimeInMilliseconds(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { | 205 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { |
| 206 rtc::CritScope crit(&lock_); | 206 rtc::CritScope crit(&lock_); |
| 207 const int64_t kDefaultProcessIntervalMs = 5; | 207 const int64_t kDefaultProcessIntervalMs = 5; |
| 208 if (capacity_link_.empty() || delay_link_.empty()) | 208 if (capacity_link_.empty() || delay_link_.empty()) |
| 209 return kDefaultProcessIntervalMs; | 209 return kDefaultProcessIntervalMs; |
| 210 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), | 210 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), |
| 211 0); | 211 0); |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace webrtc | 214 } // namespace webrtc |
| OLD | NEW |