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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 const char TCPTYPE_ACTIVE_STR[] = "active"; | 113 const char TCPTYPE_ACTIVE_STR[] = "active"; |
114 const char TCPTYPE_PASSIVE_STR[] = "passive"; | 114 const char TCPTYPE_PASSIVE_STR[] = "passive"; |
115 const char TCPTYPE_SIMOPEN_STR[] = "so"; | 115 const char TCPTYPE_SIMOPEN_STR[] = "so"; |
116 | 116 |
117 // Foundation: An arbitrary string that is the same for two candidates | 117 // Foundation: An arbitrary string that is the same for two candidates |
118 // that have the same type, base IP address, protocol (UDP, TCP, | 118 // that have the same type, base IP address, protocol (UDP, TCP, |
119 // etc.), and STUN or TURN server. If any of these are different, | 119 // etc.), and STUN or TURN server. If any of these are different, |
120 // then the foundation will be different. Two candidate pairs with | 120 // then the foundation will be different. Two candidate pairs with |
121 // the same foundation pairs are likely to have similar network | 121 // the same foundation pairs are likely to have similar network |
122 // characteristics. Foundations are used in the frozen algorithm. | 122 // characteristics. Foundations are used in the frozen algorithm. |
123 static std::string ComputeFoundation( | 123 static std::string ComputeFoundation(const std::string& type, |
124 const std::string& type, | 124 const std::string& protocol, |
125 const std::string& protocol, | 125 const std::string& relay_protocol, |
126 const rtc::SocketAddress& base_address) { | 126 const rtc::SocketAddress& base_address) { |
127 std::ostringstream ost; | 127 std::ostringstream ost; |
128 ost << type << base_address.ipaddr().ToString() << protocol; | 128 ost << type << base_address.ipaddr().ToString() << protocol << relay_protocol; |
129 return rtc::ToString<uint32_t>(rtc::ComputeCrc32(ost.str())); | 129 return rtc::ToString<uint32_t>(rtc::ComputeCrc32(ost.str())); |
130 } | 130 } |
131 | 131 |
132 Port::Port(rtc::Thread* thread, | 132 Port::Port(rtc::Thread* thread, |
133 rtc::PacketSocketFactory* factory, | 133 rtc::PacketSocketFactory* factory, |
134 rtc::Network* network, | 134 rtc::Network* network, |
135 const rtc::IPAddress& ip, | 135 const rtc::IPAddress& ip, |
136 const std::string& username_fragment, | 136 const std::string& username_fragment, |
137 const std::string& password) | 137 const std::string& password) |
138 : thread_(thread), | 138 : thread_(thread), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 c.set_tcptype(tcptype); | 245 c.set_tcptype(tcptype); |
246 c.set_address(address); | 246 c.set_address(address); |
247 c.set_priority(c.GetPriority(type_preference, network_->preference(), | 247 c.set_priority(c.GetPriority(type_preference, network_->preference(), |
248 relay_preference)); | 248 relay_preference)); |
249 c.set_username(username_fragment()); | 249 c.set_username(username_fragment()); |
250 c.set_password(password_); | 250 c.set_password(password_); |
251 c.set_network_name(network_->name()); | 251 c.set_network_name(network_->name()); |
252 c.set_network_type(network_->type()); | 252 c.set_network_type(network_->type()); |
253 c.set_generation(generation_); | 253 c.set_generation(generation_); |
254 c.set_related_address(related_address); | 254 c.set_related_address(related_address); |
255 c.set_foundation(ComputeFoundation(type, protocol, base_address)); | 255 c.set_foundation( |
| 256 ComputeFoundation(type, protocol, relay_protocol, base_address)); |
256 candidates_.push_back(c); | 257 candidates_.push_back(c); |
257 SignalCandidateReady(this, c); | 258 SignalCandidateReady(this, c); |
258 | 259 |
259 if (final) { | 260 if (final) { |
260 SignalPortComplete(this); | 261 SignalPortComplete(this); |
261 } | 262 } |
262 } | 263 } |
263 | 264 |
264 void Port::AddConnection(Connection* conn) { | 265 void Port::AddConnection(Connection* conn) { |
265 connections_[conn->remote_candidate().address()] = conn; | 266 connections_[conn->remote_candidate().address()] = conn; |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 new_local_candidate.set_component(local_candidate().component()); | 1383 new_local_candidate.set_component(local_candidate().component()); |
1383 new_local_candidate.set_type(PRFLX_PORT_TYPE); | 1384 new_local_candidate.set_type(PRFLX_PORT_TYPE); |
1384 new_local_candidate.set_protocol(local_candidate().protocol()); | 1385 new_local_candidate.set_protocol(local_candidate().protocol()); |
1385 new_local_candidate.set_address(addr->GetAddress()); | 1386 new_local_candidate.set_address(addr->GetAddress()); |
1386 new_local_candidate.set_priority(priority); | 1387 new_local_candidate.set_priority(priority); |
1387 new_local_candidate.set_username(local_candidate().username()); | 1388 new_local_candidate.set_username(local_candidate().username()); |
1388 new_local_candidate.set_password(local_candidate().password()); | 1389 new_local_candidate.set_password(local_candidate().password()); |
1389 new_local_candidate.set_network_name(local_candidate().network_name()); | 1390 new_local_candidate.set_network_name(local_candidate().network_name()); |
1390 new_local_candidate.set_network_type(local_candidate().network_type()); | 1391 new_local_candidate.set_network_type(local_candidate().network_type()); |
1391 new_local_candidate.set_related_address(local_candidate().address()); | 1392 new_local_candidate.set_related_address(local_candidate().address()); |
1392 new_local_candidate.set_foundation( | 1393 new_local_candidate.set_foundation(ComputeFoundation( |
1393 ComputeFoundation(PRFLX_PORT_TYPE, local_candidate().protocol(), | 1394 PRFLX_PORT_TYPE, local_candidate().protocol(), |
1394 local_candidate().address())); | 1395 local_candidate().relay_protocol(), local_candidate().address())); |
1395 | 1396 |
1396 // Change the local candidate of this Connection to the new prflx candidate. | 1397 // Change the local candidate of this Connection to the new prflx candidate. |
1397 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); | 1398 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); |
1398 | 1399 |
1399 // SignalStateChange to force a re-sort in P2PTransportChannel as this | 1400 // SignalStateChange to force a re-sort in P2PTransportChannel as this |
1400 // Connection's local candidate has changed. | 1401 // Connection's local candidate has changed. |
1401 SignalStateChange(this); | 1402 SignalStateChange(this); |
1402 } | 1403 } |
1403 | 1404 |
1404 ProxyConnection::ProxyConnection(Port* port, | 1405 ProxyConnection::ProxyConnection(Port* port, |
(...skipping 14 matching lines...) Expand all Loading... |
1419 ASSERT(sent < 0); | 1420 ASSERT(sent < 0); |
1420 error_ = port_->GetError(); | 1421 error_ = port_->GetError(); |
1421 sent_packets_discarded_++; | 1422 sent_packets_discarded_++; |
1422 } else { | 1423 } else { |
1423 send_rate_tracker_.AddSamples(sent); | 1424 send_rate_tracker_.AddSamples(sent); |
1424 } | 1425 } |
1425 return sent; | 1426 return sent; |
1426 } | 1427 } |
1427 | 1428 |
1428 } // namespace cricket | 1429 } // namespace cricket |
OLD | NEW |