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