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

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

Issue 2086793002: Set the generation on peer reflexive candidates when created. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updating unit test. Created 4 years, 6 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 | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index f506126cef563f78eac4fb6a700e3c2053ffd4dc..78cb7045f819c4a6e4b656d38e782ba5aeb689b1 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -577,56 +577,31 @@ void P2PTransportChannel::OnUnknownAddress(
// is currently available for. See if we already have a candidate with the
// address. If it isn't we need to create new candidate for it.
- // Determine if the remote candidates use shared ufrag.
- bool ufrag_per_port = false;
- std::vector<RemoteCandidate>::iterator it;
- if (remote_candidates_.size() > 0) {
- it = remote_candidates_.begin();
- std::string username = it->username();
- for (; it != remote_candidates_.end(); ++it) {
- if (it->username() != username) {
- ufrag_per_port = true;
- break;
- }
- }
- }
-
- const Candidate* candidate = NULL;
- std::string remote_password;
- for (it = remote_candidates_.begin(); it != remote_candidates_.end(); ++it) {
- if (it->username() == remote_username) {
- remote_password = it->password();
- if (ufrag_per_port ||
- (it->address() == address &&
- it->protocol() == ProtoToString(proto))) {
- candidate = &(*it);
- break;
- }
- // We don't want to break here because we may find a match of the address
- // later.
+ const Candidate* candidate = nullptr;
+ for (const Candidate& c : remote_candidates_) {
+ if (c.username() == remote_username && c.address() == address &&
+ c.protocol() == ProtoToString(proto)) {
+ candidate = &c;
+ break;
}
}
uint32_t remote_generation = 0;
+ std::string remote_password;
// The STUN binding request may arrive after setRemoteDescription and before
// adding remote candidate, so we need to set the password to the shared
- // password if the user name matches.
- if (remote_password.empty()) {
- const IceParameters* ice_param =
- FindRemoteIceFromUfrag(remote_username, &remote_generation);
- // Note: if not found, the remote_generation will still be 0.
- if (ice_param != nullptr) {
- remote_password = ice_param->pwd;
- }
+ // password and set the generation if the user name matches.
+ const IceParameters* ice_param =
+ FindRemoteIceFromUfrag(remote_username, &remote_generation);
+ // Note: if not found, the remote_generation will still be 0.
+ if (ice_param != nullptr) {
+ remote_password = ice_param->pwd;
}
Candidate remote_candidate;
bool remote_candidate_is_new = (candidate == nullptr);
if (!remote_candidate_is_new) {
remote_candidate = *candidate;
- if (ufrag_per_port) {
- remote_candidate.set_address(address);
- }
} else {
// Create a new candidate with this address.
// The priority of the candidate is set to the PRIORITY attribute
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698