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 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 void BasicPortAllocatorSession::StartGettingPorts() { | 193 void BasicPortAllocatorSession::StartGettingPorts() { |
194 network_thread_ = rtc::Thread::Current(); | 194 network_thread_ = rtc::Thread::Current(); |
195 if (!socket_factory_) { | 195 if (!socket_factory_) { |
196 owned_socket_factory_.reset( | 196 owned_socket_factory_.reset( |
197 new rtc::BasicPacketSocketFactory(network_thread_)); | 197 new rtc::BasicPacketSocketFactory(network_thread_)); |
198 socket_factory_ = owned_socket_factory_.get(); | 198 socket_factory_ = owned_socket_factory_.get(); |
199 } | 199 } |
200 | 200 |
201 running_ = true; | 201 running_ = true; |
202 network_thread_->Post(this, MSG_CONFIG_START); | 202 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_START); |
203 } | 203 } |
204 | 204 |
205 void BasicPortAllocatorSession::StopGettingPorts() { | 205 void BasicPortAllocatorSession::StopGettingPorts() { |
206 ASSERT(rtc::Thread::Current() == network_thread_); | 206 ASSERT(rtc::Thread::Current() == network_thread_); |
207 running_ = false; | 207 running_ = false; |
208 network_thread_->Post(this, MSG_CONFIG_STOP); | 208 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_STOP); |
209 ClearGettingPorts(); | 209 ClearGettingPorts(); |
210 } | 210 } |
211 | 211 |
212 void BasicPortAllocatorSession::ClearGettingPorts() { | 212 void BasicPortAllocatorSession::ClearGettingPorts() { |
213 network_thread_->Clear(this, MSG_ALLOCATE); | 213 network_thread_->Clear(this, MSG_ALLOCATE); |
214 for (uint32_t i = 0; i < sequences_.size(); ++i) | 214 for (uint32_t i = 0; i < sequences_.size(); ++i) |
215 sequences_[i]->Stop(); | 215 sequences_[i]->Stop(); |
216 } | 216 } |
217 | 217 |
218 std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const { | 218 std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 username(), | 329 username(), |
330 password()); | 330 password()); |
331 | 331 |
332 for (const RelayServerConfig& turn_server : allocator_->turn_servers()) { | 332 for (const RelayServerConfig& turn_server : allocator_->turn_servers()) { |
333 config->AddRelay(turn_server); | 333 config->AddRelay(turn_server); |
334 } | 334 } |
335 ConfigReady(config); | 335 ConfigReady(config); |
336 } | 336 } |
337 | 337 |
338 void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) { | 338 void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) { |
339 network_thread_->Post(this, MSG_CONFIG_READY, config); | 339 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_READY, config); |
340 } | 340 } |
341 | 341 |
342 // Adds a configuration to the list. | 342 // Adds a configuration to the list. |
343 void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) { | 343 void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) { |
344 if (config) { | 344 if (config) { |
345 configs_.push_back(config); | 345 configs_.push_back(config); |
346 } | 346 } |
347 | 347 |
348 AllocatePorts(); | 348 AllocatePorts(); |
349 } | 349 } |
(...skipping 24 matching lines...) Expand all Loading... |
374 } | 374 } |
375 | 375 |
376 // If we stopped anything that was running, send a done signal now. | 376 // If we stopped anything that was running, send a done signal now. |
377 if (send_signal) { | 377 if (send_signal) { |
378 MaybeSignalCandidatesAllocationDone(); | 378 MaybeSignalCandidatesAllocationDone(); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 void BasicPortAllocatorSession::AllocatePorts() { | 382 void BasicPortAllocatorSession::AllocatePorts() { |
383 ASSERT(rtc::Thread::Current() == network_thread_); | 383 ASSERT(rtc::Thread::Current() == network_thread_); |
384 network_thread_->Post(this, MSG_ALLOCATE); | 384 network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE); |
385 } | 385 } |
386 | 386 |
387 void BasicPortAllocatorSession::OnAllocate() { | 387 void BasicPortAllocatorSession::OnAllocate() { |
388 if (network_manager_started_) | 388 if (network_manager_started_) |
389 DoAllocate(); | 389 DoAllocate(); |
390 | 390 |
391 allocation_started_ = true; | 391 allocation_started_ = true; |
392 } | 392 } |
393 | 393 |
394 void BasicPortAllocatorSession::GetNetworks( | 394 void BasicPortAllocatorSession::GetNetworks( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 } | 484 } |
485 done_signal_needed = true; | 485 done_signal_needed = true; |
486 sequence->SignalPortAllocationComplete.connect( | 486 sequence->SignalPortAllocationComplete.connect( |
487 this, &BasicPortAllocatorSession::OnPortAllocationComplete); | 487 this, &BasicPortAllocatorSession::OnPortAllocationComplete); |
488 if (running_) | 488 if (running_) |
489 sequence->Start(); | 489 sequence->Start(); |
490 sequences_.push_back(sequence); | 490 sequences_.push_back(sequence); |
491 } | 491 } |
492 } | 492 } |
493 if (done_signal_needed) { | 493 if (done_signal_needed) { |
494 network_thread_->Post(this, MSG_SEQUENCEOBJECTS_CREATED); | 494 network_thread_->Post(RTC_FROM_HERE, this, MSG_SEQUENCEOBJECTS_CREATED); |
495 } | 495 } |
496 } | 496 } |
497 | 497 |
498 void BasicPortAllocatorSession::OnNetworksChanged() { | 498 void BasicPortAllocatorSession::OnNetworksChanged() { |
499 std::vector<rtc::Network*> networks; | 499 std::vector<rtc::Network*> networks; |
500 GetNetworks(&networks); | 500 GetNetworks(&networks); |
501 for (AllocationSequence* sequence : sequences_) { | 501 for (AllocationSequence* sequence : sequences_) { |
502 // Remove the network from the allocation sequence if it is not in | 502 // Remove the network from the allocation sequence if it is not in |
503 // |networks|. | 503 // |networks|. |
504 if (!sequence->network_removed() && | 504 if (!sequence->network_removed() && |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 // were to be given one, but that never happens in our codebase. Should | 833 // were to be given one, but that never happens in our codebase. Should |
834 // probably get rid of the list in PortConfiguration and just keep a | 834 // probably get rid of the list in PortConfiguration and just keep a |
835 // single relay server in each one. | 835 // single relay server in each one. |
836 *flags |= PORTALLOCATOR_DISABLE_RELAY; | 836 *flags |= PORTALLOCATOR_DISABLE_RELAY; |
837 } | 837 } |
838 } | 838 } |
839 } | 839 } |
840 | 840 |
841 void AllocationSequence::Start() { | 841 void AllocationSequence::Start() { |
842 state_ = kRunning; | 842 state_ = kRunning; |
843 session_->network_thread()->Post(this, MSG_ALLOCATION_PHASE); | 843 session_->network_thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATION_PHASE); |
844 } | 844 } |
845 | 845 |
846 void AllocationSequence::Stop() { | 846 void AllocationSequence::Stop() { |
847 // If the port is completed, don't set it to stopped. | 847 // If the port is completed, don't set it to stopped. |
848 if (state_ == kRunning) { | 848 if (state_ == kRunning) { |
849 state_ = kStopped; | 849 state_ = kStopped; |
850 session_->network_thread()->Clear(this, MSG_ALLOCATION_PHASE); | 850 session_->network_thread()->Clear(this, MSG_ALLOCATION_PHASE); |
851 } | 851 } |
852 } | 852 } |
853 | 853 |
(...skipping 29 matching lines...) Expand all Loading... |
883 state_ = kCompleted; | 883 state_ = kCompleted; |
884 EnableProtocol(PROTO_SSLTCP); | 884 EnableProtocol(PROTO_SSLTCP); |
885 break; | 885 break; |
886 | 886 |
887 default: | 887 default: |
888 ASSERT(false); | 888 ASSERT(false); |
889 } | 889 } |
890 | 890 |
891 if (state() == kRunning) { | 891 if (state() == kRunning) { |
892 ++phase_; | 892 ++phase_; |
893 session_->network_thread()->PostDelayed( | 893 session_->network_thread()->PostDelayed(RTC_FROM_HERE, |
894 session_->allocator()->step_delay(), | 894 session_->allocator()->step_delay(), |
895 this, MSG_ALLOCATION_PHASE); | 895 this, MSG_ALLOCATION_PHASE); |
896 } else { | 896 } else { |
897 // If all phases in AllocationSequence are completed, no allocation | 897 // If all phases in AllocationSequence are completed, no allocation |
898 // steps needed further. Canceling pending signal. | 898 // steps needed further. Canceling pending signal. |
899 session_->network_thread()->Clear(this, MSG_ALLOCATION_PHASE); | 899 session_->network_thread()->Clear(this, MSG_ALLOCATION_PHASE); |
900 SignalPortAllocationComplete(this); | 900 SignalPortAllocationComplete(this); |
901 } | 901 } |
902 } | 902 } |
903 | 903 |
904 void AllocationSequence::EnableProtocol(ProtocolType proto) { | 904 void AllocationSequence::EnableProtocol(ProtocolType proto) { |
905 if (!ProtocolEnabled(proto)) { | 905 if (!ProtocolEnabled(proto)) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 ServerAddresses servers; | 1235 ServerAddresses servers; |
1236 for (size_t i = 0; i < relays.size(); ++i) { | 1236 for (size_t i = 0; i < relays.size(); ++i) { |
1237 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1237 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1238 servers.insert(relays[i].ports.front().address); | 1238 servers.insert(relays[i].ports.front().address); |
1239 } | 1239 } |
1240 } | 1240 } |
1241 return servers; | 1241 return servers; |
1242 } | 1242 } |
1243 | 1243 |
1244 } // namespace cricket | 1244 } // namespace cricket |
OLD | NEW |