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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); | 138 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); |
139 session->SignalPortsRemoved.connect(this, | 139 session->SignalPortsRemoved.connect(this, |
140 &P2PTransportChannel::OnPortsRemoved); | 140 &P2PTransportChannel::OnPortsRemoved); |
141 session->SignalPortPruned.connect(this, &P2PTransportChannel::OnPortPruned); | 141 session->SignalPortPruned.connect(this, &P2PTransportChannel::OnPortPruned); |
142 session->SignalCandidatesReady.connect( | 142 session->SignalCandidatesReady.connect( |
143 this, &P2PTransportChannel::OnCandidatesReady); | 143 this, &P2PTransportChannel::OnCandidatesReady); |
144 session->SignalCandidatesRemoved.connect( | 144 session->SignalCandidatesRemoved.connect( |
145 this, &P2PTransportChannel::OnCandidatesRemoved); | 145 this, &P2PTransportChannel::OnCandidatesRemoved); |
146 session->SignalCandidatesAllocationDone.connect( | 146 session->SignalCandidatesAllocationDone.connect( |
147 this, &P2PTransportChannel::OnCandidatesAllocationDone); | 147 this, &P2PTransportChannel::OnCandidatesAllocationDone); |
148 allocator_sessions_.push_back(std::move(session)); | |
148 | 149 |
149 // We now only want to apply new candidates that we receive to the ports | 150 // We now only want to apply new candidates that we receive to the ports |
150 // created by this new session because these are replacing those of the | 151 // created by this new session because these are replacing those of the |
151 // previous sessions. | 152 // previous sessions. |
153 for (PortInterface* port : ports_) { | |
154 port->StopBeingUsed(); | |
155 } | |
pthatcher1
2016/07/27 18:33:15
for (PortAllocatorSession session : allocator_sess
honghaiz3
2016/07/28 01:22:49
Done. Only need to do the last one.
| |
152 removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end()); | 156 removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end()); |
153 ports_.clear(); | 157 ports_.clear(); |
pthatcher1
2016/07/27 18:33:15
Can we move this into a method called RemoveAllPor
honghaiz3
2016/07/28 01:22:49
You suggested a different name in another pending
| |
154 | |
155 allocator_sessions_.push_back(std::move(session)); | |
156 } | 158 } |
157 | 159 |
158 void P2PTransportChannel::AddConnection(Connection* connection) { | 160 void P2PTransportChannel::AddConnection(Connection* connection) { |
159 connections_.push_back(connection); | 161 connections_.push_back(connection); |
160 unpinged_connections_.insert(connection); | 162 unpinged_connections_.insert(connection); |
161 connection->set_remote_ice_mode(remote_ice_mode_); | 163 connection->set_remote_ice_mode(remote_ice_mode_); |
162 connection->set_receiving_timeout(config_.receiving_timeout); | 164 connection->set_receiving_timeout(config_.receiving_timeout); |
163 connection->SignalReadPacket.connect( | 165 connection->SignalReadPacket.connect( |
164 this, &P2PTransportChannel::OnReadPacket); | 166 this, &P2PTransportChannel::OnReadPacket); |
165 connection->SignalReadyToSend.connect( | 167 connection->SignalReadyToSend.connect( |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 << ") failed: " << port->GetError(); | 466 << ") failed: " << port->GetError(); |
465 } | 467 } |
466 } | 468 } |
467 | 469 |
468 // Remember the ports and candidates, and signal that candidates are ready. | 470 // Remember the ports and candidates, and signal that candidates are ready. |
469 // The session will handle this, and send an initiate/accept/modify message | 471 // The session will handle this, and send an initiate/accept/modify message |
470 // if one is pending. | 472 // if one is pending. |
471 | 473 |
472 port->SetIceRole(ice_role_); | 474 port->SetIceRole(ice_role_); |
473 port->SetIceTiebreaker(tiebreaker_); | 475 port->SetIceTiebreaker(tiebreaker_); |
476 port->StartBeingUsed(); | |
pthatcher1
2016/07/27 18:33:15
Like we mentioned in person, I think this could ei
honghaiz3
2016/07/28 01:22:49
Done.
| |
474 ports_.push_back(port); | 477 ports_.push_back(port); |
475 port->SignalUnknownAddress.connect( | 478 port->SignalUnknownAddress.connect( |
476 this, &P2PTransportChannel::OnUnknownAddress); | 479 this, &P2PTransportChannel::OnUnknownAddress); |
477 port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed); | 480 port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed); |
478 | 481 |
479 port->SignalRoleConflict.connect( | 482 port->SignalRoleConflict.connect( |
480 this, &P2PTransportChannel::OnRoleConflict); | 483 this, &P2PTransportChannel::OnRoleConflict); |
481 port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket); | 484 port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket); |
482 | 485 |
483 // Attempt to create a connection from this new port to all of the remote | 486 // Attempt to create a connection from this new port to all of the remote |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1739 } | 1742 } |
1740 | 1743 |
1741 bool P2PTransportChannel::RemovePort(PortInterface* port) { | 1744 bool P2PTransportChannel::RemovePort(PortInterface* port) { |
1742 auto it = std::find(ports_.begin(), ports_.end(), port); | 1745 auto it = std::find(ports_.begin(), ports_.end(), port); |
1743 // Don't need to do anything if the port has been deleted from the port list. | 1746 // Don't need to do anything if the port has been deleted from the port list. |
1744 if (it == ports_.end()) { | 1747 if (it == ports_.end()) { |
1745 return false; | 1748 return false; |
1746 } | 1749 } |
1747 ports_.erase(it); | 1750 ports_.erase(it); |
1748 removed_ports_.push_back(port); | 1751 removed_ports_.push_back(port); |
1752 port->StopBeingUsed(); | |
pthatcher1
2016/07/27 18:33:15
Like we talked about in person, having this be Por
honghaiz3
2016/07/28 01:22:49
Done.
| |
1749 return true; | 1753 return true; |
1750 } | 1754 } |
1751 | 1755 |
1752 // We data is available, let listeners know | 1756 // We data is available, let listeners know |
1753 void P2PTransportChannel::OnReadPacket(Connection* connection, | 1757 void P2PTransportChannel::OnReadPacket(Connection* connection, |
1754 const char* data, | 1758 const char* data, |
1755 size_t len, | 1759 size_t len, |
1756 const rtc::PacketTime& packet_time) { | 1760 const rtc::PacketTime& packet_time) { |
1757 ASSERT(worker_thread_ == rtc::Thread::Current()); | 1761 ASSERT(worker_thread_ == rtc::Thread::Current()); |
1758 | 1762 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1893 | 1897 |
1894 // During the initial state when nothing has been pinged yet, return the first | 1898 // During the initial state when nothing has been pinged yet, return the first |
1895 // one in the ordered |connections_|. | 1899 // one in the ordered |connections_|. |
1896 return *(std::find_if(connections_.begin(), connections_.end(), | 1900 return *(std::find_if(connections_.begin(), connections_.end(), |
1897 [conn1, conn2](Connection* conn) { | 1901 [conn1, conn2](Connection* conn) { |
1898 return conn == conn1 || conn == conn2; | 1902 return conn == conn1 || conn == conn2; |
1899 })); | 1903 })); |
1900 } | 1904 } |
1901 | 1905 |
1902 } // namespace cricket | 1906 } // namespace cricket |
OLD | NEW |