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