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/port.h" | 19 #include "webrtc/p2p/base/port.h" |
20 | 20 |
21 namespace cricket { | 21 namespace { |
22 | 22 |
23 enum { | 23 enum { |
24 MSG_ICECONNECTIONSTATE, | 24 MSG_ICECONNECTIONSTATE, |
25 MSG_RECEIVING, | 25 MSG_RECEIVING, |
26 MSG_ICEGATHERINGSTATE, | 26 MSG_ICEGATHERINGSTATE, |
27 MSG_CANDIDATESGATHERED, | 27 MSG_CANDIDATESGATHERED, |
28 }; | 28 }; |
29 | 29 |
30 struct CandidatesData : public rtc::MessageData { | 30 struct CandidatesData : public rtc::MessageData { |
31 CandidatesData(const std::string& transport_name, | 31 CandidatesData(const std::string& transport_name, |
32 const Candidates& candidates) | 32 const cricket::Candidates& candidates) |
33 : transport_name(transport_name), candidates(candidates) {} | 33 : transport_name(transport_name), candidates(candidates) {} |
34 | 34 |
35 std::string transport_name; | 35 std::string transport_name; |
36 Candidates candidates; | 36 cricket::Candidates candidates; |
37 }; | |
38 | |
39 } // namespace { | |
honghaiz3
2016/12/14 01:20:00
No left bracket.
| |
40 | |
41 namespace cricket { | |
42 | |
43 // This class groups the DTLS and ICE channels, and helps keep track of | |
44 // how many external objects (BaseChannels) reference each channel. | |
45 class TransportController::ChannelPair { | |
46 public: | |
47 // TODO(deadbeef): Change the types of |dtls| and |ice| to | |
48 // DtlsTransportChannelWrapper and P2PTransportChannelWrapper, | |
49 // once TransportChannelImpl is removed. | |
50 ChannelPair(TransportChannelImpl* dtls, TransportChannelImpl* ice) | |
51 : ice_(ice), dtls_(dtls) {} | |
52 | |
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 | |
55 // channel interface no longer includes ICE-specific methods. | |
56 const TransportChannelImpl* dtls() const { return dtls_.get(); } | |
57 TransportChannelImpl* dtls() { return dtls_.get(); } | |
58 const TransportChannelImpl* ice() const { return ice_.get(); } | |
59 TransportChannelImpl* ice() { return ice_.get(); } | |
60 | |
61 private: | |
62 std::unique_ptr<TransportChannelImpl> ice_; | |
63 std::unique_ptr<TransportChannelImpl> dtls_; | |
64 | |
65 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelPair); | |
37 }; | 66 }; |
38 | 67 |
39 TransportController::TransportController(rtc::Thread* signaling_thread, | 68 TransportController::TransportController(rtc::Thread* signaling_thread, |
40 rtc::Thread* network_thread, | 69 rtc::Thread* network_thread, |
41 PortAllocator* port_allocator, | 70 PortAllocator* port_allocator, |
42 bool redetermine_role_on_ice_restart) | 71 bool redetermine_role_on_ice_restart) |
43 : signaling_thread_(signaling_thread), | 72 : signaling_thread_(signaling_thread), |
44 network_thread_(network_thread), | 73 network_thread_(network_thread), |
45 port_allocator_(port_allocator), | 74 port_allocator_(port_allocator), |
46 redetermine_role_on_ice_restart_(redetermine_role_on_ice_restart) {} | 75 redetermine_role_on_ice_restart_(redetermine_role_on_ice_restart) {} |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 dtls->SignalCandidateGathered.connect( | 262 dtls->SignalCandidateGathered.connect( |
234 this, &TransportController::OnChannelCandidateGathered_n); | 263 this, &TransportController::OnChannelCandidateGathered_n); |
235 dtls->SignalCandidatesRemoved.connect( | 264 dtls->SignalCandidatesRemoved.connect( |
236 this, &TransportController::OnChannelCandidatesRemoved_n); | 265 this, &TransportController::OnChannelCandidatesRemoved_n); |
237 dtls->SignalRoleConflict.connect( | 266 dtls->SignalRoleConflict.connect( |
238 this, &TransportController::OnChannelRoleConflict_n); | 267 this, &TransportController::OnChannelRoleConflict_n); |
239 dtls->SignalStateChanged.connect( | 268 dtls->SignalStateChanged.connect( |
240 this, &TransportController::OnChannelStateChanged_n); | 269 this, &TransportController::OnChannelStateChanged_n); |
241 dtls->SignalDtlsHandshakeError.connect( | 270 dtls->SignalDtlsHandshakeError.connect( |
242 this, &TransportController::OnDtlsHandshakeError); | 271 this, &TransportController::OnDtlsHandshakeError); |
243 channels_.insert(channels_.end(), RefCountedChannel(dtls, ice))->AddRef(); | 272 RefCountedChannel* new_pair = new RefCountedChannel(dtls, ice); |
273 new_pair->AddRef(); | |
274 channels_.insert(channels_.end(), new_pair); | |
244 bool channel_added = transport->AddChannel(dtls, component); | 275 bool channel_added = transport->AddChannel(dtls, component); |
245 RTC_DCHECK(channel_added); | 276 RTC_DCHECK(channel_added); |
246 // Adding a channel could cause aggregate state to change. | 277 // Adding a channel could cause aggregate state to change. |
247 UpdateAggregateStates_n(); | 278 UpdateAggregateStates_n(); |
248 return dtls; | 279 return dtls; |
249 } | 280 } |
250 | 281 |
251 void TransportController::DestroyTransportChannel_n( | 282 void TransportController::DestroyTransportChannel_n( |
252 const std::string& transport_name, | 283 const std::string& transport_name, |
253 int component) { | 284 int component) { |
254 RTC_DCHECK(network_thread_->IsCurrent()); | 285 RTC_DCHECK(network_thread_->IsCurrent()); |
255 | 286 |
256 auto it = GetChannelIterator_n(transport_name, component); | 287 auto it = GetChannelIterator_n(transport_name, component); |
257 if (it == channels_.end()) { | 288 if (it == channels_.end()) { |
258 LOG(LS_WARNING) << "Attempting to delete " << transport_name | 289 LOG(LS_WARNING) << "Attempting to delete " << transport_name |
259 << " TransportChannel " << component | 290 << " TransportChannel " << component |
260 << ", which doesn't exist."; | 291 << ", which doesn't exist."; |
261 return; | 292 return; |
262 } | 293 } |
263 it->DecRef(); | 294 if ((*it)->Release() > 0) { |
264 if (it->ref() > 0) { | |
265 return; | 295 return; |
266 } | 296 } |
267 channels_.erase(it); | 297 channels_.erase(it); |
268 | 298 |
269 JsepTransport* t = GetJsepTransport(transport_name); | 299 JsepTransport* t = GetJsepTransport(transport_name); |
270 bool channel_removed = t->RemoveChannel(component); | 300 bool channel_removed = t->RemoveChannel(component); |
271 RTC_DCHECK(channel_removed); | 301 RTC_DCHECK(channel_removed); |
272 // Just as we create a Transport when its first channel is created, | 302 // Just as we create a Transport when its first channel is created, |
273 // we delete it when its last channel is deleted. | 303 // we delete it when its last channel is deleted. |
274 if (!t->HasChannels()) { | 304 if (!t->HasChannels()) { |
275 transports_.erase(transport_name); | 305 transports_.erase(transport_name); |
276 } | 306 } |
277 | 307 |
278 // Removing a channel could cause aggregate state to change. | 308 // Removing a channel could cause aggregate state to change. |
279 UpdateAggregateStates_n(); | 309 UpdateAggregateStates_n(); |
280 } | 310 } |
281 | 311 |
282 std::vector<std::string> TransportController::transport_names_for_testing() { | 312 std::vector<std::string> TransportController::transport_names_for_testing() { |
283 std::vector<std::string> ret; | 313 std::vector<std::string> ret; |
284 for (const auto& kv : transports_) { | 314 for (const auto& kv : transports_) { |
285 ret.push_back(kv.first); | 315 ret.push_back(kv.first); |
286 } | 316 } |
287 return ret; | 317 return ret; |
288 } | 318 } |
289 | 319 |
290 std::vector<TransportChannelImpl*> TransportController::channels_for_testing() { | 320 std::vector<TransportChannelImpl*> TransportController::channels_for_testing() { |
291 std::vector<TransportChannelImpl*> ret; | 321 std::vector<TransportChannelImpl*> ret; |
292 for (RefCountedChannel& channel : channels_) { | 322 for (RefCountedChannel* channel : channels_) { |
293 ret.push_back(channel.dtls()); | 323 ret.push_back(channel->dtls()); |
294 } | 324 } |
295 return ret; | 325 return ret; |
296 } | 326 } |
297 | 327 |
298 TransportChannelImpl* TransportController::get_channel_for_testing( | 328 TransportChannelImpl* TransportController::get_channel_for_testing( |
299 const std::string& transport_name, | 329 const std::string& transport_name, |
300 int component) { | 330 int component) { |
301 RefCountedChannel* ch = GetChannel_n(transport_name, component); | 331 RefCountedChannel* ch = GetChannel_n(transport_name, component); |
302 return ch ? ch->dtls() : nullptr; | 332 return ch ? ch->dtls() : nullptr; |
303 } | 333 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 CandidatesData* data = static_cast<CandidatesData*>(pmsg->pdata); | 376 CandidatesData* data = static_cast<CandidatesData*>(pmsg->pdata); |
347 SignalCandidatesGathered(data->transport_name, data->candidates); | 377 SignalCandidatesGathered(data->transport_name, data->candidates); |
348 delete data; | 378 delete data; |
349 break; | 379 break; |
350 } | 380 } |
351 default: | 381 default: |
352 ASSERT(false); | 382 ASSERT(false); |
353 } | 383 } |
354 } | 384 } |
355 | 385 |
356 std::vector<TransportController::RefCountedChannel>::iterator | 386 std::vector<TransportController::RefCountedChannel*>::iterator |
357 TransportController::GetChannelIterator_n(const std::string& transport_name, | 387 TransportController::GetChannelIterator_n(const std::string& transport_name, |
358 int component) { | 388 int component) { |
359 RTC_DCHECK(network_thread_->IsCurrent()); | 389 RTC_DCHECK(network_thread_->IsCurrent()); |
360 return std::find_if( | 390 return std::find_if(channels_.begin(), channels_.end(), |
361 channels_.begin(), channels_.end(), | 391 [transport_name, component](RefCountedChannel* channel) { |
362 [transport_name, component](const RefCountedChannel& channel) { | 392 return channel->dtls()->transport_name() == |
363 return channel.dtls()->transport_name() == transport_name && | 393 transport_name && |
364 channel.dtls()->component() == component; | 394 channel->dtls()->component() == component; |
365 }); | 395 }); |
366 } | 396 } |
367 | 397 |
368 std::vector<TransportController::RefCountedChannel>::const_iterator | 398 std::vector<TransportController::RefCountedChannel*>::const_iterator |
369 TransportController::GetChannelIterator_n(const std::string& transport_name, | 399 TransportController::GetChannelIterator_n(const std::string& transport_name, |
370 int component) const { | 400 int component) const { |
371 RTC_DCHECK(network_thread_->IsCurrent()); | 401 RTC_DCHECK(network_thread_->IsCurrent()); |
372 return std::find_if( | 402 return std::find_if( |
373 channels_.begin(), channels_.end(), | 403 channels_.begin(), channels_.end(), |
374 [transport_name, component](const RefCountedChannel& channel) { | 404 [transport_name, component](const RefCountedChannel* channel) { |
375 return channel.dtls()->transport_name() == transport_name && | 405 return channel->dtls()->transport_name() == transport_name && |
376 channel.dtls()->component() == component; | 406 channel->dtls()->component() == component; |
377 }); | 407 }); |
378 } | 408 } |
379 | 409 |
380 const JsepTransport* TransportController::GetJsepTransport( | 410 const JsepTransport* TransportController::GetJsepTransport( |
381 const std::string& transport_name) const { | 411 const std::string& transport_name) const { |
382 auto it = transports_.find(transport_name); | 412 auto it = transports_.find(transport_name); |
383 return (it == transports_.end()) ? nullptr : it->second.get(); | 413 return (it == transports_.end()) ? nullptr : it->second.get(); |
384 } | 414 } |
385 | 415 |
386 JsepTransport* TransportController::GetJsepTransport( | 416 JsepTransport* TransportController::GetJsepTransport( |
387 const std::string& transport_name) { | 417 const std::string& transport_name) { |
388 auto it = transports_.find(transport_name); | 418 auto it = transports_.find(transport_name); |
389 return (it == transports_.end()) ? nullptr : it->second.get(); | 419 return (it == transports_.end()) ? nullptr : it->second.get(); |
390 } | 420 } |
391 | 421 |
392 const TransportController::RefCountedChannel* TransportController::GetChannel_n( | 422 const TransportController::RefCountedChannel* TransportController::GetChannel_n( |
393 const std::string& transport_name, | 423 const std::string& transport_name, |
394 int component) const { | 424 int component) const { |
395 RTC_DCHECK(network_thread_->IsCurrent()); | 425 RTC_DCHECK(network_thread_->IsCurrent()); |
396 auto it = GetChannelIterator_n(transport_name, component); | 426 auto it = GetChannelIterator_n(transport_name, component); |
397 return (it == channels_.end()) ? nullptr : &(*it); | 427 return (it == channels_.end()) ? nullptr : *it; |
398 } | 428 } |
399 | 429 |
400 TransportController::RefCountedChannel* TransportController::GetChannel_n( | 430 TransportController::RefCountedChannel* TransportController::GetChannel_n( |
401 const std::string& transport_name, | 431 const std::string& transport_name, |
402 int component) { | 432 int component) { |
403 RTC_DCHECK(network_thread_->IsCurrent()); | 433 RTC_DCHECK(network_thread_->IsCurrent()); |
404 auto it = GetChannelIterator_n(transport_name, component); | 434 auto it = GetChannelIterator_n(transport_name, component); |
405 return (it == channels_.end()) ? nullptr : &(*it); | 435 return (it == channels_.end()) ? nullptr : *it; |
406 } | 436 } |
407 | 437 |
408 JsepTransport* TransportController::GetOrCreateJsepTransport( | 438 JsepTransport* TransportController::GetOrCreateJsepTransport( |
409 const std::string& transport_name) { | 439 const std::string& transport_name) { |
410 RTC_DCHECK(network_thread_->IsCurrent()); | 440 RTC_DCHECK(network_thread_->IsCurrent()); |
411 | 441 |
412 JsepTransport* transport = GetJsepTransport(transport_name); | 442 JsepTransport* transport = GetJsepTransport(transport_name); |
413 if (transport) { | 443 if (transport) { |
414 return transport; | 444 return transport; |
415 } | 445 } |
416 | 446 |
417 transport = new JsepTransport(transport_name, certificate_); | 447 transport = new JsepTransport(transport_name, certificate_); |
418 transports_[transport_name] = std::unique_ptr<JsepTransport>(transport); | 448 transports_[transport_name] = std::unique_ptr<JsepTransport>(transport); |
419 return transport; | 449 return transport; |
420 } | 450 } |
421 | 451 |
422 void TransportController::DestroyAllChannels_n() { | 452 void TransportController::DestroyAllChannels_n() { |
423 RTC_DCHECK(network_thread_->IsCurrent()); | 453 RTC_DCHECK(network_thread_->IsCurrent()); |
424 transports_.clear(); | 454 transports_.clear(); |
455 for (RefCountedChannel* channel : channels_) { | |
456 // Even though these objects are normally ref-counted, if | |
457 // TransportController is deleted while they still have references, just | |
458 // remove all references. | |
459 while (channel->Release() > 0) { | |
460 } | |
461 } | |
425 channels_.clear(); | 462 channels_.clear(); |
426 } | 463 } |
427 | 464 |
428 bool TransportController::SetSslMaxProtocolVersion_n( | 465 bool TransportController::SetSslMaxProtocolVersion_n( |
429 rtc::SSLProtocolVersion version) { | 466 rtc::SSLProtocolVersion version) { |
430 RTC_DCHECK(network_thread_->IsCurrent()); | 467 RTC_DCHECK(network_thread_->IsCurrent()); |
431 | 468 |
432 // Max SSL version can only be set before transports are created. | 469 // Max SSL version can only be set before transports are created. |
433 if (!transports_.empty()) { | 470 if (!transports_.empty()) { |
434 return false; | 471 return false; |
435 } | 472 } |
436 | 473 |
437 ssl_max_version_ = version; | 474 ssl_max_version_ = version; |
438 return true; | 475 return true; |
439 } | 476 } |
440 | 477 |
441 void TransportController::SetIceConfig_n(const IceConfig& config) { | 478 void TransportController::SetIceConfig_n(const IceConfig& config) { |
442 RTC_DCHECK(network_thread_->IsCurrent()); | 479 RTC_DCHECK(network_thread_->IsCurrent()); |
443 | 480 |
444 ice_config_ = config; | 481 ice_config_ = config; |
445 for (auto& channel : channels_) { | 482 for (auto& channel : channels_) { |
446 channel.dtls()->SetIceConfig(ice_config_); | 483 channel->dtls()->SetIceConfig(ice_config_); |
447 } | 484 } |
448 } | 485 } |
449 | 486 |
450 void TransportController::SetIceRole_n(IceRole ice_role) { | 487 void TransportController::SetIceRole_n(IceRole ice_role) { |
451 RTC_DCHECK(network_thread_->IsCurrent()); | 488 RTC_DCHECK(network_thread_->IsCurrent()); |
452 | 489 |
453 ice_role_ = ice_role; | 490 ice_role_ = ice_role; |
454 for (auto& channel : channels_) { | 491 for (auto& channel : channels_) { |
455 channel.dtls()->SetIceRole(ice_role_); | 492 channel->dtls()->SetIceRole(ice_role_); |
456 } | 493 } |
457 } | 494 } |
458 | 495 |
459 bool TransportController::GetSslRole_n(const std::string& transport_name, | 496 bool TransportController::GetSslRole_n(const std::string& transport_name, |
460 rtc::SSLRole* role) const { | 497 rtc::SSLRole* role) const { |
461 RTC_DCHECK(network_thread_->IsCurrent()); | 498 RTC_DCHECK(network_thread_->IsCurrent()); |
462 | 499 |
463 const JsepTransport* t = GetJsepTransport(transport_name); | 500 const JsepTransport* t = GetJsepTransport(transport_name); |
464 if (!t) { | 501 if (!t) { |
465 return false; | 502 return false; |
(...skipping 12 matching lines...) Expand all Loading... | |
478 } | 515 } |
479 certificate_ = certificate; | 516 certificate_ = certificate; |
480 | 517 |
481 // Set certificate both for Transport, which verifies it matches the | 518 // Set certificate both for Transport, which verifies it matches the |
482 // fingerprint in SDP... | 519 // fingerprint in SDP... |
483 for (auto& kv : transports_) { | 520 for (auto& kv : transports_) { |
484 kv.second->SetLocalCertificate(certificate_); | 521 kv.second->SetLocalCertificate(certificate_); |
485 } | 522 } |
486 // ... and for the DTLS channel, which needs it for the DTLS handshake. | 523 // ... and for the DTLS channel, which needs it for the DTLS handshake. |
487 for (auto& channel : channels_) { | 524 for (auto& channel : channels_) { |
488 bool set_cert_success = channel.dtls()->SetLocalCertificate(certificate); | 525 bool set_cert_success = channel->dtls()->SetLocalCertificate(certificate); |
489 RTC_DCHECK(set_cert_success); | 526 RTC_DCHECK(set_cert_success); |
490 } | 527 } |
491 return true; | 528 return true; |
492 } | 529 } |
493 | 530 |
494 bool TransportController::GetLocalCertificate_n( | 531 bool TransportController::GetLocalCertificate_n( |
495 const std::string& transport_name, | 532 const std::string& transport_name, |
496 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const { | 533 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const { |
497 RTC_DCHECK(network_thread_->IsCurrent()); | 534 RTC_DCHECK(network_thread_->IsCurrent()); |
498 | 535 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 // description on a deleted transport. | 614 // description on a deleted transport. |
578 return true; | 615 return true; |
579 } | 616 } |
580 | 617 |
581 LOG(LS_INFO) << "Set remote transport description on " << transport_name; | 618 LOG(LS_INFO) << "Set remote transport description on " << transport_name; |
582 return transport->SetRemoteTransportDescription(tdesc, action, err); | 619 return transport->SetRemoteTransportDescription(tdesc, action, err); |
583 } | 620 } |
584 | 621 |
585 void TransportController::MaybeStartGathering_n() { | 622 void TransportController::MaybeStartGathering_n() { |
586 for (auto& channel : channels_) { | 623 for (auto& channel : channels_) { |
587 channel.dtls()->MaybeStartGathering(); | 624 channel->dtls()->MaybeStartGathering(); |
588 } | 625 } |
589 } | 626 } |
590 | 627 |
591 bool TransportController::AddRemoteCandidates_n( | 628 bool TransportController::AddRemoteCandidates_n( |
592 const std::string& transport_name, | 629 const std::string& transport_name, |
593 const Candidates& candidates, | 630 const Candidates& candidates, |
594 std::string* err) { | 631 std::string* err) { |
595 RTC_DCHECK(network_thread_->IsCurrent()); | 632 RTC_DCHECK(network_thread_->IsCurrent()); |
596 | 633 |
597 // Verify each candidate before passing down to the transport layer. | 634 // Verify each candidate before passing down to the transport layer. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 return false; | 712 return false; |
676 } | 713 } |
677 return transport->GetStats(stats); | 714 return transport->GetStats(stats); |
678 } | 715 } |
679 | 716 |
680 void TransportController::SetMetricsObserver_n( | 717 void TransportController::SetMetricsObserver_n( |
681 webrtc::MetricsObserverInterface* metrics_observer) { | 718 webrtc::MetricsObserverInterface* metrics_observer) { |
682 RTC_DCHECK(network_thread_->IsCurrent()); | 719 RTC_DCHECK(network_thread_->IsCurrent()); |
683 metrics_observer_ = metrics_observer; | 720 metrics_observer_ = metrics_observer; |
684 for (auto& channel : channels_) { | 721 for (auto& channel : channels_) { |
685 channel.dtls()->SetMetricsObserver(metrics_observer); | 722 channel->dtls()->SetMetricsObserver(metrics_observer); |
686 } | 723 } |
687 } | 724 } |
688 | 725 |
689 void TransportController::OnChannelWritableState_n( | 726 void TransportController::OnChannelWritableState_n( |
690 rtc::PacketTransportInterface* transport) { | 727 rtc::PacketTransportInterface* transport) { |
691 RTC_DCHECK(network_thread_->IsCurrent()); | 728 RTC_DCHECK(network_thread_->IsCurrent()); |
692 LOG(LS_INFO) << " TransportChannel " << transport->debug_name() | 729 LOG(LS_INFO) << " TransportChannel " << transport->debug_name() |
693 << " writability changed to " << transport->writable() << "."; | 730 << " writability changed to " << transport->writable() << "."; |
694 UpdateAggregateStates_n(); | 731 UpdateAggregateStates_n(); |
695 } | 732 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 | 805 |
769 IceConnectionState new_connection_state = kIceConnectionConnecting; | 806 IceConnectionState new_connection_state = kIceConnectionConnecting; |
770 IceGatheringState new_gathering_state = kIceGatheringNew; | 807 IceGatheringState new_gathering_state = kIceGatheringNew; |
771 bool any_receiving = false; | 808 bool any_receiving = false; |
772 bool any_failed = false; | 809 bool any_failed = false; |
773 bool all_connected = !channels_.empty(); | 810 bool all_connected = !channels_.empty(); |
774 bool all_completed = !channels_.empty(); | 811 bool all_completed = !channels_.empty(); |
775 bool any_gathering = false; | 812 bool any_gathering = false; |
776 bool all_done_gathering = !channels_.empty(); | 813 bool all_done_gathering = !channels_.empty(); |
777 for (const auto& channel : channels_) { | 814 for (const auto& channel : channels_) { |
778 any_receiving = any_receiving || channel.dtls()->receiving(); | 815 any_receiving = any_receiving || channel->dtls()->receiving(); |
779 any_failed = | 816 any_failed = |
780 any_failed || | 817 any_failed || |
781 channel.dtls()->GetState() == TransportChannelState::STATE_FAILED; | 818 channel->dtls()->GetState() == TransportChannelState::STATE_FAILED; |
782 all_connected = all_connected && channel.dtls()->writable(); | 819 all_connected = all_connected && channel->dtls()->writable(); |
783 all_completed = | 820 all_completed = |
784 all_completed && channel.dtls()->writable() && | 821 all_completed && channel->dtls()->writable() && |
785 channel.dtls()->GetState() == TransportChannelState::STATE_COMPLETED && | 822 channel->dtls()->GetState() == TransportChannelState::STATE_COMPLETED && |
786 channel.dtls()->GetIceRole() == ICEROLE_CONTROLLING && | 823 channel->dtls()->GetIceRole() == ICEROLE_CONTROLLING && |
787 channel.dtls()->gathering_state() == kIceGatheringComplete; | 824 channel->dtls()->gathering_state() == kIceGatheringComplete; |
788 any_gathering = | 825 any_gathering = |
789 any_gathering || channel.dtls()->gathering_state() != kIceGatheringNew; | 826 any_gathering || channel->dtls()->gathering_state() != kIceGatheringNew; |
790 all_done_gathering = | 827 all_done_gathering = |
791 all_done_gathering && | 828 all_done_gathering && |
792 channel.dtls()->gathering_state() == kIceGatheringComplete; | 829 channel->dtls()->gathering_state() == kIceGatheringComplete; |
793 } | 830 } |
794 | 831 |
795 if (any_failed) { | 832 if (any_failed) { |
796 new_connection_state = kIceConnectionFailed; | 833 new_connection_state = kIceConnectionFailed; |
797 } else if (all_completed) { | 834 } else if (all_completed) { |
798 new_connection_state = kIceConnectionCompleted; | 835 new_connection_state = kIceConnectionCompleted; |
799 } else if (all_connected) { | 836 } else if (all_connected) { |
800 new_connection_state = kIceConnectionConnected; | 837 new_connection_state = kIceConnectionConnected; |
801 } | 838 } |
802 if (connection_state_ != new_connection_state) { | 839 if (connection_state_ != new_connection_state) { |
(...skipping 20 matching lines...) Expand all Loading... | |
823 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, | 860 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, |
824 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); | 861 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); |
825 } | 862 } |
826 } | 863 } |
827 | 864 |
828 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 865 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
829 SignalDtlsHandshakeError(error); | 866 SignalDtlsHandshakeError(error); |
830 } | 867 } |
831 | 868 |
832 } // namespace cricket | 869 } // namespace cricket |
OLD | NEW |