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

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: Merging again 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 virtual ~P2PTransportChannel(); 58 virtual ~P2PTransportChannel();
59 59
60 // From TransportChannelImpl: 60 // From TransportChannelImpl:
61 virtual Transport* GetTransport() { return transport_; } 61 virtual Transport* GetTransport() { return transport_; }
62 virtual TransportChannelState GetState() const; 62 virtual TransportChannelState GetState() const;
63 virtual void SetIceRole(IceRole role); 63 virtual void SetIceRole(IceRole role);
64 virtual IceRole GetIceRole() const { return ice_role_; } 64 virtual IceRole GetIceRole() const { return ice_role_; }
65 virtual void SetIceTiebreaker(uint64 tiebreaker); 65 virtual void SetIceTiebreaker(uint64 tiebreaker);
66 virtual void SetIceCredentials(const std::string& ice_ufrag, 66 virtual void SetIceCredentials(const std::string& ice_ufrag,
67 const std::string& ice_pwd); 67 const std::string& ice_pwd);
68 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, 68 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
69 const std::string& ice_pwd); 69 const std::string& ice_pwd);
70 virtual void SetRemoteIceMode(IceMode mode); 70 virtual void SetRemoteIceMode(IceMode mode);
71 virtual void Connect(); 71 virtual void Connect();
72 virtual void OnSignalingReady(); 72 virtual IceGatheringState gathering_state() const { return gathering_state_; }
73 virtual void OnCandidate(const Candidate& candidate); 73 virtual void AddRemoteCandidate(const Candidate& candidate);
74 // Sets the receiving timeout in milliseconds. 74 // Sets the receiving timeout in milliseconds.
75 // This also sets the check_receiving_delay proportionally. 75 // This also sets the check_receiving_delay proportionally.
76 virtual void SetReceivingTimeout(int receiving_timeout_ms); 76 virtual void SetReceivingTimeout(int receiving_timeout_ms);
77 77
78 // From TransportChannel: 78 // From TransportChannel:
79 virtual int SendPacket(const char *data, size_t len, 79 virtual int SendPacket(const char *data, size_t len,
80 const rtc::PacketOptions& options, int flags); 80 const rtc::PacketOptions& options, int flags);
81 virtual int SetOption(rtc::Socket::Option opt, int value); 81 virtual int SetOption(rtc::Socket::Option opt, int value);
82 virtual bool GetOption(rtc::Socket::Option opt, int* value); 82 virtual bool GetOption(rtc::Socket::Option opt, int* value);
83 virtual int GetError() { return error_; } 83 virtual int GetError() { return error_; }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 // Public for unit tests. 160 // Public for unit tests.
161 Connection* FindNextPingableConnection(); 161 Connection* FindNextPingableConnection();
162 162
163 private: 163 private:
164 rtc::Thread* thread() { return worker_thread_; } 164 rtc::Thread* thread() { return worker_thread_; }
165 PortAllocatorSession* allocator_session() { 165 PortAllocatorSession* allocator_session() {
166 return allocator_sessions_.back(); 166 return allocator_sessions_.back();
167 } 167 }
168 168
169 void Allocate(); 169 void StartGatheringCandidates();
170 void UpdateConnectionStates(); 170 void UpdateConnectionStates();
171 void RequestSort(); 171 void RequestSort();
172 void SortConnections(); 172 void SortConnections();
173 void SwitchBestConnectionTo(Connection* conn); 173 void SwitchBestConnectionTo(Connection* conn);
174 void UpdateChannelState(); 174 void UpdateChannelState();
175 void HandleWritable(); 175 void HandleWritable();
176 void HandleNotWritable(); 176 void HandleNotWritable();
177 void HandleAllTimedOut(); 177 void HandleAllTimedOut();
178 178
179 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; 179 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 virtual void OnMessage(rtc::Message *pmsg); 216 virtual void OnMessage(rtc::Message *pmsg);
217 void OnSort(); 217 void OnSort();
218 void OnPing(); 218 void OnPing();
219 219
220 void OnCheckReceiving(); 220 void OnCheckReceiving();
221 221
222 void PruneConnections(); 222 void PruneConnections();
223 Connection* best_nominated_connection() const; 223 Connection* best_nominated_connection() const;
224 224
225 P2PTransport* transport_; 225 P2PTransport* transport_;
226 PortAllocator *allocator_; 226 PortAllocator* allocator_;
227 rtc::Thread *worker_thread_; 227 rtc::Thread* worker_thread_;
228 bool incoming_only_; 228 bool incoming_only_;
229 bool waiting_for_signaling_;
230 int error_; 229 int error_;
231 std::vector<PortAllocatorSession*> allocator_sessions_; 230 std::vector<PortAllocatorSession*> allocator_sessions_;
232 std::vector<PortInterface *> ports_; 231 std::vector<PortInterface *> ports_;
233 std::vector<Connection *> connections_; 232 std::vector<Connection *> connections_;
234 Connection* best_connection_; 233 Connection* best_connection_;
235 // Connection selected by the controlling agent. This should be used only 234 // Connection selected by the controlling agent. This should be used only
236 // at controlled side when protocol type is RFC5245. 235 // at controlled side when protocol type is RFC5245.
237 Connection* pending_best_connection_; 236 Connection* pending_best_connection_;
238 std::vector<RemoteCandidate> remote_candidates_; 237 std::vector<RemoteCandidate> remote_candidates_;
239 bool sort_dirty_; // indicates whether another sort is needed right now 238 bool sort_dirty_; // indicates whether another sort is needed right now
240 bool was_writable_; 239 bool was_writable_;
240 bool had_connection_ = false; // if connections_ has ever been nonempty
241 typedef std::map<rtc::Socket::Option, int> OptionMap; 241 typedef std::map<rtc::Socket::Option, int> OptionMap;
242 OptionMap options_; 242 OptionMap options_;
243 std::string ice_ufrag_; 243 std::string ice_ufrag_;
244 std::string ice_pwd_; 244 std::string ice_pwd_;
245 std::string remote_ice_ufrag_; 245 std::string remote_ice_ufrag_;
246 std::string remote_ice_pwd_; 246 std::string remote_ice_pwd_;
247 IceMode remote_ice_mode_; 247 IceMode remote_ice_mode_;
248 IceRole ice_role_; 248 IceRole ice_role_;
249 uint64 tiebreaker_; 249 uint64 tiebreaker_;
250 uint32 remote_candidate_generation_; 250 uint32 remote_candidate_generation_;
251 IceGatheringState gathering_state_;
251 252
252 int check_receiving_delay_; 253 int check_receiving_delay_;
253 int receiving_timeout_; 254 int receiving_timeout_;
254 255
255 DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); 256 DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel);
256 }; 257 };
257 258
258 } // namespace cricket 259 } // namespace cricket
259 260
260 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ 261 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698