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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 Transport::Transport(rtc::Thread* signaling_thread, | 100 Transport::Transport(rtc::Thread* signaling_thread, |
101 rtc::Thread* worker_thread, | 101 rtc::Thread* worker_thread, |
102 const std::string& content_name, | 102 const std::string& content_name, |
103 PortAllocator* allocator) | 103 PortAllocator* allocator) |
104 : signaling_thread_(signaling_thread), | 104 : signaling_thread_(signaling_thread), |
105 worker_thread_(worker_thread), | 105 worker_thread_(worker_thread), |
106 content_name_(content_name), | 106 content_name_(content_name), |
107 allocator_(allocator), | 107 allocator_(allocator), |
108 destroyed_(false), | 108 destroyed_(false), |
109 readable_(TRANSPORT_STATE_NONE), | |
110 writable_(TRANSPORT_STATE_NONE), | 109 writable_(TRANSPORT_STATE_NONE), |
111 receiving_(TRANSPORT_STATE_NONE), | 110 receiving_(TRANSPORT_STATE_NONE), |
112 was_writable_(false), | 111 was_writable_(false), |
113 connect_requested_(false), | 112 connect_requested_(false), |
114 ice_role_(ICEROLE_UNKNOWN), | 113 ice_role_(ICEROLE_UNKNOWN), |
115 tiebreaker_(0), | 114 tiebreaker_(0), |
116 remote_ice_mode_(ICEMODE_FULL), | 115 remote_ice_mode_(ICEMODE_FULL), |
117 channel_receiving_timeout_(-1) { | 116 channel_receiving_timeout_(-1) { |
118 } | 117 } |
119 | 118 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 impl->SetReceivingTimeout(channel_receiving_timeout_); | 230 impl->SetReceivingTimeout(channel_receiving_timeout_); |
232 // TODO(ronghuawu): Change CreateChannel_w to be able to return error since | 231 // TODO(ronghuawu): Change CreateChannel_w to be able to return error since |
233 // below Apply**Description_w calls can fail. | 232 // below Apply**Description_w calls can fail. |
234 if (local_description_) | 233 if (local_description_) |
235 ApplyLocalTransportDescription_w(impl, NULL); | 234 ApplyLocalTransportDescription_w(impl, NULL); |
236 if (remote_description_) | 235 if (remote_description_) |
237 ApplyRemoteTransportDescription_w(impl, NULL); | 236 ApplyRemoteTransportDescription_w(impl, NULL); |
238 if (local_description_ && remote_description_) | 237 if (local_description_ && remote_description_) |
239 ApplyNegotiatedTransportDescription_w(impl, NULL); | 238 ApplyNegotiatedTransportDescription_w(impl, NULL); |
240 | 239 |
241 impl->SignalReadableState.connect(this, &Transport::OnChannelReadableState); | |
242 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState); | 240 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState); |
243 impl->SignalReceivingState.connect(this, &Transport::OnChannelReceivingState); | 241 impl->SignalReceivingState.connect(this, &Transport::OnChannelReceivingState); |
244 impl->SignalRequestSignaling.connect( | 242 impl->SignalRequestSignaling.connect( |
245 this, &Transport::OnChannelRequestSignaling); | 243 this, &Transport::OnChannelRequestSignaling); |
246 impl->SignalCandidateReady.connect(this, &Transport::OnChannelCandidateReady); | 244 impl->SignalCandidateReady.connect(this, &Transport::OnChannelCandidateReady); |
247 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange); | 245 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange); |
248 impl->SignalCandidatesAllocationDone.connect( | 246 impl->SignalCandidatesAllocationDone.connect( |
249 this, &Transport::OnChannelCandidatesAllocationDone); | 247 this, &Transport::OnChannelCandidatesAllocationDone); |
250 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict); | 248 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict); |
251 impl->SignalConnectionRemoved.connect( | 249 impl->SignalConnectionRemoved.connect( |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 484 |
487 void Transport::OnRemoteCandidate_w(const Candidate& candidate) { | 485 void Transport::OnRemoteCandidate_w(const Candidate& candidate) { |
488 ASSERT(worker_thread()->IsCurrent()); | 486 ASSERT(worker_thread()->IsCurrent()); |
489 ChannelMap::iterator iter = channels_.find(candidate.component()); | 487 ChannelMap::iterator iter = channels_.find(candidate.component()); |
490 // It's ok for a channel to go away while this message is in transit. | 488 // It's ok for a channel to go away while this message is in transit. |
491 if (iter != channels_.end()) { | 489 if (iter != channels_.end()) { |
492 iter->second->OnCandidate(candidate); | 490 iter->second->OnCandidate(candidate); |
493 } | 491 } |
494 } | 492 } |
495 | 493 |
496 void Transport::OnChannelReadableState(TransportChannel* channel) { | |
497 ASSERT(worker_thread()->IsCurrent()); | |
498 signaling_thread()->Post(this, MSG_READSTATE, NULL); | |
499 } | |
500 | |
501 void Transport::OnChannelReadableState_s() { | |
502 ASSERT(signaling_thread()->IsCurrent()); | |
503 TransportState readable = GetTransportState_s(TRANSPORT_READABLE_STATE); | |
504 if (readable_ != readable) { | |
505 readable_ = readable; | |
506 SignalReadableState(this); | |
507 } | |
508 } | |
509 | |
510 void Transport::OnChannelWritableState(TransportChannel* channel) { | 494 void Transport::OnChannelWritableState(TransportChannel* channel) { |
511 ASSERT(worker_thread()->IsCurrent()); | 495 ASSERT(worker_thread()->IsCurrent()); |
512 signaling_thread()->Post(this, MSG_WRITESTATE, NULL); | 496 signaling_thread()->Post(this, MSG_WRITESTATE, NULL); |
513 | 497 |
514 MaybeCompleted_w(); | 498 MaybeCompleted_w(); |
515 } | 499 } |
516 | 500 |
517 void Transport::OnChannelWritableState_s() { | 501 void Transport::OnChannelWritableState_s() { |
518 ASSERT(signaling_thread()->IsCurrent()); | 502 ASSERT(signaling_thread()->IsCurrent()); |
519 TransportState writable = GetTransportState_s(TRANSPORT_WRITABLE_STATE); | 503 TransportState writable = GetTransportState_s(TRANSPORT_WRITABLE_STATE); |
(...skipping 20 matching lines...) Expand all Loading... |
540 | 524 |
541 TransportState Transport::GetTransportState_s(TransportStateType state_type) { | 525 TransportState Transport::GetTransportState_s(TransportStateType state_type) { |
542 ASSERT(signaling_thread()->IsCurrent()); | 526 ASSERT(signaling_thread()->IsCurrent()); |
543 | 527 |
544 rtc::CritScope cs(&crit_); | 528 rtc::CritScope cs(&crit_); |
545 bool any = false; | 529 bool any = false; |
546 bool all = !channels_.empty(); | 530 bool all = !channels_.empty(); |
547 for (const auto iter : channels_) { | 531 for (const auto iter : channels_) { |
548 bool b = false; | 532 bool b = false; |
549 switch (state_type) { | 533 switch (state_type) { |
550 case TRANSPORT_READABLE_STATE: | |
551 b = iter.second->readable(); | |
552 break; | |
553 case TRANSPORT_WRITABLE_STATE: | 534 case TRANSPORT_WRITABLE_STATE: |
554 b = iter.second->writable(); | 535 b = iter.second->writable(); |
555 break; | 536 break; |
556 case TRANSPORT_RECEIVING_STATE: | 537 case TRANSPORT_RECEIVING_STATE: |
557 b = iter.second->receiving(); | 538 b = iter.second->receiving(); |
558 break; | 539 break; |
559 default: | 540 default: |
560 ASSERT(false); | 541 ASSERT(false); |
561 } | 542 } |
562 any |= b; | 543 any |= b; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 break; | 844 break; |
864 case MSG_ONREMOTECANDIDATE: { | 845 case MSG_ONREMOTECANDIDATE: { |
865 ChannelParams* params = static_cast<ChannelParams*>(msg->pdata); | 846 ChannelParams* params = static_cast<ChannelParams*>(msg->pdata); |
866 OnRemoteCandidate_w(*params->candidate); | 847 OnRemoteCandidate_w(*params->candidate); |
867 delete params; | 848 delete params; |
868 } | 849 } |
869 break; | 850 break; |
870 case MSG_CONNECTING: | 851 case MSG_CONNECTING: |
871 OnConnecting_s(); | 852 OnConnecting_s(); |
872 break; | 853 break; |
873 case MSG_READSTATE: | |
874 OnChannelReadableState_s(); | |
875 break; | |
876 case MSG_WRITESTATE: | 854 case MSG_WRITESTATE: |
877 OnChannelWritableState_s(); | 855 OnChannelWritableState_s(); |
878 break; | 856 break; |
879 case MSG_RECEIVINGSTATE: | 857 case MSG_RECEIVINGSTATE: |
880 OnChannelReceivingState_s(); | 858 OnChannelReceivingState_s(); |
881 break; | 859 break; |
882 case MSG_REQUESTSIGNALING: | 860 case MSG_REQUESTSIGNALING: |
883 OnChannelRequestSignaling_s(); | 861 OnChannelRequestSignaling_s(); |
884 break; | 862 break; |
885 case MSG_CANDIDATEREADY: | 863 case MSG_CANDIDATEREADY: |
(...skipping 14 matching lines...) Expand all Loading... |
900 case MSG_COMPLETED: | 878 case MSG_COMPLETED: |
901 SignalCompleted(this); | 879 SignalCompleted(this); |
902 break; | 880 break; |
903 case MSG_FAILED: | 881 case MSG_FAILED: |
904 SignalFailed(this); | 882 SignalFailed(this); |
905 break; | 883 break; |
906 } | 884 } |
907 } | 885 } |
908 | 886 |
909 } // namespace cricket | 887 } // namespace cricket |
OLD | NEW |