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

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

Issue 2789823002: Reland of Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Rebase fix Created 3 years, 8 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/vie_encoder.cc ('k') | webrtc/video_send_stream.h » ('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) 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
11 #include <algorithm> 11 #include <algorithm>
12 #include <limits> 12 #include <limits>
13 #include <utility> 13 #include <utility>
14 14
15 #include "webrtc/api/video/i420_buffer.h" 15 #include "webrtc/api/video/i420_buffer.h"
16 #include "webrtc/base/fakeclock.h"
16 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
17 #include "webrtc/media/base/videoadapter.h" 18 #include "webrtc/media/base/videoadapter.h"
18 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 19 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
19 #include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h" 20 #include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h"
20 #include "webrtc/system_wrappers/include/metrics_default.h" 21 #include "webrtc/system_wrappers/include/metrics_default.h"
21 #include "webrtc/system_wrappers/include/sleep.h" 22 #include "webrtc/system_wrappers/include/sleep.h"
22 #include "webrtc/test/encoder_settings.h" 23 #include "webrtc/test/encoder_settings.h"
23 #include "webrtc/test/fake_encoder.h" 24 #include "webrtc/test/fake_encoder.h"
24 #include "webrtc/test/frame_generator.h" 25 #include "webrtc/test/frame_generator.h"
25 #include "webrtc/test/gmock.h" 26 #include "webrtc/test/gmock.h"
26 #include "webrtc/test/gtest.h" 27 #include "webrtc/test/gtest.h"
27 #include "webrtc/video/send_statistics_proxy.h" 28 #include "webrtc/video/send_statistics_proxy.h"
28 #include "webrtc/video/vie_encoder.h" 29 #include "webrtc/video/vie_encoder.h"
29 30
30 namespace { 31 namespace {
31 #if defined(WEBRTC_ANDROID) 32 #if defined(WEBRTC_ANDROID)
32 // TODO(kthelgason): Lower this limit when better testing 33 // TODO(kthelgason): Lower this limit when better testing
33 // on MediaCodec and fallback implementations are in place. 34 // on MediaCodec and fallback implementations are in place.
34 const int kMinPixelsPerFrame = 320 * 180; 35 const int kMinPixelsPerFrame = 320 * 180;
35 #else 36 #else
36 const int kMinPixelsPerFrame = 120 * 90; 37 const int kMinPixelsPerFrame = 120 * 90;
37 #endif 38 #endif
38 } 39 const int kMinFramerateFps = 2;
40 const int64_t kFrameTimeoutMs = 100;
41 } // namespace
39 42
40 namespace webrtc { 43 namespace webrtc {
41 44
42 using DegredationPreference = VideoSendStream::DegradationPreference; 45 using DegredationPreference = VideoSendStream::DegradationPreference;
43 using ScaleReason = AdaptationObserverInterface::AdaptReason; 46 using ScaleReason = AdaptationObserverInterface::AdaptReason;
44 using ::testing::_; 47 using ::testing::_;
45 using ::testing::Return; 48 using ::testing::Return;
46 49
47 namespace { 50 namespace {
48 const size_t kMaxPayloadLength = 1440; 51 const size_t kMaxPayloadLength = 1440;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool adaption_enabled() { 141 bool adaption_enabled() {
139 rtc::CritScope cs(&crit_); 142 rtc::CritScope cs(&crit_);
140 return adaptation_enabled_; 143 return adaptation_enabled_;
141 } 144 }
142 145
143 void IncomingCapturedFrame(const VideoFrame& video_frame) override { 146 void IncomingCapturedFrame(const VideoFrame& video_frame) override {
144 int cropped_width = 0; 147 int cropped_width = 0;
145 int cropped_height = 0; 148 int cropped_height = 0;
146 int out_width = 0; 149 int out_width = 0;
147 int out_height = 0; 150 int out_height = 0;
148 if (adaption_enabled() && 151 if (adaption_enabled()) {
149 adapter_.AdaptFrameResolution(video_frame.width(), video_frame.height(), 152 if (adapter_.AdaptFrameResolution(
150 video_frame.timestamp_us() * 1000, 153 video_frame.width(), video_frame.height(),
151 &cropped_width, &cropped_height, 154 video_frame.timestamp_us() * 1000, &cropped_width,
152 &out_width, &out_height)) { 155 &cropped_height, &out_width, &out_height)) {
153 VideoFrame adapted_frame( 156 VideoFrame adapted_frame(new rtc::RefCountedObject<TestBuffer>(
154 new rtc::RefCountedObject<TestBuffer>(nullptr, out_width, out_height), 157 nullptr, out_width, out_height),
155 99, 99, kVideoRotation_0); 158 99, 99, kVideoRotation_0);
156 adapted_frame.set_ntp_time_ms(video_frame.ntp_time_ms()); 159 adapted_frame.set_ntp_time_ms(video_frame.ntp_time_ms());
157 test::FrameForwarder::IncomingCapturedFrame(adapted_frame); 160 test::FrameForwarder::IncomingCapturedFrame(adapted_frame);
161 }
158 } else { 162 } else {
159 test::FrameForwarder::IncomingCapturedFrame(video_frame); 163 test::FrameForwarder::IncomingCapturedFrame(video_frame);
160 } 164 }
161 } 165 }
162 166
163 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, 167 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
164 const rtc::VideoSinkWants& wants) override { 168 const rtc::VideoSinkWants& wants) override {
165 rtc::CritScope cs(&crit_); 169 rtc::CritScope cs(&crit_);
166 adapter_.OnResolutionRequest(wants.target_pixel_count, 170 adapter_.OnResolutionFramerateRequest(wants.target_pixel_count,
167 wants.max_pixel_count); 171 wants.max_pixel_count,
172 wants.max_framerate_fps);
168 test::FrameForwarder::AddOrUpdateSink(sink, wants); 173 test::FrameForwarder::AddOrUpdateSink(sink, wants);
169 } 174 }
170 175
171 cricket::VideoAdapter adapter_; 176 cricket::VideoAdapter adapter_;
172 bool adaptation_enabled_ GUARDED_BY(crit_); 177 bool adaptation_enabled_ GUARDED_BY(crit_);
173 }; 178 };
179
180 class MockableSendStatisticsProxy : public SendStatisticsProxy {
181 public:
182 MockableSendStatisticsProxy(Clock* clock,
183 const VideoSendStream::Config& config,
184 VideoEncoderConfig::ContentType content_type)
185 : SendStatisticsProxy(clock, config, content_type) {}
186
187 VideoSendStream::Stats GetStats() override {
188 rtc::CritScope cs(&lock_);
189 if (mock_stats_)
190 return *mock_stats_;
191 return SendStatisticsProxy::GetStats();
192 }
193
194 void SetMockStats(const VideoSendStream::Stats& stats) {
195 rtc::CritScope cs(&lock_);
196 mock_stats_.emplace(stats);
197 }
198
199 void ResetMockStats() {
200 rtc::CritScope cs(&lock_);
201 mock_stats_.reset();
202 }
203
204 private:
205 rtc::CriticalSection lock_;
206 rtc::Optional<VideoSendStream::Stats> mock_stats_ GUARDED_BY(lock_);
207 };
208
174 } // namespace 209 } // namespace
175 210
176 class ViEEncoderTest : public ::testing::Test { 211 class ViEEncoderTest : public ::testing::Test {
177 public: 212 public:
178 static const int kDefaultTimeoutMs = 30 * 1000; 213 static const int kDefaultTimeoutMs = 30 * 1000;
179 214
180 ViEEncoderTest() 215 ViEEncoderTest()
181 : video_send_config_(VideoSendStream::Config(nullptr)), 216 : video_send_config_(VideoSendStream::Config(nullptr)),
182 codec_width_(320), 217 codec_width_(320),
183 codec_height_(240), 218 codec_height_(240),
184 fake_encoder_(), 219 fake_encoder_(),
185 stats_proxy_(new SendStatisticsProxy( 220 stats_proxy_(new MockableSendStatisticsProxy(
186 Clock::GetRealTimeClock(), 221 Clock::GetRealTimeClock(),
187 video_send_config_, 222 video_send_config_,
188 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo)), 223 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo)),
189 sink_(&fake_encoder_) {} 224 sink_(&fake_encoder_) {}
190 225
191 void SetUp() override { 226 void SetUp() override {
192 metrics::Reset(); 227 metrics::Reset();
193 video_send_config_ = VideoSendStream::Config(nullptr); 228 video_send_config_ = VideoSendStream::Config(nullptr);
194 video_send_config_.encoder_settings.encoder = &fake_encoder_; 229 video_send_config_.encoder_settings.encoder = &fake_encoder_;
195 video_send_config_.encoder_settings.payload_name = "FAKE"; 230 video_send_config_.encoder_settings.payload_name = "FAKE";
196 video_send_config_.encoder_settings.payload_type = 125; 231 video_send_config_.encoder_settings.payload_type = 125;
197 232
198 VideoEncoderConfig video_encoder_config; 233 VideoEncoderConfig video_encoder_config;
199 test::FillEncoderConfiguration(1, &video_encoder_config); 234 test::FillEncoderConfiguration(1, &video_encoder_config);
200 video_encoder_config_ = video_encoder_config.Copy(); 235 video_encoder_config_ = video_encoder_config.Copy();
201 ConfigureEncoder(std::move(video_encoder_config), true /* nack_enabled */); 236 ConfigureEncoder(std::move(video_encoder_config), true /* nack_enabled */);
202 } 237 }
203 238
204 void ConfigureEncoder(VideoEncoderConfig video_encoder_config, 239 void ConfigureEncoder(VideoEncoderConfig video_encoder_config,
205 bool nack_enabled) { 240 bool nack_enabled) {
206 if (vie_encoder_) 241 if (vie_encoder_)
207 vie_encoder_->Stop(); 242 vie_encoder_->Stop();
208 vie_encoder_.reset(new ViEEncoderUnderTest( 243 vie_encoder_.reset(new ViEEncoderUnderTest(
209 stats_proxy_.get(), video_send_config_.encoder_settings)); 244 stats_proxy_.get(), video_send_config_.encoder_settings));
210 vie_encoder_->SetSink(&sink_, false /* rotation_applied */); 245 vie_encoder_->SetSink(&sink_, false /* rotation_applied */);
211 vie_encoder_->SetSource(&video_source_, 246 vie_encoder_->SetSource(
212 VideoSendStream::DegradationPreference::kBalanced); 247 &video_source_,
248 VideoSendStream::DegradationPreference::kMaintainFramerate);
213 vie_encoder_->SetStartBitrate(kTargetBitrateBps); 249 vie_encoder_->SetStartBitrate(kTargetBitrateBps);
214 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), 250 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
215 kMaxPayloadLength, nack_enabled); 251 kMaxPayloadLength, nack_enabled);
216 vie_encoder_->WaitUntilTaskQueueIsIdle(); 252 vie_encoder_->WaitUntilTaskQueueIsIdle();
217 } 253 }
218 254
219 void ResetEncoder(const std::string& payload_name, 255 void ResetEncoder(const std::string& payload_name,
220 size_t num_streams, 256 size_t num_streams,
221 size_t num_temporal_layers, 257 size_t num_temporal_layers,
222 bool nack_enabled) { 258 bool nack_enabled) {
(...skipping 14 matching lines...) Expand all
237 99, 99, kVideoRotation_0); 273 99, 99, kVideoRotation_0);
238 frame.set_ntp_time_ms(ntp_time_ms); 274 frame.set_ntp_time_ms(ntp_time_ms);
239 return frame; 275 return frame;
240 } 276 }
241 277
242 VideoFrame CreateFrame(int64_t ntp_time_ms, int width, int height) const { 278 VideoFrame CreateFrame(int64_t ntp_time_ms, int width, int height) const {
243 VideoFrame frame( 279 VideoFrame frame(
244 new rtc::RefCountedObject<TestBuffer>(nullptr, width, height), 99, 99, 280 new rtc::RefCountedObject<TestBuffer>(nullptr, width, height), 99, 99,
245 kVideoRotation_0); 281 kVideoRotation_0);
246 frame.set_ntp_time_ms(ntp_time_ms); 282 frame.set_ntp_time_ms(ntp_time_ms);
283 frame.set_timestamp_us(ntp_time_ms * 1000);
247 return frame; 284 return frame;
248 } 285 }
249 286
250 class TestEncoder : public test::FakeEncoder { 287 class TestEncoder : public test::FakeEncoder {
251 public: 288 public:
252 TestEncoder() 289 TestEncoder()
253 : FakeEncoder(Clock::GetRealTimeClock()), 290 : FakeEncoder(Clock::GetRealTimeClock()),
254 continue_encode_event_(false, false) {} 291 continue_encode_event_(false, false) {}
255 292
256 VideoCodec codec_config() { 293 VideoCodec codec_config() {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 EXPECT_TRUE(encoded_frame_event_.Wait(kDefaultTimeoutMs)); 396 EXPECT_TRUE(encoded_frame_event_.Wait(kDefaultTimeoutMs));
360 { 397 {
361 rtc::CritScope lock(&crit_); 398 rtc::CritScope lock(&crit_);
362 timestamp = last_timestamp_; 399 timestamp = last_timestamp_;
363 } 400 }
364 test_encoder_->CheckLastTimeStampsMatch(expected_ntp_time, timestamp); 401 test_encoder_->CheckLastTimeStampsMatch(expected_ntp_time, timestamp);
365 } 402 }
366 403
367 void WaitForEncodedFrame(uint32_t expected_width, 404 void WaitForEncodedFrame(uint32_t expected_width,
368 uint32_t expected_height) { 405 uint32_t expected_height) {
406 EXPECT_TRUE(encoded_frame_event_.Wait(kDefaultTimeoutMs));
407 CheckLastFrameSizeMathces(expected_width, expected_height);
408 }
409
410 void CheckLastFrameSizeMathces(uint32_t expected_width,
411 uint32_t expected_height) {
369 uint32_t width = 0; 412 uint32_t width = 0;
370 uint32_t height = 0; 413 uint32_t height = 0;
371 EXPECT_TRUE(encoded_frame_event_.Wait(kDefaultTimeoutMs));
372 { 414 {
373 rtc::CritScope lock(&crit_); 415 rtc::CritScope lock(&crit_);
374 width = last_width_; 416 width = last_width_;
375 height = last_height_; 417 height = last_height_;
376 } 418 }
377 EXPECT_EQ(expected_height, height); 419 EXPECT_EQ(expected_height, height);
378 EXPECT_EQ(expected_width, width); 420 EXPECT_EQ(expected_width, width);
379 } 421 }
380 422
381 void ExpectDroppedFrame() { EXPECT_FALSE(encoded_frame_event_.Wait(100)); } 423 void ExpectDroppedFrame() { EXPECT_FALSE(encoded_frame_event_.Wait(100)); }
382 424
425 bool WaitForFrame(int64_t timeout_ms) {
426 return encoded_frame_event_.Wait(timeout_ms);
427 }
428
383 void SetExpectNoFrames() { 429 void SetExpectNoFrames() {
384 rtc::CritScope lock(&crit_); 430 rtc::CritScope lock(&crit_);
385 expect_frames_ = false; 431 expect_frames_ = false;
386 } 432 }
387 433
388 int number_of_reconfigurations() { 434 int number_of_reconfigurations() {
389 rtc::CritScope lock(&crit_); 435 rtc::CritScope lock(&crit_);
390 return number_of_reconfigurations_; 436 return number_of_reconfigurations_;
391 } 437 }
392 438
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 bool expect_frames_ = true; 471 bool expect_frames_ = true;
426 int number_of_reconfigurations_ = 0; 472 int number_of_reconfigurations_ = 0;
427 int min_transmit_bitrate_bps_ = 0; 473 int min_transmit_bitrate_bps_ = 0;
428 }; 474 };
429 475
430 VideoSendStream::Config video_send_config_; 476 VideoSendStream::Config video_send_config_;
431 VideoEncoderConfig video_encoder_config_; 477 VideoEncoderConfig video_encoder_config_;
432 int codec_width_; 478 int codec_width_;
433 int codec_height_; 479 int codec_height_;
434 TestEncoder fake_encoder_; 480 TestEncoder fake_encoder_;
435 std::unique_ptr<SendStatisticsProxy> stats_proxy_; 481 std::unique_ptr<MockableSendStatisticsProxy> stats_proxy_;
436 TestSink sink_; 482 TestSink sink_;
437 AdaptingFrameForwarder video_source_; 483 AdaptingFrameForwarder video_source_;
438 std::unique_ptr<ViEEncoderUnderTest> vie_encoder_; 484 std::unique_ptr<ViEEncoderUnderTest> vie_encoder_;
439 }; 485 };
440 486
441 TEST_F(ViEEncoderTest, EncodeOneFrame) { 487 TEST_F(ViEEncoderTest, EncodeOneFrame) {
442 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 488 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
443 rtc::Event frame_destroyed_event(false, false); 489 rtc::Event frame_destroyed_event(false, false);
444 video_source_.IncomingCapturedFrame(CreateFrame(1, &frame_destroyed_event)); 490 video_source_.IncomingCapturedFrame(CreateFrame(1, &frame_destroyed_event));
445 sink_.WaitForEncodedFrame(1); 491 sink_.WaitForEncodedFrame(1);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); 689 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams);
644 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); 690 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers);
645 // Resilience is on for temporal layers. 691 // Resilience is on for temporal layers.
646 EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience); 692 EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience);
647 vie_encoder_->Stop(); 693 vie_encoder_->Stop();
648 } 694 }
649 695
650 TEST_F(ViEEncoderTest, SwitchSourceDeregisterEncoderAsSink) { 696 TEST_F(ViEEncoderTest, SwitchSourceDeregisterEncoderAsSink) {
651 EXPECT_TRUE(video_source_.has_sinks()); 697 EXPECT_TRUE(video_source_.has_sinks());
652 test::FrameForwarder new_video_source; 698 test::FrameForwarder new_video_source;
653 vie_encoder_->SetSource(&new_video_source, 699 vie_encoder_->SetSource(
654 VideoSendStream::DegradationPreference::kBalanced); 700 &new_video_source,
701 VideoSendStream::DegradationPreference::kMaintainFramerate);
655 EXPECT_FALSE(video_source_.has_sinks()); 702 EXPECT_FALSE(video_source_.has_sinks());
656 EXPECT_TRUE(new_video_source.has_sinks()); 703 EXPECT_TRUE(new_video_source.has_sinks());
657 704
658 vie_encoder_->Stop(); 705 vie_encoder_->Stop();
659 } 706 }
660 707
661 TEST_F(ViEEncoderTest, SinkWantsRotationApplied) { 708 TEST_F(ViEEncoderTest, SinkWantsRotationApplied) {
662 EXPECT_FALSE(video_source_.sink_wants().rotation_applied); 709 EXPECT_FALSE(video_source_.sink_wants().rotation_applied);
663 vie_encoder_->SetSink(&sink_, true /*rotation_applied*/); 710 vie_encoder_->SetSink(&sink_, true /*rotation_applied*/);
664 EXPECT_TRUE(video_source_.sink_wants().rotation_applied); 711 EXPECT_TRUE(video_source_.sink_wants().rotation_applied);
665 vie_encoder_->Stop(); 712 vie_encoder_->Stop();
666 } 713 }
667 714
668 TEST_F(ViEEncoderTest, SinkWantsFromOveruseDetector) { 715 TEST_F(ViEEncoderTest, SinkWantsFromOveruseDetector) {
669 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 716 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
670 717
671 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); 718 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count);
672 EXPECT_FALSE(video_source_.sink_wants().max_pixel_count); 719 EXPECT_EQ(std::numeric_limits<int>::max(),
720 video_source_.sink_wants().max_pixel_count);
673 721
674 int frame_width = 1280; 722 int frame_width = 1280;
675 int frame_height = 720; 723 int frame_height = 720;
676 724
677 // Trigger CPU overuse kMaxCpuDowngrades times. Every time, ViEEncoder should 725 // Trigger CPU overuse kMaxCpuDowngrades times. Every time, ViEEncoder should
678 // request lower resolution. 726 // request lower resolution.
679 for (int i = 1; i <= ViEEncoder::kMaxCpuDowngrades; ++i) { 727 for (int i = 1; i <= ViEEncoder::kMaxCpuResolutionDowngrades; ++i) {
680 video_source_.IncomingCapturedFrame( 728 video_source_.IncomingCapturedFrame(
681 CreateFrame(i, frame_width, frame_height)); 729 CreateFrame(i, frame_width, frame_height));
682 sink_.WaitForEncodedFrame(i); 730 sink_.WaitForEncodedFrame(i);
683 731
684 vie_encoder_->TriggerCpuOveruse(); 732 vie_encoder_->TriggerCpuOveruse();
685 733
686 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); 734 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count);
687 EXPECT_LT(video_source_.sink_wants().max_pixel_count.value_or( 735 EXPECT_LT(video_source_.sink_wants().max_pixel_count,
688 std::numeric_limits<int>::max()),
689 frame_width * frame_height); 736 frame_width * frame_height);
690 737
691 frame_width /= 2; 738 frame_width /= 2;
692 frame_height /= 2; 739 frame_height /= 2;
693 } 740 }
694 741
695 // Trigger CPU overuse one more time. This should not trigger a request for 742 // Trigger CPU overuse one more time. This should not trigger a request for
696 // lower resolution. 743 // lower resolution.
697 rtc::VideoSinkWants current_wants = video_source_.sink_wants(); 744 rtc::VideoSinkWants current_wants = video_source_.sink_wants();
698 video_source_.IncomingCapturedFrame(CreateFrame( 745 video_source_.IncomingCapturedFrame(CreateFrame(
699 ViEEncoder::kMaxCpuDowngrades + 1, frame_width, frame_height)); 746 ViEEncoder::kMaxCpuResolutionDowngrades + 1, frame_width, frame_height));
700 sink_.WaitForEncodedFrame(ViEEncoder::kMaxCpuDowngrades + 1); 747 sink_.WaitForEncodedFrame(ViEEncoder::kMaxCpuResolutionDowngrades + 1);
701 vie_encoder_->TriggerCpuOveruse(); 748 vie_encoder_->TriggerCpuOveruse();
702 EXPECT_EQ(video_source_.sink_wants().target_pixel_count, 749 EXPECT_EQ(video_source_.sink_wants().target_pixel_count,
703 current_wants.target_pixel_count); 750 current_wants.target_pixel_count);
704 EXPECT_EQ(video_source_.sink_wants().max_pixel_count, 751 EXPECT_EQ(video_source_.sink_wants().max_pixel_count,
705 current_wants.max_pixel_count); 752 current_wants.max_pixel_count);
706 753
707 // Trigger CPU normal use. 754 // Trigger CPU normal use.
708 vie_encoder_->TriggerCpuNormalUsage(); 755 vie_encoder_->TriggerCpuNormalUsage();
709 EXPECT_EQ(frame_width * frame_height * 5 / 3, 756 EXPECT_EQ(frame_width * frame_height * 5 / 3,
710 video_source_.sink_wants().target_pixel_count.value_or(0)); 757 video_source_.sink_wants().target_pixel_count.value_or(0));
711 EXPECT_EQ(frame_width * frame_height * 4, 758 EXPECT_EQ(frame_width * frame_height * 4,
712 video_source_.sink_wants().max_pixel_count.value_or(0)); 759 video_source_.sink_wants().max_pixel_count);
713 760
714 vie_encoder_->Stop(); 761 vie_encoder_->Stop();
715 } 762 }
716 763
717 TEST_F(ViEEncoderTest, 764 TEST_F(ViEEncoderTest, SinkWantsStoredByDegradationPreference) {
718 ResolutionSinkWantsResetOnSetSourceWithDisabledResolutionScaling) {
719 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 765 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
720 766
721 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); 767 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count);
722 EXPECT_FALSE(video_source_.sink_wants().max_pixel_count); 768 EXPECT_EQ(std::numeric_limits<int>::max(),
769 video_source_.sink_wants().max_pixel_count);
770 EXPECT_EQ(std::numeric_limits<int>::max(),
771 video_source_.sink_wants().max_framerate_fps);
723 772
724 int frame_width = 1280; 773 const int kFrameWidth = 1280;
725 int frame_height = 720; 774 const int kFrameHeight = 720;
775 const int kFrameIntervalMs = 1000 / 30;
776
777 int frame_timestamp = 1;
726 778
727 video_source_.IncomingCapturedFrame( 779 video_source_.IncomingCapturedFrame(
728 CreateFrame(1, frame_width, frame_height)); 780 CreateFrame(frame_timestamp, kFrameWidth, kFrameHeight));
729 sink_.WaitForEncodedFrame(1); 781 sink_.WaitForEncodedFrame(frame_timestamp);
782 frame_timestamp += kFrameIntervalMs;
783
730 // Trigger CPU overuse. 784 // Trigger CPU overuse.
731 vie_encoder_->TriggerCpuOveruse(); 785 vie_encoder_->TriggerCpuOveruse();
786 video_source_.IncomingCapturedFrame(
787 CreateFrame(frame_timestamp, kFrameWidth, kFrameHeight));
788 sink_.WaitForEncodedFrame(frame_timestamp);
789 frame_timestamp += kFrameIntervalMs;
732 790
733 video_source_.IncomingCapturedFrame( 791 // Default degradation preference in maintain-framerate, so will lower max
734 CreateFrame(2, frame_width, frame_height)); 792 // wanted resolution.
735 sink_.WaitForEncodedFrame(2);
736 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); 793 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count);
737 EXPECT_LT(video_source_.sink_wants().max_pixel_count.value_or( 794 EXPECT_LT(video_source_.sink_wants().max_pixel_count,
738 std::numeric_limits<int>::max()), 795 kFrameWidth * kFrameHeight);
739 frame_width * frame_height); 796 EXPECT_EQ(std::numeric_limits<int>::max(),
797 video_source_.sink_wants().max_framerate_fps);
740 798
741 // Set new source. 799 // Set new source, switch to maintain-resolution.
742 test::FrameForwarder new_video_source; 800 test::FrameForwarder new_video_source;
743 vie_encoder_->SetSource( 801 vie_encoder_->SetSource(
744 &new_video_source, 802 &new_video_source,
745 VideoSendStream::DegradationPreference::kMaintainResolution); 803 VideoSendStream::DegradationPreference::kMaintainResolution);
746 804
805 // Initially no degradation registered.
747 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); 806 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
748 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); 807 EXPECT_EQ(std::numeric_limits<int>::max(),
808 new_video_source.sink_wants().max_pixel_count);
809 EXPECT_EQ(std::numeric_limits<int>::max(),
810 new_video_source.sink_wants().max_framerate_fps);
749 811
812 // Force an input frame rate to be available, or the adaptation call won't
813 // know what framerate to adapt form.
814 VideoSendStream::Stats stats = stats_proxy_->GetStats();
815 stats.input_frame_rate = 30;
816 stats_proxy_->SetMockStats(stats);
817
818 vie_encoder_->TriggerCpuOveruse();
750 new_video_source.IncomingCapturedFrame( 819 new_video_source.IncomingCapturedFrame(
751 CreateFrame(3, frame_width, frame_height)); 820 CreateFrame(frame_timestamp, kFrameWidth, kFrameHeight));
752 sink_.WaitForEncodedFrame(3); 821 sink_.WaitForEncodedFrame(frame_timestamp);
822 frame_timestamp += kFrameIntervalMs;
823
824 // Some framerate constraint should be set.
753 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); 825 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
754 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); 826 EXPECT_EQ(std::numeric_limits<int>::max(),
827 new_video_source.sink_wants().max_pixel_count);
828 EXPECT_TRUE(new_video_source.sink_wants().max_framerate_fps);
829
830 // Turn of degradation completely.
831 vie_encoder_->SetSource(
832 &new_video_source,
833 VideoSendStream::DegradationPreference::kDegradationDisabled);
834
835 // Initially no degradation registered.
836 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
837 EXPECT_EQ(std::numeric_limits<int>::max(),
838 new_video_source.sink_wants().max_pixel_count);
839 EXPECT_EQ(std::numeric_limits<int>::max(),
840 new_video_source.sink_wants().max_framerate_fps);
841
842 vie_encoder_->TriggerCpuOveruse();
843 new_video_source.IncomingCapturedFrame(
844 CreateFrame(frame_timestamp, kFrameWidth, kFrameHeight));
845 sink_.WaitForEncodedFrame(frame_timestamp);
846 frame_timestamp += kFrameIntervalMs;
847
848 // Still no degradation.
849 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
850 EXPECT_EQ(std::numeric_limits<int>::max(),
851 new_video_source.sink_wants().max_pixel_count);
852 EXPECT_EQ(std::numeric_limits<int>::max(),
853 new_video_source.sink_wants().max_framerate_fps);
755 854
756 // Calling SetSource with resolution scaling enabled apply the old SinkWants. 855 // Calling SetSource with resolution scaling enabled apply the old SinkWants.
757 vie_encoder_->SetSource(&new_video_source, 856 vie_encoder_->SetSource(
758 VideoSendStream::DegradationPreference::kBalanced); 857 &new_video_source,
759 EXPECT_LT(new_video_source.sink_wants().max_pixel_count.value_or( 858 VideoSendStream::DegradationPreference::kMaintainFramerate);
760 std::numeric_limits<int>::max()), 859 EXPECT_LT(new_video_source.sink_wants().max_pixel_count,
761 frame_width * frame_height); 860 kFrameWidth * kFrameHeight);
762 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); 861 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
862 EXPECT_EQ(std::numeric_limits<int>::max(),
863 new_video_source.sink_wants().max_framerate_fps);
864
865 // Calling SetSource with framerate scaling enabled apply the old SinkWants.
866 vie_encoder_->SetSource(
867 &new_video_source,
868 VideoSendStream::DegradationPreference::kMaintainResolution);
869 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
870 EXPECT_EQ(std::numeric_limits<int>::max(),
871 new_video_source.sink_wants().max_pixel_count);
872 EXPECT_TRUE(new_video_source.sink_wants().max_framerate_fps);
763 873
764 vie_encoder_->Stop(); 874 vie_encoder_->Stop();
765 } 875 }
766 876
767 TEST_F(ViEEncoderTest, StatsTracksAdaptationStats) { 877 TEST_F(ViEEncoderTest, StatsTracksAdaptationStats) {
768 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 878 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
769 879
770 int frame_width = 1280; 880 int frame_width = 1280;
771 int frame_height = 720; 881 int frame_height = 720;
772 882
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 927
818 video_source_.IncomingCapturedFrame( 928 video_source_.IncomingCapturedFrame(
819 CreateFrame(2, frame_width, frame_height)); 929 CreateFrame(2, frame_width, frame_height));
820 sink_.WaitForEncodedFrame(2); 930 sink_.WaitForEncodedFrame(2);
821 stats = stats_proxy_->GetStats(); 931 stats = stats_proxy_->GetStats();
822 EXPECT_TRUE(stats.cpu_limited_resolution); 932 EXPECT_TRUE(stats.cpu_limited_resolution);
823 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 933 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
824 934
825 // Set new source with adaptation still enabled. 935 // Set new source with adaptation still enabled.
826 test::FrameForwarder new_video_source; 936 test::FrameForwarder new_video_source;
827 vie_encoder_->SetSource(&new_video_source, 937 vie_encoder_->SetSource(
828 VideoSendStream::DegradationPreference::kBalanced); 938 &new_video_source,
939 VideoSendStream::DegradationPreference::kMaintainFramerate);
829 940
830 new_video_source.IncomingCapturedFrame( 941 new_video_source.IncomingCapturedFrame(
831 CreateFrame(3, frame_width, frame_height)); 942 CreateFrame(3, frame_width, frame_height));
832 sink_.WaitForEncodedFrame(3); 943 sink_.WaitForEncodedFrame(3);
833 stats = stats_proxy_->GetStats(); 944 stats = stats_proxy_->GetStats();
834 EXPECT_TRUE(stats.cpu_limited_resolution); 945 EXPECT_TRUE(stats.cpu_limited_resolution);
835 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 946 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
836 947
837 // Set adaptation disabled. 948 // Set adaptation disabled.
838 vie_encoder_->SetSource( 949 vie_encoder_->SetSource(
839 &new_video_source, 950 &new_video_source,
840 VideoSendStream::DegradationPreference::kMaintainResolution); 951 VideoSendStream::DegradationPreference::kDegradationDisabled);
841 952
842 new_video_source.IncomingCapturedFrame( 953 new_video_source.IncomingCapturedFrame(
843 CreateFrame(4, frame_width, frame_height)); 954 CreateFrame(4, frame_width, frame_height));
844 sink_.WaitForEncodedFrame(4); 955 sink_.WaitForEncodedFrame(4);
845 stats = stats_proxy_->GetStats(); 956 stats = stats_proxy_->GetStats();
846 EXPECT_FALSE(stats.cpu_limited_resolution); 957 EXPECT_FALSE(stats.cpu_limited_resolution);
847 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 958 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
848 959
849 // Set adaptation back to enabled. 960 // Set adaptation back to enabled.
850 vie_encoder_->SetSource(&new_video_source, 961 vie_encoder_->SetSource(
851 VideoSendStream::DegradationPreference::kBalanced); 962 &new_video_source,
963 VideoSendStream::DegradationPreference::kMaintainFramerate);
852 964
853 new_video_source.IncomingCapturedFrame( 965 new_video_source.IncomingCapturedFrame(
854 CreateFrame(5, frame_width, frame_height)); 966 CreateFrame(5, frame_width, frame_height));
855 sink_.WaitForEncodedFrame(5); 967 sink_.WaitForEncodedFrame(5);
856 stats = stats_proxy_->GetStats(); 968 stats = stats_proxy_->GetStats();
857 EXPECT_TRUE(stats.cpu_limited_resolution); 969 EXPECT_TRUE(stats.cpu_limited_resolution);
858 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 970 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
859 971
860 vie_encoder_->TriggerCpuNormalUsage(); 972 vie_encoder_->TriggerCpuNormalUsage();
861 973
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 // Trigger overuse. 1065 // Trigger overuse.
954 vie_encoder_->TriggerCpuOveruse(); 1066 vie_encoder_->TriggerCpuOveruse();
955 video_source_.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight)); 1067 video_source_.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
956 sink_.WaitForEncodedFrame(3); 1068 sink_.WaitForEncodedFrame(3);
957 EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution); 1069 EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
958 EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution); 1070 EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
959 EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes); 1071 EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
960 1072
961 // Set source with adaptation still enabled but quality scaler is off. 1073 // Set source with adaptation still enabled but quality scaler is off.
962 fake_encoder_.SetQualityScaling(false); 1074 fake_encoder_.SetQualityScaling(false);
963 vie_encoder_->SetSource(&video_source_, 1075 vie_encoder_->SetSource(
964 VideoSendStream::DegradationPreference::kBalanced); 1076 &video_source_,
1077 VideoSendStream::DegradationPreference::kMaintainFramerate);
965 1078
966 video_source_.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight)); 1079 video_source_.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
967 sink_.WaitForEncodedFrame(4); 1080 sink_.WaitForEncodedFrame(4);
968 EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution); 1081 EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
969 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); 1082 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
970 EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes); 1083 EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
971 1084
972 vie_encoder_->Stop(); 1085 vie_encoder_->Stop();
973 } 1086 }
974 1087
(...skipping 17 matching lines...) Expand all
992 video_source_.IncomingCapturedFrame( 1105 video_source_.IncomingCapturedFrame(
993 CreateFrame(sequence, frame_width, frame_height)); 1106 CreateFrame(sequence, frame_width, frame_height));
994 sink_.WaitForEncodedFrame(sequence++); 1107 sink_.WaitForEncodedFrame(sequence++);
995 1108
996 stats = stats_proxy_->GetStats(); 1109 stats = stats_proxy_->GetStats();
997 EXPECT_TRUE(stats.cpu_limited_resolution); 1110 EXPECT_TRUE(stats.cpu_limited_resolution);
998 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 1111 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
999 1112
1000 // Set new source with adaptation still enabled. 1113 // Set new source with adaptation still enabled.
1001 test::FrameForwarder new_video_source; 1114 test::FrameForwarder new_video_source;
1002 vie_encoder_->SetSource(&new_video_source, 1115 vie_encoder_->SetSource(
1003 VideoSendStream::DegradationPreference::kBalanced); 1116 &new_video_source,
1117 VideoSendStream::DegradationPreference::kMaintainFramerate);
1004 1118
1005 new_video_source.IncomingCapturedFrame( 1119 new_video_source.IncomingCapturedFrame(
1006 CreateFrame(sequence, frame_width, frame_height)); 1120 CreateFrame(sequence, frame_width, frame_height));
1007 sink_.WaitForEncodedFrame(sequence++); 1121 sink_.WaitForEncodedFrame(sequence++);
1008 stats = stats_proxy_->GetStats(); 1122 stats = stats_proxy_->GetStats();
1009 EXPECT_TRUE(stats.cpu_limited_resolution); 1123 EXPECT_TRUE(stats.cpu_limited_resolution);
1010 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 1124 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
1011 1125
1012 // Set adaptation disabled. 1126 // Set cpu adaptation by frame dropping.
1013 vie_encoder_->SetSource( 1127 vie_encoder_->SetSource(
1014 &new_video_source, 1128 &new_video_source,
1015 VideoSendStream::DegradationPreference::kMaintainResolution); 1129 VideoSendStream::DegradationPreference::kMaintainResolution);
1016 new_video_source.IncomingCapturedFrame( 1130 new_video_source.IncomingCapturedFrame(
1017 CreateFrame(sequence, frame_width, frame_height)); 1131 CreateFrame(sequence, frame_width, frame_height));
1018 sink_.WaitForEncodedFrame(sequence++); 1132 sink_.WaitForEncodedFrame(sequence++);
1019 stats = stats_proxy_->GetStats(); 1133 stats = stats_proxy_->GetStats();
1134 // Not adapted at first.
1020 EXPECT_FALSE(stats.cpu_limited_resolution); 1135 EXPECT_FALSE(stats.cpu_limited_resolution);
1021 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 1136 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
1022 1137
1023 // Switch back the source with adaptation enabled. 1138 // Force an input frame rate to be available, or the adaptation call won't
1024 vie_encoder_->SetSource(&video_source_, 1139 // know what framerate to adapt form.
1025 VideoSendStream::DegradationPreference::kBalanced); 1140 VideoSendStream::Stats mock_stats = stats_proxy_->GetStats();
1141 mock_stats.input_frame_rate = 30;
1142 stats_proxy_->SetMockStats(mock_stats);
1143 vie_encoder_->TriggerCpuOveruse();
1144 stats_proxy_->ResetMockStats();
1145
1146 new_video_source.IncomingCapturedFrame(
1147 CreateFrame(sequence, frame_width, frame_height));
1148 sink_.WaitForEncodedFrame(sequence++);
1149
1150 // Framerate now adapted.
1151 stats = stats_proxy_->GetStats();
1152 EXPECT_TRUE(stats.cpu_limited_resolution);
1153 EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
1154
1155 // Disable CPU adaptation.
1156 vie_encoder_->SetSource(
1157 &new_video_source,
1158 VideoSendStream::DegradationPreference::kDegradationDisabled);
1159 new_video_source.IncomingCapturedFrame(
1160 CreateFrame(sequence, frame_width, frame_height));
1161 sink_.WaitForEncodedFrame(sequence++);
1162
1163 stats = stats_proxy_->GetStats();
1164 EXPECT_FALSE(stats.cpu_limited_resolution);
1165 EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
1166
1167 // Try to trigger overuse. Should not succeed.
1168 stats_proxy_->SetMockStats(mock_stats);
1169 vie_encoder_->TriggerCpuOveruse();
1170 stats_proxy_->ResetMockStats();
1171
1172 stats = stats_proxy_->GetStats();
1173 EXPECT_FALSE(stats.cpu_limited_resolution);
1174 EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
1175
1176 // Switch back the source with resolution adaptation enabled.
1177 vie_encoder_->SetSource(
1178 &video_source_,
1179 VideoSendStream::DegradationPreference::kMaintainFramerate);
1026 video_source_.IncomingCapturedFrame( 1180 video_source_.IncomingCapturedFrame(
1027 CreateFrame(sequence, frame_width, frame_height)); 1181 CreateFrame(sequence, frame_width, frame_height));
1028 sink_.WaitForEncodedFrame(sequence++); 1182 sink_.WaitForEncodedFrame(sequence++);
1029 stats = stats_proxy_->GetStats(); 1183 stats = stats_proxy_->GetStats();
1030 EXPECT_TRUE(stats.cpu_limited_resolution); 1184 EXPECT_TRUE(stats.cpu_limited_resolution);
1031 EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); 1185 EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
1032 1186
1033 // Trigger CPU normal usage. 1187 // Trigger CPU normal usage.
1034 vie_encoder_->TriggerCpuNormalUsage(); 1188 vie_encoder_->TriggerCpuNormalUsage();
1035 video_source_.IncomingCapturedFrame( 1189 video_source_.IncomingCapturedFrame(
1036 CreateFrame(sequence, frame_width, frame_height)); 1190 CreateFrame(sequence, frame_width, frame_height));
1037 sink_.WaitForEncodedFrame(sequence++); 1191 sink_.WaitForEncodedFrame(sequence++);
1038 stats = stats_proxy_->GetStats(); 1192 stats = stats_proxy_->GetStats();
1039 EXPECT_FALSE(stats.cpu_limited_resolution); 1193 EXPECT_FALSE(stats.cpu_limited_resolution);
1040 EXPECT_EQ(2, stats.number_of_cpu_adapt_changes); 1194 EXPECT_EQ(3, stats.number_of_cpu_adapt_changes);
1195
1196 // Back to the source with adaptation off, set it back to maintain-resolution.
1197 vie_encoder_->SetSource(
1198 &new_video_source,
1199 VideoSendStream::DegradationPreference::kMaintainResolution);
1200 new_video_source.IncomingCapturedFrame(
1201 CreateFrame(sequence, frame_width, frame_height));
1202 sink_.WaitForEncodedFrame(sequence++);
1203 stats = stats_proxy_->GetStats();
1204 // Disabled, since we previously switched the source too disabled.
1205 EXPECT_FALSE(stats.cpu_limited_resolution);
1206 EXPECT_EQ(3, stats.number_of_cpu_adapt_changes);
1207
1208 // Trigger CPU normal usage.
1209 vie_encoder_->TriggerCpuNormalUsage();
1210 new_video_source.IncomingCapturedFrame(
1211 CreateFrame(sequence, frame_width, frame_height));
1212 sink_.WaitForEncodedFrame(sequence++);
1213 stats = stats_proxy_->GetStats();
1214 EXPECT_FALSE(stats.cpu_limited_resolution);
1215 EXPECT_EQ(4, stats.number_of_cpu_adapt_changes);
1041 1216
1042 vie_encoder_->Stop(); 1217 vie_encoder_->Stop();
1043 } 1218 }
1044 1219
1045 TEST_F(ViEEncoderTest, StatsTracksPreferredBitrate) { 1220 TEST_F(ViEEncoderTest, StatsTracksPreferredBitrate) {
1046 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 1221 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1047 1222
1048 video_source_.IncomingCapturedFrame(CreateFrame(1, 1280, 720)); 1223 video_source_.IncomingCapturedFrame(CreateFrame(1, 1280, 720));
1049 sink_.WaitForEncodedFrame(1); 1224 sink_.WaitForEncodedFrame(1);
1050 1225
1051 VideoSendStream::Stats stats = stats_proxy_->GetStats(); 1226 VideoSendStream::Stats stats = stats_proxy_->GetStats();
1052 EXPECT_EQ(video_encoder_config_.max_bitrate_bps, 1227 EXPECT_EQ(video_encoder_config_.max_bitrate_bps,
1053 stats.preferred_media_bitrate_bps); 1228 stats.preferred_media_bitrate_bps);
1054 1229
1055 vie_encoder_->Stop(); 1230 vie_encoder_->Stop();
1056 } 1231 }
1057 1232
1058 TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) { 1233 TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) {
1059 int frame_width = 1280; 1234 int frame_width = 1280;
1060 int frame_height = 720; 1235 int frame_height = 720;
1061 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 1236 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1062 1237
1063 // Expect no scaling to begin with 1238 // Expect no scaling to begin with
1064 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); 1239 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count);
1065 EXPECT_FALSE(video_source_.sink_wants().max_pixel_count); 1240 EXPECT_EQ(std::numeric_limits<int>::max(),
1241 video_source_.sink_wants().max_pixel_count);
1066 1242
1067 video_source_.IncomingCapturedFrame( 1243 video_source_.IncomingCapturedFrame(
1068 CreateFrame(1, frame_width, frame_height)); 1244 CreateFrame(1, frame_width, frame_height));
1069 sink_.WaitForEncodedFrame(1); 1245 sink_.WaitForEncodedFrame(1);
1070 1246
1071 // Trigger scale down 1247 // Trigger scale down
1072 vie_encoder_->TriggerQualityLow(); 1248 vie_encoder_->TriggerQualityLow();
1073 1249
1074 video_source_.IncomingCapturedFrame( 1250 video_source_.IncomingCapturedFrame(
1075 CreateFrame(2, frame_width, frame_height)); 1251 CreateFrame(2, frame_width, frame_height));
1076 sink_.WaitForEncodedFrame(2); 1252 sink_.WaitForEncodedFrame(2);
1077 1253
1078 // Expect a scale down. 1254 // Expect a scale down.
1079 EXPECT_TRUE(video_source_.sink_wants().max_pixel_count); 1255 EXPECT_TRUE(video_source_.sink_wants().max_pixel_count);
1080 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, 1256 EXPECT_LT(video_source_.sink_wants().max_pixel_count,
1081 frame_width * frame_height); 1257 frame_width * frame_height);
1082 1258
1083 // Set adaptation disabled. 1259 // Set adaptation disabled.
1084 test::FrameForwarder new_video_source; 1260 test::FrameForwarder new_video_source;
1085 vie_encoder_->SetSource( 1261 vie_encoder_->SetSource(
1086 &new_video_source, 1262 &new_video_source,
1087 VideoSendStream::DegradationPreference::kMaintainResolution); 1263 VideoSendStream::DegradationPreference::kMaintainResolution);
1088 1264
1089 // Trigger scale down 1265 // Trigger scale down
1090 vie_encoder_->TriggerQualityLow(); 1266 vie_encoder_->TriggerQualityLow();
1091 new_video_source.IncomingCapturedFrame( 1267 new_video_source.IncomingCapturedFrame(
1092 CreateFrame(3, frame_width, frame_height)); 1268 CreateFrame(3, frame_width, frame_height));
1093 sink_.WaitForEncodedFrame(3); 1269 sink_.WaitForEncodedFrame(3);
1094 1270
1095 // Expect no scaling 1271 // Expect no scaling
1096 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); 1272 EXPECT_EQ(std::numeric_limits<int>::max(),
1273 new_video_source.sink_wants().max_pixel_count);
1097 1274
1098 // Trigger scale up 1275 // Trigger scale up
1099 vie_encoder_->TriggerQualityHigh(); 1276 vie_encoder_->TriggerQualityHigh();
1100 new_video_source.IncomingCapturedFrame( 1277 new_video_source.IncomingCapturedFrame(
1101 CreateFrame(4, frame_width, frame_height)); 1278 CreateFrame(4, frame_width, frame_height));
1102 sink_.WaitForEncodedFrame(4); 1279 sink_.WaitForEncodedFrame(4);
1103 1280
1104 // Expect nothing to change, still no scaling 1281 // Expect nothing to change, still no scaling
1105 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); 1282 EXPECT_EQ(std::numeric_limits<int>::max(),
1283 new_video_source.sink_wants().max_pixel_count);
1106 1284
1107 vie_encoder_->Stop(); 1285 vie_encoder_->Stop();
1108 } 1286 }
1109 1287
1110 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { 1288 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) {
1111 int frame_width = 1280; 1289 int frame_width = 1280;
1112 int frame_height = 720; 1290 int frame_height = 720;
1113 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 1291 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1114 1292
1115 for (size_t i = 1; i <= 10; i++) { 1293 for (size_t i = 1; i <= 10; i++) {
1116 video_source_.IncomingCapturedFrame( 1294 video_source_.IncomingCapturedFrame(
1117 CreateFrame(i, frame_width, frame_height)); 1295 CreateFrame(i, frame_width, frame_height));
1118 sink_.WaitForEncodedFrame(i); 1296 sink_.WaitForEncodedFrame(i);
1119 // Trigger scale down 1297 // Trigger scale down
1120 vie_encoder_->TriggerQualityLow(); 1298 vie_encoder_->TriggerQualityLow();
1121 EXPECT_GE(*video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); 1299 EXPECT_GE(video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame);
1122 } 1300 }
1123 1301
1124 vie_encoder_->Stop(); 1302 vie_encoder_->Stop();
1125 } 1303 }
1126 1304
1127 TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { 1305 TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) {
1128 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 1306 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1129 1307
1130 int frame_width = 640; 1308 int frame_width = 640;
1131 int frame_height = 360; 1309 int frame_height = 360;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 int frame_width = 640; 1382 int frame_width = 640;
1205 int frame_height = 360; 1383 int frame_height = 360;
1206 1384
1207 video_source_.IncomingCapturedFrame( 1385 video_source_.IncomingCapturedFrame(
1208 CreateFrame(1, frame_width, frame_height)); 1386 CreateFrame(1, frame_width, frame_height));
1209 1387
1210 // Expect to drop this frame, the wait should time out. 1388 // Expect to drop this frame, the wait should time out.
1211 sink_.ExpectDroppedFrame(); 1389 sink_.ExpectDroppedFrame();
1212 1390
1213 // Expect the sink_wants to specify a scaled frame. 1391 // Expect the sink_wants to specify a scaled frame.
1214 EXPECT_TRUE(video_source_.sink_wants().max_pixel_count); 1392 EXPECT_LT(video_source_.sink_wants().max_pixel_count, 1000 * 1000);
1215 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, 1000 * 1000);
1216 1393
1217 int last_pixel_count = *video_source_.sink_wants().max_pixel_count; 1394 int last_pixel_count = video_source_.sink_wants().max_pixel_count;
1218 1395
1219 // Next frame is scaled 1396 // Next frame is scaled
1220 video_source_.IncomingCapturedFrame( 1397 video_source_.IncomingCapturedFrame(
1221 CreateFrame(2, frame_width * 3 / 4, frame_height * 3 / 4)); 1398 CreateFrame(2, frame_width * 3 / 4, frame_height * 3 / 4));
1222 1399
1223 // Expect to drop this frame, the wait should time out. 1400 // Expect to drop this frame, the wait should time out.
1224 sink_.ExpectDroppedFrame(); 1401 sink_.ExpectDroppedFrame();
1225 1402
1226 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, last_pixel_count); 1403 EXPECT_LT(video_source_.sink_wants().max_pixel_count, last_pixel_count);
1227 1404
1228 vie_encoder_->Stop(); 1405 vie_encoder_->Stop();
1229 } 1406 }
1230 1407
1231 TEST_F(ViEEncoderTest, NrOfDroppedFramesLimited) { 1408 TEST_F(ViEEncoderTest, NrOfDroppedFramesLimited) {
1232 // 1kbps. This can never be achieved. 1409 // 1kbps. This can never be achieved.
1233 vie_encoder_->OnBitrateUpdated(1000, 0, 0); 1410 vie_encoder_->OnBitrateUpdated(1000, 0, 0);
1234 int frame_width = 640; 1411 int frame_width = 640;
1235 int frame_height = 360; 1412 int frame_height = 360;
1236 1413
1237 // We expect the n initial frames to get dropped. 1414 // We expect the n initial frames to get dropped.
1238 int i; 1415 int i;
1239 for (i = 1; i <= kMaxInitialFramedrop; ++i) { 1416 for (i = 1; i <= kMaxInitialFramedrop; ++i) {
1240 video_source_.IncomingCapturedFrame( 1417 video_source_.IncomingCapturedFrame(
1241 CreateFrame(i, frame_width, frame_height)); 1418 CreateFrame(i, frame_width, frame_height));
1242 sink_.ExpectDroppedFrame(); 1419 sink_.ExpectDroppedFrame();
1243 } 1420 }
1244 // The n+1th frame should not be dropped, even though it's size is too large. 1421 // The n+1th frame should not be dropped, even though it's size is too large.
1245 video_source_.IncomingCapturedFrame( 1422 video_source_.IncomingCapturedFrame(
1246 CreateFrame(i, frame_width, frame_height)); 1423 CreateFrame(i, frame_width, frame_height));
1247 sink_.WaitForEncodedFrame(i); 1424 sink_.WaitForEncodedFrame(i);
1248 1425
1249 // Expect the sink_wants to specify a scaled frame. 1426 // Expect the sink_wants to specify a scaled frame.
1250 EXPECT_TRUE(video_source_.sink_wants().max_pixel_count); 1427 EXPECT_LT(video_source_.sink_wants().max_pixel_count, 1000 * 1000);
1251 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, 1000 * 1000);
1252 1428
1253 vie_encoder_->Stop(); 1429 vie_encoder_->Stop();
1254 } 1430 }
1255 1431
1256 TEST_F(ViEEncoderTest, InitialFrameDropOffWithMaintainResolutionPreference) { 1432 TEST_F(ViEEncoderTest, InitialFrameDropOffWithMaintainResolutionPreference) {
1257 int frame_width = 640; 1433 int frame_width = 640;
1258 int frame_height = 360; 1434 int frame_height = 360;
1259 vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0); 1435 vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
1260 1436
1261 // Set degradation preference. 1437 // Set degradation preference.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 video_source_.IncomingCapturedFrame( 1478 video_source_.IncomingCapturedFrame(
1303 CreateFrame(1, kFrameWidth, kFrameHeight)); 1479 CreateFrame(1, kFrameWidth, kFrameHeight));
1304 sink_.WaitForEncodedFrame(kFrameWidth, kFrameHeight); 1480 sink_.WaitForEncodedFrame(kFrameWidth, kFrameHeight);
1305 1481
1306 // Trigger CPU overuse, downscale by 3/4. 1482 // Trigger CPU overuse, downscale by 3/4.
1307 vie_encoder_->TriggerCpuOveruse(); 1483 vie_encoder_->TriggerCpuOveruse();
1308 video_source_.IncomingCapturedFrame( 1484 video_source_.IncomingCapturedFrame(
1309 CreateFrame(2, kFrameWidth, kFrameHeight)); 1485 CreateFrame(2, kFrameWidth, kFrameHeight));
1310 sink_.WaitForEncodedFrame((kFrameWidth * 3) / 4, (kFrameHeight * 3) / 4); 1486 sink_.WaitForEncodedFrame((kFrameWidth * 3) / 4, (kFrameHeight * 3) / 4);
1311 1487
1312 // Trigger CPU normal use, return to original resoluton; 1488 // Trigger CPU normal use, return to original resolution;
1313 vie_encoder_->TriggerCpuNormalUsage(); 1489 vie_encoder_->TriggerCpuNormalUsage();
1314 video_source_.IncomingCapturedFrame( 1490 video_source_.IncomingCapturedFrame(
1315 CreateFrame(3, kFrameWidth, kFrameHeight)); 1491 CreateFrame(3, kFrameWidth, kFrameHeight));
1316 sink_.WaitForEncodedFrame(kFrameWidth, kFrameHeight); 1492 sink_.WaitForEncodedFrame(kFrameWidth, kFrameHeight);
1317 1493
1318 vie_encoder_->Stop(); 1494 vie_encoder_->Stop();
1319 } 1495 }
1320 1496
1321 TEST_F(ViEEncoderTest, FailingInitEncodeDoesntCauseCrash) { 1497 TEST_F(ViEEncoderTest, FailingInitEncodeDoesntCauseCrash) {
1322 fake_encoder_.ForceInitEncodeFailure(true); 1498 fake_encoder_.ForceInitEncodeFailure(true);
1323 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 1499 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1324 ResetEncoder("VP8", 2, 1, true); 1500 ResetEncoder("VP8", 2, 1, true);
1325 const int kFrameWidth = 1280; 1501 const int kFrameWidth = 1280;
1326 const int kFrameHeight = 720; 1502 const int kFrameHeight = 720;
1327 video_source_.IncomingCapturedFrame( 1503 video_source_.IncomingCapturedFrame(
1328 CreateFrame(1, kFrameWidth, kFrameHeight)); 1504 CreateFrame(1, kFrameWidth, kFrameHeight));
1329 sink_.ExpectDroppedFrame(); 1505 sink_.ExpectDroppedFrame();
1330 vie_encoder_->Stop(); 1506 vie_encoder_->Stop();
1331 } 1507 }
1508
1509 TEST_F(ViEEncoderTest, AdaptsFrameOnOveruseWithMaintainResolution) {
1510 const int kDefaultFramerateFps = 30;
1511 const int kFrameIntervalMs = rtc::kNumMillisecsPerSec / kDefaultFramerateFps;
1512 const int kFrameWidth = 1280;
1513 const int kFrameHeight = 720;
1514 rtc::ScopedFakeClock fake_clock;
1515
1516 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1517 vie_encoder_->SetSource(
1518 &video_source_,
1519 VideoSendStream::DegradationPreference::kMaintainResolution);
1520 video_source_.set_adaptation_enabled(true);
1521
1522 fake_clock.SetTimeMicros(kFrameIntervalMs * 1000);
1523 int64_t timestamp_ms = kFrameIntervalMs;
1524
1525 video_source_.IncomingCapturedFrame(
1526 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1527 sink_.WaitForEncodedFrame(timestamp_ms);
1528
1529 // Try to trigger overuse. No fps estimate available => no effect.
1530 vie_encoder_->TriggerCpuOveruse();
1531
1532 // Insert frames for one second to get a stable estimate.
1533 for (int i = 0; i < kDefaultFramerateFps; ++i) {
1534 timestamp_ms += kFrameIntervalMs;
1535 fake_clock.AdvanceTimeMicros(kFrameIntervalMs * 1000);
1536 video_source_.IncomingCapturedFrame(
1537 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1538 sink_.WaitForEncodedFrame(timestamp_ms);
1539 }
1540
1541 // Trigger CPU overuse, reduce framerate by 2/3.
1542 vie_encoder_->TriggerCpuOveruse();
1543 int num_frames_dropped = 0;
1544 for (int i = 0; i < kDefaultFramerateFps; ++i) {
1545 timestamp_ms += kFrameIntervalMs;
1546 fake_clock.AdvanceTimeMicros(kFrameIntervalMs * 1000);
1547 video_source_.IncomingCapturedFrame(
1548 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1549 if (!sink_.WaitForFrame(kFrameTimeoutMs)) {
1550 ++num_frames_dropped;
1551 } else {
1552 sink_.CheckLastFrameSizeMathces(kFrameWidth, kFrameHeight);
1553 }
1554 }
1555
1556 // TODO(sprang): Find where there's rounding errors or stuff causing the
1557 // margin here to be a little larger than we'd like (input fps estimate is
1558 // off) and the frame dropping is a little too aggressive.
1559 const int kErrorMargin = 5;
1560 EXPECT_NEAR(num_frames_dropped,
1561 kDefaultFramerateFps - (kDefaultFramerateFps * 2 / 3),
1562 kErrorMargin);
1563
1564 // Trigger CPU overuse, reduce framerate by 2/3 again.
1565 vie_encoder_->TriggerCpuOveruse();
1566 num_frames_dropped = 0;
1567 for (int i = 0; i < kDefaultFramerateFps; ++i) {
1568 timestamp_ms += kFrameIntervalMs;
1569 fake_clock.AdvanceTimeMicros(kFrameIntervalMs * 1000);
1570 video_source_.IncomingCapturedFrame(
1571 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1572 if (!sink_.WaitForFrame(kFrameTimeoutMs)) {
1573 ++num_frames_dropped;
1574 } else {
1575 sink_.CheckLastFrameSizeMathces(kFrameWidth, kFrameHeight);
1576 }
1577 }
1578 EXPECT_NEAR(num_frames_dropped,
1579 kDefaultFramerateFps - (kDefaultFramerateFps * 4 / 9),
1580 kErrorMargin);
1581
1582 // Go back up one step.
1583 vie_encoder_->TriggerCpuNormalUsage();
1584 num_frames_dropped = 0;
1585 for (int i = 0; i < kDefaultFramerateFps; ++i) {
1586 timestamp_ms += kFrameIntervalMs;
1587 fake_clock.AdvanceTimeMicros(kFrameIntervalMs * 1000);
1588 video_source_.IncomingCapturedFrame(
1589 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1590 if (!sink_.WaitForFrame(kFrameTimeoutMs)) {
1591 ++num_frames_dropped;
1592 } else {
1593 sink_.CheckLastFrameSizeMathces(kFrameWidth, kFrameHeight);
1594 }
1595 }
1596 EXPECT_NEAR(num_frames_dropped,
1597 kDefaultFramerateFps - (kDefaultFramerateFps * 2 / 3),
1598 kErrorMargin);
1599
1600 // Go back up to original mode.
1601 vie_encoder_->TriggerCpuNormalUsage();
1602 num_frames_dropped = 0;
1603 for (int i = 0; i < kDefaultFramerateFps; ++i) {
1604 timestamp_ms += kFrameIntervalMs;
1605 fake_clock.AdvanceTimeMicros(kFrameIntervalMs * 1000);
1606 video_source_.IncomingCapturedFrame(
1607 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1608 if (!sink_.WaitForFrame(kFrameTimeoutMs)) {
1609 ++num_frames_dropped;
1610 } else {
1611 sink_.CheckLastFrameSizeMathces(kFrameWidth, kFrameHeight);
1612 }
1613 }
1614 EXPECT_NEAR(num_frames_dropped, 0, kErrorMargin);
1615
1616 vie_encoder_->Stop();
1617 }
1618
1619 TEST_F(ViEEncoderTest, DoesntAdaptDownPastMinFramerate) {
1620 const int kFramerateFps = 5;
1621 const int kFrameIntervalMs = rtc::kNumMillisecsPerSec / kFramerateFps;
1622 const int kMinFpsFrameInterval = rtc::kNumMillisecsPerSec / kMinFramerateFps;
1623 const int kFrameWidth = 1280;
1624 const int kFrameHeight = 720;
1625
1626 rtc::ScopedFakeClock fake_clock;
1627 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1628 vie_encoder_->SetSource(
1629 &video_source_,
1630 VideoSendStream::DegradationPreference::kMaintainResolution);
1631 video_source_.set_adaptation_enabled(true);
1632
1633 fake_clock.SetTimeMicros(kFrameIntervalMs * 1000);
1634 int64_t timestamp_ms = kFrameIntervalMs;
1635
1636 // Trigger overuse as much as we can.
1637 for (int i = 0; i < ViEEncoder::kMaxCpuResolutionDowngrades; ++i) {
1638 // Insert frames to get a new fps estimate...
1639 for (int j = 0; j < kFramerateFps; ++j) {
1640 video_source_.IncomingCapturedFrame(
1641 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1642 timestamp_ms += kFrameIntervalMs;
1643 fake_clock.AdvanceTimeMicros(kFrameIntervalMs * 1000);
1644 }
1645 // ...and then try to adapt again.
1646 vie_encoder_->TriggerCpuOveruse();
1647 }
1648
1649 // Drain any frame in the pipeline.
1650 sink_.WaitForFrame(kDefaultTimeoutMs);
1651
1652 // Insert frames at min fps, all should go through.
1653 for (int i = 0; i < 10; ++i) {
1654 timestamp_ms += kMinFpsFrameInterval;
1655 fake_clock.AdvanceTimeMicros(kMinFpsFrameInterval * 1000);
1656 video_source_.IncomingCapturedFrame(
1657 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
1658 sink_.WaitForEncodedFrame(timestamp_ms);
1659 }
1660 vie_encoder_->Stop();
1661 }
1332 } // namespace webrtc 1662 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | webrtc/video_send_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698