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

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

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