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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection"); | 515 TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection"); |
516 RTC_DCHECK(signaling_thread()->IsCurrent()); | 516 RTC_DCHECK(signaling_thread()->IsCurrent()); |
517 // Need to detach RTP senders/receivers from WebRtcSession, | 517 // Need to detach RTP senders/receivers from WebRtcSession, |
518 // since it's about to be destroyed. | 518 // since it's about to be destroyed. |
519 for (const auto& sender : senders_) { | 519 for (const auto& sender : senders_) { |
520 sender->Stop(); | 520 sender->Stop(); |
521 } | 521 } |
522 for (const auto& receiver : receivers_) { | 522 for (const auto& receiver : receivers_) { |
523 receiver->Stop(); | 523 receiver->Stop(); |
524 } | 524 } |
525 // Destroy stats_ because it depends on session_. | |
526 stats_.reset(nullptr); | |
527 // Now destroy session_ before destroying other members, | |
528 // because its destruction fires signals (such as VoiceChannelDestroyed) | |
529 // which will trigger some final actions in PeerConnection... | |
530 session_.reset(nullptr); | |
531 // port_allocator_ lives on the worker thread and should be destroyed there. | |
532 worker_thread()->Invoke<void>([this] { port_allocator_.reset(nullptr); }); | |
525 } | 533 } |
526 | 534 |
527 bool PeerConnection::Initialize( | 535 bool PeerConnection::Initialize( |
528 const PeerConnectionInterface::RTCConfiguration& configuration, | 536 const PeerConnectionInterface::RTCConfiguration& configuration, |
529 std::unique_ptr<cricket::PortAllocator> allocator, | 537 std::unique_ptr<cricket::PortAllocator> allocator, |
530 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 538 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
531 PeerConnectionObserver* observer) { | 539 PeerConnectionObserver* observer) { |
532 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); | 540 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); |
533 RTC_DCHECK(observer != nullptr); | 541 RTC_DCHECK(observer != nullptr); |
534 if (!observer) { | 542 if (!observer) { |
535 return false; | 543 return false; |
536 } | 544 } |
537 observer_ = observer; | 545 observer_ = observer; |
538 | 546 |
539 port_allocator_ = std::move(allocator); | 547 port_allocator_ = std::move(allocator); |
540 | 548 |
541 cricket::ServerAddresses stun_servers; | 549 cricket::ServerAddresses stun_servers; |
542 std::vector<cricket::RelayServerConfig> turn_servers; | 550 std::vector<cricket::RelayServerConfig> turn_servers; |
543 if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) { | 551 if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) { |
544 return false; | 552 return false; |
545 } | 553 } |
546 port_allocator_->SetIceServers(stun_servers, turn_servers); | 554 worker_thread()->Invoke<void>(rtc::Bind( |
555 &cricket::PortAllocator::SetConfiguration, port_allocator_.get(), | |
pthatcher1
2016/05/05 21:51:24
I'm a little confused. Some things on PortAllocat
Taylor Brandstetter
2016/05/06 03:53:34
That's the way it's always been. I agree it should
| |
556 stun_servers, turn_servers, configuration.ice_candidate_pool_size)); | |
547 | 557 |
548 // To handle both internal and externally created port allocator, we will | 558 // To handle both internal and externally created port allocator, we will |
549 // enable BUNDLE here. | 559 // enable BUNDLE here. |
550 int portallocator_flags = port_allocator_->flags(); | 560 int portallocator_flags = port_allocator_->flags(); |
551 portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 561 portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
552 cricket::PORTALLOCATOR_ENABLE_IPV6; | 562 cricket::PORTALLOCATOR_ENABLE_IPV6; |
553 // If the disable-IPv6 flag was specified, we'll not override it | 563 // If the disable-IPv6 flag was specified, we'll not override it |
554 // by experiment. | 564 // by experiment. |
555 if (configuration.disable_ipv6) { | 565 if (configuration.disable_ipv6) { |
556 portallocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6); | 566 portallocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6); |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1137 stats_->AddStream(new_stream); | 1147 stats_->AddStream(new_stream); |
1138 observer_->OnAddStream(new_stream); | 1148 observer_->OnAddStream(new_stream); |
1139 } | 1149 } |
1140 | 1150 |
1141 UpdateEndedRemoteMediaStreams(); | 1151 UpdateEndedRemoteMediaStreams(); |
1142 | 1152 |
1143 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 1153 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
1144 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); | 1154 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
1145 } | 1155 } |
1146 | 1156 |
1147 bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { | 1157 bool PeerConnection::SetConfiguration(const RTCConfiguration& configuration) { |
1148 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); | 1158 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); |
1149 if (port_allocator_) { | 1159 if (port_allocator_) { |
1150 cricket::ServerAddresses stun_servers; | 1160 cricket::ServerAddresses stun_servers; |
1151 std::vector<cricket::RelayServerConfig> turn_servers; | 1161 std::vector<cricket::RelayServerConfig> turn_servers; |
1152 if (!ParseIceServers(config.servers, &stun_servers, &turn_servers)) { | 1162 if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) { |
1153 return false; | 1163 return false; |
1154 } | 1164 } |
1155 port_allocator_->SetIceServers(stun_servers, turn_servers); | 1165 worker_thread()->Invoke<void>(rtc::Bind( |
1166 &cricket::PortAllocator::SetConfiguration, port_allocator_.get(), | |
1167 stun_servers, turn_servers, configuration.ice_candidate_pool_size)); | |
1156 } | 1168 } |
1157 session_->SetIceConfig(session_->ParseIceConfig(config)); | 1169 session_->SetIceConfig(session_->ParseIceConfig(configuration)); |
1158 return session_->SetIceTransports(config.type); | 1170 return session_->SetIceTransports(configuration.type); |
1159 } | 1171 } |
1160 | 1172 |
1161 bool PeerConnection::AddIceCandidate( | 1173 bool PeerConnection::AddIceCandidate( |
1162 const IceCandidateInterface* ice_candidate) { | 1174 const IceCandidateInterface* ice_candidate) { |
1163 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); | 1175 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); |
1164 return session_->ProcessIceMessage(ice_candidate); | 1176 return session_->ProcessIceMessage(ice_candidate); |
1165 } | 1177 } |
1166 | 1178 |
1167 bool PeerConnection::RemoveIceCandidates( | 1179 bool PeerConnection::RemoveIceCandidates( |
1168 const std::vector<cricket::Candidate>& candidates) { | 1180 const std::vector<cricket::Candidate>& candidates) { |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2058 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2070 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2059 for (const auto& channel : sctp_data_channels_) { | 2071 for (const auto& channel : sctp_data_channels_) { |
2060 if (channel->id() == sid) { | 2072 if (channel->id() == sid) { |
2061 return channel; | 2073 return channel; |
2062 } | 2074 } |
2063 } | 2075 } |
2064 return nullptr; | 2076 return nullptr; |
2065 } | 2077 } |
2066 | 2078 |
2067 } // namespace webrtc | 2079 } // namespace webrtc |
OLD | NEW |