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

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

Issue 1696933003: When doing continual gathering, remove local candidates when a network is dropped. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix a type conversion error on Windows Created 4 years, 10 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
11 #include "webrtc/p2p/base/p2ptransportchannel.h" 11 #include "webrtc/p2p/base/p2ptransportchannel.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <set> 14 #include <set>
15 #include "webrtc/p2p/base/common.h" 15
16 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE.
17 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE.
18 #include "webrtc/base/common.h" 16 #include "webrtc/base/common.h"
19 #include "webrtc/base/crc32.h" 17 #include "webrtc/base/crc32.h"
20 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
21 #include "webrtc/base/stringencode.h" 19 #include "webrtc/base/stringencode.h"
20 #include "webrtc/p2p/base/candidate.h"
21 #include "webrtc/p2p/base/common.h"
22 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE.
23 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE.
22 #include "webrtc/system_wrappers/include/field_trial.h" 24 #include "webrtc/system_wrappers/include/field_trial.h"
23 25
24 namespace { 26 namespace {
25 27
26 // messages for queuing up work for ourselves 28 // messages for queuing up work for ourselves
27 enum { MSG_SORT = 1, MSG_CHECK_AND_PING }; 29 enum { MSG_SORT = 1, MSG_CHECK_AND_PING };
28 30
29 // The minimum improvement in RTT that justifies a switch. 31 // The minimum improvement in RTT that justifies a switch.
30 static const double kMinImprovement = 10; 32 static const double kMinImprovement = 10;
31 33
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // Remember the ports and candidates, and signal that candidates are ready. 459 // Remember the ports and candidates, and signal that candidates are ready.
458 // The session will handle this, and send an initiate/accept/modify message 460 // The session will handle this, and send an initiate/accept/modify message
459 // if one is pending. 461 // if one is pending.
460 462
461 port->SetIceRole(ice_role_); 463 port->SetIceRole(ice_role_);
462 port->SetIceTiebreaker(tiebreaker_); 464 port->SetIceTiebreaker(tiebreaker_);
463 ports_.push_back(port); 465 ports_.push_back(port);
464 port->SignalUnknownAddress.connect( 466 port->SignalUnknownAddress.connect(
465 this, &P2PTransportChannel::OnUnknownAddress); 467 this, &P2PTransportChannel::OnUnknownAddress);
466 port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed); 468 port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed);
469 port->SignalNetworkInactive.connect(
470 this, &P2PTransportChannel::OnPortNetworkInactive);
467 port->SignalRoleConflict.connect( 471 port->SignalRoleConflict.connect(
468 this, &P2PTransportChannel::OnRoleConflict); 472 this, &P2PTransportChannel::OnRoleConflict);
469 port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket); 473 port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket);
470 474
471 // Attempt to create a connection from this new port to all of the remote 475 // Attempt to create a connection from this new port to all of the remote
472 // candidates that we were given so far. 476 // candidates that we were given so far.
473 477
474 std::vector<RemoteCandidate>::iterator iter; 478 std::vector<RemoteCandidate>::iterator iter;
475 for (iter = remote_candidates_.begin(); iter != remote_candidates_.end(); 479 for (iter = remote_candidates_.begin(); iter != remote_candidates_.end();
476 ++iter) { 480 ++iter) {
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 // Remove this port from the list (if we didn't drop it already). 1412 // Remove this port from the list (if we didn't drop it already).
1409 std::vector<PortInterface*>::iterator iter = 1413 std::vector<PortInterface*>::iterator iter =
1410 std::find(ports_.begin(), ports_.end(), port); 1414 std::find(ports_.begin(), ports_.end(), port);
1411 if (iter != ports_.end()) 1415 if (iter != ports_.end())
1412 ports_.erase(iter); 1416 ports_.erase(iter);
1413 1417
1414 LOG(INFO) << "Removed port from p2p socket: " 1418 LOG(INFO) << "Removed port from p2p socket: "
1415 << static_cast<int>(ports_.size()) << " remaining"; 1419 << static_cast<int>(ports_.size()) << " remaining";
1416 } 1420 }
1417 1421
1422 void P2PTransportChannel::OnPortNetworkInactive(PortInterface* port) {
1423 // If it does not gather continually, the port will be removed from the list
1424 // when ICE restarts.
1425 if (!gather_continually_) {
1426 return;
1427 }
1428 auto it = std::find(ports_.begin(), ports_.end(), port);
1429 // Don't need to do anything if the port has been deleted from the port list.
1430 if (it == ports_.end()) {
1431 return;
1432 }
1433 ports_.erase(it);
1434 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size()
1435 << " remaining";
1436 // TODO(honghaiz): Signal candidate removals to the remote side.
1437 }
1438
1418 // We data is available, let listeners know 1439 // We data is available, let listeners know
1419 void P2PTransportChannel::OnReadPacket(Connection* connection, 1440 void P2PTransportChannel::OnReadPacket(Connection* connection,
1420 const char* data, 1441 const char* data,
1421 size_t len, 1442 size_t len,
1422 const rtc::PacketTime& packet_time) { 1443 const rtc::PacketTime& packet_time) {
1423 ASSERT(worker_thread_ == rtc::Thread::Current()); 1444 ASSERT(worker_thread_ == rtc::Thread::Current());
1424 1445
1425 // Do not deliver, if packet doesn't belong to the correct transport channel. 1446 // Do not deliver, if packet doesn't belong to the correct transport channel.
1426 if (!FindConnection(connection)) 1447 if (!FindConnection(connection))
1427 return; 1448 return;
(...skipping 15 matching lines...) Expand all
1443 SignalSentPacket(this, sent_packet); 1464 SignalSentPacket(this, sent_packet);
1444 } 1465 }
1445 1466
1446 void P2PTransportChannel::OnReadyToSend(Connection* connection) { 1467 void P2PTransportChannel::OnReadyToSend(Connection* connection) {
1447 if (connection == best_connection_ && writable()) { 1468 if (connection == best_connection_ && writable()) {
1448 SignalReadyToSend(this); 1469 SignalReadyToSend(this);
1449 } 1470 }
1450 } 1471 }
1451 1472
1452 } // namespace cricket 1473 } // 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