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 |
11 #include "webrtc/p2p/base/p2ptransportchannel.h" | 11 #include "webrtc/p2p/base/p2ptransportchannel.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <iterator> | 14 #include <iterator> |
15 #include <set> | 15 #include <set> |
16 | 16 |
17 #include "webrtc/api/peerconnectioninterface.h" | 17 #include "webrtc/api/peerconnectioninterface.h" |
| 18 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/common.h" | 19 #include "webrtc/base/common.h" |
19 #include "webrtc/base/crc32.h" | 20 #include "webrtc/base/crc32.h" |
20 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
21 #include "webrtc/base/stringencode.h" | 22 #include "webrtc/base/stringencode.h" |
22 #include "webrtc/p2p/base/candidate.h" | 23 #include "webrtc/p2p/base/candidate.h" |
23 #include "webrtc/p2p/base/candidatepairinterface.h" | 24 #include "webrtc/p2p/base/candidatepairinterface.h" |
24 #include "webrtc/p2p/base/common.h" | 25 #include "webrtc/p2p/base/common.h" |
25 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE. | 26 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE. |
26 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE. | 27 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE. |
27 #include "webrtc/system_wrappers/include/field_trial.h" | 28 #include "webrtc/system_wrappers/include/field_trial.h" |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // There shouldn't be an existing connection with this remote address. | 656 // There shouldn't be an existing connection with this remote address. |
656 // When ports are muxed, this channel might get multiple unknown address | 657 // When ports are muxed, this channel might get multiple unknown address |
657 // signals. In that case if the connection is already exists, we should | 658 // signals. In that case if the connection is already exists, we should |
658 // simply ignore the signal otherwise send server error. | 659 // simply ignore the signal otherwise send server error. |
659 if (port->GetConnection(remote_candidate.address())) { | 660 if (port->GetConnection(remote_candidate.address())) { |
660 if (port_muxed) { | 661 if (port_muxed) { |
661 LOG(LS_INFO) << "Connection already exists for peer reflexive " | 662 LOG(LS_INFO) << "Connection already exists for peer reflexive " |
662 << "candidate: " << remote_candidate.ToString(); | 663 << "candidate: " << remote_candidate.ToString(); |
663 return; | 664 return; |
664 } else { | 665 } else { |
665 ASSERT(false); | 666 RTC_NOTREACHED(); |
666 port->SendBindingErrorResponse(stun_msg, address, | 667 port->SendBindingErrorResponse(stun_msg, address, |
667 STUN_ERROR_SERVER_ERROR, | 668 STUN_ERROR_SERVER_ERROR, |
668 STUN_ERROR_REASON_SERVER_ERROR); | 669 STUN_ERROR_REASON_SERVER_ERROR); |
669 return; | 670 return; |
670 } | 671 } |
671 } | 672 } |
672 | 673 |
673 Connection* connection = | 674 Connection* connection = |
674 port->CreateConnection(remote_candidate, PortInterface::ORIGIN_THIS_PORT); | 675 port->CreateConnection(remote_candidate, PortInterface::ORIGIN_THIS_PORT); |
675 if (!connection) { | 676 if (!connection) { |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 case MSG_SORT_AND_UPDATE_STATE: | 1491 case MSG_SORT_AND_UPDATE_STATE: |
1491 SortConnectionsAndUpdateState(); | 1492 SortConnectionsAndUpdateState(); |
1492 break; | 1493 break; |
1493 case MSG_CHECK_AND_PING: | 1494 case MSG_CHECK_AND_PING: |
1494 OnCheckAndPing(); | 1495 OnCheckAndPing(); |
1495 break; | 1496 break; |
1496 case MSG_REGATHER_ON_FAILED_NETWORKS: | 1497 case MSG_REGATHER_ON_FAILED_NETWORKS: |
1497 OnRegatherOnFailedNetworks(); | 1498 OnRegatherOnFailedNetworks(); |
1498 break; | 1499 break; |
1499 default: | 1500 default: |
1500 ASSERT(false); | 1501 RTC_NOTREACHED(); |
1501 break; | 1502 break; |
1502 } | 1503 } |
1503 } | 1504 } |
1504 | 1505 |
1505 // Handle queued up check-and-ping request | 1506 // Handle queued up check-and-ping request |
1506 void P2PTransportChannel::OnCheckAndPing() { | 1507 void P2PTransportChannel::OnCheckAndPing() { |
1507 // Make sure the states of the connections are up-to-date (since this affects | 1508 // Make sure the states of the connections are up-to-date (since this affects |
1508 // which ones are pingable). | 1509 // which ones are pingable). |
1509 UpdateConnectionStates(); | 1510 UpdateConnectionStates(); |
1510 // When the selected connection is not receiving or not writable, or any | 1511 // When the selected connection is not receiving or not writable, or any |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 | 2008 |
2008 // During the initial state when nothing has been pinged yet, return the first | 2009 // During the initial state when nothing has been pinged yet, return the first |
2009 // one in the ordered |connections_|. | 2010 // one in the ordered |connections_|. |
2010 return *(std::find_if(connections_.begin(), connections_.end(), | 2011 return *(std::find_if(connections_.begin(), connections_.end(), |
2011 [conn1, conn2](Connection* conn) { | 2012 [conn1, conn2](Connection* conn) { |
2012 return conn == conn1 || conn == conn2; | 2013 return conn == conn1 || conn == conn2; |
2013 })); | 2014 })); |
2014 } | 2015 } |
2015 | 2016 |
2016 } // namespace cricket | 2017 } // namespace cricket |
OLD | NEW |