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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 factory_(factory), | 104 factory_(factory), |
105 ipv4_network_("network", | 105 ipv4_network_("network", |
106 "unittest", | 106 "unittest", |
107 rtc::IPAddress(INADDR_LOOPBACK), | 107 rtc::IPAddress(INADDR_LOOPBACK), |
108 32), | 108 32), |
109 ipv6_network_("network", | 109 ipv6_network_("network", |
110 "unittest", | 110 "unittest", |
111 rtc::IPAddress(in6addr_loopback), | 111 rtc::IPAddress(in6addr_loopback), |
112 64), | 112 64), |
113 port_(), | 113 port_(), |
114 running_(false), | |
115 port_config_count_(0), | 114 port_config_count_(0), |
116 stun_servers_(allocator->stun_servers()), | 115 stun_servers_(allocator->stun_servers()), |
117 turn_servers_(allocator->turn_servers()) { | 116 turn_servers_(allocator->turn_servers()) { |
118 ipv4_network_.AddIP(rtc::IPAddress(INADDR_LOOPBACK)); | 117 ipv4_network_.AddIP(rtc::IPAddress(INADDR_LOOPBACK)); |
119 ipv6_network_.AddIP(rtc::IPAddress(in6addr_loopback)); | 118 ipv6_network_.AddIP(rtc::IPAddress(in6addr_loopback)); |
120 } | 119 } |
121 | 120 |
122 void SetCandidateFilter(uint32_t filter) override { | 121 void SetCandidateFilter(uint32_t filter) override { |
123 candidate_filter_ = filter; | 122 candidate_filter_ = filter; |
124 } | 123 } |
125 | 124 |
126 void StartGettingPorts() override { | 125 void StartGettingPorts() override { |
| 126 PortAllocatorSession::StartGettingPorts(); |
127 if (!port_) { | 127 if (!port_) { |
128 rtc::Network& network = | 128 rtc::Network& network = |
129 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) | 129 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) |
130 ? ipv6_network_ | 130 ? ipv6_network_ |
131 : ipv4_network_; | 131 : ipv4_network_; |
132 port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, | 132 port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, |
133 network.GetBestIP(), 0, 0, username(), | 133 network.GetBestIP(), 0, 0, username(), |
134 password(), std::string(), false)); | 134 password(), std::string(), false)); |
135 port_->SignalDestroyed.connect( | 135 port_->SignalDestroyed.connect( |
136 this, &FakePortAllocatorSession::OnPortDestroyed); | 136 this, &FakePortAllocatorSession::OnPortDestroyed); |
137 AddPort(port_.get()); | 137 AddPort(port_.get()); |
138 } | 138 } |
139 ++port_config_count_; | 139 ++port_config_count_; |
140 running_ = true; | |
141 } | 140 } |
142 | 141 |
143 void StopGettingPorts() override { running_ = false; } | |
144 bool IsGettingPorts() override { return running_; } | |
145 void ClearGettingPorts() override {} | |
146 std::vector<PortInterface*> ReadyPorts() const override { | 142 std::vector<PortInterface*> ReadyPorts() const override { |
147 return ready_ports_; | 143 return ready_ports_; |
148 } | 144 } |
149 std::vector<Candidate> ReadyCandidates() const override { | 145 std::vector<Candidate> ReadyCandidates() const override { |
150 return candidates_; | 146 return candidates_; |
151 } | 147 } |
152 bool CandidatesAllocationDone() const override { return allocation_done_; } | 148 bool CandidatesAllocationDone() const override { return allocation_done_; } |
153 | 149 |
154 int port_config_count() { return port_config_count_; } | 150 int port_config_count() { return port_config_count_; } |
155 | 151 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void OnPortDestroyed(cricket::PortInterface* port) { | 189 void OnPortDestroyed(cricket::PortInterface* port) { |
194 // Don't want to double-delete port if it deletes itself. | 190 // Don't want to double-delete port if it deletes itself. |
195 port_.release(); | 191 port_.release(); |
196 } | 192 } |
197 | 193 |
198 rtc::Thread* network_thread_; | 194 rtc::Thread* network_thread_; |
199 rtc::PacketSocketFactory* factory_; | 195 rtc::PacketSocketFactory* factory_; |
200 rtc::Network ipv4_network_; | 196 rtc::Network ipv4_network_; |
201 rtc::Network ipv6_network_; | 197 rtc::Network ipv6_network_; |
202 std::unique_ptr<cricket::Port> port_; | 198 std::unique_ptr<cricket::Port> port_; |
203 bool running_; | |
204 int port_config_count_; | 199 int port_config_count_; |
205 std::vector<Candidate> candidates_; | 200 std::vector<Candidate> candidates_; |
206 std::vector<PortInterface*> ready_ports_; | 201 std::vector<PortInterface*> ready_ports_; |
207 bool allocation_done_ = false; | 202 bool allocation_done_ = false; |
208 ServerAddresses stun_servers_; | 203 ServerAddresses stun_servers_; |
209 std::vector<RelayServerConfig> turn_servers_; | 204 std::vector<RelayServerConfig> turn_servers_; |
210 uint32_t candidate_filter_ = CF_ALL; | 205 uint32_t candidate_filter_ = CF_ALL; |
211 int transport_info_update_count_ = 0; | 206 int transport_info_update_count_ = 0; |
212 }; | 207 }; |
213 | 208 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 private: | 240 private: |
246 rtc::Thread* network_thread_; | 241 rtc::Thread* network_thread_; |
247 rtc::PacketSocketFactory* factory_; | 242 rtc::PacketSocketFactory* factory_; |
248 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; | 243 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; |
249 bool initialized_ = false; | 244 bool initialized_ = false; |
250 }; | 245 }; |
251 | 246 |
252 } // namespace cricket | 247 } // namespace cricket |
253 | 248 |
254 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ | 249 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ |
OLD | NEW |