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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 if (data.port()->Network()->name() == network_name && | 738 if (data.port()->Network()->name() == network_name && |
739 data.port()->Type() == RELAY_PORT_TYPE && data.ready() && | 739 data.port()->Type() == RELAY_PORT_TYPE && data.ready() && |
740 (!best_turn_port || ComparePort(data.port(), best_turn_port) > 0)) { | 740 (!best_turn_port || ComparePort(data.port(), best_turn_port) > 0)) { |
741 best_turn_port = data.port(); | 741 best_turn_port = data.port(); |
742 } | 742 } |
743 } | 743 } |
744 return best_turn_port; | 744 return best_turn_port; |
745 } | 745 } |
746 | 746 |
747 bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) { | 747 bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) { |
748 bool pruned_port = false; | |
749 // Note: We determine the same network based only on their network names. So | 748 // Note: We determine the same network based only on their network names. So |
750 // if an IPv4 address and an IPv6 address have the same network name, they | 749 // if an IPv4 address and an IPv6 address have the same network name, they |
751 // are considered the same network here. | 750 // are considered the same network here. |
752 const std::string& network_name = newly_pairable_turn_port->Network()->name(); | 751 const std::string& network_name = newly_pairable_turn_port->Network()->name(); |
753 Port* best_turn_port = GetBestTurnPortForNetwork(network_name); | 752 Port* best_turn_port = GetBestTurnPortForNetwork(network_name); |
754 // |port| is already in the list of ports, so the best port cannot be nullptr. | 753 // |port| is already in the list of ports, so the best port cannot be nullptr. |
755 RTC_CHECK(best_turn_port != nullptr); | 754 RTC_CHECK(best_turn_port != nullptr); |
756 | 755 |
756 bool pruned_port = false; | |
757 std::vector<PortInterface*> ports_pruned; | |
pthatcher1
2016/07/27 18:38:12
I'd rename these to:
pruned_port => ports_pruned
honghaiz3
2016/07/27 21:31:26
They appears confusing. Change pruned_port to prun
| |
757 for (PortData& data : ports_) { | 758 for (PortData& data : ports_) { |
758 if (data.port()->Network()->name() == network_name && | 759 if (data.port()->Network()->name() == network_name && |
759 data.port()->Type() == RELAY_PORT_TYPE && !data.pruned() && | 760 data.port()->Type() == RELAY_PORT_TYPE && !data.pruned() && |
760 ComparePort(data.port(), best_turn_port) < 0) { | 761 ComparePort(data.port(), best_turn_port) < 0) { |
761 data.set_pruned(); | 762 data.set_pruned(); |
762 pruned_port = true; | 763 pruned_port = true; |
763 if (data.port() != newly_pairable_turn_port) { | 764 if (data.port() != newly_pairable_turn_port) { |
764 SignalPortPruned(this, data.port()); | 765 ports_pruned.push_back(data.port()); |
765 } | 766 } |
766 } | 767 } |
767 } | 768 } |
769 if (!ports_pruned.empty()) { | |
770 LOG(LS_INFO) << "Pruned " << ports_pruned.size() << " ports"; | |
771 SignalPortsRemoved(this, ports_pruned); | |
772 } | |
768 return pruned_port; | 773 return pruned_port; |
769 } | 774 } |
770 | 775 |
771 void BasicPortAllocatorSession::OnPortComplete(Port* port) { | 776 void BasicPortAllocatorSession::OnPortComplete(Port* port) { |
772 ASSERT(rtc::Thread::Current() == network_thread_); | 777 ASSERT(rtc::Thread::Current() == network_thread_); |
773 LOG_J(LS_INFO, port) << "Port completed gathering candidates."; | 778 LOG_J(LS_INFO, port) << "Port completed gathering candidates."; |
774 PortData* data = FindPort(port); | 779 PortData* data = FindPort(port); |
775 ASSERT(data != NULL); | 780 ASSERT(data != NULL); |
776 | 781 |
777 // Ignore any late signals. | 782 // Ignore any late signals. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 } | 944 } |
940 ports_to_remove.push_back(data.port()); | 945 ports_to_remove.push_back(data.port()); |
941 if (data.has_pairable_candidate()) { | 946 if (data.has_pairable_candidate()) { |
942 GetCandidatesFromPort(data, &candidates_to_remove); | 947 GetCandidatesFromPort(data, &candidates_to_remove); |
943 // Mark the port as having no pairable candidates so that its candidates | 948 // Mark the port as having no pairable candidates so that its candidates |
944 // won't be removed multiple times. | 949 // won't be removed multiple times. |
945 data.set_has_pairable_candidate(false); | 950 data.set_has_pairable_candidate(false); |
946 } | 951 } |
947 } | 952 } |
948 if (!ports_to_remove.empty()) { | 953 if (!ports_to_remove.empty()) { |
954 LOG(LS_INFO) << "Removed " << ports_to_remove.size() << " ports"; | |
949 SignalPortsRemoved(this, ports_to_remove); | 955 SignalPortsRemoved(this, ports_to_remove); |
950 } | 956 } |
951 if (!candidates_to_remove.empty()) { | 957 if (!candidates_to_remove.empty()) { |
952 SignalCandidatesRemoved(this, candidates_to_remove); | 958 SignalCandidatesRemoved(this, candidates_to_remove); |
953 } | 959 } |
954 } | 960 } |
955 | 961 |
956 // AllocationSequence | 962 // AllocationSequence |
957 | 963 |
958 AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session, | 964 AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session, |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1431 ServerAddresses servers; | 1437 ServerAddresses servers; |
1432 for (size_t i = 0; i < relays.size(); ++i) { | 1438 for (size_t i = 0; i < relays.size(); ++i) { |
1433 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1439 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1434 servers.insert(relays[i].ports.front().address); | 1440 servers.insert(relays[i].ports.front().address); |
1435 } | 1441 } |
1436 } | 1442 } |
1437 return servers; | 1443 return servers; |
1438 } | 1444 } |
1439 | 1445 |
1440 } // namespace cricket | 1446 } // namespace cricket |
OLD | NEW |