Index: webrtc/test/fake_network_pipe.cc |
diff --git a/webrtc/test/fake_network_pipe.cc b/webrtc/test/fake_network_pipe.cc |
index bb9d6b1322e5ecf495aca3b46ec25c098bed2d98..a8b53f4cb5785813fcd6f50fdaf5665ad2ddde57 100644 |
--- a/webrtc/test/fake_network_pipe.cc |
+++ b/webrtc/test/fake_network_pipe.cc |
@@ -132,8 +132,17 @@ void FakeNetworkPipe::SendPacket(const uint8_t* data, size_t data_length) { |
// Delay introduced by the link capacity. |
int64_t capacity_delay_ms = 0; |
- if (config_.link_capacity_kbps > 0) |
- capacity_delay_ms = data_length / (config_.link_capacity_kbps / 8); |
+ if (config_.link_capacity_kbps > 0) { |
+ // To round to closest millisecond we add half a milliseconds worth of bytes |
philipel
2017/08/30 09:00:42
To round to the
|
+ // to the delay calculation. |
+ const int offset_bytes = config_.link_capacity_kbps / 8 / 2; |
terelius
2017/08/29 15:02:16
foo = config_.link_capacity_kbps / 8;
capacity_del
|
+ |
+ capacity_delay_ms = |
+ (data_length + capacity_delay_error_bytes_ + offset_bytes) / |
+ (config_.link_capacity_kbps / 8); |
+ capacity_delay_error_bytes_ += |
+ data_length - capacity_delay_ms * (config_.link_capacity_kbps / 8); |
+ } |
int64_t network_start_time = time_now; |
// Check if there already are packets on the link and change network start |