| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2010 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 turn_servers_(allocator->turn_servers()) { | 116 turn_servers_(allocator->turn_servers()) { |
| 117 ipv4_network_.AddIP(rtc::IPAddress(INADDR_LOOPBACK)); | 117 ipv4_network_.AddIP(rtc::IPAddress(INADDR_LOOPBACK)); |
| 118 ipv6_network_.AddIP(rtc::IPAddress(in6addr_loopback)); | 118 ipv6_network_.AddIP(rtc::IPAddress(in6addr_loopback)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SetCandidateFilter(uint32_t filter) override { | 121 void SetCandidateFilter(uint32_t filter) override { |
| 122 candidate_filter_ = filter; | 122 candidate_filter_ = filter; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void StartGettingPorts() override { | 125 void StartGettingPorts() override { |
| 126 PortAllocatorSession::StartGettingPorts(); | |
| 127 if (!port_) { | 126 if (!port_) { |
| 128 rtc::Network& network = | 127 rtc::Network& network = |
| 129 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) | 128 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) |
| 130 ? ipv6_network_ | 129 ? ipv6_network_ |
| 131 : ipv4_network_; | 130 : ipv4_network_; |
| 132 port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, | 131 port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, |
| 133 network.GetBestIP(), 0, 0, username(), | 132 network.GetBestIP(), 0, 0, username(), |
| 134 password(), std::string(), false)); | 133 password(), std::string(), false)); |
| 135 port_->SignalDestroyed.connect( | 134 port_->SignalDestroyed.connect( |
| 136 this, &FakePortAllocatorSession::OnPortDestroyed); | 135 this, &FakePortAllocatorSession::OnPortDestroyed); |
| 137 AddPort(port_.get()); | 136 AddPort(port_.get()); |
| 138 } | 137 } |
| 139 ++port_config_count_; | 138 ++port_config_count_; |
| 139 running_ = true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void StopGettingPorts() override { running_ = false; } |
| 143 bool IsGettingPorts() override { return running_; } |
| 144 void ClearGettingPorts() override {} |
| 145 |
| 142 std::vector<PortInterface*> ReadyPorts() const override { | 146 std::vector<PortInterface*> ReadyPorts() const override { |
| 143 return ready_ports_; | 147 return ready_ports_; |
| 144 } | 148 } |
| 145 std::vector<Candidate> ReadyCandidates() const override { | 149 std::vector<Candidate> ReadyCandidates() const override { |
| 146 return candidates_; | 150 return candidates_; |
| 147 } | 151 } |
| 148 bool CandidatesAllocationDone() const override { return allocation_done_; } | 152 bool CandidatesAllocationDone() const override { return allocation_done_; } |
| 149 | 153 |
| 150 int port_config_count() { return port_config_count_; } | 154 int port_config_count() { return port_config_count_; } |
| 151 | 155 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 rtc::Network ipv6_network_; | 201 rtc::Network ipv6_network_; |
| 198 std::unique_ptr<cricket::Port> port_; | 202 std::unique_ptr<cricket::Port> port_; |
| 199 int port_config_count_; | 203 int port_config_count_; |
| 200 std::vector<Candidate> candidates_; | 204 std::vector<Candidate> candidates_; |
| 201 std::vector<PortInterface*> ready_ports_; | 205 std::vector<PortInterface*> ready_ports_; |
| 202 bool allocation_done_ = false; | 206 bool allocation_done_ = false; |
| 203 ServerAddresses stun_servers_; | 207 ServerAddresses stun_servers_; |
| 204 std::vector<RelayServerConfig> turn_servers_; | 208 std::vector<RelayServerConfig> turn_servers_; |
| 205 uint32_t candidate_filter_ = CF_ALL; | 209 uint32_t candidate_filter_ = CF_ALL; |
| 206 int transport_info_update_count_ = 0; | 210 int transport_info_update_count_ = 0; |
| 211 bool running_ = false; |
| 207 }; | 212 }; |
| 208 | 213 |
| 209 class FakePortAllocator : public cricket::PortAllocator { | 214 class FakePortAllocator : public cricket::PortAllocator { |
| 210 public: | 215 public: |
| 211 FakePortAllocator(rtc::Thread* network_thread, | 216 FakePortAllocator(rtc::Thread* network_thread, |
| 212 rtc::PacketSocketFactory* factory) | 217 rtc::PacketSocketFactory* factory) |
| 213 : network_thread_(network_thread), factory_(factory) { | 218 : network_thread_(network_thread), factory_(factory) { |
| 214 if (factory_ == NULL) { | 219 if (factory_ == NULL) { |
| 215 owned_factory_.reset(new rtc::BasicPacketSocketFactory(network_thread_)); | 220 owned_factory_.reset(new rtc::BasicPacketSocketFactory(network_thread_)); |
| 216 factory_ = owned_factory_.get(); | 221 factory_ = owned_factory_.get(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 240 private: | 245 private: |
| 241 rtc::Thread* network_thread_; | 246 rtc::Thread* network_thread_; |
| 242 rtc::PacketSocketFactory* factory_; | 247 rtc::PacketSocketFactory* factory_; |
| 243 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; | 248 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; |
| 244 bool initialized_ = false; | 249 bool initialized_ = false; |
| 245 }; | 250 }; |
| 246 | 251 |
| 247 } // namespace cricket | 252 } // namespace cricket |
| 248 | 253 |
| 249 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ | 254 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ |
| OLD | NEW |