| 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 10 matching lines...) Expand all Loading... |
| 21 #include "webrtc/call/call.h" | 21 #include "webrtc/call/call.h" |
| 22 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
| 23 | 23 |
| 24 namespace webrtc { | 24 namespace webrtc { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 constexpr int64_t kDefaultProcessIntervalMs = 5; | 27 constexpr int64_t kDefaultProcessIntervalMs = 5; |
| 28 } | 28 } |
| 29 | 29 |
| 30 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, | 30 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| 31 const FakeNetworkPipe::Config& config) | 31 const FakeNetworkPipe::Config& config, |
| 32 : FakeNetworkPipe(clock, config, 1) {} | 32 MediaType media_type) |
| 33 : FakeNetworkPipe(clock, config, media_type, 1) {} |
| 33 | 34 |
| 34 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, | 35 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| 35 const FakeNetworkPipe::Config& config, | 36 const FakeNetworkPipe::Config& config, |
| 37 MediaType media_type, |
| 36 uint64_t seed) | 38 uint64_t seed) |
| 37 : clock_(clock), | 39 : clock_(clock), |
| 40 media_type_(media_type), |
| 38 packet_receiver_(NULL), | 41 packet_receiver_(NULL), |
| 39 random_(seed), | 42 random_(seed), |
| 40 config_(), | 43 config_(), |
| 41 dropped_packets_(0), | 44 dropped_packets_(0), |
| 42 sent_packets_(0), | 45 sent_packets_(0), |
| 43 total_packet_delay_(0), | 46 total_packet_delay_(0), |
| 44 bursting_(false), | 47 bursting_(false), |
| 45 next_process_time_(clock_->TimeInMilliseconds()), | 48 next_process_time_(clock_->TimeInMilliseconds()), |
| 46 last_log_time_(clock_->TimeInMilliseconds()) { | 49 last_log_time_(clock_->TimeInMilliseconds()) { |
| 47 SetConfig(config); | 50 SetConfig(config); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // |time_now| might be later than when the packet should have arrived, due | 195 // |time_now| might be later than when the packet should have arrived, due |
| 193 // to NetworkProcess being called too late. For stats, use the time it | 196 // to NetworkProcess being called too late. For stats, use the time it |
| 194 // should have been on the link. | 197 // should have been on the link. |
| 195 total_packet_delay_ += packet->arrival_time() - packet->send_time(); | 198 total_packet_delay_ += packet->arrival_time() - packet->send_time(); |
| 196 } | 199 } |
| 197 sent_packets_ += packets_to_deliver.size(); | 200 sent_packets_ += packets_to_deliver.size(); |
| 198 } | 201 } |
| 199 while (!packets_to_deliver.empty()) { | 202 while (!packets_to_deliver.empty()) { |
| 200 NetworkPacket* packet = packets_to_deliver.front(); | 203 NetworkPacket* packet = packets_to_deliver.front(); |
| 201 packets_to_deliver.pop(); | 204 packets_to_deliver.pop(); |
| 202 packet_receiver_->DeliverPacket(MediaType::ANY, packet->data(), | 205 packet_receiver_->DeliverPacket(media_type_, packet->data(), |
| 203 packet->data_length(), PacketTime()); | 206 packet->data_length(), PacketTime()); |
| 204 delete packet; | 207 delete packet; |
| 205 } | 208 } |
| 206 | 209 |
| 207 next_process_time_ = !delay_link_.empty() | 210 next_process_time_ = !delay_link_.empty() |
| 208 ? (*delay_link_.begin())->arrival_time() | 211 ? (*delay_link_.begin())->arrival_time() |
| 209 : time_now + kDefaultProcessIntervalMs; | 212 : time_now + kDefaultProcessIntervalMs; |
| 210 } | 213 } |
| 211 | 214 |
| 212 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { | 215 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { |
| 213 rtc::CritScope crit(&lock_); | 216 rtc::CritScope crit(&lock_); |
| 214 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), | 217 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), |
| 215 0); | 218 0); |
| 216 } | 219 } |
| 217 | 220 |
| 218 } // namespace webrtc | 221 } // namespace webrtc |
| OLD | NEW |