Chromium Code Reviews

Side by Side Diff: webrtc/api/webrtcsession.cc

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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...)
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 392 matching lines...)
1032 1050
1033 cricket::TransportStats tstats; 1051 cricket::TransportStats tstats;
1034 if (!transport_controller_->GetStats(transport_name, &tstats)) { 1052 if (!transport_controller_->GetStats(transport_name, &tstats)) {
1035 return false; 1053 return false;
1036 } 1054 }
1037 1055
1038 stats->transport_stats[transport_name] = tstats; 1056 stats->transport_stats[transport_name] = tstats;
1039 return true; 1057 return true;
1040 } 1058 }
1041 1059
1060 std::unique_ptr<SessionStats> WebRtcSession::GetSessionStats_n(
1061 const ChannelNamePairs& channel_name_pairs) {
1062 ASSERT(network_thread()->IsCurrent());
1063 std::unique_ptr<SessionStats> session_stats(new SessionStats());
1064 if (channel_name_pairs.voice) {
1065 cricket::TransportStats voice_transport_stats;
1066 if (!transport_controller_->GetStats_n(
1067 channel_name_pairs.voice->transport_name, &voice_transport_stats)) {
1068 return nullptr;
1069 }
1070 session_stats->proxy_to_transport[channel_name_pairs.voice->content_name] =
1071 channel_name_pairs.voice->transport_name;
1072 session_stats->transport_stats[channel_name_pairs.voice->transport_name] =
1073 std::move(voice_transport_stats);
1074 }
1075 if (channel_name_pairs.video) {
1076 cricket::TransportStats video_transport_stats;
1077 if (!transport_controller_->GetStats_n(
1078 channel_name_pairs.video->transport_name, &video_transport_stats)) {
1079 return nullptr;
1080 }
1081 session_stats->proxy_to_transport[channel_name_pairs.video->content_name] =
1082 channel_name_pairs.video->transport_name;
1083 session_stats->transport_stats[channel_name_pairs.video->transport_name] =
1084 std::move(video_transport_stats);
1085 }
1086 if (channel_name_pairs.data) {
1087 cricket::TransportStats data_transport_stats;
1088 if (!transport_controller_->GetStats_n(
1089 channel_name_pairs.data->transport_name, &data_transport_stats)) {
1090 return nullptr;
1091 }
1092 session_stats->proxy_to_transport[channel_name_pairs.data->content_name] =
1093 channel_name_pairs.data->transport_name;
1094 session_stats->transport_stats[channel_name_pairs.data->transport_name] =
1095 std::move(data_transport_stats);
1096 }
1097 return session_stats;
1098 }
1099
1042 bool WebRtcSession::GetLocalCertificate( 1100 bool WebRtcSession::GetLocalCertificate(
1043 const std::string& transport_name, 1101 const std::string& transport_name,
1044 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 1102 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
1045 ASSERT(signaling_thread()->IsCurrent()); 1103 ASSERT(signaling_thread()->IsCurrent());
1046 return transport_controller_->GetLocalCertificate(transport_name, 1104 return transport_controller_->GetLocalCertificate(transport_name,
1047 certificate); 1105 certificate);
1048 } 1106 }
1049 1107
1108 bool WebRtcSession::GetLocalCertificate_n(
1109 const std::string& transport_name,
1110 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
1111 ASSERT(network_thread()->IsCurrent());
1112 return transport_controller_->GetLocalCertificate_n(transport_name,
1113 certificate);
1114 }
1115
1050 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate( 1116 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate(
1051 const std::string& transport_name) { 1117 const std::string& transport_name) {
1052 ASSERT(signaling_thread()->IsCurrent()); 1118 ASSERT(signaling_thread()->IsCurrent());
1053 return transport_controller_->GetRemoteSSLCertificate(transport_name); 1119 return transport_controller_->GetRemoteSSLCertificate(transport_name);
1054 } 1120 }
1055 1121
1122 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate_n(
1123 const std::string& transport_name) {
1124 ASSERT(network_thread()->IsCurrent());
1125 return transport_controller_->GetRemoteSSLCertificate_n(transport_name);
1126 }
1127
1056 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { 1128 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) {
1057 const std::string* first_content_name = bundle.FirstContentName(); 1129 const std::string* first_content_name = bundle.FirstContentName();
1058 if (!first_content_name) { 1130 if (!first_content_name) {
1059 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; 1131 LOG(LS_WARNING) << "Tried to BUNDLE with no contents.";
1060 return false; 1132 return false;
1061 } 1133 }
1062 const std::string& transport_name = *first_content_name; 1134 const std::string& transport_name = *first_content_name;
1063 cricket::BaseChannel* first_channel = GetChannel(transport_name); 1135 cricket::BaseChannel* first_channel = GetChannel(transport_name);
1064 1136
1065 #ifdef HAVE_QUIC 1137 #ifdef HAVE_QUIC
(...skipping 1021 matching lines...)
2087 } 2159 }
2088 2160
2089 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { 2161 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) {
2090 if (metrics_observer_) { 2162 if (metrics_observer_) {
2091 metrics_observer_->IncrementEnumCounter( 2163 metrics_observer_->IncrementEnumCounter(
2092 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), 2164 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error),
2093 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); 2165 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE));
2094 } 2166 }
2095 } 2167 }
2096 } // namespace webrtc 2168 } // namespace webrtc
OLDNEW

Powered by Google App Engine