Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.h

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed bugs with ICE connection state that occur when destroying transports Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 private: 45 private:
46 PortInterface* origin_port_; 46 PortInterface* origin_port_;
47 }; 47 };
48 48
49 // P2PTransportChannel manages the candidates and connection process to keep 49 // P2PTransportChannel manages the candidates and connection process to keep
50 // two P2P clients connected to each other. 50 // two P2P clients connected to each other.
51 class P2PTransportChannel : public TransportChannelImpl, 51 class P2PTransportChannel : public TransportChannelImpl,
52 public rtc::MessageHandler { 52 public rtc::MessageHandler {
53 public: 53 public:
54 P2PTransportChannel(const std::string& content_name, 54 P2PTransportChannel(const std::string& transport_name,
55 int component, 55 int component,
56 P2PTransport* transport, 56 P2PTransport* transport,
57 PortAllocator *allocator); 57 PortAllocator* allocator);
58 ~P2PTransportChannel() override; 58 virtual ~P2PTransportChannel();
59 59
60 // From TransportChannelImpl: 60 // From TransportChannelImpl:
61 Transport* GetTransport() override { return transport_; } 61 Transport* GetTransport() override { return transport_; }
62 TransportChannelState GetState() const override; 62 TransportChannelState GetState() const override;
63 void SetIceRole(IceRole role) override; 63 void SetIceRole(IceRole role) override;
64 IceRole GetIceRole() const override { return ice_role_; } 64 IceRole GetIceRole() const override { return ice_role_; }
65 void SetIceTiebreaker(uint64 tiebreaker) override; 65 void SetIceTiebreaker(uint64 tiebreaker) override;
66 void SetIceCredentials(const std::string& ice_ufrag, 66 void SetIceCredentials(const std::string& ice_ufrag,
67 const std::string& ice_pwd) override; 67 const std::string& ice_pwd) override;
68 void SetRemoteIceCredentials(const std::string& ice_ufrag, 68 void SetRemoteIceCredentials(const std::string& ice_ufrag,
69 const std::string& ice_pwd) override; 69 const std::string& ice_pwd) override;
70 void SetRemoteIceMode(IceMode mode) override; 70 void SetRemoteIceMode(IceMode mode) override;
71 void Connect() override; 71 void Connect() override;
72 void OnSignalingReady() override; 72 IceGatheringState gathering_state() const override {
73 void OnCandidate(const Candidate& candidate) override; 73 return gathering_state_;
74 }
75 void AddRemoteCandidate(const Candidate& candidate) override;
74 // Sets the receiving timeout in milliseconds. 76 // Sets the receiving timeout in milliseconds.
75 // This also sets the check_receiving_delay proportionally. 77 // This also sets the check_receiving_delay proportionally.
76 void SetReceivingTimeout(int receiving_timeout_ms) override; 78 void SetReceivingTimeout(int receiving_timeout_ms) override;
77 79
78 // From TransportChannel: 80 // From TransportChannel:
79 int SendPacket(const char *data, size_t len, 81 int SendPacket(const char* data,
80 const rtc::PacketOptions& options, int flags) override; 82 size_t len,
83 const rtc::PacketOptions& options,
84 int flags) override;
81 int SetOption(rtc::Socket::Option opt, int value) override; 85 int SetOption(rtc::Socket::Option opt, int value) override;
82 bool GetOption(rtc::Socket::Option opt, int* value) override; 86 bool GetOption(rtc::Socket::Option opt, int* value) override;
83 int GetError() override { return error_; } 87 int GetError() override { return error_; }
84 bool GetStats(std::vector<ConnectionInfo>* stats) override; 88 bool GetStats(std::vector<ConnectionInfo>* stats) override;
85 89
86 const Connection* best_connection() const { return best_connection_; } 90 const Connection* best_connection() const { return best_connection_; }
87 void set_incoming_only(bool value) { incoming_only_ = value; } 91 void set_incoming_only(bool value) { incoming_only_ = value; }
88 92
89 // Note: This is only for testing purpose. 93 // Note: This is only for testing purpose.
90 // |ports_| should not be changed from outside. 94 // |ports_| should not be changed from outside.
91 const std::vector<PortInterface*>& ports() { return ports_; } 95 const std::vector<PortInterface*>& ports() { return ports_; }
92 96
93 IceMode remote_ice_mode() const { return remote_ice_mode_; } 97 IceMode remote_ice_mode() const { return remote_ice_mode_; }
94 98
95 // DTLS methods. 99 // DTLS methods.
96 bool IsDtlsActive() const override { return false; } 100 bool IsDtlsActive() const override { return false; }
97 101
98 // Default implementation. 102 // Default implementation.
99 bool GetSslRole(rtc::SSLRole* role) const override { 103 bool GetSslRole(rtc::SSLRole* role) const override { return false; }
100 return false;
101 }
102 104
103 bool SetSslRole(rtc::SSLRole role) override { 105 bool SetSslRole(rtc::SSLRole role) override { return false; }
104 return false;
105 }
106 106
107 // Set up the ciphers to use for DTLS-SRTP. 107 // Set up the ciphers to use for DTLS-SRTP.
108 bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override { 108 bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override {
109 return false; 109 return false;
110 } 110 }
111 111
112 // Find out which DTLS-SRTP cipher was negotiated. 112 // Find out which DTLS-SRTP cipher was negotiated.
113 bool GetSrtpCipher(std::string* cipher) override { 113 bool GetSrtpCipher(std::string* cipher) override { return false; }
114 return false;
115 }
116 114
117 // Find out which DTLS cipher was negotiated. 115 // Find out which DTLS cipher was negotiated.
118 bool GetSslCipher(std::string* cipher) override { 116 bool GetSslCipher(std::string* cipher) override { return false; }
119 return false;
120 }
121 117
122 // Returns null because the channel is not encrypted by default. 118 // Returns null because the channel is not encrypted by default.
123 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override { 119 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override {
124 return nullptr; 120 return nullptr;
125 } 121 }
126 122
127 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override { 123 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override {
128 return false; 124 return false;
129 } 125 }
130 126
(...skipping 27 matching lines...) Expand all
158 154
159 // Public for unit tests. 155 // Public for unit tests.
160 Connection* FindNextPingableConnection(); 156 Connection* FindNextPingableConnection();
161 157
162 private: 158 private:
163 rtc::Thread* thread() { return worker_thread_; } 159 rtc::Thread* thread() { return worker_thread_; }
164 PortAllocatorSession* allocator_session() { 160 PortAllocatorSession* allocator_session() {
165 return allocator_sessions_.back(); 161 return allocator_sessions_.back();
166 } 162 }
167 163
168 void Allocate(); 164 void StartGatheringCandidates();
169 void UpdateConnectionStates(); 165 void UpdateConnectionStates();
170 void RequestSort(); 166 void RequestSort();
171 void SortConnections(); 167 void SortConnections();
172 void SwitchBestConnectionTo(Connection* conn); 168 void SwitchBestConnectionTo(Connection* conn);
173 void UpdateChannelState(); 169 void UpdateChannelState();
174 void HandleWritable(); 170 void HandleWritable();
175 void HandleNotWritable(); 171 void HandleNotWritable();
176 void HandleAllTimedOut(); 172 void HandleAllTimedOut();
177 173
178 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; 174 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const;
(...skipping 26 matching lines...) Expand all
205 void OnRoleConflict(PortInterface* port); 201 void OnRoleConflict(PortInterface* port);
206 202
207 void OnConnectionStateChange(Connection* connection); 203 void OnConnectionStateChange(Connection* connection);
208 void OnReadPacket(Connection *connection, const char *data, size_t len, 204 void OnReadPacket(Connection *connection, const char *data, size_t len,
209 const rtc::PacketTime& packet_time); 205 const rtc::PacketTime& packet_time);
210 void OnReadyToSend(Connection* connection); 206 void OnReadyToSend(Connection* connection);
211 void OnConnectionDestroyed(Connection *connection); 207 void OnConnectionDestroyed(Connection *connection);
212 208
213 void OnNominated(Connection* conn); 209 void OnNominated(Connection* conn);
214 210
215 void OnMessage(rtc::Message *pmsg) override; 211 void OnMessage(rtc::Message* pmsg) override;
216 void OnSort(); 212 void OnSort();
217 void OnPing(); 213 void OnPing();
218 214
219 void OnCheckReceiving(); 215 void OnCheckReceiving();
220 216
221 void PruneConnections(); 217 void PruneConnections();
222 Connection* best_nominated_connection() const; 218 Connection* best_nominated_connection() const;
223 219
224 P2PTransport* transport_; 220 P2PTransport* transport_;
225 PortAllocator *allocator_; 221 PortAllocator* allocator_;
226 rtc::Thread *worker_thread_; 222 rtc::Thread* worker_thread_;
227 bool incoming_only_; 223 bool incoming_only_;
228 bool waiting_for_signaling_;
229 int error_; 224 int error_;
230 std::vector<PortAllocatorSession*> allocator_sessions_; 225 std::vector<PortAllocatorSession*> allocator_sessions_;
231 std::vector<PortInterface *> ports_; 226 std::vector<PortInterface *> ports_;
232 std::vector<Connection *> connections_; 227 std::vector<Connection *> connections_;
233 Connection* best_connection_; 228 Connection* best_connection_;
234 // Connection selected by the controlling agent. This should be used only 229 // Connection selected by the controlling agent. This should be used only
235 // at controlled side when protocol type is RFC5245. 230 // at controlled side when protocol type is RFC5245.
236 Connection* pending_best_connection_; 231 Connection* pending_best_connection_;
237 std::vector<RemoteCandidate> remote_candidates_; 232 std::vector<RemoteCandidate> remote_candidates_;
238 bool sort_dirty_; // indicates whether another sort is needed right now 233 bool sort_dirty_; // indicates whether another sort is needed right now
239 bool was_writable_; 234 bool was_writable_;
235 bool had_connection_ = false; // if connections_ has ever been nonempty
240 typedef std::map<rtc::Socket::Option, int> OptionMap; 236 typedef std::map<rtc::Socket::Option, int> OptionMap;
241 OptionMap options_; 237 OptionMap options_;
242 std::string ice_ufrag_; 238 std::string ice_ufrag_;
243 std::string ice_pwd_; 239 std::string ice_pwd_;
244 std::string remote_ice_ufrag_; 240 std::string remote_ice_ufrag_;
245 std::string remote_ice_pwd_; 241 std::string remote_ice_pwd_;
246 IceMode remote_ice_mode_; 242 IceMode remote_ice_mode_;
247 IceRole ice_role_; 243 IceRole ice_role_;
248 uint64 tiebreaker_; 244 uint64 tiebreaker_;
249 uint32 remote_candidate_generation_; 245 uint32 remote_candidate_generation_;
246 IceGatheringState gathering_state_;
250 247
251 int check_receiving_delay_; 248 int check_receiving_delay_;
252 int receiving_timeout_; 249 int receiving_timeout_;
253 250
254 DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); 251 DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel);
255 }; 252 };
256 253
257 } // namespace cricket 254 } // namespace cricket
258 255
259 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ 256 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698