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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 }; | 164 }; |
165 | 165 |
166 void OnConfigReady(PortConfiguration* config); | 166 void OnConfigReady(PortConfiguration* config); |
167 void OnConfigStop(); | 167 void OnConfigStop(); |
168 void AllocatePorts(); | 168 void AllocatePorts(); |
169 void OnAllocate(); | 169 void OnAllocate(); |
170 void DoAllocate(); | 170 void DoAllocate(); |
171 void OnNetworksChanged(); | 171 void OnNetworksChanged(); |
172 void OnAllocationSequenceObjectsCreated(); | 172 void OnAllocationSequenceObjectsCreated(); |
173 void DisableEquivalentPhases(rtc::Network* network, | 173 void DisableEquivalentPhases(rtc::Network* network, |
174 PortConfiguration* config, uint32* flags); | 174 PortConfiguration* config, |
| 175 uint32_t* flags); |
175 void AddAllocatedPort(Port* port, AllocationSequence* seq, | 176 void AddAllocatedPort(Port* port, AllocationSequence* seq, |
176 bool prepare_address); | 177 bool prepare_address); |
177 void OnCandidateReady(Port* port, const Candidate& c); | 178 void OnCandidateReady(Port* port, const Candidate& c); |
178 void OnPortComplete(Port* port); | 179 void OnPortComplete(Port* port); |
179 void OnPortError(Port* port); | 180 void OnPortError(Port* port); |
180 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); | 181 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); |
181 void OnPortDestroyed(PortInterface* port); | 182 void OnPortDestroyed(PortInterface* port); |
182 void OnShake(); | 183 void OnShake(); |
183 void MaybeSignalCandidatesAllocationDone(); | 184 void MaybeSignalCandidatesAllocationDone(); |
184 void OnPortAllocationComplete(AllocationSequence* seq); | 185 void OnPortAllocationComplete(AllocationSequence* seq); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 kInit, // Initial state. | 252 kInit, // Initial state. |
252 kRunning, // Started allocating ports. | 253 kRunning, // Started allocating ports. |
253 kStopped, // Stopped from running. | 254 kStopped, // Stopped from running. |
254 kCompleted, // All ports are allocated. | 255 kCompleted, // All ports are allocated. |
255 | 256 |
256 // kInit --> kRunning --> {kCompleted|kStopped} | 257 // kInit --> kRunning --> {kCompleted|kStopped} |
257 }; | 258 }; |
258 AllocationSequence(BasicPortAllocatorSession* session, | 259 AllocationSequence(BasicPortAllocatorSession* session, |
259 rtc::Network* network, | 260 rtc::Network* network, |
260 PortConfiguration* config, | 261 PortConfiguration* config, |
261 uint32 flags); | 262 uint32_t flags); |
262 ~AllocationSequence(); | 263 ~AllocationSequence(); |
263 bool Init(); | 264 bool Init(); |
264 void Clear(); | 265 void Clear(); |
265 void OnNetworkRemoved(); | 266 void OnNetworkRemoved(); |
266 | 267 |
267 State state() const { return state_; } | 268 State state() const { return state_; } |
268 const rtc::Network* network() const { return network_; } | 269 const rtc::Network* network() const { return network_; } |
269 bool network_removed() const { return network_removed_; } | 270 bool network_removed() const { return network_removed_; } |
270 | 271 |
271 // Disables the phases for a new sequence that this one already covers for an | 272 // Disables the phases for a new sequence that this one already covers for an |
272 // equivalent network setup. | 273 // equivalent network setup. |
273 void DisableEquivalentPhases(rtc::Network* network, | 274 void DisableEquivalentPhases(rtc::Network* network, |
274 PortConfiguration* config, | 275 PortConfiguration* config, |
275 uint32* flags); | 276 uint32_t* flags); |
276 | 277 |
277 // Starts and stops the sequence. When started, it will continue allocating | 278 // Starts and stops the sequence. When started, it will continue allocating |
278 // new ports on its own timed schedule. | 279 // new ports on its own timed schedule. |
279 void Start(); | 280 void Start(); |
280 void Stop(); | 281 void Stop(); |
281 | 282 |
282 // MessageHandler | 283 // MessageHandler |
283 void OnMessage(rtc::Message* msg); | 284 void OnMessage(rtc::Message* msg); |
284 | 285 |
285 void EnableProtocol(ProtocolType proto); | 286 void EnableProtocol(ProtocolType proto); |
286 bool ProtocolEnabled(ProtocolType proto) const; | 287 bool ProtocolEnabled(ProtocolType proto) const; |
287 | 288 |
288 // Signal from AllocationSequence, when it's done with allocating ports. | 289 // Signal from AllocationSequence, when it's done with allocating ports. |
289 // This signal is useful, when port allocation fails which doesn't result | 290 // This signal is useful, when port allocation fails which doesn't result |
290 // in any candidates. Using this signal BasicPortAllocatorSession can send | 291 // in any candidates. Using this signal BasicPortAllocatorSession can send |
291 // its candidate discovery conclusion signal. Without this signal, | 292 // its candidate discovery conclusion signal. Without this signal, |
292 // BasicPortAllocatorSession doesn't have any event to trigger signal. This | 293 // BasicPortAllocatorSession doesn't have any event to trigger signal. This |
293 // can also be achieved by starting timer in BPAS. | 294 // can also be achieved by starting timer in BPAS. |
294 sigslot::signal1<AllocationSequence*> SignalPortAllocationComplete; | 295 sigslot::signal1<AllocationSequence*> SignalPortAllocationComplete; |
295 | 296 |
296 protected: | 297 protected: |
297 // For testing. | 298 // For testing. |
298 void CreateTurnPort(const RelayServerConfig& config); | 299 void CreateTurnPort(const RelayServerConfig& config); |
299 | 300 |
300 private: | 301 private: |
301 typedef std::vector<ProtocolType> ProtocolList; | 302 typedef std::vector<ProtocolType> ProtocolList; |
302 | 303 |
303 bool IsFlagSet(uint32 flag) { return ((flags_ & flag) != 0); } | 304 bool IsFlagSet(uint32_t flag) { return ((flags_ & flag) != 0); } |
304 void CreateUDPPorts(); | 305 void CreateUDPPorts(); |
305 void CreateTCPPorts(); | 306 void CreateTCPPorts(); |
306 void CreateStunPorts(); | 307 void CreateStunPorts(); |
307 void CreateRelayPorts(); | 308 void CreateRelayPorts(); |
308 void CreateGturnPort(const RelayServerConfig& config); | 309 void CreateGturnPort(const RelayServerConfig& config); |
309 | 310 |
310 void OnReadPacket(rtc::AsyncPacketSocket* socket, | 311 void OnReadPacket(rtc::AsyncPacketSocket* socket, |
311 const char* data, | 312 const char* data, |
312 size_t size, | 313 size_t size, |
313 const rtc::SocketAddress& remote_addr, | 314 const rtc::SocketAddress& remote_addr, |
314 const rtc::PacketTime& packet_time); | 315 const rtc::PacketTime& packet_time); |
315 | 316 |
316 void OnPortDestroyed(PortInterface* port); | 317 void OnPortDestroyed(PortInterface* port); |
317 | 318 |
318 BasicPortAllocatorSession* session_; | 319 BasicPortAllocatorSession* session_; |
319 bool network_removed_ = false; | 320 bool network_removed_ = false; |
320 rtc::Network* network_; | 321 rtc::Network* network_; |
321 rtc::IPAddress ip_; | 322 rtc::IPAddress ip_; |
322 PortConfiguration* config_; | 323 PortConfiguration* config_; |
323 State state_; | 324 State state_; |
324 uint32 flags_; | 325 uint32_t flags_; |
325 ProtocolList protocols_; | 326 ProtocolList protocols_; |
326 rtc::scoped_ptr<rtc::AsyncPacketSocket> udp_socket_; | 327 rtc::scoped_ptr<rtc::AsyncPacketSocket> udp_socket_; |
327 // There will be only one udp port per AllocationSequence. | 328 // There will be only one udp port per AllocationSequence. |
328 UDPPort* udp_port_; | 329 UDPPort* udp_port_; |
329 std::vector<TurnPort*> turn_ports_; | 330 std::vector<TurnPort*> turn_ports_; |
330 int phase_; | 331 int phase_; |
331 }; | 332 }; |
332 | 333 |
333 } // namespace cricket | 334 } // namespace cricket |
334 | 335 |
335 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ | 336 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ |
OLD | NEW |