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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 } | 782 } |
783 } | 783 } |
784 | 784 |
785 // If this candidate matches what was thought to be a peer reflexive | 785 // If this candidate matches what was thought to be a peer reflexive |
786 // candidate, we need to update the candidate priority/etc. | 786 // candidate, we need to update the candidate priority/etc. |
787 for (Connection* conn : connections_) { | 787 for (Connection* conn : connections_) { |
788 conn->MaybeUpdatePeerReflexiveCandidate(new_remote_candidate); | 788 conn->MaybeUpdatePeerReflexiveCandidate(new_remote_candidate); |
789 } | 789 } |
790 | 790 |
791 // Create connections to this remote candidate. | 791 // Create connections to this remote candidate. |
792 CreateConnections(new_remote_candidate, NULL); | 792 CreateConnections(new_remote_candidate, nullptr); |
793 | 793 |
794 // Resort the connections list, which may have new elements. | 794 // Resort the connections list, which may have new elements. |
795 SortConnectionsAndUpdateState(); | 795 SortConnectionsAndUpdateState(); |
796 } | 796 } |
797 | 797 |
798 void P2PTransportChannel::RemoveRemoteCandidate( | 798 void P2PTransportChannel::RemoveRemoteCandidate( |
799 const Candidate& cand_to_remove) { | 799 const Candidate& cand_to_remove) { |
800 auto iter = | 800 auto iter = |
801 std::remove_if(remote_candidates_.begin(), remote_candidates_.end(), | 801 std::remove_if(remote_candidates_.begin(), remote_candidates_.end(), |
802 [cand_to_remove](const Candidate& candidate) { | 802 [cand_to_remove](const Candidate& candidate) { |
(...skipping 12 matching lines...) Expand all Loading... |
815 PortInterface* origin_port) { | 815 PortInterface* origin_port) { |
816 RTC_DCHECK(network_thread_ == rtc::Thread::Current()); | 816 RTC_DCHECK(network_thread_ == rtc::Thread::Current()); |
817 | 817 |
818 // If we've already seen the new remote candidate (in the current candidate | 818 // If we've already seen the new remote candidate (in the current candidate |
819 // generation), then we shouldn't try creating connections for it. | 819 // generation), then we shouldn't try creating connections for it. |
820 // We either already have a connection for it, or we previously created one | 820 // We either already have a connection for it, or we previously created one |
821 // and then later pruned it. If we don't return, the channel will again | 821 // and then later pruned it. If we don't return, the channel will again |
822 // re-create any connections that were previously pruned, which will then | 822 // re-create any connections that were previously pruned, which will then |
823 // immediately be re-pruned, churning the network for no purpose. | 823 // immediately be re-pruned, churning the network for no purpose. |
824 // This only applies to candidates received over signaling (i.e. origin_port | 824 // This only applies to candidates received over signaling (i.e. origin_port |
825 // is NULL). | 825 // is null). |
826 if (!origin_port && IsDuplicateRemoteCandidate(remote_candidate)) { | 826 if (!origin_port && IsDuplicateRemoteCandidate(remote_candidate)) { |
827 // return true to indicate success, without creating any new connections. | 827 // return true to indicate success, without creating any new connections. |
828 return true; | 828 return true; |
829 } | 829 } |
830 | 830 |
831 // Add a new connection for this candidate to every port that allows such a | 831 // Add a new connection for this candidate to every port that allows such a |
832 // connection (i.e., if they have compatible protocols) and that does not | 832 // connection (i.e., if they have compatible protocols) and that does not |
833 // already have a connection to an equivalent candidate. We must be careful | 833 // already have a connection to an equivalent candidate. We must be careful |
834 // to make sure that the origin port is included, even if it was pruned, | 834 // to make sure that the origin port is included, even if it was pruned, |
835 // since that may be the only port that can create this connection. | 835 // since that may be the only port that can create this connection. |
836 bool created = false; | 836 bool created = false; |
837 std::vector<PortInterface *>::reverse_iterator it; | 837 std::vector<PortInterface *>::reverse_iterator it; |
838 for (it = ports_.rbegin(); it != ports_.rend(); ++it) { | 838 for (it = ports_.rbegin(); it != ports_.rend(); ++it) { |
839 if (CreateConnection(*it, remote_candidate, origin_port)) { | 839 if (CreateConnection(*it, remote_candidate, origin_port)) { |
840 if (*it == origin_port) | 840 if (*it == origin_port) |
841 created = true; | 841 created = true; |
842 } | 842 } |
843 } | 843 } |
844 | 844 |
845 if ((origin_port != NULL) && | 845 if ((origin_port != nullptr) && |
846 std::find(ports_.begin(), ports_.end(), origin_port) == ports_.end()) { | 846 std::find(ports_.begin(), ports_.end(), origin_port) == ports_.end()) { |
847 if (CreateConnection(origin_port, remote_candidate, origin_port)) | 847 if (CreateConnection(origin_port, remote_candidate, origin_port)) |
848 created = true; | 848 created = true; |
849 } | 849 } |
850 | 850 |
851 // Remember this remote candidate so that we can add it to future ports. | 851 // Remember this remote candidate so that we can add it to future ports. |
852 RememberRemoteCandidate(remote_candidate, origin_port); | 852 RememberRemoteCandidate(remote_candidate, origin_port); |
853 | 853 |
854 return created; | 854 return created; |
855 } | 855 } |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 if (best_conn_on_network && conn != best_conn_on_network && | 1362 if (best_conn_on_network && conn != best_conn_on_network && |
1363 !best_conn_on_network->weak() && | 1363 !best_conn_on_network->weak() && |
1364 CompareConnectionCandidates(best_conn_on_network, conn) >= 0) { | 1364 CompareConnectionCandidates(best_conn_on_network, conn) >= 0) { |
1365 conn->Prune(); | 1365 conn->Prune(); |
1366 } | 1366 } |
1367 } | 1367 } |
1368 } | 1368 } |
1369 | 1369 |
1370 // Change the selected connection, and let listeners know. | 1370 // Change the selected connection, and let listeners know. |
1371 void P2PTransportChannel::SwitchSelectedConnection(Connection* conn) { | 1371 void P2PTransportChannel::SwitchSelectedConnection(Connection* conn) { |
1372 // Note: if conn is NULL, the previous |selected_connection_| has been | 1372 // Note: if conn is null, the previous |selected_connection_| has been |
1373 // destroyed, so don't use it. | 1373 // destroyed, so don't use it. |
1374 Connection* old_selected_connection = selected_connection_; | 1374 Connection* old_selected_connection = selected_connection_; |
1375 selected_connection_ = conn; | 1375 selected_connection_ = conn; |
1376 if (selected_connection_) { | 1376 if (selected_connection_) { |
1377 ++nomination_; | 1377 ++nomination_; |
1378 if (old_selected_connection) { | 1378 if (old_selected_connection) { |
1379 LOG_J(LS_INFO, this) << "Previous selected connection: " | 1379 LOG_J(LS_INFO, this) << "Previous selected connection: " |
1380 << old_selected_connection->ToString(); | 1380 << old_selected_connection->ToString(); |
1381 } | 1381 } |
1382 LOG_J(LS_INFO, this) << "New selected connection: " | 1382 LOG_J(LS_INFO, this) << "New selected connection: " |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 | 2049 |
2050 void P2PTransportChannel::set_receiving(bool receiving) { | 2050 void P2PTransportChannel::set_receiving(bool receiving) { |
2051 if (receiving_ == receiving) { | 2051 if (receiving_ == receiving) { |
2052 return; | 2052 return; |
2053 } | 2053 } |
2054 receiving_ = receiving; | 2054 receiving_ = receiving; |
2055 SignalReceivingState(this); | 2055 SignalReceivingState(this); |
2056 } | 2056 } |
2057 | 2057 |
2058 } // namespace cricket | 2058 } // namespace cricket |
OLD | NEW |