| 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 |
| 11 #include "webrtc/p2p/base/transportcontroller.h" | 11 #include "webrtc/p2p/base/transportcontroller.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "webrtc/base/bind.h" | 16 #include "webrtc/base/bind.h" |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/thread.h" | 18 #include "webrtc/base/thread.h" |
| 19 #include "webrtc/p2p/base/dtlstransport.h" | |
| 20 #include "webrtc/p2p/base/p2ptransport.h" | |
| 21 #include "webrtc/p2p/base/port.h" | 19 #include "webrtc/p2p/base/port.h" |
| 22 | 20 |
| 23 #ifdef HAVE_QUIC | |
| 24 #include "webrtc/p2p/quic/quictransport.h" | |
| 25 #endif // HAVE_QUIC | |
| 26 | |
| 27 namespace cricket { | 21 namespace cricket { |
| 28 | 22 |
| 29 enum { | 23 enum { |
| 30 MSG_ICECONNECTIONSTATE, | 24 MSG_ICECONNECTIONSTATE, |
| 31 MSG_RECEIVING, | 25 MSG_RECEIVING, |
| 32 MSG_ICEGATHERINGSTATE, | 26 MSG_ICEGATHERINGSTATE, |
| 33 MSG_CANDIDATESGATHERED, | 27 MSG_CANDIDATESGATHERED, |
| 34 }; | 28 }; |
| 35 | 29 |
| 36 struct CandidatesData : public rtc::MessageData { | 30 struct CandidatesData : public rtc::MessageData { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 | 47 |
| 54 TransportController::TransportController(rtc::Thread* signaling_thread, | 48 TransportController::TransportController(rtc::Thread* signaling_thread, |
| 55 rtc::Thread* network_thread, | 49 rtc::Thread* network_thread, |
| 56 PortAllocator* port_allocator) | 50 PortAllocator* port_allocator) |
| 57 : TransportController(signaling_thread, | 51 : TransportController(signaling_thread, |
| 58 network_thread, | 52 network_thread, |
| 59 port_allocator, | 53 port_allocator, |
| 60 true) {} | 54 true) {} |
| 61 | 55 |
| 62 TransportController::~TransportController() { | 56 TransportController::~TransportController() { |
| 57 // Channel destructors may try to send packets, so this needs to happen on |
| 58 // the network thread. |
| 63 network_thread_->Invoke<void>( | 59 network_thread_->Invoke<void>( |
| 64 RTC_FROM_HERE, | 60 RTC_FROM_HERE, |
| 65 rtc::Bind(&TransportController::DestroyAllTransports_n, this)); | 61 rtc::Bind(&TransportController::DestroyAllChannels_n, this)); |
| 66 signaling_thread_->Clear(this); | |
| 67 } | 62 } |
| 68 | 63 |
| 69 bool TransportController::SetSslMaxProtocolVersion( | 64 bool TransportController::SetSslMaxProtocolVersion( |
| 70 rtc::SSLProtocolVersion version) { | 65 rtc::SSLProtocolVersion version) { |
| 71 return network_thread_->Invoke<bool>( | 66 return network_thread_->Invoke<bool>( |
| 72 RTC_FROM_HERE, rtc::Bind(&TransportController::SetSslMaxProtocolVersion_n, | 67 RTC_FROM_HERE, rtc::Bind(&TransportController::SetSslMaxProtocolVersion_n, |
| 73 this, version)); | 68 this, version)); |
| 74 } | 69 } |
| 75 | 70 |
| 76 void TransportController::SetIceConfig(const IceConfig& config) { | 71 void TransportController::SetIceConfig(const IceConfig& config) { |
| 77 network_thread_->Invoke<void>( | 72 network_thread_->Invoke<void>( |
| 78 RTC_FROM_HERE, | 73 RTC_FROM_HERE, |
| 79 rtc::Bind(&TransportController::SetIceConfig_n, this, config)); | 74 rtc::Bind(&TransportController::SetIceConfig_n, this, config)); |
| 80 } | 75 } |
| 81 | 76 |
| 82 void TransportController::SetIceRole(IceRole ice_role) { | 77 void TransportController::SetIceRole(IceRole ice_role) { |
| 83 network_thread_->Invoke<void>( | 78 network_thread_->Invoke<void>( |
| 84 RTC_FROM_HERE, | 79 RTC_FROM_HERE, |
| 85 rtc::Bind(&TransportController::SetIceRole_n, this, ice_role)); | 80 rtc::Bind(&TransportController::SetIceRole_n, this, ice_role)); |
| 86 } | 81 } |
| 87 | 82 |
| 88 bool TransportController::GetSslRole(const std::string& transport_name, | 83 bool TransportController::GetSslRole(const std::string& transport_name, |
| 89 rtc::SSLRole* role) { | 84 rtc::SSLRole* role) const { |
| 90 return network_thread_->Invoke<bool>( | 85 return network_thread_->Invoke<bool>( |
| 91 RTC_FROM_HERE, rtc::Bind(&TransportController::GetSslRole_n, this, | 86 RTC_FROM_HERE, rtc::Bind(&TransportController::GetSslRole_n, this, |
| 92 transport_name, role)); | 87 transport_name, role)); |
| 93 } | 88 } |
| 94 | 89 |
| 95 bool TransportController::SetLocalCertificate( | 90 bool TransportController::SetLocalCertificate( |
| 96 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { | 91 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { |
| 97 return network_thread_->Invoke<bool>( | 92 return network_thread_->Invoke<bool>( |
| 98 RTC_FROM_HERE, rtc::Bind(&TransportController::SetLocalCertificate_n, | 93 RTC_FROM_HERE, rtc::Bind(&TransportController::SetLocalCertificate_n, |
| 99 this, certificate)); | 94 this, certificate)); |
| 100 } | 95 } |
| 101 | 96 |
| 102 bool TransportController::GetLocalCertificate( | 97 bool TransportController::GetLocalCertificate( |
| 103 const std::string& transport_name, | 98 const std::string& transport_name, |
| 104 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { | 99 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const { |
| 105 return network_thread_->Invoke<bool>( | 100 return network_thread_->Invoke<bool>( |
| 106 RTC_FROM_HERE, rtc::Bind(&TransportController::GetLocalCertificate_n, | 101 RTC_FROM_HERE, rtc::Bind(&TransportController::GetLocalCertificate_n, |
| 107 this, transport_name, certificate)); | 102 this, transport_name, certificate)); |
| 108 } | 103 } |
| 109 | 104 |
| 110 std::unique_ptr<rtc::SSLCertificate> | 105 std::unique_ptr<rtc::SSLCertificate> |
| 111 TransportController::GetRemoteSSLCertificate( | 106 TransportController::GetRemoteSSLCertificate( |
| 112 const std::string& transport_name) { | 107 const std::string& transport_name) const { |
| 113 return network_thread_->Invoke<std::unique_ptr<rtc::SSLCertificate>>( | 108 return network_thread_->Invoke<std::unique_ptr<rtc::SSLCertificate>>( |
| 114 RTC_FROM_HERE, rtc::Bind(&TransportController::GetRemoteSSLCertificate_n, | 109 RTC_FROM_HERE, rtc::Bind(&TransportController::GetRemoteSSLCertificate_n, |
| 115 this, transport_name)); | 110 this, transport_name)); |
| 116 } | 111 } |
| 117 | 112 |
| 118 bool TransportController::SetLocalTransportDescription( | 113 bool TransportController::SetLocalTransportDescription( |
| 119 const std::string& transport_name, | 114 const std::string& transport_name, |
| 120 const TransportDescription& tdesc, | 115 const TransportDescription& tdesc, |
| 121 ContentAction action, | 116 ContentAction action, |
| 122 std::string* err) { | 117 std::string* err) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 152 } | 147 } |
| 153 | 148 |
| 154 bool TransportController::RemoveRemoteCandidates(const Candidates& candidates, | 149 bool TransportController::RemoveRemoteCandidates(const Candidates& candidates, |
| 155 std::string* err) { | 150 std::string* err) { |
| 156 return network_thread_->Invoke<bool>( | 151 return network_thread_->Invoke<bool>( |
| 157 RTC_FROM_HERE, rtc::Bind(&TransportController::RemoveRemoteCandidates_n, | 152 RTC_FROM_HERE, rtc::Bind(&TransportController::RemoveRemoteCandidates_n, |
| 158 this, candidates, err)); | 153 this, candidates, err)); |
| 159 } | 154 } |
| 160 | 155 |
| 161 bool TransportController::ReadyForRemoteCandidates( | 156 bool TransportController::ReadyForRemoteCandidates( |
| 162 const std::string& transport_name) { | 157 const std::string& transport_name) const { |
| 163 return network_thread_->Invoke<bool>( | 158 return network_thread_->Invoke<bool>( |
| 164 RTC_FROM_HERE, rtc::Bind(&TransportController::ReadyForRemoteCandidates_n, | 159 RTC_FROM_HERE, rtc::Bind(&TransportController::ReadyForRemoteCandidates_n, |
| 165 this, transport_name)); | 160 this, transport_name)); |
| 166 } | 161 } |
| 167 | 162 |
| 168 bool TransportController::GetStats(const std::string& transport_name, | 163 bool TransportController::GetStats(const std::string& transport_name, |
| 169 TransportStats* stats) { | 164 TransportStats* stats) { |
| 170 return network_thread_->Invoke<bool>( | 165 return network_thread_->Invoke<bool>( |
| 171 RTC_FROM_HERE, | 166 RTC_FROM_HERE, |
| 172 rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats)); | 167 rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats)); |
| 173 } | 168 } |
| 174 | 169 |
| 170 void TransportController::SetMetricsObserver( |
| 171 webrtc::MetricsObserverInterface* metrics_observer) { |
| 172 return network_thread_->Invoke<void>( |
| 173 RTC_FROM_HERE, rtc::Bind(&TransportController::SetMetricsObserver_n, this, |
| 174 metrics_observer)); |
| 175 } |
| 176 |
| 175 TransportChannel* TransportController::CreateTransportChannel_n( | 177 TransportChannel* TransportController::CreateTransportChannel_n( |
| 176 const std::string& transport_name, | 178 const std::string& transport_name, |
| 177 int component) { | 179 int component) { |
| 178 RTC_DCHECK(network_thread_->IsCurrent()); | 180 RTC_DCHECK(network_thread_->IsCurrent()); |
| 179 | 181 |
| 180 auto it = FindChannel_n(transport_name, component); | 182 RefCountedChannel* existing_channel = GetChannel_n(transport_name, component); |
| 181 if (it != channels_.end()) { | 183 if (existing_channel) { |
| 182 // Channel already exists; increment reference count and return. | 184 // Channel already exists; increment reference count and return. |
| 183 it->AddRef(); | 185 existing_channel->AddRef(); |
| 184 return it->get(); | 186 return existing_channel->dtls(); |
| 185 } | 187 } |
| 186 | 188 |
| 187 // Need to create a new channel. | 189 // Need to create a new channel. |
| 188 Transport* transport = GetOrCreateTransport_n(transport_name); | 190 JsepTransport* transport = GetOrCreateJsepTransport_n(transport_name); |
| 189 TransportChannelImpl* channel = transport->CreateChannel(component); | 191 |
| 190 channel->SetMetricsObserver(metrics_observer_); | 192 // Create DTLS channel wrapping ICE channel, and configure it. |
| 191 channel->SignalWritableState.connect( | 193 TransportChannelImpl* ice = |
| 194 CreateIceTransportChannel_n(transport_name, component); |
| 195 // TODO(deadbeef): To support QUIC, would need to create a |
| 196 // QuicTransportChannel here. What is "dtls" in this file would then become |
| 197 // "dtls or quic". |
| 198 TransportChannelImpl* dtls = |
| 199 CreateDtlsTransportChannel_n(transport_name, component, ice); |
| 200 dtls->SetMetricsObserver(metrics_observer_); |
| 201 dtls->SetIceRole(ice_role_); |
| 202 dtls->SetIceTiebreaker(ice_tiebreaker_); |
| 203 dtls->SetIceConfig(ice_config_); |
| 204 if (certificate_) { |
| 205 bool set_cert_success = dtls->SetLocalCertificate(certificate_); |
| 206 RTC_DCHECK(set_cert_success); |
| 207 } |
| 208 |
| 209 // Connect to signals offered by the channels. Currently, the DTLS channel |
| 210 // forwards signals from the ICE channel, so we only need to connect to the |
| 211 // DTLS channel. In the future this won't be the case. |
| 212 dtls->SignalWritableState.connect( |
| 192 this, &TransportController::OnChannelWritableState_n); | 213 this, &TransportController::OnChannelWritableState_n); |
| 193 channel->SignalReceivingState.connect( | 214 dtls->SignalReceivingState.connect( |
| 194 this, &TransportController::OnChannelReceivingState_n); | 215 this, &TransportController::OnChannelReceivingState_n); |
| 195 channel->SignalGatheringState.connect( | 216 dtls->SignalGatheringState.connect( |
| 196 this, &TransportController::OnChannelGatheringState_n); | 217 this, &TransportController::OnChannelGatheringState_n); |
| 197 channel->SignalCandidateGathered.connect( | 218 dtls->SignalCandidateGathered.connect( |
| 198 this, &TransportController::OnChannelCandidateGathered_n); | 219 this, &TransportController::OnChannelCandidateGathered_n); |
| 199 channel->SignalCandidatesRemoved.connect( | 220 dtls->SignalCandidatesRemoved.connect( |
| 200 this, &TransportController::OnChannelCandidatesRemoved_n); | 221 this, &TransportController::OnChannelCandidatesRemoved_n); |
| 201 channel->SignalRoleConflict.connect( | 222 dtls->SignalRoleConflict.connect( |
| 202 this, &TransportController::OnChannelRoleConflict_n); | 223 this, &TransportController::OnChannelRoleConflict_n); |
| 203 channel->SignalStateChanged.connect( | 224 dtls->SignalStateChanged.connect( |
| 204 this, &TransportController::OnChannelStateChanged_n); | 225 this, &TransportController::OnChannelStateChanged_n); |
| 205 channel->SignalDtlsHandshakeError.connect( | 226 dtls->SignalDtlsHandshakeError.connect( |
| 206 this, &TransportController::OnDtlsHandshakeError); | 227 this, &TransportController::OnDtlsHandshakeError); |
| 207 channels_.insert(channels_.end(), RefCountedChannel(channel))->AddRef(); | 228 channels_.insert(channels_.end(), RefCountedChannel(dtls, ice))->AddRef(); |
| 229 bool channel_added = transport->AddChannel(dtls, component); |
| 230 RTC_DCHECK(channel_added); |
| 208 // Adding a channel could cause aggregate state to change. | 231 // Adding a channel could cause aggregate state to change. |
| 209 UpdateAggregateStates_n(); | 232 UpdateAggregateStates_n(); |
| 210 return channel; | 233 return dtls; |
| 211 } | 234 } |
| 212 | 235 |
| 213 void TransportController::DestroyTransportChannel_n( | 236 void TransportController::DestroyTransportChannel_n( |
| 214 const std::string& transport_name, | 237 const std::string& transport_name, |
| 215 int component) { | 238 int component) { |
| 216 RTC_DCHECK(network_thread_->IsCurrent()); | 239 RTC_DCHECK(network_thread_->IsCurrent()); |
| 217 | 240 |
| 218 auto it = FindChannel_n(transport_name, component); | 241 auto it = GetChannelIterator_n(transport_name, component); |
| 219 if (it == channels_.end()) { | 242 if (it == channels_.end()) { |
| 220 LOG(LS_WARNING) << "Attempting to delete " << transport_name | 243 LOG(LS_WARNING) << "Attempting to delete " << transport_name |
| 221 << " TransportChannel " << component | 244 << " TransportChannel " << component |
| 222 << ", which doesn't exist."; | 245 << ", which doesn't exist."; |
| 223 return; | 246 return; |
| 224 } | 247 } |
| 225 | |
| 226 it->DecRef(); | 248 it->DecRef(); |
| 227 if (it->ref() > 0) { | 249 if (it->ref() > 0) { |
| 228 return; | 250 return; |
| 229 } | 251 } |
| 252 channels_.erase(it); |
| 230 | 253 |
| 231 channels_.erase(it); | 254 JsepTransport* t = GetJsepTransport_n(transport_name); |
| 232 Transport* transport = GetTransport_n(transport_name); | 255 bool channel_removed = t->RemoveChannel(component); |
| 233 transport->DestroyChannel(component); | 256 RTC_DCHECK(channel_removed); |
| 234 // Just as we create a Transport when its first channel is created, | 257 // Just as we create a Transport when its first channel is created, |
| 235 // we delete it when its last channel is deleted. | 258 // we delete it when its last channel is deleted. |
| 236 if (!transport->HasChannels()) { | 259 if (!t->HasChannels()) { |
| 237 DestroyTransport_n(transport_name); | 260 transports_.erase(transport_name); |
| 238 } | 261 } |
| 262 |
| 239 // Removing a channel could cause aggregate state to change. | 263 // Removing a channel could cause aggregate state to change. |
| 240 UpdateAggregateStates_n(); | 264 UpdateAggregateStates_n(); |
| 241 } | 265 } |
| 242 | 266 |
| 243 const rtc::scoped_refptr<rtc::RTCCertificate>& | 267 std::vector<std::string> TransportController::transport_names_for_testing() { |
| 244 TransportController::certificate_for_testing() { | 268 std::vector<std::string> ret; |
| 245 return certificate_; | 269 for (const auto& kv : transports_) { |
| 270 ret.push_back(kv.first); |
| 271 } |
| 272 return ret; |
| 246 } | 273 } |
| 247 | 274 |
| 248 Transport* TransportController::CreateTransport_n( | 275 std::vector<TransportChannelImpl*> TransportController::channels_for_testing() { |
| 249 const std::string& transport_name) { | 276 std::vector<TransportChannelImpl*> ret; |
| 250 RTC_DCHECK(network_thread_->IsCurrent()); | 277 for (RefCountedChannel& channel : channels_) { |
| 251 | 278 ret.push_back(channel.dtls()); |
| 252 #ifdef HAVE_QUIC | |
| 253 if (quic_) { | |
| 254 return new QuicTransport(transport_name, port_allocator(), certificate_); | |
| 255 } | 279 } |
| 256 #endif // HAVE_QUIC | 280 return ret; |
| 257 Transport* transport = new DtlsTransport<P2PTransport>( | |
| 258 transport_name, port_allocator(), certificate_); | |
| 259 return transport; | |
| 260 } | 281 } |
| 261 | 282 |
| 262 Transport* TransportController::GetTransport_n( | 283 TransportChannelImpl* TransportController::get_channel_for_testing( |
| 263 const std::string& transport_name) { | 284 const std::string& transport_name, |
| 264 RTC_DCHECK(network_thread_->IsCurrent()); | 285 int component) { |
| 286 RefCountedChannel* ch = GetChannel_n(transport_name, component); |
| 287 return ch ? ch->dtls() : nullptr; |
| 288 } |
| 265 | 289 |
| 266 auto iter = transports_.find(transport_name); | 290 TransportChannelImpl* TransportController::CreateIceTransportChannel_n( |
| 267 return (iter != transports_.end()) ? iter->second : nullptr; | 291 const std::string& transport_name, |
| 292 int component) { |
| 293 return new P2PTransportChannel(transport_name, component, port_allocator_); |
| 294 } |
| 295 |
| 296 TransportChannelImpl* TransportController::CreateDtlsTransportChannel_n( |
| 297 const std::string&, |
| 298 int, |
| 299 TransportChannelImpl* ice) { |
| 300 DtlsTransportChannelWrapper* dtls = new DtlsTransportChannelWrapper(ice); |
| 301 dtls->SetSslMaxProtocolVersion(ssl_max_version_); |
| 302 return dtls; |
| 268 } | 303 } |
| 269 | 304 |
| 270 void TransportController::OnMessage(rtc::Message* pmsg) { | 305 void TransportController::OnMessage(rtc::Message* pmsg) { |
| 271 RTC_DCHECK(signaling_thread_->IsCurrent()); | 306 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 272 | 307 |
| 273 switch (pmsg->message_id) { | 308 switch (pmsg->message_id) { |
| 274 case MSG_ICECONNECTIONSTATE: { | 309 case MSG_ICECONNECTIONSTATE: { |
| 275 rtc::TypedMessageData<IceConnectionState>* data = | 310 rtc::TypedMessageData<IceConnectionState>* data = |
| 276 static_cast<rtc::TypedMessageData<IceConnectionState>*>(pmsg->pdata); | 311 static_cast<rtc::TypedMessageData<IceConnectionState>*>(pmsg->pdata); |
| 277 SignalConnectionState(data->data()); | 312 SignalConnectionState(data->data()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 297 SignalCandidatesGathered(data->transport_name, data->candidates); | 332 SignalCandidatesGathered(data->transport_name, data->candidates); |
| 298 delete data; | 333 delete data; |
| 299 break; | 334 break; |
| 300 } | 335 } |
| 301 default: | 336 default: |
| 302 ASSERT(false); | 337 ASSERT(false); |
| 303 } | 338 } |
| 304 } | 339 } |
| 305 | 340 |
| 306 std::vector<TransportController::RefCountedChannel>::iterator | 341 std::vector<TransportController::RefCountedChannel>::iterator |
| 307 TransportController::FindChannel_n(const std::string& transport_name, | 342 TransportController::GetChannelIterator_n(const std::string& transport_name, |
| 308 int component) { | 343 int component) { |
| 344 RTC_DCHECK(network_thread_->IsCurrent()); |
| 309 return std::find_if( | 345 return std::find_if( |
| 310 channels_.begin(), channels_.end(), | 346 channels_.begin(), channels_.end(), |
| 311 [transport_name, component](const RefCountedChannel& channel) { | 347 [transport_name, component](const RefCountedChannel& channel) { |
| 312 return channel->transport_name() == transport_name && | 348 return channel.dtls()->transport_name() == transport_name && |
| 313 channel->component() == component; | 349 channel.dtls()->component() == component; |
| 314 }); | 350 }); |
| 315 } | 351 } |
| 316 | 352 |
| 317 Transport* TransportController::GetOrCreateTransport_n( | 353 std::vector<TransportController::RefCountedChannel>::const_iterator |
| 354 TransportController::GetChannelIterator_n(const std::string& transport_name, |
| 355 int component) const { |
| 356 RTC_DCHECK(network_thread_->IsCurrent()); |
| 357 return std::find_if( |
| 358 channels_.begin(), channels_.end(), |
| 359 [transport_name, component](const RefCountedChannel& channel) { |
| 360 return channel.dtls()->transport_name() == transport_name && |
| 361 channel.dtls()->component() == component; |
| 362 }); |
| 363 } |
| 364 |
| 365 const JsepTransport* TransportController::GetJsepTransport_n( |
| 366 const std::string& transport_name) const { |
| 367 RTC_DCHECK(network_thread_->IsCurrent()); |
| 368 auto it = transports_.find(transport_name); |
| 369 return (it == transports_.end()) ? nullptr : it->second.get(); |
| 370 } |
| 371 |
| 372 JsepTransport* TransportController::GetJsepTransport_n( |
| 373 const std::string& transport_name) { |
| 374 RTC_DCHECK(network_thread_->IsCurrent()); |
| 375 auto it = transports_.find(transport_name); |
| 376 return (it == transports_.end()) ? nullptr : it->second.get(); |
| 377 } |
| 378 |
| 379 const TransportController::RefCountedChannel* TransportController::GetChannel_n( |
| 380 const std::string& transport_name, |
| 381 int component) const { |
| 382 RTC_DCHECK(network_thread_->IsCurrent()); |
| 383 auto it = GetChannelIterator_n(transport_name, component); |
| 384 return (it == channels_.end()) ? nullptr : &(*it); |
| 385 } |
| 386 |
| 387 TransportController::RefCountedChannel* TransportController::GetChannel_n( |
| 388 const std::string& transport_name, |
| 389 int component) { |
| 390 RTC_DCHECK(network_thread_->IsCurrent()); |
| 391 auto it = GetChannelIterator_n(transport_name, component); |
| 392 return (it == channels_.end()) ? nullptr : &(*it); |
| 393 } |
| 394 |
| 395 JsepTransport* TransportController::GetOrCreateJsepTransport_n( |
| 318 const std::string& transport_name) { | 396 const std::string& transport_name) { |
| 319 RTC_DCHECK(network_thread_->IsCurrent()); | 397 RTC_DCHECK(network_thread_->IsCurrent()); |
| 320 | 398 |
| 321 Transport* transport = GetTransport_n(transport_name); | 399 JsepTransport* transport = GetJsepTransport_n(transport_name); |
| 322 if (transport) { | 400 if (transport) { |
| 323 return transport; | 401 return transport; |
| 324 } | 402 } |
| 325 | 403 |
| 326 transport = CreateTransport_n(transport_name); | 404 transport = new JsepTransport(transport_name, certificate_); |
| 327 // The stuff below happens outside of CreateTransport_w so that unit tests | 405 transports_[transport_name] = std::unique_ptr<JsepTransport>(transport); |
| 328 // can override CreateTransport_w to return a different type of transport. | |
| 329 transport->SetSslMaxProtocolVersion(ssl_max_version_); | |
| 330 transport->SetIceConfig(ice_config_); | |
| 331 transport->SetIceRole(ice_role_); | |
| 332 transport->SetIceTiebreaker(ice_tiebreaker_); | |
| 333 if (certificate_) { | |
| 334 transport->SetLocalCertificate(certificate_); | |
| 335 } | |
| 336 transports_[transport_name] = transport; | |
| 337 | |
| 338 return transport; | 406 return transport; |
| 339 } | 407 } |
| 340 | 408 |
| 341 void TransportController::DestroyTransport_n( | 409 void TransportController::DestroyAllChannels_n() { |
| 342 const std::string& transport_name) { | |
| 343 RTC_DCHECK(network_thread_->IsCurrent()); | 410 RTC_DCHECK(network_thread_->IsCurrent()); |
| 344 | |
| 345 auto iter = transports_.find(transport_name); | |
| 346 if (iter != transports_.end()) { | |
| 347 delete iter->second; | |
| 348 transports_.erase(transport_name); | |
| 349 } | |
| 350 } | |
| 351 | |
| 352 void TransportController::DestroyAllTransports_n() { | |
| 353 RTC_DCHECK(network_thread_->IsCurrent()); | |
| 354 | |
| 355 for (const auto& kv : transports_) { | |
| 356 delete kv.second; | |
| 357 } | |
| 358 transports_.clear(); | 411 transports_.clear(); |
| 412 channels_.clear(); |
| 359 } | 413 } |
| 360 | 414 |
| 361 bool TransportController::SetSslMaxProtocolVersion_n( | 415 bool TransportController::SetSslMaxProtocolVersion_n( |
| 362 rtc::SSLProtocolVersion version) { | 416 rtc::SSLProtocolVersion version) { |
| 363 RTC_DCHECK(network_thread_->IsCurrent()); | 417 RTC_DCHECK(network_thread_->IsCurrent()); |
| 364 | 418 |
| 365 // Max SSL version can only be set before transports are created. | 419 // Max SSL version can only be set before transports are created. |
| 366 if (!transports_.empty()) { | 420 if (!transports_.empty()) { |
| 367 return false; | 421 return false; |
| 368 } | 422 } |
| 369 | 423 |
| 370 ssl_max_version_ = version; | 424 ssl_max_version_ = version; |
| 371 return true; | 425 return true; |
| 372 } | 426 } |
| 373 | 427 |
| 374 void TransportController::SetIceConfig_n(const IceConfig& config) { | 428 void TransportController::SetIceConfig_n(const IceConfig& config) { |
| 375 RTC_DCHECK(network_thread_->IsCurrent()); | 429 RTC_DCHECK(network_thread_->IsCurrent()); |
| 430 |
| 376 ice_config_ = config; | 431 ice_config_ = config; |
| 377 for (const auto& kv : transports_) { | 432 for (auto& channel : channels_) { |
| 378 kv.second->SetIceConfig(ice_config_); | 433 channel.dtls()->SetIceConfig(ice_config_); |
| 379 } | 434 } |
| 380 } | 435 } |
| 381 | 436 |
| 382 void TransportController::SetIceRole_n(IceRole ice_role) { | 437 void TransportController::SetIceRole_n(IceRole ice_role) { |
| 383 RTC_DCHECK(network_thread_->IsCurrent()); | 438 RTC_DCHECK(network_thread_->IsCurrent()); |
| 439 |
| 384 ice_role_ = ice_role; | 440 ice_role_ = ice_role; |
| 385 for (const auto& kv : transports_) { | 441 for (auto& channel : channels_) { |
| 386 kv.second->SetIceRole(ice_role_); | 442 channel.dtls()->SetIceRole(ice_role_); |
| 387 } | 443 } |
| 388 } | 444 } |
| 389 | 445 |
| 390 bool TransportController::GetSslRole_n(const std::string& transport_name, | 446 bool TransportController::GetSslRole_n(const std::string& transport_name, |
| 391 rtc::SSLRole* role) { | 447 rtc::SSLRole* role) const { |
| 392 RTC_DCHECK(network_thread_->IsCurrent()); | 448 RTC_DCHECK(network_thread_->IsCurrent()); |
| 393 | 449 |
| 394 Transport* t = GetTransport_n(transport_name); | 450 const JsepTransport* t = GetJsepTransport_n(transport_name); |
| 395 if (!t) { | 451 if (!t) { |
| 396 return false; | 452 return false; |
| 397 } | 453 } |
| 398 | 454 t->GetSslRole(role); |
| 399 return t->GetSslRole(role); | 455 return true; |
| 400 } | 456 } |
| 401 | 457 |
| 402 bool TransportController::SetLocalCertificate_n( | 458 bool TransportController::SetLocalCertificate_n( |
| 403 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { | 459 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { |
| 404 RTC_DCHECK(network_thread_->IsCurrent()); | 460 RTC_DCHECK(network_thread_->IsCurrent()); |
| 405 | 461 |
| 406 if (certificate_) { | 462 // Can't change a certificate, or set a null certificate. |
| 407 return false; | 463 if (certificate_ || !certificate) { |
| 408 } | |
| 409 if (!certificate) { | |
| 410 return false; | 464 return false; |
| 411 } | 465 } |
| 412 certificate_ = certificate; | 466 certificate_ = certificate; |
| 413 | 467 |
| 414 for (const auto& kv : transports_) { | 468 // Set certificate both for Transport, which verifies it matches the |
| 469 // fingerprint in SDP... |
| 470 for (auto& kv : transports_) { |
| 415 kv.second->SetLocalCertificate(certificate_); | 471 kv.second->SetLocalCertificate(certificate_); |
| 416 } | 472 } |
| 473 // ... and for the DTLS channel, which needs it for the DTLS handshake. |
| 474 for (auto& channel : channels_) { |
| 475 bool set_cert_success = channel.dtls()->SetLocalCertificate(certificate); |
| 476 RTC_DCHECK(set_cert_success); |
| 477 } |
| 417 return true; | 478 return true; |
| 418 } | 479 } |
| 419 | 480 |
| 420 bool TransportController::GetLocalCertificate_n( | 481 bool TransportController::GetLocalCertificate_n( |
| 421 const std::string& transport_name, | 482 const std::string& transport_name, |
| 422 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { | 483 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const { |
| 423 RTC_DCHECK(network_thread_->IsCurrent()); | 484 RTC_DCHECK(network_thread_->IsCurrent()); |
| 424 | 485 |
| 425 Transport* t = GetTransport_n(transport_name); | 486 const JsepTransport* t = GetJsepTransport_n(transport_name); |
| 426 if (!t) { | 487 if (!t) { |
| 427 return false; | 488 return false; |
| 428 } | 489 } |
| 429 | |
| 430 return t->GetLocalCertificate(certificate); | 490 return t->GetLocalCertificate(certificate); |
| 431 } | 491 } |
| 432 | 492 |
| 433 std::unique_ptr<rtc::SSLCertificate> | 493 std::unique_ptr<rtc::SSLCertificate> |
| 434 TransportController::GetRemoteSSLCertificate_n( | 494 TransportController::GetRemoteSSLCertificate_n( |
| 435 const std::string& transport_name) { | 495 const std::string& transport_name) const { |
| 436 RTC_DCHECK(network_thread_->IsCurrent()); | 496 RTC_DCHECK(network_thread_->IsCurrent()); |
| 437 | 497 |
| 438 Transport* t = GetTransport_n(transport_name); | 498 // Get the certificate from the RTP channel's DTLS handshake. Should be |
| 439 if (!t) { | 499 // identical to the RTCP channel's, since they were given the same remote |
| 500 // fingerprint. |
| 501 const RefCountedChannel* ch = GetChannel_n(transport_name, 1); |
| 502 if (!ch) { |
| 440 return nullptr; | 503 return nullptr; |
| 441 } | 504 } |
| 442 | 505 return ch->dtls()->GetRemoteSSLCertificate(); |
| 443 return t->GetRemoteSSLCertificate(); | |
| 444 } | 506 } |
| 445 | 507 |
| 446 bool TransportController::SetLocalTransportDescription_n( | 508 bool TransportController::SetLocalTransportDescription_n( |
| 447 const std::string& transport_name, | 509 const std::string& transport_name, |
| 448 const TransportDescription& tdesc, | 510 const TransportDescription& tdesc, |
| 449 ContentAction action, | 511 ContentAction action, |
| 450 std::string* err) { | 512 std::string* err) { |
| 451 RTC_DCHECK(network_thread_->IsCurrent()); | 513 RTC_DCHECK(network_thread_->IsCurrent()); |
| 452 | 514 |
| 453 Transport* transport = GetTransport_n(transport_name); | 515 JsepTransport* transport = GetJsepTransport_n(transport_name); |
| 454 if (!transport) { | 516 if (!transport) { |
| 455 // If we didn't find a transport, that's not an error; | 517 // If we didn't find a transport, that's not an error; |
| 456 // it could have been deleted as a result of bundling. | 518 // it could have been deleted as a result of bundling. |
| 457 // TODO(deadbeef): Make callers smarter so they won't attempt to set a | 519 // TODO(deadbeef): Make callers smarter so they won't attempt to set a |
| 458 // description on a deleted transport. | 520 // description on a deleted transport. |
| 459 return true; | 521 return true; |
| 460 } | 522 } |
| 461 | 523 |
| 462 // Older versions of Chrome expect the ICE role to be re-determined when an | 524 // Older versions of Chrome expect the ICE role to be re-determined when an |
| 463 // ICE restart occurs, and also don't perform conflict resolution correctly, | 525 // ICE restart occurs, and also don't perform conflict resolution correctly, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 479 return transport->SetLocalTransportDescription(tdesc, action, err); | 541 return transport->SetLocalTransportDescription(tdesc, action, err); |
| 480 } | 542 } |
| 481 | 543 |
| 482 bool TransportController::SetRemoteTransportDescription_n( | 544 bool TransportController::SetRemoteTransportDescription_n( |
| 483 const std::string& transport_name, | 545 const std::string& transport_name, |
| 484 const TransportDescription& tdesc, | 546 const TransportDescription& tdesc, |
| 485 ContentAction action, | 547 ContentAction action, |
| 486 std::string* err) { | 548 std::string* err) { |
| 487 RTC_DCHECK(network_thread_->IsCurrent()); | 549 RTC_DCHECK(network_thread_->IsCurrent()); |
| 488 | 550 |
| 489 Transport* transport = GetTransport_n(transport_name); | 551 // If our role is ICEROLE_CONTROLLED and the remote endpoint supports only |
| 552 // ice_lite, this local endpoint should take the CONTROLLING role. |
| 553 // TODO(deadbeef): This is a session-level attribute, so it really shouldn't |
| 554 // be in a TransportDescription in the first place... |
| 555 if (ice_role_ == ICEROLE_CONTROLLED && tdesc.ice_mode == ICEMODE_LITE) { |
| 556 SetIceRole_n(ICEROLE_CONTROLLING); |
| 557 } |
| 558 |
| 559 JsepTransport* transport = GetJsepTransport_n(transport_name); |
| 490 if (!transport) { | 560 if (!transport) { |
| 491 // If we didn't find a transport, that's not an error; | 561 // If we didn't find a transport, that's not an error; |
| 492 // it could have been deleted as a result of bundling. | 562 // it could have been deleted as a result of bundling. |
| 493 // TODO(deadbeef): Make callers smarter so they won't attempt to set a | 563 // TODO(deadbeef): Make callers smarter so they won't attempt to set a |
| 494 // description on a deleted transport. | 564 // description on a deleted transport. |
| 495 return true; | 565 return true; |
| 496 } | 566 } |
| 497 | 567 |
| 498 LOG(LS_INFO) << "Set remote transport description on " << transport_name; | 568 LOG(LS_INFO) << "Set remote transport description on " << transport_name; |
| 499 return transport->SetRemoteTransportDescription(tdesc, action, err); | 569 return transport->SetRemoteTransportDescription(tdesc, action, err); |
| 500 } | 570 } |
| 501 | 571 |
| 502 void TransportController::MaybeStartGathering_n() { | 572 void TransportController::MaybeStartGathering_n() { |
| 503 for (const auto& kv : transports_) { | 573 for (auto& channel : channels_) { |
| 504 kv.second->MaybeStartGathering(); | 574 channel.dtls()->MaybeStartGathering(); |
| 505 } | 575 } |
| 506 } | 576 } |
| 507 | 577 |
| 508 bool TransportController::AddRemoteCandidates_n( | 578 bool TransportController::AddRemoteCandidates_n( |
| 509 const std::string& transport_name, | 579 const std::string& transport_name, |
| 510 const Candidates& candidates, | 580 const Candidates& candidates, |
| 511 std::string* err) { | 581 std::string* err) { |
| 512 RTC_DCHECK(network_thread_->IsCurrent()); | 582 RTC_DCHECK(network_thread_->IsCurrent()); |
| 513 | 583 |
| 514 Transport* transport = GetTransport_n(transport_name); | 584 // Verify each candidate before passing down to the transport layer. |
| 585 if (!VerifyCandidates(candidates, err)) { |
| 586 return false; |
| 587 } |
| 588 |
| 589 JsepTransport* transport = GetJsepTransport_n(transport_name); |
| 515 if (!transport) { | 590 if (!transport) { |
| 516 // If we didn't find a transport, that's not an error; | 591 // If we didn't find a transport, that's not an error; |
| 517 // it could have been deleted as a result of bundling. | 592 // it could have been deleted as a result of bundling. |
| 518 return true; | 593 return true; |
| 519 } | 594 } |
| 520 | 595 |
| 521 return transport->AddRemoteCandidates(candidates, err); | 596 for (const Candidate& candidate : candidates) { |
| 597 RefCountedChannel* channel = |
| 598 GetChannel_n(transport_name, candidate.component()); |
| 599 if (!channel) { |
| 600 *err = "Candidate has an unknown component: " + candidate.ToString() + |
| 601 " for content: " + transport_name; |
| 602 return false; |
| 603 } |
| 604 channel->dtls()->AddRemoteCandidate(candidate); |
| 605 } |
| 606 return true; |
| 522 } | 607 } |
| 523 | 608 |
| 524 bool TransportController::RemoveRemoteCandidates_n(const Candidates& candidates, | 609 bool TransportController::RemoveRemoteCandidates_n(const Candidates& candidates, |
| 525 std::string* err) { | 610 std::string* err) { |
| 526 RTC_DCHECK(network_thread_->IsCurrent()); | 611 RTC_DCHECK(network_thread_->IsCurrent()); |
| 612 |
| 613 // Verify each candidate before passing down to the transport layer. |
| 614 if (!VerifyCandidates(candidates, err)) { |
| 615 return false; |
| 616 } |
| 617 |
| 527 std::map<std::string, Candidates> candidates_by_transport_name; | 618 std::map<std::string, Candidates> candidates_by_transport_name; |
| 528 for (const Candidate& cand : candidates) { | 619 for (const Candidate& cand : candidates) { |
| 529 RTC_DCHECK(!cand.transport_name().empty()); | 620 RTC_DCHECK(!cand.transport_name().empty()); |
| 530 candidates_by_transport_name[cand.transport_name()].push_back(cand); | 621 candidates_by_transport_name[cand.transport_name()].push_back(cand); |
| 531 } | 622 } |
| 532 | 623 |
| 533 bool result = true; | 624 bool result = true; |
| 534 for (auto kv : candidates_by_transport_name) { | 625 for (const auto& kv : candidates_by_transport_name) { |
| 535 Transport* transport = GetTransport_n(kv.first); | 626 const std::string& transport_name = kv.first; |
| 627 const Candidates& candidates = kv.second; |
| 628 JsepTransport* transport = GetJsepTransport_n(transport_name); |
| 536 if (!transport) { | 629 if (!transport) { |
| 537 // If we didn't find a transport, that's not an error; | 630 // If we didn't find a transport, that's not an error; |
| 538 // it could have been deleted as a result of bundling. | 631 // it could have been deleted as a result of bundling. |
| 539 continue; | 632 continue; |
| 540 } | 633 } |
| 541 result &= transport->RemoveRemoteCandidates(kv.second, err); | 634 for (const Candidate& candidate : candidates) { |
| 635 RefCountedChannel* channel = |
| 636 GetChannel_n(transport_name, candidate.component()); |
| 637 if (channel) { |
| 638 channel->dtls()->RemoveRemoteCandidate(candidate); |
| 639 } |
| 640 } |
| 542 } | 641 } |
| 543 return result; | 642 return result; |
| 544 } | 643 } |
| 545 | 644 |
| 546 bool TransportController::ReadyForRemoteCandidates_n( | 645 bool TransportController::ReadyForRemoteCandidates_n( |
| 547 const std::string& transport_name) { | 646 const std::string& transport_name) const { |
| 548 RTC_DCHECK(network_thread_->IsCurrent()); | 647 RTC_DCHECK(network_thread_->IsCurrent()); |
| 549 | 648 |
| 550 Transport* transport = GetTransport_n(transport_name); | 649 const JsepTransport* transport = GetJsepTransport_n(transport_name); |
| 551 if (!transport) { | 650 if (!transport) { |
| 552 return false; | 651 return false; |
| 553 } | 652 } |
| 554 return transport->ready_for_remote_candidates(); | 653 return transport->ready_for_remote_candidates(); |
| 555 } | 654 } |
| 556 | 655 |
| 557 bool TransportController::GetStats_n(const std::string& transport_name, | 656 bool TransportController::GetStats_n(const std::string& transport_name, |
| 558 TransportStats* stats) { | 657 TransportStats* stats) { |
| 559 RTC_DCHECK(network_thread_->IsCurrent()); | 658 RTC_DCHECK(network_thread_->IsCurrent()); |
| 560 | 659 |
| 561 Transport* transport = GetTransport_n(transport_name); | 660 JsepTransport* transport = GetJsepTransport_n(transport_name); |
| 562 if (!transport) { | 661 if (!transport) { |
| 563 return false; | 662 return false; |
| 564 } | 663 } |
| 565 return transport->GetStats(stats); | 664 return transport->GetStats(stats); |
| 566 } | 665 } |
| 567 | 666 |
| 667 void TransportController::SetMetricsObserver_n( |
| 668 webrtc::MetricsObserverInterface* metrics_observer) { |
| 669 RTC_DCHECK(network_thread_->IsCurrent()); |
| 670 metrics_observer_ = metrics_observer; |
| 671 for (auto& channel : channels_) { |
| 672 channel.dtls()->SetMetricsObserver(metrics_observer); |
| 673 } |
| 674 } |
| 675 |
| 568 void TransportController::OnChannelWritableState_n( | 676 void TransportController::OnChannelWritableState_n( |
| 569 rtc::PacketTransportInterface* transport) { | 677 rtc::PacketTransportInterface* transport) { |
| 570 RTC_DCHECK(network_thread_->IsCurrent()); | 678 RTC_DCHECK(network_thread_->IsCurrent()); |
| 571 LOG(LS_INFO) << " TransportChannel " << transport->debug_name() | 679 LOG(LS_INFO) << " TransportChannel " << transport->debug_name() |
| 572 << " writability changed to " << transport->writable() << "."; | 680 << " writability changed to " << transport->writable() << "."; |
| 573 UpdateAggregateStates_n(); | 681 UpdateAggregateStates_n(); |
| 574 } | 682 } |
| 575 | 683 |
| 576 void TransportController::OnChannelReceivingState_n( | 684 void TransportController::OnChannelReceivingState_n( |
| 577 rtc::PacketTransportInterface* transport) { | 685 rtc::PacketTransportInterface* transport) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 755 |
| 648 IceConnectionState new_connection_state = kIceConnectionConnecting; | 756 IceConnectionState new_connection_state = kIceConnectionConnecting; |
| 649 IceGatheringState new_gathering_state = kIceGatheringNew; | 757 IceGatheringState new_gathering_state = kIceGatheringNew; |
| 650 bool any_receiving = false; | 758 bool any_receiving = false; |
| 651 bool any_failed = false; | 759 bool any_failed = false; |
| 652 bool all_connected = !channels_.empty(); | 760 bool all_connected = !channels_.empty(); |
| 653 bool all_completed = !channels_.empty(); | 761 bool all_completed = !channels_.empty(); |
| 654 bool any_gathering = false; | 762 bool any_gathering = false; |
| 655 bool all_done_gathering = !channels_.empty(); | 763 bool all_done_gathering = !channels_.empty(); |
| 656 for (const auto& channel : channels_) { | 764 for (const auto& channel : channels_) { |
| 657 any_receiving = any_receiving || channel->receiving(); | 765 any_receiving = any_receiving || channel.dtls()->receiving(); |
| 658 any_failed = any_failed || | 766 any_failed = |
| 659 channel->GetState() == TransportChannelState::STATE_FAILED; | 767 any_failed || |
| 660 all_connected = all_connected && channel->writable(); | 768 channel.dtls()->GetState() == TransportChannelState::STATE_FAILED; |
| 769 all_connected = all_connected && channel.dtls()->writable(); |
| 661 all_completed = | 770 all_completed = |
| 662 all_completed && channel->writable() && | 771 all_completed && channel.dtls()->writable() && |
| 663 channel->GetState() == TransportChannelState::STATE_COMPLETED && | 772 channel.dtls()->GetState() == TransportChannelState::STATE_COMPLETED && |
| 664 channel->GetIceRole() == ICEROLE_CONTROLLING && | 773 channel.dtls()->GetIceRole() == ICEROLE_CONTROLLING && |
| 665 channel->gathering_state() == kIceGatheringComplete; | 774 channel.dtls()->gathering_state() == kIceGatheringComplete; |
| 666 any_gathering = | 775 any_gathering = |
| 667 any_gathering || channel->gathering_state() != kIceGatheringNew; | 776 any_gathering || channel.dtls()->gathering_state() != kIceGatheringNew; |
| 668 all_done_gathering = all_done_gathering && | 777 all_done_gathering = |
| 669 channel->gathering_state() == kIceGatheringComplete; | 778 all_done_gathering && |
| 779 channel.dtls()->gathering_state() == kIceGatheringComplete; |
| 670 } | 780 } |
| 671 | 781 |
| 672 if (any_failed) { | 782 if (any_failed) { |
| 673 new_connection_state = kIceConnectionFailed; | 783 new_connection_state = kIceConnectionFailed; |
| 674 } else if (all_completed) { | 784 } else if (all_completed) { |
| 675 new_connection_state = kIceConnectionCompleted; | 785 new_connection_state = kIceConnectionCompleted; |
| 676 } else if (all_connected) { | 786 } else if (all_connected) { |
| 677 new_connection_state = kIceConnectionConnected; | 787 new_connection_state = kIceConnectionConnected; |
| 678 } | 788 } |
| 679 if (connection_state_ != new_connection_state) { | 789 if (connection_state_ != new_connection_state) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 699 signaling_thread_->Post( | 809 signaling_thread_->Post( |
| 700 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, | 810 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, |
| 701 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); | 811 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); |
| 702 } | 812 } |
| 703 } | 813 } |
| 704 | 814 |
| 705 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 815 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
| 706 SignalDtlsHandshakeError(error); | 816 SignalDtlsHandshakeError(error); |
| 707 } | 817 } |
| 708 | 818 |
| 709 void TransportController::SetMetricsObserver( | |
| 710 webrtc::MetricsObserverInterface* metrics_observer) { | |
| 711 metrics_observer_ = metrics_observer; | |
| 712 for (auto channel : channels_) { | |
| 713 channel->SetMetricsObserver(metrics_observer); | |
| 714 } | |
| 715 } | |
| 716 | |
| 717 } // namespace cricket | 819 } // namespace cricket |
| OLD | NEW |