Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2111663003: Revert of Add config to prune TURN ports (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 // Add the allocator session to our list so that we know which sessions 120 // Add the allocator session to our list so that we know which sessions
121 // are still active. 121 // are still active.
122 void P2PTransportChannel::AddAllocatorSession( 122 void P2PTransportChannel::AddAllocatorSession(
123 std::unique_ptr<PortAllocatorSession> session) { 123 std::unique_ptr<PortAllocatorSession> session) {
124 ASSERT(worker_thread_ == rtc::Thread::Current()); 124 ASSERT(worker_thread_ == rtc::Thread::Current());
125 125
126 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size())); 126 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
127 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); 127 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
128 session->SignalPortPruned.connect(this, &P2PTransportChannel::OnPortPruned);
129 session->SignalCandidatesReady.connect( 128 session->SignalCandidatesReady.connect(
130 this, &P2PTransportChannel::OnCandidatesReady); 129 this, &P2PTransportChannel::OnCandidatesReady);
131 session->SignalCandidatesAllocationDone.connect( 130 session->SignalCandidatesAllocationDone.connect(
132 this, &P2PTransportChannel::OnCandidatesAllocationDone); 131 this, &P2PTransportChannel::OnCandidatesAllocationDone);
133 132
134 // We now only want to apply new candidates that we receive to the ports 133 // We now only want to apply new candidates that we receive to the ports
135 // created by this new session because these are replacing those of the 134 // created by this new session because these are replacing those of the
136 // previous sessions. 135 // previous sessions.
137 removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end()); 136 removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end());
138 ports_.clear(); 137 ports_.clear();
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 // connection attempts. 1598 // connection attempts.
1600 void P2PTransportChannel::OnPortDestroyed(PortInterface* port) { 1599 void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
1601 ASSERT(worker_thread_ == rtc::Thread::Current()); 1600 ASSERT(worker_thread_ == rtc::Thread::Current());
1602 1601
1603 // Remove this port from the lists (if we didn't drop it already). 1602 // Remove this port from the lists (if we didn't drop it already).
1604 ports_.erase(std::remove(ports_.begin(), ports_.end(), port), ports_.end()); 1603 ports_.erase(std::remove(ports_.begin(), ports_.end(), port), ports_.end());
1605 removed_ports_.erase( 1604 removed_ports_.erase(
1606 std::remove(removed_ports_.begin(), removed_ports_.end(), port), 1605 std::remove(removed_ports_.begin(), removed_ports_.end(), port),
1607 removed_ports_.end()); 1606 removed_ports_.end());
1608 1607
1609 LOG(INFO) << "Removed port because it is destroyed: " 1608 LOG(INFO) << "Removed port from p2p socket: "
1610 << static_cast<int>(ports_.size()) << " remaining"; 1609 << static_cast<int>(ports_.size()) << " remaining";
1611 } 1610 }
1612 1611
1613 void P2PTransportChannel::OnPortNetworkInactive(PortInterface* port) { 1612 void P2PTransportChannel::OnPortNetworkInactive(PortInterface* port) {
1614 // If it does not gather continually, the port will be removed from the list 1613 // If it does not gather continually, the port will be removed from the list
1615 // when ICE restarts. 1614 // when ICE restarts.
1616 if (!config_.gather_continually) { 1615 if (!config_.gather_continually) {
1617 return; 1616 return;
1618 } 1617 }
1619 if (!RemovePort(port)) { 1618 auto it = std::find(ports_.begin(), ports_.end(), port);
1619 // Don't need to do anything if the port has been deleted from the port list.
1620 if (it == ports_.end()) {
1620 return; 1621 return;
1621 } 1622 }
1622 LOG(INFO) << "Removed port because its network is inactive : " 1623 removed_ports_.push_back(*it);
1623 << port->ToString() << " " << ports_.size() << " remaining"; 1624 ports_.erase(it);
1625 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size()
1626 << " remaining";
1624 std::vector<Candidate> candidates = port->Candidates(); 1627 std::vector<Candidate> candidates = port->Candidates();
1625 for (Candidate& candidate : candidates) { 1628 for (Candidate& candidate : candidates) {
1626 candidate.set_transport_name(transport_name()); 1629 candidate.set_transport_name(transport_name());
1627 } 1630 }
1628 SignalCandidatesRemoved(this, candidates); 1631 SignalCandidatesRemoved(this, candidates);
1629 } 1632 }
1630 1633
1631 void P2PTransportChannel::OnPortPruned(PortAllocatorSession* session,
1632 PortInterface* port) {
1633 if (RemovePort(port)) {
1634 LOG(INFO) << "Removed port because it is pruned: " << port->ToString()
1635 << " " << ports_.size() << " remaining";
1636 }
1637 }
1638
1639 bool P2PTransportChannel::RemovePort(PortInterface* port) {
1640 auto it = std::find(ports_.begin(), ports_.end(), port);
1641 // Don't need to do anything if the port has been deleted from the port list.
1642 if (it == ports_.end()) {
1643 return false;
1644 }
1645 ports_.erase(it);
1646 removed_ports_.push_back(port);
1647 return true;
1648 }
1649
1650 // We data is available, let listeners know 1634 // We data is available, let listeners know
1651 void P2PTransportChannel::OnReadPacket(Connection* connection, 1635 void P2PTransportChannel::OnReadPacket(Connection* connection,
1652 const char* data, 1636 const char* data,
1653 size_t len, 1637 size_t len,
1654 const rtc::PacketTime& packet_time) { 1638 const rtc::PacketTime& packet_time) {
1655 ASSERT(worker_thread_ == rtc::Thread::Current()); 1639 ASSERT(worker_thread_ == rtc::Thread::Current());
1656 1640
1657 // Do not deliver, if packet doesn't belong to the correct transport channel. 1641 // Do not deliver, if packet doesn't belong to the correct transport channel.
1658 if (!FindConnection(connection)) 1642 if (!FindConnection(connection))
1659 return; 1643 return;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 1778
1795 // During the initial state when nothing has been pinged yet, return the first 1779 // During the initial state when nothing has been pinged yet, return the first
1796 // one in the ordered |connections_|. 1780 // one in the ordered |connections_|.
1797 return *(std::find_if(connections_.begin(), connections_.end(), 1781 return *(std::find_if(connections_.begin(), connections_.end(),
1798 [conn1, conn2](Connection* conn) { 1782 [conn1, conn2](Connection* conn) {
1799 return conn == conn1 || conn == conn2; 1783 return conn == conn1 || conn == conn2;
1800 })); 1784 }));
1801 } 1785 }
1802 1786
1803 } // namespace cricket 1787 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698