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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 int receiving_timeout() const { return receiving_timeout_; } | 150 int receiving_timeout() const { return receiving_timeout_; } |
151 int check_receiving_delay() const { return check_receiving_delay_; } | 151 int check_receiving_delay() const { return check_receiving_delay_; } |
152 | 152 |
153 // Helper method used only in unittest. | 153 // Helper method used only in unittest. |
154 rtc::DiffServCodePoint DefaultDscpValue() const; | 154 rtc::DiffServCodePoint DefaultDscpValue() const; |
155 | 155 |
156 // Public for unit tests. | 156 // Public for unit tests. |
157 Connection* FindNextPingableConnection(); | 157 Connection* FindNextPingableConnection(); |
158 | 158 |
159 private: | 159 // Helper method used only in unit tests. |
160 rtc::Thread* thread() { return worker_thread_; } | |
161 PortAllocatorSession* allocator_session() { | 160 PortAllocatorSession* allocator_session() { |
162 return allocator_sessions_.back(); | 161 return allocator_sessions_.back(); |
163 } | 162 } |
164 | 163 |
| 164 private: |
| 165 rtc::Thread* thread() { return worker_thread_; } |
| 166 |
| 167 |
165 // A transport channel is weak if the current best connection is either | 168 // A transport channel is weak if the current best connection is either |
166 // not receiving or not writable, or if there is no best connection at all. | 169 // not receiving or not writable, or if there is no best connection at all. |
167 bool weak() const; | 170 bool weak() const; |
168 void UpdateConnectionStates(); | 171 void UpdateConnectionStates(); |
169 void RequestSort(); | 172 void RequestSort(); |
170 void SortConnections(); | 173 void SortConnections(); |
171 void SwitchBestConnectionTo(Connection* conn); | 174 void SwitchBestConnectionTo(Connection* conn); |
172 void UpdateChannelState(); | 175 void UpdateChannelState(); |
173 void HandleWritable(); | 176 void HandleWritable(); |
174 void HandleNotWritable(); | 177 void HandleNotWritable(); |
175 void HandleAllTimedOut(); | 178 void HandleAllTimedOut(); |
| 179 void MaybeStopSessions(); |
176 | 180 |
177 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; | 181 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; |
178 bool CreateConnections(const Candidate& remote_candidate, | 182 bool CreateConnections(const Candidate& remote_candidate, |
179 PortInterface* origin_port); | 183 PortInterface* origin_port); |
180 bool CreateConnection(PortInterface* port, | 184 bool CreateConnection(PortInterface* port, |
181 const Candidate& remote_candidate, | 185 const Candidate& remote_candidate, |
182 PortInterface* origin_port); | 186 PortInterface* origin_port); |
183 bool FindConnection(cricket::Connection* connection) const; | 187 bool FindConnection(cricket::Connection* connection) const; |
184 | 188 |
185 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); | 189 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 int error_; | 231 int error_; |
228 std::vector<PortAllocatorSession*> allocator_sessions_; | 232 std::vector<PortAllocatorSession*> allocator_sessions_; |
229 std::vector<PortInterface *> ports_; | 233 std::vector<PortInterface *> ports_; |
230 std::vector<Connection *> connections_; | 234 std::vector<Connection *> connections_; |
231 Connection* best_connection_; | 235 Connection* best_connection_; |
232 // Connection selected by the controlling agent. This should be used only | 236 // Connection selected by the controlling agent. This should be used only |
233 // at controlled side when protocol type is RFC5245. | 237 // at controlled side when protocol type is RFC5245. |
234 Connection* pending_best_connection_; | 238 Connection* pending_best_connection_; |
235 std::vector<RemoteCandidate> remote_candidates_; | 239 std::vector<RemoteCandidate> remote_candidates_; |
236 bool sort_dirty_; // indicates whether another sort is needed right now | 240 bool sort_dirty_; // indicates whether another sort is needed right now |
237 bool was_writable_; | |
238 bool had_connection_ = false; // if connections_ has ever been nonempty | 241 bool had_connection_ = false; // if connections_ has ever been nonempty |
239 typedef std::map<rtc::Socket::Option, int> OptionMap; | 242 typedef std::map<rtc::Socket::Option, int> OptionMap; |
240 OptionMap options_; | 243 OptionMap options_; |
241 std::string ice_ufrag_; | 244 std::string ice_ufrag_; |
242 std::string ice_pwd_; | 245 std::string ice_pwd_; |
243 std::string remote_ice_ufrag_; | 246 std::string remote_ice_ufrag_; |
244 std::string remote_ice_pwd_; | 247 std::string remote_ice_pwd_; |
245 IceMode remote_ice_mode_; | 248 IceMode remote_ice_mode_; |
246 IceRole ice_role_; | 249 IceRole ice_role_; |
247 uint64_t tiebreaker_; | 250 uint64_t tiebreaker_; |
248 uint32_t remote_candidate_generation_; | 251 uint32_t remote_candidate_generation_; |
249 IceGatheringState gathering_state_; | 252 IceGatheringState gathering_state_; |
250 | 253 |
251 int check_receiving_delay_; | 254 int check_receiving_delay_; |
252 int receiving_timeout_; | 255 int receiving_timeout_; |
253 uint32_t last_ping_sent_ms_ = 0; | 256 uint32_t last_ping_sent_ms_ = 0; |
254 bool gather_continually_ = false; | 257 bool gather_continually_ = false; |
| 258 // Whether a new session has been started to get ports and it is not |
| 259 // stopped yet. |
| 260 bool is_getting_ports_ = false; |
255 | 261 |
256 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 262 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
257 }; | 263 }; |
258 | 264 |
259 } // namespace cricket | 265 } // namespace cricket |
260 | 266 |
261 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 267 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
OLD | NEW |