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 12 matching lines...) Expand all Loading... | |
23 #include <map> | 23 #include <map> |
24 #include <string> | 24 #include <string> |
25 #include <vector> | 25 #include <vector> |
26 #include "webrtc/p2p/base/candidate.h" | 26 #include "webrtc/p2p/base/candidate.h" |
27 #include "webrtc/p2p/base/p2ptransport.h" | 27 #include "webrtc/p2p/base/p2ptransport.h" |
28 #include "webrtc/p2p/base/portallocator.h" | 28 #include "webrtc/p2p/base/portallocator.h" |
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/optional.h" | |
33 #include "webrtc/base/sigslot.h" | 34 #include "webrtc/base/sigslot.h" |
34 | 35 |
35 namespace cricket { | 36 namespace cricket { |
36 | 37 |
37 extern const uint32_t WEAK_PING_DELAY; | 38 extern const uint32_t WEAK_PING_DELAY; |
38 | 39 |
40 struct IceParameter { | |
pthatcher1
2015/12/12 00:30:34
IceParameters
(with an "s")
Yes, I know that mak
honghaiz3
2015/12/14 18:40:19
Done.
| |
41 std::string ufrag; | |
42 std::string pwd; | |
43 IceParameter(const std::string& ice_ufrag, const std::string& ice_pwd) | |
44 : ufrag(ice_ufrag), pwd(ice_pwd) {} | |
45 IceParameter() : ufrag(""), pwd("") {} | |
46 bool operator!=(const IceParameter& other) { | |
pthatcher1
2015/12/12 00:30:34
Can you implement both == and != just to make sure
honghaiz3
2015/12/14 18:40:19
Done.
| |
47 return ufrag != other.ufrag || pwd != other.pwd; | |
48 } | |
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 rtc::Optional<IceParameter> remote_ice() { | |
pthatcher1
2015/12/12 00:30:34
Can you leave a comment saying it's the latest rem
honghaiz3
2015/12/14 18:40:19
Done.
| |
245 return remote_ice_parameters_.empty() | |
246 ? rtc::Optional<IceParameter>() | |
247 : rtc::Optional<IceParameter>(remote_ice_parameters_.back()); | |
248 } | |
pthatcher1
2015/12/12 00:30:34
If it's too much of a problem to avoid copying wit
honghaiz3
2015/12/14 18:40:19
Done.
| |
249 uint32_t remote_ice_generation() { | |
pthatcher1
2015/12/12 00:30:34
Can you leave a comment saying it's the index of t
honghaiz3
2015/12/14 18:40:19
Done.
| |
250 // When |remote_ice_parameters_| has one element, it is generation 0. | |
251 return remote_ice_parameters_.empty() | |
252 ? 0 | |
253 : static_cast<uint32_t>(remote_ice_parameters_.size() - 1); | |
254 } | |
255 | |
232 P2PTransport* transport_; | 256 P2PTransport* transport_; |
233 PortAllocator* allocator_; | 257 PortAllocator* allocator_; |
234 rtc::Thread* worker_thread_; | 258 rtc::Thread* worker_thread_; |
235 bool incoming_only_; | 259 bool incoming_only_; |
236 int error_; | 260 int error_; |
237 std::vector<PortAllocatorSession*> allocator_sessions_; | 261 std::vector<PortAllocatorSession*> allocator_sessions_; |
238 std::vector<PortInterface *> ports_; | 262 std::vector<PortInterface *> ports_; |
239 std::vector<Connection *> connections_; | 263 std::vector<Connection *> connections_; |
240 Connection* best_connection_; | 264 Connection* best_connection_; |
241 // Connection selected by the controlling agent. This should be used only | 265 // Connection selected by the controlling agent. This should be used only |
242 // at controlled side when protocol type is RFC5245. | 266 // at controlled side when protocol type is RFC5245. |
243 Connection* pending_best_connection_; | 267 Connection* pending_best_connection_; |
244 std::vector<RemoteCandidate> remote_candidates_; | 268 std::vector<RemoteCandidate> remote_candidates_; |
245 bool sort_dirty_; // indicates whether another sort is needed right now | 269 bool sort_dirty_; // indicates whether another sort is needed right now |
246 bool had_connection_ = false; // if connections_ has ever been nonempty | 270 bool had_connection_ = false; // if connections_ has ever been nonempty |
247 typedef std::map<rtc::Socket::Option, int> OptionMap; | 271 typedef std::map<rtc::Socket::Option, int> OptionMap; |
248 OptionMap options_; | 272 OptionMap options_; |
249 std::string ice_ufrag_; | 273 std::string ice_ufrag_; |
250 std::string ice_pwd_; | 274 std::string ice_pwd_; |
251 std::string remote_ice_ufrag_; | 275 std::vector<IceParameter> remote_ice_parameters_; |
252 std::string remote_ice_pwd_; | |
253 IceMode remote_ice_mode_; | 276 IceMode remote_ice_mode_; |
254 IceRole ice_role_; | 277 IceRole ice_role_; |
255 uint64_t tiebreaker_; | 278 uint64_t tiebreaker_; |
256 uint32_t remote_candidate_generation_; | |
257 IceGatheringState gathering_state_; | 279 IceGatheringState gathering_state_; |
258 | 280 |
259 int check_receiving_delay_; | 281 int check_receiving_delay_; |
260 int receiving_timeout_; | 282 int receiving_timeout_; |
261 int backup_connection_ping_interval_; | 283 int backup_connection_ping_interval_; |
262 uint32_t last_ping_sent_ms_ = 0; | 284 uint32_t last_ping_sent_ms_ = 0; |
263 bool gather_continually_ = false; | 285 bool gather_continually_ = false; |
264 int weak_ping_delay_ = WEAK_PING_DELAY; | 286 int weak_ping_delay_ = WEAK_PING_DELAY; |
265 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 287 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
266 | 288 |
267 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 289 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
268 }; | 290 }; |
269 | 291 |
270 } // namespace cricket | 292 } // namespace cricket |
271 | 293 |
272 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 294 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
OLD | NEW |