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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 (*it)->Stop(); | 751 (*it)->Stop(); |
752 senders_.erase(it); | 752 senders_.erase(it); |
753 | 753 |
754 observer_->OnRenegotiationNeeded(); | 754 observer_->OnRenegotiationNeeded(); |
755 return true; | 755 return true; |
756 } | 756 } |
757 | 757 |
758 rtc::scoped_refptr<DtmfSenderInterface> PeerConnection::CreateDtmfSender( | 758 rtc::scoped_refptr<DtmfSenderInterface> PeerConnection::CreateDtmfSender( |
759 AudioTrackInterface* track) { | 759 AudioTrackInterface* track) { |
760 TRACE_EVENT0("webrtc", "PeerConnection::CreateDtmfSender"); | 760 TRACE_EVENT0("webrtc", "PeerConnection::CreateDtmfSender"); |
761 if (IsClosed()) { | |
762 return nullptr; | |
763 } | |
761 if (!track) { | 764 if (!track) { |
762 LOG(LS_ERROR) << "CreateDtmfSender - track is NULL."; | 765 LOG(LS_ERROR) << "CreateDtmfSender - track is NULL."; |
763 return NULL; | 766 return NULL; |
764 } | 767 } |
765 if (!local_streams_->FindAudioTrack(track->id())) { | 768 if (!local_streams_->FindAudioTrack(track->id())) { |
766 LOG(LS_ERROR) << "CreateDtmfSender is called with a non local audio track."; | 769 LOG(LS_ERROR) << "CreateDtmfSender is called with a non local audio track."; |
767 return NULL; | 770 return NULL; |
768 } | 771 } |
769 | 772 |
770 rtc::scoped_refptr<DtmfSenderInterface> sender( | 773 rtc::scoped_refptr<DtmfSenderInterface> sender( |
771 DtmfSender::Create(track, signaling_thread(), session_.get())); | 774 DtmfSender::Create(track, signaling_thread(), session_.get())); |
772 if (!sender.get()) { | 775 if (!sender.get()) { |
773 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create."; | 776 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create."; |
774 return NULL; | 777 return NULL; |
775 } | 778 } |
776 return DtmfSenderProxy::Create(signaling_thread(), sender.get()); | 779 return DtmfSenderProxy::Create(signaling_thread(), sender.get()); |
777 } | 780 } |
778 | 781 |
779 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( | 782 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( |
780 const std::string& kind, | 783 const std::string& kind, |
781 const std::string& stream_id) { | 784 const std::string& stream_id) { |
782 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); | 785 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); |
786 if (IsClosed()) { | |
787 return nullptr; | |
788 } | |
783 rtc::scoped_refptr<RtpSenderInterface> new_sender; | 789 rtc::scoped_refptr<RtpSenderInterface> new_sender; |
784 if (kind == MediaStreamTrackInterface::kAudioKind) { | 790 if (kind == MediaStreamTrackInterface::kAudioKind) { |
785 new_sender = RtpSenderProxy::Create( | 791 new_sender = RtpSenderProxy::Create( |
786 signaling_thread(), new AudioRtpSender(session_.get(), stats_.get())); | 792 signaling_thread(), new AudioRtpSender(session_.get(), stats_.get())); |
787 } else if (kind == MediaStreamTrackInterface::kVideoKind) { | 793 } else if (kind == MediaStreamTrackInterface::kVideoKind) { |
788 new_sender = RtpSenderProxy::Create(signaling_thread(), | 794 new_sender = RtpSenderProxy::Create(signaling_thread(), |
789 new VideoRtpSender(session_.get())); | 795 new VideoRtpSender(session_.get())); |
790 } else { | 796 } else { |
791 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; | 797 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; |
792 return new_sender; | 798 return new_sender; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 } | 1174 } |
1169 port_allocator_->SetIceServers(stun_servers, turn_servers); | 1175 port_allocator_->SetIceServers(stun_servers, turn_servers); |
1170 } | 1176 } |
1171 session_->SetIceConfig(session_->ParseIceConfig(config)); | 1177 session_->SetIceConfig(session_->ParseIceConfig(config)); |
1172 return session_->SetIceTransports(config.type); | 1178 return session_->SetIceTransports(config.type); |
1173 } | 1179 } |
1174 | 1180 |
1175 bool PeerConnection::AddIceCandidate( | 1181 bool PeerConnection::AddIceCandidate( |
1176 const IceCandidateInterface* ice_candidate) { | 1182 const IceCandidateInterface* ice_candidate) { |
1177 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); | 1183 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); |
1184 if (IsClosed()) { | |
1185 return false; | |
1186 } | |
1178 return session_->ProcessIceMessage(ice_candidate); | 1187 return session_->ProcessIceMessage(ice_candidate); |
1179 } | 1188 } |
1180 | 1189 |
1181 bool PeerConnection::RemoveIceCandidates( | 1190 bool PeerConnection::RemoveIceCandidates( |
1182 const std::vector<cricket::Candidate>& candidates) { | 1191 const std::vector<cricket::Candidate>& candidates) { |
1183 TRACE_EVENT0("webrtc", "PeerConnection::RemoveIceCandidates"); | 1192 TRACE_EVENT0("webrtc", "PeerConnection::RemoveIceCandidates"); |
1184 return session_->RemoveRemoteIceCandidates(candidates); | 1193 return session_->RemoveRemoteIceCandidates(candidates); |
1185 } | 1194 } |
1186 | 1195 |
1187 void PeerConnection::RegisterUMAObserver(UMAObserver* observer) { | 1196 void PeerConnection::RegisterUMAObserver(UMAObserver* observer) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 } | 1298 } |
1290 default: | 1299 default: |
1291 RTC_DCHECK(false && "Not implemented"); | 1300 RTC_DCHECK(false && "Not implemented"); |
1292 break; | 1301 break; |
1293 } | 1302 } |
1294 } | 1303 } |
1295 | 1304 |
1296 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, | 1305 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, |
1297 const std::string& track_id, | 1306 const std::string& track_id, |
1298 uint32_t ssrc) { | 1307 uint32_t ssrc) { |
1308 if (IsClosed()) { | |
1309 return; | |
1310 } | |
Taylor Brandstetter
2016/05/11 22:18:36
This and CreateVideoReceiver are internal methods,
Zhi Huang
2016/05/12 01:25:49
Done.
| |
1299 receivers_.push_back(RtpReceiverProxy::Create( | 1311 receivers_.push_back(RtpReceiverProxy::Create( |
1300 signaling_thread(), | 1312 signaling_thread(), |
1301 new AudioRtpReceiver(stream, track_id, ssrc, session_.get()))); | 1313 new AudioRtpReceiver(stream, track_id, ssrc, session_.get()))); |
1302 } | 1314 } |
1303 | 1315 |
1304 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, | 1316 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, |
1305 const std::string& track_id, | 1317 const std::string& track_id, |
1306 uint32_t ssrc) { | 1318 uint32_t ssrc) { |
1319 if (IsClosed()) { | |
1320 return; | |
1321 } | |
1307 receivers_.push_back(RtpReceiverProxy::Create( | 1322 receivers_.push_back(RtpReceiverProxy::Create( |
1308 signaling_thread(), | 1323 signaling_thread(), |
1309 new VideoRtpReceiver(stream, track_id, factory_->worker_thread(), ssrc, | 1324 new VideoRtpReceiver(stream, track_id, factory_->worker_thread(), ssrc, |
1310 session_.get()))); | 1325 session_.get()))); |
1311 } | 1326 } |
1312 | 1327 |
1313 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote | 1328 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote |
1314 // description. | 1329 // description. |
1315 void PeerConnection::DestroyReceiver(const std::string& track_id) { | 1330 void PeerConnection::DestroyReceiver(const std::string& track_id) { |
1316 auto it = FindReceiverForTrack(track_id); | 1331 auto it = FindReceiverForTrack(track_id); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1353 RTC_DCHECK(signaling_thread()->IsCurrent()); | 1368 RTC_DCHECK(signaling_thread()->IsCurrent()); |
1354 if (IsClosed()) { | 1369 if (IsClosed()) { |
1355 return; | 1370 return; |
1356 } | 1371 } |
1357 ice_gathering_state_ = new_state; | 1372 ice_gathering_state_ = new_state; |
1358 observer_->OnIceGatheringChange(ice_gathering_state_); | 1373 observer_->OnIceGatheringChange(ice_gathering_state_); |
1359 } | 1374 } |
1360 | 1375 |
1361 void PeerConnection::OnIceCandidate(const IceCandidateInterface* candidate) { | 1376 void PeerConnection::OnIceCandidate(const IceCandidateInterface* candidate) { |
1362 RTC_DCHECK(signaling_thread()->IsCurrent()); | 1377 RTC_DCHECK(signaling_thread()->IsCurrent()); |
1378 if (IsClosed()) { | |
1379 return; | |
1380 } | |
1363 observer_->OnIceCandidate(candidate); | 1381 observer_->OnIceCandidate(candidate); |
1364 } | 1382 } |
1365 | 1383 |
1366 void PeerConnection::OnIceCandidatesRemoved( | 1384 void PeerConnection::OnIceCandidatesRemoved( |
1367 const std::vector<cricket::Candidate>& candidates) { | 1385 const std::vector<cricket::Candidate>& candidates) { |
1368 RTC_DCHECK(signaling_thread()->IsCurrent()); | 1386 RTC_DCHECK(signaling_thread()->IsCurrent()); |
1387 if (IsClosed()) { | |
1388 return; | |
1389 } | |
1369 observer_->OnIceCandidatesRemoved(candidates); | 1390 observer_->OnIceCandidatesRemoved(candidates); |
1370 } | 1391 } |
1371 | 1392 |
1372 void PeerConnection::OnIceConnectionReceivingChange(bool receiving) { | 1393 void PeerConnection::OnIceConnectionReceivingChange(bool receiving) { |
1373 RTC_DCHECK(signaling_thread()->IsCurrent()); | 1394 RTC_DCHECK(signaling_thread()->IsCurrent()); |
1395 if (IsClosed()) { | |
1396 return; | |
1397 } | |
1374 observer_->OnIceConnectionReceivingChange(receiving); | 1398 observer_->OnIceConnectionReceivingChange(receiving); |
1375 } | 1399 } |
1376 | 1400 |
1377 void PeerConnection::ChangeSignalingState( | 1401 void PeerConnection::ChangeSignalingState( |
1378 PeerConnectionInterface::SignalingState signaling_state) { | 1402 PeerConnectionInterface::SignalingState signaling_state) { |
1379 signaling_state_ = signaling_state; | 1403 signaling_state_ = signaling_state; |
1380 if (signaling_state == kClosed) { | 1404 if (signaling_state == kClosed) { |
1381 ice_connection_state_ = kIceConnectionClosed; | 1405 ice_connection_state_ = kIceConnectionClosed; |
1382 observer_->OnIceConnectionChange(ice_connection_state_); | 1406 observer_->OnIceConnectionChange(ice_connection_state_); |
1383 if (ice_gathering_state_ != kIceGatheringComplete) { | 1407 if (ice_gathering_state_ != kIceGatheringComplete) { |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2078 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2102 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2079 for (const auto& channel : sctp_data_channels_) { | 2103 for (const auto& channel : sctp_data_channels_) { |
2080 if (channel->id() == sid) { | 2104 if (channel->id() == sid) { |
2081 return channel; | 2105 return channel; |
2082 } | 2106 } |
2083 } | 2107 } |
2084 return nullptr; | 2108 return nullptr; |
2085 } | 2109 } |
2086 | 2110 |
2087 } // namespace webrtc | 2111 } // namespace webrtc |
OLD | NEW |