Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: webrtc/p2p/client/basicportallocator.cc

Issue 1987833002: Add a flag to filter out high-cost networks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/client/basicportallocator.cc
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
index 143b036183777875730387f85736ed71ad90e3db..141ee9aa5dcc565d6d7c6cea5a69e90a80b96227 100644
--- a/webrtc/p2p/client/basicportallocator.cc
+++ b/webrtc/p2p/client/basicportallocator.cc
@@ -393,6 +393,21 @@ void BasicPortAllocatorSession::GetNetworks(
network->type();
}),
networks->end());
+
+ if (flags() & PORTALLOCATOR_GATHER_LOW_COST_NETWORK_ONLY) {
+ uint16_t lowest_cost = rtc::kMaxNetworkCost;
+ for (rtc::Network* network : *networks) {
+ uint16_t cost = network->GetCost();
+ if (cost < lowest_cost) {
+ lowest_cost = cost;
+ }
+ }
pthatcher1 2016/05/17 20:44:28 std::min might work here
honghaiz3 2016/05/18 05:55:02 Done.
+ networks->erase(std::remove_if(networks->begin(), networks->end(),
+ [lowest_cost](rtc::Network* network) {
+ return network->GetCost() > lowest_cost;
+ }),
+ networks->end());
pthatcher1 2016/05/17 20:44:28 We could use a threshold greater than zero (perhap
honghaiz3 2016/05/18 05:55:02 Done.
+ }
}
// For each network, see if we have a sequence that covers it already. If not,

Powered by Google App Engine
This is Rietveld 408576698