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 18 matching lines...) Expand all Loading... |
29 #include "webrtc/p2p/base/portinterface.h" | 29 #include "webrtc/p2p/base/portinterface.h" |
30 #include "webrtc/p2p/base/transport.h" | 30 #include "webrtc/p2p/base/transport.h" |
31 #include "webrtc/p2p/base/transportchannelimpl.h" | 31 #include "webrtc/p2p/base/transportchannelimpl.h" |
32 #include "webrtc/base/asyncpacketsocket.h" | 32 #include "webrtc/base/asyncpacketsocket.h" |
33 #include "webrtc/base/sigslot.h" | 33 #include "webrtc/base/sigslot.h" |
34 | 34 |
35 namespace cricket { | 35 namespace cricket { |
36 | 36 |
37 extern const uint32_t WEAK_PING_DELAY; | 37 extern const uint32_t WEAK_PING_DELAY; |
38 | 38 |
| 39 struct IceParameters { |
| 40 std::string ufrag; |
| 41 std::string pwd; |
| 42 IceParameters(const std::string& ice_ufrag, const std::string& ice_pwd) |
| 43 : ufrag(ice_ufrag), pwd(ice_pwd) {} |
| 44 |
| 45 bool operator==(const IceParameters& other) { |
| 46 return ufrag == other.ufrag && pwd == other.pwd; |
| 47 } |
| 48 bool operator!=(const IceParameters& other) { return !(*this == other); } |
| 49 }; |
| 50 |
39 // Adds the port on which the candidate originated. | 51 // Adds the port on which the candidate originated. |
40 class RemoteCandidate : public Candidate { | 52 class RemoteCandidate : public Candidate { |
41 public: | 53 public: |
42 RemoteCandidate(const Candidate& c, PortInterface* origin_port) | 54 RemoteCandidate(const Candidate& c, PortInterface* origin_port) |
43 : Candidate(c), origin_port_(origin_port) {} | 55 : Candidate(c), origin_port_(origin_port) {} |
44 | 56 |
45 PortInterface* origin_port() { return origin_port_; } | 57 PortInterface* origin_port() { return origin_port_; } |
46 | 58 |
47 private: | 59 private: |
48 PortInterface* origin_port_; | 60 PortInterface* origin_port_; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 void OnNominated(Connection* conn); | 234 void OnNominated(Connection* conn); |
223 | 235 |
224 void OnMessage(rtc::Message* pmsg) override; | 236 void OnMessage(rtc::Message* pmsg) override; |
225 void OnSort(); | 237 void OnSort(); |
226 void OnCheckAndPing(); | 238 void OnCheckAndPing(); |
227 | 239 |
228 void PruneConnections(); | 240 void PruneConnections(); |
229 Connection* best_nominated_connection() const; | 241 Connection* best_nominated_connection() const; |
230 bool IsBackupConnection(Connection* conn) const; | 242 bool IsBackupConnection(Connection* conn) const; |
231 | 243 |
| 244 // Returns the latest remote ICE parameters or nullptr if there are no remote |
| 245 // ICE parameters yet. |
| 246 IceParameters* remote_ice() { |
| 247 return remote_ice_parameters_.empty() ? nullptr |
| 248 : &remote_ice_parameters_.back(); |
| 249 } |
| 250 // Returns the index of the latest remote ICE parameters, or 0 if no remote |
| 251 // ICE parameters have been received. |
| 252 uint32_t remote_ice_generation() { |
| 253 return remote_ice_parameters_.empty() |
| 254 ? 0 |
| 255 : static_cast<uint32_t>(remote_ice_parameters_.size() - 1); |
| 256 } |
| 257 |
232 P2PTransport* transport_; | 258 P2PTransport* transport_; |
233 PortAllocator* allocator_; | 259 PortAllocator* allocator_; |
234 rtc::Thread* worker_thread_; | 260 rtc::Thread* worker_thread_; |
235 bool incoming_only_; | 261 bool incoming_only_; |
236 int error_; | 262 int error_; |
237 std::vector<PortAllocatorSession*> allocator_sessions_; | 263 std::vector<PortAllocatorSession*> allocator_sessions_; |
238 std::vector<PortInterface *> ports_; | 264 std::vector<PortInterface *> ports_; |
239 std::vector<Connection *> connections_; | 265 std::vector<Connection *> connections_; |
240 Connection* best_connection_; | 266 Connection* best_connection_; |
241 // Connection selected by the controlling agent. This should be used only | 267 // Connection selected by the controlling agent. This should be used only |
242 // at controlled side when protocol type is RFC5245. | 268 // at controlled side when protocol type is RFC5245. |
243 Connection* pending_best_connection_; | 269 Connection* pending_best_connection_; |
244 std::vector<RemoteCandidate> remote_candidates_; | 270 std::vector<RemoteCandidate> remote_candidates_; |
245 bool sort_dirty_; // indicates whether another sort is needed right now | 271 bool sort_dirty_; // indicates whether another sort is needed right now |
246 bool had_connection_ = false; // if connections_ has ever been nonempty | 272 bool had_connection_ = false; // if connections_ has ever been nonempty |
247 typedef std::map<rtc::Socket::Option, int> OptionMap; | 273 typedef std::map<rtc::Socket::Option, int> OptionMap; |
248 OptionMap options_; | 274 OptionMap options_; |
249 std::string ice_ufrag_; | 275 std::string ice_ufrag_; |
250 std::string ice_pwd_; | 276 std::string ice_pwd_; |
251 std::string remote_ice_ufrag_; | 277 std::vector<IceParameters> remote_ice_parameters_; |
252 std::string remote_ice_pwd_; | |
253 IceMode remote_ice_mode_; | 278 IceMode remote_ice_mode_; |
254 IceRole ice_role_; | 279 IceRole ice_role_; |
255 uint64_t tiebreaker_; | 280 uint64_t tiebreaker_; |
256 uint32_t remote_candidate_generation_; | |
257 IceGatheringState gathering_state_; | 281 IceGatheringState gathering_state_; |
258 | 282 |
259 int check_receiving_delay_; | 283 int check_receiving_delay_; |
260 int receiving_timeout_; | 284 int receiving_timeout_; |
261 int backup_connection_ping_interval_; | 285 int backup_connection_ping_interval_; |
262 uint32_t last_ping_sent_ms_ = 0; | 286 uint32_t last_ping_sent_ms_ = 0; |
263 bool gather_continually_ = false; | 287 bool gather_continually_ = false; |
264 int weak_ping_delay_ = WEAK_PING_DELAY; | 288 int weak_ping_delay_ = WEAK_PING_DELAY; |
265 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 289 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
266 | 290 |
267 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 291 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
268 }; | 292 }; |
269 | 293 |
270 } // namespace cricket | 294 } // namespace cricket |
271 | 295 |
272 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 296 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
OLD | NEW |