OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 void SetUp() override { | 87 void SetUp() override { |
88 metrics::Reset(); | 88 metrics::Reset(); |
89 video_send_config_ = VideoSendStream::Config(nullptr); | 89 video_send_config_ = VideoSendStream::Config(nullptr); |
90 video_send_config_.encoder_settings.encoder = &fake_encoder_; | 90 video_send_config_.encoder_settings.encoder = &fake_encoder_; |
91 video_send_config_.encoder_settings.payload_name = "FAKE"; | 91 video_send_config_.encoder_settings.payload_name = "FAKE"; |
92 video_send_config_.encoder_settings.payload_type = 125; | 92 video_send_config_.encoder_settings.payload_type = 125; |
93 | 93 |
94 VideoEncoderConfig video_encoder_config; | 94 VideoEncoderConfig video_encoder_config; |
95 test::FillEncoderConfiguration(1, &video_encoder_config); | 95 test::FillEncoderConfiguration(1, &video_encoder_config); |
| 96 video_encoder_config_ = video_encoder_config.Copy(); |
96 vie_encoder_.reset(new ViEEncoderUnderTest( | 97 vie_encoder_.reset(new ViEEncoderUnderTest( |
97 stats_proxy_.get(), video_send_config_.encoder_settings)); | 98 stats_proxy_.get(), video_send_config_.encoder_settings)); |
98 vie_encoder_->SetSink(&sink_, false /* rotation_applied */); | 99 vie_encoder_->SetSink(&sink_, false /* rotation_applied */); |
99 vie_encoder_->SetSource(&video_source_, | 100 vie_encoder_->SetSource(&video_source_, |
100 VideoSendStream::DegradationPreference::kBalanced); | 101 VideoSendStream::DegradationPreference::kBalanced); |
101 vie_encoder_->SetStartBitrate(10000); | 102 vie_encoder_->SetStartBitrate(10000); |
102 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), 1440); | 103 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), 1440); |
103 } | 104 } |
104 | 105 |
105 VideoFrame CreateFrame(int64_t ntp_ts, rtc::Event* destruction_event) const { | 106 VideoFrame CreateFrame(int64_t ntp_ts, rtc::Event* destruction_event) const { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 rtc::CriticalSection crit_; | 230 rtc::CriticalSection crit_; |
230 TestEncoder* test_encoder_; | 231 TestEncoder* test_encoder_; |
231 rtc::Event encoded_frame_event_; | 232 rtc::Event encoded_frame_event_; |
232 uint32_t timestamp_ = 0; | 233 uint32_t timestamp_ = 0; |
233 bool expect_frames_ = true; | 234 bool expect_frames_ = true; |
234 int number_of_reconfigurations_ = 0; | 235 int number_of_reconfigurations_ = 0; |
235 int min_transmit_bitrate_bps_ = 0; | 236 int min_transmit_bitrate_bps_ = 0; |
236 }; | 237 }; |
237 | 238 |
238 VideoSendStream::Config video_send_config_; | 239 VideoSendStream::Config video_send_config_; |
| 240 VideoEncoderConfig video_encoder_config_; |
239 int codec_width_; | 241 int codec_width_; |
240 int codec_height_; | 242 int codec_height_; |
241 TestEncoder fake_encoder_; | 243 TestEncoder fake_encoder_; |
242 std::unique_ptr<SendStatisticsProxy> stats_proxy_; | 244 std::unique_ptr<SendStatisticsProxy> stats_proxy_; |
243 TestSink sink_; | 245 TestSink sink_; |
244 test::FrameForwarder video_source_; | 246 test::FrameForwarder video_source_; |
245 std::unique_ptr<ViEEncoderUnderTest> vie_encoder_; | 247 std::unique_ptr<ViEEncoderUnderTest> vie_encoder_; |
246 }; | 248 }; |
247 | 249 |
248 TEST_F(ViEEncoderTest, EncodeOneFrame) { | 250 TEST_F(ViEEncoderTest, EncodeOneFrame) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 video_source_.IncomingCapturedFrame( | 590 video_source_.IncomingCapturedFrame( |
589 CreateFrame(5, frame_width, frame_height)); | 591 CreateFrame(5, frame_width, frame_height)); |
590 sink_.WaitForEncodedFrame(5); | 592 sink_.WaitForEncodedFrame(5); |
591 stats = stats_proxy_->GetStats(); | 593 stats = stats_proxy_->GetStats(); |
592 EXPECT_FALSE(stats.cpu_limited_resolution); | 594 EXPECT_FALSE(stats.cpu_limited_resolution); |
593 EXPECT_EQ(2, stats.number_of_cpu_adapt_changes); | 595 EXPECT_EQ(2, stats.number_of_cpu_adapt_changes); |
594 | 596 |
595 vie_encoder_->Stop(); | 597 vie_encoder_->Stop(); |
596 } | 598 } |
597 | 599 |
| 600 TEST_F(ViEEncoderTest, StatsTracksPreferredBitrate) { |
| 601 const int kTargetBitrateBps = 100000; |
| 602 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| 603 |
| 604 video_source_.IncomingCapturedFrame(CreateFrame(1, 1280, 720)); |
| 605 sink_.WaitForEncodedFrame(1); |
| 606 |
| 607 VideoSendStream::Stats stats = stats_proxy_->GetStats(); |
| 608 EXPECT_EQ(video_encoder_config_.max_bitrate_bps, |
| 609 stats.preferred_media_bitrate_bps); |
| 610 |
| 611 vie_encoder_->Stop(); |
| 612 } |
| 613 |
598 TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { | 614 TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { |
599 const int kTargetBitrateBps = 100000; | 615 const int kTargetBitrateBps = 100000; |
600 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 616 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
601 | 617 |
602 int frame_width = 640; | 618 int frame_width = 640; |
603 int frame_height = 360; | 619 int frame_height = 360; |
604 | 620 |
605 for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { | 621 for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { |
606 video_source_.IncomingCapturedFrame( | 622 video_source_.IncomingCapturedFrame( |
607 CreateFrame(i, frame_width, frame_height)); | 623 CreateFrame(i, frame_width, frame_height)); |
(...skipping 12 matching lines...) Expand all Loading... |
620 vie_encoder_->Stop(); | 636 vie_encoder_->Stop(); |
621 | 637 |
622 stats_proxy_.reset(); | 638 stats_proxy_.reset(); |
623 EXPECT_EQ(1, | 639 EXPECT_EQ(1, |
624 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); | 640 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); |
625 EXPECT_EQ( | 641 EXPECT_EQ( |
626 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); | 642 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); |
627 } | 643 } |
628 | 644 |
629 } // namespace webrtc | 645 } // namespace webrtc |
OLD | NEW |