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 #include <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "vpx/vpx_encoder.h" | 15 #include "vpx/vpx_encoder.h" |
16 #include "vpx/vp8cx.h" | 16 #include "vpx/vp8cx.h" |
17 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 17 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
18 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" | 18 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" |
19 #include "webrtc/modules/video_coding/utility/mock/mock_frame_dropper.h" | 19 #include "webrtc/modules/video_coding/utility/mock/mock_frame_dropper.h" |
20 #include "webrtc/system_wrappers/include/clock.h" | 20 #include "webrtc/system_wrappers/include/clock.h" |
21 #include "webrtc/system_wrappers/include/metrics.h" | 21 #include "webrtc/system_wrappers/include/metrics.h" |
22 #include "webrtc/test/histogram.h" | 22 #include "webrtc/system_wrappers/include/metrics_default.h" |
23 | 23 |
24 using ::testing::_; | 24 using ::testing::_; |
25 using ::testing::NiceMock; | 25 using ::testing::NiceMock; |
26 using ::testing::Return; | 26 using ::testing::Return; |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
29 | 29 |
30 // 5 frames per second at 90 kHz. | 30 // 5 frames per second at 90 kHz. |
31 const uint32_t kTimestampDelta5Fps = 90000 / 5; | 31 const uint32_t kTimestampDelta5Fps = 90000 / 5; |
32 const int kDefaultQp = 54; | 32 const int kDefaultQp = 54; |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 kStartTimestamp + (ScreenshareLayers::kMaxFrameIntervalMs * 90)); | 467 kStartTimestamp + (ScreenshareLayers::kMaxFrameIntervalMs * 90)); |
468 | 468 |
469 EXPECT_EQ(-1, layers_->EncodeFlags(kTwoSecondsLater)); | 469 EXPECT_EQ(-1, layers_->EncodeFlags(kTwoSecondsLater)); |
470 // More than two seconds has passed since last frame, one should be emitted | 470 // More than two seconds has passed since last frame, one should be emitted |
471 // even if bitrate target is then exceeded. | 471 // even if bitrate target is then exceeded. |
472 EXPECT_EQ(ScreenshareLayers::kTl0Flags, | 472 EXPECT_EQ(ScreenshareLayers::kTl0Flags, |
473 layers_->EncodeFlags(kTwoSecondsLater + 90)); | 473 layers_->EncodeFlags(kTwoSecondsLater + 90)); |
474 } | 474 } |
475 | 475 |
476 TEST_F(ScreenshareLayerTest, UpdatesHistograms) { | 476 TEST_F(ScreenshareLayerTest, UpdatesHistograms) { |
| 477 metrics::Reset(); |
477 ConfigureBitrates(); | 478 ConfigureBitrates(); |
478 vpx_codec_enc_cfg_t cfg = GetConfig(); | 479 vpx_codec_enc_cfg_t cfg = GetConfig(); |
479 bool trigger_drop = false; | 480 bool trigger_drop = false; |
480 bool dropped_frame = false; | 481 bool dropped_frame = false; |
481 bool overshoot = false; | 482 bool overshoot = false; |
482 const int kTl0Qp = 35; | 483 const int kTl0Qp = 35; |
483 const int kTl1Qp = 30; | 484 const int kTl1Qp = 30; |
484 for (int64_t timestamp = 0; | 485 for (int64_t timestamp = 0; |
485 timestamp < kTimestampDelta5Fps * 5 * metrics::kMinRunTimeInSeconds; | 486 timestamp < kTimestampDelta5Fps * 5 * metrics::kMinRunTimeInSeconds; |
486 timestamp += kTimestampDelta5Fps) { | 487 timestamp += kTimestampDelta5Fps) { |
(...skipping 25 matching lines...) Expand all Loading... |
512 RTC_NOTREACHED() << "Unexpected flags"; | 513 RTC_NOTREACHED() << "Unexpected flags"; |
513 } | 514 } |
514 clock_.AdvanceTimeMilliseconds(1000 / 5); | 515 clock_.AdvanceTimeMilliseconds(1000 / 5); |
515 } | 516 } |
516 | 517 |
517 EXPECT_TRUE(overshoot); | 518 EXPECT_TRUE(overshoot); |
518 EXPECT_TRUE(dropped_frame); | 519 EXPECT_TRUE(dropped_frame); |
519 | 520 |
520 layers_.reset(); // Histograms are reported on destruction. | 521 layers_.reset(); // Histograms are reported on destruction. |
521 | 522 |
522 EXPECT_EQ(1, test::NumHistogramSamples( | 523 EXPECT_EQ(1, |
523 "WebRTC.Video.Screenshare.Layer0.FrameRate")); | 524 metrics::NumSamples("WebRTC.Video.Screenshare.Layer0.FrameRate")); |
524 EXPECT_EQ(1, test::NumHistogramSamples( | 525 EXPECT_EQ(1, |
525 "WebRTC.Video.Screenshare.Layer1.FrameRate")); | 526 metrics::NumSamples("WebRTC.Video.Screenshare.Layer1.FrameRate")); |
| 527 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Screenshare.FramesPerDrop")); |
| 528 EXPECT_EQ(1, |
| 529 metrics::NumSamples("WebRTC.Video.Screenshare.FramesPerOvershoot")); |
| 530 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Screenshare.Layer0.Qp")); |
| 531 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Screenshare.Layer1.Qp")); |
526 EXPECT_EQ( | 532 EXPECT_EQ( |
527 1, test::NumHistogramSamples("WebRTC.Video.Screenshare.FramesPerDrop")); | 533 1, metrics::NumSamples("WebRTC.Video.Screenshare.Layer0.TargetBitrate")); |
528 EXPECT_EQ(1, test::NumHistogramSamples( | 534 EXPECT_EQ( |
529 "WebRTC.Video.Screenshare.FramesPerOvershoot")); | 535 1, metrics::NumSamples("WebRTC.Video.Screenshare.Layer1.TargetBitrate")); |
530 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Screenshare.Layer0.Qp")); | |
531 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Screenshare.Layer1.Qp")); | |
532 EXPECT_EQ(1, test::NumHistogramSamples( | |
533 "WebRTC.Video.Screenshare.Layer0.TargetBitrate")); | |
534 EXPECT_EQ(1, test::NumHistogramSamples( | |
535 "WebRTC.Video.Screenshare.Layer1.TargetBitrate")); | |
536 | 536 |
537 EXPECT_GT( | 537 EXPECT_GT(metrics::MinSample("WebRTC.Video.Screenshare.Layer0.FrameRate"), 1); |
538 test::LastHistogramSample("WebRTC.Video.Screenshare.Layer0.FrameRate"), | 538 EXPECT_GT(metrics::MinSample("WebRTC.Video.Screenshare.Layer1.FrameRate"), 1); |
539 1); | 539 EXPECT_GT(metrics::MinSample("WebRTC.Video.Screenshare.FramesPerDrop"), 1); |
540 EXPECT_GT( | 540 EXPECT_GT(metrics::MinSample("WebRTC.Video.Screenshare.FramesPerOvershoot"), |
541 test::LastHistogramSample("WebRTC.Video.Screenshare.Layer1.FrameRate"), | |
542 1); | |
543 EXPECT_GT(test::LastHistogramSample("WebRTC.Video.Screenshare.FramesPerDrop"), | |
544 1); | 541 1); |
545 EXPECT_GT( | 542 EXPECT_EQ(1, |
546 test::LastHistogramSample("WebRTC.Video.Screenshare.FramesPerOvershoot"), | 543 metrics::NumEvents("WebRTC.Video.Screenshare.Layer0.Qp", kTl0Qp)); |
547 1); | 544 EXPECT_EQ(1, |
548 EXPECT_EQ(kTl0Qp, | 545 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.Qp", kTl1Qp)); |
549 test::LastHistogramSample("WebRTC.Video.Screenshare.Layer0.Qp")); | 546 EXPECT_EQ(1, |
550 EXPECT_EQ(kTl1Qp, | 547 metrics::NumEvents("WebRTC.Video.Screenshare.Layer0.TargetBitrate", |
551 test::LastHistogramSample("WebRTC.Video.Screenshare.Layer1.Qp")); | 548 kDefaultTl0BitrateKbps)); |
552 EXPECT_EQ(kDefaultTl0BitrateKbps, | 549 EXPECT_EQ(1, |
553 test::LastHistogramSample( | 550 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.TargetBitrate", |
554 "WebRTC.Video.Screenshare.Layer0.TargetBitrate")); | 551 kDefaultTl1BitrateKbps)); |
555 EXPECT_EQ(kDefaultTl1BitrateKbps, | |
556 test::LastHistogramSample( | |
557 "WebRTC.Video.Screenshare.Layer1.TargetBitrate")); | |
558 } | 552 } |
559 | 553 |
560 } // namespace webrtc | 554 } // namespace webrtc |
OLD | NEW |