Chromium Code Reviews| 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_buffer_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 cricket::ConnectionInfo connection_info; | |
| 1009 connection_info.local_candidate = *CreateFakeCandidate( | |
| 1010 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
| 1011 connection_info.remote_candidate = *CreateFakeCandidate( | |
| 1012 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
| 1013 channel_stats.connection_infos.push_back(connection_info); | |
|
Taylor Brandstetter
2016/10/27 21:26:03
Is this connection_info needed?
hbos
2016/10/28 10:03:48
Ah, it isn't, removed here and other places.
| |
| 1014 session_stats.transport_stats["TransportName"].channel_stats.push_back( | |
| 1015 channel_stats); | |
| 1016 | |
| 1017 EXPECT_CALL(test_->session(), GetTransportStats(_)) | |
| 1018 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | |
| 1019 EXPECT_CALL(test_->session(), voice_channel()) | |
| 1020 .WillRepeatedly(Return(&voice_channel)); | |
| 1021 | |
| 1022 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 1023 | |
| 1024 RTCInboundRTPStreamStats expected_audio( | |
| 1025 "RTCInboundRTPAudioStream_1", report->timestamp_us()); | |
| 1026 expected_audio.ssrc = "1"; | |
| 1027 expected_audio.is_remote = false; | |
| 1028 expected_audio.media_type = "audio"; | |
| 1029 expected_audio.transport_id = "RTCTransport_TransportName_" + | |
| 1030 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); | |
| 1031 expected_audio.packets_received = 2; | |
| 1032 expected_audio.bytes_received = 3; | |
| 1033 expected_audio.jitter = 4.5; | |
| 1034 expected_audio.fraction_lost = 5.5; | |
| 1035 | |
| 1036 ASSERT(report->Get(expected_audio.id())); | |
| 1037 const RTCInboundRTPStreamStats& audio = report->Get( | |
| 1038 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); | |
| 1039 EXPECT_EQ(audio, expected_audio); | |
| 1040 | |
| 1041 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); | |
| 1042 } | |
| 1043 | |
| 1044 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { | |
| 1045 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | |
| 1046 cricket::VideoChannel video_channel( | |
| 1047 test_->worker_thread(), test_->network_thread(), video_media_channel, | |
| 1048 nullptr, "VideoContentName", false); | |
| 1049 | |
| 1050 cricket::VideoMediaInfo video_media_info; | |
| 1051 video_media_info.receivers.push_back(cricket::VideoReceiverInfo()); | |
| 1052 video_media_info.receivers[0].local_stats.push_back( | |
| 1053 cricket::SsrcReceiverInfo()); | |
| 1054 video_media_info.receivers[0].local_stats[0].ssrc = 1; | |
| 1055 video_media_info.receivers[0].packets_rcvd = 2; | |
| 1056 video_media_info.receivers[0].bytes_rcvd = 3; | |
| 1057 video_media_info.receivers[0].jitter_buffer_ms = 4500; | |
| 1058 video_media_info.receivers[0].fraction_lost = 5.5f; | |
| 1059 EXPECT_CALL(*video_media_channel, GetStats(_)) | |
| 1060 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | |
| 1061 | |
| 1062 SessionStats session_stats; | |
| 1063 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; | |
| 1064 session_stats.transport_stats["TransportName"].transport_name = | |
| 1065 "TransportName"; | |
| 1066 | |
| 1067 // Make sure the associated |RTCTransportStats| is created. | |
| 1068 cricket::TransportChannelStats channel_stats; | |
| 1069 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | |
| 1070 cricket::ConnectionInfo connection_info; | |
| 1071 connection_info.local_candidate = *CreateFakeCandidate( | |
| 1072 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
| 1073 connection_info.remote_candidate = *CreateFakeCandidate( | |
| 1074 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42).get(); | |
| 1075 channel_stats.connection_infos.push_back(connection_info); | |
| 1076 session_stats.transport_stats["TransportName"].channel_stats.push_back( | |
| 1077 channel_stats); | |
| 1078 | |
| 1079 EXPECT_CALL(test_->session(), GetTransportStats(_)) | |
| 1080 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); | |
| 1081 EXPECT_CALL(test_->session(), video_channel()) | |
| 1082 .WillRepeatedly(Return(&video_channel)); | |
| 1083 | |
| 1084 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 1085 | |
| 1086 RTCInboundRTPStreamStats expected_audio( | |
| 1087 "RTCInboundRTPVideoStream_1", report->timestamp_us()); | |
| 1088 expected_audio.ssrc = "1"; | |
| 1089 expected_audio.is_remote = false; | |
| 1090 expected_audio.media_type = "video"; | |
| 1091 expected_audio.transport_id = "RTCTransport_TransportName_" + | |
| 1092 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); | |
| 1093 expected_audio.packets_received = 2; | |
| 1094 expected_audio.bytes_received = 3; | |
| 1095 expected_audio.jitter = 4.5; | |
| 1096 expected_audio.fraction_lost = 5.5; | |
| 1097 | |
| 1098 ASSERT(report->Get(expected_audio.id())); | |
| 1099 const RTCInboundRTPStreamStats& audio = report->Get( | |
| 1100 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); | |
| 1101 EXPECT_EQ(audio, expected_audio); | |
| 1102 | |
| 1103 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); | |
| 1104 } | |
| 1105 | |
| 978 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { | 1106 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
| 979 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 1107 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
| 980 cricket::VoiceChannel voice_channel( | 1108 cricket::VoiceChannel voice_channel( |
| 981 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1109 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
| 982 voice_media_channel, nullptr, "VoiceContentName", false); | 1110 voice_media_channel, nullptr, "VoiceContentName", false); |
| 983 | 1111 |
| 984 cricket::VoiceMediaInfo voice_media_info; | 1112 cricket::VoiceMediaInfo voice_media_info; |
| 985 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); | 1113 voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); |
| 986 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 1114 voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
| 987 voice_media_info.senders[0].local_stats[0].ssrc = 1; | 1115 voice_media_info.senders[0].local_stats[0].ssrc = 1; |
| 988 voice_media_info.senders[0].packets_sent = 2; | 1116 voice_media_info.senders[0].packets_sent = 2; |
| 989 voice_media_info.senders[0].bytes_sent = 3; | 1117 voice_media_info.senders[0].bytes_sent = 3; |
| 990 voice_media_info.senders[0].rtt_ms = 4500.0; | 1118 voice_media_info.senders[0].rtt_ms = 4500; |
| 991 EXPECT_CALL(*voice_media_channel, GetStats(_)) | 1119 EXPECT_CALL(*voice_media_channel, GetStats(_)) |
| 992 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); | 1120 .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
| 993 | 1121 |
| 994 SessionStats session_stats; | 1122 SessionStats session_stats; |
| 995 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; | 1123 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; |
| 996 session_stats.transport_stats["TransportName"].transport_name = | 1124 session_stats.transport_stats["TransportName"].transport_name = |
| 997 "TransportName"; | 1125 "TransportName"; |
| 998 | 1126 |
| 999 // Make sure the associated |RTCTransportStats| is created. | 1127 // Make sure the associated |RTCTransportStats| is created. |
| 1000 cricket::TransportChannelStats channel_stats; | 1128 cricket::TransportChannelStats channel_stats; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1042 | 1170 |
| 1043 cricket::VideoMediaInfo video_media_info; | 1171 cricket::VideoMediaInfo video_media_info; |
| 1044 video_media_info.senders.push_back(cricket::VideoSenderInfo()); | 1172 video_media_info.senders.push_back(cricket::VideoSenderInfo()); |
| 1045 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); | 1173 video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
| 1046 video_media_info.senders[0].local_stats[0].ssrc = 1; | 1174 video_media_info.senders[0].local_stats[0].ssrc = 1; |
| 1047 video_media_info.senders[0].firs_rcvd = 2; | 1175 video_media_info.senders[0].firs_rcvd = 2; |
| 1048 video_media_info.senders[0].plis_rcvd = 3; | 1176 video_media_info.senders[0].plis_rcvd = 3; |
| 1049 video_media_info.senders[0].nacks_rcvd = 4; | 1177 video_media_info.senders[0].nacks_rcvd = 4; |
| 1050 video_media_info.senders[0].packets_sent = 5; | 1178 video_media_info.senders[0].packets_sent = 5; |
| 1051 video_media_info.senders[0].bytes_sent = 6; | 1179 video_media_info.senders[0].bytes_sent = 6; |
| 1052 video_media_info.senders[0].rtt_ms = 7500.0; | 1180 video_media_info.senders[0].rtt_ms = 7500; |
| 1053 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1181 EXPECT_CALL(*video_media_channel, GetStats(_)) |
| 1054 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1182 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
| 1055 | 1183 |
| 1056 SessionStats session_stats; | 1184 SessionStats session_stats; |
| 1057 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; | 1185 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; |
| 1058 session_stats.transport_stats["TransportName"].transport_name = | 1186 session_stats.transport_stats["TransportName"].transport_name = |
| 1059 "TransportName"; | 1187 "TransportName"; |
| 1060 | 1188 |
| 1061 // Make sure the associated |RTCTransportStats| is created. | 1189 // Make sure the associated |RTCTransportStats| is created. |
| 1062 cricket::TransportChannelStats channel_stats; | 1190 cricket::TransportChannelStats channel_stats; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1211 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1339 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
| 1212 }; | 1340 }; |
| 1213 | 1341 |
| 1214 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1342 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
| 1215 collector_->VerifyThreadUsageAndResultsMerging(); | 1343 collector_->VerifyThreadUsageAndResultsMerging(); |
| 1216 } | 1344 } |
| 1217 | 1345 |
| 1218 } // namespace | 1346 } // namespace |
| 1219 | 1347 |
| 1220 } // namespace webrtc | 1348 } // namespace webrtc |
| OLD | NEW |