OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 for (num = 1; num < (kFrameCountHistorySize - 1); ++num) { | 624 for (num = 1; num < (kFrameCountHistorySize - 1); ++num) { |
625 if (incoming_frame_times_[num] <= 0 || | 625 if (incoming_frame_times_[num] <= 0 || |
626 // don't use data older than 2 s | 626 // don't use data older than 2 s |
627 now - incoming_frame_times_[num] > kFrameHistoryWinMs) { | 627 now - incoming_frame_times_[num] > kFrameHistoryWinMs) { |
628 break; | 628 break; |
629 } else { | 629 } else { |
630 nr_of_frames++; | 630 nr_of_frames++; |
631 } | 631 } |
632 } | 632 } |
633 if (num > 1) { | 633 if (num > 1) { |
634 const int64_t diff = now - incoming_frame_times_[num - 1]; | 634 const int64_t diff = |
635 incoming_frame_rate_ = 1.0; | 635 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; |
| 636 incoming_frame_rate_ = 0.0; // No frame rate estimate available. |
636 if (diff > 0) { | 637 if (diff > 0) { |
637 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); | 638 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); |
638 } | 639 } |
639 } | 640 } |
640 } | 641 } |
641 | 642 |
642 void MediaOptimization::CheckSuspendConditions() { | 643 void MediaOptimization::CheckSuspendConditions() { |
643 // Check conditions for SuspendBelowMinBitrate. |target_bit_rate_| is in bps. | 644 // Check conditions for SuspendBelowMinBitrate. |target_bit_rate_| is in bps. |
644 if (suspension_enabled_) { | 645 if (suspension_enabled_) { |
645 if (!video_suspended_) { | 646 if (!video_suspended_) { |
646 // Check if we just went below the threshold. | 647 // Check if we just went below the threshold. |
647 if (target_bit_rate_ < suspension_threshold_bps_) { | 648 if (target_bit_rate_ < suspension_threshold_bps_) { |
648 video_suspended_ = true; | 649 video_suspended_ = true; |
649 } | 650 } |
650 } else { | 651 } else { |
651 // Video is already suspended. Check if we just went over the threshold | 652 // Video is already suspended. Check if we just went over the threshold |
652 // with a margin. | 653 // with a margin. |
653 if (target_bit_rate_ > | 654 if (target_bit_rate_ > |
654 suspension_threshold_bps_ + suspension_window_bps_) { | 655 suspension_threshold_bps_ + suspension_window_bps_) { |
655 video_suspended_ = false; | 656 video_suspended_ = false; |
656 } | 657 } |
657 } | 658 } |
658 } | 659 } |
659 } | 660 } |
660 | 661 |
661 } // namespace media_optimization | 662 } // namespace media_optimization |
662 } // namespace webrtc | 663 } // namespace webrtc |
OLD | NEW |