| 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 29 matching lines...) Expand all Loading... |
| 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 // DtlsTransportChannelWrapper and P2PTransportChannelWrapper, |
| 49 // once TransportChannelImpl is removed. | 49 // once TransportChannelImpl is removed. |
| 50 ChannelPair(TransportChannelImpl* dtls, IceTransportInternal* ice) | 50 ChannelPair(TransportChannelImpl* dtls, TransportChannelImpl* 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 TransportChannelImpl* dtls() const { return dtls_.get(); } |
| 57 TransportChannelImpl* dtls() { return dtls_.get(); } | 57 TransportChannelImpl* dtls() { return dtls_.get(); } |
| 58 const IceTransportInternal* ice() const { return ice_.get(); } | 58 const TransportChannelImpl* ice() const { return ice_.get(); } |
| 59 IceTransportInternal* ice() { return ice_.get(); } | 59 TransportChannelImpl* ice() { return ice_.get(); } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 std::unique_ptr<IceTransportInternal> ice_; | 62 std::unique_ptr<TransportChannelImpl> ice_; |
| 63 std::unique_ptr<TransportChannelImpl> dtls_; | 63 std::unique_ptr<TransportChannelImpl> 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), |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if (existing_channel) { | 236 if (existing_channel) { |
| 237 // Channel already exists; increment reference count and return. | 237 // Channel already exists; increment reference count and return. |
| 238 existing_channel->AddRef(); | 238 existing_channel->AddRef(); |
| 239 return existing_channel->dtls(); | 239 return existing_channel->dtls(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 // Need to create a new channel. | 242 // Need to create a new channel. |
| 243 JsepTransport* transport = GetOrCreateJsepTransport(transport_name); | 243 JsepTransport* transport = GetOrCreateJsepTransport(transport_name); |
| 244 | 244 |
| 245 // Create DTLS channel wrapping ICE channel, and configure it. | 245 // Create DTLS channel wrapping ICE channel, and configure it. |
| 246 IceTransportInternal* ice = | 246 TransportChannelImpl* ice = |
| 247 CreateIceTransportChannel_n(transport_name, component); | 247 CreateIceTransportChannel_n(transport_name, component); |
| 248 // TODO(deadbeef): To support QUIC, would need to create a | 248 // TODO(deadbeef): To support QUIC, would need to create a |
| 249 // QuicTransportChannel here. What is "dtls" in this file would then become | 249 // QuicTransportChannel here. What is "dtls" in this file would then become |
| 250 // "dtls or quic". | 250 // "dtls or quic". |
| 251 TransportChannelImpl* dtls = | 251 TransportChannelImpl* dtls = |
| 252 CreateDtlsTransportChannel_n(transport_name, component, ice); | 252 CreateDtlsTransportChannel_n(transport_name, component, ice); |
| 253 dtls->SetMetricsObserver(metrics_observer_); | 253 dtls->SetMetricsObserver(metrics_observer_); |
| 254 dtls->SetIceRole(ice_role_); | 254 dtls->SetIceRole(ice_role_); |
| 255 dtls->SetIceTiebreaker(ice_tiebreaker_); | 255 dtls->SetIceTiebreaker(ice_tiebreaker_); |
| 256 dtls->SetIceConfig(ice_config_); | 256 dtls->SetIceConfig(ice_config_); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 return ret; | 334 return ret; |
| 335 } | 335 } |
| 336 | 336 |
| 337 TransportChannelImpl* TransportController::get_channel_for_testing( | 337 TransportChannelImpl* TransportController::get_channel_for_testing( |
| 338 const std::string& transport_name, | 338 const std::string& transport_name, |
| 339 int component) { | 339 int component) { |
| 340 RefCountedChannel* ch = GetChannel_n(transport_name, component); | 340 RefCountedChannel* ch = GetChannel_n(transport_name, component); |
| 341 return ch ? ch->dtls() : nullptr; | 341 return ch ? ch->dtls() : nullptr; |
| 342 } | 342 } |
| 343 | 343 |
| 344 IceTransportInternal* TransportController::CreateIceTransportChannel_n( | 344 TransportChannelImpl* TransportController::CreateIceTransportChannel_n( |
| 345 const std::string& transport_name, | 345 const std::string& transport_name, |
| 346 int component) { | 346 int component) { |
| 347 return new P2PTransportChannel(transport_name, component, port_allocator_); | 347 return new P2PTransportChannel(transport_name, component, port_allocator_); |
| 348 } | 348 } |
| 349 | 349 |
| 350 TransportChannelImpl* TransportController::CreateDtlsTransportChannel_n( | 350 TransportChannelImpl* TransportController::CreateDtlsTransportChannel_n( |
| 351 const std::string&, | 351 const std::string&, |
| 352 int, | 352 int, |
| 353 IceTransportInternal* ice) { | 353 TransportChannelImpl* ice) { |
| 354 DtlsTransportChannelWrapper* dtls = new DtlsTransportChannelWrapper(ice); | 354 DtlsTransportChannelWrapper* dtls = new DtlsTransportChannelWrapper(ice); |
| 355 dtls->SetSslMaxProtocolVersion(ssl_max_version_); | 355 dtls->SetSslMaxProtocolVersion(ssl_max_version_); |
| 356 return dtls; | 356 return dtls; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void TransportController::OnMessage(rtc::Message* pmsg) { | 359 void TransportController::OnMessage(rtc::Message* pmsg) { |
| 360 RTC_DCHECK(signaling_thread_->IsCurrent()); | 360 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 361 | 361 |
| 362 switch (pmsg->message_id) { | 362 switch (pmsg->message_id) { |
| 363 case MSG_ICECONNECTIONSTATE: { | 363 case MSG_ICECONNECTIONSTATE: { |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 IceConnectionState new_connection_state = kIceConnectionConnecting; | 815 IceConnectionState new_connection_state = kIceConnectionConnecting; |
| 816 IceGatheringState new_gathering_state = kIceGatheringNew; | 816 IceGatheringState new_gathering_state = kIceGatheringNew; |
| 817 bool any_receiving = false; | 817 bool any_receiving = false; |
| 818 bool any_failed = false; | 818 bool any_failed = false; |
| 819 bool all_connected = !channels_.empty(); | 819 bool all_connected = !channels_.empty(); |
| 820 bool all_completed = !channels_.empty(); | 820 bool all_completed = !channels_.empty(); |
| 821 bool any_gathering = false; | 821 bool any_gathering = false; |
| 822 bool all_done_gathering = !channels_.empty(); | 822 bool all_done_gathering = !channels_.empty(); |
| 823 for (const auto& channel : channels_) { | 823 for (const auto& channel : channels_) { |
| 824 any_receiving = any_receiving || channel->dtls()->receiving(); | 824 any_receiving = any_receiving || channel->dtls()->receiving(); |
| 825 any_failed = any_failed || | 825 any_failed = |
| 826 channel->dtls()->GetState() == IceTransportState::STATE_FAILED; | 826 any_failed || |
| 827 channel->dtls()->GetState() == TransportChannelState::STATE_FAILED; |
| 827 all_connected = all_connected && channel->dtls()->writable(); | 828 all_connected = all_connected && channel->dtls()->writable(); |
| 828 all_completed = | 829 all_completed = |
| 829 all_completed && channel->dtls()->writable() && | 830 all_completed && channel->dtls()->writable() && |
| 830 channel->dtls()->GetState() == IceTransportState::STATE_COMPLETED && | 831 channel->dtls()->GetState() == TransportChannelState::STATE_COMPLETED && |
| 831 channel->dtls()->GetIceRole() == ICEROLE_CONTROLLING && | 832 channel->dtls()->GetIceRole() == ICEROLE_CONTROLLING && |
| 832 channel->dtls()->gathering_state() == kIceGatheringComplete; | 833 channel->dtls()->gathering_state() == kIceGatheringComplete; |
| 833 any_gathering = | 834 any_gathering = |
| 834 any_gathering || channel->dtls()->gathering_state() != kIceGatheringNew; | 835 any_gathering || channel->dtls()->gathering_state() != kIceGatheringNew; |
| 835 all_done_gathering = | 836 all_done_gathering = |
| 836 all_done_gathering && | 837 all_done_gathering && |
| 837 channel->dtls()->gathering_state() == kIceGatheringComplete; | 838 channel->dtls()->gathering_state() == kIceGatheringComplete; |
| 838 } | 839 } |
| 839 | 840 |
| 840 if (any_failed) { | 841 if (any_failed) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 868 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, | 869 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, |
| 869 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); | 870 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); |
| 870 } | 871 } |
| 871 } | 872 } |
| 872 | 873 |
| 873 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 874 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
| 874 SignalDtlsHandshakeError(error); | 875 SignalDtlsHandshakeError(error); |
| 875 } | 876 } |
| 876 | 877 |
| 877 } // namespace cricket | 878 } // namespace cricket |
| OLD | NEW |