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

Unified Diff: webrtc/p2p/base/port.cc

Issue 2125823004: Fixing problems with ICE candidate pair prioritization. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing line length. Created 4 years, 4 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
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index 98b62c4222e11eac346bfc1991599d833aeb7e70..c648450b9a8a88ce56960766716e14681013376d 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -799,8 +799,12 @@ class ConnectionRequest : public StunRequest {
// priority = (2^24)*(type preference) +
// (2^8)*(local preference) +
// (2^0)*(256 - component ID)
+ uint32_t type_preference =
+ (connection_->local_candidate().protocol() == TCP_PROTOCOL_NAME)
+ ? ICE_TYPE_PREFERENCE_PRFLX_TCP
+ : ICE_TYPE_PREFERENCE_PRFLX;
uint32_t prflx_priority =
- ICE_TYPE_PREFERENCE_PRFLX << 24 |
+ type_preference << 24 |
(connection_->local_candidate().priority() & 0x00FFFFFF);
request->AddAttribute(
new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority));
@@ -1362,7 +1366,7 @@ void Connection::OnConnectionRequestResponse(ConnectionRequest* request,
stats_.recv_ping_responses++;
- MaybeAddPrflxCandidate(request, response);
+ MaybeUpdateLocalCandidate(request, response);
}
void Connection::OnConnectionRequestErrorResponse(ConnectionRequest* request,
@@ -1471,8 +1475,8 @@ ConnectionInfo Connection::stats() {
return stats_;
}
-void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request,
- StunMessage* response) {
+void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request,
+ StunMessage* response) {
// RFC 5245
// The agent checks the mapped address from the STUN response. If the
// transport address does not match any of the local candidates that the
@@ -1487,16 +1491,18 @@ void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request,
return;
}
- bool known_addr = false;
for (size_t i = 0; i < port_->Candidates().size(); ++i) {
if (port_->Candidates()[i].address() == addr->GetAddress()) {
- known_addr = true;
- break;
+ if (local_candidate_index_ != i) {
+ LOG_J(LS_INFO, this) << "Updating local candidate type to srflx.";
+ local_candidate_index_ = i;
+ // SignalStateChange to force a re-sort in P2PTransportChannel as this
+ // Connection's local candidate has changed.
+ SignalStateChange(this);
+ }
+ return;
}
}
- if (known_addr) {
- return;
- }
// RFC 5245
// Its priority is set equal to the value of the PRIORITY attribute
@@ -1532,6 +1538,7 @@ void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request,
new_local_candidate.set_network_cost(local_candidate().network_cost());
// Change the local candidate of this Connection to the new prflx candidate.
+ LOG_J(LS_INFO, this) << "Updating local candidate type to prflx.";
local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate);
// SignalStateChange to force a re-sort in P2PTransportChannel as this
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698