Index: webrtc/p2p/base/candidate.h |
diff --git a/webrtc/p2p/base/candidate.h b/webrtc/p2p/base/candidate.h |
index ac7acabf057cdd06fa4beb915989bc49d65f04ec..a4335f838b51a024e08828dc6f87761319595ab5 100644 |
--- a/webrtc/p2p/base/candidate.h |
+++ b/webrtc/p2p/base/candidate.h |
@@ -27,6 +27,8 @@ |
namespace cricket { |
+const uint32_t kMaxNetworkCost = 0xFFFF; |
pthatcher1
2016/02/12 00:07:12
Can we make it something that is going to look rea
honghaiz3
2016/02/12 19:28:43
Changed to 999. (digit 9 is a better convention to
pthatcher1
2016/02/12 20:05:26
Sounds good.
|
+ |
// Candidate for ICE based connection discovery. |
class Candidate { |
@@ -138,6 +140,15 @@ class Candidate { |
ist >> generation_; |
} |
+ // |network_cost| measures the cost/penalty of using this candidate. A network |
+ // cost of 0 indicates this candidate can be used freely. A value of |
+ // |kMaxNetworkCost| indicates it should be used only as the last resort. |
+ 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_; |
} |
@@ -211,10 +222,10 @@ class Candidate { |
std::ostringstream ost; |
std::string address = sensitive ? address_.ToSensitiveString() : |
address_.ToString(); |
- ost << "Cand[" << foundation_ << ":" << component_ << ":" |
- << protocol_ << ":" << priority_ << ":" |
- << address << ":" << type_ << ":" << related_address_ << ":" |
- << username_ << ":" << password_ << "]"; |
+ ost << "Cand[" << foundation_ << ":" << component_ << ":" << protocol_ |
+ << ":" << priority_ << ":" << address << ":" << type_ << ":" |
+ << related_address_ << ":" << username_ << ":" << password_ << ":" |
+ << network_cost_ << "]"; |
return ost.str(); |
} |
@@ -233,6 +244,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 |