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 |
11 // A Transport manages a set of named channels of the same type. | 11 // A Transport manages a set of named channels of the same type. |
12 // | 12 // |
13 // Subclasses choose the appropriate class to instantiate for each channel; | 13 // Subclasses choose the appropriate class to instantiate for each channel; |
14 // however, this base class keeps track of the channels by name, watches their | 14 // however, this base class keeps track of the channels by name, watches their |
15 // state changes (in order to update the manager's state), and forwards | 15 // state changes (in order to update the manager's state), and forwards |
16 // requests to begin connecting or to reset to each of the channels. | 16 // requests to begin connecting or to reset to each of the channels. |
17 // | 17 // |
18 // On Threading: Transport performs work on both the signaling and worker | 18 // Note: Subclasses must call DestroyChannels() in their own destructors. |
19 // threads. For subclasses, the rule is that all signaling related calls will | 19 // It is not possible to do so here because the subclass destructor will |
20 // be made on the signaling thread and all channel related calls (including | |
21 // signaling for a channel) will be made on the worker thread. When | |
22 // information needs to be sent between the two threads, this class should do | |
23 // the work (e.g., OnRemoteCandidate). | |
24 // | |
25 // Note: Subclasses must call DestroyChannels() in their own constructors. | |
26 // It is not possible to do so here because the subclass constructor will | |
27 // already have run. | 20 // already have run. |
28 | 21 |
29 #ifndef WEBRTC_P2P_BASE_TRANSPORT_H_ | 22 #ifndef WEBRTC_P2P_BASE_TRANSPORT_H_ |
30 #define WEBRTC_P2P_BASE_TRANSPORT_H_ | 23 #define WEBRTC_P2P_BASE_TRANSPORT_H_ |
31 | 24 |
32 #include <map> | 25 #include <map> |
33 #include <string> | 26 #include <string> |
34 #include <vector> | 27 #include <vector> |
35 #include "webrtc/p2p/base/candidate.h" | 28 #include "webrtc/p2p/base/candidate.h" |
36 #include "webrtc/p2p/base/constants.h" | 29 #include "webrtc/p2p/base/constants.h" |
37 #include "webrtc/p2p/base/sessiondescription.h" | 30 #include "webrtc/p2p/base/sessiondescription.h" |
38 #include "webrtc/p2p/base/transportinfo.h" | 31 #include "webrtc/p2p/base/transportinfo.h" |
39 #include "webrtc/base/criticalsection.h" | |
40 #include "webrtc/base/messagequeue.h" | 32 #include "webrtc/base/messagequeue.h" |
41 #include "webrtc/base/sigslot.h" | 33 #include "webrtc/base/sigslot.h" |
42 #include "webrtc/base/sslstreamadapter.h" | 34 #include "webrtc/base/sslstreamadapter.h" |
43 | 35 |
44 namespace rtc { | |
45 class Thread; | |
46 } | |
47 | |
48 namespace cricket { | 36 namespace cricket { |
49 | 37 |
50 class PortAllocator; | 38 class PortAllocator; |
51 class TransportChannel; | 39 class TransportChannel; |
52 class TransportChannelImpl; | 40 class TransportChannelImpl; |
53 | 41 |
54 typedef std::vector<Candidate> Candidates; | 42 typedef std::vector<Candidate> Candidates; |
55 | 43 |
56 // For "writable", "readable", and "receiving", we need to differentiate between | 44 // For "writable", "readable", and "receiving", we need to differentiate between |
57 // none, all, and some. | 45 // none, all, and some. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 TransportChannelStatsList channel_stats; | 116 TransportChannelStatsList channel_stats; |
129 }; | 117 }; |
130 | 118 |
131 bool BadTransportDescription(const std::string& desc, std::string* err_desc); | 119 bool BadTransportDescription(const std::string& desc, std::string* err_desc); |
132 | 120 |
133 bool IceCredentialsChanged(const std::string& old_ufrag, | 121 bool IceCredentialsChanged(const std::string& old_ufrag, |
134 const std::string& old_pwd, | 122 const std::string& old_pwd, |
135 const std::string& new_ufrag, | 123 const std::string& new_ufrag, |
136 const std::string& new_pwd); | 124 const std::string& new_pwd); |
137 | 125 |
138 class Transport : public rtc::MessageHandler, | 126 class Transport : public sigslot::has_slots<> { |
139 public sigslot::has_slots<> { | |
140 public: | 127 public: |
141 Transport(rtc::Thread* signaling_thread, | 128 enum CandidateGatheringState { |
142 rtc::Thread* worker_thread, | 129 kGatheringNew = 0, |
143 const std::string& content_name, | 130 kGatheringGathering, |
131 kGatheringDone, | |
pthatcher1
2015/08/10 20:40:17
Done => Complete
Also, this enum should probably
Taylor Brandstetter
2015/08/11 01:20:08
Done.
| |
132 }; | |
133 | |
134 Transport(const std::string& content_name, | |
144 const std::string& type, | 135 const std::string& type, |
145 PortAllocator* allocator); | 136 PortAllocator* allocator); |
146 virtual ~Transport(); | 137 virtual ~Transport(); |
147 | 138 |
148 // Returns the signaling thread. The app talks to Transport on this thread. | |
149 rtc::Thread* signaling_thread() { return signaling_thread_; } | |
150 // Returns the worker thread. The actual networking is done on this thread. | |
151 rtc::Thread* worker_thread() { return worker_thread_; } | |
152 | |
153 // Returns the content_name of this transport. | 139 // Returns the content_name of this transport. |
154 const std::string& content_name() const { return content_name_; } | 140 const std::string& content_name() const { return content_name_; } |
155 // Returns the type of this transport. | 141 // Returns the type of this transport. |
156 const std::string& type() const { return type_; } | 142 const std::string& type() const { return type_; } |
157 | 143 |
158 // Returns the port allocator object for this transport. | 144 // Returns the port allocator object for this transport. |
159 PortAllocator* port_allocator() { return allocator_; } | 145 PortAllocator* port_allocator() { return allocator_; } |
160 | 146 |
161 // Returns the readable and states of this manager. These bits are the ORs | 147 // Returns the readable and states of this manager. These bits are the ORs |
162 // of the corresponding bits on the managed channels. Each time one of these | 148 // of the corresponding bits on the managed channels. Each time one of these |
(...skipping 14 matching lines...) Expand all Loading... | |
177 bool all_channels_readable() const { | 163 bool all_channels_readable() const { |
178 return (readable_ == TRANSPORT_STATE_ALL); | 164 return (readable_ == TRANSPORT_STATE_ALL); |
179 } | 165 } |
180 bool all_channels_writable() const { | 166 bool all_channels_writable() const { |
181 return (writable_ == TRANSPORT_STATE_ALL); | 167 return (writable_ == TRANSPORT_STATE_ALL); |
182 } | 168 } |
183 bool any_channel_receiving() const { | 169 bool any_channel_receiving() const { |
184 return (receiving_ == TRANSPORT_STATE_SOME || | 170 return (receiving_ == TRANSPORT_STATE_SOME || |
185 receiving_ == TRANSPORT_STATE_ALL); | 171 receiving_ == TRANSPORT_STATE_ALL); |
186 } | 172 } |
173 bool local_description_set() const { | |
174 return local_description_set_; | |
175 } | |
176 bool remote_description_set() const { | |
177 return remote_description_set_; | |
178 } | |
179 | |
180 // Checks if all channels are completed | |
181 bool Completed() const; | |
182 | |
183 CandidateGatheringState candidate_gathering_state() const { | |
184 return candidate_gathering_state_; | |
185 } | |
187 | 186 |
188 sigslot::signal1<Transport*> SignalReadableState; | 187 sigslot::signal1<Transport*> SignalReadableState; |
189 sigslot::signal1<Transport*> SignalWritableState; | 188 sigslot::signal1<Transport*> SignalWritableState; |
190 sigslot::signal1<Transport*> SignalReceivingState; | 189 sigslot::signal1<Transport*> SignalReceivingState; |
191 sigslot::signal1<Transport*> SignalCompleted; | 190 sigslot::signal1<Transport*> SignalCompleted; |
192 sigslot::signal1<Transport*> SignalFailed; | 191 sigslot::signal1<Transport*> SignalFailed; |
193 | 192 |
194 // Returns whether the client has requested the channels to connect. | 193 // Returns whether the client has requested the channels to connect. |
195 bool connect_requested() const { return connect_requested_; } | 194 bool connect_requested() const { return connect_requested_; } |
196 | 195 |
197 void SetIceRole(IceRole role); | 196 void SetIceRole(IceRole role); |
198 IceRole ice_role() const { return ice_role_; } | 197 IceRole ice_role() const { return ice_role_; } |
199 | 198 |
200 void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; } | 199 void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; } |
201 uint64 IceTiebreaker() { return tiebreaker_; } | 200 uint64 IceTiebreaker() { return tiebreaker_; } |
202 | 201 |
203 void SetChannelReceivingTimeout(int timeout_ms); | 202 void SetChannelReceivingTimeout(int timeout_ms); |
204 | 203 |
205 // Must be called before applying local session description. | 204 // Must be called before applying local session description. |
206 void SetIdentity(rtc::SSLIdentity* identity); | 205 virtual void SetIdentity(rtc::SSLIdentity* identity) {} |
207 | 206 |
208 // Get a copy of the local identity provided by SetIdentity. | 207 // Get a copy of the local identity provided by SetIdentity. |
209 bool GetIdentity(rtc::SSLIdentity** identity); | 208 virtual bool GetIdentity(rtc::SSLIdentity** identity) { return false; } |
210 | 209 |
211 // Get a copy of the remote certificate in use by the specified channel. | 210 // Get a copy of the remote certificate in use by the specified channel. |
212 bool GetRemoteCertificate(rtc::SSLCertificate** cert); | 211 bool GetRemoteCertificate(rtc::SSLCertificate** cert); |
213 | 212 |
214 TransportProtocol protocol() const { return protocol_; } | 213 TransportProtocol protocol() const { return protocol_; } |
215 | 214 |
216 // Create, destroy, and lookup the channels of this type by their components. | 215 // Create, destroy, and lookup the channels of this type by their components. |
217 TransportChannelImpl* CreateChannel(int component); | 216 TransportChannelImpl* CreateChannel(int component); |
218 // Note: GetChannel may lead to race conditions, since the mutex is not held | 217 |
219 // after the pointer is returned. | |
220 TransportChannelImpl* GetChannel(int component); | 218 TransportChannelImpl* GetChannel(int component); |
221 // Note: HasChannel does not lead to race conditions, unlike GetChannel. | 219 |
222 bool HasChannel(int component) { | 220 bool HasChannel(int component) { |
223 return (NULL != GetChannel(component)); | 221 return (NULL != GetChannel(component)); |
224 } | 222 } |
225 bool HasChannels(); | 223 bool HasChannels(); |
226 void DestroyChannel(int component); | 224 void DestroyChannel(int component); |
227 | 225 |
228 // Set the local TransportDescription to be used by TransportChannels. | 226 // Set the local TransportDescription to be used by TransportChannels. |
229 // This should be called before ConnectChannels(). | 227 // This should be called before ConnectChannels(). |
230 bool SetLocalTransportDescription(const TransportDescription& description, | 228 bool SetLocalTransportDescription(const TransportDescription& description, |
231 ContentAction action, | 229 ContentAction action, |
(...skipping 11 matching lines...) Expand all Loading... | |
243 | 241 |
244 // Resets all of the channels back to their initial state. They are no | 242 // Resets all of the channels back to their initial state. They are no |
245 // longer connecting. | 243 // longer connecting. |
246 void ResetChannels(); | 244 void ResetChannels(); |
247 | 245 |
248 // Destroys every channel created so far. | 246 // Destroys every channel created so far. |
249 void DestroyAllChannels(); | 247 void DestroyAllChannels(); |
250 | 248 |
251 bool GetStats(TransportStats* stats); | 249 bool GetStats(TransportStats* stats); |
252 | 250 |
253 // Before any stanza is sent, the manager will request signaling. Once | 251 sigslot::signal1<Transport*> SignalCandidatesAllocationStarted; |
254 // signaling is available, the client should call OnSignalingReady. Once | |
255 // this occurs, the transport (or its channels) can send any waiting stanzas. | |
256 // OnSignalingReady invokes OnTransportSignalingReady and then forwards this | |
257 // signal to each channel. | |
258 sigslot::signal1<Transport*> SignalRequestSignaling; | |
259 void OnSignalingReady(); | |
260 | 252 |
261 // Handles sending of ready candidates and receiving of remote candidates. | 253 // Handles sending of ready candidates and receiving of remote candidates. |
262 sigslot::signal2<Transport*, | 254 sigslot::signal2<Transport*, |
263 const std::vector<Candidate>&> SignalCandidatesReady; | 255 const std::vector<Candidate>&> SignalCandidatesReady; |
256 sigslot::signal1<Transport*> SignalCandidatesAllocationDone; | |
264 | 257 |
265 sigslot::signal1<Transport*> SignalCandidatesAllocationDone; | 258 // Called when one or more candidates are ready from the remote peer. |
266 void OnRemoteCandidates(const std::vector<Candidate>& candidates); | 259 bool AddRemoteCandidates( |
260 const std::vector<Candidate>& candidates, std::string* error); | |
261 | |
262 void AddRemoteCandidate(const Candidate& candidate); | |
pthatcher1
2015/08/10 20:40:17
Why do we need both of these?
Taylor Brandstetter
2015/08/11 01:20:08
I'm not sure; this was left over from your origina
| |
267 | 263 |
268 // If candidate is not acceptable, returns false and sets error. | 264 // If candidate is not acceptable, returns false and sets error. |
269 // Call this before calling OnRemoteCandidates. | 265 // Call this before calling OnRemoteCandidates. |
270 virtual bool VerifyCandidate(const Candidate& candidate, | 266 virtual bool VerifyCandidate(const Candidate& candidate, |
271 std::string* error); | 267 std::string* error); |
272 | 268 |
273 // Signals when the best connection for a channel changes. | 269 // Signals when the best connection for a channel changes. |
274 sigslot::signal3<Transport*, | 270 sigslot::signal3<Transport*, |
275 int, // component | 271 int, // component |
276 const Candidate&> SignalRouteChange; | 272 const Candidate&> SignalRouteChange; |
277 | 273 |
278 // Forwards the signal from TransportChannel to BaseSession. | 274 // Forwards the signal from TransportChannel to BaseSession. |
279 sigslot::signal0<> SignalRoleConflict; | 275 sigslot::signal0<> SignalRoleConflict; |
280 | 276 |
281 virtual bool GetSslRole(rtc::SSLRole* ssl_role) const; | 277 virtual bool GetSslRole(rtc::SSLRole* ssl_role) const { return false; } |
282 | 278 |
283 // Must be called before channel is starting to connect. | 279 // Must be called before channel is starting to connect. |
284 virtual bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version); | 280 virtual bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { |
281 return false; | |
282 } | |
285 | 283 |
286 protected: | 284 protected: |
287 // These are called by Create/DestroyChannel above in order to create or | 285 // These are called by Create/DestroyChannel above in order to create or |
288 // destroy the appropriate type of channel. | 286 // destroy the appropriate type of channel. |
289 virtual TransportChannelImpl* CreateTransportChannel(int component) = 0; | 287 virtual TransportChannelImpl* CreateTransportChannel(int component) = 0; |
290 virtual void DestroyTransportChannel(TransportChannelImpl* channel) = 0; | 288 virtual void DestroyTransportChannel(TransportChannelImpl* channel) = 0; |
291 | 289 |
292 // Informs the subclass that we received the signaling ready message. | |
293 virtual void OnTransportSignalingReady() {} | |
294 | |
295 // The current local transport description, for use by derived classes | 290 // The current local transport description, for use by derived classes |
296 // when performing transport description negotiation. | 291 // when performing transport description negotiation. |
297 const TransportDescription* local_description() const { | 292 const TransportDescription* local_description() const { |
298 return local_description_.get(); | 293 return local_description_.get(); |
299 } | 294 } |
300 | 295 |
301 // The current remote transport description, for use by derived classes | 296 // The current remote transport description, for use by derived classes |
302 // when performing transport description negotiation. | 297 // when performing transport description negotiation. |
303 const TransportDescription* remote_description() const { | 298 const TransportDescription* remote_description() const { |
304 return remote_description_.get(); | 299 return remote_description_.get(); |
305 } | 300 } |
306 | 301 |
307 virtual void SetIdentity_w(rtc::SSLIdentity* identity) {} | |
308 | |
309 virtual bool GetIdentity_w(rtc::SSLIdentity** identity) { | |
310 return false; | |
311 } | |
312 | |
313 // Pushes down the transport parameters from the local description, such | 302 // Pushes down the transport parameters from the local description, such |
314 // as the ICE ufrag and pwd. | 303 // as the ICE ufrag and pwd. |
315 // Derived classes can override, but must call the base as well. | 304 // Derived classes can override, but must call the base as well. |
316 virtual bool ApplyLocalTransportDescription_w(TransportChannelImpl* channel, | 305 virtual bool ApplyLocalTransportDescription(TransportChannelImpl* channel, |
317 std::string* error_desc); | 306 std::string* error_desc); |
318 | 307 |
319 // Pushes down remote ice credentials from the remote description to the | 308 // Pushes down remote ice credentials from the remote description to the |
320 // transport channel. | 309 // transport channel. |
321 virtual bool ApplyRemoteTransportDescription_w(TransportChannelImpl* ch, | 310 virtual bool ApplyRemoteTransportDescription(TransportChannelImpl* ch, |
322 std::string* error_desc); | 311 std::string* error_desc); |
323 | 312 |
324 // Negotiates the transport parameters based on the current local and remote | 313 // Negotiates the transport parameters based on the current local and remote |
325 // transport description, such at the version of ICE to use, and whether DTLS | 314 // transport description, such at the version of ICE to use, and whether DTLS |
326 // should be activated. | 315 // should be activated. |
327 // Derived classes can negotiate their specific parameters here, but must call | 316 // Derived classes can negotiate their specific parameters here, but must call |
328 // the base as well. | 317 // the base as well. |
329 virtual bool NegotiateTransportDescription_w(ContentAction local_role, | 318 virtual bool NegotiateTransportDescription(ContentAction local_role, |
330 std::string* error_desc); | 319 std::string* error_desc); |
331 | 320 |
332 // Pushes down the transport parameters obtained via negotiation. | 321 // Pushes down the transport parameters obtained via negotiation. |
333 // Derived classes can set their specific parameters here, but must call the | 322 // Derived classes can set their specific parameters here, but must call the |
334 // base as well. | 323 // base as well. |
335 virtual bool ApplyNegotiatedTransportDescription_w( | 324 virtual bool ApplyNegotiatedTransportDescription( |
336 TransportChannelImpl* channel, std::string* error_desc); | 325 TransportChannelImpl* channel, std::string* error_desc); |
337 | 326 |
338 virtual bool GetSslRole_w(rtc::SSLRole* ssl_role) const { | |
339 return false; | |
340 } | |
341 | |
342 virtual bool SetSslMaxProtocolVersion_w(rtc::SSLProtocolVersion version) { | |
343 return false; | |
344 } | |
345 | |
346 private: | 327 private: |
347 struct ChannelMapEntry { | 328 struct ChannelMapEntry { |
348 ChannelMapEntry() : impl_(NULL), candidates_allocated_(false), ref_(0) {} | 329 ChannelMapEntry() : impl_(NULL), ref_(0) {} |
349 explicit ChannelMapEntry(TransportChannelImpl *impl) | 330 explicit ChannelMapEntry(TransportChannelImpl *impl) |
350 : impl_(impl), | 331 : impl_(impl), |
351 candidates_allocated_(false), | |
352 ref_(0) { | 332 ref_(0) { |
353 } | 333 } |
354 | 334 |
355 void AddRef() { ++ref_; } | 335 void AddRef() { ++ref_; } |
356 void DecRef() { | 336 void DecRef() { |
357 ASSERT(ref_ > 0); | 337 ASSERT(ref_ > 0); |
358 --ref_; | 338 --ref_; |
359 } | 339 } |
360 int ref() const { return ref_; } | 340 int ref() const { return ref_; } |
361 | 341 |
362 TransportChannelImpl* get() const { return impl_; } | 342 TransportChannelImpl* get() const { return impl_; } |
363 TransportChannelImpl* operator->() const { return impl_; } | 343 TransportChannelImpl* operator->() const { return impl_; } |
364 void set_candidates_allocated(bool status) { | |
365 candidates_allocated_ = status; | |
366 } | |
367 bool candidates_allocated() const { return candidates_allocated_; } | |
368 | 344 |
369 private: | 345 private: |
370 TransportChannelImpl *impl_; | 346 TransportChannelImpl* impl_; |
371 bool candidates_allocated_; | |
372 int ref_; | 347 int ref_; |
373 }; | 348 }; |
374 | 349 |
375 // Candidate component => ChannelMapEntry | 350 // Candidate component => ChannelMapEntry |
376 typedef std::map<int, ChannelMapEntry> ChannelMap; | 351 typedef std::map<int, ChannelMapEntry> ChannelMap; |
377 | 352 |
378 // Called when the state of a channel changes. | 353 // Called when the state of a channel changes. |
379 void OnChannelReadableState(TransportChannel* channel); | 354 void OnChannelReadableState(TransportChannel* channel); |
380 void OnChannelWritableState(TransportChannel* channel); | 355 void OnChannelWritableState(TransportChannel* channel); |
381 | 356 |
382 // Called when the receiving state of a channel changes. | 357 // Called when the receiving state of a channel changes. |
383 void OnChannelReceivingState(TransportChannel* channel); | 358 void OnChannelReceivingState(TransportChannel* channel); |
384 | 359 |
385 // Called when a channel requests signaling. | 360 // Called when a channel starts allocating candidates for a new ICE session |
386 void OnChannelRequestSignaling(TransportChannelImpl* channel); | 361 void OnChannelCandidatesAllocationStarted(TransportChannelImpl* channel); |
387 | 362 |
388 // Called when a candidate is ready from remote peer. | |
389 void OnRemoteCandidate(const Candidate& candidate); | |
390 // Called when a candidate is ready from channel. | 363 // Called when a candidate is ready from channel. |
391 void OnChannelCandidateReady(TransportChannelImpl* channel, | 364 void OnChannelCandidateReady(TransportChannelImpl* channel, |
392 const Candidate& candidate); | 365 const Candidate& candidate); |
393 void OnChannelRouteChange(TransportChannel* channel, | 366 void OnChannelRouteChange(TransportChannel* channel, |
394 const Candidate& remote_candidate); | 367 const Candidate& remote_candidate); |
395 void OnChannelCandidatesAllocationDone(TransportChannelImpl* channel); | 368 void OnChannelCandidatesAllocationDone(TransportChannelImpl* channel); |
396 // Called when there is ICE role change. | 369 // Called when there is ICE role change. |
397 void OnRoleConflict(TransportChannelImpl* channel); | 370 void OnRoleConflict(TransportChannelImpl* channel); |
398 // Called when the channel removes a connection. | 371 // Called when the channel removes a connection. |
399 void OnChannelConnectionRemoved(TransportChannelImpl* channel); | 372 void OnChannelConnectionRemoved(TransportChannelImpl* channel); |
400 | 373 |
401 // Dispatches messages to the appropriate handler (below). | |
402 void OnMessage(rtc::Message* msg); | |
403 | |
404 // These are versions of the above methods that are called only on a | |
405 // particular thread (s = signaling, w = worker). The above methods post or | |
406 // send a message to invoke this version. | |
407 TransportChannelImpl* CreateChannel_w(int component); | |
408 void DestroyChannel_w(int component); | |
409 void ConnectChannels_w(); | |
410 void ResetChannels_w(); | |
411 void DestroyAllChannels_w(); | |
412 void OnRemoteCandidate_w(const Candidate& candidate); | |
413 void OnChannelReadableState_s(); | |
414 void OnChannelWritableState_s(); | |
415 void OnChannelReceivingState_s(); | |
416 void OnChannelRequestSignaling_s(); | |
417 void OnConnecting_s(); | |
418 void OnChannelRouteChange_s(const TransportChannel* channel, | |
419 const Candidate& remote_candidate); | |
420 void OnChannelCandidatesAllocationDone_s(); | |
421 | |
422 // Helper function that invokes the given function on every channel. | 374 // Helper function that invokes the given function on every channel. |
423 typedef void (TransportChannelImpl::* TransportChannelFunc)(); | 375 typedef void (TransportChannelImpl::* TransportChannelFunc)(); |
424 void CallChannels_w(TransportChannelFunc func); | 376 void CallChannels(TransportChannelFunc func); |
425 | 377 |
426 // Computes the AND and OR of the channel's read/write/receiving state | 378 // Computes the AND and OR of the channel's read/write/receiving state |
427 // (argument picks the operation). | 379 // (argument picks the operation). |
428 TransportState GetTransportState_s(TransportStateType type); | 380 TransportState GetTransportState(TransportStateType type); |
429 | |
430 void OnChannelCandidateReady_s(); | |
431 | |
432 void SetIceRole_w(IceRole role); | |
433 void SetRemoteIceMode_w(IceMode mode); | |
434 bool SetLocalTransportDescription_w(const TransportDescription& desc, | |
435 ContentAction action, | |
436 std::string* error_desc); | |
437 bool SetRemoteTransportDescription_w(const TransportDescription& desc, | |
438 ContentAction action, | |
439 std::string* error_desc); | |
440 bool GetStats_w(TransportStats* infos); | |
441 bool GetRemoteCertificate_w(rtc::SSLCertificate** cert); | |
442 | |
443 void SetChannelReceivingTimeout_w(int timeout_ms); | |
444 | 381 |
445 // Sends SignalCompleted if we are now in that state. | 382 // Sends SignalCompleted if we are now in that state. |
446 void MaybeCompleted_w(); | 383 void CheckIfCompleted(); |
447 | 384 |
448 rtc::Thread* const signaling_thread_; | 385 // Sends SignalCandidatesAllocationDone if all channels are done |
449 rtc::Thread* const worker_thread_; | 386 void CheckIfCandidatesAllocationDone(); |
387 | |
388 void UpdateReadableState(); | |
389 void UpdateWritableState(); | |
390 void UpdateReceivingState(); | |
391 | |
450 const std::string content_name_; | 392 const std::string content_name_; |
451 const std::string type_; | 393 const std::string type_; |
452 PortAllocator* const allocator_; | 394 PortAllocator* const allocator_; |
453 bool destroyed_; | 395 bool destroyed_; |
454 TransportState readable_; | 396 TransportState readable_; |
455 TransportState writable_; | 397 TransportState writable_; |
456 TransportState receiving_; | 398 TransportState receiving_; |
457 bool was_writable_; | 399 bool was_writable_; |
458 bool connect_requested_; | 400 bool connect_requested_; |
459 IceRole ice_role_; | 401 IceRole ice_role_; |
460 uint64 tiebreaker_; | 402 uint64 tiebreaker_; |
461 TransportProtocol protocol_; | 403 TransportProtocol protocol_; |
462 IceMode remote_ice_mode_; | 404 IceMode remote_ice_mode_; |
463 int channel_receiving_timeout_; | 405 int channel_receiving_timeout_; |
464 rtc::scoped_ptr<TransportDescription> local_description_; | 406 rtc::scoped_ptr<TransportDescription> local_description_; |
465 rtc::scoped_ptr<TransportDescription> remote_description_; | 407 rtc::scoped_ptr<TransportDescription> remote_description_; |
408 bool local_description_set_; | |
409 bool remote_description_set_; | |
410 CandidateGatheringState candidate_gathering_state_; | |
466 | 411 |
467 // TODO(tommi): Make sure we only use this on the worker thread. | |
468 ChannelMap channels_; | 412 ChannelMap channels_; |
469 // Buffers the ready_candidates so that SignalCanidatesReady can | 413 // Buffers the ready_candidates so that SignalCanidatesReady can |
470 // provide them in multiples. | 414 // provide them in multiples. |
471 std::vector<Candidate> ready_candidates_; | 415 std::vector<Candidate> ready_candidates_; |
472 // Protects changes to channels and messages | |
473 rtc::CriticalSection crit_; | |
474 | 416 |
475 DISALLOW_COPY_AND_ASSIGN(Transport); | 417 DISALLOW_COPY_AND_ASSIGN(Transport); |
476 }; | 418 }; |
477 | 419 |
478 // Extract a TransportProtocol from a TransportDescription. | 420 // Extract a TransportProtocol from a TransportDescription. |
479 TransportProtocol TransportProtocolFromDescription( | 421 TransportProtocol TransportProtocolFromDescription( |
480 const TransportDescription* desc); | 422 const TransportDescription* desc); |
481 | 423 |
482 } // namespace cricket | 424 } // namespace cricket |
483 | 425 |
484 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ | 426 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ |
OLD | NEW |