Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/p2p/client/basicportallocator.h" | 11 #include "webrtc/p2p/client/basicportallocator.h" |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 16 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 17 #include "webrtc/p2p/base/common.h" | 17 #include "webrtc/p2p/base/common.h" |
| 18 #include "webrtc/p2p/base/port.h" | 18 #include "webrtc/p2p/base/port.h" |
| 19 #include "webrtc/p2p/base/relayport.h" | 19 #include "webrtc/p2p/base/relayport.h" |
| 20 #include "webrtc/p2p/base/stunport.h" | 20 #include "webrtc/p2p/base/stunport.h" |
| 21 #include "webrtc/p2p/base/tcpport.h" | 21 #include "webrtc/p2p/base/tcpport.h" |
| 22 #include "webrtc/p2p/base/turnport.h" | 22 #include "webrtc/p2p/base/turnport.h" |
| 23 #include "webrtc/p2p/base/udpport.h" | 23 #include "webrtc/p2p/base/udpport.h" |
| 24 #include "webrtc/base/checks.h" | |
| 24 #include "webrtc/base/common.h" | 25 #include "webrtc/base/common.h" |
| 25 #include "webrtc/base/helpers.h" | 26 #include "webrtc/base/helpers.h" |
| 26 #include "webrtc/base/logging.h" | 27 #include "webrtc/base/logging.h" |
| 27 | 28 |
| 28 using rtc::CreateRandomId; | 29 using rtc::CreateRandomId; |
| 29 using rtc::CreateRandomString; | 30 using rtc::CreateRandomString; |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 enum { | 34 enum { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 void BasicPortAllocatorSession::OnCandidateReady( | 434 void BasicPortAllocatorSession::OnCandidateReady( |
| 434 Port* port, const Candidate& c) { | 435 Port* port, const Candidate& c) { |
| 435 ASSERT(rtc::Thread::Current() == network_thread_); | 436 ASSERT(rtc::Thread::Current() == network_thread_); |
| 436 PortData* data = FindPort(port); | 437 PortData* data = FindPort(port); |
| 437 ASSERT(data != NULL); | 438 ASSERT(data != NULL); |
| 438 // Discarding any candidate signal if port allocation status is | 439 // Discarding any candidate signal if port allocation status is |
| 439 // already in completed state. | 440 // already in completed state. |
| 440 if (data->complete()) | 441 if (data->complete()) |
| 441 return; | 442 return; |
| 442 | 443 |
| 443 // Send candidates whose protocol is enabled. | |
| 444 std::vector<Candidate> candidates; | |
| 445 ProtocolType pvalue; | 444 ProtocolType pvalue; |
| 446 bool candidate_allowed_to_send = CheckCandidateFilter(c); | 445 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.
| |
| 447 if (StringToProto(c.protocol().c_str(), &pvalue) && | 446 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.
| |
| 448 data->sequence()->ProtocolEnabled(pvalue) && | 447 c.address().IsAnyIP() && |
| 449 candidate_allowed_to_send) { | 448 (port->SharedSocket() || c.protocol() == TCP_PROTOCOL_NAME); |
| 449 bool candidate_protocol_enabled = | |
| 450 StringToProto(c.protocol().c_str(), &pvalue) && | |
| 451 data->sequence()->ProtocolEnabled(pvalue); | |
| 452 | |
| 453 // These can't be true at the same time. The any address candidate shouldn't | |
| 454 // be allowed to send. | |
| 455 DCHECK(!(candidate_signable && candidate_unsignable_but_pairable)); | |
| 456 | |
| 457 if (candidate_signable && candidate_protocol_enabled) { | |
| 458 std::vector<Candidate> candidates; | |
| 450 candidates.push_back(c); | 459 candidates.push_back(c); |
| 451 } | |
| 452 | |
| 453 if (!candidates.empty()) { | |
| 454 SignalCandidatesReady(this, candidates); | 460 SignalCandidatesReady(this, candidates); |
| 455 } | 461 } |
| 456 | 462 |
| 457 // Moving to READY state as we have atleast one candidate from the port. | 463 // Port has been made ready. Nothing to do here. |
| 458 // Since this port has atleast one candidate we should forward this port | 464 if (data->ready()) { |
| 459 // to listners, to allow connections from this port. | 465 return; |
| 460 // Also we should make sure that candidate gathered from this port is allowed | 466 } |
| 461 // to send outside. | 467 |
| 462 if (!data->ready() && candidate_allowed_to_send) { | 468 // Move the port to the READY state, either because we have a usable candidate |
| 469 // from the port, or simply because the port is bound to the any address and | |
| 470 // therefore has no host candidate. This will trigger the port to start | |
| 471 // creating candidate pairs (connections) and issue connectivity checks. | |
| 472 if (candidate_signable || candidate_unsignable_but_pairable) { | |
| 463 data->set_ready(); | 473 data->set_ready(); |
| 464 SignalPortReady(this, port); | 474 SignalPortReady(this, port); |
| 465 } | 475 } |
| 466 } | 476 } |
| 467 | 477 |
| 468 void BasicPortAllocatorSession::OnPortComplete(Port* port) { | 478 void BasicPortAllocatorSession::OnPortComplete(Port* port) { |
| 469 ASSERT(rtc::Thread::Current() == network_thread_); | 479 ASSERT(rtc::Thread::Current() == network_thread_); |
| 470 PortData* data = FindPort(port); | 480 PortData* data = FindPort(port); |
| 471 ASSERT(data != NULL); | 481 ASSERT(data != NULL); |
| 472 | 482 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 501 for (std::vector<PortData>::iterator it = ports_.begin(); | 511 for (std::vector<PortData>::iterator it = ports_.begin(); |
| 502 it != ports_.end(); ++it) { | 512 it != ports_.end(); ++it) { |
| 503 if (it->sequence() != seq) | 513 if (it->sequence() != seq) |
| 504 continue; | 514 continue; |
| 505 | 515 |
| 506 const std::vector<Candidate>& potentials = it->port()->Candidates(); | 516 const std::vector<Candidate>& potentials = it->port()->Candidates(); |
| 507 for (size_t i = 0; i < potentials.size(); ++i) { | 517 for (size_t i = 0; i < potentials.size(); ++i) { |
| 508 if (!CheckCandidateFilter(potentials[i])) | 518 if (!CheckCandidateFilter(potentials[i])) |
| 509 continue; | 519 continue; |
| 510 ProtocolType pvalue; | 520 ProtocolType pvalue; |
| 511 if (!StringToProto(potentials[i].protocol().c_str(), &pvalue)) | 521 bool candidate_protocol_enabled = |
| 512 continue; | 522 StringToProto(potentials[i].protocol().c_str(), &pvalue) && |
| 513 if (pvalue == proto) { | 523 pvalue == proto; |
| 524 if (candidate_protocol_enabled) { | |
| 514 candidates.push_back(potentials[i]); | 525 candidates.push_back(potentials[i]); |
| 515 } | 526 } |
| 516 } | 527 } |
| 517 } | 528 } |
| 518 | 529 |
| 519 if (!candidates.empty()) { | 530 if (!candidates.empty()) { |
| 520 SignalCandidatesReady(this, candidates); | 531 SignalCandidatesReady(this, candidates); |
| 521 } | 532 } |
| 522 } | 533 } |
| 523 | 534 |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 ServerAddresses servers; | 1130 ServerAddresses servers; |
| 1120 for (size_t i = 0; i < relays.size(); ++i) { | 1131 for (size_t i = 0; i < relays.size(); ++i) { |
| 1121 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1132 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
| 1122 servers.insert(relays[i].ports.front().address); | 1133 servers.insert(relays[i].ports.front().address); |
| 1123 } | 1134 } |
| 1124 } | 1135 } |
| 1125 return servers; | 1136 return servers; |
| 1126 } | 1137 } |
| 1127 | 1138 |
| 1128 } // namespace cricket | 1139 } // namespace cricket |
| OLD | NEW |