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

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

Issue 2620303003: Replace ASSERT by RTC_DCHECK in all non-test code. (Closed)
Patch Set: Address final nits. Created 3 years, 11 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
« no previous file with comments | « webrtc/p2p/client/basicportallocator.h ('k') | webrtc/p2p/client/socketmonitor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 namespace cricket { 94 namespace cricket {
95 const uint32_t DISABLE_ALL_PHASES = 95 const uint32_t DISABLE_ALL_PHASES =
96 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP | 96 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP |
97 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY; 97 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY;
98 98
99 // BasicPortAllocator 99 // BasicPortAllocator
100 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager, 100 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager,
101 rtc::PacketSocketFactory* socket_factory) 101 rtc::PacketSocketFactory* socket_factory)
102 : network_manager_(network_manager), socket_factory_(socket_factory) { 102 : network_manager_(network_manager), socket_factory_(socket_factory) {
103 ASSERT(network_manager_ != nullptr); 103 RTC_DCHECK(network_manager_ != nullptr);
104 ASSERT(socket_factory_ != nullptr); 104 RTC_DCHECK(socket_factory_ != nullptr);
105 Construct(); 105 Construct();
106 } 106 }
107 107
108 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager) 108 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager)
109 : network_manager_(network_manager), socket_factory_(nullptr) { 109 : network_manager_(network_manager), socket_factory_(nullptr) {
110 ASSERT(network_manager_ != nullptr); 110 RTC_DCHECK(network_manager_ != nullptr);
111 Construct(); 111 Construct();
112 } 112 }
113 113
114 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager, 114 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager,
115 rtc::PacketSocketFactory* socket_factory, 115 rtc::PacketSocketFactory* socket_factory,
116 const ServerAddresses& stun_servers) 116 const ServerAddresses& stun_servers)
117 : network_manager_(network_manager), socket_factory_(socket_factory) { 117 : network_manager_(network_manager), socket_factory_(socket_factory) {
118 ASSERT(socket_factory_ != NULL); 118 RTC_DCHECK(socket_factory_ != NULL);
119 SetConfiguration(stun_servers, std::vector<RelayServerConfig>(), 0, false); 119 SetConfiguration(stun_servers, std::vector<RelayServerConfig>(), 0, false);
120 Construct(); 120 Construct();
121 } 121 }
122 122
123 BasicPortAllocator::BasicPortAllocator( 123 BasicPortAllocator::BasicPortAllocator(
124 rtc::NetworkManager* network_manager, 124 rtc::NetworkManager* network_manager,
125 const ServerAddresses& stun_servers, 125 const ServerAddresses& stun_servers,
126 const rtc::SocketAddress& relay_address_udp, 126 const rtc::SocketAddress& relay_address_udp,
127 const rtc::SocketAddress& relay_address_tcp, 127 const rtc::SocketAddress& relay_address_tcp,
128 const rtc::SocketAddress& relay_address_ssl) 128 const rtc::SocketAddress& relay_address_ssl)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 socket_factory_ = owned_socket_factory_.get(); 267 socket_factory_ = owned_socket_factory_.get();
268 } 268 }
269 269
270 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_START); 270 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_START);
271 271
272 LOG(LS_INFO) << "Start getting ports with prune_turn_ports " 272 LOG(LS_INFO) << "Start getting ports with prune_turn_ports "
273 << (prune_turn_ports_ ? "enabled" : "disabled"); 273 << (prune_turn_ports_ ? "enabled" : "disabled");
274 } 274 }
275 275
276 void BasicPortAllocatorSession::StopGettingPorts() { 276 void BasicPortAllocatorSession::StopGettingPorts() {
277 ASSERT(rtc::Thread::Current() == network_thread_); 277 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
278 ClearGettingPorts(); 278 ClearGettingPorts();
279 // Note: this must be called after ClearGettingPorts because both may set the 279 // Note: this must be called after ClearGettingPorts because both may set the
280 // session state and we should set the state to STOPPED. 280 // session state and we should set the state to STOPPED.
281 state_ = SessionState::STOPPED; 281 state_ = SessionState::STOPPED;
282 } 282 }
283 283
284 void BasicPortAllocatorSession::ClearGettingPorts() { 284 void BasicPortAllocatorSession::ClearGettingPorts() {
285 ASSERT(rtc::Thread::Current() == network_thread_); 285 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
286 network_thread_->Clear(this, MSG_ALLOCATE); 286 network_thread_->Clear(this, MSG_ALLOCATE);
287 for (uint32_t i = 0; i < sequences_.size(); ++i) { 287 for (uint32_t i = 0; i < sequences_.size(); ++i) {
288 sequences_[i]->Stop(); 288 sequences_[i]->Stop();
289 } 289 }
290 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_STOP); 290 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_STOP);
291 state_ = SessionState::CLEARED; 291 state_ = SessionState::CLEARED;
292 } 292 }
293 293
294 std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() { 294 std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() {
295 std::vector<rtc::Network*> networks = GetNetworks(); 295 std::vector<rtc::Network*> networks = GetNetworks();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // If all allocated ports are no longer gathering, session must have got all 428 // If all allocated ports are no longer gathering, session must have got all
429 // expected candidates. Session will trigger candidates allocation complete 429 // expected candidates. Session will trigger candidates allocation complete
430 // signal. 430 // signal.
431 return std::none_of(ports_.begin(), ports_.end(), 431 return std::none_of(ports_.begin(), ports_.end(),
432 [](const PortData& port) { return port.inprogress(); }); 432 [](const PortData& port) { return port.inprogress(); });
433 } 433 }
434 434
435 void BasicPortAllocatorSession::OnMessage(rtc::Message *message) { 435 void BasicPortAllocatorSession::OnMessage(rtc::Message *message) {
436 switch (message->message_id) { 436 switch (message->message_id) {
437 case MSG_CONFIG_START: 437 case MSG_CONFIG_START:
438 ASSERT(rtc::Thread::Current() == network_thread_); 438 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
439 GetPortConfigurations(); 439 GetPortConfigurations();
440 break; 440 break;
441 case MSG_CONFIG_READY: 441 case MSG_CONFIG_READY:
442 ASSERT(rtc::Thread::Current() == network_thread_); 442 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
443 OnConfigReady(static_cast<PortConfiguration*>(message->pdata)); 443 OnConfigReady(static_cast<PortConfiguration*>(message->pdata));
444 break; 444 break;
445 case MSG_ALLOCATE: 445 case MSG_ALLOCATE:
446 ASSERT(rtc::Thread::Current() == network_thread_); 446 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
447 OnAllocate(); 447 OnAllocate();
448 break; 448 break;
449 case MSG_SEQUENCEOBJECTS_CREATED: 449 case MSG_SEQUENCEOBJECTS_CREATED:
450 ASSERT(rtc::Thread::Current() == network_thread_); 450 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
451 OnAllocationSequenceObjectsCreated(); 451 OnAllocationSequenceObjectsCreated();
452 break; 452 break;
453 case MSG_CONFIG_STOP: 453 case MSG_CONFIG_STOP:
454 ASSERT(rtc::Thread::Current() == network_thread_); 454 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
455 OnConfigStop(); 455 OnConfigStop();
456 break; 456 break;
457 default: 457 default:
458 RTC_NOTREACHED(); 458 RTC_NOTREACHED();
459 } 459 }
460 } 460 }
461 461
462 void BasicPortAllocatorSession::UpdateIceParametersInternal() { 462 void BasicPortAllocatorSession::UpdateIceParametersInternal() {
463 for (PortData& port : ports_) { 463 for (PortData& port : ports_) {
464 port.port()->set_content_name(content_name()); 464 port.port()->set_content_name(content_name());
(...skipping 19 matching lines...) Expand all
484 // Adds a configuration to the list. 484 // Adds a configuration to the list.
485 void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) { 485 void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) {
486 if (config) { 486 if (config) {
487 configs_.push_back(config); 487 configs_.push_back(config);
488 } 488 }
489 489
490 AllocatePorts(); 490 AllocatePorts();
491 } 491 }
492 492
493 void BasicPortAllocatorSession::OnConfigStop() { 493 void BasicPortAllocatorSession::OnConfigStop() {
494 ASSERT(rtc::Thread::Current() == network_thread_); 494 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
495 495
496 // If any of the allocated ports have not completed the candidates allocation, 496 // If any of the allocated ports have not completed the candidates allocation,
497 // mark those as error. Since session doesn't need any new candidates 497 // mark those as error. Since session doesn't need any new candidates
498 // at this stage of the allocation, it's safe to discard any new candidates. 498 // at this stage of the allocation, it's safe to discard any new candidates.
499 bool send_signal = false; 499 bool send_signal = false;
500 for (std::vector<PortData>::iterator it = ports_.begin(); 500 for (std::vector<PortData>::iterator it = ports_.begin();
501 it != ports_.end(); ++it) { 501 it != ports_.end(); ++it) {
502 if (it->inprogress()) { 502 if (it->inprogress()) {
503 // Updating port state to error, which didn't finish allocating candidates 503 // Updating port state to error, which didn't finish allocating candidates
504 // yet. 504 // yet.
(...skipping 10 matching lines...) Expand all
515 } 515 }
516 } 516 }
517 517
518 // If we stopped anything that was running, send a done signal now. 518 // If we stopped anything that was running, send a done signal now.
519 if (send_signal) { 519 if (send_signal) {
520 MaybeSignalCandidatesAllocationDone(); 520 MaybeSignalCandidatesAllocationDone();
521 } 521 }
522 } 522 }
523 523
524 void BasicPortAllocatorSession::AllocatePorts() { 524 void BasicPortAllocatorSession::AllocatePorts() {
525 ASSERT(rtc::Thread::Current() == network_thread_); 525 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
526 network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE); 526 network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE);
527 } 527 }
528 528
529 void BasicPortAllocatorSession::OnAllocate() { 529 void BasicPortAllocatorSession::OnAllocate() {
530 if (network_manager_started_ && !IsStopped()) 530 if (network_manager_started_ && !IsStopped())
531 DoAllocate(); 531 DoAllocate();
532 532
533 allocation_started_ = true; 533 allocation_started_ = true;
534 } 534 }
535 535
536 std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() { 536 std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
537 std::vector<rtc::Network*> networks; 537 std::vector<rtc::Network*> networks;
538 rtc::NetworkManager* network_manager = allocator_->network_manager(); 538 rtc::NetworkManager* network_manager = allocator_->network_manager();
539 ASSERT(network_manager != nullptr); 539 RTC_DCHECK(network_manager != nullptr);
540 // If the network permission state is BLOCKED, we just act as if the flag has 540 // If the network permission state is BLOCKED, we just act as if the flag has
541 // been passed in. 541 // been passed in.
542 if (network_manager->enumeration_permission() == 542 if (network_manager->enumeration_permission() ==
543 rtc::NetworkManager::ENUMERATION_BLOCKED) { 543 rtc::NetworkManager::ENUMERATION_BLOCKED) {
544 set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); 544 set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
545 } 545 }
546 // If the adapter enumeration is disabled, we'll just bind to any address 546 // If the adapter enumeration is disabled, we'll just bind to any address
547 // instead of specific NIC. This is to ensure the same routing for http 547 // instead of specific NIC. This is to ensure the same routing for http
548 // traffic by OS is also used here to avoid any local or public IP leakage 548 // traffic by OS is also used here to avoid any local or public IP leakage
549 // during stun process. 549 // during stun process.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 713 }
714 714
715 void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() { 715 void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {
716 allocation_sequences_created_ = true; 716 allocation_sequences_created_ = true;
717 // Send candidate allocation complete signal if we have no sequences. 717 // Send candidate allocation complete signal if we have no sequences.
718 MaybeSignalCandidatesAllocationDone(); 718 MaybeSignalCandidatesAllocationDone();
719 } 719 }
720 720
721 void BasicPortAllocatorSession::OnCandidateReady( 721 void BasicPortAllocatorSession::OnCandidateReady(
722 Port* port, const Candidate& c) { 722 Port* port, const Candidate& c) {
723 ASSERT(rtc::Thread::Current() == network_thread_); 723 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
724 PortData* data = FindPort(port); 724 PortData* data = FindPort(port);
725 ASSERT(data != NULL); 725 RTC_DCHECK(data != NULL);
726 LOG_J(LS_INFO, port) << "Gathered candidate: " << c.ToSensitiveString(); 726 LOG_J(LS_INFO, port) << "Gathered candidate: " << c.ToSensitiveString();
727 // Discarding any candidate signal if port allocation status is 727 // Discarding any candidate signal if port allocation status is
728 // already done with gathering. 728 // already done with gathering.
729 if (!data->inprogress()) { 729 if (!data->inprogress()) {
730 LOG(LS_WARNING) 730 LOG(LS_WARNING)
731 << "Discarding candidate because port is already done gathering."; 731 << "Discarding candidate because port is already done gathering.";
732 return; 732 return;
733 } 733 }
734 734
735 // Mark that the port has a pairable candidate, either because we have a 735 // Mark that the port has a pairable candidate, either because we have a
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 return pruned; 824 return pruned;
825 } 825 }
826 826
827 void BasicPortAllocatorSession::PruneAllPorts() { 827 void BasicPortAllocatorSession::PruneAllPorts() {
828 for (PortData& data : ports_) { 828 for (PortData& data : ports_) {
829 data.Prune(); 829 data.Prune();
830 } 830 }
831 } 831 }
832 832
833 void BasicPortAllocatorSession::OnPortComplete(Port* port) { 833 void BasicPortAllocatorSession::OnPortComplete(Port* port) {
834 ASSERT(rtc::Thread::Current() == network_thread_); 834 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
835 LOG_J(LS_INFO, port) << "Port completed gathering candidates."; 835 LOG_J(LS_INFO, port) << "Port completed gathering candidates.";
836 PortData* data = FindPort(port); 836 PortData* data = FindPort(port);
837 ASSERT(data != NULL); 837 RTC_DCHECK(data != NULL);
838 838
839 // Ignore any late signals. 839 // Ignore any late signals.
840 if (!data->inprogress()) { 840 if (!data->inprogress()) {
841 return; 841 return;
842 } 842 }
843 843
844 // Moving to COMPLETE state. 844 // Moving to COMPLETE state.
845 data->set_complete(); 845 data->set_complete();
846 // Send candidate allocation complete signal if this was the last port. 846 // Send candidate allocation complete signal if this was the last port.
847 MaybeSignalCandidatesAllocationDone(); 847 MaybeSignalCandidatesAllocationDone();
848 } 848 }
849 849
850 void BasicPortAllocatorSession::OnPortError(Port* port) { 850 void BasicPortAllocatorSession::OnPortError(Port* port) {
851 ASSERT(rtc::Thread::Current() == network_thread_); 851 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
852 LOG_J(LS_INFO, port) << "Port encountered error while gathering candidates."; 852 LOG_J(LS_INFO, port) << "Port encountered error while gathering candidates.";
853 PortData* data = FindPort(port); 853 PortData* data = FindPort(port);
854 ASSERT(data != NULL); 854 RTC_DCHECK(data != NULL);
855 // We might have already given up on this port and stopped it. 855 // We might have already given up on this port and stopped it.
856 if (!data->inprogress()) { 856 if (!data->inprogress()) {
857 return; 857 return;
858 } 858 }
859 859
860 // SignalAddressError is currently sent from StunPort/TurnPort. 860 // SignalAddressError is currently sent from StunPort/TurnPort.
861 // But this signal itself is generic. 861 // But this signal itself is generic.
862 data->set_error(); 862 data->set_error();
863 // Send candidate allocation complete signal if this was the last port. 863 // Send candidate allocation complete signal if this was the last port.
864 MaybeSignalCandidatesAllocationDone(); 864 MaybeSignalCandidatesAllocationDone();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 } else { 958 } else {
959 LOG(LS_INFO) << "All candidates gathered for " << content_name() << ":" 959 LOG(LS_INFO) << "All candidates gathered for " << content_name() << ":"
960 << component() << ":" << generation(); 960 << component() << ":" << generation();
961 } 961 }
962 SignalCandidatesAllocationDone(this); 962 SignalCandidatesAllocationDone(this);
963 } 963 }
964 } 964 }
965 965
966 void BasicPortAllocatorSession::OnPortDestroyed( 966 void BasicPortAllocatorSession::OnPortDestroyed(
967 PortInterface* port) { 967 PortInterface* port) {
968 ASSERT(rtc::Thread::Current() == network_thread_); 968 RTC_DCHECK(rtc::Thread::Current() == network_thread_);
969 for (std::vector<PortData>::iterator iter = ports_.begin(); 969 for (std::vector<PortData>::iterator iter = ports_.begin();
970 iter != ports_.end(); ++iter) { 970 iter != ports_.end(); ++iter) {
971 if (port == iter->port()) { 971 if (port == iter->port()) {
972 ports_.erase(iter); 972 ports_.erase(iter);
973 LOG_J(LS_INFO, port) << "Removed port from allocator (" 973 LOG_J(LS_INFO, port) << "Removed port from allocator ("
974 << static_cast<int>(ports_.size()) << " remaining)"; 974 << static_cast<int>(ports_.size()) << " remaining)";
975 return; 975 return;
976 } 976 }
977 } 977 }
978 RTC_NOTREACHED(); 978 RTC_NOTREACHED();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1116
1117 void AllocationSequence::Stop() { 1117 void AllocationSequence::Stop() {
1118 // If the port is completed, don't set it to stopped. 1118 // If the port is completed, don't set it to stopped.
1119 if (state_ == kRunning) { 1119 if (state_ == kRunning) {
1120 state_ = kStopped; 1120 state_ = kStopped;
1121 session_->network_thread()->Clear(this, MSG_ALLOCATION_PHASE); 1121 session_->network_thread()->Clear(this, MSG_ALLOCATION_PHASE);
1122 } 1122 }
1123 } 1123 }
1124 1124
1125 void AllocationSequence::OnMessage(rtc::Message* msg) { 1125 void AllocationSequence::OnMessage(rtc::Message* msg) {
1126 ASSERT(rtc::Thread::Current() == session_->network_thread()); 1126 RTC_DCHECK(rtc::Thread::Current() == session_->network_thread());
1127 ASSERT(msg->message_id == MSG_ALLOCATION_PHASE); 1127 RTC_DCHECK(msg->message_id == MSG_ALLOCATION_PHASE);
1128 1128
1129 const char* const PHASE_NAMES[kNumPhases] = { 1129 const char* const PHASE_NAMES[kNumPhases] = {
1130 "Udp", "Relay", "Tcp", "SslTcp" 1130 "Udp", "Relay", "Tcp", "SslTcp"
1131 }; 1131 };
1132 1132
1133 // Perform all of the phases in the current step. 1133 // Perform all of the phases in the current step.
1134 LOG_J(LS_INFO, network_) << "Allocation Phase=" 1134 LOG_J(LS_INFO, network_) << "Allocation Phase="
1135 << PHASE_NAMES[phase_]; 1135 << PHASE_NAMES[phase_];
1136 1136
1137 switch (phase_) { 1137 switch (phase_) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 } 1285 }
1286 1286
1287 void AllocationSequence::CreateRelayPorts() { 1287 void AllocationSequence::CreateRelayPorts() {
1288 if (IsFlagSet(PORTALLOCATOR_DISABLE_RELAY)) { 1288 if (IsFlagSet(PORTALLOCATOR_DISABLE_RELAY)) {
1289 LOG(LS_VERBOSE) << "AllocationSequence: Relay ports disabled, skipping."; 1289 LOG(LS_VERBOSE) << "AllocationSequence: Relay ports disabled, skipping.";
1290 return; 1290 return;
1291 } 1291 }
1292 1292
1293 // If BasicPortAllocatorSession::OnAllocate left relay ports enabled then we 1293 // If BasicPortAllocatorSession::OnAllocate left relay ports enabled then we
1294 // ought to have a relay list for them here. 1294 // ought to have a relay list for them here.
1295 ASSERT(config_ && !config_->relays.empty()); 1295 RTC_DCHECK(config_ && !config_->relays.empty());
1296 if (!(config_ && !config_->relays.empty())) { 1296 if (!(config_ && !config_->relays.empty())) {
1297 LOG(LS_WARNING) 1297 LOG(LS_WARNING)
1298 << "AllocationSequence: No relay server configured, skipping."; 1298 << "AllocationSequence: No relay server configured, skipping.";
1299 return; 1299 return;
1300 } 1300 }
1301 1301
1302 for (RelayServerConfig& relay : config_->relays) { 1302 for (RelayServerConfig& relay : config_->relays) {
1303 if (relay.type == RELAY_GTURN) { 1303 if (relay.type == RELAY_GTURN) {
1304 CreateGturnPort(relay); 1304 CreateGturnPort(relay);
1305 } else if (relay.type == RELAY_TURN) { 1305 } else if (relay.type == RELAY_TURN) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 port = TurnPort::Create(session_->network_thread(), 1386 port = TurnPort::Create(session_->network_thread(),
1387 session_->socket_factory(), 1387 session_->socket_factory(),
1388 network_, ip_, 1388 network_, ip_,
1389 session_->allocator()->min_port(), 1389 session_->allocator()->min_port(),
1390 session_->allocator()->max_port(), 1390 session_->allocator()->max_port(),
1391 session_->username(), 1391 session_->username(),
1392 session_->password(), 1392 session_->password(),
1393 *relay_port, config.credentials, config.priority, 1393 *relay_port, config.credentials, config.priority,
1394 session_->allocator()->origin()); 1394 session_->allocator()->origin());
1395 } 1395 }
1396 ASSERT(port != NULL); 1396 RTC_DCHECK(port != NULL);
1397 port->SetTlsCertPolicy(config.tls_cert_policy); 1397 port->SetTlsCertPolicy(config.tls_cert_policy);
1398 session_->AddAllocatedPort(port, this, true); 1398 session_->AddAllocatedPort(port, this, true);
1399 } 1399 }
1400 } 1400 }
1401 1401
1402 void AllocationSequence::OnReadPacket( 1402 void AllocationSequence::OnReadPacket(
1403 rtc::AsyncPacketSocket* socket, const char* data, size_t size, 1403 rtc::AsyncPacketSocket* socket, const char* data, size_t size,
1404 const rtc::SocketAddress& remote_addr, 1404 const rtc::SocketAddress& remote_addr,
1405 const rtc::PacketTime& packet_time) { 1405 const rtc::PacketTime& packet_time) {
1406 ASSERT(socket == udp_socket_.get()); 1406 RTC_DCHECK(socket == udp_socket_.get());
1407 1407
1408 bool turn_port_found = false; 1408 bool turn_port_found = false;
1409 1409
1410 // Try to find the TurnPort that matches the remote address. Note that the 1410 // Try to find the TurnPort that matches the remote address. Note that the
1411 // message could be a STUN binding response if the TURN server is also used as 1411 // message could be a STUN binding response if the TURN server is also used as
1412 // a STUN server. We don't want to parse every message here to check if it is 1412 // a STUN server. We don't want to parse every message here to check if it is
1413 // a STUN binding response, so we pass the message to TurnPort regardless of 1413 // a STUN binding response, so we pass the message to TurnPort regardless of
1414 // the message type. The TurnPort will just ignore the message since it will 1414 // the message type. The TurnPort will just ignore the message since it will
1415 // not find any request by transaction ID. 1415 // not find any request by transaction ID.
1416 for (TurnPort* port : turn_ports_) { 1416 for (TurnPort* port : turn_ports_) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 ServerAddresses servers; 1518 ServerAddresses servers;
1519 for (size_t i = 0; i < relays.size(); ++i) { 1519 for (size_t i = 0; i < relays.size(); ++i) {
1520 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { 1520 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {
1521 servers.insert(relays[i].ports.front().address); 1521 servers.insert(relays[i].ports.front().address);
1522 } 1522 }
1523 } 1523 }
1524 return servers; 1524 return servers;
1525 } 1525 }
1526 1526
1527 } // namespace cricket 1527 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/client/basicportallocator.h ('k') | webrtc/p2p/client/socketmonitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698