Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: webrtc/modules/video_coding/main/source/media_optimization.cc

Issue 1180623005: Update encoder settings periodically, not only on new bandwidth estimate (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698