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 |
11 #include "webrtc/modules/video_coding/media_optimization.h" | 11 #include "webrtc/modules/video_coding/media_optimization.h" |
12 | 12 |
13 #include <limits> | |
14 | |
13 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
14 #include "webrtc/modules/video_coding/utility/frame_dropper.h" | 16 #include "webrtc/modules/video_coding/utility/frame_dropper.h" |
15 #include "webrtc/system_wrappers/include/clock.h" | 17 #include "webrtc/system_wrappers/include/clock.h" |
16 | 18 |
17 namespace webrtc { | 19 namespace webrtc { |
18 namespace media_optimization { | 20 namespace media_optimization { |
19 | 21 |
20 struct MediaOptimization::EncodedFrameSample { | 22 struct MediaOptimization::EncodedFrameSample { |
21 EncodedFrameSample(size_t size_bytes, | 23 EncodedFrameSample(size_t size_bytes, |
22 uint32_t timestamp, | 24 uint32_t timestamp, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 return video_target_bitrate_; | 124 return video_target_bitrate_; |
123 } | 125 } |
124 | 126 |
125 uint32_t MediaOptimization::InputFrameRate() { | 127 uint32_t MediaOptimization::InputFrameRate() { |
126 CriticalSectionScoped lock(crit_sect_.get()); | 128 CriticalSectionScoped lock(crit_sect_.get()); |
127 return InputFrameRateInternal(); | 129 return InputFrameRateInternal(); |
128 } | 130 } |
129 | 131 |
130 uint32_t MediaOptimization::InputFrameRateInternal() { | 132 uint32_t MediaOptimization::InputFrameRateInternal() { |
131 ProcessIncomingFrameRate(clock_->TimeInMilliseconds()); | 133 ProcessIncomingFrameRate(clock_->TimeInMilliseconds()); |
132 return uint32_t(incoming_frame_rate_ + 0.5f); | 134 uint32_t framerate = static_cast<uint32_t>(std::min<float>( |
135 std::numeric_limits<uint32_t>::max(), incoming_frame_rate_ + 0.5f)); | |
136 return framerate; | |
tommi
2017/03/10 12:55:45
should we have a check here? At least RTC_DCHECK(
stefan-webrtc
2017/03/10 13:06:55
framerate == 0 is handled outside this class, whic
| |
133 } | 137 } |
134 | 138 |
135 uint32_t MediaOptimization::SentFrameRate() { | 139 uint32_t MediaOptimization::SentFrameRate() { |
136 CriticalSectionScoped lock(crit_sect_.get()); | 140 CriticalSectionScoped lock(crit_sect_.get()); |
137 return SentFrameRateInternal(); | 141 return SentFrameRateInternal(); |
138 } | 142 } |
139 | 143 |
140 uint32_t MediaOptimization::SentFrameRateInternal() { | 144 uint32_t MediaOptimization::SentFrameRateInternal() { |
141 PurgeOldFrameSamples(clock_->TimeInMilliseconds()); | 145 PurgeOldFrameSamples(clock_->TimeInMilliseconds()); |
142 UpdateSentFramerate(); | 146 UpdateSentFramerate(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 const int64_t diff = | 273 const int64_t diff = |
270 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; | 274 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; |
271 incoming_frame_rate_ = 0.0; // No frame rate estimate available. | 275 incoming_frame_rate_ = 0.0; // No frame rate estimate available. |
272 if (diff > 0) { | 276 if (diff > 0) { |
273 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); | 277 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); |
274 } | 278 } |
275 } | 279 } |
276 } | 280 } |
277 } // namespace media_optimization | 281 } // namespace media_optimization |
278 } // namespace webrtc | 282 } // namespace webrtc |
OLD | NEW |