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 27 matching lines...) Expand all Loading... | |
38 virtual ~BasicPortAllocator(); | 38 virtual ~BasicPortAllocator(); |
39 | 39 |
40 // Set to kDefaultNetworkIgnoreMask by default. | 40 // Set to kDefaultNetworkIgnoreMask by default. |
41 void SetNetworkIgnoreMask(int network_ignore_mask) override { | 41 void SetNetworkIgnoreMask(int network_ignore_mask) override { |
42 // TODO(phoglund): implement support for other types than loopback. | 42 // TODO(phoglund): implement support for other types than loopback. |
43 // See https://code.google.com/p/webrtc/issues/detail?id=4288. | 43 // See https://code.google.com/p/webrtc/issues/detail?id=4288. |
44 // Then remove set_network_ignore_list from NetworkManager. | 44 // Then remove set_network_ignore_list from NetworkManager. |
45 network_ignore_mask_ = network_ignore_mask; | 45 network_ignore_mask_ = network_ignore_mask; |
46 } | 46 } |
47 | 47 |
48 void GetNetworks(std::vector<rtc::Network*>* networks) const override { | |
Taylor Brandstetter
2016/06/06 18:18:37
Instead of going through BasicPortAllocator, P2PTr
honghaiz3
2016/06/07 16:42:06
Done.
| |
49 network_manager()->GetNetworks(networks); | |
50 } | |
51 | |
48 int network_ignore_mask() const { return network_ignore_mask_; } | 52 int network_ignore_mask() const { return network_ignore_mask_; } |
49 | 53 |
50 rtc::NetworkManager* network_manager() { return network_manager_; } | 54 rtc::NetworkManager* network_manager() const { return network_manager_; } |
51 | 55 |
52 // If socket_factory() is set to NULL each PortAllocatorSession | 56 // If socket_factory() is set to NULL each PortAllocatorSession |
53 // creates its own socket factory. | 57 // creates its own socket factory. |
54 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } | 58 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } |
55 | 59 |
56 PortAllocatorSession* CreateSessionInternal( | 60 PortAllocatorSession* CreateSessionInternal( |
57 const std::string& content_name, | 61 const std::string& content_name, |
58 int component, | 62 int component, |
59 const std::string& ice_ufrag, | 63 const std::string& ice_ufrag, |
60 const std::string& ice_pwd) override; | 64 const std::string& ice_pwd) override; |
(...skipping 21 matching lines...) Expand all Loading... | |
82 int component, | 86 int component, |
83 const std::string& ice_ufrag, | 87 const std::string& ice_ufrag, |
84 const std::string& ice_pwd); | 88 const std::string& ice_pwd); |
85 ~BasicPortAllocatorSession(); | 89 ~BasicPortAllocatorSession(); |
86 | 90 |
87 virtual BasicPortAllocator* allocator() { return allocator_; } | 91 virtual BasicPortAllocator* allocator() { return allocator_; } |
88 rtc::Thread* network_thread() { return network_thread_; } | 92 rtc::Thread* network_thread() { return network_thread_; } |
89 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } | 93 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } |
90 | 94 |
91 void SetCandidateFilter(uint32_t filter) override; | 95 void SetCandidateFilter(uint32_t filter) override; |
96 | |
92 void StartGettingPorts() override; | 97 void StartGettingPorts() override; |
93 void StopGettingPorts() override; | 98 void StopGettingPorts() override; |
94 void ClearGettingPorts() override; | 99 void ClearGettingPorts() override; |
95 bool IsGettingPorts() override { return running_; } | 100 bool IsGettingPorts() override { return running_; } |
96 // These will all be cricket::Ports. | 101 // These will all be cricket::Ports. |
97 std::vector<PortInterface*> ReadyPorts() const override; | 102 std::vector<PortInterface*> ReadyPorts() const override; |
98 std::vector<Candidate> ReadyCandidates() const override; | 103 std::vector<Candidate> ReadyCandidates() const override; |
99 bool CandidatesAllocationDone() const override; | 104 bool CandidatesAllocationDone() const override; |
105 void InactivateNetworksInExistingSequences( | |
106 std::vector<rtc::Network*>* networks) override; | |
100 | 107 |
101 protected: | 108 protected: |
102 void UpdateIceParametersInternal() override; | 109 void UpdateIceParametersInternal() override; |
103 | 110 |
104 // Starts the process of getting the port configurations. | 111 // Starts the process of getting the port configurations. |
105 virtual void GetPortConfigurations(); | 112 virtual void GetPortConfigurations(); |
106 | 113 |
107 // Adds a port configuration that is now ready. Once we have one for each | 114 // Adds a port configuration that is now ready. Once we have one for each |
108 // network (or a timeout occurs), we will start allocating ports. | 115 // network (or a timeout occurs), we will start allocating ports. |
109 virtual void ConfigReady(PortConfiguration* config); | 116 virtual void ConfigReady(PortConfiguration* config); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 | 255 |
249 // kInit --> kRunning --> {kCompleted|kStopped} | 256 // kInit --> kRunning --> {kCompleted|kStopped} |
250 }; | 257 }; |
251 AllocationSequence(BasicPortAllocatorSession* session, | 258 AllocationSequence(BasicPortAllocatorSession* session, |
252 rtc::Network* network, | 259 rtc::Network* network, |
253 PortConfiguration* config, | 260 PortConfiguration* config, |
254 uint32_t flags); | 261 uint32_t flags); |
255 ~AllocationSequence(); | 262 ~AllocationSequence(); |
256 bool Init(); | 263 bool Init(); |
257 void Clear(); | 264 void Clear(); |
258 void OnNetworkRemoved(); | 265 void OnNetworkInactivated(); |
259 | 266 |
260 State state() const { return state_; } | 267 State state() const { return state_; } |
261 const rtc::Network* network() const { return network_; } | 268 const rtc::Network* network() const { return network_; } |
262 bool network_removed() const { return network_removed_; } | 269 |
270 bool network_inactive() const { return network_inactive_; } | |
271 void set_network_inactive(bool network_inactive) { | |
272 network_inactive_ = network_inactive; | |
273 } | |
263 | 274 |
264 // Disables the phases for a new sequence that this one already covers for an | 275 // Disables the phases for a new sequence that this one already covers for an |
265 // equivalent network setup. | 276 // equivalent network setup. |
266 void DisableEquivalentPhases(rtc::Network* network, | 277 void DisableEquivalentPhases(rtc::Network* network, |
267 PortConfiguration* config, | 278 PortConfiguration* config, |
268 uint32_t* flags); | 279 uint32_t* flags); |
269 | 280 |
270 // Starts and stops the sequence. When started, it will continue allocating | 281 // Starts and stops the sequence. When started, it will continue allocating |
271 // new ports on its own timed schedule. | 282 // new ports on its own timed schedule. |
272 void Start(); | 283 void Start(); |
(...skipping 29 matching lines...) Expand all Loading... | |
302 | 313 |
303 void OnReadPacket(rtc::AsyncPacketSocket* socket, | 314 void OnReadPacket(rtc::AsyncPacketSocket* socket, |
304 const char* data, | 315 const char* data, |
305 size_t size, | 316 size_t size, |
306 const rtc::SocketAddress& remote_addr, | 317 const rtc::SocketAddress& remote_addr, |
307 const rtc::PacketTime& packet_time); | 318 const rtc::PacketTime& packet_time); |
308 | 319 |
309 void OnPortDestroyed(PortInterface* port); | 320 void OnPortDestroyed(PortInterface* port); |
310 | 321 |
311 BasicPortAllocatorSession* session_; | 322 BasicPortAllocatorSession* session_; |
312 bool network_removed_ = false; | 323 bool network_inactive_ = false; |
313 rtc::Network* network_; | 324 rtc::Network* network_; |
314 rtc::IPAddress ip_; | 325 rtc::IPAddress ip_; |
315 PortConfiguration* config_; | 326 PortConfiguration* config_; |
316 State state_; | 327 State state_; |
317 uint32_t flags_; | 328 uint32_t flags_; |
318 ProtocolList protocols_; | 329 ProtocolList protocols_; |
319 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; | 330 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; |
320 // There will be only one udp port per AllocationSequence. | 331 // There will be only one udp port per AllocationSequence. |
321 UDPPort* udp_port_; | 332 UDPPort* udp_port_; |
322 std::vector<TurnPort*> turn_ports_; | 333 std::vector<TurnPort*> turn_ports_; |
323 int phase_; | 334 int phase_; |
324 }; | 335 }; |
325 | 336 |
326 } // namespace cricket | 337 } // namespace cricket |
327 | 338 |
328 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ | 339 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ |
OLD | NEW |