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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 typedef std::vector<Candidate> Candidates; | 54 typedef std::vector<Candidate> Candidates; |
55 | 55 |
56 // For "writable" and "readable", we need to differentiate between | 56 // For "writable" and "readable", we need to differentiate between |
57 // none, all, and some. | 57 // none, all, and some. |
58 enum TransportState { | 58 enum TransportState { |
59 TRANSPORT_STATE_NONE = 0, | 59 TRANSPORT_STATE_NONE = 0, |
60 TRANSPORT_STATE_SOME, | 60 TRANSPORT_STATE_SOME, |
61 TRANSPORT_STATE_ALL | 61 TRANSPORT_STATE_ALL |
62 }; | 62 }; |
63 | 63 |
64 // When checking transport state, we need to differentiate between | |
65 // "readable", "writable", or "flaky" check. | |
66 enum TransportStateType { | |
67 TRANSPORT_READABLE_STATE = 0, | |
68 TRANSPORT_WRITABLE_STATE, | |
69 TRANSPORT_FLAKY_STATE | |
pthatcher1
2015/06/26 19:24:03
TRANSPORT_RECEIVING_STATE
honghaiz3
2015/08/05 23:56:56
Done.
| |
70 }; | |
71 | |
64 // Stats that we can return about the connections for a transport channel. | 72 // Stats that we can return about the connections for a transport channel. |
65 // TODO(hta): Rename to ConnectionStats | 73 // TODO(hta): Rename to ConnectionStats |
66 struct ConnectionInfo { | 74 struct ConnectionInfo { |
67 ConnectionInfo() | 75 ConnectionInfo() |
68 : best_connection(false), | 76 : best_connection(false), |
69 writable(false), | 77 writable(false), |
70 readable(false), | 78 readable(false), |
71 timeout(false), | 79 timeout(false), |
72 new_connection(false), | 80 new_connection(false), |
73 rtt(0), | 81 rtt(0), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 bool any_channels_writable() const { | 173 bool any_channels_writable() const { |
166 return (writable_ == TRANSPORT_STATE_SOME || | 174 return (writable_ == TRANSPORT_STATE_SOME || |
167 writable_ == TRANSPORT_STATE_ALL); | 175 writable_ == TRANSPORT_STATE_ALL); |
168 } | 176 } |
169 bool all_channels_readable() const { | 177 bool all_channels_readable() const { |
170 return (readable_ == TRANSPORT_STATE_ALL); | 178 return (readable_ == TRANSPORT_STATE_ALL); |
171 } | 179 } |
172 bool all_channels_writable() const { | 180 bool all_channels_writable() const { |
173 return (writable_ == TRANSPORT_STATE_ALL); | 181 return (writable_ == TRANSPORT_STATE_ALL); |
174 } | 182 } |
183 bool all_channels_flaky() const { | |
184 return (flaky_ == TRANSPORT_STATE_ALL); | |
185 } | |
186 | |
175 sigslot::signal1<Transport*> SignalReadableState; | 187 sigslot::signal1<Transport*> SignalReadableState; |
176 sigslot::signal1<Transport*> SignalWritableState; | 188 sigslot::signal1<Transport*> SignalWritableState; |
189 sigslot::signal1<Transport*> SignalFlakyState; | |
177 sigslot::signal1<Transport*> SignalCompleted; | 190 sigslot::signal1<Transport*> SignalCompleted; |
178 sigslot::signal1<Transport*> SignalFailed; | 191 sigslot::signal1<Transport*> SignalFailed; |
179 | 192 |
180 // Returns whether the client has requested the channels to connect. | 193 // Returns whether the client has requested the channels to connect. |
181 bool connect_requested() const { return connect_requested_; } | 194 bool connect_requested() const { return connect_requested_; } |
182 | 195 |
183 void SetIceRole(IceRole role); | 196 void SetIceRole(IceRole role); |
184 IceRole ice_role() const { return ice_role_; } | 197 IceRole ice_role() const { return ice_role_; } |
185 | 198 |
186 void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; } | 199 void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 int ref_; | 369 int ref_; |
357 }; | 370 }; |
358 | 371 |
359 // Candidate component => ChannelMapEntry | 372 // Candidate component => ChannelMapEntry |
360 typedef std::map<int, ChannelMapEntry> ChannelMap; | 373 typedef std::map<int, ChannelMapEntry> ChannelMap; |
361 | 374 |
362 // Called when the state of a channel changes. | 375 // Called when the state of a channel changes. |
363 void OnChannelReadableState(TransportChannel* channel); | 376 void OnChannelReadableState(TransportChannel* channel); |
364 void OnChannelWritableState(TransportChannel* channel); | 377 void OnChannelWritableState(TransportChannel* channel); |
365 | 378 |
379 // Called when the flakiness of a channel changes. | |
380 void OnChannelFlakyState(TransportChannel* channel); | |
pthatcher1
2015/06/26 19:24:03
OnChannelReceivingState
honghaiz3
2015/08/05 23:56:57
Done.
| |
381 | |
366 // Called when a channel requests signaling. | 382 // Called when a channel requests signaling. |
367 void OnChannelRequestSignaling(TransportChannelImpl* channel); | 383 void OnChannelRequestSignaling(TransportChannelImpl* channel); |
368 | 384 |
369 // Called when a candidate is ready from remote peer. | 385 // Called when a candidate is ready from remote peer. |
370 void OnRemoteCandidate(const Candidate& candidate); | 386 void OnRemoteCandidate(const Candidate& candidate); |
371 // Called when a candidate is ready from channel. | 387 // Called when a candidate is ready from channel. |
372 void OnChannelCandidateReady(TransportChannelImpl* channel, | 388 void OnChannelCandidateReady(TransportChannelImpl* channel, |
373 const Candidate& candidate); | 389 const Candidate& candidate); |
374 void OnChannelRouteChange(TransportChannel* channel, | 390 void OnChannelRouteChange(TransportChannel* channel, |
375 const Candidate& remote_candidate); | 391 const Candidate& remote_candidate); |
(...skipping 10 matching lines...) Expand all Loading... | |
386 // particular thread (s = signaling, w = worker). The above methods post or | 402 // particular thread (s = signaling, w = worker). The above methods post or |
387 // send a message to invoke this version. | 403 // send a message to invoke this version. |
388 TransportChannelImpl* CreateChannel_w(int component); | 404 TransportChannelImpl* CreateChannel_w(int component); |
389 void DestroyChannel_w(int component); | 405 void DestroyChannel_w(int component); |
390 void ConnectChannels_w(); | 406 void ConnectChannels_w(); |
391 void ResetChannels_w(); | 407 void ResetChannels_w(); |
392 void DestroyAllChannels_w(); | 408 void DestroyAllChannels_w(); |
393 void OnRemoteCandidate_w(const Candidate& candidate); | 409 void OnRemoteCandidate_w(const Candidate& candidate); |
394 void OnChannelReadableState_s(); | 410 void OnChannelReadableState_s(); |
395 void OnChannelWritableState_s(); | 411 void OnChannelWritableState_s(); |
412 void OnChannelFlakyState_s(); | |
396 void OnChannelRequestSignaling_s(); | 413 void OnChannelRequestSignaling_s(); |
397 void OnConnecting_s(); | 414 void OnConnecting_s(); |
398 void OnChannelRouteChange_s(const TransportChannel* channel, | 415 void OnChannelRouteChange_s(const TransportChannel* channel, |
399 const Candidate& remote_candidate); | 416 const Candidate& remote_candidate); |
400 void OnChannelCandidatesAllocationDone_s(); | 417 void OnChannelCandidatesAllocationDone_s(); |
401 | 418 |
402 // Helper function that invokes the given function on every channel. | 419 // Helper function that invokes the given function on every channel. |
403 typedef void (TransportChannelImpl::* TransportChannelFunc)(); | 420 typedef void (TransportChannelImpl::* TransportChannelFunc)(); |
404 void CallChannels_w(TransportChannelFunc func); | 421 void CallChannels_w(TransportChannelFunc func); |
405 | 422 |
406 // Computes the OR of the channel's read or write state (argument picks). | 423 // Computes the AND and OR of the channel's read/write/flaky state |
407 TransportState GetTransportState_s(bool read); | 424 // (argument picks the operation). |
425 TransportState GetTransportState_s(TransportStateType type); | |
408 | 426 |
409 void OnChannelCandidateReady_s(); | 427 void OnChannelCandidateReady_s(); |
410 | 428 |
411 void SetIceRole_w(IceRole role); | 429 void SetIceRole_w(IceRole role); |
412 void SetRemoteIceMode_w(IceMode mode); | 430 void SetRemoteIceMode_w(IceMode mode); |
413 bool SetLocalTransportDescription_w(const TransportDescription& desc, | 431 bool SetLocalTransportDescription_w(const TransportDescription& desc, |
414 ContentAction action, | 432 ContentAction action, |
415 std::string* error_desc); | 433 std::string* error_desc); |
416 bool SetRemoteTransportDescription_w(const TransportDescription& desc, | 434 bool SetRemoteTransportDescription_w(const TransportDescription& desc, |
417 ContentAction action, | 435 ContentAction action, |
418 std::string* error_desc); | 436 std::string* error_desc); |
419 bool GetStats_w(TransportStats* infos); | 437 bool GetStats_w(TransportStats* infos); |
420 bool GetRemoteCertificate_w(rtc::SSLCertificate** cert); | 438 bool GetRemoteCertificate_w(rtc::SSLCertificate** cert); |
421 | 439 |
422 // Sends SignalCompleted if we are now in that state. | 440 // Sends SignalCompleted if we are now in that state. |
423 void MaybeCompleted_w(); | 441 void MaybeCompleted_w(); |
424 | 442 |
425 rtc::Thread* const signaling_thread_; | 443 rtc::Thread* const signaling_thread_; |
426 rtc::Thread* const worker_thread_; | 444 rtc::Thread* const worker_thread_; |
427 const std::string content_name_; | 445 const std::string content_name_; |
428 const std::string type_; | 446 const std::string type_; |
429 PortAllocator* const allocator_; | 447 PortAllocator* const allocator_; |
430 bool destroyed_; | 448 bool destroyed_; |
431 TransportState readable_; | 449 TransportState readable_; |
432 TransportState writable_; | 450 TransportState writable_; |
451 TransportState flaky_; | |
pthatcher1
2015/06/26 19:24:03
receiving_;
honghaiz3
2015/08/05 23:56:57
Done.
| |
433 bool was_writable_; | 452 bool was_writable_; |
434 bool connect_requested_; | 453 bool connect_requested_; |
435 IceRole ice_role_; | 454 IceRole ice_role_; |
436 uint64 tiebreaker_; | 455 uint64 tiebreaker_; |
437 TransportProtocol protocol_; | 456 TransportProtocol protocol_; |
438 IceMode remote_ice_mode_; | 457 IceMode remote_ice_mode_; |
439 rtc::scoped_ptr<TransportDescription> local_description_; | 458 rtc::scoped_ptr<TransportDescription> local_description_; |
440 rtc::scoped_ptr<TransportDescription> remote_description_; | 459 rtc::scoped_ptr<TransportDescription> remote_description_; |
441 | 460 |
442 // TODO(tommi): Make sure we only use this on the worker thread. | 461 // TODO(tommi): Make sure we only use this on the worker thread. |
443 ChannelMap channels_; | 462 ChannelMap channels_; |
444 // Buffers the ready_candidates so that SignalCanidatesReady can | 463 // Buffers the ready_candidates so that SignalCanidatesReady can |
445 // provide them in multiples. | 464 // provide them in multiples. |
446 std::vector<Candidate> ready_candidates_; | 465 std::vector<Candidate> ready_candidates_; |
447 // Protects changes to channels and messages | 466 // Protects changes to channels and messages |
448 rtc::CriticalSection crit_; | 467 rtc::CriticalSection crit_; |
449 | 468 |
450 DISALLOW_COPY_AND_ASSIGN(Transport); | 469 DISALLOW_COPY_AND_ASSIGN(Transport); |
451 }; | 470 }; |
452 | 471 |
453 // Extract a TransportProtocol from a TransportDescription. | 472 // Extract a TransportProtocol from a TransportDescription. |
454 TransportProtocol TransportProtocolFromDescription( | 473 TransportProtocol TransportProtocolFromDescription( |
455 const TransportDescription* desc); | 474 const TransportDescription* desc); |
456 | 475 |
457 } // namespace cricket | 476 } // namespace cricket |
458 | 477 |
459 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ | 478 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ |
OLD | NEW |