OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 }; | 99 }; |
100 static_assert(INVALID == arraysize(kValidIceServiceTypes), | 100 static_assert(INVALID == arraysize(kValidIceServiceTypes), |
101 "kValidIceServiceTypes must have as many strings as ServiceType " | 101 "kValidIceServiceTypes must have as many strings as ServiceType " |
102 "has values."); | 102 "has values."); |
103 | 103 |
104 enum { | 104 enum { |
105 MSG_SET_SESSIONDESCRIPTION_SUCCESS = 0, | 105 MSG_SET_SESSIONDESCRIPTION_SUCCESS = 0, |
106 MSG_SET_SESSIONDESCRIPTION_FAILED, | 106 MSG_SET_SESSIONDESCRIPTION_FAILED, |
107 MSG_CREATE_SESSIONDESCRIPTION_FAILED, | 107 MSG_CREATE_SESSIONDESCRIPTION_FAILED, |
108 MSG_GETSTATS, | 108 MSG_GETSTATS, |
| 109 MSG_DELETE, |
109 }; | 110 }; |
110 | 111 |
111 struct SetSessionDescriptionMsg : public rtc::MessageData { | 112 struct SetSessionDescriptionMsg : public rtc::MessageData { |
112 explicit SetSessionDescriptionMsg( | 113 explicit SetSessionDescriptionMsg( |
113 webrtc::SetSessionDescriptionObserver* observer) | 114 webrtc::SetSessionDescriptionObserver* observer) |
114 : observer(observer) { | 115 : observer(observer) { |
115 } | 116 } |
116 | 117 |
117 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserver> observer; | 118 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserver> observer; |
118 std::string error; | 119 std::string error; |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 uma_observer_(NULL), | 589 uma_observer_(NULL), |
589 signaling_state_(kStable), | 590 signaling_state_(kStable), |
590 ice_state_(kIceNew), | 591 ice_state_(kIceNew), |
591 ice_connection_state_(kIceConnectionNew), | 592 ice_connection_state_(kIceConnectionNew), |
592 ice_gathering_state_(kIceGatheringNew), | 593 ice_gathering_state_(kIceGatheringNew), |
593 local_streams_(StreamCollection::Create()), | 594 local_streams_(StreamCollection::Create()), |
594 remote_streams_(StreamCollection::Create()) {} | 595 remote_streams_(StreamCollection::Create()) {} |
595 | 596 |
596 PeerConnection::~PeerConnection() { | 597 PeerConnection::~PeerConnection() { |
597 RTC_DCHECK(signaling_thread()->IsCurrent()); | 598 RTC_DCHECK(signaling_thread()->IsCurrent()); |
| 599 // Finish any pending deletions. |
| 600 signaling_thread()->Clear(this, MSG_DELETE, nullptr); |
598 // Need to detach RTP senders/receivers from WebRtcSession, | 601 // Need to detach RTP senders/receivers from WebRtcSession, |
599 // since it's about to be destroyed. | 602 // since it's about to be destroyed. |
600 for (const auto& sender : senders_) { | 603 for (const auto& sender : senders_) { |
601 sender->Stop(); | 604 sender->Stop(); |
602 } | 605 } |
603 for (const auto& receiver : receivers_) { | 606 for (const auto& receiver : receivers_) { |
604 receiver->Stop(); | 607 receiver->Stop(); |
605 } | 608 } |
606 } | 609 } |
607 | 610 |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 break; | 1309 break; |
1307 } | 1310 } |
1308 case MSG_GETSTATS: { | 1311 case MSG_GETSTATS: { |
1309 GetStatsMsg* param = static_cast<GetStatsMsg*>(msg->pdata); | 1312 GetStatsMsg* param = static_cast<GetStatsMsg*>(msg->pdata); |
1310 StatsReports reports; | 1313 StatsReports reports; |
1311 stats_->GetStats(param->track, &reports); | 1314 stats_->GetStats(param->track, &reports); |
1312 param->observer->OnComplete(reports); | 1315 param->observer->OnComplete(reports); |
1313 delete param; | 1316 delete param; |
1314 break; | 1317 break; |
1315 } | 1318 } |
| 1319 case MSG_DELETE: { |
| 1320 delete msg->pdata; |
| 1321 break; |
| 1322 } |
1316 default: | 1323 default: |
1317 RTC_DCHECK(false && "Not implemented"); | 1324 RTC_DCHECK(false && "Not implemented"); |
1318 break; | 1325 break; |
1319 } | 1326 } |
1320 } | 1327 } |
1321 | 1328 |
1322 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, | 1329 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, |
1323 AudioTrackInterface* audio_track, | 1330 AudioTrackInterface* audio_track, |
1324 uint32_t ssrc) { | 1331 uint32_t ssrc) { |
1325 receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get())); | 1332 receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get())); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 } | 1900 } |
1894 } | 1901 } |
1895 | 1902 |
1896 void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) { | 1903 void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) { |
1897 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end(); | 1904 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end(); |
1898 ++it) { | 1905 ++it) { |
1899 if (it->get() == channel) { | 1906 if (it->get() == channel) { |
1900 if (channel->id() >= 0) { | 1907 if (channel->id() >= 0) { |
1901 sid_allocator_.ReleaseSid(channel->id()); | 1908 sid_allocator_.ReleaseSid(channel->id()); |
1902 } | 1909 } |
| 1910 // Since this method is triggered by a signal from the DataChannel, |
| 1911 // we can't free it directly here; we need to free it asynchronously. |
| 1912 signaling_thread()->Post( |
| 1913 this, MSG_DELETE, |
| 1914 new rtc::TypedMessageData<rtc::scoped_refptr<DataChannel>>(channel)); |
1903 sctp_data_channels_.erase(it); | 1915 sctp_data_channels_.erase(it); |
1904 return; | 1916 return; |
1905 } | 1917 } |
1906 } | 1918 } |
1907 } | 1919 } |
1908 | 1920 |
1909 void PeerConnection::OnVoiceChannelDestroyed() { | 1921 void PeerConnection::OnVoiceChannelDestroyed() { |
1910 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); | 1922 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); |
1911 } | 1923 } |
1912 | 1924 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2021 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2010 for (const auto& channel : sctp_data_channels_) { | 2022 for (const auto& channel : sctp_data_channels_) { |
2011 if (channel->id() == sid) { | 2023 if (channel->id() == sid) { |
2012 return channel; | 2024 return channel; |
2013 } | 2025 } |
2014 } | 2026 } |
2015 return nullptr; | 2027 return nullptr; |
2016 } | 2028 } |
2017 | 2029 |
2018 } // namespace webrtc | 2030 } // namespace webrtc |
OLD | NEW |