Chromium Code Reviews

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

Issue 2099563004: Start ICE connectivity checks as soon as the first pair is pingable. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removing debug log message, adding missing UpdateState. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/transport.h » ('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 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 908 matching lines...)
919 LOG_J(LS_VERBOSE, this) << "set_state"; 919 LOG_J(LS_VERBOSE, this) << "set_state";
920 } 920 }
921 } 921 }
922 922
923 void Connection::set_connected(bool value) { 923 void Connection::set_connected(bool value) {
924 bool old_value = connected_; 924 bool old_value = connected_;
925 connected_ = value; 925 connected_ = value;
926 if (value != old_value) { 926 if (value != old_value) {
927 LOG_J(LS_VERBOSE, this) << "set_connected from: " << old_value << " to " 927 LOG_J(LS_VERBOSE, this) << "set_connected from: " << old_value << " to "
928 << value; 928 << value;
929 SignalStateChange(this);
929 } 930 }
930 } 931 }
931 932
932 void Connection::set_use_candidate_attr(bool enable) { 933 void Connection::set_use_candidate_attr(bool enable) {
933 use_candidate_attr_ = enable; 934 use_candidate_attr_ = enable;
934 } 935 }
935 936
936 void Connection::OnSendStunPacket(const void* data, size_t size, 937 void Connection::OnSendStunPacket(const void* data, size_t size,
937 StunRequest* req) { 938 StunRequest* req) {
938 rtc::PacketOptions options(port_->DefaultDscpValue()); 939 rtc::PacketOptions options(port_->DefaultDscpValue());
(...skipping 289 matching lines...)
1228 return false; 1229 return false;
1229 } 1230 }
1230 1231
1231 // If it has never received anything and is not actively pinging (pruned), we 1232 // If it has never received anything and is not actively pinging (pruned), we
1232 // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections 1233 // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections
1233 // from being pruned too quickly during a network change event when two 1234 // from being pruned too quickly during a network change event when two
1234 // networks would be up simultaneously but only for a brief period. 1235 // networks would be up simultaneously but only for a brief period.
1235 return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME); 1236 return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME);
1236 } 1237 }
1237 1238
1238 bool Connection::stable(int64_t now) { 1239 bool Connection::stable(int64_t now) const {
1239 // A connection is stable if it's RTT has converged and it isn't missing any 1240 // A connection is stable if it's RTT has converged and it isn't missing any
1240 // responses. We should send pings at a higher rate until the RTT converges 1241 // responses. We should send pings at a higher rate until the RTT converges
1241 // and whenever a ping response is missing (so that we can detect 1242 // and whenever a ping response is missing (so that we can detect
1242 // unwritability faster) 1243 // unwritability faster)
1243 return rtt_converged() && !missing_responses(now); 1244 return rtt_converged() && !missing_responses(now);
1244 } 1245 }
1245 1246
1246 std::string Connection::ToDebugId() const { 1247 std::string Connection::ToDebugId() const {
1247 std::stringstream ss; 1248 std::stringstream ss;
1248 ss << std::hex << this; 1249 ss << std::hex << this;
(...skipping 251 matching lines...)
1500 new_local_candidate.set_network_cost(local_candidate().network_cost()); 1501 new_local_candidate.set_network_cost(local_candidate().network_cost());
1501 1502
1502 // Change the local candidate of this Connection to the new prflx candidate. 1503 // Change the local candidate of this Connection to the new prflx candidate.
1503 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); 1504 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate);
1504 1505
1505 // SignalStateChange to force a re-sort in P2PTransportChannel as this 1506 // SignalStateChange to force a re-sort in P2PTransportChannel as this
1506 // Connection's local candidate has changed. 1507 // Connection's local candidate has changed.
1507 SignalStateChange(this); 1508 SignalStateChange(this);
1508 } 1509 }
1509 1510
1510 bool Connection::rtt_converged() { 1511 bool Connection::rtt_converged() const {
1511 return rtt_samples_ > (RTT_RATIO + 1); 1512 return rtt_samples_ > (RTT_RATIO + 1);
1512 } 1513 }
1513 1514
1514 bool Connection::missing_responses(int64_t now) { 1515 bool Connection::missing_responses(int64_t now) const {
1515 if (pings_since_last_response_.empty()) { 1516 if (pings_since_last_response_.empty()) {
1516 return false; 1517 return false;
1517 } 1518 }
1518 1519
1519 int64_t waiting = now - pings_since_last_response_[0].sent_time; 1520 int64_t waiting = now - pings_since_last_response_[0].sent_time;
1520 return waiting > 2 * rtt(); 1521 return waiting > 2 * rtt();
1521 } 1522 }
1522 1523
1523 ProxyConnection::ProxyConnection(Port* port, 1524 ProxyConnection::ProxyConnection(Port* port,
1524 size_t index, 1525 size_t index,
1525 const Candidate& remote_candidate) 1526 const Candidate& remote_candidate)
1526 : Connection(port, index, remote_candidate) {} 1527 : Connection(port, index, remote_candidate) {}
1527 1528
1528 int ProxyConnection::Send(const void* data, size_t size, 1529 int ProxyConnection::Send(const void* data, size_t size,
1529 const rtc::PacketOptions& options) { 1530 const rtc::PacketOptions& options) {
1530 stats_.sent_total_packets++; 1531 stats_.sent_total_packets++;
1531 int sent = port_->SendTo(data, size, remote_candidate_.address(), 1532 int sent = port_->SendTo(data, size, remote_candidate_.address(),
1532 options, true); 1533 options, true);
1533 if (sent <= 0) { 1534 if (sent <= 0) {
1534 ASSERT(sent < 0); 1535 ASSERT(sent < 0);
1535 error_ = port_->GetError(); 1536 error_ = port_->GetError();
1536 stats_.sent_discarded_packets++; 1537 stats_.sent_discarded_packets++;
1537 } else { 1538 } else {
1538 send_rate_tracker_.AddSamples(sent); 1539 send_rate_tracker_.AddSamples(sent);
1539 } 1540 }
1540 return sent; 1541 return sent;
1541 } 1542 }
1542 1543
1543 } // namespace cricket 1544 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/transport.h » ('j') | no next file with comments »

Powered by Google App Engine