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

Unified Diff: webrtc/p2p/base/candidate.h

Issue 1668073002: Add network cost as part of the connection comparison. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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/base/candidate.h
diff --git a/webrtc/p2p/base/candidate.h b/webrtc/p2p/base/candidate.h
index ac7acabf057cdd06fa4beb915989bc49d65f04ec..bb5cf9d0465e05eca2847a50f0c59c73c653b0f0 100644
--- a/webrtc/p2p/base/candidate.h
+++ b/webrtc/p2p/base/candidate.h
@@ -27,6 +27,10 @@
namespace cricket {
+// A candidate with the maximum cost indicates it should be used only as the
+// last resort.
+const uint32_t kMaxNetworkCost = 99;
pthatcher1 2016/02/04 23:16:20 I'd prefer to make this an enum.
honghaiz3 2016/02/05 01:36:46 Acknowledged.
+
// Candidate for ICE based connection discovery.
class Candidate {
@@ -138,6 +142,14 @@ class Candidate {
ist >> generation_;
}
+ // |network_cost| measures the cost/penalty of using this candidate. A cost of
+ // 0 indicates this candidate can be used freely.
+ void set_network_cost(uint32_t network_cost) {
+ ASSERT(network_cost <= kMaxNetworkCost);
+ network_cost_ = network_cost;
+ }
+ uint32_t network_cost() const { return network_cost_; }
+
const std::string& foundation() const {
return foundation_;
}
@@ -214,7 +226,7 @@ class Candidate {
ost << "Cand[" << foundation_ << ":" << component_ << ":"
<< protocol_ << ":" << priority_ << ":"
<< address << ":" << type_ << ":" << related_address_ << ":"
- << username_ << ":" << password_ << "]";
+ << username_ << ":" << password_ << ":" << network_cost_ << "]";
return ost.str();
}
@@ -233,6 +245,7 @@ class Candidate {
std::string foundation_;
rtc::SocketAddress related_address_;
std::string tcptype_;
+ uint32_t network_cost_ = 0;
};
// Used during parsing and writing to map component to channel name

Powered by Google App Engine
This is Rietveld 408576698