| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 AddressMap::iterator iter = connections_.begin(); | 209 AddressMap::iterator iter = connections_.begin(); |
| 210 while (iter != connections_.end()) { | 210 while (iter != connections_.end()) { |
| 211 list.push_back(iter->second); | 211 list.push_back(iter->second); |
| 212 ++iter; | 212 ++iter; |
| 213 } | 213 } |
| 214 | 214 |
| 215 for (uint32_t i = 0; i < list.size(); i++) | 215 for (uint32_t i = 0; i < list.size(); i++) |
| 216 delete list[i]; | 216 delete list[i]; |
| 217 } | 217 } |
| 218 | 218 |
| 219 Port::CloseAndSignalCandidateRemovals() { |
| 220 if (closed_) { |
| 221 return; |
| 222 } |
| 223 |
| 224 closed_ = true; |
| 225 SignalClosed(this); |
| 226 SignalCandidatesRemoved(this, candidates_); |
| 227 } |
| 228 |
| 219 void Port::SetIceParameters(int component, | 229 void Port::SetIceParameters(int component, |
| 220 const std::string& username_fragment, | 230 const std::string& username_fragment, |
| 221 const std::string& password) { | 231 const std::string& password) { |
| 222 component_ = component; | 232 component_ = component; |
| 223 ice_username_fragment_ = username_fragment; | 233 ice_username_fragment_ = username_fragment; |
| 224 password_ = password; | 234 password_ = password; |
| 225 for (Candidate& c : candidates_) { | 235 for (Candidate& c : candidates_) { |
| 226 c.set_component(component); | 236 c.set_component(component); |
| 227 c.set_username(username_fragment); | 237 c.set_username(username_fragment); |
| 228 c.set_password(password); | 238 c.set_password(password); |
| 229 } | 239 } |
| 230 } | 240 } |
| 231 | 241 |
| 232 Connection* Port::GetConnection(const rtc::SocketAddress& remote_addr) { | 242 Connection* Port::GetConnection(const rtc::SocketAddress& remote_addr) { |
| 233 AddressMap::const_iterator iter = connections_.find(remote_addr); | 243 AddressMap::const_iterator iter = connections_.find(remote_addr); |
| 234 if (iter != connections_.end()) | 244 if (iter != connections_.end()) |
| 235 return iter->second; | 245 return iter->second; |
| 236 else | 246 else |
| 237 return NULL; | 247 return NULL; |
| 238 } | 248 } |
| 239 | 249 |
| 250 void Port::FailAndDestroyConnections() { |
| 251 for (auto kv : connections_) { |
| 252 kv.second->FailAndDestroy(); |
| 253 } |
| 254 } |
| 255 |
| 240 void Port::AddAddress(const rtc::SocketAddress& address, | 256 void Port::AddAddress(const rtc::SocketAddress& address, |
| 241 const rtc::SocketAddress& base_address, | 257 const rtc::SocketAddress& base_address, |
| 242 const rtc::SocketAddress& related_address, | 258 const rtc::SocketAddress& related_address, |
| 243 const std::string& protocol, | 259 const std::string& protocol, |
| 244 const std::string& relay_protocol, | 260 const std::string& relay_protocol, |
| 245 const std::string& tcptype, | 261 const std::string& tcptype, |
| 246 const std::string& type, | 262 const std::string& type, |
| 247 uint32_t type_preference, | 263 uint32_t type_preference, |
| 248 uint32_t relay_preference, | 264 uint32_t relay_preference, |
| 249 bool final) { | 265 bool final) { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 661 |
| 646 void Port::OnMessage(rtc::Message *pmsg) { | 662 void Port::OnMessage(rtc::Message *pmsg) { |
| 647 ASSERT(pmsg->message_id == MSG_DEAD); | 663 ASSERT(pmsg->message_id == MSG_DEAD); |
| 648 if (dead()) { | 664 if (dead()) { |
| 649 Destroy(); | 665 Destroy(); |
| 650 } | 666 } |
| 651 } | 667 } |
| 652 | 668 |
| 653 void Port::OnNetworkInactive(const rtc::Network* network) { | 669 void Port::OnNetworkInactive(const rtc::Network* network) { |
| 654 ASSERT(network == network_); | 670 ASSERT(network == network_); |
| 655 SignalNetworkInactive(this); | 671 CloseAndSignalCandidateRemovals(); |
| 656 } | 672 } |
| 657 | 673 |
| 658 void Port::OnNetworkTypeChanged(const rtc::Network* network) { | 674 void Port::OnNetworkTypeChanged(const rtc::Network* network) { |
| 659 ASSERT(network == network_); | 675 ASSERT(network == network_); |
| 660 | 676 |
| 661 UpdateNetworkCost(); | 677 UpdateNetworkCost(); |
| 662 } | 678 } |
| 663 | 679 |
| 664 std::string Port::ToString() const { | 680 std::string Port::ToString() const { |
| 665 std::stringstream ss; | 681 std::stringstream ss; |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 ASSERT(sent < 0); | 1524 ASSERT(sent < 0); |
| 1509 error_ = port_->GetError(); | 1525 error_ = port_->GetError(); |
| 1510 stats_.sent_discarded_packets++; | 1526 stats_.sent_discarded_packets++; |
| 1511 } else { | 1527 } else { |
| 1512 send_rate_tracker_.AddSamples(sent); | 1528 send_rate_tracker_.AddSamples(sent); |
| 1513 } | 1529 } |
| 1514 return sent; | 1530 return sent; |
| 1515 } | 1531 } |
| 1516 | 1532 |
| 1517 } // namespace cricket | 1533 } // namespace cricket |
| OLD | NEW |