Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Side by Side Diff: webrtc/video/send_statistics_proxy_unittest.cc

Issue 2536613002: Use RateAccCounter for sent bitrate stats. Reports average of periodically computed stats over a ca… (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | webrtc/video/stats_counter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 EXPECT_TRUE(GetStreamStats(kFlexFecSsrc).is_flexfec); 1082 EXPECT_TRUE(GetStreamStats(kFlexFecSsrc).is_flexfec);
1083 } 1083 }
1084 1084
1085 TEST_F(SendStatisticsProxyTest, SendBitratesAreReportedWithFlexFecEnabled) { 1085 TEST_F(SendStatisticsProxyTest, SendBitratesAreReportedWithFlexFecEnabled) {
1086 statistics_proxy_.reset( 1086 statistics_proxy_.reset(
1087 new SendStatisticsProxy(&fake_clock_, GetTestConfigWithFlexFec(), 1087 new SendStatisticsProxy(&fake_clock_, GetTestConfigWithFlexFec(),
1088 VideoEncoderConfig::ContentType::kRealtimeVideo)); 1088 VideoEncoderConfig::ContentType::kRealtimeVideo));
1089 1089
1090 StreamDataCountersCallback* proxy = 1090 StreamDataCountersCallback* proxy =
1091 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get()); 1091 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get());
1092
1093 StreamDataCounters counters; 1092 StreamDataCounters counters;
1094 StreamDataCounters rtx_counters; 1093 StreamDataCounters rtx_counters;
1095 proxy->DataCountersUpdated(counters, kFirstSsrc);
1096 proxy->DataCountersUpdated(counters, kSecondSsrc);
1097 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
1098 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
1099 proxy->DataCountersUpdated(counters, kFlexFecSsrc);
1100 1094
1101 counters.transmitted.header_bytes = 5000; 1095 const int kMinRequiredPeriodSamples = 8;
1102 counters.transmitted.packets = 20; 1096 const int kPeriodIntervalMs = 2000;
1103 counters.transmitted.padding_bytes = 10000; 1097 for (int i = 0; i < kMinRequiredPeriodSamples; ++i) {
1104 counters.transmitted.payload_bytes = 20000; 1098 counters.transmitted.packets += 20;
1105 counters.retransmitted.header_bytes = 400; 1099 counters.transmitted.header_bytes += 500;
1106 counters.retransmitted.packets = 2; 1100 counters.transmitted.padding_bytes += 1000;
1107 counters.retransmitted.padding_bytes = 1000; 1101 counters.transmitted.payload_bytes += 2000;
1108 counters.retransmitted.payload_bytes = 2000; 1102 counters.retransmitted.packets += 2;
1109 counters.fec = counters.retransmitted; 1103 counters.retransmitted.header_bytes += 25;
1110 rtx_counters.transmitted = counters.transmitted; 1104 counters.retransmitted.padding_bytes += 100;
1105 counters.retransmitted.payload_bytes += 250;
1106 counters.fec = counters.retransmitted;
1107 rtx_counters.transmitted = counters.transmitted;
1108 // Advance one interval and update counters.
1109 fake_clock_.AdvanceTimeMilliseconds(kPeriodIntervalMs);
1110 proxy->DataCountersUpdated(counters, kFirstSsrc);
1111 proxy->DataCountersUpdated(counters, kSecondSsrc);
1112 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
1113 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
1114 proxy->DataCountersUpdated(counters, kFlexFecSsrc);
1115 }
1111 1116
1112 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds);
1113 proxy->DataCountersUpdated(counters, kFirstSsrc);
1114 proxy->DataCountersUpdated(counters, kSecondSsrc);
1115 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
1116 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
1117 proxy->DataCountersUpdated(counters, kFlexFecSsrc);
1118
1119 // Reset stats proxy causes histograms to be reported.
1120 statistics_proxy_.reset(); 1117 statistics_proxy_.reset();
1118 // Interval: 3500 bytes * 4 / 2 sec = 7000 bytes / sec = 56 kbps
1121 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); 1119 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps"));
1122 EXPECT_EQ(1, 1120 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.BitrateSentInKbps", 56));
1123 metrics::NumEvents( 1121 // Interval: 3500 bytes * 2 / 2 sec = 3500 bytes / sec = 28 kbps
1124 "WebRTC.Video.BitrateSentInKbps", 1122 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RtxBitrateSentInKbps"));
1125 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / 1123 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.RtxBitrateSentInKbps", 28));
1126 metrics::kMinRunTimeInSeconds / 1000))); 1124 // Interval: (2000 - 2 * 250) bytes / 2 sec = 1500 bytes / sec = 12 kbps
1127
1128 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps")); 1125 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps"));
1129 EXPECT_EQ(1, metrics::NumEvents( 1126 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.MediaBitrateSentInKbps", 12));
1130 "WebRTC.Video.MediaBitrateSentInKbps", 1127 // Interval: 1000 bytes * 4 / 2 sec = 2000 bytes / sec = 16 kbps
1131 static_cast<int>((counters.MediaPayloadBytes() * 2 * 8) /
1132 metrics::kMinRunTimeInSeconds / 1000)));
1133
1134 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PaddingBitrateSentInKbps")); 1128 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PaddingBitrateSentInKbps"));
1135 EXPECT_EQ(1, 1129 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.PaddingBitrateSentInKbps", 16));
1136 metrics::NumEvents( 1130 // Interval: 375 bytes * 2 / 2 sec = 375 bytes / sec = 3 kbps
1137 "WebRTC.Video.PaddingBitrateSentInKbps", 1131 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps"));
1138 static_cast<int>((counters.transmitted.padding_bytes * 4 * 8) / 1132 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.FecBitrateSentInKbps", 3));
1139 metrics::kMinRunTimeInSeconds / 1000))); 1133 // Interval: 375 bytes * 2 / 2 sec = 375 bytes / sec = 3 kbps
1140
1141 EXPECT_EQ(1, 1134 EXPECT_EQ(1,
1142 metrics::NumSamples("WebRTC.Video.RetransmittedBitrateSentInKbps")); 1135 metrics::NumSamples("WebRTC.Video.RetransmittedBitrateSentInKbps"));
1143 EXPECT_EQ(1,
1144 metrics::NumEvents(
1145 "WebRTC.Video.RetransmittedBitrateSentInKbps",
1146 static_cast<int>((counters.retransmitted.TotalBytes() * 2 * 8) /
1147 metrics::kMinRunTimeInSeconds / 1000)));
1148
1149 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RtxBitrateSentInKbps"));
1150 EXPECT_EQ( 1136 EXPECT_EQ(
1151 1, metrics::NumEvents( 1137 1, metrics::NumEvents("WebRTC.Video.RetransmittedBitrateSentInKbps", 3));
1152 "WebRTC.Video.RtxBitrateSentInKbps",
1153 static_cast<int>((rtx_counters.transmitted.TotalBytes() * 2 * 8) /
1154 metrics::kMinRunTimeInSeconds / 1000)));
1155
1156 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps"));
1157 EXPECT_EQ(1, metrics::NumEvents(
1158 "WebRTC.Video.FecBitrateSentInKbps",
1159 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) /
1160 metrics::kMinRunTimeInSeconds / 1000)));
1161 } 1138 }
1162 1139
1163 TEST_F(SendStatisticsProxyTest, ResetsRtpCountersOnContentChange) { 1140 TEST_F(SendStatisticsProxyTest, ResetsRtpCountersOnContentChange) {
1164 StreamDataCountersCallback* proxy = 1141 StreamDataCountersCallback* proxy =
1165 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get()); 1142 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get());
1166 StreamDataCounters counters; 1143 StreamDataCounters counters;
1167 StreamDataCounters rtx_counters; 1144 StreamDataCounters rtx_counters;
1168 counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds(); 1145 counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds();
1169 proxy->DataCountersUpdated(counters, kFirstSsrc); 1146
1170 proxy->DataCountersUpdated(counters, kSecondSsrc); 1147 const int kMinRequiredPeriodSamples = 8;
1171 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); 1148 const int kPeriodIntervalMs = 2000;
1172 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); 1149 for (int i = 0; i < kMinRequiredPeriodSamples; ++i) {
1173 1150 counters.transmitted.packets += 20;
1174 counters.transmitted.header_bytes = 5000; 1151 counters.transmitted.header_bytes += 500;
1175 counters.transmitted.packets = 20; 1152 counters.transmitted.padding_bytes += 1000;
1176 counters.transmitted.padding_bytes = 10000; 1153 counters.transmitted.payload_bytes += 2000;
1177 counters.transmitted.payload_bytes = 20000; 1154 counters.retransmitted.packets += 2;
1178 1155 counters.retransmitted.header_bytes += 25;
1179 counters.retransmitted.header_bytes = 400; 1156 counters.retransmitted.padding_bytes += 100;
1180 counters.retransmitted.packets = 2; 1157 counters.retransmitted.payload_bytes += 250;
1181 counters.retransmitted.padding_bytes = 1000; 1158 counters.fec = counters.retransmitted;
1182 counters.retransmitted.payload_bytes = 2000; 1159 rtx_counters.transmitted = counters.transmitted;
1183 1160 // Advance one interval and update counters.
1184 counters.fec = counters.retransmitted; 1161 fake_clock_.AdvanceTimeMilliseconds(kPeriodIntervalMs);
1185 1162 proxy->DataCountersUpdated(counters, kFirstSsrc);
1186 rtx_counters.transmitted = counters.transmitted; 1163 proxy->DataCountersUpdated(counters, kSecondSsrc);
1187 1164 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
1188 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); 1165 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
1189 proxy->DataCountersUpdated(counters, kFirstSsrc); 1166 }
1190 proxy->DataCountersUpdated(counters, kSecondSsrc);
1191 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
1192 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
1193 1167
1194 // Changing content type causes histograms to be reported. 1168 // Changing content type causes histograms to be reported.
1195 VideoEncoderConfig config; 1169 VideoEncoderConfig config;
1196 config.content_type = VideoEncoderConfig::ContentType::kScreen; 1170 config.content_type = VideoEncoderConfig::ContentType::kScreen;
1197 statistics_proxy_->OnEncoderReconfigured(config, 50); 1171 statistics_proxy_->OnEncoderReconfigured(config, 50000);
1198 1172
1173 // Interval: 3500 bytes * 4 / 2 sec = 7000 bytes / sec = 56 kbps
1199 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); 1174 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps"));
1200 EXPECT_EQ(1, 1175 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.BitrateSentInKbps", 56));
1201 metrics::NumEvents( 1176 // Interval: 3500 bytes * 2 / 2 sec = 3500 bytes / sec = 28 kbps
1202 "WebRTC.Video.BitrateSentInKbps", 1177 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RtxBitrateSentInKbps"));
1203 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / 1178 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.RtxBitrateSentInKbps", 28));
1204 metrics::kMinRunTimeInSeconds / 1000))); 1179 // Interval: (2000 - 2 * 250) bytes / 2 sec = 1500 bytes / sec = 12 kbps
1205
1206 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps")); 1180 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps"));
1207 EXPECT_EQ(1, metrics::NumEvents( 1181 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.MediaBitrateSentInKbps", 12));
1208 "WebRTC.Video.MediaBitrateSentInKbps", 1182 // Interval: 1000 bytes * 4 / 2 sec = 2000 bytes / sec = 16 kbps
1209 static_cast<int>((counters.MediaPayloadBytes() * 2 * 8) /
1210 metrics::kMinRunTimeInSeconds / 1000)));
1211
1212 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PaddingBitrateSentInKbps")); 1183 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PaddingBitrateSentInKbps"));
1213 EXPECT_EQ(1, 1184 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.PaddingBitrateSentInKbps", 16));
1214 metrics::NumEvents( 1185 // Interval: 375 bytes * 2 / 2 sec = 375 bytes / sec = 3 kbps
1215 "WebRTC.Video.PaddingBitrateSentInKbps", 1186 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps"));
1216 static_cast<int>((counters.transmitted.padding_bytes * 4 * 8) / 1187 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.FecBitrateSentInKbps", 3));
1217 metrics::kMinRunTimeInSeconds / 1000))); 1188 // Interval: 375 bytes * 2 / 2 sec = 375 bytes / sec = 3 kbps
1218
1219 EXPECT_EQ(1, 1189 EXPECT_EQ(1,
1220 metrics::NumSamples("WebRTC.Video.RetransmittedBitrateSentInKbps")); 1190 metrics::NumSamples("WebRTC.Video.RetransmittedBitrateSentInKbps"));
1221 EXPECT_EQ(1, 1191 EXPECT_EQ(
1222 metrics::NumEvents( 1192 1, metrics::NumEvents("WebRTC.Video.RetransmittedBitrateSentInKbps", 3));
1223 "WebRTC.Video.RetransmittedBitrateSentInKbps", 1193
1224 static_cast<int>((counters.retransmitted.TotalBytes() * 2 * 8) / 1194 // New metric counters but same data counters.
1225 metrics::kMinRunTimeInSeconds / 1000)));
1226
1227 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RtxBitrateSentInKbps"));
1228 EXPECT_EQ(
1229 1, metrics::NumEvents(
1230 "WebRTC.Video.RtxBitrateSentInKbps",
1231 static_cast<int>((rtx_counters.transmitted.TotalBytes() * 2 * 8) /
1232 metrics::kMinRunTimeInSeconds / 1000)));
1233
1234 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps"));
1235 EXPECT_EQ(1, metrics::NumEvents(
1236 "WebRTC.Video.FecBitrateSentInKbps",
1237 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) /
1238 metrics::kMinRunTimeInSeconds / 1000)));
1239
1240 // New start time but same counter values.
1241 proxy->DataCountersUpdated(counters, kFirstSsrc);
1242 proxy->DataCountersUpdated(counters, kSecondSsrc);
1243 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
1244 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
1245
1246 // Double counter values, this should result in the same counts as before but 1195 // Double counter values, this should result in the same counts as before but
1247 // with new histogram names. 1196 // with new histogram names.
1248 StreamDataCounters new_counters = counters; 1197 for (int i = 0; i < kMinRequiredPeriodSamples; ++i) {
1249 new_counters.Add(counters); 1198 counters.transmitted.packets += 20;
1250 StreamDataCounters new_rtx_counters = rtx_counters; 1199 counters.transmitted.header_bytes += 500;
1251 new_rtx_counters.Add(rtx_counters); 1200 counters.transmitted.padding_bytes += 1000;
1252 1201 counters.transmitted.payload_bytes += 2000;
1253 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); 1202 counters.retransmitted.packets += 2;
1254 proxy->DataCountersUpdated(new_counters, kFirstSsrc); 1203 counters.retransmitted.header_bytes += 25;
1255 proxy->DataCountersUpdated(new_counters, kSecondSsrc); 1204 counters.retransmitted.padding_bytes += 100;
1256 proxy->DataCountersUpdated(new_rtx_counters, kFirstRtxSsrc); 1205 counters.retransmitted.payload_bytes += 250;
1257 proxy->DataCountersUpdated(new_rtx_counters, kSecondRtxSsrc); 1206 counters.fec = counters.retransmitted;
1258 1207 rtx_counters.transmitted = counters.transmitted;
1259 SetUp(); // Reset stats proxy also causes histograms to be reported. 1208 // Advance one interval and update counters.
1260 1209 fake_clock_.AdvanceTimeMilliseconds(kPeriodIntervalMs);
1210 proxy->DataCountersUpdated(counters, kFirstSsrc);
1211 proxy->DataCountersUpdated(counters, kSecondSsrc);
1212 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
1213 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
1214 }
1215
1216 // Reset stats proxy also causes histograms to be reported.
1217 statistics_proxy_.reset();
1218
1219 // Interval: 3500 bytes * 4 / 2 sec = 7000 bytes / sec = 56 kbps
1261 EXPECT_EQ(1, 1220 EXPECT_EQ(1,
1262 metrics::NumSamples("WebRTC.Video.Screenshare.BitrateSentInKbps")); 1221 metrics::NumSamples("WebRTC.Video.Screenshare.BitrateSentInKbps"));
1263 EXPECT_EQ(1, 1222 EXPECT_EQ(
1264 metrics::NumEvents( 1223 1, metrics::NumEvents("WebRTC.Video.Screenshare.BitrateSentInKbps", 56));
1265 "WebRTC.Video.Screenshare.BitrateSentInKbps", 1224 // Interval: 3500 bytes * 2 / 2 sec = 3500 bytes / sec = 28 kbps
1266 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / 1225 EXPECT_EQ(
1267 metrics::kMinRunTimeInSeconds / 1000))); 1226 1, metrics::NumSamples("WebRTC.Video.Screenshare.RtxBitrateSentInKbps"));
1268 1227 EXPECT_EQ(1, metrics::NumEvents(
1228 "WebRTC.Video.Screenshare.RtxBitrateSentInKbps", 28));
1229 // Interval: (2000 - 2 * 250) bytes / 2 sec = 1500 bytes / sec = 12 kbps
1269 EXPECT_EQ(1, metrics::NumSamples( 1230 EXPECT_EQ(1, metrics::NumSamples(
1270 "WebRTC.Video.Screenshare.MediaBitrateSentInKbps")); 1231 "WebRTC.Video.Screenshare.MediaBitrateSentInKbps"));
1271 EXPECT_EQ(1, metrics::NumEvents( 1232 EXPECT_EQ(1, metrics::NumEvents(
1272 "WebRTC.Video.Screenshare.MediaBitrateSentInKbps", 1233 "WebRTC.Video.Screenshare.MediaBitrateSentInKbps", 12));
1273 static_cast<int>((counters.MediaPayloadBytes() * 2 * 8) / 1234 // Interval: 1000 bytes * 4 / 2 sec = 2000 bytes / sec = 16 kbps
1274 metrics::kMinRunTimeInSeconds / 1000)));
1275
1276 EXPECT_EQ(1, metrics::NumSamples( 1235 EXPECT_EQ(1, metrics::NumSamples(
1277 "WebRTC.Video.Screenshare.PaddingBitrateSentInKbps")); 1236 "WebRTC.Video.Screenshare.PaddingBitrateSentInKbps"));
1278 EXPECT_EQ(1, 1237 EXPECT_EQ(1, metrics::NumEvents(
1279 metrics::NumEvents( 1238 "WebRTC.Video.Screenshare.PaddingBitrateSentInKbps", 16));
1280 "WebRTC.Video.Screenshare.PaddingBitrateSentInKbps", 1239 // Interval: 375 bytes * 2 / 2 sec = 375 bytes / sec = 3 kbps
1281 static_cast<int>((counters.transmitted.padding_bytes * 4 * 8) / 1240 EXPECT_EQ(
1282 metrics::kMinRunTimeInSeconds / 1000))); 1241 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps"));
1283 1242 EXPECT_EQ(1, metrics::NumEvents(
1243 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", 3));
1244 // Interval: 375 bytes * 2 / 2 sec = 375 bytes / sec = 3 kbps
1284 EXPECT_EQ(1, metrics::NumSamples( 1245 EXPECT_EQ(1, metrics::NumSamples(
1285 "WebRTC.Video.Screenshare.RetransmittedBitrateSentInKbps")); 1246 "WebRTC.Video.Screenshare.RetransmittedBitrateSentInKbps"));
1286 EXPECT_EQ(1, 1247 EXPECT_EQ(1,
1287 metrics::NumEvents( 1248 metrics::NumEvents(
1288 "WebRTC.Video.Screenshare.RetransmittedBitrateSentInKbps", 1249 "WebRTC.Video.Screenshare.RetransmittedBitrateSentInKbps", 3));
1289 static_cast<int>((counters.retransmitted.TotalBytes() * 2 * 8) / 1250 }
1290 metrics::kMinRunTimeInSeconds / 1000))); 1251
1291 1252 TEST_F(SendStatisticsProxyTest, RtxBitrateIsZeroWhenEnabledAndNoRtxDataIsSent) {
1292 EXPECT_EQ( 1253 StreamDataCountersCallback* proxy =
1293 1, metrics::NumSamples("WebRTC.Video.Screenshare.RtxBitrateSentInKbps")); 1254 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get());
1294 EXPECT_EQ( 1255 StreamDataCounters counters;
1295 1, metrics::NumEvents( 1256 StreamDataCounters rtx_counters;
1296 "WebRTC.Video.Screenshare.RtxBitrateSentInKbps", 1257
1297 static_cast<int>((rtx_counters.transmitted.TotalBytes() * 2 * 8) / 1258 const int kMinRequiredPeriodSamples = 8;
1298 metrics::kMinRunTimeInSeconds / 1000))); 1259 const int kPeriodIntervalMs = 2000;
1299 1260 for (int i = 0; i < kMinRequiredPeriodSamples; ++i) {
1300 EXPECT_EQ( 1261 counters.transmitted.packets += 20;
1301 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); 1262 counters.transmitted.header_bytes += 500;
1302 EXPECT_EQ(1, metrics::NumEvents( 1263 counters.transmitted.payload_bytes += 2000;
1303 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", 1264 counters.fec = counters.retransmitted;
1304 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / 1265 // Advance one interval and update counters.
1305 metrics::kMinRunTimeInSeconds / 1000))); 1266 fake_clock_.AdvanceTimeMilliseconds(kPeriodIntervalMs);
1267 proxy->DataCountersUpdated(counters, kFirstSsrc);
1268 }
1269
1270 // RTX enabled. No data sent over RTX.
1271 statistics_proxy_.reset();
1272 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RtxBitrateSentInKbps"));
1273 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.RtxBitrateSentInKbps", 0));
1274 }
1275
1276 TEST_F(SendStatisticsProxyTest, RtxBitrateNotReportedWhenNotEnabled) {
1277 VideoSendStream::Config config(nullptr);
1278 config.rtp.ssrcs.push_back(kFirstSsrc); // RTX not configured.
1279 statistics_proxy_.reset(new SendStatisticsProxy(
1280 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo));
1281
1282 StreamDataCountersCallback* proxy =
1283 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get());
1284 StreamDataCounters counters;
1285
1286 const int kMinRequiredPeriodSamples = 8;
1287 const int kPeriodIntervalMs = 2000;
1288 for (int i = 0; i < kMinRequiredPeriodSamples; ++i) {
1289 counters.transmitted.packets += 20;
1290 counters.transmitted.header_bytes += 500;
1291 counters.transmitted.payload_bytes += 2000;
1292 counters.fec = counters.retransmitted;
1293 // Advance one interval and update counters.
1294 fake_clock_.AdvanceTimeMilliseconds(kPeriodIntervalMs);
1295 proxy->DataCountersUpdated(counters, kFirstSsrc);
1296 }
1297
1298 // RTX not enabled.
1299 statistics_proxy_.reset();
1300 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.RtxBitrateSentInKbps"));
1301 }
1302
1303 TEST_F(SendStatisticsProxyTest, FecBitrateIsZeroWhenEnabledAndNoFecDataIsSent) {
1304 StreamDataCountersCallback* proxy =
1305 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get());
1306 StreamDataCounters counters;
1307 StreamDataCounters rtx_counters;
1308
1309 const int kMinRequiredPeriodSamples = 8;
1310 const int kPeriodIntervalMs = 2000;
1311 for (int i = 0; i < kMinRequiredPeriodSamples; ++i) {
1312 counters.transmitted.packets += 20;
1313 counters.transmitted.header_bytes += 500;
1314 counters.transmitted.payload_bytes += 2000;
1315 // Advance one interval and update counters.
1316 fake_clock_.AdvanceTimeMilliseconds(kPeriodIntervalMs);
1317 proxy->DataCountersUpdated(counters, kFirstSsrc);
1318 }
1319
1320 // FEC enabled. No FEC data sent.
1321 statistics_proxy_.reset();
1322 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps"));
1323 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.FecBitrateSentInKbps", 0));
1324 }
1325
1326 TEST_F(SendStatisticsProxyTest, FecBitrateNotReportedWhenNotEnabled) {
1327 VideoSendStream::Config config(nullptr);
1328 config.rtp.ssrcs.push_back(kFirstSsrc); // FEC not configured.
1329 statistics_proxy_.reset(new SendStatisticsProxy(
1330 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo));
1331
1332 StreamDataCountersCallback* proxy =
1333 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get());
1334 StreamDataCounters counters;
1335
1336 const int kMinRequiredPeriodSamples = 8;
1337 const int kPeriodIntervalMs = 2000;
1338 for (int i = 0; i < kMinRequiredPeriodSamples; ++i) {
1339 counters.transmitted.packets += 20;
1340 counters.transmitted.header_bytes += 500;
1341 counters.transmitted.payload_bytes += 2000;
1342 counters.fec = counters.retransmitted;
1343 // Advance one interval and update counters.
1344 fake_clock_.AdvanceTimeMilliseconds(kPeriodIntervalMs);
1345 proxy->DataCountersUpdated(counters, kFirstSsrc);
1346 }
1347
1348 // FEC not enabled.
1349 statistics_proxy_.reset();
1350 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps"));
1306 } 1351 }
1307 1352
1308 } // namespace webrtc 1353 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | webrtc/video/stats_counter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698