| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 impl->SetReceivingTimeout(channel_receiving_timeout_); | 233 impl->SetReceivingTimeout(channel_receiving_timeout_); |
| 234 // TODO(ronghuawu): Change CreateChannel to be able to return error since | 234 // TODO(ronghuawu): Change CreateChannel to be able to return error since |
| 235 // below Apply**Description calls can fail. | 235 // below Apply**Description calls can fail. |
| 236 if (local_description_) | 236 if (local_description_) |
| 237 ApplyLocalTransportDescription(impl, NULL); | 237 ApplyLocalTransportDescription(impl, NULL); |
| 238 if (remote_description_) | 238 if (remote_description_) |
| 239 ApplyRemoteTransportDescription(impl, NULL); | 239 ApplyRemoteTransportDescription(impl, NULL); |
| 240 if (local_description_ && remote_description_) | 240 if (local_description_ && remote_description_) |
| 241 ApplyNegotiatedTransportDescription(impl, NULL); | 241 ApplyNegotiatedTransportDescription(impl, NULL); |
| 242 | 242 |
| 243 impl->SignalReadableState.connect(this, &Transport::OnChannelReadableState); | |
| 244 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState); | 243 impl->SignalWritableState.connect(this, &Transport::OnChannelWritableState); |
| 245 impl->SignalReceivingState.connect(this, &Transport::OnChannelReceivingState); | 244 impl->SignalReceivingState.connect(this, &Transport::OnChannelReceivingState); |
| 246 impl->SignalGatheringState.connect(this, &Transport::OnChannelGatheringState); | 245 impl->SignalGatheringState.connect(this, &Transport::OnChannelGatheringState); |
| 247 impl->SignalCandidateGathered.connect(this, | 246 impl->SignalCandidateGathered.connect(this, |
| 248 &Transport::OnChannelCandidateGathered); | 247 &Transport::OnChannelCandidateGathered); |
| 249 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange); | 248 impl->SignalRouteChange.connect(this, &Transport::OnChannelRouteChange); |
| 250 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict); | 249 impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict); |
| 251 impl->SignalConnectionRemoved.connect( | 250 impl->SignalConnectionRemoved.connect( |
| 252 this, &Transport::OnChannelConnectionRemoved); | 251 this, &Transport::OnChannelConnectionRemoved); |
| 253 | 252 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 285 |
| 287 if (connect_requested_ && channels_.empty()) { | 286 if (connect_requested_ && channels_.empty()) { |
| 288 // We're no longer attempting to connect. | 287 // We're no longer attempting to connect. |
| 289 SignalConnecting(this); | 288 SignalConnecting(this); |
| 290 } | 289 } |
| 291 | 290 |
| 292 if (impl) { | 291 if (impl) { |
| 293 DestroyTransportChannel(impl); | 292 DestroyTransportChannel(impl); |
| 294 // Need to update aggregate state after destroying a channel, | 293 // Need to update aggregate state after destroying a channel, |
| 295 // for example if it was the only one that wasn't yet writable. | 294 // for example if it was the only one that wasn't yet writable. |
| 296 UpdateReadableState(); | |
| 297 UpdateWritableState(); | 295 UpdateWritableState(); |
| 298 UpdateReceivingState(); | 296 UpdateReceivingState(); |
| 299 UpdateGatheringState(); | 297 UpdateGatheringState(); |
| 300 MaybeSignalCompleted(); | 298 MaybeSignalCompleted(); |
| 301 } | 299 } |
| 302 } | 300 } |
| 303 | 301 |
| 304 void Transport::ConnectChannels() { | 302 void Transport::ConnectChannels() { |
| 305 if (connect_requested_ || channels_.empty()) | 303 if (connect_requested_ || channels_.empty()) |
| 306 return; | 304 return; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 iter != candidates.end(); | 422 iter != candidates.end(); |
| 425 ++iter) { | 423 ++iter) { |
| 426 TransportChannelImpl* channel = GetChannel(iter->component()); | 424 TransportChannelImpl* channel = GetChannel(iter->component()); |
| 427 if (channel != NULL) { | 425 if (channel != NULL) { |
| 428 channel->AddRemoteCandidate(*iter); | 426 channel->AddRemoteCandidate(*iter); |
| 429 } | 427 } |
| 430 } | 428 } |
| 431 return true; | 429 return true; |
| 432 } | 430 } |
| 433 | 431 |
| 434 void Transport::OnChannelReadableState(TransportChannel* channel) { | |
| 435 UpdateReadableState(); | |
| 436 } | |
| 437 | |
| 438 void Transport::OnChannelWritableState(TransportChannel* channel) { | 432 void Transport::OnChannelWritableState(TransportChannel* channel) { |
| 439 LOG(LS_INFO) << name() << " TransportChannel " << channel->component() | 433 LOG(LS_INFO) << name() << " TransportChannel " << channel->component() |
| 440 << " writability changed to " << channel->writable() | 434 << " writability changed to " << channel->writable() |
| 441 << ". Check if transport is complete."; | 435 << ". Check if transport is complete."; |
| 442 UpdateWritableState(); | 436 UpdateWritableState(); |
| 443 MaybeSignalCompleted(); | 437 MaybeSignalCompleted(); |
| 444 } | 438 } |
| 445 | 439 |
| 446 void Transport::OnChannelReceivingState(TransportChannel* channel) { | 440 void Transport::OnChannelReceivingState(TransportChannel* channel) { |
| 447 UpdateReceivingState(); | 441 UpdateReceivingState(); |
| 448 } | 442 } |
| 449 | 443 |
| 450 TransportState Transport::GetTransportState(TransportStateType state_type) { | 444 TransportState Transport::GetTransportState(TransportStateType state_type) { |
| 451 bool any = false; | 445 bool any = false; |
| 452 bool all = !channels_.empty(); | 446 bool all = !channels_.empty(); |
| 453 for (const auto iter : channels_) { | 447 for (const auto iter : channels_) { |
| 454 bool b = false; | 448 bool b = false; |
| 455 switch (state_type) { | 449 switch (state_type) { |
| 456 case TRANSPORT_READABLE_STATE: | |
| 457 b = iter.second->readable(); | |
| 458 break; | |
| 459 case TRANSPORT_WRITABLE_STATE: | 450 case TRANSPORT_WRITABLE_STATE: |
| 460 b = iter.second->writable(); | 451 b = iter.second->writable(); |
| 461 break; | 452 break; |
| 462 case TRANSPORT_RECEIVING_STATE: | 453 case TRANSPORT_RECEIVING_STATE: |
| 463 b = iter.second->receiving(); | 454 b = iter.second->receiving(); |
| 464 break; | 455 break; |
| 465 default: | 456 default: |
| 466 ASSERT(false); | 457 ASSERT(false); |
| 467 } | 458 } |
| 468 any |= b; | 459 any |= b; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 TransportState writable = GetTransportState(TRANSPORT_WRITABLE_STATE); | 579 TransportState writable = GetTransportState(TRANSPORT_WRITABLE_STATE); |
| 589 LOG(LS_INFO) << name() << " transport writable state changed? " << writable_ | 580 LOG(LS_INFO) << name() << " transport writable state changed? " << writable_ |
| 590 << " => " << writable; | 581 << " => " << writable; |
| 591 if (writable_ != writable) { | 582 if (writable_ != writable) { |
| 592 was_writable_ = (writable_ == TRANSPORT_STATE_ALL); | 583 was_writable_ = (writable_ == TRANSPORT_STATE_ALL); |
| 593 writable_ = writable; | 584 writable_ = writable; |
| 594 SignalWritableState(this); | 585 SignalWritableState(this); |
| 595 } | 586 } |
| 596 } | 587 } |
| 597 | 588 |
| 598 void Transport::UpdateReadableState() { | |
| 599 TransportState readable = GetTransportState(TRANSPORT_READABLE_STATE); | |
| 600 if (readable_ != readable) { | |
| 601 readable_ = readable; | |
| 602 SignalReadableState(this); | |
| 603 } | |
| 604 } | |
| 605 | |
| 606 bool Transport::ApplyLocalTransportDescription(TransportChannelImpl* ch, | 589 bool Transport::ApplyLocalTransportDescription(TransportChannelImpl* ch, |
| 607 std::string* error_desc) { | 590 std::string* error_desc) { |
| 608 ch->SetIceCredentials(local_description_->ice_ufrag, | 591 ch->SetIceCredentials(local_description_->ice_ufrag, |
| 609 local_description_->ice_pwd); | 592 local_description_->ice_pwd); |
| 610 return true; | 593 return true; |
| 611 } | 594 } |
| 612 | 595 |
| 613 bool Transport::ApplyRemoteTransportDescription(TransportChannelImpl* ch, | 596 bool Transport::ApplyRemoteTransportDescription(TransportChannelImpl* ch, |
| 614 std::string* error_desc) { | 597 std::string* error_desc) { |
| 615 ch->SetRemoteIceCredentials(remote_description_->ice_ufrag, | 598 ch->SetRemoteIceCredentials(remote_description_->ice_ufrag, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 645 // creation, we have the negotiation state saved until a new | 628 // creation, we have the negotiation state saved until a new |
| 646 // negotiation happens. | 629 // negotiation happens. |
| 647 for (auto& iter : channels_) { | 630 for (auto& iter : channels_) { |
| 648 if (!ApplyNegotiatedTransportDescription(iter.second.get(), error_desc)) | 631 if (!ApplyNegotiatedTransportDescription(iter.second.get(), error_desc)) |
| 649 return false; | 632 return false; |
| 650 } | 633 } |
| 651 return true; | 634 return true; |
| 652 } | 635 } |
| 653 | 636 |
| 654 } // namespace cricket | 637 } // namespace cricket |
| OLD | NEW |