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

Side by Side Diff: webrtc/video_engine/overuse_frame_detector_unittest.cc

Issue 1278383002: Remove avg encode time from CpuOveruseMetric struct and use value from OnEncodedFrame instead. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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
OLDNEW
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 void TriggerUnderuse() { 96 void TriggerUnderuse() {
97 const int kDelayMs1 = 5; 97 const int kDelayMs1 = 5;
98 const int kDelayMs2 = 6; 98 const int kDelayMs2 = 6;
99 InsertAndSendFramesWithInterval( 99 InsertAndSendFramesWithInterval(
100 1300, kFrameInterval33ms, kWidth, kHeight, kDelayMs1); 100 1300, kFrameInterval33ms, kWidth, kHeight, kDelayMs1);
101 InsertAndSendFramesWithInterval( 101 InsertAndSendFramesWithInterval(
102 1, kFrameInterval33ms, kWidth, kHeight, kDelayMs2); 102 1, kFrameInterval33ms, kWidth, kHeight, kDelayMs2);
103 overuse_detector_->Process(); 103 overuse_detector_->Process();
104 } 104 }
105 105
106 int AvgEncodeTimeMs() { return metrics_.avg_encode_time_ms; }
107
108 int UsagePercent() { return metrics_.encode_usage_percent; } 106 int UsagePercent() { return metrics_.encode_usage_percent; }
109 107
110 CpuOveruseOptions options_; 108 CpuOveruseOptions options_;
111 rtc::scoped_ptr<SimulatedClock> clock_; 109 rtc::scoped_ptr<SimulatedClock> clock_;
112 rtc::scoped_ptr<MockCpuOveruseObserver> observer_; 110 rtc::scoped_ptr<MockCpuOveruseObserver> observer_;
113 rtc::scoped_ptr<OveruseFrameDetector> overuse_detector_; 111 rtc::scoped_ptr<OveruseFrameDetector> overuse_detector_;
114 CpuOveruseMetrics metrics_; 112 CpuOveruseMetrics metrics_;
115 }; 113 };
116 114
117 115
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 ReinitializeOveruseDetector(); 347 ReinitializeOveruseDetector();
350 const int kProcessingTimeMs = 100; 348 const int kProcessingTimeMs = 100;
351 overuse_detector_->FrameCaptured(kWidth, kHeight, 33); 349 overuse_detector_->FrameCaptured(kWidth, kHeight, 33);
352 clock_->AdvanceTimeMilliseconds(kProcessingTimeMs); 350 clock_->AdvanceTimeMilliseconds(kProcessingTimeMs);
353 overuse_detector_->FrameSent(34); 351 overuse_detector_->FrameSent(34);
354 EXPECT_EQ(-1, overuse_detector_->LastProcessingTimeMs()); 352 EXPECT_EQ(-1, overuse_detector_->LastProcessingTimeMs());
355 overuse_detector_->FrameSent(33); 353 overuse_detector_->FrameSent(33);
356 EXPECT_EQ(kProcessingTimeMs, overuse_detector_->LastProcessingTimeMs()); 354 EXPECT_EQ(kProcessingTimeMs, overuse_detector_->LastProcessingTimeMs());
357 } 355 }
358 356
359 TEST_F(OveruseFrameDetectorTest, EncodedFrame) {
360 const int kInitialAvgEncodeTimeInMs = 5;
361 EXPECT_EQ(kInitialAvgEncodeTimeInMs, AvgEncodeTimeMs());
362 for (int i = 0; i < 30; i++) {
363 clock_->AdvanceTimeMilliseconds(33);
364 overuse_detector_->FrameEncoded(2);
365 }
366 EXPECT_EQ(2, AvgEncodeTimeMs());
367 }
368
369 // enable_encode_usage_method = true; 357 // enable_encode_usage_method = true;
370 // enable_extended_processing_usage = true; 358 // enable_extended_processing_usage = true;
371 // UsagePercent() > high_encode_usage_threshold_percent => overuse. 359 // UsagePercent() > high_encode_usage_threshold_percent => overuse.
372 // UsagePercent() < low_encode_usage_threshold_percent => underuse. 360 // UsagePercent() < low_encode_usage_threshold_percent => underuse.
373 TEST_F(OveruseFrameDetectorTest, TriggerOveruseWithExtendedProcessingUsage) { 361 TEST_F(OveruseFrameDetectorTest, TriggerOveruseWithExtendedProcessingUsage) {
374 options_.enable_extended_processing_usage = true; 362 options_.enable_extended_processing_usage = true;
375 ReinitializeOveruseDetector(); 363 ReinitializeOveruseDetector();
376 // usage > high => overuse 364 // usage > high => overuse
377 EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1); 365 EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
378 TriggerOveruse(options_.high_threshold_consecutive_count); 366 TriggerOveruse(options_.high_threshold_consecutive_count);
(...skipping 17 matching lines...) Expand all
396 ReinitializeOveruseDetector(); 384 ReinitializeOveruseDetector();
397 // usage > high => overuse 385 // usage > high => overuse
398 EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(0); 386 EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(0);
399 TriggerOveruse(options_.high_threshold_consecutive_count); 387 TriggerOveruse(options_.high_threshold_consecutive_count);
400 // usage < low => underuse 388 // usage < low => underuse
401 EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(0); 389 EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(0);
402 TriggerUnderuse(); 390 TriggerUnderuse();
403 } 391 }
404 392
405 } // namespace webrtc 393 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698