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

Side by Side Diff: webrtc/p2p/client/basicportallocator.cc

Issue 1982513002: Revert of Relanding: Implement RTCConfiguration.iceCandidatePoolSize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 namespace cricket { 61 namespace cricket {
62 const uint32_t DISABLE_ALL_PHASES = 62 const uint32_t DISABLE_ALL_PHASES =
63 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP | 63 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP |
64 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY; 64 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY;
65 65
66 // BasicPortAllocator 66 // BasicPortAllocator
67 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager, 67 BasicPortAllocator::BasicPortAllocator(
68 rtc::PacketSocketFactory* socket_factory) 68 rtc::NetworkManager* network_manager,
69 : network_manager_(network_manager), socket_factory_(socket_factory) { 69 rtc::PacketSocketFactory* socket_factory)
70 : network_manager_(network_manager),
71 socket_factory_(socket_factory),
72 stun_servers_() {
70 ASSERT(network_manager_ != nullptr); 73 ASSERT(network_manager_ != nullptr);
71 ASSERT(socket_factory_ != nullptr); 74 ASSERT(socket_factory_ != nullptr);
72 Construct(); 75 Construct();
73 } 76 }
74 77
75 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager) 78 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager)
76 : network_manager_(network_manager), socket_factory_(nullptr) { 79 : network_manager_(network_manager),
80 socket_factory_(nullptr),
81 stun_servers_() {
77 ASSERT(network_manager_ != nullptr); 82 ASSERT(network_manager_ != nullptr);
78 Construct(); 83 Construct();
79 } 84 }
80 85
81 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager, 86 BasicPortAllocator::BasicPortAllocator(
82 rtc::PacketSocketFactory* socket_factory, 87 rtc::NetworkManager* network_manager,
83 const ServerAddresses& stun_servers) 88 rtc::PacketSocketFactory* socket_factory,
84 : network_manager_(network_manager), socket_factory_(socket_factory) { 89 const ServerAddresses& stun_servers)
90 : network_manager_(network_manager),
91 socket_factory_(socket_factory),
92 stun_servers_(stun_servers) {
85 ASSERT(socket_factory_ != NULL); 93 ASSERT(socket_factory_ != NULL);
86 SetConfiguration(stun_servers, std::vector<RelayServerConfig>(), 0);
87 Construct(); 94 Construct();
88 } 95 }
89 96
90 BasicPortAllocator::BasicPortAllocator( 97 BasicPortAllocator::BasicPortAllocator(
91 rtc::NetworkManager* network_manager, 98 rtc::NetworkManager* network_manager,
92 const ServerAddresses& stun_servers, 99 const ServerAddresses& stun_servers,
93 const rtc::SocketAddress& relay_address_udp, 100 const rtc::SocketAddress& relay_address_udp,
94 const rtc::SocketAddress& relay_address_tcp, 101 const rtc::SocketAddress& relay_address_tcp,
95 const rtc::SocketAddress& relay_address_ssl) 102 const rtc::SocketAddress& relay_address_ssl)
96 : network_manager_(network_manager), socket_factory_(NULL) { 103 : network_manager_(network_manager),
97 std::vector<RelayServerConfig> turn_servers; 104 socket_factory_(NULL),
105 stun_servers_(stun_servers) {
106
98 RelayServerConfig config(RELAY_GTURN); 107 RelayServerConfig config(RELAY_GTURN);
99 if (!relay_address_udp.IsNil()) { 108 if (!relay_address_udp.IsNil()) {
100 config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP)); 109 config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP));
101 } 110 }
102 if (!relay_address_tcp.IsNil()) { 111 if (!relay_address_tcp.IsNil()) {
103 config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP)); 112 config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP));
104 } 113 }
105 if (!relay_address_ssl.IsNil()) { 114 if (!relay_address_ssl.IsNil()) {
106 config.ports.push_back(ProtocolAddress(relay_address_ssl, PROTO_SSLTCP)); 115 config.ports.push_back(ProtocolAddress(relay_address_ssl, PROTO_SSLTCP));
107 } 116 }
108 117
109 if (!config.ports.empty()) { 118 if (!config.ports.empty()) {
110 turn_servers.push_back(config); 119 AddTurnServer(config);
111 } 120 }
112 121
113 SetConfiguration(stun_servers, turn_servers, 0);
114 Construct(); 122 Construct();
115 } 123 }
116 124
117 void BasicPortAllocator::Construct() { 125 void BasicPortAllocator::Construct() {
118 allow_tcp_listen_ = true; 126 allow_tcp_listen_ = true;
119 } 127 }
120 128
121 BasicPortAllocator::~BasicPortAllocator() { 129 BasicPortAllocator::~BasicPortAllocator() {
122 } 130 }
123 131
124 PortAllocatorSession* BasicPortAllocator::CreateSessionInternal( 132 PortAllocatorSession* BasicPortAllocator::CreateSessionInternal(
125 const std::string& content_name, int component, 133 const std::string& content_name, int component,
126 const std::string& ice_ufrag, const std::string& ice_pwd) { 134 const std::string& ice_ufrag, const std::string& ice_pwd) {
127 return new BasicPortAllocatorSession( 135 return new BasicPortAllocatorSession(
128 this, content_name, component, ice_ufrag, ice_pwd); 136 this, content_name, component, ice_ufrag, ice_pwd);
129 } 137 }
130 138
131 void BasicPortAllocator::AddTurnServer(const RelayServerConfig& turn_server) {
132 std::vector<RelayServerConfig> new_turn_servers = turn_servers();
133 new_turn_servers.push_back(turn_server);
134 SetConfiguration(stun_servers(), new_turn_servers, candidate_pool_size());
135 }
136 139
137 // BasicPortAllocatorSession 140 // BasicPortAllocatorSession
138 BasicPortAllocatorSession::BasicPortAllocatorSession( 141 BasicPortAllocatorSession::BasicPortAllocatorSession(
139 BasicPortAllocator *allocator, 142 BasicPortAllocator *allocator,
140 const std::string& content_name, 143 const std::string& content_name,
141 int component, 144 int component,
142 const std::string& ice_ufrag, 145 const std::string& ice_ufrag,
143 const std::string& ice_pwd) 146 const std::string& ice_pwd)
144 : PortAllocatorSession(content_name, component, 147 : PortAllocatorSession(content_name, component,
145 ice_ufrag, ice_pwd, allocator->flags()), 148 ice_ufrag, ice_pwd, allocator->flags()),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 network_thread_->Post(this, MSG_CONFIG_STOP); 200 network_thread_->Post(this, MSG_CONFIG_STOP);
198 ClearGettingPorts(); 201 ClearGettingPorts();
199 } 202 }
200 203
201 void BasicPortAllocatorSession::ClearGettingPorts() { 204 void BasicPortAllocatorSession::ClearGettingPorts() {
202 network_thread_->Clear(this, MSG_ALLOCATE); 205 network_thread_->Clear(this, MSG_ALLOCATE);
203 for (uint32_t i = 0; i < sequences_.size(); ++i) 206 for (uint32_t i = 0; i < sequences_.size(); ++i)
204 sequences_[i]->Stop(); 207 sequences_[i]->Stop();
205 } 208 }
206 209
207 std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const {
208 std::vector<PortInterface*> ret;
209 for (const PortData& port : ports_) {
210 if (port.ready() || port.complete()) {
211 ret.push_back(port.port());
212 }
213 }
214 return ret;
215 }
216
217 std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const {
218 std::vector<Candidate> candidates;
219 for (const PortData& data : ports_) {
220 for (const Candidate& candidate : data.port()->Candidates()) {
221 if (!CheckCandidateFilter(candidate)) {
222 continue;
223 }
224 ProtocolType pvalue;
225 if (!StringToProto(candidate.protocol().c_str(), &pvalue) ||
226 !data.sequence()->ProtocolEnabled(pvalue)) {
227 continue;
228 }
229 candidates.push_back(candidate);
230 }
231 }
232 return candidates;
233 }
234
235 bool BasicPortAllocatorSession::CandidatesAllocationDone() const {
236 // Done only if all required AllocationSequence objects
237 // are created.
238 if (!allocation_sequences_created_) {
239 return false;
240 }
241
242 // Check that all port allocation sequences are complete (not running).
243 if (std::any_of(sequences_.begin(), sequences_.end(),
244 [](const AllocationSequence* sequence) {
245 return sequence->state() == AllocationSequence::kRunning;
246 })) {
247 return false;
248 }
249
250 // If all allocated ports are in complete state, session must have got all
251 // expected candidates. Session will trigger candidates allocation complete
252 // signal.
253 if (!std::all_of(ports_.begin(), ports_.end(), [](const PortData& port) {
254 return (port.complete() || port.error());
255 })) {
256 return false;
257 }
258
259 return true;
260 }
261
262 void BasicPortAllocatorSession::OnMessage(rtc::Message *message) { 210 void BasicPortAllocatorSession::OnMessage(rtc::Message *message) {
263 switch (message->message_id) { 211 switch (message->message_id) {
264 case MSG_CONFIG_START: 212 case MSG_CONFIG_START:
265 ASSERT(rtc::Thread::Current() == network_thread_); 213 ASSERT(rtc::Thread::Current() == network_thread_);
266 GetPortConfigurations(); 214 GetPortConfigurations();
267 break; 215 break;
268 216
269 case MSG_CONFIG_READY: 217 case MSG_CONFIG_READY:
270 ASSERT(rtc::Thread::Current() == network_thread_); 218 ASSERT(rtc::Thread::Current() == network_thread_);
271 OnConfigReady(static_cast<PortConfiguration*>(message->pdata)); 219 OnConfigReady(static_cast<PortConfiguration*>(message->pdata));
(...skipping 14 matching lines...) Expand all
286 break; 234 break;
287 case MSG_CONFIG_STOP: 235 case MSG_CONFIG_STOP:
288 ASSERT(rtc::Thread::Current() == network_thread_); 236 ASSERT(rtc::Thread::Current() == network_thread_);
289 OnConfigStop(); 237 OnConfigStop();
290 break; 238 break;
291 default: 239 default:
292 ASSERT(false); 240 ASSERT(false);
293 } 241 }
294 } 242 }
295 243
296 void BasicPortAllocatorSession::UpdateIceParametersInternal() {
297 for (PortData& port : ports_) {
298 port.port()->set_content_name(content_name());
299 port.port()->SetIceParameters(component(), ice_ufrag(), ice_pwd());
300 }
301 }
302
303 void BasicPortAllocatorSession::GetPortConfigurations() { 244 void BasicPortAllocatorSession::GetPortConfigurations() {
304 PortConfiguration* config = new PortConfiguration(allocator_->stun_servers(), 245 PortConfiguration* config = new PortConfiguration(allocator_->stun_servers(),
305 username(), 246 username(),
306 password()); 247 password());
307 248
308 for (const RelayServerConfig& turn_server : allocator_->turn_servers()) { 249 for (const RelayServerConfig& turn_server : allocator_->turn_servers()) {
309 config->AddRelay(turn_server); 250 config->AddRelay(turn_server);
310 } 251 }
311 ConfigReady(config); 252 ConfigReady(config);
312 } 253 }
(...skipping 13 matching lines...) Expand all
326 267
327 void BasicPortAllocatorSession::OnConfigStop() { 268 void BasicPortAllocatorSession::OnConfigStop() {
328 ASSERT(rtc::Thread::Current() == network_thread_); 269 ASSERT(rtc::Thread::Current() == network_thread_);
329 270
330 // If any of the allocated ports have not completed the candidates allocation, 271 // If any of the allocated ports have not completed the candidates allocation,
331 // mark those as error. Since session doesn't need any new candidates 272 // mark those as error. Since session doesn't need any new candidates
332 // at this stage of the allocation, it's safe to discard any new candidates. 273 // at this stage of the allocation, it's safe to discard any new candidates.
333 bool send_signal = false; 274 bool send_signal = false;
334 for (std::vector<PortData>::iterator it = ports_.begin(); 275 for (std::vector<PortData>::iterator it = ports_.begin();
335 it != ports_.end(); ++it) { 276 it != ports_.end(); ++it) {
336 if (!it->complete() && !it->error()) { 277 if (!it->complete()) {
337 // Updating port state to error, which didn't finish allocating candidates 278 // Updating port state to error, which didn't finish allocating candidates
338 // yet. 279 // yet.
339 it->set_error(); 280 it->set_error();
340 send_signal = true; 281 send_signal = true;
341 } 282 }
342 } 283 }
343 284
344 // Did we stop any running sequences? 285 // Did we stop any running sequences?
345 for (std::vector<AllocationSequence*>::iterator it = sequences_.begin(); 286 for (std::vector<AllocationSequence*>::iterator it = sequences_.begin();
346 it != sequences_.end() && !send_signal; ++it) { 287 it != sequences_.end() && !send_signal; ++it) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 429 }
489 430
490 void BasicPortAllocatorSession::AddAllocatedPort(Port* port, 431 void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
491 AllocationSequence * seq, 432 AllocationSequence * seq,
492 bool prepare_address) { 433 bool prepare_address) {
493 if (!port) 434 if (!port)
494 return; 435 return;
495 436
496 LOG(LS_INFO) << "Adding allocated port for " << content_name(); 437 LOG(LS_INFO) << "Adding allocated port for " << content_name();
497 port->set_content_name(content_name()); 438 port->set_content_name(content_name());
498 port->set_component(component()); 439 port->set_component(component_);
499 port->set_generation(generation()); 440 port->set_generation(generation());
500 if (allocator_->proxy().type != rtc::PROXY_NONE) 441 if (allocator_->proxy().type != rtc::PROXY_NONE)
501 port->set_proxy(allocator_->user_agent(), allocator_->proxy()); 442 port->set_proxy(allocator_->user_agent(), allocator_->proxy());
502 port->set_send_retransmit_count_attribute( 443 port->set_send_retransmit_count_attribute((allocator_->flags() &
503 (flags() & PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0); 444 PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0);
504 445
505 // Push down the candidate_filter to individual port. 446 // Push down the candidate_filter to individual port.
506 uint32_t candidate_filter = allocator_->candidate_filter(); 447 uint32_t candidate_filter = allocator_->candidate_filter();
507 448
508 // When adapter enumeration is disabled, disable CF_HOST at port level so 449 // When adapter enumeration is disabled, disable CF_HOST at port level so
509 // local address is not leaked by stunport in the candidate's related address. 450 // local address is not leaked by stunport in the candidate's related address.
510 if ((flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) && 451 if ((flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) &&
511 (flags() & PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE)) { 452 (flags() & PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE)) {
512 candidate_filter &= ~CF_HOST; 453 candidate_filter &= ~CF_HOST;
513 } 454 }
(...skipping 22 matching lines...) Expand all
536 MaybeSignalCandidatesAllocationDone(); 477 MaybeSignalCandidatesAllocationDone();
537 } 478 }
538 479
539 void BasicPortAllocatorSession::OnCandidateReady( 480 void BasicPortAllocatorSession::OnCandidateReady(
540 Port* port, const Candidate& c) { 481 Port* port, const Candidate& c) {
541 ASSERT(rtc::Thread::Current() == network_thread_); 482 ASSERT(rtc::Thread::Current() == network_thread_);
542 PortData* data = FindPort(port); 483 PortData* data = FindPort(port);
543 ASSERT(data != NULL); 484 ASSERT(data != NULL);
544 // Discarding any candidate signal if port allocation status is 485 // Discarding any candidate signal if port allocation status is
545 // already in completed state. 486 // already in completed state.
546 if (data->complete() || data->error()) { 487 if (data->complete())
547 return; 488 return;
548 }
549 489
550 ProtocolType pvalue; 490 ProtocolType pvalue;
551 bool candidate_signalable = CheckCandidateFilter(c); 491 bool candidate_signalable = CheckCandidateFilter(c);
552 492
553 // When device enumeration is disabled (to prevent non-default IP addresses 493 // When device enumeration is disabled (to prevent non-default IP addresses
554 // from leaking), we ping from some local candidates even though we don't 494 // from leaking), we ping from some local candidates even though we don't
555 // signal them. However, if host candidates are also disabled (for example, to 495 // signal them. However, if host candidates are also disabled (for example, to
556 // prevent even default IP addresses from leaking), we still don't want to 496 // prevent even default IP addresses from leaking), we still don't want to
557 // ping from them, even if device enumeration is disabled. Thus, we check for 497 // ping from them, even if device enumeration is disabled. Thus, we check for
558 // both device enumeration and host candidates being disabled. 498 // both device enumeration and host candidates being disabled.
(...skipping 30 matching lines...) Expand all
589 SignalPortReady(this, port); 529 SignalPortReady(this, port);
590 } 530 }
591 } 531 }
592 532
593 void BasicPortAllocatorSession::OnPortComplete(Port* port) { 533 void BasicPortAllocatorSession::OnPortComplete(Port* port) {
594 ASSERT(rtc::Thread::Current() == network_thread_); 534 ASSERT(rtc::Thread::Current() == network_thread_);
595 PortData* data = FindPort(port); 535 PortData* data = FindPort(port);
596 ASSERT(data != NULL); 536 ASSERT(data != NULL);
597 537
598 // Ignore any late signals. 538 // Ignore any late signals.
599 if (data->complete() || data->error()) { 539 if (data->complete())
600 return; 540 return;
601 }
602 541
603 // Moving to COMPLETE state. 542 // Moving to COMPLETE state.
604 data->set_complete(); 543 data->set_complete();
605 // Send candidate allocation complete signal if this was the last port. 544 // Send candidate allocation complete signal if this was the last port.
606 MaybeSignalCandidatesAllocationDone(); 545 MaybeSignalCandidatesAllocationDone();
607 } 546 }
608 547
609 void BasicPortAllocatorSession::OnPortError(Port* port) { 548 void BasicPortAllocatorSession::OnPortError(Port* port) {
610 ASSERT(rtc::Thread::Current() == network_thread_); 549 ASSERT(rtc::Thread::Current() == network_thread_);
611 PortData* data = FindPort(port); 550 PortData* data = FindPort(port);
612 ASSERT(data != NULL); 551 ASSERT(data != NULL);
613 // We might have already given up on this port and stopped it. 552 // We might have already given up on this port and stopped it.
614 if (data->complete() || data->error()) { 553 if (data->complete())
615 return; 554 return;
616 }
617 555
618 // SignalAddressError is currently sent from StunPort/TurnPort. 556 // SignalAddressError is currently sent from StunPort/TurnPort.
619 // But this signal itself is generic. 557 // But this signal itself is generic.
620 data->set_error(); 558 data->set_error();
621 // Send candidate allocation complete signal if this was the last port. 559 // Send candidate allocation complete signal if this was the last port.
622 MaybeSignalCandidatesAllocationDone(); 560 MaybeSignalCandidatesAllocationDone();
623 } 561 }
624 562
625 void BasicPortAllocatorSession::OnProtocolEnabled(AllocationSequence* seq, 563 void BasicPortAllocatorSession::OnProtocolEnabled(AllocationSequence* seq,
626 ProtocolType proto) { 564 ProtocolType proto) {
(...skipping 15 matching lines...) Expand all
642 candidates.push_back(potentials[i]); 580 candidates.push_back(potentials[i]);
643 } 581 }
644 } 582 }
645 } 583 }
646 584
647 if (!candidates.empty()) { 585 if (!candidates.empty()) {
648 SignalCandidatesReady(this, candidates); 586 SignalCandidatesReady(this, candidates);
649 } 587 }
650 } 588 }
651 589
652 bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) const { 590 bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) {
653 uint32_t filter = allocator_->candidate_filter(); 591 uint32_t filter = allocator_->candidate_filter();
654 592
655 // When binding to any address, before sending packets out, the getsockname 593 // When binding to any address, before sending packets out, the getsockname
656 // returns all 0s, but after sending packets, it'll be the NIC used to 594 // returns all 0s, but after sending packets, it'll be the NIC used to
657 // send. All 0s is not a valid ICE candidate address and should be filtered 595 // send. All 0s is not a valid ICE candidate address and should be filtered
658 // out. 596 // out.
659 if (c.address().IsAnyIP()) { 597 if (c.address().IsAnyIP()) {
660 return false; 598 return false;
661 } 599 }
662 600
(...skipping 17 matching lines...) Expand all
680 return false; 618 return false;
681 } 619 }
682 620
683 void BasicPortAllocatorSession::OnPortAllocationComplete( 621 void BasicPortAllocatorSession::OnPortAllocationComplete(
684 AllocationSequence* seq) { 622 AllocationSequence* seq) {
685 // Send candidate allocation complete signal if all ports are done. 623 // Send candidate allocation complete signal if all ports are done.
686 MaybeSignalCandidatesAllocationDone(); 624 MaybeSignalCandidatesAllocationDone();
687 } 625 }
688 626
689 void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() { 627 void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
690 if (CandidatesAllocationDone()) { 628 // Send signal only if all required AllocationSequence objects
691 if (pooled()) { 629 // are created.
692 LOG(LS_INFO) << "All candidates gathered for pooled session."; 630 if (!allocation_sequences_created_)
693 } else { 631 return;
694 LOG(LS_INFO) << "All candidates gathered for " << content_name() << ":" 632
695 << component() << ":" << generation(); 633 // Check that all port allocation sequences are complete.
696 } 634 for (std::vector<AllocationSequence*>::iterator it = sequences_.begin();
697 SignalCandidatesAllocationDone(this); 635 it != sequences_.end(); ++it) {
636 if ((*it)->state() == AllocationSequence::kRunning)
637 return;
698 } 638 }
639
640 // If all allocated ports are in complete state, session must have got all
641 // expected candidates. Session will trigger candidates allocation complete
642 // signal.
643 for (std::vector<PortData>::iterator it = ports_.begin();
644 it != ports_.end(); ++it) {
645 if (!it->complete())
646 return;
647 }
648 LOG(LS_INFO) << "All candidates gathered for " << content_name_ << ":"
649 << component_ << ":" << generation();
650 SignalCandidatesAllocationDone(this);
699 } 651 }
700 652
701 void BasicPortAllocatorSession::OnPortDestroyed( 653 void BasicPortAllocatorSession::OnPortDestroyed(
702 PortInterface* port) { 654 PortInterface* port) {
703 ASSERT(rtc::Thread::Current() == network_thread_); 655 ASSERT(rtc::Thread::Current() == network_thread_);
704 for (std::vector<PortData>::iterator iter = ports_.begin(); 656 for (std::vector<PortData>::iterator iter = ports_.begin();
705 iter != ports_.end(); ++iter) { 657 iter != ports_.end(); ++iter) {
706 if (port == iter->port()) { 658 if (port == iter->port()) {
707 ports_.erase(iter); 659 ports_.erase(iter);
708 LOG_J(LS_INFO, port) << "Removed port from allocator (" 660 LOG_J(LS_INFO, port) << "Removed port from allocator ("
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 ServerAddresses servers; 1184 ServerAddresses servers;
1233 for (size_t i = 0; i < relays.size(); ++i) { 1185 for (size_t i = 0; i < relays.size(); ++i) {
1234 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { 1186 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {
1235 servers.insert(relays[i].ports.front().address); 1187 servers.insert(relays[i].ports.front().address);
1236 } 1188 }
1237 } 1189 }
1238 return servers; 1190 return servers;
1239 } 1191 }
1240 1192
1241 } // namespace cricket 1193 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/client/basicportallocator.h ('k') | webrtc/p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698