OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 | 488 |
489 LOG(LS_INFO) << "VAdapt GD Request: " | 489 LOG(LS_INFO) << "VAdapt GD Request: " |
490 << (DOWNGRADE == request ? "down" : | 490 << (DOWNGRADE == request ? "down" : |
491 (UPGRADE == request ? "up" : "keep")) | 491 (UPGRADE == request ? "up" : "keep")) |
492 << " From: " << width << "x" << height | 492 << " From: " << width << "x" << height |
493 << " Pixels: " << encoder_desired_num_pixels_ | 493 << " Pixels: " << encoder_desired_num_pixels_ |
494 << " Changed: " << (changed ? "true" : "false") | 494 << " Changed: " << (changed ? "true" : "false") |
495 << " To: " << new_width << "x" << new_height; | 495 << " To: " << new_width << "x" << new_height; |
496 } | 496 } |
497 | 497 |
498 void CoordinatedVideoAdapter::OnCpuResolutionRequest( | |
499 rtc::Optional<int> max_pixel_count, | |
500 rtc::Optional<int> max_pixel_count_step_up) { | |
501 rtc::CritScope cs(&request_critical_section_); | |
502 | |
503 AdaptRequest request = KEEP; | |
504 if (!max_pixel_count && !max_pixel_count_step_up) { | |
505 return; | |
506 } | |
507 if (max_pixel_count && *max_pixel_count < GetOutputNumPixels()) { | |
508 request = DOWNGRADE; | |
509 } else if (max_pixel_count_step_up && | |
510 *max_pixel_count_step_up <= GetOutputNumPixels()) { | |
511 request = UPGRADE; | |
512 } | |
513 OnCpuResolutionRequest(request); | |
pthatcher1
2016/02/25 07:40:30
Could this be shortened to the following?
if (max
perkj_webrtc
2016/02/25 13:57:07
Done.
| |
514 } | |
515 | |
498 // A Bandwidth GD request for new resolution | 516 // A Bandwidth GD request for new resolution |
499 void CoordinatedVideoAdapter::OnCpuResolutionRequest(AdaptRequest request) { | 517 void CoordinatedVideoAdapter::OnCpuResolutionRequest(AdaptRequest request) { |
500 rtc::CritScope cs(&request_critical_section_); | 518 rtc::CritScope cs(&request_critical_section_); |
501 if (!cpu_adaptation_) { | 519 if (!cpu_adaptation_) { |
502 return; | 520 return; |
503 } | 521 } |
522 | |
504 // Update how many times we have downgraded due to the cpu load. | 523 // Update how many times we have downgraded due to the cpu load. |
505 switch (request) { | 524 switch (request) { |
506 case DOWNGRADE: | 525 case DOWNGRADE: |
507 // Ignore downgrades if we have downgraded the maximum times. | 526 // Ignore downgrades if we have downgraded the maximum times. |
508 if (cpu_downgrade_count_ < kMaxCpuDowngrades) { | 527 if (cpu_downgrade_count_ < kMaxCpuDowngrades) { |
509 ++cpu_downgrade_count_; | 528 ++cpu_downgrade_count_; |
510 } else { | 529 } else { |
511 LOG(LS_VERBOSE) << "VAdapt CPU load high but do not downgrade " | 530 LOG(LS_VERBOSE) << "VAdapt CPU load high but do not downgrade " |
512 "because maximum downgrades reached"; | 531 "because maximum downgrades reached"; |
513 SignalCpuAdaptationUnable(); | 532 SignalCpuAdaptationUnable(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 // When any adaptation occurs, historic CPU load levels are no longer | 712 // When any adaptation occurs, historic CPU load levels are no longer |
694 // accurate. Clear out our state so we can re-learn at the new normal. | 713 // accurate. Clear out our state so we can re-learn at the new normal. |
695 cpu_load_num_samples_ = 0; | 714 cpu_load_num_samples_ = 0; |
696 system_load_average_ = kCpuLoadInitialAverage; | 715 system_load_average_ = kCpuLoadInitialAverage; |
697 } | 716 } |
698 | 717 |
699 return changed; | 718 return changed; |
700 } | 719 } |
701 | 720 |
702 } // namespace cricket | 721 } // namespace cricket |
OLD | NEW |