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 17 matching lines...) Expand all Loading... |
28 MSG_READSTATE, | 28 MSG_READSTATE, |
29 MSG_WRITESTATE, | 29 MSG_WRITESTATE, |
30 MSG_REQUESTSIGNALING, | 30 MSG_REQUESTSIGNALING, |
31 MSG_CANDIDATEREADY, | 31 MSG_CANDIDATEREADY, |
32 MSG_ROUTECHANGE, | 32 MSG_ROUTECHANGE, |
33 MSG_CONNECTING, | 33 MSG_CONNECTING, |
34 MSG_CANDIDATEALLOCATIONCOMPLETE, | 34 MSG_CANDIDATEALLOCATIONCOMPLETE, |
35 MSG_ROLECONFLICT, | 35 MSG_ROLECONFLICT, |
36 MSG_COMPLETED, | 36 MSG_COMPLETED, |
37 MSG_FAILED, | 37 MSG_FAILED, |
| 38 MSG_RECEIVINGSTATE, |
38 }; | 39 }; |
39 | 40 |
40 struct ChannelParams : public rtc::MessageData { | 41 struct ChannelParams : public rtc::MessageData { |
41 ChannelParams() : channel(NULL), candidate(NULL) {} | 42 ChannelParams() : channel(NULL), candidate(NULL) {} |
42 explicit ChannelParams(int component) | 43 explicit ChannelParams(int component) |
43 : component(component), channel(NULL), candidate(NULL) {} | 44 : component(component), channel(NULL), candidate(NULL) {} |
44 explicit ChannelParams(Candidate* candidate) | 45 explicit ChannelParams(Candidate* candidate) |
45 : channel(NULL), candidate(candidate) { | 46 : channel(NULL), candidate(candidate) { |
46 } | 47 } |
47 | 48 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const std::string& type, | 122 const std::string& type, |
122 PortAllocator* allocator) | 123 PortAllocator* allocator) |
123 : signaling_thread_(signaling_thread), | 124 : signaling_thread_(signaling_thread), |
124 worker_thread_(worker_thread), | 125 worker_thread_(worker_thread), |
125 content_name_(content_name), | 126 content_name_(content_name), |
126 type_(type), | 127 type_(type), |
127 allocator_(allocator), | 128 allocator_(allocator), |
128 destroyed_(false), | 129 destroyed_(false), |
129 readable_(TRANSPORT_STATE_NONE), | 130 readable_(TRANSPORT_STATE_NONE), |
130 writable_(TRANSPORT_STATE_NONE), | 131 writable_(TRANSPORT_STATE_NONE), |
| 132 receiving_(TRANSPORT_STATE_NONE), |
131 was_writable_(false), | 133 was_writable_(false), |
132 connect_requested_(false), | 134 connect_requested_(false), |
133 ice_role_(ICEROLE_UNKNOWN), | 135 ice_role_(ICEROLE_UNKNOWN), |
134 tiebreaker_(0), | 136 tiebreaker_(0), |
135 protocol_(ICEPROTO_HYBRID), | 137 protocol_(ICEPROTO_HYBRID), |
136 remote_ice_mode_(ICEMODE_FULL) { | 138 remote_ice_mode_(ICEMODE_FULL) { |
137 } | 139 } |
138 | 140 |
139 Transport::~Transport() { | 141 Transport::~Transport() { |
140 ASSERT(signaling_thread_->IsCurrent()); | 142 ASSERT(signaling_thread_->IsCurrent()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // below Apply**Description_w calls can fail. | 237 // below Apply**Description_w calls can fail. |
236 if (local_description_) | 238 if (local_description_) |
237 ApplyLocalTransportDescription_w(impl, NULL); | 239 ApplyLocalTransportDescription_w(impl, NULL); |
238 if (remote_description_) | 240 if (remote_description_) |
239 ApplyRemoteTransportDescription_w(impl, NULL); | 241 ApplyRemoteTransportDescription_w(impl, NULL); |
240 if (local_description_ && remote_description_) | 242 if (local_description_ && remote_description_) |
241 ApplyNegotiatedTransportDescription_w(impl, NULL); | 243 ApplyNegotiatedTransportDescription_w(impl, NULL); |
242 | 244 |
243 impl->SignalReadableState.connect(this, &Transport::OnChannelReadableState); | 245 impl->SignalReadableState.connect(this, &Transport::OnChannelReadableState); |
244 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState); | 246 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState); |
| 247 impl->SignalReceivingState.connect(this, &Transport::OnChannelReceivingState); |
245 impl->SignalRequestSignaling.connect( | 248 impl->SignalRequestSignaling.connect( |
246 this, &Transport::OnChannelRequestSignaling); | 249 this, &Transport::OnChannelRequestSignaling); |
247 impl->SignalCandidateReady.connect(this, &Transport::OnChannelCandidateReady); | 250 impl->SignalCandidateReady.connect(this, &Transport::OnChannelCandidateReady); |
248 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange); | 251 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange); |
249 impl->SignalCandidatesAllocationDone.connect( | 252 impl->SignalCandidatesAllocationDone.connect( |
250 this, &Transport::OnChannelCandidatesAllocationDone); | 253 this, &Transport::OnChannelCandidatesAllocationDone); |
251 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict); | 254 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict); |
252 impl->SignalConnectionRemoved.connect( | 255 impl->SignalConnectionRemoved.connect( |
253 this, &Transport::OnChannelConnectionRemoved); | 256 this, &Transport::OnChannelConnectionRemoved); |
254 | 257 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 497 } |
495 } | 498 } |
496 | 499 |
497 void Transport::OnChannelReadableState(TransportChannel* channel) { | 500 void Transport::OnChannelReadableState(TransportChannel* channel) { |
498 ASSERT(worker_thread()->IsCurrent()); | 501 ASSERT(worker_thread()->IsCurrent()); |
499 signaling_thread()->Post(this, MSG_READSTATE, NULL); | 502 signaling_thread()->Post(this, MSG_READSTATE, NULL); |
500 } | 503 } |
501 | 504 |
502 void Transport::OnChannelReadableState_s() { | 505 void Transport::OnChannelReadableState_s() { |
503 ASSERT(signaling_thread()->IsCurrent()); | 506 ASSERT(signaling_thread()->IsCurrent()); |
504 TransportState readable = GetTransportState_s(true); | 507 TransportState readable = GetTransportState_s(TRANSPORT_READABLE_STATE); |
505 if (readable_ != readable) { | 508 if (readable_ != readable) { |
506 readable_ = readable; | 509 readable_ = readable; |
507 SignalReadableState(this); | 510 SignalReadableState(this); |
508 } | 511 } |
509 } | 512 } |
510 | 513 |
511 void Transport::OnChannelWritableState(TransportChannel* channel) { | 514 void Transport::OnChannelWritableState(TransportChannel* channel) { |
512 ASSERT(worker_thread()->IsCurrent()); | 515 ASSERT(worker_thread()->IsCurrent()); |
513 signaling_thread()->Post(this, MSG_WRITESTATE, NULL); | 516 signaling_thread()->Post(this, MSG_WRITESTATE, NULL); |
514 | 517 |
515 MaybeCompleted_w(); | 518 MaybeCompleted_w(); |
516 } | 519 } |
517 | 520 |
518 void Transport::OnChannelWritableState_s() { | 521 void Transport::OnChannelWritableState_s() { |
519 ASSERT(signaling_thread()->IsCurrent()); | 522 ASSERT(signaling_thread()->IsCurrent()); |
520 TransportState writable = GetTransportState_s(false); | 523 TransportState writable = GetTransportState_s(TRANSPORT_WRITABLE_STATE); |
521 if (writable_ != writable) { | 524 if (writable_ != writable) { |
522 was_writable_ = (writable_ == TRANSPORT_STATE_ALL); | 525 was_writable_ = (writable_ == TRANSPORT_STATE_ALL); |
523 writable_ = writable; | 526 writable_ = writable; |
524 SignalWritableState(this); | 527 SignalWritableState(this); |
525 } | 528 } |
526 } | 529 } |
527 | 530 |
528 TransportState Transport::GetTransportState_s(bool read) { | 531 void Transport::OnChannelReceivingState(TransportChannel* channel) { |
| 532 ASSERT(worker_thread()->IsCurrent()); |
| 533 signaling_thread()->Post(this, MSG_RECEIVINGSTATE); |
| 534 } |
| 535 |
| 536 void Transport::OnChannelReceivingState_s() { |
| 537 ASSERT(signaling_thread()->IsCurrent()); |
| 538 TransportState receiving = GetTransportState_s(TRANSPORT_RECEIVING_STATE); |
| 539 if (receiving_ != receiving) { |
| 540 receiving_ = receiving; |
| 541 SignalReceivingState(this); |
| 542 } |
| 543 } |
| 544 |
| 545 TransportState Transport::GetTransportState_s(TransportStateType state_type) { |
529 ASSERT(signaling_thread()->IsCurrent()); | 546 ASSERT(signaling_thread()->IsCurrent()); |
530 | 547 |
531 rtc::CritScope cs(&crit_); | 548 rtc::CritScope cs(&crit_); |
532 bool any = false; | 549 bool any = false; |
533 bool all = !channels_.empty(); | 550 bool all = !channels_.empty(); |
534 for (const auto iter : channels_) { | 551 for (const auto iter : channels_) { |
535 bool b = (read ? iter.second->readable() : | 552 bool b = false; |
536 iter.second->writable()); | 553 switch (state_type) { |
| 554 case TRANSPORT_READABLE_STATE: |
| 555 b = iter.second->readable(); |
| 556 break; |
| 557 case TRANSPORT_WRITABLE_STATE: |
| 558 b = iter.second->writable(); |
| 559 break; |
| 560 case TRANSPORT_RECEIVING_STATE: |
| 561 b = iter.second->receiving(); |
| 562 break; |
| 563 default: |
| 564 ASSERT(false); |
| 565 } |
537 any |= b; | 566 any |= b; |
538 all &= b; | 567 all &= b; |
539 } | 568 } |
540 | 569 |
541 if (all) { | 570 if (all) { |
542 return TRANSPORT_STATE_ALL; | 571 return TRANSPORT_STATE_ALL; |
543 } else if (any) { | 572 } else if (any) { |
544 return TRANSPORT_STATE_SOME; | 573 return TRANSPORT_STATE_SOME; |
545 } | 574 } |
546 | 575 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 break; | 922 break; |
894 case MSG_CONNECTING: | 923 case MSG_CONNECTING: |
895 OnConnecting_s(); | 924 OnConnecting_s(); |
896 break; | 925 break; |
897 case MSG_READSTATE: | 926 case MSG_READSTATE: |
898 OnChannelReadableState_s(); | 927 OnChannelReadableState_s(); |
899 break; | 928 break; |
900 case MSG_WRITESTATE: | 929 case MSG_WRITESTATE: |
901 OnChannelWritableState_s(); | 930 OnChannelWritableState_s(); |
902 break; | 931 break; |
| 932 case MSG_RECEIVINGSTATE: |
| 933 OnChannelReceivingState_s(); |
| 934 break; |
903 case MSG_REQUESTSIGNALING: | 935 case MSG_REQUESTSIGNALING: |
904 OnChannelRequestSignaling_s(); | 936 OnChannelRequestSignaling_s(); |
905 break; | 937 break; |
906 case MSG_CANDIDATEREADY: | 938 case MSG_CANDIDATEREADY: |
907 OnChannelCandidateReady_s(); | 939 OnChannelCandidateReady_s(); |
908 break; | 940 break; |
909 case MSG_ROUTECHANGE: { | 941 case MSG_ROUTECHANGE: { |
910 ChannelParams* params = static_cast<ChannelParams*>(msg->pdata); | 942 ChannelParams* params = static_cast<ChannelParams*>(msg->pdata); |
911 OnChannelRouteChange_s(params->channel, *params->candidate); | 943 OnChannelRouteChange_s(params->channel, *params->candidate); |
912 delete params; | 944 delete params; |
(...skipping 20 matching lines...) Expand all Loading... |
933 const TransportDescription* desc) { | 965 const TransportDescription* desc) { |
934 ASSERT(desc != NULL); | 966 ASSERT(desc != NULL); |
935 if (desc->transport_type == NS_JINGLE_ICE_UDP) { | 967 if (desc->transport_type == NS_JINGLE_ICE_UDP) { |
936 return (desc->HasOption(ICE_OPTION_GICE)) ? | 968 return (desc->HasOption(ICE_OPTION_GICE)) ? |
937 ICEPROTO_HYBRID : ICEPROTO_RFC5245; | 969 ICEPROTO_HYBRID : ICEPROTO_RFC5245; |
938 } | 970 } |
939 return ICEPROTO_GOOGLE; | 971 return ICEPROTO_GOOGLE; |
940 } | 972 } |
941 | 973 |
942 } // namespace cricket | 974 } // namespace cricket |
OLD | NEW |