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 | |
77 void PrintTo(const RTCOutboundRTPStreamStats& stats, ::std::ostream* os) { | 73 void PrintTo(const RTCOutboundRTPStreamStats& stats, ::std::ostream* os) { |
78 *os << stats.ToString(); | 74 *os << stats.ToString(); |
79 } | 75 } |
80 | 76 |
81 void PrintTo(const RTCTransportStats& stats, ::std::ostream* os) { | 77 void PrintTo(const RTCTransportStats& stats, ::std::ostream* os) { |
82 *os << stats.ToString(); | 78 *os << stats.ToString(); |
83 } | 79 } |
84 | 80 |
85 namespace { | 81 namespace { |
86 | 82 |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 // channels that have been opened and closed, not the numbers currently | 968 // channels that have been opened and closed, not the numbers currently |
973 // open/closed, we would expect opened >= closed and (opened - closed) to be | 969 // open/closed, we would expect opened >= closed and (opened - closed) to be |
974 // the number currently open. crbug.com/636818. | 970 // the number currently open. crbug.com/636818. |
975 const RTCPeerConnectionStats& pcstats = | 971 const RTCPeerConnectionStats& pcstats = |
976 stats->cast_to<RTCPeerConnectionStats>(); | 972 stats->cast_to<RTCPeerConnectionStats>(); |
977 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); | 973 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); |
978 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); | 974 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); |
979 } | 975 } |
980 } | 976 } |
981 | 977 |
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 | |
1092 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { | 978 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
1093 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 979 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
1094 cricket::VoiceChannel voice_channel( | 980 cricket::VoiceChannel voice_channel( |
1095 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 981 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
1096 voice_media_channel, nullptr, "VoiceContentName", false); | 982 voice_media_channel, nullptr, "VoiceContentName", false); |
1097 | 983 |
1098 cricket::VoiceMediaInfo voice_media_info; | 984 cricket::VoiceMediaInfo voice_media_info; |
1099 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); | 985 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); |
1100 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 986 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
1101 voice_media_info.senders[0].local_stats[0].ssrc = 1; | 987 voice_media_info.senders[0].local_stats[0].ssrc = 1; |
1102 voice_media_info.senders[0].packets_sent = 2; | 988 voice_media_info.senders[0].packets_sent = 2; |
1103 voice_media_info.senders[0].bytes_sent = 3; | 989 voice_media_info.senders[0].bytes_sent = 3; |
1104 voice_media_info.senders[0].rtt_ms = 4500; | 990 voice_media_info.senders[0].rtt_ms = 4500.0; |
1105 EXPECT_CALL(*voice_media_channel, GetStats(_)) | 991 EXPECT_CALL(*voice_media_channel, GetStats(_)) |
1106 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); | 992 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
1107 | 993 |
1108 SessionStats session_stats; | 994 SessionStats session_stats; |
1109 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; | 995 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; |
1110 session_stats.transport_stats["TransportName"].transport_name = | 996 session_stats.transport_stats["TransportName"].transport_name = |
1111 "TransportName"; | 997 "TransportName"; |
1112 | 998 |
1113 // Make sure the associated |RTCTransportStats| is created. | 999 // Make sure the associated |RTCTransportStats| is created. |
1114 cricket::TransportChannelStats channel_stats; | 1000 cricket::TransportChannelStats channel_stats; |
1115 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1001 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); |
1116 session_stats.transport_stats["TransportName"].channel_stats.push_back( | 1008 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
1117 channel_stats); | 1009 channel_stats); |
1118 | 1010 |
1119 EXPECT_CALL(test_->session(), GetTransportStats(_)) | 1011 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
1120 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | 1012 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
1121 EXPECT_CALL(test_->session(), voice_channel()) | 1013 EXPECT_CALL(test_->session(), voice_channel()) |
1122 .WillRepeatedly(Return(&voice_channel)); | 1014 .WillRepeatedly(Return(&voice_channel)); |
1123 | 1015 |
1124 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1016 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1125 | 1017 |
(...skipping 24 matching lines...) Expand all Loading... |
1150 | 1042 |
1151 cricket::VideoMediaInfo video_media_info; | 1043 cricket::VideoMediaInfo video_media_info; |
1152 video_media_info.senders.push_back(cricket::VideoSenderInfo()); | 1044 video_media_info.senders.push_back(cricket::VideoSenderInfo()); |
1153 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 1045 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
1154 video_media_info.senders[0].local_stats[0].ssrc = 1; | 1046 video_media_info.senders[0].local_stats[0].ssrc = 1; |
1155 video_media_info.senders[0].firs_rcvd = 2; | 1047 video_media_info.senders[0].firs_rcvd = 2; |
1156 video_media_info.senders[0].plis_rcvd = 3; | 1048 video_media_info.senders[0].plis_rcvd = 3; |
1157 video_media_info.senders[0].nacks_rcvd = 4; | 1049 video_media_info.senders[0].nacks_rcvd = 4; |
1158 video_media_info.senders[0].packets_sent = 5; | 1050 video_media_info.senders[0].packets_sent = 5; |
1159 video_media_info.senders[0].bytes_sent = 6; | 1051 video_media_info.senders[0].bytes_sent = 6; |
1160 video_media_info.senders[0].rtt_ms = 7500; | 1052 video_media_info.senders[0].rtt_ms = 7500.0; |
1161 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1053 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1162 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1054 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1163 | 1055 |
1164 SessionStats session_stats; | 1056 SessionStats session_stats; |
1165 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; | 1057 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; |
1166 session_stats.transport_stats["TransportName"].transport_name = | 1058 session_stats.transport_stats["TransportName"].transport_name = |
1167 "TransportName"; | 1059 "TransportName"; |
1168 | 1060 |
1169 // Make sure the associated |RTCTransportStats| is created. | 1061 // Make sure the associated |RTCTransportStats| is created. |
1170 cricket::TransportChannelStats channel_stats; | 1062 cricket::TransportChannelStats channel_stats; |
1171 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1063 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); |
1172 session_stats.transport_stats["TransportName"].channel_stats.push_back( | 1070 session_stats.transport_stats["TransportName"].channel_stats.push_back( |
1173 channel_stats); | 1071 channel_stats); |
1174 | 1072 |
1175 EXPECT_CALL(test_->session(), GetTransportStats(_)) | 1073 EXPECT_CALL(test_->session(), GetTransportStats(_)) |
1176 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | 1074 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); |
1177 EXPECT_CALL(test_->session(), video_channel()) | 1075 EXPECT_CALL(test_->session(), video_channel()) |
1178 .WillRepeatedly(Return(&video_channel)); | 1076 .WillRepeatedly(Return(&video_channel)); |
1179 | 1077 |
1180 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1078 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1181 | 1079 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1211 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
1314 }; | 1212 }; |
1315 | 1213 |
1316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1214 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
1317 collector_->VerifyThreadUsageAndResultsMerging(); | 1215 collector_->VerifyThreadUsageAndResultsMerging(); |
1318 } | 1216 } |
1319 | 1217 |
1320 } // namespace | 1218 } // namespace |
1321 | 1219 |
1322 } // namespace webrtc | 1220 } // namespace webrtc |
OLD | NEW |