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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 | 620 |
621 void WebRtcSession::Close() { | 621 void WebRtcSession::Close() { |
622 SetState(STATE_CLOSED); | 622 SetState(STATE_CLOSED); |
623 RemoveUnusedChannels(nullptr); | 623 RemoveUnusedChannels(nullptr); |
624 ASSERT(!voice_channel_); | 624 ASSERT(!voice_channel_); |
625 ASSERT(!video_channel_); | 625 ASSERT(!video_channel_); |
626 ASSERT(!data_channel_); | 626 ASSERT(!data_channel_); |
627 media_controller_->Close(); | 627 media_controller_->Close(); |
628 } | 628 } |
629 | 629 |
630 std::unique_ptr<ChannelNamePairs> WebRtcSession::GetChannelNamePairs() { | |
631 ASSERT(signaling_thread()->IsCurrent()); | |
632 std::unique_ptr<ChannelNamePairs> channel_name_pairs(new ChannelNamePairs()); | |
633 if (voice_channel()) { | |
634 channel_name_pairs->voice = rtc::Optional<ChannelNamePair>(ChannelNamePair( | |
635 voice_channel()->content_name(), voice_channel()->transport_name())); | |
636 } | |
637 if (video_channel()) { | |
638 channel_name_pairs->video = rtc::Optional<ChannelNamePair>(ChannelNamePair( | |
639 video_channel()->content_name(), video_channel()->transport_name())); | |
640 } | |
641 if (data_channel()) { | |
642 channel_name_pairs->data = rtc::Optional<ChannelNamePair>(ChannelNamePair( | |
643 data_channel()->content_name(), data_channel()->transport_name())); | |
644 } | |
645 return channel_name_pairs; | |
646 } | |
647 | |
630 cricket::BaseChannel* WebRtcSession::GetChannel( | 648 cricket::BaseChannel* WebRtcSession::GetChannel( |
631 const std::string& content_name) { | 649 const std::string& content_name) { |
632 if (voice_channel() && voice_channel()->content_name() == content_name) { | 650 if (voice_channel() && voice_channel()->content_name() == content_name) { |
633 return voice_channel(); | 651 return voice_channel(); |
634 } | 652 } |
635 if (video_channel() && video_channel()->content_name() == content_name) { | 653 if (video_channel() && video_channel()->content_name() == content_name) { |
636 return video_channel(); | 654 return video_channel(); |
637 } | 655 } |
638 if (data_channel() && data_channel()->content_name() == content_name) { | 656 if (data_channel() && data_channel()->content_name() == content_name) { |
639 return data_channel(); | 657 return data_channel(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
999 } | 1017 } |
1000 const TransportInfo* transport_info = | 1018 const TransportInfo* transport_info = |
1001 description->GetTransportInfoByName(content_name); | 1019 description->GetTransportInfoByName(content_name); |
1002 if (!transport_info) { | 1020 if (!transport_info) { |
1003 return false; | 1021 return false; |
1004 } | 1022 } |
1005 *tdesc = transport_info->description; | 1023 *tdesc = transport_info->description; |
1006 return true; | 1024 return true; |
1007 } | 1025 } |
1008 | 1026 |
1009 bool WebRtcSession::GetTransportStats(SessionStats* stats) { | 1027 std::unique_ptr<SessionStats> WebRtcSession::GetSessionStats() { |
1010 ASSERT(signaling_thread()->IsCurrent()); | 1028 ASSERT(signaling_thread()->IsCurrent()); |
1011 return (GetChannelTransportStats(voice_channel(), stats) && | 1029 std::unique_ptr<ChannelNamePairs> channel_name_pairs = GetChannelNamePairs(); |
1012 GetChannelTransportStats(video_channel(), stats) && | 1030 return GetSessionStats(*channel_name_pairs); |
1013 GetChannelTransportStats(data_channel(), stats)); | |
1014 } | 1031 } |
1015 | 1032 |
1016 bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch, | 1033 std::unique_ptr<SessionStats> WebRtcSession::GetSessionStats( |
1017 SessionStats* stats) { | 1034 const ChannelNamePairs& channel_name_pairs) { |
1018 ASSERT(signaling_thread()->IsCurrent()); | 1035 if (network_thread()->IsCurrent()) |
1019 if (!ch) { | 1036 return GetSessionStats_n(channel_name_pairs); |
1020 // Not using this channel. | 1037 return network_thread()->Invoke<std::unique_ptr<SessionStats>>( |
1021 return true; | 1038 RTC_FROM_HERE, |
1022 } | 1039 rtc::Bind(&WebRtcSession::GetSessionStats_n, this, channel_name_pairs)); |
1023 | |
1024 const std::string& content_name = ch->content_name(); | |
1025 const std::string& transport_name = ch->transport_name(); | |
1026 stats->proxy_to_transport[content_name] = transport_name; | |
1027 if (stats->transport_stats.find(transport_name) != | |
1028 stats->transport_stats.end()) { | |
1029 // Transport stats already done for this transport. | |
1030 return true; | |
1031 } | |
1032 | |
1033 cricket::TransportStats tstats; | |
1034 if (!transport_controller_->GetStats(transport_name, &tstats)) { | |
1035 return false; | |
1036 } | |
1037 | |
1038 stats->transport_stats[transport_name] = tstats; | |
1039 return true; | |
1040 } | 1040 } |
1041 | 1041 |
1042 bool WebRtcSession::GetLocalCertificate( | 1042 bool WebRtcSession::GetLocalCertificate( |
1043 const std::string& transport_name, | 1043 const std::string& transport_name, |
1044 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { | 1044 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { |
1045 ASSERT(signaling_thread()->IsCurrent()); | |
1046 return transport_controller_->GetLocalCertificate(transport_name, | 1045 return transport_controller_->GetLocalCertificate(transport_name, |
1047 certificate); | 1046 certificate); |
1048 } | 1047 } |
1049 | 1048 |
1050 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate( | 1049 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate( |
1051 const std::string& transport_name) { | 1050 const std::string& transport_name) { |
1052 ASSERT(signaling_thread()->IsCurrent()); | |
1053 return transport_controller_->GetRemoteSSLCertificate(transport_name); | 1051 return transport_controller_->GetRemoteSSLCertificate(transport_name); |
1054 } | 1052 } |
1055 | 1053 |
1056 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { | 1054 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { |
1057 const std::string* first_content_name = bundle.FirstContentName(); | 1055 const std::string* first_content_name = bundle.FirstContentName(); |
1058 if (!first_content_name) { | 1056 if (!first_content_name) { |
1059 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; | 1057 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; |
1060 return false; | 1058 return false; |
1061 } | 1059 } |
1062 const std::string& transport_name = *first_content_name; | 1060 const std::string& transport_name = *first_content_name; |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1742 } | 1740 } |
1743 | 1741 |
1744 data_channel_->SignalDtlsSetupFailure.connect( | 1742 data_channel_->SignalDtlsSetupFailure.connect( |
1745 this, &WebRtcSession::OnDtlsSetupFailure); | 1743 this, &WebRtcSession::OnDtlsSetupFailure); |
1746 | 1744 |
1747 SignalDataChannelCreated(); | 1745 SignalDataChannelCreated(); |
1748 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); | 1746 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); |
1749 return true; | 1747 return true; |
1750 } | 1748 } |
1751 | 1749 |
1750 std::unique_ptr<SessionStats> WebRtcSession::GetSessionStats_n( | |
Taylor Brandstetter
2016/12/15 01:12:53
nit: Does this method need the channel_name_pairs
| |
1751 const ChannelNamePairs& channel_name_pairs) { | |
1752 ASSERT(network_thread()->IsCurrent()); | |
1753 std::unique_ptr<SessionStats> session_stats(new SessionStats()); | |
1754 if (channel_name_pairs.voice) { | |
1755 cricket::TransportStats voice_transport_stats; | |
1756 if (!transport_controller_->GetStats( | |
1757 channel_name_pairs.voice->transport_name, &voice_transport_stats)) { | |
1758 return nullptr; | |
1759 } | |
1760 session_stats->proxy_to_transport[channel_name_pairs.voice->content_name] = | |
1761 channel_name_pairs.voice->transport_name; | |
1762 session_stats->transport_stats[channel_name_pairs.voice->transport_name] = | |
1763 std::move(voice_transport_stats); | |
1764 } | |
1765 if (channel_name_pairs.video) { | |
1766 cricket::TransportStats video_transport_stats; | |
1767 if (!transport_controller_->GetStats( | |
1768 channel_name_pairs.video->transport_name, &video_transport_stats)) { | |
1769 return nullptr; | |
1770 } | |
1771 session_stats->proxy_to_transport[channel_name_pairs.video->content_name] = | |
1772 channel_name_pairs.video->transport_name; | |
1773 session_stats->transport_stats[channel_name_pairs.video->transport_name] = | |
1774 std::move(video_transport_stats); | |
1775 } | |
1776 if (channel_name_pairs.data) { | |
1777 cricket::TransportStats data_transport_stats; | |
1778 if (!transport_controller_->GetStats( | |
1779 channel_name_pairs.data->transport_name, &data_transport_stats)) { | |
1780 return nullptr; | |
1781 } | |
1782 session_stats->proxy_to_transport[channel_name_pairs.data->content_name] = | |
1783 channel_name_pairs.data->transport_name; | |
1784 session_stats->transport_stats[channel_name_pairs.data->transport_name] = | |
1785 std::move(data_transport_stats); | |
1786 } | |
1787 return session_stats; | |
1788 } | |
1789 | |
1752 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { | 1790 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { |
1753 SetError(ERROR_TRANSPORT, | 1791 SetError(ERROR_TRANSPORT, |
1754 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); | 1792 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); |
1755 } | 1793 } |
1756 | 1794 |
1757 void WebRtcSession::OnDataChannelMessageReceived( | 1795 void WebRtcSession::OnDataChannelMessageReceived( |
1758 cricket::DataChannel* channel, | 1796 cricket::DataChannel* channel, |
1759 const cricket::ReceiveDataParams& params, | 1797 const cricket::ReceiveDataParams& params, |
1760 const rtc::CopyOnWriteBuffer& payload) { | 1798 const rtc::CopyOnWriteBuffer& payload) { |
1761 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP); | 1799 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2087 } | 2125 } |
2088 | 2126 |
2089 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 2127 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
2090 if (metrics_observer_) { | 2128 if (metrics_observer_) { |
2091 metrics_observer_->IncrementEnumCounter( | 2129 metrics_observer_->IncrementEnumCounter( |
2092 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), | 2130 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), |
2093 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); | 2131 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); |
2094 } | 2132 } |
2095 } | 2133 } |
2096 } // namespace webrtc | 2134 } // namespace webrtc |
OLD | NEW |