| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 int64_t now = clock_->TimeInMilliseconds(); | 248 int64_t now = clock_->TimeInMilliseconds(); |
| 249 if (FrameSizeChanged(width * height) || FrameTimeoutDetected(now)) { | 249 if (FrameSizeChanged(width * height) || FrameTimeoutDetected(now)) { |
| 250 ResetAll(width * height); | 250 ResetAll(width * height); |
| 251 } | 251 } |
| 252 | 252 |
| 253 if (last_capture_time_ != 0) | 253 if (last_capture_time_ != 0) |
| 254 usage_->AddCaptureSample(now - last_capture_time_); | 254 usage_->AddCaptureSample(now - last_capture_time_); |
| 255 | 255 |
| 256 last_capture_time_ = now; | 256 last_capture_time_ = now; |
| 257 | 257 |
| 258 if (options_.enable_extended_processing_usage) { | 258 frame_queue_->Start(capture_time_ms, now); |
| 259 frame_queue_->Start(capture_time_ms, now); | |
| 260 } | |
| 261 } | |
| 262 | |
| 263 void OveruseFrameDetector::FrameEncoded(int encode_time_ms) { | |
| 264 if (options_.enable_extended_processing_usage) | |
| 265 return; | |
| 266 | |
| 267 rtc::CritScope cs(&crit_); | |
| 268 AddProcessingTime(encode_time_ms); | |
| 269 } | 259 } |
| 270 | 260 |
| 271 void OveruseFrameDetector::FrameSent(int64_t capture_time_ms) { | 261 void OveruseFrameDetector::FrameSent(int64_t capture_time_ms) { |
| 272 if (!options_.enable_extended_processing_usage) | |
| 273 return; | |
| 274 | |
| 275 rtc::CritScope cs(&crit_); | 262 rtc::CritScope cs(&crit_); |
| 276 int delay_ms = frame_queue_->End(capture_time_ms, | 263 int delay_ms = frame_queue_->End(capture_time_ms, |
| 277 clock_->TimeInMilliseconds()); | 264 clock_->TimeInMilliseconds()); |
| 278 if (delay_ms > 0) { | 265 if (delay_ms > 0) { |
| 279 AddProcessingTime(delay_ms); | 266 AddProcessingTime(delay_ms); |
| 280 } | 267 } |
| 281 } | 268 } |
| 282 | 269 |
| 283 void OveruseFrameDetector::AddProcessingTime(int elapsed_ms) { | 270 void OveruseFrameDetector::AddProcessingTime(int elapsed_ms) { |
| 284 int64_t now = clock_->TimeInMilliseconds(); | 271 int64_t now = clock_->TimeInMilliseconds(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 336 |
| 350 LOG(LS_VERBOSE) << " Frame stats: " | 337 LOG(LS_VERBOSE) << " Frame stats: " |
| 351 << " encode usage " << current_metrics.encode_usage_percent | 338 << " encode usage " << current_metrics.encode_usage_percent |
| 352 << " overuse detections " << num_overuse_detections_ | 339 << " overuse detections " << num_overuse_detections_ |
| 353 << " rampup delay " << rampup_delay; | 340 << " rampup delay " << rampup_delay; |
| 354 | 341 |
| 355 return 0; | 342 return 0; |
| 356 } | 343 } |
| 357 | 344 |
| 358 bool OveruseFrameDetector::IsOverusing(const CpuOveruseMetrics& metrics) { | 345 bool OveruseFrameDetector::IsOverusing(const CpuOveruseMetrics& metrics) { |
| 359 bool overusing = false; | 346 if (metrics.encode_usage_percent >= |
| 360 if (options_.enable_encode_usage_method) { | 347 options_.high_encode_usage_threshold_percent) { |
| 361 overusing = metrics.encode_usage_percent >= | |
| 362 options_.high_encode_usage_threshold_percent; | |
| 363 } | |
| 364 if (overusing) { | |
| 365 ++checks_above_threshold_; | 348 ++checks_above_threshold_; |
| 366 } else { | 349 } else { |
| 367 checks_above_threshold_ = 0; | 350 checks_above_threshold_ = 0; |
| 368 } | 351 } |
| 369 return checks_above_threshold_ >= options_.high_threshold_consecutive_count; | 352 return checks_above_threshold_ >= options_.high_threshold_consecutive_count; |
| 370 } | 353 } |
| 371 | 354 |
| 372 bool OveruseFrameDetector::IsUnderusing(const CpuOveruseMetrics& metrics, | 355 bool OveruseFrameDetector::IsUnderusing(const CpuOveruseMetrics& metrics, |
| 373 int64_t time_now) { | 356 int64_t time_now) { |
| 374 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; | 357 int delay = in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_; |
| 375 if (time_now < last_rampup_time_ + delay) | 358 if (time_now < last_rampup_time_ + delay) |
| 376 return false; | 359 return false; |
| 377 | 360 |
| 378 bool underusing = false; | 361 return metrics.encode_usage_percent < |
| 379 if (options_.enable_encode_usage_method) { | 362 options_.low_encode_usage_threshold_percent; |
| 380 underusing = metrics.encode_usage_percent < | |
| 381 options_.low_encode_usage_threshold_percent; | |
| 382 } | |
| 383 return underusing; | |
| 384 } | 363 } |
| 385 } // namespace webrtc | 364 } // namespace webrtc |
| OLD | NEW |