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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 } | 963 } |
964 const TransportInfo* transport_info = | 964 const TransportInfo* transport_info = |
965 description->GetTransportInfoByName(content_name); | 965 description->GetTransportInfoByName(content_name); |
966 if (!transport_info) { | 966 if (!transport_info) { |
967 return false; | 967 return false; |
968 } | 968 } |
969 *tdesc = transport_info->description; | 969 *tdesc = transport_info->description; |
970 return true; | 970 return true; |
971 } | 971 } |
972 | 972 |
973 bool WebRtcSession::GetTransportStats(SessionStats* stats) { | 973 std::unique_ptr<SessionStats> WebRtcSession::GetStats() { |
974 ASSERT(signaling_thread()->IsCurrent()); | 974 ASSERT(signaling_thread()->IsCurrent()); |
975 return (GetChannelTransportStats(voice_channel(), stats) && | 975 ChannelNamePairs channel_name_pairs; |
976 GetChannelTransportStats(video_channel(), stats) && | 976 if (voice_channel()) { |
977 GetChannelTransportStats(data_channel(), stats)); | 977 channel_name_pairs.voice = rtc::Optional<ChannelNamePair>(ChannelNamePair( |
| 978 voice_channel()->content_name(), voice_channel()->transport_name())); |
| 979 } |
| 980 if (video_channel()) { |
| 981 channel_name_pairs.video = rtc::Optional<ChannelNamePair>(ChannelNamePair( |
| 982 video_channel()->content_name(), video_channel()->transport_name())); |
| 983 } |
| 984 if (data_channel()) { |
| 985 channel_name_pairs.data = rtc::Optional<ChannelNamePair>(ChannelNamePair( |
| 986 data_channel()->content_name(), data_channel()->transport_name())); |
| 987 } |
| 988 return GetStats(channel_name_pairs); |
978 } | 989 } |
979 | 990 |
980 bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch, | 991 std::unique_ptr<SessionStats> WebRtcSession::GetStats( |
981 SessionStats* stats) { | 992 const ChannelNamePairs& channel_name_pairs) { |
982 ASSERT(signaling_thread()->IsCurrent()); | 993 if (network_thread()->IsCurrent()) { |
983 if (!ch) { | 994 return GetStats_n(channel_name_pairs); |
984 // Not using this channel. | |
985 return true; | |
986 } | 995 } |
987 | 996 return network_thread()->Invoke<std::unique_ptr<SessionStats>>( |
988 const std::string& content_name = ch->content_name(); | 997 RTC_FROM_HERE, |
989 const std::string& transport_name = ch->transport_name(); | 998 rtc::Bind(&WebRtcSession::GetStats_n, this, channel_name_pairs)); |
990 stats->proxy_to_transport[content_name] = transport_name; | |
991 if (stats->transport_stats.find(transport_name) != | |
992 stats->transport_stats.end()) { | |
993 // Transport stats already done for this transport. | |
994 return true; | |
995 } | |
996 | |
997 cricket::TransportStats tstats; | |
998 if (!transport_controller_->GetStats(transport_name, &tstats)) { | |
999 return false; | |
1000 } | |
1001 | |
1002 stats->transport_stats[transport_name] = tstats; | |
1003 return true; | |
1004 } | 999 } |
1005 | 1000 |
1006 bool WebRtcSession::GetLocalCertificate( | 1001 bool WebRtcSession::GetLocalCertificate( |
1007 const std::string& transport_name, | 1002 const std::string& transport_name, |
1008 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { | 1003 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { |
1009 ASSERT(signaling_thread()->IsCurrent()); | |
1010 return transport_controller_->GetLocalCertificate(transport_name, | 1004 return transport_controller_->GetLocalCertificate(transport_name, |
1011 certificate); | 1005 certificate); |
1012 } | 1006 } |
1013 | 1007 |
1014 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate( | 1008 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate( |
1015 const std::string& transport_name) { | 1009 const std::string& transport_name) { |
1016 ASSERT(signaling_thread()->IsCurrent()); | |
1017 return transport_controller_->GetRemoteSSLCertificate(transport_name); | 1010 return transport_controller_->GetRemoteSSLCertificate(transport_name); |
1018 } | 1011 } |
1019 | 1012 |
1020 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { | 1013 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { |
1021 const std::string* first_content_name = bundle.FirstContentName(); | 1014 const std::string* first_content_name = bundle.FirstContentName(); |
1022 if (!first_content_name) { | 1015 if (!first_content_name) { |
1023 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; | 1016 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; |
1024 return false; | 1017 return false; |
1025 } | 1018 } |
1026 const std::string& transport_name = *first_content_name; | 1019 const std::string& transport_name = *first_content_name; |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 } | 1702 } |
1710 | 1703 |
1711 data_channel_->SignalDtlsSetupFailure.connect( | 1704 data_channel_->SignalDtlsSetupFailure.connect( |
1712 this, &WebRtcSession::OnDtlsSetupFailure); | 1705 this, &WebRtcSession::OnDtlsSetupFailure); |
1713 | 1706 |
1714 SignalDataChannelCreated(); | 1707 SignalDataChannelCreated(); |
1715 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); | 1708 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); |
1716 return true; | 1709 return true; |
1717 } | 1710 } |
1718 | 1711 |
| 1712 std::unique_ptr<SessionStats> WebRtcSession::GetStats_n( |
| 1713 const ChannelNamePairs& channel_name_pairs) { |
| 1714 ASSERT(network_thread()->IsCurrent()); |
| 1715 std::unique_ptr<SessionStats> session_stats(new SessionStats()); |
| 1716 for (const auto channel_name_pair : { &channel_name_pairs.voice, |
| 1717 &channel_name_pairs.video, |
| 1718 &channel_name_pairs.data }) { |
| 1719 if (*channel_name_pair) { |
| 1720 cricket::TransportStats transport_stats; |
| 1721 if (!transport_controller_->GetStats((*channel_name_pair)->transport_name, |
| 1722 &transport_stats)) { |
| 1723 return nullptr; |
| 1724 } |
| 1725 session_stats->proxy_to_transport[(*channel_name_pair)->content_name] = |
| 1726 (*channel_name_pair)->transport_name; |
| 1727 session_stats->transport_stats[(*channel_name_pair)->transport_name] = |
| 1728 std::move(transport_stats); |
| 1729 } |
| 1730 } |
| 1731 return session_stats; |
| 1732 } |
| 1733 |
1719 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { | 1734 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { |
1720 SetError(ERROR_TRANSPORT, | 1735 SetError(ERROR_TRANSPORT, |
1721 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); | 1736 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); |
1722 } | 1737 } |
1723 | 1738 |
1724 void WebRtcSession::OnDataChannelMessageReceived( | 1739 void WebRtcSession::OnDataChannelMessageReceived( |
1725 cricket::DataChannel* channel, | 1740 cricket::DataChannel* channel, |
1726 const cricket::ReceiveDataParams& params, | 1741 const cricket::ReceiveDataParams& params, |
1727 const rtc::CopyOnWriteBuffer& payload) { | 1742 const rtc::CopyOnWriteBuffer& payload) { |
1728 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP); | 1743 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 } | 2074 } |
2060 | 2075 |
2061 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 2076 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
2062 if (metrics_observer_) { | 2077 if (metrics_observer_) { |
2063 metrics_observer_->IncrementEnumCounter( | 2078 metrics_observer_->IncrementEnumCounter( |
2064 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), | 2079 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), |
2065 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); | 2080 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); |
2066 } | 2081 } |
2067 } | 2082 } |
2068 } // namespace webrtc | 2083 } // namespace webrtc |
OLD | NEW |