OLD | NEW |
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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 LOG_J(LS_VERBOSE, this) << "set_state"; | 917 LOG_J(LS_VERBOSE, this) << "set_state"; |
918 } | 918 } |
919 } | 919 } |
920 | 920 |
921 void Connection::set_connected(bool value) { | 921 void Connection::set_connected(bool value) { |
922 bool old_value = connected_; | 922 bool old_value = connected_; |
923 connected_ = value; | 923 connected_ = value; |
924 if (value != old_value) { | 924 if (value != old_value) { |
925 LOG_J(LS_VERBOSE, this) << "set_connected from: " << old_value << " to " | 925 LOG_J(LS_VERBOSE, this) << "set_connected from: " << old_value << " to " |
926 << value; | 926 << value; |
| 927 SignalStateChange(this); |
927 } | 928 } |
928 } | 929 } |
929 | 930 |
930 void Connection::set_use_candidate_attr(bool enable) { | 931 void Connection::set_use_candidate_attr(bool enable) { |
931 use_candidate_attr_ = enable; | 932 use_candidate_attr_ = enable; |
932 } | 933 } |
933 | 934 |
934 void Connection::OnSendStunPacket(const void* data, size_t size, | 935 void Connection::OnSendStunPacket(const void* data, size_t size, |
935 StunRequest* req) { | 936 StunRequest* req) { |
936 rtc::PacketOptions options(port_->DefaultDscpValue()); | 937 rtc::PacketOptions options(port_->DefaultDscpValue()); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 return false; | 1227 return false; |
1227 } | 1228 } |
1228 | 1229 |
1229 // If it has never received anything and is not actively pinging (pruned), we | 1230 // If it has never received anything and is not actively pinging (pruned), we |
1230 // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections | 1231 // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections |
1231 // from being pruned too quickly during a network change event when two | 1232 // from being pruned too quickly during a network change event when two |
1232 // networks would be up simultaneously but only for a brief period. | 1233 // networks would be up simultaneously but only for a brief period. |
1233 return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME); | 1234 return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME); |
1234 } | 1235 } |
1235 | 1236 |
1236 bool Connection::stable(int64_t now) { | 1237 bool Connection::stable(int64_t now) const { |
1237 // A connection is stable if it's RTT has converged and it isn't missing any | 1238 // A connection is stable if it's RTT has converged and it isn't missing any |
1238 // responses. We should send pings at a higher rate until the RTT converges | 1239 // responses. We should send pings at a higher rate until the RTT converges |
1239 // and whenever a ping response is missing (so that we can detect | 1240 // and whenever a ping response is missing (so that we can detect |
1240 // unwritability faster) | 1241 // unwritability faster) |
1241 return rtt_converged() && !missing_responses(now); | 1242 return rtt_converged() && !missing_responses(now); |
1242 } | 1243 } |
1243 | 1244 |
1244 std::string Connection::ToDebugId() const { | 1245 std::string Connection::ToDebugId() const { |
1245 std::stringstream ss; | 1246 std::stringstream ss; |
1246 ss << std::hex << this; | 1247 ss << std::hex << this; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 new_local_candidate.set_network_cost(local_candidate().network_cost()); | 1499 new_local_candidate.set_network_cost(local_candidate().network_cost()); |
1499 | 1500 |
1500 // Change the local candidate of this Connection to the new prflx candidate. | 1501 // Change the local candidate of this Connection to the new prflx candidate. |
1501 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); | 1502 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); |
1502 | 1503 |
1503 // SignalStateChange to force a re-sort in P2PTransportChannel as this | 1504 // SignalStateChange to force a re-sort in P2PTransportChannel as this |
1504 // Connection's local candidate has changed. | 1505 // Connection's local candidate has changed. |
1505 SignalStateChange(this); | 1506 SignalStateChange(this); |
1506 } | 1507 } |
1507 | 1508 |
1508 bool Connection::rtt_converged() { | 1509 bool Connection::rtt_converged() const { |
1509 return rtt_samples_ > (RTT_RATIO + 1); | 1510 return rtt_samples_ > (RTT_RATIO + 1); |
1510 } | 1511 } |
1511 | 1512 |
1512 bool Connection::missing_responses(int64_t now) { | 1513 bool Connection::missing_responses(int64_t now) const { |
1513 if (pings_since_last_response_.empty()) { | 1514 if (pings_since_last_response_.empty()) { |
1514 return false; | 1515 return false; |
1515 } | 1516 } |
1516 | 1517 |
1517 int64_t waiting = now - pings_since_last_response_[0].sent_time; | 1518 int64_t waiting = now - pings_since_last_response_[0].sent_time; |
1518 return waiting > 2 * rtt(); | 1519 return waiting > 2 * rtt(); |
1519 } | 1520 } |
1520 | 1521 |
1521 ProxyConnection::ProxyConnection(Port* port, | 1522 ProxyConnection::ProxyConnection(Port* port, |
1522 size_t index, | 1523 size_t index, |
(...skipping 13 matching lines...) Expand all Loading... |
1536 ASSERT(sent < 0); | 1537 ASSERT(sent < 0); |
1537 error_ = port_->GetError(); | 1538 error_ = port_->GetError(); |
1538 stats_.sent_discarded_packets++; | 1539 stats_.sent_discarded_packets++; |
1539 } else { | 1540 } else { |
1540 send_rate_tracker_.AddSamples(sent); | 1541 send_rate_tracker_.AddSamples(sent); |
1541 } | 1542 } |
1542 return sent; | 1543 return sent; |
1543 } | 1544 } |
1544 | 1545 |
1545 } // namespace cricket | 1546 } // namespace cricket |
OLD | NEW |