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

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

Issue 1358413003: Revert of TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
« no previous file with comments | « webrtc/p2p/base/p2ptransport.cc ('k') | webrtc/p2p/base/p2ptransportchannel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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& transport_name, 54 P2PTransportChannel(const std::string& content_name,
55 int component, 55 int component,
56 P2PTransport* transport, 56 P2PTransport* transport,
57 PortAllocator* allocator); 57 PortAllocator *allocator);
58 virtual ~P2PTransportChannel(); 58 ~P2PTransportChannel() override;
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 MaybeStartGathering() override; 72 void OnSignalingReady() override;
73 IceGatheringState gathering_state() const override { 73 void OnCandidate(const Candidate& candidate) override;
74 return gathering_state_;
75 }
76 void AddRemoteCandidate(const Candidate& candidate) override;
77 // Sets the receiving timeout in milliseconds. 74 // Sets the receiving timeout in milliseconds.
78 // This also sets the check_receiving_delay proportionally. 75 // This also sets the check_receiving_delay proportionally.
79 void SetReceivingTimeout(int receiving_timeout_ms) override; 76 void SetReceivingTimeout(int receiving_timeout_ms) override;
80 77
81 // From TransportChannel: 78 // From TransportChannel:
82 int SendPacket(const char* data, 79 int SendPacket(const char *data, size_t len,
83 size_t len, 80 const rtc::PacketOptions& options, int flags) override;
84 const rtc::PacketOptions& options,
85 int flags) override;
86 int SetOption(rtc::Socket::Option opt, int value) override; 81 int SetOption(rtc::Socket::Option opt, int value) override;
87 bool GetOption(rtc::Socket::Option opt, int* value) override; 82 bool GetOption(rtc::Socket::Option opt, int* value) override;
88 int GetError() override { return error_; } 83 int GetError() override { return error_; }
89 bool GetStats(std::vector<ConnectionInfo>* stats) override; 84 bool GetStats(std::vector<ConnectionInfo>* stats) override;
90 85
91 const Connection* best_connection() const { return best_connection_; } 86 const Connection* best_connection() const { return best_connection_; }
92 void set_incoming_only(bool value) { incoming_only_ = value; } 87 void set_incoming_only(bool value) { incoming_only_ = value; }
93 88
94 // Note: This is only for testing purpose. 89 // Note: This is only for testing purpose.
95 // |ports_| should not be changed from outside. 90 // |ports_| should not be changed from outside.
96 const std::vector<PortInterface*>& ports() { return ports_; } 91 const std::vector<PortInterface*>& ports() { return ports_; }
97 92
98 IceMode remote_ice_mode() const { return remote_ice_mode_; } 93 IceMode remote_ice_mode() const { return remote_ice_mode_; }
99 94
100 // DTLS methods. 95 // DTLS methods.
101 bool IsDtlsActive() const override { return false; } 96 bool IsDtlsActive() const override { return false; }
102 97
103 // Default implementation. 98 // Default implementation.
104 bool GetSslRole(rtc::SSLRole* role) const override { return false; } 99 bool GetSslRole(rtc::SSLRole* role) const override {
100 return false;
101 }
105 102
106 bool SetSslRole(rtc::SSLRole role) override { return false; } 103 bool SetSslRole(rtc::SSLRole role) override {
104 return false;
105 }
107 106
108 // Set up the ciphers to use for DTLS-SRTP. 107 // Set up the ciphers to use for DTLS-SRTP.
109 bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override { 108 bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override {
110 return false; 109 return false;
111 } 110 }
112 111
113 // Find out which DTLS-SRTP cipher was negotiated. 112 // Find out which DTLS-SRTP cipher was negotiated.
114 bool GetSrtpCipher(std::string* cipher) override { return false; } 113 bool GetSrtpCipher(std::string* cipher) override {
114 return false;
115 }
115 116
116 // Find out which DTLS cipher was negotiated. 117 // Find out which DTLS cipher was negotiated.
117 bool GetSslCipher(std::string* cipher) override { return false; } 118 bool GetSslCipher(std::string* cipher) override {
119 return false;
120 }
118 121
119 // Returns null because the channel is not encrypted by default. 122 // Returns null because the channel is not encrypted by default.
120 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override { 123 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override {
121 return nullptr; 124 return nullptr;
122 } 125 }
123 126
124 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override { 127 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override {
125 return false; 128 return false;
126 } 129 }
127 130
(...skipping 27 matching lines...) Expand all
155 158
156 // Public for unit tests. 159 // Public for unit tests.
157 Connection* FindNextPingableConnection(); 160 Connection* FindNextPingableConnection();
158 161
159 private: 162 private:
160 rtc::Thread* thread() { return worker_thread_; } 163 rtc::Thread* thread() { return worker_thread_; }
161 PortAllocatorSession* allocator_session() { 164 PortAllocatorSession* allocator_session() {
162 return allocator_sessions_.back(); 165 return allocator_sessions_.back();
163 } 166 }
164 167
168 void Allocate();
165 void UpdateConnectionStates(); 169 void UpdateConnectionStates();
166 void RequestSort(); 170 void RequestSort();
167 void SortConnections(); 171 void SortConnections();
168 void SwitchBestConnectionTo(Connection* conn); 172 void SwitchBestConnectionTo(Connection* conn);
169 void UpdateChannelState(); 173 void UpdateChannelState();
170 void HandleWritable(); 174 void HandleWritable();
171 void HandleNotWritable(); 175 void HandleNotWritable();
172 void HandleAllTimedOut(); 176 void HandleAllTimedOut();
173 177
174 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; 178 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const;
(...skipping 27 matching lines...) Expand all
202 void OnRoleConflict(PortInterface* port); 206 void OnRoleConflict(PortInterface* port);
203 207
204 void OnConnectionStateChange(Connection* connection); 208 void OnConnectionStateChange(Connection* connection);
205 void OnReadPacket(Connection *connection, const char *data, size_t len, 209 void OnReadPacket(Connection *connection, const char *data, size_t len,
206 const rtc::PacketTime& packet_time); 210 const rtc::PacketTime& packet_time);
207 void OnReadyToSend(Connection* connection); 211 void OnReadyToSend(Connection* connection);
208 void OnConnectionDestroyed(Connection *connection); 212 void OnConnectionDestroyed(Connection *connection);
209 213
210 void OnNominated(Connection* conn); 214 void OnNominated(Connection* conn);
211 215
212 void OnMessage(rtc::Message* pmsg) override; 216 void OnMessage(rtc::Message *pmsg) override;
213 void OnSort(); 217 void OnSort();
214 void OnPing(); 218 void OnPing();
215 219
216 void OnCheckReceiving(); 220 void OnCheckReceiving();
217 221
218 void PruneConnections(); 222 void PruneConnections();
219 Connection* best_nominated_connection() const; 223 Connection* best_nominated_connection() const;
220 224
221 P2PTransport* transport_; 225 P2PTransport* transport_;
222 PortAllocator* allocator_; 226 PortAllocator *allocator_;
223 rtc::Thread* worker_thread_; 227 rtc::Thread *worker_thread_;
224 bool incoming_only_; 228 bool incoming_only_;
229 bool waiting_for_signaling_;
225 int error_; 230 int error_;
226 std::vector<PortAllocatorSession*> allocator_sessions_; 231 std::vector<PortAllocatorSession*> allocator_sessions_;
227 std::vector<PortInterface *> ports_; 232 std::vector<PortInterface *> ports_;
228 std::vector<Connection *> connections_; 233 std::vector<Connection *> connections_;
229 Connection* best_connection_; 234 Connection* best_connection_;
230 // Connection selected by the controlling agent. This should be used only 235 // Connection selected by the controlling agent. This should be used only
231 // at controlled side when protocol type is RFC5245. 236 // at controlled side when protocol type is RFC5245.
232 Connection* pending_best_connection_; 237 Connection* pending_best_connection_;
233 std::vector<RemoteCandidate> remote_candidates_; 238 std::vector<RemoteCandidate> remote_candidates_;
234 bool sort_dirty_; // indicates whether another sort is needed right now 239 bool sort_dirty_; // indicates whether another sort is needed right now
235 bool was_writable_; 240 bool was_writable_;
236 bool had_connection_ = false; // if connections_ has ever been nonempty
237 typedef std::map<rtc::Socket::Option, int> OptionMap; 241 typedef std::map<rtc::Socket::Option, int> OptionMap;
238 OptionMap options_; 242 OptionMap options_;
239 std::string ice_ufrag_; 243 std::string ice_ufrag_;
240 std::string ice_pwd_; 244 std::string ice_pwd_;
241 std::string remote_ice_ufrag_; 245 std::string remote_ice_ufrag_;
242 std::string remote_ice_pwd_; 246 std::string remote_ice_pwd_;
243 IceMode remote_ice_mode_; 247 IceMode remote_ice_mode_;
244 IceRole ice_role_; 248 IceRole ice_role_;
245 uint64 tiebreaker_; 249 uint64 tiebreaker_;
246 uint32 remote_candidate_generation_; 250 uint32 remote_candidate_generation_;
247 IceGatheringState gathering_state_;
248 251
249 int check_receiving_delay_; 252 int check_receiving_delay_;
250 int receiving_timeout_; 253 int receiving_timeout_;
251 254
252 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); 255 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel);
253 }; 256 };
254 257
255 } // namespace cricket 258 } // namespace cricket
256 259
257 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ 260 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransport.cc ('k') | webrtc/p2p/base/p2ptransportchannel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698