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

Unified Diff: webrtc/p2p/client/basicportallocator.cc

Issue 1274013002: Bug 4865: Enable connectivity when the remote peer is on public internet. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 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
Index: webrtc/p2p/client/basicportallocator.cc
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
index 3f5aa0a1ff396cbb512d65166d46c54c598b70b9..ef99875af35151f2fab353bbcebe330006225b05 100644
--- a/webrtc/p2p/client/basicportallocator.cc
+++ b/webrtc/p2p/client/basicportallocator.cc
@@ -21,6 +21,7 @@
#include "webrtc/p2p/base/tcpport.h"
#include "webrtc/p2p/base/turnport.h"
#include "webrtc/p2p/base/udpport.h"
+#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
@@ -440,26 +441,35 @@ void BasicPortAllocatorSession::OnCandidateReady(
if (data->complete())
return;
- // Send candidates whose protocol is enabled.
- std::vector<Candidate> candidates;
ProtocolType pvalue;
- bool candidate_allowed_to_send = CheckCandidateFilter(c);
- if (StringToProto(c.protocol().c_str(), &pvalue) &&
- data->sequence()->ProtocolEnabled(pvalue) &&
- candidate_allowed_to_send) {
+ bool candidate_signable = CheckCandidateFilter(c);
juberti1 2015/08/13 21:23:59 I think you want "signalable" (that's what was in
guoweis_webrtc 2015/08/14 05:24:25 Done.
+ bool candidate_unsignable_but_pairable =
juberti1 2015/08/13 21:23:59 I like Peter's idea of candidate_pairable = candid
guoweis_webrtc 2015/08/14 05:24:25 Done.
+ c.address().IsAnyIP() &&
+ (port->SharedSocket() || c.protocol() == TCP_PROTOCOL_NAME);
+ bool candidate_protocol_enabled =
+ StringToProto(c.protocol().c_str(), &pvalue) &&
+ data->sequence()->ProtocolEnabled(pvalue);
+
+ // These can't be true at the same time. The any address candidate shouldn't
+ // be allowed to send.
+ DCHECK(!(candidate_signable && candidate_unsignable_but_pairable));
+
+ if (candidate_signable && candidate_protocol_enabled) {
+ std::vector<Candidate> candidates;
candidates.push_back(c);
+ SignalCandidatesReady(this, candidates);
}
- if (!candidates.empty()) {
- SignalCandidatesReady(this, candidates);
+ // Port has been made ready. Nothing to do here.
+ if (data->ready()) {
+ return;
}
- // Moving to READY state as we have atleast one candidate from the port.
- // Since this port has atleast one candidate we should forward this port
- // to listners, to allow connections from this port.
- // Also we should make sure that candidate gathered from this port is allowed
- // to send outside.
- if (!data->ready() && candidate_allowed_to_send) {
+ // Move the port to the READY state, either because we have a usable candidate
+ // from the port, or simply because the port is bound to the any address and
+ // therefore has no host candidate. This will trigger the port to start
+ // creating candidate pairs (connections) and issue connectivity checks.
+ if (candidate_signable || candidate_unsignable_but_pairable) {
data->set_ready();
SignalPortReady(this, port);
}
@@ -508,9 +518,10 @@ void BasicPortAllocatorSession::OnProtocolEnabled(AllocationSequence* seq,
if (!CheckCandidateFilter(potentials[i]))
continue;
ProtocolType pvalue;
- if (!StringToProto(potentials[i].protocol().c_str(), &pvalue))
- continue;
- if (pvalue == proto) {
+ bool candidate_protocol_enabled =
+ StringToProto(potentials[i].protocol().c_str(), &pvalue) &&
+ pvalue == proto;
+ if (candidate_protocol_enabled) {
candidates.push_back(potentials[i]);
}
}

Powered by Google App Engine
This is Rietveld 408576698