OLD | NEW |
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 |
11 // This file includes unit tests for SendStatisticsProxy. | 11 // This file includes unit tests for SendStatisticsProxy. |
12 #include "webrtc/video/send_statistics_proxy.h" | 12 #include "webrtc/video/send_statistics_proxy.h" |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "webrtc/system_wrappers/include/metrics.h" | 20 #include "webrtc/system_wrappers/include/metrics.h" |
21 #include "webrtc/test/histogram.h" | 21 #include "webrtc/test/histogram.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 namespace { | 24 namespace { |
25 const uint32_t kFirstSsrc = 17; | 25 const uint32_t kFirstSsrc = 17; |
26 const uint32_t kSecondSsrc = 42; | 26 const uint32_t kSecondSsrc = 42; |
27 const uint32_t kFirstRtxSsrc = 18; | 27 const uint32_t kFirstRtxSsrc = 18; |
28 const uint32_t kSecondRtxSsrc = 43; | 28 const uint32_t kSecondRtxSsrc = 43; |
29 | 29 |
| 30 const int64_t kMaxPacketDelayMs = 11000; |
30 const int kMinRequiredSamples = 200; | 31 const int kMinRequiredSamples = 200; |
31 const int kQpIdx0 = 21; | 32 const int kQpIdx0 = 21; |
32 const int kQpIdx1 = 39; | 33 const int kQpIdx1 = 39; |
33 } // namespace | 34 } // namespace |
34 | 35 |
35 class SendStatisticsProxyTest : public ::testing::Test { | 36 class SendStatisticsProxyTest : public ::testing::Test { |
36 public: | 37 public: |
37 SendStatisticsProxyTest() | 38 SendStatisticsProxyTest() |
38 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0), | 39 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0), |
39 max_delay_ms_(0) {} | 40 max_delay_ms_(0) {} |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 VideoSendStream::Config config_; | 105 VideoSendStream::Config config_; |
105 int avg_delay_ms_; | 106 int avg_delay_ms_; |
106 int max_delay_ms_; | 107 int max_delay_ms_; |
107 VideoSendStream::Stats expected_; | 108 VideoSendStream::Stats expected_; |
108 typedef std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator | 109 typedef std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator |
109 StreamIterator; | 110 StreamIterator; |
110 }; | 111 }; |
111 | 112 |
112 TEST_F(SendStatisticsProxyTest, RtcpStatistics) { | 113 TEST_F(SendStatisticsProxyTest, RtcpStatistics) { |
113 RtcpStatisticsCallback* callback = statistics_proxy_.get(); | 114 RtcpStatisticsCallback* callback = statistics_proxy_.get(); |
114 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 115 for (const auto& ssrc : config_.rtp.ssrcs) { |
115 it != config_.rtp.ssrcs.end(); | |
116 ++it) { | |
117 const uint32_t ssrc = *it; | |
118 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; | 116 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; |
119 | 117 |
120 // Add statistics with some arbitrary, but unique, numbers. | 118 // Add statistics with some arbitrary, but unique, numbers. |
121 uint32_t offset = ssrc * sizeof(RtcpStatistics); | 119 uint32_t offset = ssrc * sizeof(RtcpStatistics); |
122 ssrc_stats.rtcp_stats.cumulative_lost = offset; | 120 ssrc_stats.rtcp_stats.cumulative_lost = offset; |
123 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; | 121 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; |
124 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; | 122 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; |
125 ssrc_stats.rtcp_stats.jitter = offset + 3; | 123 ssrc_stats.rtcp_stats.jitter = offset + 3; |
126 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); | 124 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); |
127 } | 125 } |
128 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 126 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
129 it != config_.rtp.rtx.ssrcs.end(); | |
130 ++it) { | |
131 const uint32_t ssrc = *it; | |
132 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; | 127 VideoSendStream::StreamStats& ssrc_stats = expected_.substreams[ssrc]; |
133 | 128 |
134 // Add statistics with some arbitrary, but unique, numbers. | 129 // Add statistics with some arbitrary, but unique, numbers. |
135 uint32_t offset = ssrc * sizeof(RtcpStatistics); | 130 uint32_t offset = ssrc * sizeof(RtcpStatistics); |
136 ssrc_stats.rtcp_stats.cumulative_lost = offset; | 131 ssrc_stats.rtcp_stats.cumulative_lost = offset; |
137 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; | 132 ssrc_stats.rtcp_stats.extended_max_sequence_number = offset + 1; |
138 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; | 133 ssrc_stats.rtcp_stats.fraction_lost = offset + 2; |
139 ssrc_stats.rtcp_stats.jitter = offset + 3; | 134 ssrc_stats.rtcp_stats.jitter = offset + 3; |
140 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); | 135 callback->StatisticsUpdated(ssrc_stats.rtcp_stats, ssrc); |
141 } | 136 } |
(...skipping 20 matching lines...) Expand all Loading... |
162 statistics_proxy_->OnSuspendChange(true); | 157 statistics_proxy_->OnSuspendChange(true); |
163 EXPECT_TRUE(statistics_proxy_->GetStats().suspended); | 158 EXPECT_TRUE(statistics_proxy_->GetStats().suspended); |
164 | 159 |
165 // Verify that we can set it back to false again. | 160 // Verify that we can set it back to false again. |
166 statistics_proxy_->OnSuspendChange(false); | 161 statistics_proxy_->OnSuspendChange(false); |
167 EXPECT_FALSE(statistics_proxy_->GetStats().suspended); | 162 EXPECT_FALSE(statistics_proxy_->GetStats().suspended); |
168 } | 163 } |
169 | 164 |
170 TEST_F(SendStatisticsProxyTest, FrameCounts) { | 165 TEST_F(SendStatisticsProxyTest, FrameCounts) { |
171 FrameCountObserver* observer = statistics_proxy_.get(); | 166 FrameCountObserver* observer = statistics_proxy_.get(); |
172 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 167 for (const auto& ssrc : config_.rtp.ssrcs) { |
173 it != config_.rtp.ssrcs.end(); | |
174 ++it) { | |
175 const uint32_t ssrc = *it; | |
176 // Add statistics with some arbitrary, but unique, numbers. | 168 // Add statistics with some arbitrary, but unique, numbers. |
177 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; | 169 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; |
178 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); | 170 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); |
179 FrameCounts frame_counts; | 171 FrameCounts frame_counts; |
180 frame_counts.key_frames = offset; | 172 frame_counts.key_frames = offset; |
181 frame_counts.delta_frames = offset + 1; | 173 frame_counts.delta_frames = offset + 1; |
182 stats.frame_counts = frame_counts; | 174 stats.frame_counts = frame_counts; |
183 observer->FrameCountUpdated(frame_counts, ssrc); | 175 observer->FrameCountUpdated(frame_counts, ssrc); |
184 } | 176 } |
185 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 177 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
186 it != config_.rtp.rtx.ssrcs.end(); | |
187 ++it) { | |
188 const uint32_t ssrc = *it; | |
189 // Add statistics with some arbitrary, but unique, numbers. | 178 // Add statistics with some arbitrary, but unique, numbers. |
190 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; | 179 VideoSendStream::StreamStats& stats = expected_.substreams[ssrc]; |
191 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); | 180 uint32_t offset = ssrc * sizeof(VideoSendStream::StreamStats); |
192 FrameCounts frame_counts; | 181 FrameCounts frame_counts; |
193 frame_counts.key_frames = offset; | 182 frame_counts.key_frames = offset; |
194 frame_counts.delta_frames = offset + 1; | 183 frame_counts.delta_frames = offset + 1; |
195 stats.frame_counts = frame_counts; | 184 stats.frame_counts = frame_counts; |
196 observer->FrameCountUpdated(frame_counts, ssrc); | 185 observer->FrameCountUpdated(frame_counts, ssrc); |
197 } | 186 } |
198 | 187 |
199 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 188 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
200 ExpectEqual(expected_, stats); | 189 ExpectEqual(expected_, stats); |
201 } | 190 } |
202 | 191 |
203 TEST_F(SendStatisticsProxyTest, DataCounters) { | 192 TEST_F(SendStatisticsProxyTest, DataCounters) { |
204 StreamDataCountersCallback* callback = statistics_proxy_.get(); | 193 StreamDataCountersCallback* callback = statistics_proxy_.get(); |
205 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 194 for (const auto& ssrc : config_.rtp.ssrcs) { |
206 it != config_.rtp.ssrcs.end(); | |
207 ++it) { | |
208 const uint32_t ssrc = *it; | |
209 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; | 195 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; |
210 // Add statistics with some arbitrary, but unique, numbers. | 196 // Add statistics with some arbitrary, but unique, numbers. |
211 size_t offset = ssrc * sizeof(StreamDataCounters); | 197 size_t offset = ssrc * sizeof(StreamDataCounters); |
212 uint32_t offset_uint32 = static_cast<uint32_t>(offset); | 198 uint32_t offset_uint32 = static_cast<uint32_t>(offset); |
213 counters.transmitted.payload_bytes = offset; | 199 counters.transmitted.payload_bytes = offset; |
214 counters.transmitted.header_bytes = offset + 1; | 200 counters.transmitted.header_bytes = offset + 1; |
215 counters.fec.packets = offset_uint32 + 2; | 201 counters.fec.packets = offset_uint32 + 2; |
216 counters.transmitted.padding_bytes = offset + 3; | 202 counters.transmitted.padding_bytes = offset + 3; |
217 counters.retransmitted.packets = offset_uint32 + 4; | 203 counters.retransmitted.packets = offset_uint32 + 4; |
218 counters.transmitted.packets = offset_uint32 + 5; | 204 counters.transmitted.packets = offset_uint32 + 5; |
219 callback->DataCountersUpdated(counters, ssrc); | 205 callback->DataCountersUpdated(counters, ssrc); |
220 } | 206 } |
221 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 207 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
222 it != config_.rtp.rtx.ssrcs.end(); | |
223 ++it) { | |
224 const uint32_t ssrc = *it; | |
225 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; | 208 StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; |
226 // Add statistics with some arbitrary, but unique, numbers. | 209 // Add statistics with some arbitrary, but unique, numbers. |
227 size_t offset = ssrc * sizeof(StreamDataCounters); | 210 size_t offset = ssrc * sizeof(StreamDataCounters); |
228 uint32_t offset_uint32 = static_cast<uint32_t>(offset); | 211 uint32_t offset_uint32 = static_cast<uint32_t>(offset); |
229 counters.transmitted.payload_bytes = offset; | 212 counters.transmitted.payload_bytes = offset; |
230 counters.transmitted.header_bytes = offset + 1; | 213 counters.transmitted.header_bytes = offset + 1; |
231 counters.fec.packets = offset_uint32 + 2; | 214 counters.fec.packets = offset_uint32 + 2; |
232 counters.transmitted.padding_bytes = offset + 3; | 215 counters.transmitted.padding_bytes = offset + 3; |
233 counters.retransmitted.packets = offset_uint32 + 4; | 216 counters.retransmitted.packets = offset_uint32 + 4; |
234 counters.transmitted.packets = offset_uint32 + 5; | 217 counters.transmitted.packets = offset_uint32 + 5; |
235 callback->DataCountersUpdated(counters, ssrc); | 218 callback->DataCountersUpdated(counters, ssrc); |
236 } | 219 } |
237 | 220 |
238 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 221 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
239 ExpectEqual(expected_, stats); | 222 ExpectEqual(expected_, stats); |
240 } | 223 } |
241 | 224 |
242 TEST_F(SendStatisticsProxyTest, Bitrate) { | 225 TEST_F(SendStatisticsProxyTest, Bitrate) { |
243 BitrateStatisticsObserver* observer = statistics_proxy_.get(); | 226 BitrateStatisticsObserver* observer = statistics_proxy_.get(); |
244 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 227 for (const auto& ssrc : config_.rtp.ssrcs) { |
245 it != config_.rtp.ssrcs.end(); | |
246 ++it) { | |
247 const uint32_t ssrc = *it; | |
248 BitrateStatistics total; | 228 BitrateStatistics total; |
249 BitrateStatistics retransmit; | 229 BitrateStatistics retransmit; |
250 // Use ssrc as bitrate_bps to get a unique value for each stream. | 230 // Use ssrc as bitrate_bps to get a unique value for each stream. |
251 total.bitrate_bps = ssrc; | 231 total.bitrate_bps = ssrc; |
252 retransmit.bitrate_bps = ssrc + 1; | 232 retransmit.bitrate_bps = ssrc + 1; |
253 observer->Notify(total, retransmit, ssrc); | 233 observer->Notify(total, retransmit, ssrc); |
254 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; | 234 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; |
255 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; | 235 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; |
256 } | 236 } |
257 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 237 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
258 it != config_.rtp.rtx.ssrcs.end(); | |
259 ++it) { | |
260 const uint32_t ssrc = *it; | |
261 BitrateStatistics total; | 238 BitrateStatistics total; |
262 BitrateStatistics retransmit; | 239 BitrateStatistics retransmit; |
263 // Use ssrc as bitrate_bps to get a unique value for each stream. | 240 // Use ssrc as bitrate_bps to get a unique value for each stream. |
264 total.bitrate_bps = ssrc; | 241 total.bitrate_bps = ssrc; |
265 retransmit.bitrate_bps = ssrc + 1; | 242 retransmit.bitrate_bps = ssrc + 1; |
266 observer->Notify(total, retransmit, ssrc); | 243 observer->Notify(total, retransmit, ssrc); |
267 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; | 244 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; |
268 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; | 245 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; |
269 } | 246 } |
270 | 247 |
271 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 248 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
272 ExpectEqual(expected_, stats); | 249 ExpectEqual(expected_, stats); |
273 } | 250 } |
274 | 251 |
275 TEST_F(SendStatisticsProxyTest, SendSideDelay) { | 252 TEST_F(SendStatisticsProxyTest, SendSideDelay) { |
276 SendSideDelayObserver* observer = statistics_proxy_.get(); | 253 SendSideDelayObserver* observer = statistics_proxy_.get(); |
277 for (std::vector<uint32_t>::const_iterator it = config_.rtp.ssrcs.begin(); | 254 for (const auto& ssrc : config_.rtp.ssrcs) { |
278 it != config_.rtp.ssrcs.end(); | |
279 ++it) { | |
280 const uint32_t ssrc = *it; | |
281 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each | 255 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each |
282 // stream. | 256 // stream. |
283 int avg_delay_ms = ssrc; | 257 int avg_delay_ms = ssrc; |
284 int max_delay_ms = ssrc + 1; | 258 int max_delay_ms = ssrc + 1; |
285 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); | 259 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); |
286 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; | 260 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; |
287 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; | 261 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; |
288 } | 262 } |
289 for (std::vector<uint32_t>::const_iterator it = config_.rtp.rtx.ssrcs.begin(); | 263 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { |
290 it != config_.rtp.rtx.ssrcs.end(); | |
291 ++it) { | |
292 const uint32_t ssrc = *it; | |
293 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each | 264 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each |
294 // stream. | 265 // stream. |
295 int avg_delay_ms = ssrc; | 266 int avg_delay_ms = ssrc; |
296 int max_delay_ms = ssrc + 1; | 267 int max_delay_ms = ssrc + 1; |
297 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); | 268 observer->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); |
298 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; | 269 expected_.substreams[ssrc].avg_delay_ms = avg_delay_ms; |
299 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; | 270 expected_.substreams[ssrc].max_delay_ms = max_delay_ms; |
300 } | 271 } |
301 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 272 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
302 ExpectEqual(expected_, stats); | 273 ExpectEqual(expected_, stats); |
303 } | 274 } |
304 | 275 |
| 276 TEST_F(SendStatisticsProxyTest, VerifySendDelayHistogramStats) { |
| 277 test::ClearHistograms(); |
| 278 const int64_t kSendDelayInMs = 5; |
| 279 SendPacketObserver* observer = statistics_proxy_.get(); |
| 280 const uint32_t ssrc = *config_.rtp.ssrcs.begin(); |
| 281 |
| 282 uint16_t packet_id = 0; |
| 283 for (int i = 0; i < kMinRequiredSamples; ++i) { |
| 284 observer->OnSendPacket(++packet_id, fake_clock_.TimeInMilliseconds(), ssrc); |
| 285 // Packet sent to transport. |
| 286 fake_clock_.AdvanceTimeMilliseconds(kSendDelayInMs); |
| 287 EXPECT_TRUE(statistics_proxy_->OnSentPacket(packet_id)); |
| 288 } |
| 289 statistics_proxy_.reset(); |
| 290 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.SendDelayInMs")); |
| 291 EXPECT_EQ(kSendDelayInMs, |
| 292 test::LastHistogramSample("WebRTC.Video.SendDelayInMs")); |
| 293 } |
| 294 |
| 295 TEST_F(SendStatisticsProxyTest, OnSentPacket) { |
| 296 const uint16_t kPacketId = 2345; |
| 297 SendPacketObserver* observer = statistics_proxy_.get(); |
| 298 const uint32_t ssrc = *config_.rtp.ssrcs.begin(); |
| 299 |
| 300 observer->OnSendPacket(kPacketId, fake_clock_.TimeInMilliseconds(), ssrc); |
| 301 fake_clock_.AdvanceTimeMilliseconds(kMaxPacketDelayMs - 1); |
| 302 observer->OnSendPacket(kPacketId + 1, fake_clock_.TimeInMilliseconds(), ssrc); |
| 303 |
| 304 // Verify that packets are found. |
| 305 EXPECT_TRUE(statistics_proxy_->OnSentPacket(kPacketId)); |
| 306 EXPECT_TRUE(statistics_proxy_->OnSentPacket(kPacketId + 1)); |
| 307 // Packets found, should have been removed. |
| 308 EXPECT_FALSE(statistics_proxy_->OnSentPacket(kPacketId)); |
| 309 EXPECT_FALSE(statistics_proxy_->OnSentPacket(kPacketId + 1)); |
| 310 } |
| 311 |
| 312 TEST_F(SendStatisticsProxyTest, OnSendPacketRemovesOldPackets) { |
| 313 SendPacketObserver* observer = statistics_proxy_.get(); |
| 314 const uint32_t ssrc = *config_.rtp.ssrcs.begin(); |
| 315 const int64_t kCaptureTimeMs = fake_clock_.TimeInMilliseconds(); |
| 316 |
| 317 observer->OnSendPacket(0xffffu, kCaptureTimeMs, ssrc); |
| 318 observer->OnSendPacket(0u, kCaptureTimeMs, ssrc); |
| 319 observer->OnSendPacket(1u, kCaptureTimeMs + 1, ssrc); |
| 320 fake_clock_.AdvanceTimeMilliseconds(kMaxPacketDelayMs); // 0xffff, 0 -> old. |
| 321 observer->OnSendPacket(2u, kCaptureTimeMs + 2, ssrc); |
| 322 |
| 323 EXPECT_FALSE(statistics_proxy_->OnSentPacket(0xffffu)); // Old removed. |
| 324 EXPECT_FALSE(statistics_proxy_->OnSentPacket(0u)); // Old removed. |
| 325 EXPECT_TRUE(statistics_proxy_->OnSentPacket(1u)); |
| 326 EXPECT_TRUE(statistics_proxy_->OnSentPacket(2u)); |
| 327 } |
| 328 |
305 TEST_F(SendStatisticsProxyTest, OnEncodedFrameTimeMeasured) { | 329 TEST_F(SendStatisticsProxyTest, OnEncodedFrameTimeMeasured) { |
306 const int kEncodeTimeMs = 11; | 330 const int kEncodeTimeMs = 11; |
307 CpuOveruseMetrics metrics; | 331 CpuOveruseMetrics metrics; |
308 metrics.encode_usage_percent = 80; | 332 metrics.encode_usage_percent = 80; |
309 statistics_proxy_->OnEncodedFrameTimeMeasured(kEncodeTimeMs, metrics); | 333 statistics_proxy_->OnEncodedFrameTimeMeasured(kEncodeTimeMs, metrics); |
310 | 334 |
311 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); | 335 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
312 EXPECT_EQ(kEncodeTimeMs, stats.avg_encode_time_ms); | 336 EXPECT_EQ(kEncodeTimeMs, stats.avg_encode_time_ms); |
313 EXPECT_EQ(metrics.encode_usage_percent, stats.encode_usage_percent); | 337 EXPECT_EQ(metrics.encode_usage_percent, stats.encode_usage_percent); |
314 } | 338 } |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 773 |
750 EXPECT_EQ(1, test::NumHistogramSamples( | 774 EXPECT_EQ(1, test::NumHistogramSamples( |
751 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 775 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
752 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / | 776 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / |
753 metrics::kMinRunTimeInSeconds / 1000), | 777 metrics::kMinRunTimeInSeconds / 1000), |
754 test::LastHistogramSample( | 778 test::LastHistogramSample( |
755 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 779 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
756 } | 780 } |
757 | 781 |
758 } // namespace webrtc | 782 } // namespace webrtc |
OLD | NEW |