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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 int GetError() override { return error_; } | 120 int GetError() override { return error_; } |
121 bool GetStats(std::vector<ConnectionInfo>* stats) override; | 121 bool GetStats(std::vector<ConnectionInfo>* stats) override; |
122 | 122 |
123 // TODO(honghaiz): Remove this method once the reference of it in | 123 // TODO(honghaiz): Remove this method once the reference of it in |
124 // Chromoting is removed. | 124 // Chromoting is removed. |
125 const Connection* best_connection() const { return selected_connection_; } | 125 const Connection* best_connection() const { return selected_connection_; } |
126 | 126 |
127 const Connection* selected_connection() const { return selected_connection_; } | 127 const Connection* selected_connection() const { return selected_connection_; } |
128 void set_incoming_only(bool value) { incoming_only_ = value; } | 128 void set_incoming_only(bool value) { incoming_only_ = value; } |
129 | 129 |
130 // Note: This is only for testing purpose. | 130 // Note: These are only for testing purpose. |
131 // |ports_| should not be changed from outside. | 131 // |ports_| and |pruned_ports| should not be changed from outside. |
132 const std::vector<PortInterface*>& ports() { return ports_; } | 132 const std::vector<PortInterface*>& ports() { return ports_; } |
| 133 const std::vector<PortInterface*>& pruned_ports() { return pruned_ports_; } |
133 | 134 |
134 IceMode remote_ice_mode() const { return remote_ice_mode_; } | 135 IceMode remote_ice_mode() const { return remote_ice_mode_; } |
135 | 136 |
136 // DTLS methods. | 137 // DTLS methods. |
137 bool IsDtlsActive() const override { return false; } | 138 bool IsDtlsActive() const override { return false; } |
138 | 139 |
139 // Default implementation. | 140 // Default implementation. |
140 bool GetSslRole(rtc::SSLRole* role) const override { return false; } | 141 bool GetSslRole(rtc::SSLRole* role) const override { return false; } |
141 | 142 |
142 bool SetSslRole(rtc::SSLRole role) override { return false; } | 143 bool SetSslRole(rtc::SSLRole role) override { return false; } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return false; | 178 return false; |
178 } | 179 } |
179 | 180 |
180 // Set DTLS Remote fingerprint. Must be after local identity set. | 181 // Set DTLS Remote fingerprint. Must be after local identity set. |
181 bool SetRemoteFingerprint(const std::string& digest_alg, | 182 bool SetRemoteFingerprint(const std::string& digest_alg, |
182 const uint8_t* digest, | 183 const uint8_t* digest, |
183 size_t digest_len) override { | 184 size_t digest_len) override { |
184 return false; | 185 return false; |
185 } | 186 } |
186 | 187 |
| 188 void PruneAllPorts(); |
187 int receiving_timeout() const { return config_.receiving_timeout; } | 189 int receiving_timeout() const { return config_.receiving_timeout; } |
188 int check_receiving_interval() const { return check_receiving_interval_; } | 190 int check_receiving_interval() const { return check_receiving_interval_; } |
189 | 191 |
190 // Helper method used only in unittest. | 192 // Helper method used only in unittest. |
191 rtc::DiffServCodePoint DefaultDscpValue() const; | 193 rtc::DiffServCodePoint DefaultDscpValue() const; |
192 | 194 |
193 // Public for unit tests. | 195 // Public for unit tests. |
194 Connection* FindNextPingableConnection(); | 196 Connection* FindNextPingableConnection(); |
195 void MarkConnectionPinged(Connection* conn); | 197 void MarkConnectionPinged(Connection* conn); |
196 | 198 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 PortInterface* origin_port); | 271 PortInterface* origin_port); |
270 bool IsPingable(const Connection* conn, int64_t now) const; | 272 bool IsPingable(const Connection* conn, int64_t now) const; |
271 bool IsSelectedConnectionPingable(int64_t now); | 273 bool IsSelectedConnectionPingable(int64_t now); |
272 int CalculateActiveWritablePingInterval(const Connection* conn, | 274 int CalculateActiveWritablePingInterval(const Connection* conn, |
273 int64_t now) const; | 275 int64_t now) const; |
274 void PingConnection(Connection* conn); | 276 void PingConnection(Connection* conn); |
275 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session); | 277 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session); |
276 void AddConnection(Connection* connection); | 278 void AddConnection(Connection* connection); |
277 | 279 |
278 void OnPortReady(PortAllocatorSession *session, PortInterface* port); | 280 void OnPortReady(PortAllocatorSession *session, PortInterface* port); |
279 // TODO(honghaiz): Merge the two methods OnPortsRemoved and OnPortPruned but | 281 void OnPortsPruned(PortAllocatorSession* session, |
280 // still log the reason of removing. | 282 const std::vector<PortInterface*>& ports); |
281 void OnPortsRemoved(PortAllocatorSession* session, | |
282 const std::vector<PortInterface*>& ports); | |
283 void OnPortPruned(PortAllocatorSession* session, PortInterface* port); | |
284 void OnCandidatesReady(PortAllocatorSession *session, | 283 void OnCandidatesReady(PortAllocatorSession *session, |
285 const std::vector<Candidate>& candidates); | 284 const std::vector<Candidate>& candidates); |
286 void OnCandidatesRemoved(PortAllocatorSession* session, | 285 void OnCandidatesRemoved(PortAllocatorSession* session, |
287 const std::vector<Candidate>& candidates); | 286 const std::vector<Candidate>& candidates); |
288 void OnCandidatesAllocationDone(PortAllocatorSession* session); | 287 void OnCandidatesAllocationDone(PortAllocatorSession* session); |
289 void OnUnknownAddress(PortInterface* port, | 288 void OnUnknownAddress(PortInterface* port, |
290 const rtc::SocketAddress& addr, | 289 const rtc::SocketAddress& addr, |
291 ProtocolType proto, | 290 ProtocolType proto, |
292 IceMessage* stun_msg, | 291 IceMessage* stun_msg, |
293 const std::string& remote_username, | 292 const std::string& remote_username, |
294 bool port_muxed); | 293 bool port_muxed); |
295 | 294 |
296 // When a port is destroyed, remove it from both lists |ports_| | 295 // When a port is destroyed, remove it from both lists |ports_| |
297 // and |removed_ports_|. | 296 // and |pruned_ports_|. |
298 void OnPortDestroyed(PortInterface* port); | 297 void OnPortDestroyed(PortInterface* port); |
299 // When removing a port, move it from |ports_| to |removed_ports_|. | 298 // When pruning a port, move it from |ports_| to |pruned_ports_|. |
300 // Returns true if the port is found and removed from |ports_|. | 299 // Returns true if the port is found and removed from |ports_|. |
301 bool RemovePort(PortInterface* port); | 300 bool PrunePort(PortInterface* port); |
302 void OnRoleConflict(PortInterface* port); | 301 void OnRoleConflict(PortInterface* port); |
303 | 302 |
304 void OnConnectionStateChange(Connection* connection); | 303 void OnConnectionStateChange(Connection* connection); |
305 void OnReadPacket(Connection *connection, const char *data, size_t len, | 304 void OnReadPacket(Connection *connection, const char *data, size_t len, |
306 const rtc::PacketTime& packet_time); | 305 const rtc::PacketTime& packet_time); |
307 void OnSentPacket(const rtc::SentPacket& sent_packet); | 306 void OnSentPacket(const rtc::SentPacket& sent_packet); |
308 void OnReadyToSend(Connection* connection); | 307 void OnReadyToSend(Connection* connection); |
309 void OnConnectionDestroyed(Connection *connection); | 308 void OnConnectionDestroyed(Connection *connection); |
310 | 309 |
311 void OnNominated(Connection* conn); | 310 void OnNominated(Connection* conn); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 } | 358 } |
360 | 359 |
361 PortAllocator* allocator_; | 360 PortAllocator* allocator_; |
362 rtc::Thread* worker_thread_; | 361 rtc::Thread* worker_thread_; |
363 bool incoming_only_; | 362 bool incoming_only_; |
364 int error_; | 363 int error_; |
365 std::vector<std::unique_ptr<PortAllocatorSession>> allocator_sessions_; | 364 std::vector<std::unique_ptr<PortAllocatorSession>> allocator_sessions_; |
366 // |ports_| contains ports that are used to form new connections when | 365 // |ports_| contains ports that are used to form new connections when |
367 // new remote candidates are added. | 366 // new remote candidates are added. |
368 std::vector<PortInterface*> ports_; | 367 std::vector<PortInterface*> ports_; |
369 // |removed_ports_| contains ports that have been removed from |ports_| and | 368 // |pruned_ports_| contains ports that have been removed from |ports_| and |
370 // are not being used to form new connections, but that aren't yet destroyed. | 369 // are not being used to form new connections, but that aren't yet destroyed. |
371 // They may have existing connections, and they still fire signals such as | 370 // They may have existing connections, and they still fire signals such as |
372 // SignalUnknownAddress. | 371 // SignalUnknownAddress. |
373 std::vector<PortInterface*> removed_ports_; | 372 std::vector<PortInterface*> pruned_ports_; |
374 | 373 |
375 // |connections_| is a sorted list with the first one always be the | 374 // |connections_| is a sorted list with the first one always be the |
376 // |selected_connection_| when it's not nullptr. The combination of | 375 // |selected_connection_| when it's not nullptr. The combination of |
377 // |pinged_connections_| and |unpinged_connections_| has the same | 376 // |pinged_connections_| and |unpinged_connections_| has the same |
378 // connections as |connections_|. These 2 sets maintain whether a | 377 // connections as |connections_|. These 2 sets maintain whether a |
379 // connection should be pinged next or not. | 378 // connection should be pinged next or not. |
380 std::vector<Connection *> connections_; | 379 std::vector<Connection *> connections_; |
381 std::set<Connection*> pinged_connections_; | 380 std::set<Connection*> pinged_connections_; |
382 std::set<Connection*> unpinged_connections_; | 381 std::set<Connection*> unpinged_connections_; |
383 | 382 |
(...skipping 19 matching lines...) Expand all Loading... |
403 IceConfig config_; | 402 IceConfig config_; |
404 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. | 403 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. |
405 bool started_pinging_ = false; | 404 bool started_pinging_ = false; |
406 | 405 |
407 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 406 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
408 }; | 407 }; |
409 | 408 |
410 } // namespace cricket | 409 } // namespace cricket |
411 | 410 |
412 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 411 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
OLD | NEW |