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

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

Issue 1648813004: Remove candidates when doing continual gathering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: small fixes Created 4 years, 9 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
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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 } 754 }
755 } 755 }
756 756
757 // Create connections to this remote candidate. 757 // Create connections to this remote candidate.
758 CreateConnections(new_remote_candidate, NULL); 758 CreateConnections(new_remote_candidate, NULL);
759 759
760 // Resort the connections list, which may have new elements. 760 // Resort the connections list, which may have new elements.
761 SortConnections(); 761 SortConnections();
762 } 762 }
763 763
764 void P2PTransportChannel::RemoveRemoteCandidate(
765 const Candidate& cand_to_remove) {
766 auto iter =
767 std::remove_if(remote_candidates_.begin(), remote_candidates_.end(),
768 [cand_to_remove](const Candidate& candidate) {
769 return cand_to_remove.MatchesForRemoval(candidate);
770 });
771 if (iter != remote_candidates_.end()) {
772 LOG(LS_VERBOSE) << "Removed remote candidate " << cand_to_remove.ToString();
773 remote_candidates_.erase(iter, remote_candidates_.end());
774 }
775 }
776
764 // Creates connections from all of the ports that we care about to the given 777 // Creates connections from all of the ports that we care about to the given
765 // remote candidate. The return value is true if we created a connection from 778 // remote candidate. The return value is true if we created a connection from
766 // the origin port. 779 // the origin port.
767 bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate, 780 bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate,
768 PortInterface* origin_port) { 781 PortInterface* origin_port) {
769 ASSERT(worker_thread_ == rtc::Thread::Current()); 782 ASSERT(worker_thread_ == rtc::Thread::Current());
770 783
771 // If we've already seen the new remote candidate (in the current candidate 784 // If we've already seen the new remote candidate (in the current candidate
772 // generation), then we shouldn't try creating connections for it. 785 // generation), then we shouldn't try creating connections for it.
773 // We either already have a connection for it, or we previously created one 786 // We either already have a connection for it, or we previously created one
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 return; 1453 return;
1441 } 1454 }
1442 auto it = std::find(ports_.begin(), ports_.end(), port); 1455 auto it = std::find(ports_.begin(), ports_.end(), port);
1443 // Don't need to do anything if the port has been deleted from the port list. 1456 // Don't need to do anything if the port has been deleted from the port list.
1444 if (it == ports_.end()) { 1457 if (it == ports_.end()) {
1445 return; 1458 return;
1446 } 1459 }
1447 ports_.erase(it); 1460 ports_.erase(it);
1448 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() 1461 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size()
1449 << " remaining"; 1462 << " remaining";
1450 // TODO(honghaiz): Signal candidate removals to the remote side. 1463 std::vector<Candidate> candidates = port->Candidates();
1464 for (Candidate& candidate : candidates) {
1465 candidate.set_transport_name(transport_name());
1466 }
1467 SignalCandidatesRemoved(this, candidates);
1451 } 1468 }
1452 1469
1453 // We data is available, let listeners know 1470 // We data is available, let listeners know
1454 void P2PTransportChannel::OnReadPacket(Connection* connection, 1471 void P2PTransportChannel::OnReadPacket(Connection* connection,
1455 const char* data, 1472 const char* data,
1456 size_t len, 1473 size_t len,
1457 const rtc::PacketTime& packet_time) { 1474 const rtc::PacketTime& packet_time) {
1458 ASSERT(worker_thread_ == rtc::Thread::Current()); 1475 ASSERT(worker_thread_ == rtc::Thread::Current());
1459 1476
1460 // Do not deliver, if packet doesn't belong to the correct transport channel. 1477 // Do not deliver, if packet doesn't belong to the correct transport channel.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 1612
1596 // During the initial state when nothing has been pinged yet, return the first 1613 // During the initial state when nothing has been pinged yet, return the first
1597 // one in the ordered |connections_|. 1614 // one in the ordered |connections_|.
1598 return *(std::find_if(connections_.begin(), connections_.end(), 1615 return *(std::find_if(connections_.begin(), connections_.end(),
1599 [conn1, conn2](Connection* conn) { 1616 [conn1, conn2](Connection* conn) {
1600 return conn == conn1 || conn == conn2; 1617 return conn == conn1 || conn == conn2;
1601 })); 1618 }));
1602 } 1619 }
1603 1620
1604 } // namespace cricket 1621 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698