OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 void PrintTo(const RTCRemoteIceCandidateStats& stats, ::std::ostream* os) { | 65 void PrintTo(const RTCRemoteIceCandidateStats& stats, ::std::ostream* os) { |
66 *os << stats.ToString(); | 66 *os << stats.ToString(); |
67 } | 67 } |
68 | 68 |
69 void PrintTo(const RTCPeerConnectionStats& stats, ::std::ostream* os) { | 69 void PrintTo(const RTCPeerConnectionStats& stats, ::std::ostream* os) { |
70 *os << stats.ToString(); | 70 *os << stats.ToString(); |
71 } | 71 } |
72 | 72 |
| 73 void PrintTo(const RTCInboundRTPStreamStats& stats, ::std::ostream* os) { |
| 74 *os << stats.ToString(); |
| 75 } |
| 76 |
73 void PrintTo(const RTCOutboundRTPStreamStats& stats, ::std::ostream* os) { | 77 void PrintTo(const RTCOutboundRTPStreamStats& stats, ::std::ostream* os) { |
74 *os << stats.ToString(); | 78 *os << stats.ToString(); |
75 } | 79 } |
76 | 80 |
77 void PrintTo(const RTCTransportStats& stats, ::std::ostream* os) { | 81 void PrintTo(const RTCTransportStats& stats, ::std::ostream* os) { |
78 *os << stats.ToString(); | 82 *os << stats.ToString(); |
79 } | 83 } |
80 | 84 |
81 namespace { | 85 namespace { |
82 | 86 |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 // channels that have been opened and closed, not the numbers currently | 972 // channels that have been opened and closed, not the numbers currently |
969 // open/closed, we would expect opened >= closed and (opened - closed) to be | 973 // open/closed, we would expect opened >= closed and (opened - closed) to be |
970 // the number currently open. crbug.com/636818. | 974 // the number currently open. crbug.com/636818. |
971 const RTCPeerConnectionStats& pcstats = | 975 const RTCPeerConnectionStats& pcstats = |
972 stats->cast_to<RTCPeerConnectionStats>(); | 976 stats->cast_to<RTCPeerConnectionStats>(); |
973 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); | 977 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); |
974 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); | 978 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); |
975 } | 979 } |
976 } | 980 } |
977 | 981 |
| 982 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { |
| 983 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
| 984 cricket::VoiceChannel voice_channel( |
| 985 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
| 986 voice_media_channel, nullptr, "VoiceContentName", false); |
| 987 |
| 988 cricket::VoiceMediaInfo voice_media_info; |
| 989 voice_media_info.receivers.push_back(cricket::VoiceReceiverInfo()); |
| 990 voice_media_info.receivers[0].local_stats.push_back( |
| 991 cricket::SsrcReceiverInfo()); |
| 992 voice_media_info.receivers[0].local_stats[0].ssrc = 1; |
| 993 voice_media_info.receivers[0].packets_rcvd = 2; |
| 994 voice_media_info.receivers[0].bytes_rcvd = 3; |
| 995 voice_media_info.receivers[0].jitter_ms = 4500; |
| 996 voice_media_info.receivers[0].fraction_lost = 5.5f; |
| 997 EXPECT_CALL(*voice_media_channel, GetStats(_)) |
| 998 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
| 999 |
| 1000 SessionStats session_stats; |
| 1001 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; |
| 1002 session_stats.transport_stats["TransportName"].transport_name = |
| 1003 "TransportName"; |
| 1004 |
| 1005 // Make sure the associated |RTCTransportStats| is created. |
| 1006 cricket::TransportChannelStats channel_stats; |
| 1007 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
| 1008 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
| 1009 channel_stats); |
| 1010 |
| 1011 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
| 1012 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
| 1013 EXPECT_CALL(test_->session(), voice_channel()) |
| 1014 .WillRepeatedly(Return(&voice_channel)); |
| 1015 |
| 1016 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1017 |
| 1018 RTCInboundRTPStreamStats expected_audio( |
| 1019 "RTCInboundRTPAudioStream_1", report->timestamp_us()); |
| 1020 expected_audio.ssrc = "1"; |
| 1021 expected_audio.is_remote = false; |
| 1022 expected_audio.media_type = "audio"; |
| 1023 expected_audio.transport_id = "RTCTransport_TransportName_" + |
| 1024 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 1025 expected_audio.packets_received = 2; |
| 1026 expected_audio.bytes_received = 3; |
| 1027 expected_audio.jitter = 4.5; |
| 1028 expected_audio.fraction_lost = 5.5; |
| 1029 |
| 1030 ASSERT(report->Get(expected_audio.id())); |
| 1031 const RTCInboundRTPStreamStats& audio = report->Get( |
| 1032 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); |
| 1033 EXPECT_EQ(audio, expected_audio); |
| 1034 |
| 1035 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); |
| 1036 } |
| 1037 |
| 1038 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { |
| 1039 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
| 1040 cricket::VideoChannel video_channel( |
| 1041 test_->worker_thread(), test_->network_thread(), video_media_channel, |
| 1042 nullptr, "VideoContentName", false); |
| 1043 |
| 1044 cricket::VideoMediaInfo video_media_info; |
| 1045 video_media_info.receivers.push_back(cricket::VideoReceiverInfo()); |
| 1046 video_media_info.receivers[0].local_stats.push_back( |
| 1047 cricket::SsrcReceiverInfo()); |
| 1048 video_media_info.receivers[0].local_stats[0].ssrc = 1; |
| 1049 video_media_info.receivers[0].packets_rcvd = 2; |
| 1050 video_media_info.receivers[0].bytes_rcvd = 3; |
| 1051 video_media_info.receivers[0].fraction_lost = 4.5f; |
| 1052 EXPECT_CALL(*video_media_channel, GetStats(_)) |
| 1053 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
| 1054 |
| 1055 SessionStats session_stats; |
| 1056 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; |
| 1057 session_stats.transport_stats["TransportName"].transport_name = |
| 1058 "TransportName"; |
| 1059 |
| 1060 // Make sure the associated |RTCTransportStats| is created. |
| 1061 cricket::TransportChannelStats channel_stats; |
| 1062 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
| 1063 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
| 1064 channel_stats); |
| 1065 |
| 1066 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
| 1067 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
| 1068 EXPECT_CALL(test_->session(), video_channel()) |
| 1069 .WillRepeatedly(Return(&video_channel)); |
| 1070 |
| 1071 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1072 |
| 1073 RTCInboundRTPStreamStats expected_audio( |
| 1074 "RTCInboundRTPVideoStream_1", report->timestamp_us()); |
| 1075 expected_audio.ssrc = "1"; |
| 1076 expected_audio.is_remote = false; |
| 1077 expected_audio.media_type = "video"; |
| 1078 expected_audio.transport_id = "RTCTransport_TransportName_" + |
| 1079 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 1080 expected_audio.packets_received = 2; |
| 1081 expected_audio.bytes_received = 3; |
| 1082 expected_audio.fraction_lost = 4.5; |
| 1083 |
| 1084 ASSERT(report->Get(expected_audio.id())); |
| 1085 const RTCInboundRTPStreamStats& audio = report->Get( |
| 1086 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); |
| 1087 EXPECT_EQ(audio, expected_audio); |
| 1088 |
| 1089 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); |
| 1090 } |
| 1091 |
978 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { | 1092 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
979 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 1093 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
980 cricket::VoiceChannel voice_channel( | 1094 cricket::VoiceChannel voice_channel( |
981 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1095 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
982 voice_media_channel, nullptr, "VoiceContentName", false); | 1096 voice_media_channel, nullptr, "VoiceContentName", false); |
983 | 1097 |
984 cricket::VoiceMediaInfo voice_media_info; | 1098 cricket::VoiceMediaInfo voice_media_info; |
985 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); | 1099 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); |
986 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 1100 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
987 voice_media_info.senders[0].local_stats[0].ssrc = 1; | 1101 voice_media_info.senders[0].local_stats[0].ssrc = 1; |
988 voice_media_info.senders[0].packets_sent = 2; | 1102 voice_media_info.senders[0].packets_sent = 2; |
989 voice_media_info.senders[0].bytes_sent = 3; | 1103 voice_media_info.senders[0].bytes_sent = 3; |
990 voice_media_info.senders[0].rtt_ms = 4500.0; | 1104 voice_media_info.senders[0].rtt_ms = 4500; |
991 EXPECT_CALL(*voice_media_channel, GetStats(_)) | 1105 EXPECT_CALL(*voice_media_channel, GetStats(_)) |
992 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); | 1106 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
993 | 1107 |
994 SessionStats session_stats; | 1108 SessionStats session_stats; |
995 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; | 1109 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; |
996 session_stats.transport_stats["TransportName"].transport_name = | 1110 session_stats.transport_stats["TransportName"].transport_name = |
997 "TransportName"; | 1111 "TransportName"; |
998 | 1112 |
999 // Make sure the associated |RTCTransportStats| is created. | 1113 // Make sure the associated |RTCTransportStats| is created. |
1000 cricket::TransportChannelStats channel_stats; | 1114 cricket::TransportChannelStats channel_stats; |
1001 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1115 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
1002 cricket::ConnectionInfo connection_info; | |
1003 connection_info.local_candidate = *CreateFakeCandidate( | |
1004 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
1005 connection_info.remote_candidate = *CreateFakeCandidate( | |
1006 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
1007 channel_stats.connection_infos.push_back(connection_info); | |
1008 session_stats.transport_stats["TransportName"].channel_stats.push_back( | 1116 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
1009 channel_stats); | 1117 channel_stats); |
1010 | 1118 |
1011 EXPECT_CALL(test_->session(), GetTransportStats(_)) | 1119 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
1012 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | 1120 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
1013 EXPECT_CALL(test_->session(), voice_channel()) | 1121 EXPECT_CALL(test_->session(), voice_channel()) |
1014 .WillRepeatedly(Return(&voice_channel)); | 1122 .WillRepeatedly(Return(&voice_channel)); |
1015 | 1123 |
1016 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1124 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1017 | 1125 |
(...skipping 24 matching lines...) Expand all Loading... |
1042 | 1150 |
1043 cricket::VideoMediaInfo video_media_info; | 1151 cricket::VideoMediaInfo video_media_info; |
1044 video_media_info.senders.push_back(cricket::VideoSenderInfo()); | 1152 video_media_info.senders.push_back(cricket::VideoSenderInfo()); |
1045 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 1153 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
1046 video_media_info.senders[0].local_stats[0].ssrc = 1; | 1154 video_media_info.senders[0].local_stats[0].ssrc = 1; |
1047 video_media_info.senders[0].firs_rcvd = 2; | 1155 video_media_info.senders[0].firs_rcvd = 2; |
1048 video_media_info.senders[0].plis_rcvd = 3; | 1156 video_media_info.senders[0].plis_rcvd = 3; |
1049 video_media_info.senders[0].nacks_rcvd = 4; | 1157 video_media_info.senders[0].nacks_rcvd = 4; |
1050 video_media_info.senders[0].packets_sent = 5; | 1158 video_media_info.senders[0].packets_sent = 5; |
1051 video_media_info.senders[0].bytes_sent = 6; | 1159 video_media_info.senders[0].bytes_sent = 6; |
1052 video_media_info.senders[0].rtt_ms = 7500.0; | 1160 video_media_info.senders[0].rtt_ms = 7500; |
1053 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1161 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1054 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1162 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1055 | 1163 |
1056 SessionStats session_stats; | 1164 SessionStats session_stats; |
1057 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; | 1165 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; |
1058 session_stats.transport_stats["TransportName"].transport_name = | 1166 session_stats.transport_stats["TransportName"].transport_name = |
1059 "TransportName"; | 1167 "TransportName"; |
1060 | 1168 |
1061 // Make sure the associated |RTCTransportStats| is created. | 1169 // Make sure the associated |RTCTransportStats| is created. |
1062 cricket::TransportChannelStats channel_stats; | 1170 cricket::TransportChannelStats channel_stats; |
1063 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1171 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
1064 cricket::ConnectionInfo connection_info; | |
1065 connection_info.local_candidate = *CreateFakeCandidate( | |
1066 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
1067 connection_info.remote_candidate = *CreateFakeCandidate( | |
1068 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
1069 channel_stats.connection_infos.push_back(connection_info); | |
1070 session_stats.transport_stats["TransportName"].channel_stats.push_back( | 1172 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
1071 channel_stats); | 1173 channel_stats); |
1072 | 1174 |
1073 EXPECT_CALL(test_->session(), GetTransportStats(_)) | 1175 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
1074 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | 1176 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
1075 EXPECT_CALL(test_->session(), video_channel()) | 1177 EXPECT_CALL(test_->session(), video_channel()) |
1076 .WillRepeatedly(Return(&video_channel)); | 1178 .WillRepeatedly(Return(&video_channel)); |
1077 | 1179 |
1078 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1180 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1079 | 1181 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
1212 }; | 1314 }; |
1213 | 1315 |
1214 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
1215 collector_->VerifyThreadUsageAndResultsMerging(); | 1317 collector_->VerifyThreadUsageAndResultsMerging(); |
1216 } | 1318 } |
1217 | 1319 |
1218 } // namespace | 1320 } // namespace |
1219 | 1321 |
1220 } // namespace webrtc | 1322 } // namespace webrtc |
OLD | NEW |