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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 network_manager->GetAnyAddressNetworks(networks); | 410 network_manager->GetAnyAddressNetworks(networks); |
411 } else { | 411 } else { |
412 network_manager->GetNetworks(networks); | 412 network_manager->GetNetworks(networks); |
413 } | 413 } |
414 networks->erase(std::remove_if(networks->begin(), networks->end(), | 414 networks->erase(std::remove_if(networks->begin(), networks->end(), |
415 [this](rtc::Network* network) { | 415 [this](rtc::Network* network) { |
416 return allocator_->network_ignore_mask() & | 416 return allocator_->network_ignore_mask() & |
417 network->type(); | 417 network->type(); |
418 }), | 418 }), |
419 networks->end()); | 419 networks->end()); |
| 420 |
| 421 if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) { |
| 422 uint16_t lowest_cost = rtc::kNetworkCostMax; |
| 423 for (rtc::Network* network : *networks) { |
| 424 lowest_cost = std::min<uint16_t>(lowest_cost, network->GetCost()); |
| 425 } |
| 426 networks->erase(std::remove_if(networks->begin(), networks->end(), |
| 427 [lowest_cost](rtc::Network* network) { |
| 428 return network->GetCost() > |
| 429 lowest_cost + rtc::kNetworkCostLow; |
| 430 }), |
| 431 networks->end()); |
| 432 } |
420 } | 433 } |
421 | 434 |
422 // For each network, see if we have a sequence that covers it already. If not, | 435 // For each network, see if we have a sequence that covers it already. If not, |
423 // create a new sequence to create the appropriate ports. | 436 // create a new sequence to create the appropriate ports. |
424 void BasicPortAllocatorSession::DoAllocate() { | 437 void BasicPortAllocatorSession::DoAllocate() { |
425 bool done_signal_needed = false; | 438 bool done_signal_needed = false; |
426 std::vector<rtc::Network*> networks; | 439 std::vector<rtc::Network*> networks; |
427 GetNetworks(&networks); | 440 GetNetworks(&networks); |
428 | 441 |
429 if (networks.empty()) { | 442 if (networks.empty()) { |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 ServerAddresses servers; | 1235 ServerAddresses servers; |
1223 for (size_t i = 0; i < relays.size(); ++i) { | 1236 for (size_t i = 0; i < relays.size(); ++i) { |
1224 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1237 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1225 servers.insert(relays[i].ports.front().address); | 1238 servers.insert(relays[i].ports.front().address); |
1226 } | 1239 } |
1227 } | 1240 } |
1228 return servers; | 1241 return servers; |
1229 } | 1242 } |
1230 | 1243 |
1231 } // namespace cricket | 1244 } // namespace cricket |
OLD | NEW |