| 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Expontential back-off factor, to prevent annoying up-down behaviour. | 41 // Expontential back-off factor, to prevent annoying up-down behaviour. |
| 42 const double kRampUpBackoffFactor = 2.0; | 42 const double kRampUpBackoffFactor = 2.0; |
| 43 | 43 |
| 44 // Max number of overuses detected before always applying the rampup delay. | 44 // Max number of overuses detected before always applying the rampup delay. |
| 45 const int kMaxOverusesBeforeApplyRampupDelay = 4; | 45 const int kMaxOverusesBeforeApplyRampupDelay = 4; |
| 46 | 46 |
| 47 // The maximum exponent to use in VCMExpFilter. | 47 // The maximum exponent to use in VCMExpFilter. |
| 48 const float kSampleDiffMs = 33.0f; | 48 const float kSampleDiffMs = 33.0f; |
| 49 const float kMaxExp = 7.0f; | 49 const float kMaxExp = 7.0f; |
| 50 | 50 |
| 51 const auto kScaleReasonCpu = ScalingObserverInterface::ScaleReason::kCpu; | 51 const auto kScaleReasonCpu = AdaptationObserverInterface::AdaptReason::kCpu; |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 CpuOveruseOptions::CpuOveruseOptions() | 54 CpuOveruseOptions::CpuOveruseOptions() |
| 55 : high_encode_usage_threshold_percent(85), | 55 : high_encode_usage_threshold_percent(85), |
| 56 frame_timeout_interval_ms(1500), | 56 frame_timeout_interval_ms(1500), |
| 57 min_frame_samples(120), | 57 min_frame_samples(120), |
| 58 min_process_count(3), | 58 min_process_count(3), |
| 59 high_threshold_consecutive_count(2) { | 59 high_threshold_consecutive_count(2) { |
| 60 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | 60 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| 61 // This is proof-of-concept code for letting the physical core count affect | 61 // This is proof-of-concept code for letting the physical core count affect |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Return false to prevent this task from being deleted. Ownership has been | 196 // Return false to prevent this task from being deleted. Ownership has been |
| 197 // transferred to the task queue when PostDelayedTask was called. | 197 // transferred to the task queue when PostDelayedTask was called. |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| 200 rtc::SequencedTaskChecker task_checker_; | 200 rtc::SequencedTaskChecker task_checker_; |
| 201 OveruseFrameDetector* overuse_detector_; | 201 OveruseFrameDetector* overuse_detector_; |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 OveruseFrameDetector::OveruseFrameDetector( | 204 OveruseFrameDetector::OveruseFrameDetector( |
| 205 const CpuOveruseOptions& options, | 205 const CpuOveruseOptions& options, |
| 206 ScalingObserverInterface* observer, | 206 AdaptationObserverInterface* observer, |
| 207 EncodedFrameObserver* encoder_timing, | 207 EncodedFrameObserver* encoder_timing, |
| 208 CpuOveruseMetricsObserver* metrics_observer) | 208 CpuOveruseMetricsObserver* metrics_observer) |
| 209 : check_overuse_task_(nullptr), | 209 : check_overuse_task_(nullptr), |
| 210 options_(options), | 210 options_(options), |
| 211 observer_(observer), | 211 observer_(observer), |
| 212 encoder_timing_(encoder_timing), | 212 encoder_timing_(encoder_timing), |
| 213 metrics_observer_(metrics_observer), | 213 metrics_observer_(metrics_observer), |
| 214 num_process_times_(0), | 214 num_process_times_(0), |
| 215 // TODO(nisse): Use rtc::Optional | 215 // TODO(nisse): Use rtc::Optional |
| 216 last_capture_time_us_(-1), | 216 last_capture_time_us_(-1), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 current_rampup_delay_ms_ = kStandardRampUpDelayMs; | 369 current_rampup_delay_ms_ = kStandardRampUpDelayMs; |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 last_overuse_time_ms_ = now_ms; | 373 last_overuse_time_ms_ = now_ms; |
| 374 in_quick_rampup_ = false; | 374 in_quick_rampup_ = false; |
| 375 checks_above_threshold_ = 0; | 375 checks_above_threshold_ = 0; |
| 376 ++num_overuse_detections_; | 376 ++num_overuse_detections_; |
| 377 | 377 |
| 378 if (observer_) | 378 if (observer_) |
| 379 observer_->ScaleDown(kScaleReasonCpu); | 379 observer_->AdaptDown(kScaleReasonCpu); |
| 380 } else if (IsUnderusing(*metrics_, now_ms)) { | 380 } else if (IsUnderusing(*metrics_, now_ms)) { |
| 381 last_rampup_time_ms_ = now_ms; | 381 last_rampup_time_ms_ = now_ms; |
| 382 in_quick_rampup_ = true; | 382 in_quick_rampup_ = true; |
| 383 | 383 |
| 384 if (observer_) | 384 if (observer_) |
| 385 observer_->ScaleUp(kScaleReasonCpu); | 385 observer_->AdaptUp(kScaleReasonCpu); |
| 386 } | 386 } |
| 387 | 387 |
| 388 int rampup_delay = | 388 int rampup_delay = |
| 389 in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; | 389 in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; |
| 390 | 390 |
| 391 LOG(LS_VERBOSE) << " Frame stats: " | 391 LOG(LS_VERBOSE) << " Frame stats: " |
| 392 << " encode usage " << metrics_->encode_usage_percent | 392 << " encode usage " << metrics_->encode_usage_percent |
| 393 << " overuse detections " << num_overuse_detections_ | 393 << " overuse detections " << num_overuse_detections_ |
| 394 << " rampup delay " << rampup_delay; | 394 << " rampup delay " << rampup_delay; |
| 395 } | 395 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 409 int64_t time_now) { | 409 int64_t time_now) { |
| 410 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 410 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
| 411 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; | 411 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; |
| 412 if (time_now < last_rampup_time_ms_ + delay) | 412 if (time_now < last_rampup_time_ms_ + delay) |
| 413 return false; | 413 return false; |
| 414 | 414 |
| 415 return metrics.encode_usage_percent < | 415 return metrics.encode_usage_percent < |
| 416 options_.low_encode_usage_threshold_percent; | 416 options_.low_encode_usage_threshold_percent; |
| 417 } | 417 } |
| 418 } // namespace webrtc | 418 } // namespace webrtc |
| OLD | NEW |