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, | |
110 }; | 109 }; |
111 | 110 |
112 struct SetSessionDescriptionMsg : public rtc::MessageData { | 111 struct SetSessionDescriptionMsg : public rtc::MessageData { |
113 explicit SetSessionDescriptionMsg( | 112 explicit SetSessionDescriptionMsg( |
114 webrtc::SetSessionDescriptionObserver* observer) | 113 webrtc::SetSessionDescriptionObserver* observer) |
115 : observer(observer) { | 114 : observer(observer) { |
116 } | 115 } |
117 | 116 |
118 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserver> observer; | 117 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserver> observer; |
119 std::string error; | 118 std::string error; |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 uma_observer_(NULL), | 588 uma_observer_(NULL), |
590 signaling_state_(kStable), | 589 signaling_state_(kStable), |
591 ice_state_(kIceNew), | 590 ice_state_(kIceNew), |
592 ice_connection_state_(kIceConnectionNew), | 591 ice_connection_state_(kIceConnectionNew), |
593 ice_gathering_state_(kIceGatheringNew), | 592 ice_gathering_state_(kIceGatheringNew), |
594 local_streams_(StreamCollection::Create()), | 593 local_streams_(StreamCollection::Create()), |
595 remote_streams_(StreamCollection::Create()) {} | 594 remote_streams_(StreamCollection::Create()) {} |
596 | 595 |
597 PeerConnection::~PeerConnection() { | 596 PeerConnection::~PeerConnection() { |
598 RTC_DCHECK(signaling_thread()->IsCurrent()); | 597 RTC_DCHECK(signaling_thread()->IsCurrent()); |
599 // Finish any pending deletions. | |
600 signaling_thread()->Clear(this, MSG_DELETE, nullptr); | |
601 // Need to detach RTP senders/receivers from WebRtcSession, | 598 // Need to detach RTP senders/receivers from WebRtcSession, |
602 // since it's about to be destroyed. | 599 // since it's about to be destroyed. |
603 for (const auto& sender : senders_) { | 600 for (const auto& sender : senders_) { |
604 sender->Stop(); | 601 sender->Stop(); |
605 } | 602 } |
606 for (const auto& receiver : receivers_) { | 603 for (const auto& receiver : receivers_) { |
607 receiver->Stop(); | 604 receiver->Stop(); |
608 } | 605 } |
609 } | 606 } |
610 | 607 |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 break; | 1306 break; |
1310 } | 1307 } |
1311 case MSG_GETSTATS: { | 1308 case MSG_GETSTATS: { |
1312 GetStatsMsg* param = static_cast<GetStatsMsg*>(msg->pdata); | 1309 GetStatsMsg* param = static_cast<GetStatsMsg*>(msg->pdata); |
1313 StatsReports reports; | 1310 StatsReports reports; |
1314 stats_->GetStats(param->track, &reports); | 1311 stats_->GetStats(param->track, &reports); |
1315 param->observer->OnComplete(reports); | 1312 param->observer->OnComplete(reports); |
1316 delete param; | 1313 delete param; |
1317 break; | 1314 break; |
1318 } | 1315 } |
1319 case MSG_DELETE: { | |
1320 delete msg->pdata; | |
1321 break; | |
1322 } | |
1323 default: | 1316 default: |
1324 RTC_DCHECK(false && "Not implemented"); | 1317 RTC_DCHECK(false && "Not implemented"); |
1325 break; | 1318 break; |
1326 } | 1319 } |
1327 } | 1320 } |
1328 | 1321 |
1329 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, | 1322 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, |
1330 AudioTrackInterface* audio_track, | 1323 AudioTrackInterface* audio_track, |
1331 uint32_t ssrc) { | 1324 uint32_t ssrc) { |
1332 receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get())); | 1325 receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get())); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 } | 1893 } |
1901 } | 1894 } |
1902 | 1895 |
1903 void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) { | 1896 void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) { |
1904 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end(); | 1897 for (auto it = sctp_data_channels_.begin(); it != sctp_data_channels_.end(); |
1905 ++it) { | 1898 ++it) { |
1906 if (it->get() == channel) { | 1899 if (it->get() == channel) { |
1907 if (channel->id() >= 0) { | 1900 if (channel->id() >= 0) { |
1908 sid_allocator_.ReleaseSid(channel->id()); | 1901 sid_allocator_.ReleaseSid(channel->id()); |
1909 } | 1902 } |
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)); | |
1915 sctp_data_channels_.erase(it); | 1903 sctp_data_channels_.erase(it); |
1916 return; | 1904 return; |
1917 } | 1905 } |
1918 } | 1906 } |
1919 } | 1907 } |
1920 | 1908 |
1921 void PeerConnection::OnVoiceChannelDestroyed() { | 1909 void PeerConnection::OnVoiceChannelDestroyed() { |
1922 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); | 1910 EndRemoteTracks(cricket::MEDIA_TYPE_AUDIO); |
1923 } | 1911 } |
1924 | 1912 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2009 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2022 for (const auto& channel : sctp_data_channels_) { | 2010 for (const auto& channel : sctp_data_channels_) { |
2023 if (channel->id() == sid) { | 2011 if (channel->id() == sid) { |
2024 return channel; | 2012 return channel; |
2025 } | 2013 } |
2026 } | 2014 } |
2027 return nullptr; | 2015 return nullptr; |
2028 } | 2016 } |
2029 | 2017 |
2030 } // namespace webrtc | 2018 } // namespace webrtc |
OLD | NEW |