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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 network_thread_->Post(this, MSG_CONFIG_STOP); | 208 network_thread_->Post(this, MSG_CONFIG_STOP); |
209 ClearGettingPorts(); | 209 ClearGettingPorts(); |
210 } | 210 } |
211 | 211 |
212 void BasicPortAllocatorSession::ClearGettingPorts() { | 212 void BasicPortAllocatorSession::ClearGettingPorts() { |
213 network_thread_->Clear(this, MSG_ALLOCATE); | 213 network_thread_->Clear(this, MSG_ALLOCATE); |
214 for (uint32_t i = 0; i < sequences_.size(); ++i) | 214 for (uint32_t i = 0; i < sequences_.size(); ++i) |
215 sequences_[i]->Stop(); | 215 sequences_[i]->Stop(); |
216 } | 216 } |
217 | 217 |
218 void BasicPortAllocatorSession::InactivateNetworksInExistingSequences( | |
Taylor Brandstetter
2016/06/06 18:18:37
On second thought... If this method is always inte
honghaiz3
2016/06/07 16:42:06
Done, except the name.
We are not re-gathering "p
| |
219 std::vector<rtc::Network*>* networks) { | |
220 for (AllocationSequence* sequence : sequences_) { | |
221 if (!sequence->network_inactive() && | |
222 (!networks || | |
223 std::find(networks->begin(), networks->end(), sequence->network()) != | |
224 networks->end())) { | |
225 sequence->OnNetworkInactivated(); | |
226 } | |
227 } | |
228 } | |
229 | |
218 std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const { | 230 std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const { |
219 std::vector<PortInterface*> ret; | 231 std::vector<PortInterface*> ret; |
220 for (const PortData& port : ports_) { | 232 for (const PortData& port : ports_) { |
221 if (port.has_pairable_candidate() && !port.error()) { | 233 if (port.has_pairable_candidate() && !port.error()) { |
222 ret.push_back(port.port()); | 234 ret.push_back(port.port()); |
223 } | 235 } |
224 } | 236 } |
225 return ret; | 237 return ret; |
226 } | 238 } |
227 | 239 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 network_thread_->Post(this, MSG_SEQUENCEOBJECTS_CREATED); | 506 network_thread_->Post(this, MSG_SEQUENCEOBJECTS_CREATED); |
495 } | 507 } |
496 } | 508 } |
497 | 509 |
498 void BasicPortAllocatorSession::OnNetworksChanged() { | 510 void BasicPortAllocatorSession::OnNetworksChanged() { |
499 std::vector<rtc::Network*> networks; | 511 std::vector<rtc::Network*> networks; |
500 GetNetworks(&networks); | 512 GetNetworks(&networks); |
501 for (AllocationSequence* sequence : sequences_) { | 513 for (AllocationSequence* sequence : sequences_) { |
502 // Remove the network from the allocation sequence if it is not in | 514 // Remove the network from the allocation sequence if it is not in |
503 // |networks|. | 515 // |networks|. |
504 if (!sequence->network_removed() && | 516 if (!sequence->network_inactive() && |
505 std::find(networks.begin(), networks.end(), sequence->network()) == | 517 std::find(networks.begin(), networks.end(), sequence->network()) == |
506 networks.end()) { | 518 networks.end()) { |
507 sequence->OnNetworkRemoved(); | 519 sequence->OnNetworkInactivated(); |
508 } | 520 } |
509 } | 521 } |
510 | 522 |
511 network_manager_started_ = true; | 523 network_manager_started_ = true; |
512 if (allocation_started_) | 524 if (allocation_started_) |
513 DoAllocate(); | 525 DoAllocate(); |
514 } | 526 } |
515 | 527 |
516 void BasicPortAllocatorSession::DisableEquivalentPhases( | 528 void BasicPortAllocatorSession::DisableEquivalentPhases( |
517 rtc::Network* network, | 529 rtc::Network* network, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
786 // are next available options to setup a communication channel. | 798 // are next available options to setup a communication channel. |
787 } | 799 } |
788 return true; | 800 return true; |
789 } | 801 } |
790 | 802 |
791 void AllocationSequence::Clear() { | 803 void AllocationSequence::Clear() { |
792 udp_port_ = NULL; | 804 udp_port_ = NULL; |
793 turn_ports_.clear(); | 805 turn_ports_.clear(); |
794 } | 806 } |
795 | 807 |
796 void AllocationSequence::OnNetworkRemoved() { | 808 void AllocationSequence::OnNetworkInactivated() { |
797 // Stop the allocation sequence if its network is gone. | 809 // Stop the allocation sequence if its network is gone. |
810 network_inactive_ = true; | |
798 Stop(); | 811 Stop(); |
799 network_removed_ = true; | |
800 } | 812 } |
801 | 813 |
802 AllocationSequence::~AllocationSequence() { | 814 AllocationSequence::~AllocationSequence() { |
803 session_->network_thread()->Clear(this); | 815 session_->network_thread()->Clear(this); |
804 } | 816 } |
805 | 817 |
806 void AllocationSequence::DisableEquivalentPhases(rtc::Network* network, | 818 void AllocationSequence::DisableEquivalentPhases(rtc::Network* network, |
807 PortConfiguration* config, uint32_t* flags) { | 819 PortConfiguration* config, uint32_t* flags) { |
808 if (network_removed_) { | 820 if (network_inactive_) { |
809 // If the network of this allocation sequence has ever gone away, | 821 // If the network of this allocation sequence has ever become inactive, |
810 // it won't be equivalent to the new network. | 822 // it won't be equivalent to the new network. |
811 return; | 823 return; |
812 } | 824 } |
813 | 825 |
814 if (!((network == network_) && (ip_ == network->GetBestIP()))) { | 826 if (!((network == network_) && (ip_ == network->GetBestIP()))) { |
815 // Different network setup; nothing is equivalent. | 827 // Different network setup; nothing is equivalent. |
816 return; | 828 return; |
817 } | 829 } |
818 | 830 |
819 // Else turn off the stuff that we've already got covered. | 831 // Else turn off the stuff that we've already got covered. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1235 ServerAddresses servers; | 1247 ServerAddresses servers; |
1236 for (size_t i = 0; i < relays.size(); ++i) { | 1248 for (size_t i = 0; i < relays.size(); ++i) { |
1237 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1249 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1238 servers.insert(relays[i].ports.front().address); | 1250 servers.insert(relays[i].ports.front().address); |
1239 } | 1251 } |
1240 } | 1252 } |
1241 return servers; | 1253 return servers; |
1242 } | 1254 } |
1243 | 1255 |
1244 } // namespace cricket | 1256 } // namespace cricket |
OLD | NEW |