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

Unified Diff: talk/app/webrtc/webrtcsdp.cc

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: talk/app/webrtc/webrtcsdp.cc
diff --git a/talk/app/webrtc/webrtcsdp.cc b/talk/app/webrtc/webrtcsdp.cc
index f5fb7f78e3334edd7f320d6f3e89f49b25132c4f..57e235a01e85372fc21690d3e9f79ff7cd4e6771 100644
--- a/talk/app/webrtc/webrtcsdp.cc
+++ b/talk/app/webrtc/webrtcsdp.cc
@@ -143,6 +143,7 @@ static const char kAttributeCandidateRport[] = "rport";
static const char kAttributeCandidateUfrag[] = "ufrag";
static const char kAttributeCandidatePwd[] = "pwd";
static const char kAttributeCandidateGeneration[] = "generation";
+static const char kAttributeCandidateCost[] = "cost";
static const char kAttributeFingerprint[] = "fingerprint";
static const char kAttributeSetup[] = "setup";
static const char kAttributeFmtp[] = "fmtp";
@@ -1079,6 +1080,7 @@ bool ParseCandidate(const std::string& message, Candidate* candidate,
std::string username;
std::string password;
uint32_t generation = 0;
+ uint32_t cost = 0;
for (size_t i = current_position; i + 1 < fields.size(); ++i) {
// RFC 5245
// *(SP extension-att-name SP extension-att-value)
@@ -1090,6 +1092,10 @@ bool ParseCandidate(const std::string& message, Candidate* candidate,
username = fields[++i];
} else if (fields[i] == kAttributeCandidatePwd) {
password = fields[++i];
+ } else if (fields[i] == kAttributeCandidateCost) {
+ if (!GetValueFromString(first_line, fields[++i], &cost, error)) {
+ return false;
+ }
} else {
// Skip the unknown extension.
++i;
@@ -1101,6 +1107,7 @@ bool ParseCandidate(const std::string& message, Candidate* candidate,
generation, foundation);
candidate->set_related_address(related_address);
candidate->set_tcptype(tcptype);
+ candidate->set_network_cost(std::min(cost, cricket::kMaxNetworkCost));
pthatcher1 2016/02/04 23:16:20 I think we should pick "cost" or "network cost" bu
honghaiz3 2016/02/05 01:36:46 Discussed in other comments.
honghaiz3 2016/02/11 21:12:28 I think it might be good to put "cost" on the sign
return true;
}
@@ -1775,6 +1782,7 @@ void BuildCandidate(const std::vector<Candidate>& candidates,
if (include_ufrag && !it->username().empty()) {
os << " " << kAttributeCandidateUfrag << " " << it->username();
}
+ os << " " << kAttributeCandidateCost << " " << it->network_cost();
AddLine(os.str(), message);
}

Powered by Google App Engine
This is Rietveld 408576698