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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 rtc::NetworkManager* network_manager_; | 68 rtc::NetworkManager* network_manager_; |
69 rtc::PacketSocketFactory* socket_factory_; | 69 rtc::PacketSocketFactory* socket_factory_; |
70 bool allow_tcp_listen_; | 70 bool allow_tcp_listen_; |
71 int network_ignore_mask_ = rtc::kDefaultNetworkIgnoreMask; | 71 int network_ignore_mask_ = rtc::kDefaultNetworkIgnoreMask; |
72 }; | 72 }; |
73 | 73 |
74 struct PortConfiguration; | 74 struct PortConfiguration; |
75 class AllocationSequence; | 75 class AllocationSequence; |
76 | 76 |
| 77 enum class SessionState { |
| 78 GATHERING, // Actively allocating ports and gathering candidates. |
| 79 CLEARED, // Current allocation process has been stopped but may start |
| 80 // new ones. |
| 81 STOPPED // This session has completely stopped, no new allocation |
| 82 // process will be started. |
| 83 }; |
| 84 |
77 class BasicPortAllocatorSession : public PortAllocatorSession, | 85 class BasicPortAllocatorSession : public PortAllocatorSession, |
78 public rtc::MessageHandler { | 86 public rtc::MessageHandler { |
79 public: | 87 public: |
80 BasicPortAllocatorSession(BasicPortAllocator* allocator, | 88 BasicPortAllocatorSession(BasicPortAllocator* allocator, |
81 const std::string& content_name, | 89 const std::string& content_name, |
82 int component, | 90 int component, |
83 const std::string& ice_ufrag, | 91 const std::string& ice_ufrag, |
84 const std::string& ice_pwd); | 92 const std::string& ice_pwd); |
85 ~BasicPortAllocatorSession(); | 93 ~BasicPortAllocatorSession(); |
86 | 94 |
87 virtual BasicPortAllocator* allocator() { return allocator_; } | 95 virtual BasicPortAllocator* allocator() { return allocator_; } |
88 rtc::Thread* network_thread() { return network_thread_; } | 96 rtc::Thread* network_thread() { return network_thread_; } |
89 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } | 97 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } |
90 | 98 |
91 void SetCandidateFilter(uint32_t filter) override; | 99 void SetCandidateFilter(uint32_t filter) override; |
92 void StartGettingPorts() override; | 100 void StartGettingPorts() override; |
93 void StopGettingPorts() override; | 101 void StopGettingPorts() override; |
94 void ClearGettingPorts() override; | 102 void ClearGettingPorts() override; |
| 103 bool IsGettingPorts() override { return state_ == SessionState::GATHERING; } |
| 104 bool IsCleared() const override { return state_ == SessionState::CLEARED; } |
| 105 bool IsStopped() const override { return state_ == SessionState::STOPPED; } |
95 // These will all be cricket::Ports. | 106 // These will all be cricket::Ports. |
96 std::vector<PortInterface*> ReadyPorts() const override; | 107 std::vector<PortInterface*> ReadyPorts() const override; |
97 std::vector<Candidate> ReadyCandidates() const override; | 108 std::vector<Candidate> ReadyCandidates() const override; |
98 bool CandidatesAllocationDone() const override; | 109 bool CandidatesAllocationDone() const override; |
99 void RegatherOnFailedNetworks() override; | 110 void RegatherOnFailedNetworks() override; |
100 | 111 |
101 protected: | 112 protected: |
102 void UpdateIceParametersInternal() override; | 113 void UpdateIceParametersInternal() override; |
103 | 114 |
104 // Starts the process of getting the port configurations. | 115 // Starts the process of getting the port configurations. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 rtc::PacketSocketFactory* socket_factory_; | 216 rtc::PacketSocketFactory* socket_factory_; |
206 bool allocation_started_; | 217 bool allocation_started_; |
207 bool network_manager_started_; | 218 bool network_manager_started_; |
208 bool allocation_sequences_created_; | 219 bool allocation_sequences_created_; |
209 std::vector<PortConfiguration*> configs_; | 220 std::vector<PortConfiguration*> configs_; |
210 std::vector<AllocationSequence*> sequences_; | 221 std::vector<AllocationSequence*> sequences_; |
211 std::vector<PortData> ports_; | 222 std::vector<PortData> ports_; |
212 uint32_t candidate_filter_ = CF_ALL; | 223 uint32_t candidate_filter_ = CF_ALL; |
213 // Whether to prune low-priority ports, taken from the port allocator. | 224 // Whether to prune low-priority ports, taken from the port allocator. |
214 bool prune_turn_ports_; | 225 bool prune_turn_ports_; |
| 226 SessionState state_ = SessionState::CLEARED; |
215 | 227 |
216 friend class AllocationSequence; | 228 friend class AllocationSequence; |
217 }; | 229 }; |
218 | 230 |
219 // Records configuration information useful in creating ports. | 231 // Records configuration information useful in creating ports. |
220 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct. | 232 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct. |
221 struct PortConfiguration : public rtc::MessageData { | 233 struct PortConfiguration : public rtc::MessageData { |
222 // TODO(jiayl): remove |stun_address| when Chrome is updated. | 234 // TODO(jiayl): remove |stun_address| when Chrome is updated. |
223 rtc::SocketAddress stun_address; | 235 rtc::SocketAddress stun_address; |
224 ServerAddresses stun_servers; | 236 ServerAddresses stun_servers; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; | 355 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; |
344 // There will be only one udp port per AllocationSequence. | 356 // There will be only one udp port per AllocationSequence. |
345 UDPPort* udp_port_; | 357 UDPPort* udp_port_; |
346 std::vector<TurnPort*> turn_ports_; | 358 std::vector<TurnPort*> turn_ports_; |
347 int phase_; | 359 int phase_; |
348 }; | 360 }; |
349 | 361 |
350 } // namespace cricket | 362 } // namespace cricket |
351 | 363 |
352 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ | 364 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ |
OLD | NEW |