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

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

Issue 2061423003: Refactor NACK bitrate allocation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed nit Created 4 years, 5 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/video_send_stream.cc » ('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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 callback->DataCountersUpdated(counters, ssrc); 219 callback->DataCountersUpdated(counters, ssrc);
220 } 220 }
221 221
222 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 222 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
223 ExpectEqual(expected_, stats); 223 ExpectEqual(expected_, stats);
224 } 224 }
225 225
226 TEST_F(SendStatisticsProxyTest, Bitrate) { 226 TEST_F(SendStatisticsProxyTest, Bitrate) {
227 BitrateStatisticsObserver* observer = statistics_proxy_.get(); 227 BitrateStatisticsObserver* observer = statistics_proxy_.get();
228 for (const auto& ssrc : config_.rtp.ssrcs) { 228 for (const auto& ssrc : config_.rtp.ssrcs) {
229 BitrateStatistics total; 229 uint32_t total;
230 BitrateStatistics retransmit; 230 uint32_t retransmit;
231 // Use ssrc as bitrate_bps to get a unique value for each stream. 231 // Use ssrc as bitrate_bps to get a unique value for each stream.
232 total.bitrate_bps = ssrc; 232 total = ssrc;
233 retransmit.bitrate_bps = ssrc + 1; 233 retransmit = ssrc + 1;
234 observer->Notify(total, retransmit, ssrc); 234 observer->Notify(total, retransmit, ssrc);
235 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; 235 expected_.substreams[ssrc].total_bitrate_bps = total;
236 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; 236 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit;
237 } 237 }
238 for (const auto& ssrc : config_.rtp.rtx.ssrcs) { 238 for (const auto& ssrc : config_.rtp.rtx.ssrcs) {
239 BitrateStatistics total; 239 uint32_t total;
240 BitrateStatistics retransmit; 240 uint32_t retransmit;
241 // Use ssrc as bitrate_bps to get a unique value for each stream. 241 // Use ssrc as bitrate_bps to get a unique value for each stream.
242 total.bitrate_bps = ssrc; 242 total = ssrc;
243 retransmit.bitrate_bps = ssrc + 1; 243 retransmit = ssrc + 1;
244 observer->Notify(total, retransmit, ssrc); 244 observer->Notify(total, retransmit, ssrc);
245 expected_.substreams[ssrc].total_bitrate_bps = total.bitrate_bps; 245 expected_.substreams[ssrc].total_bitrate_bps = total;
246 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit.bitrate_bps; 246 expected_.substreams[ssrc].retransmit_bitrate_bps = retransmit;
247 } 247 }
248 248
249 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 249 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
250 ExpectEqual(expected_, stats); 250 ExpectEqual(expected_, stats);
251 } 251 }
252 252
253 TEST_F(SendStatisticsProxyTest, SendSideDelay) { 253 TEST_F(SendStatisticsProxyTest, SendSideDelay) {
254 SendSideDelayObserver* observer = statistics_proxy_.get(); 254 SendSideDelayObserver* observer = statistics_proxy_.get();
255 for (const auto& ssrc : config_.rtp.ssrcs) { 255 for (const auto& ssrc : config_.rtp.ssrcs) {
256 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each 256 // Use ssrc as avg_delay_ms and max_delay_ms to get a unique value for each
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), 390 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()),
391 *std::max_element(config_.rtp.rtx.ssrcs.begin(), 391 *std::max_element(config_.rtp.rtx.ssrcs.begin(),
392 config_.rtp.rtx.ssrcs.end())) + 392 config_.rtp.rtx.ssrcs.end())) +
393 1; 393 1;
394 // From RtcpStatisticsCallback. 394 // From RtcpStatisticsCallback.
395 RtcpStatistics rtcp_stats; 395 RtcpStatistics rtcp_stats;
396 RtcpStatisticsCallback* rtcp_callback = statistics_proxy_.get(); 396 RtcpStatisticsCallback* rtcp_callback = statistics_proxy_.get();
397 rtcp_callback->StatisticsUpdated(rtcp_stats, excluded_ssrc); 397 rtcp_callback->StatisticsUpdated(rtcp_stats, excluded_ssrc);
398 398
399 // From BitrateStatisticsObserver. 399 // From BitrateStatisticsObserver.
400 BitrateStatistics total; 400 uint32_t total = 0;
401 BitrateStatistics retransmit; 401 uint32_t retransmit = 0;
402 BitrateStatisticsObserver* bitrate_observer = statistics_proxy_.get(); 402 BitrateStatisticsObserver* bitrate_observer = statistics_proxy_.get();
403 bitrate_observer->Notify(total, retransmit, excluded_ssrc); 403 bitrate_observer->Notify(total, retransmit, excluded_ssrc);
404 404
405 // From FrameCountObserver. 405 // From FrameCountObserver.
406 FrameCountObserver* fps_observer = statistics_proxy_.get(); 406 FrameCountObserver* fps_observer = statistics_proxy_.get();
407 FrameCounts frame_counts; 407 FrameCounts frame_counts;
408 frame_counts.key_frames = 1; 408 frame_counts.key_frames = 1;
409 fps_observer->FrameCountUpdated(frame_counts, excluded_ssrc); 409 fps_observer->FrameCountUpdated(frame_counts, excluded_ssrc);
410 410
411 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 411 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 statistics_proxy_->OnInactiveSsrc(config_.rtp.ssrcs[1]); 478 statistics_proxy_->OnInactiveSsrc(config_.rtp.ssrcs[1]);
479 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 479 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
480 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width); 480 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width);
481 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height); 481 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height);
482 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].width); 482 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].width);
483 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].height); 483 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].height);
484 } 484 }
485 485
486 TEST_F(SendStatisticsProxyTest, ClearsBitratesFromInactiveSsrcs) { 486 TEST_F(SendStatisticsProxyTest, ClearsBitratesFromInactiveSsrcs) {
487 BitrateStatistics bitrate; 487 uint32_t bitrate = 42;
488 bitrate.bitrate_bps = 42;
489 BitrateStatisticsObserver* observer = statistics_proxy_.get(); 488 BitrateStatisticsObserver* observer = statistics_proxy_.get();
490 observer->Notify(bitrate, bitrate, config_.rtp.ssrcs[0]); 489 observer->Notify(bitrate, bitrate, config_.rtp.ssrcs[0]);
491 observer->Notify(bitrate, bitrate, config_.rtp.ssrcs[1]); 490 observer->Notify(bitrate, bitrate, config_.rtp.ssrcs[1]);
492 491
493 statistics_proxy_->OnInactiveSsrc(config_.rtp.ssrcs[1]); 492 statistics_proxy_->OnInactiveSsrc(config_.rtp.ssrcs[1]);
494 493
495 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 494 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
496 EXPECT_EQ(static_cast<int>(bitrate.bitrate_bps), 495 EXPECT_EQ(static_cast<int>(bitrate),
497 stats.substreams[config_.rtp.ssrcs[0]].total_bitrate_bps); 496 stats.substreams[config_.rtp.ssrcs[0]].total_bitrate_bps);
498 EXPECT_EQ(static_cast<int>(bitrate.bitrate_bps), 497 EXPECT_EQ(static_cast<int>(bitrate),
499 stats.substreams[config_.rtp.ssrcs[0]].retransmit_bitrate_bps); 498 stats.substreams[config_.rtp.ssrcs[0]].retransmit_bitrate_bps);
500 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].total_bitrate_bps); 499 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].total_bitrate_bps);
501 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].retransmit_bitrate_bps); 500 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].retransmit_bitrate_bps);
502 } 501 }
503 502
504 TEST_F(SendStatisticsProxyTest, ResetsRtcpCountersOnContentChange) { 503 TEST_F(SendStatisticsProxyTest, ResetsRtcpCountersOnContentChange) {
505 RtcpPacketTypeCounterObserver* proxy = 504 RtcpPacketTypeCounterObserver* proxy =
506 static_cast<RtcpPacketTypeCounterObserver*>(statistics_proxy_.get()); 505 static_cast<RtcpPacketTypeCounterObserver*>(statistics_proxy_.get());
507 RtcpPacketTypeCounter counters; 506 RtcpPacketTypeCounter counters;
508 counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds(); 507 counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 720
722 EXPECT_EQ( 721 EXPECT_EQ(
723 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); 722 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps"));
724 EXPECT_EQ(1, metrics::NumEvents( 723 EXPECT_EQ(1, metrics::NumEvents(
725 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", 724 "WebRTC.Video.Screenshare.FecBitrateSentInKbps",
726 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / 725 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) /
727 metrics::kMinRunTimeInSeconds / 1000))); 726 metrics::kMinRunTimeInSeconds / 1000)));
728 } 727 }
729 728
730 } // namespace webrtc 729 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | webrtc/video/video_send_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698