Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: webrtc/test/fake_network_pipe.cc

Issue 2997883002: Video/Screenshare loopback tool.
Patch Set: Rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/fake_network_pipe.h ('k') | webrtc/video/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 capacity_link_.size() >= config_.queue_length_packets) { 125 capacity_link_.size() >= config_.queue_length_packets) {
126 // Too many packet on the link, drop this one. 126 // Too many packet on the link, drop this one.
127 ++dropped_packets_; 127 ++dropped_packets_;
128 return; 128 return;
129 } 129 }
130 130
131 int64_t time_now = clock_->TimeInMilliseconds(); 131 int64_t time_now = clock_->TimeInMilliseconds();
132 132
133 // Delay introduced by the link capacity. 133 // Delay introduced by the link capacity.
134 int64_t capacity_delay_ms = 0; 134 int64_t capacity_delay_ms = 0;
135 if (config_.link_capacity_kbps > 0) 135 if (config_.link_capacity_kbps > 0) {
136 capacity_delay_ms = data_length / (config_.link_capacity_kbps / 8); 136 int offset_bytes = config_.link_capacity_kbps / 8 / 2;
137 capacity_delay_ms = (data_length + capacity_delay_error_ + offset_bytes) /
138 (config_.link_capacity_kbps / 8);
139 capacity_delay_error_ +=
140 data_length - capacity_delay_ms * (config_.link_capacity_kbps / 8);
141 // Print("Error: %ld", capacity_delay_error_);
142 }
137 int64_t network_start_time = time_now; 143 int64_t network_start_time = time_now;
138 144
139 // Check if there already are packets on the link and change network start 145 // Check if there already are packets on the link and change network start
140 // time forward if there is. 146 // time forward if there is.
141 if (!capacity_link_.empty() && 147 if (!capacity_link_.empty() &&
142 network_start_time < capacity_link_.back()->arrival_time()) 148 network_start_time < capacity_link_.back()->arrival_time())
143 network_start_time = capacity_link_.back()->arrival_time(); 149 network_start_time = capacity_link_.back()->arrival_time();
144 150
145 int64_t arrival_time = network_start_time + capacity_delay_ms; 151 int64_t arrival_time = network_start_time + capacity_delay_ms;
146 NetworkPacket* packet = new NetworkPacket(data, data_length, time_now, 152 NetworkPacket* packet = new NetworkPacket(data, data_length, time_now,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 : time_now + kDefaultProcessIntervalMs; 244 : time_now + kDefaultProcessIntervalMs;
239 } 245 }
240 246
241 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { 247 int64_t FakeNetworkPipe::TimeUntilNextProcess() const {
242 rtc::CritScope crit(&lock_); 248 rtc::CritScope crit(&lock_);
243 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), 249 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(),
244 0); 250 0);
245 } 251 }
246 252
247 } // namespace webrtc 253 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fake_network_pipe.h ('k') | webrtc/video/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698