| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 } // namespace { | 39 } // namespace { |
| 40 | 40 |
| 41 namespace cricket { | 41 namespace cricket { |
| 42 | 42 |
| 43 // This class groups the DTLS and ICE channels, and helps keep track of | 43 // This class groups the DTLS and ICE channels, and helps keep track of |
| 44 // how many external objects (BaseChannels) reference each channel. | 44 // how many external objects (BaseChannels) reference each channel. |
| 45 class TransportController::ChannelPair { | 45 class TransportController::ChannelPair { |
| 46 public: | 46 public: |
| 47 // TODO(deadbeef): Change the types of |dtls| and |ice| to | 47 // TODO(deadbeef): Change the types of |dtls| and |ice| to |
| 48 // DtlsTransportChannelWrapper and P2PTransportChannelWrapper, | 48 // DtlsTransport and P2PTransportChannelWrapper, once TransportChannelImpl is |
| 49 // once TransportChannelImpl is removed. | 49 // removed. |
| 50 ChannelPair(TransportChannelImpl* dtls, IceTransportInternal* ice) | 50 ChannelPair(DtlsTransportInternal* dtls, IceTransportInternal* ice) |
| 51 : ice_(ice), dtls_(dtls) {} | 51 : ice_(ice), dtls_(dtls) {} |
| 52 | 52 |
| 53 // Currently, all ICE-related calls still go through this DTLS channel. But | 53 // Currently, all ICE-related calls still go through this DTLS channel. But |
| 54 // that will change once we get rid of TransportChannelImpl, and the DTLS | 54 // that will change once we get rid of TransportChannelImpl, and the DTLS |
| 55 // channel interface no longer includes ICE-specific methods. | 55 // channel interface no longer includes ICE-specific methods. |
| 56 const TransportChannelImpl* dtls() const { return dtls_.get(); } | 56 const DtlsTransportInternal* dtls() const { return dtls_.get(); } |
| 57 TransportChannelImpl* dtls() { return dtls_.get(); } | 57 DtlsTransportInternal* dtls() { return dtls_.get(); } |
| 58 const IceTransportInternal* ice() const { return ice_.get(); } | 58 const IceTransportInternal* ice() const { return ice_.get(); } |
| 59 IceTransportInternal* ice() { return ice_.get(); } | 59 IceTransportInternal* ice() { return ice_.get(); } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 std::unique_ptr<IceTransportInternal> ice_; | 62 std::unique_ptr<IceTransportInternal> ice_; |
| 63 std::unique_ptr<TransportChannelImpl> dtls_; | 63 std::unique_ptr<DtlsTransportInternal> dtls_; |
| 64 | 64 |
| 65 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelPair); | 65 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelPair); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 TransportController::TransportController(rtc::Thread* signaling_thread, | 68 TransportController::TransportController(rtc::Thread* signaling_thread, |
| 69 rtc::Thread* network_thread, | 69 rtc::Thread* network_thread, |
| 70 PortAllocator* port_allocator, | 70 PortAllocator* port_allocator, |
| 71 bool redetermine_role_on_ice_restart) | 71 bool redetermine_role_on_ice_restart) |
| 72 : signaling_thread_(signaling_thread), | 72 : signaling_thread_(signaling_thread), |
| 73 network_thread_(network_thread), | 73 network_thread_(network_thread), |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats)); | 220 rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void TransportController::SetMetricsObserver( | 223 void TransportController::SetMetricsObserver( |
| 224 webrtc::MetricsObserverInterface* metrics_observer) { | 224 webrtc::MetricsObserverInterface* metrics_observer) { |
| 225 return network_thread_->Invoke<void>( | 225 return network_thread_->Invoke<void>( |
| 226 RTC_FROM_HERE, rtc::Bind(&TransportController::SetMetricsObserver_n, this, | 226 RTC_FROM_HERE, rtc::Bind(&TransportController::SetMetricsObserver_n, this, |
| 227 metrics_observer)); | 227 metrics_observer)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 TransportChannel* TransportController::CreateTransportChannel( | 230 DtlsTransportInternal* TransportController::CreateDtlsTransport( |
| 231 const std::string& transport_name, | 231 const std::string& transport_name, |
| 232 int component) { | 232 int component) { |
| 233 return network_thread_->Invoke<TransportChannel*>( | 233 return network_thread_->Invoke<DtlsTransportInternal*>( |
| 234 RTC_FROM_HERE, rtc::Bind(&TransportController::CreateTransportChannel_n, | 234 RTC_FROM_HERE, rtc::Bind(&TransportController::CreateDtlsTransport_n, |
| 235 this, transport_name, component)); | 235 this, transport_name, component)); |
| 236 } | 236 } |
| 237 | 237 |
| 238 TransportChannel* TransportController::CreateTransportChannel_n( | 238 DtlsTransportInternal* TransportController::CreateDtlsTransport_n( |
| 239 const std::string& transport_name, | 239 const std::string& transport_name, |
| 240 int component) { | 240 int component) { |
| 241 RTC_DCHECK(network_thread_->IsCurrent()); | 241 RTC_DCHECK(network_thread_->IsCurrent()); |
| 242 | 242 |
| 243 RefCountedChannel* existing_channel = GetChannel_n(transport_name, component); | 243 RefCountedChannel* existing_channel = GetChannel_n(transport_name, component); |
| 244 if (existing_channel) { | 244 if (existing_channel) { |
| 245 // Channel already exists; increment reference count and return. | 245 // Channel already exists; increment reference count and return. |
| 246 existing_channel->AddRef(); | 246 existing_channel->AddRef(); |
| 247 return existing_channel->dtls(); | 247 return existing_channel->dtls(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 // Need to create a new channel. | 250 // Need to create a new channel. |
| 251 JsepTransport* transport = GetOrCreateJsepTransport(transport_name); | 251 JsepTransport* transport = GetOrCreateJsepTransport(transport_name); |
| 252 | 252 |
| 253 // Create DTLS channel wrapping ICE channel, and configure it. | 253 // Create DTLS channel wrapping ICE channel, and configure it. |
| 254 IceTransportInternal* ice = | 254 IceTransportInternal* ice = |
| 255 CreateIceTransportChannel_n(transport_name, component); | 255 CreateIceTransportChannel_n(transport_name, component); |
| 256 // TODO(deadbeef): To support QUIC, would need to create a | 256 // TODO(deadbeef): To support QUIC, would need to create a |
| 257 // QuicTransportChannel here. What is "dtls" in this file would then become | 257 // QuicTransportChannel here. What is "dtls" in this file would then become |
| 258 // "dtls or quic". | 258 // "dtls or quic". |
| 259 TransportChannelImpl* dtls = | 259 DtlsTransportInternal* dtls = |
| 260 CreateDtlsTransportChannel_n(transport_name, component, ice); | 260 CreateDtlsTransportChannel_n(transport_name, component, ice); |
| 261 dtls->SetMetricsObserver(metrics_observer_); | 261 dtls->ice_transport()->SetMetricsObserver(metrics_observer_); |
| 262 dtls->SetIceRole(ice_role_); | 262 dtls->ice_transport()->SetIceRole(ice_role_); |
| 263 dtls->SetIceTiebreaker(ice_tiebreaker_); | 263 dtls->ice_transport()->SetIceTiebreaker(ice_tiebreaker_); |
| 264 dtls->SetIceConfig(ice_config_); | 264 dtls->ice_transport()->SetIceConfig(ice_config_); |
| 265 if (certificate_) { | 265 if (certificate_) { |
| 266 bool set_cert_success = dtls->SetLocalCertificate(certificate_); | 266 bool set_cert_success = dtls->SetLocalCertificate(certificate_); |
| 267 RTC_DCHECK(set_cert_success); | 267 RTC_DCHECK(set_cert_success); |
| 268 } | 268 } |
| 269 | 269 |
| 270 // Connect to signals offered by the channels. Currently, the DTLS channel | 270 // Connect to signals offered by the channels. Currently, the DTLS channel |
| 271 // forwards signals from the ICE channel, so we only need to connect to the | 271 // forwards signals from the ICE channel, so we only need to connect to the |
| 272 // DTLS channel. In the future this won't be the case. | 272 // DTLS channel. In the future this won't be the case. |
| 273 dtls->SignalWritableState.connect( | 273 dtls->SignalWritableState.connect( |
| 274 this, &TransportController::OnChannelWritableState_n); | 274 this, &TransportController::OnChannelWritableState_n); |
| 275 dtls->SignalReceivingState.connect( | 275 dtls->SignalReceivingState.connect( |
| 276 this, &TransportController::OnChannelReceivingState_n); | 276 this, &TransportController::OnChannelReceivingState_n); |
| 277 dtls->SignalGatheringState.connect( | |
| 278 this, &TransportController::OnChannelGatheringState_n); | |
| 279 dtls->SignalCandidateGathered.connect( | |
| 280 this, &TransportController::OnChannelCandidateGathered_n); | |
| 281 dtls->SignalCandidatesRemoved.connect( | |
| 282 this, &TransportController::OnChannelCandidatesRemoved_n); | |
| 283 dtls->SignalRoleConflict.connect( | |
| 284 this, &TransportController::OnChannelRoleConflict_n); | |
| 285 dtls->SignalStateChanged.connect( | |
| 286 this, &TransportController::OnChannelStateChanged_n); | |
| 287 dtls->SignalDtlsHandshakeError.connect( | 277 dtls->SignalDtlsHandshakeError.connect( |
| 288 this, &TransportController::OnDtlsHandshakeError); | 278 this, &TransportController::OnDtlsHandshakeError); |
| 279 dtls->ice_transport()->SignalGatheringState.connect( |
| 280 this, &TransportController::OnChannelGatheringState_n); |
| 281 dtls->ice_transport()->SignalCandidateGathered.connect( |
| 282 this, &TransportController::OnChannelCandidateGathered_n); |
| 283 dtls->ice_transport()->SignalCandidatesRemoved.connect( |
| 284 this, &TransportController::OnChannelCandidatesRemoved_n); |
| 285 dtls->ice_transport()->SignalRoleConflict.connect( |
| 286 this, &TransportController::OnChannelRoleConflict_n); |
| 287 dtls->ice_transport()->SignalStateChanged.connect( |
| 288 this, &TransportController::OnChannelStateChanged_n); |
| 289 RefCountedChannel* new_pair = new RefCountedChannel(dtls, ice); | 289 RefCountedChannel* new_pair = new RefCountedChannel(dtls, ice); |
| 290 new_pair->AddRef(); | 290 new_pair->AddRef(); |
| 291 channels_.insert(channels_.end(), new_pair); | 291 channels_.insert(channels_.end(), new_pair); |
| 292 bool channel_added = transport->AddChannel(dtls, component); | 292 bool channel_added = transport->AddChannel(dtls, component); |
| 293 RTC_DCHECK(channel_added); | 293 RTC_DCHECK(channel_added); |
| 294 // Adding a channel could cause aggregate state to change. | 294 // Adding a channel could cause aggregate state to change. |
| 295 UpdateAggregateStates_n(); | 295 UpdateAggregateStates_n(); |
| 296 return dtls; | 296 return dtls; |
| 297 } | 297 } |
| 298 | 298 |
| 299 void TransportController::DestroyTransportChannel( | 299 void TransportController::DestroyDtlsTransport( |
| 300 const std::string& transport_name, | 300 const std::string& transport_name, |
| 301 int component) { | 301 int component) { |
| 302 network_thread_->Invoke<void>( | 302 network_thread_->Invoke<void>( |
| 303 RTC_FROM_HERE, rtc::Bind(&TransportController::DestroyTransportChannel_n, | 303 RTC_FROM_HERE, rtc::Bind(&TransportController::DestroyDtlsTransport_n, |
| 304 this, transport_name, component)); | 304 this, transport_name, component)); |
| 305 } | 305 } |
| 306 | 306 |
| 307 void TransportController::DestroyTransportChannel_n( | 307 void TransportController::DestroyDtlsTransport_n( |
| 308 const std::string& transport_name, | 308 const std::string& transport_name, |
| 309 int component) { | 309 int component) { |
| 310 RTC_DCHECK(network_thread_->IsCurrent()); | 310 RTC_DCHECK(network_thread_->IsCurrent()); |
| 311 auto it = GetChannelIterator_n(transport_name, component); | 311 auto it = GetChannelIterator_n(transport_name, component); |
| 312 if (it == channels_.end()) { | 312 if (it == channels_.end()) { |
| 313 LOG(LS_WARNING) << "Attempting to delete " << transport_name | 313 LOG(LS_WARNING) << "Attempting to delete " << transport_name |
| 314 << " TransportChannel " << component | 314 << " TransportChannel " << component |
| 315 << ", which doesn't exist."; | 315 << ", which doesn't exist."; |
| 316 return; | 316 return; |
| 317 } | 317 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 333 } | 333 } |
| 334 | 334 |
| 335 std::vector<std::string> TransportController::transport_names_for_testing() { | 335 std::vector<std::string> TransportController::transport_names_for_testing() { |
| 336 std::vector<std::string> ret; | 336 std::vector<std::string> ret; |
| 337 for (const auto& kv : transports_) { | 337 for (const auto& kv : transports_) { |
| 338 ret.push_back(kv.first); | 338 ret.push_back(kv.first); |
| 339 } | 339 } |
| 340 return ret; | 340 return ret; |
| 341 } | 341 } |
| 342 | 342 |
| 343 std::vector<TransportChannelImpl*> TransportController::channels_for_testing() { | 343 std::vector<DtlsTransportInternal*> |
| 344 std::vector<TransportChannelImpl*> ret; | 344 TransportController::channels_for_testing() { |
| 345 std::vector<DtlsTransportInternal*> ret; |
| 345 for (RefCountedChannel* channel : channels_) { | 346 for (RefCountedChannel* channel : channels_) { |
| 346 ret.push_back(channel->dtls()); | 347 ret.push_back(channel->dtls()); |
| 347 } | 348 } |
| 348 return ret; | 349 return ret; |
| 349 } | 350 } |
| 350 | 351 |
| 351 TransportChannelImpl* TransportController::get_channel_for_testing( | 352 DtlsTransportInternal* TransportController::get_channel_for_testing( |
| 352 const std::string& transport_name, | 353 const std::string& transport_name, |
| 353 int component) { | 354 int component) { |
| 354 RefCountedChannel* ch = GetChannel_n(transport_name, component); | 355 RefCountedChannel* ch = GetChannel_n(transport_name, component); |
| 355 return ch ? ch->dtls() : nullptr; | 356 return ch ? ch->dtls() : nullptr; |
| 356 } | 357 } |
| 357 | 358 |
| 358 IceTransportInternal* TransportController::CreateIceTransportChannel_n( | 359 IceTransportInternal* TransportController::CreateIceTransportChannel_n( |
| 359 const std::string& transport_name, | 360 const std::string& transport_name, |
| 360 int component) { | 361 int component) { |
| 361 return new P2PTransportChannel(transport_name, component, port_allocator_); | 362 return new P2PTransportChannel(transport_name, component, port_allocator_); |
| 362 } | 363 } |
| 363 | 364 |
| 364 TransportChannelImpl* TransportController::CreateDtlsTransportChannel_n( | 365 DtlsTransportInternal* TransportController::CreateDtlsTransportChannel_n( |
| 365 const std::string&, | 366 const std::string&, |
| 366 int, | 367 int, |
| 367 IceTransportInternal* ice) { | 368 IceTransportInternal* ice) { |
| 368 DtlsTransportChannelWrapper* dtls = new DtlsTransportChannelWrapper(ice); | 369 DtlsTransport* dtls = new DtlsTransport(ice); |
| 369 dtls->SetSslMaxProtocolVersion(ssl_max_version_); | 370 dtls->SetSslMaxProtocolVersion(ssl_max_version_); |
| 370 return dtls; | 371 return dtls; |
| 371 } | 372 } |
| 372 | 373 |
| 373 void TransportController::OnMessage(rtc::Message* pmsg) { | 374 void TransportController::OnMessage(rtc::Message* pmsg) { |
| 374 RTC_DCHECK(signaling_thread_->IsCurrent()); | 375 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 375 | 376 |
| 376 switch (pmsg->message_id) { | 377 switch (pmsg->message_id) { |
| 377 case MSG_ICECONNECTIONSTATE: { | 378 case MSG_ICECONNECTIONSTATE: { |
| 378 rtc::TypedMessageData<IceConnectionState>* data = | 379 rtc::TypedMessageData<IceConnectionState>* data = |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 497 |
| 497 ssl_max_version_ = version; | 498 ssl_max_version_ = version; |
| 498 return true; | 499 return true; |
| 499 } | 500 } |
| 500 | 501 |
| 501 void TransportController::SetIceConfig_n(const IceConfig& config) { | 502 void TransportController::SetIceConfig_n(const IceConfig& config) { |
| 502 RTC_DCHECK(network_thread_->IsCurrent()); | 503 RTC_DCHECK(network_thread_->IsCurrent()); |
| 503 | 504 |
| 504 ice_config_ = config; | 505 ice_config_ = config; |
| 505 for (auto& channel : channels_) { | 506 for (auto& channel : channels_) { |
| 506 channel->dtls()->SetIceConfig(ice_config_); | 507 channel->dtls()->ice_transport()->SetIceConfig(ice_config_); |
| 507 } | 508 } |
| 508 } | 509 } |
| 509 | 510 |
| 510 void TransportController::SetIceRole_n(IceRole ice_role) { | 511 void TransportController::SetIceRole_n(IceRole ice_role) { |
| 511 RTC_DCHECK(network_thread_->IsCurrent()); | 512 RTC_DCHECK(network_thread_->IsCurrent()); |
| 512 | 513 |
| 513 ice_role_ = ice_role; | 514 ice_role_ = ice_role; |
| 514 for (auto& channel : channels_) { | 515 for (auto& channel : channels_) { |
| 515 channel->dtls()->SetIceRole(ice_role_); | 516 channel->dtls()->ice_transport()->SetIceRole(ice_role_); |
| 516 } | 517 } |
| 517 } | 518 } |
| 518 | 519 |
| 519 bool TransportController::GetSslRole_n(const std::string& transport_name, | 520 bool TransportController::GetSslRole_n(const std::string& transport_name, |
| 520 rtc::SSLRole* role) const { | 521 rtc::SSLRole* role) const { |
| 521 RTC_DCHECK(network_thread_->IsCurrent()); | 522 RTC_DCHECK(network_thread_->IsCurrent()); |
| 522 | 523 |
| 523 const JsepTransport* t = GetJsepTransport(transport_name); | 524 const JsepTransport* t = GetJsepTransport(transport_name); |
| 524 if (!t) { | 525 if (!t) { |
| 525 return false; | 526 return false; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 // description on a deleted transport. | 638 // description on a deleted transport. |
| 638 return true; | 639 return true; |
| 639 } | 640 } |
| 640 | 641 |
| 641 LOG(LS_INFO) << "Set remote transport description on " << transport_name; | 642 LOG(LS_INFO) << "Set remote transport description on " << transport_name; |
| 642 return transport->SetRemoteTransportDescription(tdesc, action, err); | 643 return transport->SetRemoteTransportDescription(tdesc, action, err); |
| 643 } | 644 } |
| 644 | 645 |
| 645 void TransportController::MaybeStartGathering_n() { | 646 void TransportController::MaybeStartGathering_n() { |
| 646 for (auto& channel : channels_) { | 647 for (auto& channel : channels_) { |
| 647 channel->dtls()->MaybeStartGathering(); | 648 channel->dtls()->ice_transport()->MaybeStartGathering(); |
| 648 } | 649 } |
| 649 } | 650 } |
| 650 | 651 |
| 651 bool TransportController::AddRemoteCandidates_n( | 652 bool TransportController::AddRemoteCandidates_n( |
| 652 const std::string& transport_name, | 653 const std::string& transport_name, |
| 653 const Candidates& candidates, | 654 const Candidates& candidates, |
| 654 std::string* err) { | 655 std::string* err) { |
| 655 RTC_DCHECK(network_thread_->IsCurrent()); | 656 RTC_DCHECK(network_thread_->IsCurrent()); |
| 656 | 657 |
| 657 // Verify each candidate before passing down to the transport layer. | 658 // Verify each candidate before passing down to the transport layer. |
| 658 if (!VerifyCandidates(candidates, err)) { | 659 if (!VerifyCandidates(candidates, err)) { |
| 659 return false; | 660 return false; |
| 660 } | 661 } |
| 661 | 662 |
| 662 JsepTransport* transport = GetJsepTransport(transport_name); | 663 JsepTransport* transport = GetJsepTransport(transport_name); |
| 663 if (!transport) { | 664 if (!transport) { |
| 664 // If we didn't find a transport, that's not an error; | 665 // If we didn't find a transport, that's not an error; |
| 665 // it could have been deleted as a result of bundling. | 666 // it could have been deleted as a result of bundling. |
| 666 return true; | 667 return true; |
| 667 } | 668 } |
| 668 | 669 |
| 669 for (const Candidate& candidate : candidates) { | 670 for (const Candidate& candidate : candidates) { |
| 670 RefCountedChannel* channel = | 671 RefCountedChannel* channel = |
| 671 GetChannel_n(transport_name, candidate.component()); | 672 GetChannel_n(transport_name, candidate.component()); |
| 672 if (!channel) { | 673 if (!channel) { |
| 673 *err = "Candidate has an unknown component: " + candidate.ToString() + | 674 *err = "Candidate has an unknown component: " + candidate.ToString() + |
| 674 " for content: " + transport_name; | 675 " for content: " + transport_name; |
| 675 return false; | 676 return false; |
| 676 } | 677 } |
| 677 channel->dtls()->AddRemoteCandidate(candidate); | 678 channel->dtls()->ice_transport()->AddRemoteCandidate(candidate); |
| 678 } | 679 } |
| 679 return true; | 680 return true; |
| 680 } | 681 } |
| 681 | 682 |
| 682 bool TransportController::RemoveRemoteCandidates_n(const Candidates& candidates, | 683 bool TransportController::RemoveRemoteCandidates_n(const Candidates& candidates, |
| 683 std::string* err) { | 684 std::string* err) { |
| 684 RTC_DCHECK(network_thread_->IsCurrent()); | 685 RTC_DCHECK(network_thread_->IsCurrent()); |
| 685 | 686 |
| 686 // Verify each candidate before passing down to the transport layer. | 687 // Verify each candidate before passing down to the transport layer. |
| 687 if (!VerifyCandidates(candidates, err)) { | 688 if (!VerifyCandidates(candidates, err)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 701 JsepTransport* transport = GetJsepTransport(transport_name); | 702 JsepTransport* transport = GetJsepTransport(transport_name); |
| 702 if (!transport) { | 703 if (!transport) { |
| 703 // If we didn't find a transport, that's not an error; | 704 // If we didn't find a transport, that's not an error; |
| 704 // it could have been deleted as a result of bundling. | 705 // it could have been deleted as a result of bundling. |
| 705 continue; | 706 continue; |
| 706 } | 707 } |
| 707 for (const Candidate& candidate : candidates) { | 708 for (const Candidate& candidate : candidates) { |
| 708 RefCountedChannel* channel = | 709 RefCountedChannel* channel = |
| 709 GetChannel_n(transport_name, candidate.component()); | 710 GetChannel_n(transport_name, candidate.component()); |
| 710 if (channel) { | 711 if (channel) { |
| 711 channel->dtls()->RemoveRemoteCandidate(candidate); | 712 channel->dtls()->ice_transport()->RemoveRemoteCandidate(candidate); |
| 712 } | 713 } |
| 713 } | 714 } |
| 714 } | 715 } |
| 715 return result; | 716 return result; |
| 716 } | 717 } |
| 717 | 718 |
| 718 bool TransportController::ReadyForRemoteCandidates_n( | 719 bool TransportController::ReadyForRemoteCandidates_n( |
| 719 const std::string& transport_name) const { | 720 const std::string& transport_name) const { |
| 720 RTC_DCHECK(network_thread_->IsCurrent()); | 721 RTC_DCHECK(network_thread_->IsCurrent()); |
| 721 | 722 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 735 return false; | 736 return false; |
| 736 } | 737 } |
| 737 return transport->GetStats(stats); | 738 return transport->GetStats(stats); |
| 738 } | 739 } |
| 739 | 740 |
| 740 void TransportController::SetMetricsObserver_n( | 741 void TransportController::SetMetricsObserver_n( |
| 741 webrtc::MetricsObserverInterface* metrics_observer) { | 742 webrtc::MetricsObserverInterface* metrics_observer) { |
| 742 RTC_DCHECK(network_thread_->IsCurrent()); | 743 RTC_DCHECK(network_thread_->IsCurrent()); |
| 743 metrics_observer_ = metrics_observer; | 744 metrics_observer_ = metrics_observer; |
| 744 for (auto& channel : channels_) { | 745 for (auto& channel : channels_) { |
| 745 channel->dtls()->SetMetricsObserver(metrics_observer); | 746 channel->dtls()->ice_transport()->SetMetricsObserver(metrics_observer); |
| 746 } | 747 } |
| 747 } | 748 } |
| 748 | 749 |
| 749 void TransportController::OnChannelWritableState_n( | 750 void TransportController::OnChannelWritableState_n( |
| 750 rtc::PacketTransportInterface* transport) { | 751 rtc::PacketTransportInterface* transport) { |
| 751 RTC_DCHECK(network_thread_->IsCurrent()); | 752 RTC_DCHECK(network_thread_->IsCurrent()); |
| 752 LOG(LS_INFO) << " TransportChannel " << transport->debug_name() | 753 LOG(LS_INFO) << " TransportChannel " << transport->debug_name() |
| 753 << " writability changed to " << transport->writable() << "."; | 754 << " writability changed to " << transport->writable() << "."; |
| 754 UpdateAggregateStates_n(); | 755 UpdateAggregateStates_n(); |
| 755 } | 756 } |
| 756 | 757 |
| 757 void TransportController::OnChannelReceivingState_n( | 758 void TransportController::OnChannelReceivingState_n( |
| 758 rtc::PacketTransportInterface* transport) { | 759 rtc::PacketTransportInterface* transport) { |
| 759 RTC_DCHECK(network_thread_->IsCurrent()); | 760 RTC_DCHECK(network_thread_->IsCurrent()); |
| 760 UpdateAggregateStates_n(); | 761 UpdateAggregateStates_n(); |
| 761 } | 762 } |
| 762 | 763 |
| 763 void TransportController::OnChannelGatheringState_n( | 764 void TransportController::OnChannelGatheringState_n( |
| 764 TransportChannelImpl* channel) { | 765 IceTransportInternal* channel) { |
| 765 RTC_DCHECK(network_thread_->IsCurrent()); | 766 RTC_DCHECK(network_thread_->IsCurrent()); |
| 766 UpdateAggregateStates_n(); | 767 UpdateAggregateStates_n(); |
| 767 } | 768 } |
| 768 | 769 |
| 769 void TransportController::OnChannelCandidateGathered_n( | 770 void TransportController::OnChannelCandidateGathered_n( |
| 770 TransportChannelImpl* channel, | 771 IceTransportInternal* channel, |
| 771 const Candidate& candidate) { | 772 const Candidate& candidate) { |
| 772 RTC_DCHECK(network_thread_->IsCurrent()); | 773 RTC_DCHECK(network_thread_->IsCurrent()); |
| 773 | 774 |
| 774 // We should never signal peer-reflexive candidates. | 775 // We should never signal peer-reflexive candidates. |
| 775 if (candidate.type() == PRFLX_PORT_TYPE) { | 776 if (candidate.type() == PRFLX_PORT_TYPE) { |
| 776 RTC_NOTREACHED(); | 777 RTC_NOTREACHED(); |
| 777 return; | 778 return; |
| 778 } | 779 } |
| 779 std::vector<Candidate> candidates; | 780 std::vector<Candidate> candidates; |
| 780 candidates.push_back(candidate); | 781 candidates.push_back(candidate); |
| 781 CandidatesData* data = | 782 CandidatesData* data = |
| 782 new CandidatesData(channel->transport_name(), candidates); | 783 new CandidatesData(channel->transport_name(), candidates); |
| 783 signaling_thread_->Post(RTC_FROM_HERE, this, MSG_CANDIDATESGATHERED, data); | 784 signaling_thread_->Post(RTC_FROM_HERE, this, MSG_CANDIDATESGATHERED, data); |
| 784 } | 785 } |
| 785 | 786 |
| 786 void TransportController::OnChannelCandidatesRemoved_n( | 787 void TransportController::OnChannelCandidatesRemoved_n( |
| 787 TransportChannelImpl* channel, | 788 IceTransportInternal* channel, |
| 788 const Candidates& candidates) { | 789 const Candidates& candidates) { |
| 789 invoker_.AsyncInvoke<void>( | 790 invoker_.AsyncInvoke<void>( |
| 790 RTC_FROM_HERE, signaling_thread_, | 791 RTC_FROM_HERE, signaling_thread_, |
| 791 rtc::Bind(&TransportController::OnChannelCandidatesRemoved, this, | 792 rtc::Bind(&TransportController::OnChannelCandidatesRemoved, this, |
| 792 candidates)); | 793 candidates)); |
| 793 } | 794 } |
| 794 | 795 |
| 795 void TransportController::OnChannelCandidatesRemoved( | 796 void TransportController::OnChannelCandidatesRemoved( |
| 796 const Candidates& candidates) { | 797 const Candidates& candidates) { |
| 797 RTC_DCHECK(signaling_thread_->IsCurrent()); | 798 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 798 SignalCandidatesRemoved(candidates); | 799 SignalCandidatesRemoved(candidates); |
| 799 } | 800 } |
| 800 | 801 |
| 801 void TransportController::OnChannelRoleConflict_n( | 802 void TransportController::OnChannelRoleConflict_n( |
| 802 TransportChannelImpl* channel) { | 803 IceTransportInternal* channel) { |
| 803 RTC_DCHECK(network_thread_->IsCurrent()); | 804 RTC_DCHECK(network_thread_->IsCurrent()); |
| 804 // Note: since the role conflict is handled entirely on the network thread, | 805 // Note: since the role conflict is handled entirely on the network thread, |
| 805 // we don't need to worry about role conflicts occurring on two ports at once. | 806 // we don't need to worry about role conflicts occurring on two ports at once. |
| 806 // The first one encountered should immediately reverse the role. | 807 // The first one encountered should immediately reverse the role. |
| 807 IceRole reversed_role = (ice_role_ == ICEROLE_CONTROLLING) | 808 IceRole reversed_role = (ice_role_ == ICEROLE_CONTROLLING) |
| 808 ? ICEROLE_CONTROLLED | 809 ? ICEROLE_CONTROLLED |
| 809 : ICEROLE_CONTROLLING; | 810 : ICEROLE_CONTROLLING; |
| 810 LOG(LS_INFO) << "Got role conflict; switching to " | 811 LOG(LS_INFO) << "Got role conflict; switching to " |
| 811 << (reversed_role == ICEROLE_CONTROLLING ? "controlling" | 812 << (reversed_role == ICEROLE_CONTROLLING ? "controlling" |
| 812 : "controlled") | 813 : "controlled") |
| 813 << " role."; | 814 << " role."; |
| 814 SetIceRole_n(reversed_role); | 815 SetIceRole_n(reversed_role); |
| 815 } | 816 } |
| 816 | 817 |
| 817 void TransportController::OnChannelStateChanged_n( | 818 void TransportController::OnChannelStateChanged_n( |
| 818 TransportChannelImpl* channel) { | 819 IceTransportInternal* channel) { |
| 819 RTC_DCHECK(network_thread_->IsCurrent()); | 820 RTC_DCHECK(network_thread_->IsCurrent()); |
| 820 LOG(LS_INFO) << channel->transport_name() << " TransportChannel " | 821 LOG(LS_INFO) << channel->transport_name() << " TransportChannel " |
| 821 << channel->component() | 822 << channel->component() |
| 822 << " state changed. Check if state is complete."; | 823 << " state changed. Check if state is complete."; |
| 823 UpdateAggregateStates_n(); | 824 UpdateAggregateStates_n(); |
| 824 } | 825 } |
| 825 | 826 |
| 826 void TransportController::UpdateAggregateStates_n() { | 827 void TransportController::UpdateAggregateStates_n() { |
| 827 RTC_DCHECK(network_thread_->IsCurrent()); | 828 RTC_DCHECK(network_thread_->IsCurrent()); |
| 828 | 829 |
| 829 IceConnectionState new_connection_state = kIceConnectionConnecting; | 830 IceConnectionState new_connection_state = kIceConnectionConnecting; |
| 830 IceGatheringState new_gathering_state = kIceGatheringNew; | 831 IceGatheringState new_gathering_state = kIceGatheringNew; |
| 831 bool any_receiving = false; | 832 bool any_receiving = false; |
| 832 bool any_failed = false; | 833 bool any_failed = false; |
| 833 bool all_connected = !channels_.empty(); | 834 bool all_connected = !channels_.empty(); |
| 834 bool all_completed = !channels_.empty(); | 835 bool all_completed = !channels_.empty(); |
| 835 bool any_gathering = false; | 836 bool any_gathering = false; |
| 836 bool all_done_gathering = !channels_.empty(); | 837 bool all_done_gathering = !channels_.empty(); |
| 837 for (const auto& channel : channels_) { | 838 for (const auto& channel : channels_) { |
| 838 any_receiving = any_receiving || channel->dtls()->receiving(); | 839 any_receiving = any_receiving || channel->dtls()->receiving(); |
| 839 any_failed = any_failed || | 840 any_failed = any_failed || |
| 840 channel->dtls()->GetState() == IceTransportState::STATE_FAILED; | 841 channel->dtls()->ice_transport()->GetState() == |
| 842 IceTransportState::STATE_FAILED; |
| 841 all_connected = all_connected && channel->dtls()->writable(); | 843 all_connected = all_connected && channel->dtls()->writable(); |
| 842 all_completed = | 844 all_completed = |
| 843 all_completed && channel->dtls()->writable() && | 845 all_completed && channel->dtls()->writable() && |
| 844 channel->dtls()->GetState() == IceTransportState::STATE_COMPLETED && | 846 channel->dtls()->ice_transport()->GetState() == |
| 845 channel->dtls()->GetIceRole() == ICEROLE_CONTROLLING && | 847 IceTransportState::STATE_COMPLETED && |
| 846 channel->dtls()->gathering_state() == kIceGatheringComplete; | 848 channel->dtls()->ice_transport()->GetIceRole() == ICEROLE_CONTROLLING && |
| 849 channel->dtls()->ice_transport()->gathering_state() == |
| 850 kIceGatheringComplete; |
| 847 any_gathering = | 851 any_gathering = |
| 848 any_gathering || channel->dtls()->gathering_state() != kIceGatheringNew; | 852 any_gathering || |
| 849 all_done_gathering = | 853 channel->dtls()->ice_transport()->gathering_state() != kIceGatheringNew; |
| 850 all_done_gathering && | 854 all_done_gathering = all_done_gathering && |
| 851 channel->dtls()->gathering_state() == kIceGatheringComplete; | 855 channel->dtls()->ice_transport()->gathering_state() == |
| 856 kIceGatheringComplete; |
| 852 } | 857 } |
| 853 | |
| 854 if (any_failed) { | 858 if (any_failed) { |
| 855 new_connection_state = kIceConnectionFailed; | 859 new_connection_state = kIceConnectionFailed; |
| 856 } else if (all_completed) { | 860 } else if (all_completed) { |
| 857 new_connection_state = kIceConnectionCompleted; | 861 new_connection_state = kIceConnectionCompleted; |
| 858 } else if (all_connected) { | 862 } else if (all_connected) { |
| 859 new_connection_state = kIceConnectionConnected; | 863 new_connection_state = kIceConnectionConnected; |
| 860 } | 864 } |
| 861 if (connection_state_ != new_connection_state) { | 865 if (connection_state_ != new_connection_state) { |
| 862 connection_state_ = new_connection_state; | 866 connection_state_ = new_connection_state; |
| 863 signaling_thread_->Post( | 867 signaling_thread_->Post( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 882 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, | 886 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, |
| 883 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); | 887 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); |
| 884 } | 888 } |
| 885 } | 889 } |
| 886 | 890 |
| 887 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 891 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
| 888 SignalDtlsHandshakeError(error); | 892 SignalDtlsHandshakeError(error); |
| 889 } | 893 } |
| 890 | 894 |
| 891 } // namespace cricket | 895 } // namespace cricket |
| OLD | NEW |