| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // because its destruction fires signals (such as VoiceChannelDestroyed) | 559 // because its destruction fires signals (such as VoiceChannelDestroyed) |
| 560 // which will trigger some final actions in PeerConnection... | 560 // which will trigger some final actions in PeerConnection... |
| 561 session_.reset(nullptr); | 561 session_.reset(nullptr); |
| 562 // port_allocator_ lives on the network thread and should be destroyed there. | 562 // port_allocator_ lives on the network thread and should be destroyed there. |
| 563 network_thread()->Invoke<void>([this] { port_allocator_.reset(nullptr); }); | 563 network_thread()->Invoke<void>([this] { port_allocator_.reset(nullptr); }); |
| 564 } | 564 } |
| 565 | 565 |
| 566 bool PeerConnection::Initialize( | 566 bool PeerConnection::Initialize( |
| 567 const PeerConnectionInterface::RTCConfiguration& configuration, | 567 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 568 std::unique_ptr<cricket::PortAllocator> allocator, | 568 std::unique_ptr<cricket::PortAllocator> allocator, |
| 569 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 569 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
| 570 PeerConnectionObserver* observer) { | 570 PeerConnectionObserver* observer) { |
| 571 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); | 571 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); |
| 572 RTC_DCHECK(observer != nullptr); | 572 RTC_DCHECK(observer != nullptr); |
| 573 if (!observer) { | 573 if (!observer) { |
| 574 return false; | 574 return false; |
| 575 } | 575 } |
| 576 observer_ = observer; | 576 observer_ = observer; |
| 577 | 577 |
| 578 port_allocator_ = std::move(allocator); | 578 port_allocator_ = std::move(allocator); |
| 579 | 579 |
| 580 // The port allocator lives on the network thread and should be initialized | 580 // The port allocator lives on the network thread and should be initialized |
| 581 // there. | 581 // there. |
| 582 if (!network_thread()->Invoke<bool>(rtc::Bind( | 582 if (!network_thread()->Invoke<bool>(rtc::Bind( |
| 583 &PeerConnection::InitializePortAllocator_n, this, configuration))) { | 583 &PeerConnection::InitializePortAllocator_n, this, configuration))) { |
| 584 return false; | 584 return false; |
| 585 } | 585 } |
| 586 | 586 |
| 587 media_controller_.reset( | 587 media_controller_.reset( |
| 588 factory_->CreateMediaController(configuration.media_config)); | 588 factory_->CreateMediaController(configuration.media_config)); |
| 589 | 589 |
| 590 session_.reset( | 590 session_.reset( |
| 591 new WebRtcSession(media_controller_.get(), factory_->network_thread(), | 591 new WebRtcSession(media_controller_.get(), factory_->network_thread(), |
| 592 factory_->worker_thread(), factory_->signaling_thread(), | 592 factory_->worker_thread(), factory_->signaling_thread(), |
| 593 port_allocator_.get())); | 593 port_allocator_.get())); |
| 594 stats_.reset(new StatsCollector(this)); | 594 stats_.reset(new StatsCollector(this)); |
| 595 | 595 |
| 596 // Initialize the WebRtcSession. It creates transport channels etc. | 596 // Initialize the WebRtcSession. It creates transport channels etc. |
| 597 if (!session_->Initialize(factory_->options(), std::move(dtls_identity_store), | 597 if (!session_->Initialize(factory_->options(), std::move(cert_generator), |
| 598 configuration)) { | 598 configuration)) { |
| 599 return false; | 599 return false; |
| 600 } | 600 } |
| 601 | 601 |
| 602 // Register PeerConnection as receiver of local ice candidates. | 602 // Register PeerConnection as receiver of local ice candidates. |
| 603 // All the callbacks will be posted to the application from PeerConnection. | 603 // All the callbacks will be posted to the application from PeerConnection. |
| 604 session_->RegisterIceObserver(this); | 604 session_->RegisterIceObserver(this); |
| 605 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); | 605 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); |
| 606 session_->SignalVoiceChannelDestroyed.connect( | 606 session_->SignalVoiceChannelDestroyed.connect( |
| 607 this, &PeerConnection::OnVoiceChannelDestroyed); | 607 this, &PeerConnection::OnVoiceChannelDestroyed); |
| (...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2138 port_allocator_->set_candidate_filter( | 2138 port_allocator_->set_candidate_filter( |
| 2139 ConvertIceTransportTypeToCandidateFilter(configuration.type)); | 2139 ConvertIceTransportTypeToCandidateFilter(configuration.type)); |
| 2140 // Call this last since it may create pooled allocator sessions using the | 2140 // Call this last since it may create pooled allocator sessions using the |
| 2141 // candidate filter set above. | 2141 // candidate filter set above. |
| 2142 port_allocator_->SetConfiguration(stun_servers, turn_servers, | 2142 port_allocator_->SetConfiguration(stun_servers, turn_servers, |
| 2143 configuration.ice_candidate_pool_size); | 2143 configuration.ice_candidate_pool_size); |
| 2144 return true; | 2144 return true; |
| 2145 } | 2145 } |
| 2146 | 2146 |
| 2147 } // namespace webrtc | 2147 } // namespace webrtc |
| OLD | NEW |