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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 }; | 100 }; |
101 static_assert(INVALID == arraysize(kValidIceServiceTypes), | 101 static_assert(INVALID == arraysize(kValidIceServiceTypes), |
102 "kValidIceServiceTypes must have as many strings as ServiceType " | 102 "kValidIceServiceTypes must have as many strings as ServiceType " |
103 "has values."); | 103 "has values."); |
104 | 104 |
105 enum { | 105 enum { |
106 MSG_SET_SESSIONDESCRIPTION_SUCCESS = 0, | 106 MSG_SET_SESSIONDESCRIPTION_SUCCESS = 0, |
107 MSG_SET_SESSIONDESCRIPTION_FAILED, | 107 MSG_SET_SESSIONDESCRIPTION_FAILED, |
108 MSG_CREATE_SESSIONDESCRIPTION_FAILED, | 108 MSG_CREATE_SESSIONDESCRIPTION_FAILED, |
109 MSG_GETSTATS, | 109 MSG_GETSTATS, |
| 110 MSG_FREE_DATACHANNELS, |
110 }; | 111 }; |
111 | 112 |
112 struct SetSessionDescriptionMsg : public rtc::MessageData { | 113 struct SetSessionDescriptionMsg : public rtc::MessageData { |
113 explicit SetSessionDescriptionMsg( | 114 explicit SetSessionDescriptionMsg( |
114 webrtc::SetSessionDescriptionObserver* observer) | 115 webrtc::SetSessionDescriptionObserver* observer) |
115 : observer(observer) { | 116 : observer(observer) { |
116 } | 117 } |
117 | 118 |
118 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserver> observer; | 119 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserver> observer; |
119 std::string error; | 120 std::string error; |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 break; | 1323 break; |
1323 } | 1324 } |
1324 case MSG_GETSTATS: { | 1325 case MSG_GETSTATS: { |
1325 GetStatsMsg* param = static_cast<GetStatsMsg*>(msg->pdata); | 1326 GetStatsMsg* param = static_cast<GetStatsMsg*>(msg->pdata); |
1326 StatsReports reports; | 1327 StatsReports reports; |
1327 stats_->GetStats(param->track, &reports); | 1328 stats_->GetStats(param->track, &reports); |
1328 param->observer->OnComplete(reports); | 1329 param->observer->OnComplete(reports); |
1329 delete param; | 1330 delete param; |
1330 break; | 1331 break; |
1331 } | 1332 } |
| 1333 case MSG_FREE_DATACHANNELS: { |
| 1334 sctp_data_channels_to_free_.clear(); |
| 1335 break; |
| 1336 } |
1332 default: | 1337 default: |
1333 RTC_DCHECK(false && "Not implemented"); | 1338 RTC_DCHECK(false && "Not implemented"); |
1334 break; | 1339 break; |
1335 } | 1340 } |
1336 } | 1341 } |
1337 | 1342 |
1338 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, | 1343 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, |
1339 AudioTrackInterface* audio_track, | 1344 AudioTrackInterface* audio_track, |
1340 uint32_t ssrc) { | 1345 uint32_t ssrc) { |
1341 receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get())); | 1346 receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get())); |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 if (!sid_allocator_.AllocateSid(role, &sid)) { | 1900 if (!sid_allocator_.AllocateSid(role, &sid)) { |
1896 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; | 1901 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; |
1897 continue; | 1902 continue; |
1898 } | 1903 } |
1899 channel->SetSctpSid(sid); | 1904 channel->SetSctpSid(sid); |
1900 } | 1905 } |
1901 } | 1906 } |
1902 } | 1907 } |
1903 | 1908 |
1904 void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) { | 1909 void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) { |
| 1910 RTC_DCHECK(signaling_thread()->IsCurrent()); |
1905 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end(); | 1911 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end(); |
1906 ++it) { | 1912 ++it) { |
1907 if (it->get() == channel) { | 1913 if (it->get() == channel) { |
1908 if (channel->id() >= 0) { | 1914 if (channel->id() >= 0) { |
1909 sid_allocator_.ReleaseSid(channel->id()); | 1915 sid_allocator_.ReleaseSid(channel->id()); |
1910 } | 1916 } |
| 1917 // Since this method is triggered by a signal from the DataChannel, |
| 1918 // we can't free it directly here; we need to free it asynchronously. |
| 1919 sctp_data_channels_to_free_.push_back(*it); |
1911 sctp_data_channels_.erase(it); | 1920 sctp_data_channels_.erase(it); |
| 1921 signaling_thread()->Post(this, MSG_FREE_DATACHANNELS, nullptr); |
1912 return; | 1922 return; |
1913 } | 1923 } |
1914 } | 1924 } |
1915 } | 1925 } |
1916 | 1926 |
1917 void PeerConnection::OnVoiceChannelDestroyed() { | 1927 void PeerConnection::OnVoiceChannelDestroyed() { |
1918 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); | 1928 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); |
1919 } | 1929 } |
1920 | 1930 |
1921 void PeerConnection::OnVideoChannelDestroyed() { | 1931 void PeerConnection::OnVideoChannelDestroyed() { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2027 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2018 for (const auto& channel : sctp_data_channels_) { | 2028 for (const auto& channel : sctp_data_channels_) { |
2019 if (channel->id() == sid) { | 2029 if (channel->id() == sid) { |
2020 return channel; | 2030 return channel; |
2021 } | 2031 } |
2022 } | 2032 } |
2023 return nullptr; | 2033 return nullptr; |
2024 } | 2034 } |
2025 | 2035 |
2026 } // namespace webrtc | 2036 } // namespace webrtc |
OLD | NEW |