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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2232563002: Do not switch to a high-cost connection that is not receiving (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix comments Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // and the last data received time. This prevents the controlled side from 176 // and the last data received time. This prevents the controlled side from
177 // switching the selected connection too frequently when the controlling side 177 // switching the selected connection too frequently when the controlling side
178 // is doing aggressive nominations. The precedence of the connection switching 178 // is doing aggressive nominations. The precedence of the connection switching
179 // criteria is as follows: 179 // criteria is as follows:
180 // i) write/receiving/connected states 180 // i) write/receiving/connected states
181 // ii) For controlled side, 181 // ii) For controlled side,
182 // a) nomination state, 182 // a) nomination state,
183 // b) last data received time. 183 // b) last data received time.
184 // iii) Lower cost / higher priority. 184 // iii) Lower cost / higher priority.
185 // iv) rtt. 185 // iv) rtt.
186 // To further prevent switching to high-cost networks, does not switch to
187 // a high-cost connection if it is not receiving.
186 // TODO(honghaiz): Stop the aggressive nomination on the controlling side and 188 // TODO(honghaiz): Stop the aggressive nomination on the controlling side and
187 // implement the ice-renomination option. 189 // implement the ice-renomination option.
188 bool P2PTransportChannel::ShouldSwitchSelectedConnection( 190 bool P2PTransportChannel::ShouldSwitchSelectedConnection(
189 Connection* new_connection, 191 Connection* new_connection,
190 bool* missed_receiving_unchanged_threshold) const { 192 bool* missed_receiving_unchanged_threshold) const {
191 if (!new_connection || selected_connection_ == new_connection) { 193 if (!new_connection || selected_connection_ == new_connection) {
192 return false; 194 return false;
193 } 195 }
194 196
195 if (selected_connection_ == nullptr) { 197 if (selected_connection_ == nullptr) {
196 return true; 198 return true;
197 } 199 }
198 200
201 // Do not switch to a connection that is not receiving if it has higher cost
202 // because it may be just spuriously better.
203 if (new_connection->ComputeNetworkCost() >
204 selected_connection_->ComputeNetworkCost() &&
205 !new_connection->receiving()) {
206 return false;
207 }
208
199 rtc::Optional<int64_t> receiving_unchanged_threshold( 209 rtc::Optional<int64_t> receiving_unchanged_threshold(
200 rtc::TimeMillis() - config_.receiving_switching_delay.value_or(0)); 210 rtc::TimeMillis() - config_.receiving_switching_delay.value_or(0));
201 int cmp = CompareConnections(selected_connection_, new_connection, 211 int cmp = CompareConnections(selected_connection_, new_connection,
202 receiving_unchanged_threshold, 212 receiving_unchanged_threshold,
203 missed_receiving_unchanged_threshold); 213 missed_receiving_unchanged_threshold);
204 if (cmp != 0) { 214 if (cmp != 0) {
205 return cmp < 0; 215 return cmp < 0;
206 } 216 }
207 217
208 // If everything else is the same, switch only if rtt has improved by 218 // If everything else is the same, switch only if rtt has improved by
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 1939
1930 // During the initial state when nothing has been pinged yet, return the first 1940 // During the initial state when nothing has been pinged yet, return the first
1931 // one in the ordered |connections_|. 1941 // one in the ordered |connections_|.
1932 return *(std::find_if(connections_.begin(), connections_.end(), 1942 return *(std::find_if(connections_.begin(), connections_.end(),
1933 [conn1, conn2](Connection* conn) { 1943 [conn1, conn2](Connection* conn) {
1934 return conn == conn1 || conn == conn2; 1944 return conn == conn1 || conn == conn2;
1935 })); 1945 }));
1936 } 1946 }
1937 1947
1938 } // namespace cricket 1948 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698