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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 video_target_bitrate_ = target_bitrate; | 111 video_target_bitrate_ = target_bitrate; |
112 | 112 |
113 // Cap target video bitrate to codec maximum. | 113 // Cap target video bitrate to codec maximum. |
114 if (max_bit_rate_ > 0 && video_target_bitrate_ > max_bit_rate_) { | 114 if (max_bit_rate_ > 0 && video_target_bitrate_ > max_bit_rate_) { |
115 video_target_bitrate_ = max_bit_rate_; | 115 video_target_bitrate_ = max_bit_rate_; |
116 } | 116 } |
117 | 117 |
118 // Update encoding rates following protection settings. | 118 // Update encoding rates following protection settings. |
119 float target_video_bitrate_kbps = | 119 float target_video_bitrate_kbps = |
120 static_cast<float>(video_target_bitrate_) / 1000.0f; | 120 static_cast<float>(video_target_bitrate_) / 1000.0f; |
121 float framerate = incoming_frame_rate_; | 121 frame_dropper_->SetRates(target_video_bitrate_kbps, incoming_frame_rate_); |
122 if (framerate == 0.0) { | |
123 // No framerate estimate available, use configured max framerate instead. | |
124 framerate = user_frame_rate_; | |
125 } | |
126 | |
127 frame_dropper_->SetRates(target_video_bitrate_kbps, framerate); | |
128 | 122 |
129 return video_target_bitrate_; | 123 return video_target_bitrate_; |
130 } | 124 } |
131 | 125 |
132 uint32_t MediaOptimization::InputFrameRate() { | 126 uint32_t MediaOptimization::InputFrameRate() { |
133 rtc::CritScope lock(&crit_sect_); | 127 rtc::CritScope lock(&crit_sect_); |
134 return InputFrameRateInternal(); | 128 return InputFrameRateInternal(); |
135 } | 129 } |
136 | 130 |
137 uint32_t MediaOptimization::InputFrameRateInternal() { | 131 uint32_t MediaOptimization::InputFrameRateInternal() { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 const int64_t diff = | 272 const int64_t diff = |
279 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; | 273 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; |
280 incoming_frame_rate_ = 0.0; // No frame rate estimate available. | 274 incoming_frame_rate_ = 0.0; // No frame rate estimate available. |
281 if (diff > 0) { | 275 if (diff > 0) { |
282 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); | 276 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); |
283 } | 277 } |
284 } | 278 } |
285 } | 279 } |
286 } // namespace media_optimization | 280 } // namespace media_optimization |
287 } // namespace webrtc | 281 } // namespace webrtc |
OLD | NEW |