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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 VideoEncoderConfig::ContentType::kRealtimeVideo)); | 40 VideoEncoderConfig::ContentType::kRealtimeVideo)); |
41 expected_ = VideoSendStream::Stats(); | 41 expected_ = VideoSendStream::Stats(); |
42 } | 42 } |
43 | 43 |
44 VideoSendStream::Config GetTestConfig() { | 44 VideoSendStream::Config GetTestConfig() { |
45 VideoSendStream::Config config(nullptr); | 45 VideoSendStream::Config config(nullptr); |
46 config.rtp.ssrcs.push_back(kFirstSsrc); | 46 config.rtp.ssrcs.push_back(kFirstSsrc); |
47 config.rtp.ssrcs.push_back(kSecondSsrc); | 47 config.rtp.ssrcs.push_back(kSecondSsrc); |
48 config.rtp.rtx.ssrcs.push_back(kFirstRtxSsrc); | 48 config.rtp.rtx.ssrcs.push_back(kFirstRtxSsrc); |
49 config.rtp.rtx.ssrcs.push_back(kSecondRtxSsrc); | 49 config.rtp.rtx.ssrcs.push_back(kSecondRtxSsrc); |
| 50 config.rtp.fec.red_payload_type = 17; |
50 return config; | 51 return config; |
51 } | 52 } |
52 | 53 |
53 void ExpectEqual(VideoSendStream::Stats one, VideoSendStream::Stats other) { | 54 void ExpectEqual(VideoSendStream::Stats one, VideoSendStream::Stats other) { |
54 EXPECT_EQ(one.input_frame_rate, other.input_frame_rate); | 55 EXPECT_EQ(one.input_frame_rate, other.input_frame_rate); |
55 EXPECT_EQ(one.encode_frame_rate, other.encode_frame_rate); | 56 EXPECT_EQ(one.encode_frame_rate, other.encode_frame_rate); |
56 EXPECT_EQ(one.media_bitrate_bps, other.media_bitrate_bps); | 57 EXPECT_EQ(one.media_bitrate_bps, other.media_bitrate_bps); |
57 EXPECT_EQ(one.suspended, other.suspended); | 58 EXPECT_EQ(one.suspended, other.suspended); |
58 | 59 |
59 EXPECT_EQ(one.substreams.size(), other.substreams.size()); | 60 EXPECT_EQ(one.substreams.size(), other.substreams.size()); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 "WebRTC.Video.Screenshare.FirPacketsReceivedPerMinute")); | 519 "WebRTC.Video.Screenshare.FirPacketsReceivedPerMinute")); |
519 EXPECT_EQ(3 * kRate, | 520 EXPECT_EQ(3 * kRate, |
520 test::LastHistogramSample( | 521 test::LastHistogramSample( |
521 "WebRTC.Video.Screenshare.PliPacketsReceivedPerMinute")); | 522 "WebRTC.Video.Screenshare.PliPacketsReceivedPerMinute")); |
522 EXPECT_EQ( | 523 EXPECT_EQ( |
523 4 * 100 / 5, | 524 4 * 100 / 5, |
524 test::LastHistogramSample( | 525 test::LastHistogramSample( |
525 "WebRTC.Video.Screenshare.UniqueNackRequestsReceivedInPercent")); | 526 "WebRTC.Video.Screenshare.UniqueNackRequestsReceivedInPercent")); |
526 } | 527 } |
527 | 528 |
| 529 TEST_F(SendStatisticsProxyTest, ResetsRtpCountersOnContentChange) { |
| 530 StreamDataCountersCallback* proxy = |
| 531 static_cast<StreamDataCountersCallback*>(statistics_proxy_.get()); |
| 532 StreamDataCounters counters; |
| 533 StreamDataCounters rtx_counters; |
| 534 counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds(); |
| 535 proxy->DataCountersUpdated(counters, kFirstSsrc); |
| 536 proxy->DataCountersUpdated(counters, kSecondSsrc); |
| 537 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); |
| 538 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); |
| 539 |
| 540 counters.transmitted.header_bytes = 400; |
| 541 counters.transmitted.packets = 20; |
| 542 counters.transmitted.padding_bytes = 1000; |
| 543 counters.transmitted.payload_bytes = 2000; |
| 544 |
| 545 counters.retransmitted.header_bytes = 40; |
| 546 counters.retransmitted.packets = 2; |
| 547 counters.retransmitted.padding_bytes = 100; |
| 548 counters.retransmitted.payload_bytes = 200; |
| 549 |
| 550 counters.fec = counters.retransmitted; |
| 551 |
| 552 rtx_counters.transmitted = counters.transmitted; |
| 553 |
| 554 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); |
| 555 proxy->DataCountersUpdated(counters, kFirstSsrc); |
| 556 proxy->DataCountersUpdated(counters, kSecondSsrc); |
| 557 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); |
| 558 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); |
| 559 |
| 560 // Changing content type causes histograms to be reported. |
| 561 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); |
| 562 |
| 563 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.BitrateSentInKbps")); |
| 564 EXPECT_EQ(static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / |
| 565 metrics::kMinRunTimeInSeconds / 1000), |
| 566 test::LastHistogramSample("WebRTC.Video.BitrateSentInKbps")); |
| 567 |
| 568 EXPECT_EQ(1, |
| 569 test::NumHistogramSamples("WebRTC.Video.MediaBitrateSentInKbps")); |
| 570 EXPECT_EQ(static_cast<int>((counters.MediaPayloadBytes() * 2 * 8) / |
| 571 metrics::kMinRunTimeInSeconds / 1000), |
| 572 test::LastHistogramSample("WebRTC.Video.MediaBitrateSentInKbps")); |
| 573 |
| 574 EXPECT_EQ(1, |
| 575 test::NumHistogramSamples("WebRTC.Video.PaddingBitrateSentInKbps")); |
| 576 EXPECT_EQ(static_cast<int>((counters.transmitted.padding_bytes * 4 * 8) / |
| 577 metrics::kMinRunTimeInSeconds / 1000), |
| 578 test::LastHistogramSample("WebRTC.Video.PaddingBitrateSentInKbps")); |
| 579 |
| 580 EXPECT_EQ(1, test::NumHistogramSamples( |
| 581 "WebRTC.Video.RetransmittedBitrateSentInKbps")); |
| 582 EXPECT_EQ( |
| 583 static_cast<int>((counters.retransmitted.TotalBytes() * 2 * 8) / |
| 584 metrics::kMinRunTimeInSeconds / 1000), |
| 585 test::LastHistogramSample("WebRTC.Video.RetransmittedBitrateSentInKbps")); |
| 586 |
| 587 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.RtxBitrateSentInKbps")); |
| 588 EXPECT_EQ(static_cast<int>((rtx_counters.transmitted.TotalBytes() * 2 * 8) / |
| 589 metrics::kMinRunTimeInSeconds / 1000), |
| 590 test::LastHistogramSample("WebRTC.Video.RtxBitrateSentInKbps")); |
| 591 |
| 592 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.FecBitrateSentInKbps")); |
| 593 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / |
| 594 metrics::kMinRunTimeInSeconds / 1000), |
| 595 test::LastHistogramSample("WebRTC.Video.FecBitrateSentInKbps")); |
| 596 |
| 597 // New start time but same counter values. |
| 598 proxy->DataCountersUpdated(counters, kFirstSsrc); |
| 599 proxy->DataCountersUpdated(counters, kSecondSsrc); |
| 600 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); |
| 601 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); |
| 602 |
| 603 // Double counter values, this should result in the same counts as before but |
| 604 // with new histogram names. |
| 605 StreamDataCounters new_counters = counters; |
| 606 new_counters.Add(counters); |
| 607 StreamDataCounters new_rtx_counters = rtx_counters; |
| 608 new_rtx_counters.Add(rtx_counters); |
| 609 |
| 610 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); |
| 611 proxy->DataCountersUpdated(new_counters, kFirstSsrc); |
| 612 proxy->DataCountersUpdated(new_counters, kSecondSsrc); |
| 613 proxy->DataCountersUpdated(new_rtx_counters, kFirstRtxSsrc); |
| 614 proxy->DataCountersUpdated(new_rtx_counters, kSecondRtxSsrc); |
| 615 |
| 616 SetUp(); // Reset stats proxy also causes histograms to be reported. |
| 617 |
| 618 EXPECT_EQ(1, test::NumHistogramSamples( |
| 619 "WebRTC.Video.Screenshare.BitrateSentInKbps")); |
| 620 EXPECT_EQ( |
| 621 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / |
| 622 metrics::kMinRunTimeInSeconds / 1000), |
| 623 test::LastHistogramSample("WebRTC.Video.Screenshare.BitrateSentInKbps")); |
| 624 |
| 625 EXPECT_EQ(1, test::NumHistogramSamples( |
| 626 "WebRTC.Video.Screenshare.MediaBitrateSentInKbps")); |
| 627 EXPECT_EQ(static_cast<int>((counters.MediaPayloadBytes() * 2 * 8) / |
| 628 metrics::kMinRunTimeInSeconds / 1000), |
| 629 test::LastHistogramSample( |
| 630 "WebRTC.Video.Screenshare.MediaBitrateSentInKbps")); |
| 631 |
| 632 EXPECT_EQ(1, test::NumHistogramSamples( |
| 633 "WebRTC.Video.Screenshare.PaddingBitrateSentInKbps")); |
| 634 EXPECT_EQ(static_cast<int>((counters.transmitted.padding_bytes * 4 * 8) / |
| 635 metrics::kMinRunTimeInSeconds / 1000), |
| 636 test::LastHistogramSample( |
| 637 "WebRTC.Video.Screenshare.PaddingBitrateSentInKbps")); |
| 638 |
| 639 EXPECT_EQ(1, test::NumHistogramSamples( |
| 640 "WebRTC.Video.Screenshare.RetransmittedBitrateSentInKbps")); |
| 641 EXPECT_EQ(static_cast<int>((counters.retransmitted.TotalBytes() * 2 * 8) / |
| 642 metrics::kMinRunTimeInSeconds / 1000), |
| 643 test::LastHistogramSample( |
| 644 "WebRTC.Video.Screenshare.RetransmittedBitrateSentInKbps")); |
| 645 |
| 646 EXPECT_EQ(1, test::NumHistogramSamples( |
| 647 "WebRTC.Video.Screenshare.RtxBitrateSentInKbps")); |
| 648 EXPECT_EQ(static_cast<int>((rtx_counters.transmitted.TotalBytes() * 2 * 8) / |
| 649 metrics::kMinRunTimeInSeconds / 1000), |
| 650 test::LastHistogramSample( |
| 651 "WebRTC.Video.Screenshare.RtxBitrateSentInKbps")); |
| 652 |
| 653 EXPECT_EQ(1, test::NumHistogramSamples( |
| 654 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 655 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / |
| 656 metrics::kMinRunTimeInSeconds / 1000), |
| 657 test::LastHistogramSample( |
| 658 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 659 } |
| 660 |
528 } // namespace webrtc | 661 } // namespace webrtc |
OLD | NEW |