OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 455 |
456 // Create an entry, if needed, so we can get our permissions set up correctly. | 456 // Create an entry, if needed, so we can get our permissions set up correctly. |
457 CreateOrRefreshEntry(address.address()); | 457 CreateOrRefreshEntry(address.address()); |
458 | 458 |
459 // A TURN port will have two candiates, STUN and TURN. STUN may not | 459 // A TURN port will have two candiates, STUN and TURN. STUN may not |
460 // present in all cases. If present stun candidate will be added first | 460 // present in all cases. If present stun candidate will be added first |
461 // and TURN candidate later. | 461 // and TURN candidate later. |
462 for (size_t index = 0; index < Candidates().size(); ++index) { | 462 for (size_t index = 0; index < Candidates().size(); ++index) { |
463 if (Candidates()[index].type() == RELAY_PORT_TYPE) { | 463 if (Candidates()[index].type() == RELAY_PORT_TYPE) { |
464 ProxyConnection* conn = new ProxyConnection(this, index, address); | 464 ProxyConnection* conn = new ProxyConnection(this, index, address); |
465 conn->SignalDestroyed.connect(this, &TurnPort::OnConnectionDestroyed); | 465 AddOrReplaceConnection(conn); |
466 AddConnection(conn); | |
467 return conn; | 466 return conn; |
468 } | 467 } |
469 } | 468 } |
470 return NULL; | 469 return NULL; |
471 } | 470 } |
472 | 471 |
473 bool TurnPort::DestroyConnection(const rtc::SocketAddress& address) { | 472 bool TurnPort::DestroyConnection(const rtc::SocketAddress& address) { |
474 Connection* conn = GetConnection(address); | 473 Connection* conn = GetConnection(address); |
475 if (conn != nullptr) { | 474 if (conn != nullptr) { |
476 conn->Destroy(); | 475 conn->Destroy(); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 void TurnPort::DestroyEntryIfNotCancelled(TurnEntry* entry, int64_t timestamp) { | 1005 void TurnPort::DestroyEntryIfNotCancelled(TurnEntry* entry, int64_t timestamp) { |
1007 if (!EntryExists(entry)) { | 1006 if (!EntryExists(entry)) { |
1008 return; | 1007 return; |
1009 } | 1008 } |
1010 bool cancelled = timestamp != entry->destruction_timestamp(); | 1009 bool cancelled = timestamp != entry->destruction_timestamp(); |
1011 if (!cancelled) { | 1010 if (!cancelled) { |
1012 DestroyEntry(entry); | 1011 DestroyEntry(entry); |
1013 } | 1012 } |
1014 } | 1013 } |
1015 | 1014 |
1016 void TurnPort::OnConnectionDestroyed(Connection* conn) { | 1015 void TurnPort::HandleConnectionDestroyed(Connection* conn) { |
1017 // Schedule an event to destroy TurnEntry for the connection, which is | 1016 // Schedule an event to destroy TurnEntry for the connection, which is |
1018 // already destroyed. | 1017 // already destroyed. |
1019 const rtc::SocketAddress& remote_address = conn->remote_candidate().address(); | 1018 const rtc::SocketAddress& remote_address = conn->remote_candidate().address(); |
1020 TurnEntry* entry = FindEntry(remote_address); | 1019 TurnEntry* entry = FindEntry(remote_address); |
1021 ASSERT(entry != NULL); | 1020 ASSERT(entry != NULL); |
1022 ScheduleEntryDestruction(entry); | 1021 ScheduleEntryDestruction(entry); |
1023 } | 1022 } |
1024 | 1023 |
1025 void TurnPort::ScheduleEntryDestruction(TurnEntry* entry) { | 1024 void TurnPort::ScheduleEntryDestruction(TurnEntry* entry) { |
1026 ASSERT(entry->destruction_timestamp() == 0); | 1025 ASSERT(entry->destruction_timestamp() == 0); |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 } else { | 1524 } else { |
1526 state_ = STATE_UNBOUND; | 1525 state_ = STATE_UNBOUND; |
1527 port_->DestroyConnection(ext_addr_); | 1526 port_->DestroyConnection(ext_addr_); |
1528 } | 1527 } |
1529 } | 1528 } |
1530 void TurnEntry::OnChannelBindTimeout() { | 1529 void TurnEntry::OnChannelBindTimeout() { |
1531 state_ = STATE_UNBOUND; | 1530 state_ = STATE_UNBOUND; |
1532 port_->DestroyConnection(ext_addr_); | 1531 port_->DestroyConnection(ext_addr_); |
1533 } | 1532 } |
1534 } // namespace cricket | 1533 } // namespace cricket |
OLD | NEW |