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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 last_processed_capture_time_ms_(-1), | 186 last_processed_capture_time_ms_(-1), |
187 num_pixels_(0), | 187 num_pixels_(0), |
188 next_process_time_ms_(clock_->TimeInMilliseconds()), | 188 next_process_time_ms_(clock_->TimeInMilliseconds()), |
189 last_overuse_time_ms_(-1), | 189 last_overuse_time_ms_(-1), |
190 checks_above_threshold_(0), | 190 checks_above_threshold_(0), |
191 num_overuse_detections_(0), | 191 num_overuse_detections_(0), |
192 last_rampup_time_ms_(-1), | 192 last_rampup_time_ms_(-1), |
193 in_quick_rampup_(false), | 193 in_quick_rampup_(false), |
194 current_rampup_delay_ms_(kStandardRampUpDelayMs), | 194 current_rampup_delay_ms_(kStandardRampUpDelayMs), |
195 usage_(new SendProcessingUsage(options)) { | 195 usage_(new SendProcessingUsage(options)) { |
196 RTC_DCHECK(metrics_observer != nullptr); | 196 RTC_DCHECK(metrics_observer); |
197 processing_thread_.DetachFromThread(); | 197 processing_thread_.DetachFromThread(); |
198 } | 198 } |
199 | 199 |
200 OveruseFrameDetector::~OveruseFrameDetector() { | 200 OveruseFrameDetector::~OveruseFrameDetector() { |
201 } | 201 } |
202 | 202 |
203 void OveruseFrameDetector::EncodedFrameTimeMeasured(int encode_duration_ms) { | 203 void OveruseFrameDetector::EncodedFrameTimeMeasured(int encode_duration_ms) { |
204 if (!metrics_) | 204 if (!metrics_) |
205 metrics_ = rtc::Optional<CpuOveruseMetrics>(CpuOveruseMetrics()); | 205 metrics_ = rtc::Optional<CpuOveruseMetrics>(CpuOveruseMetrics()); |
206 metrics_->encode_usage_percent = usage_->Value(); | 206 metrics_->encode_usage_percent = usage_->Value(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // Not currently backing off, reset rampup delay. | 334 // Not currently backing off, reset rampup delay. |
335 current_rampup_delay_ms_ = kStandardRampUpDelayMs; | 335 current_rampup_delay_ms_ = kStandardRampUpDelayMs; |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 last_overuse_time_ms_ = now; | 339 last_overuse_time_ms_ = now; |
340 in_quick_rampup_ = false; | 340 in_quick_rampup_ = false; |
341 checks_above_threshold_ = 0; | 341 checks_above_threshold_ = 0; |
342 ++num_overuse_detections_; | 342 ++num_overuse_detections_; |
343 | 343 |
344 if (observer_ != NULL) | 344 if (observer_) |
345 observer_->OveruseDetected(); | 345 observer_->OveruseDetected(); |
346 } else if (IsUnderusing(current_metrics, now)) { | 346 } else if (IsUnderusing(current_metrics, now)) { |
347 last_rampup_time_ms_ = now; | 347 last_rampup_time_ms_ = now; |
348 in_quick_rampup_ = true; | 348 in_quick_rampup_ = true; |
349 | 349 |
350 if (observer_ != NULL) | 350 if (observer_) |
351 observer_->NormalUsage(); | 351 observer_->NormalUsage(); |
352 } | 352 } |
353 | 353 |
354 int rampup_delay = | 354 int rampup_delay = |
355 in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; | 355 in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; |
356 | 356 |
357 LOG(LS_VERBOSE) << " Frame stats: " | 357 LOG(LS_VERBOSE) << " Frame stats: " |
358 << " encode usage " << current_metrics.encode_usage_percent | 358 << " encode usage " << current_metrics.encode_usage_percent |
359 << " overuse detections " << num_overuse_detections_ | 359 << " overuse detections " << num_overuse_detections_ |
360 << " rampup delay " << rampup_delay; | 360 << " rampup delay " << rampup_delay; |
(...skipping 12 matching lines...) Expand all Loading... |
373 bool OveruseFrameDetector::IsUnderusing(const CpuOveruseMetrics& metrics, | 373 bool OveruseFrameDetector::IsUnderusing(const CpuOveruseMetrics& metrics, |
374 int64_t time_now) { | 374 int64_t time_now) { |
375 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; | 375 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; |
376 if (time_now < last_rampup_time_ms_ + delay) | 376 if (time_now < last_rampup_time_ms_ + delay) |
377 return false; | 377 return false; |
378 | 378 |
379 return metrics.encode_usage_percent < | 379 return metrics.encode_usage_percent < |
380 options_.low_encode_usage_threshold_percent; | 380 options_.low_encode_usage_threshold_percent; |
381 } | 381 } |
382 } // namespace webrtc | 382 } // namespace webrtc |
OLD | NEW |