OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // This should be called after each frame is encoded. The timestamp at which | 52 // This should be called after each frame is encoded. The timestamp at which |
53 // it is called is used to estimate the output bitrate of the encoder. | 53 // it is called is used to estimate the output bitrate of the encoder. |
54 // Should be called from only one thread. | 54 // Should be called from only one thread. |
55 void Update(size_t frame_size); | 55 void Update(size_t frame_size); |
56 | 56 |
57 private: | 57 private: |
58 // Returns true if the bitrate is within kBitrateTolerancePct of bitrate_bps. | 58 // Returns true if the bitrate is within kBitrateTolerancePct of bitrate_bps. |
59 bool IsWithinTolerance(uint32_t bitrate_bps, uint32_t target_bitrate_bps); | 59 bool IsWithinTolerance(uint32_t bitrate_bps, uint32_t target_bitrate_bps); |
60 | 60 |
61 // Returns smallest possible adjusted value. | 61 // Returns smallest possible adjusted value. |
62 uint32_t GetMinAdjustedBitrateBps() const EXCLUSIVE_LOCKS_REQUIRED(crit_); | 62 uint32_t GetMinAdjustedBitrateBps() const RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_); |
63 // Returns largest possible adjusted value. | 63 // Returns largest possible adjusted value. |
64 uint32_t GetMaxAdjustedBitrateBps() const EXCLUSIVE_LOCKS_REQUIRED(crit_); | 64 uint32_t GetMaxAdjustedBitrateBps() const RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_); |
65 | 65 |
66 void Reset(); | 66 void Reset(); |
67 void UpdateBitrate(uint32_t current_time_ms) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 67 void UpdateBitrate(uint32_t current_time_ms) |
| 68 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_); |
68 | 69 |
69 rtc::CriticalSection crit_; | 70 rtc::CriticalSection crit_; |
70 Clock* const clock_; | 71 Clock* const clock_; |
71 const float min_adjusted_bitrate_pct_; | 72 const float min_adjusted_bitrate_pct_; |
72 const float max_adjusted_bitrate_pct_; | 73 const float max_adjusted_bitrate_pct_; |
73 // The bitrate we want. | 74 // The bitrate we want. |
74 volatile uint32_t target_bitrate_bps_ GUARDED_BY(crit_); | 75 volatile uint32_t target_bitrate_bps_ RTC_GUARDED_BY(crit_); |
75 // The bitrate we use to get what we want. | 76 // The bitrate we use to get what we want. |
76 volatile uint32_t adjusted_bitrate_bps_ GUARDED_BY(crit_); | 77 volatile uint32_t adjusted_bitrate_bps_ RTC_GUARDED_BY(crit_); |
77 // The target bitrate that the adjusted bitrate was computed from. | 78 // The target bitrate that the adjusted bitrate was computed from. |
78 volatile uint32_t last_adjusted_target_bitrate_bps_ GUARDED_BY(crit_); | 79 volatile uint32_t last_adjusted_target_bitrate_bps_ RTC_GUARDED_BY(crit_); |
79 // Used to estimate bitrate. | 80 // Used to estimate bitrate. |
80 RateStatistics bitrate_tracker_ GUARDED_BY(crit_); | 81 RateStatistics bitrate_tracker_ RTC_GUARDED_BY(crit_); |
81 // The last time we tried to adjust the bitrate. | 82 // The last time we tried to adjust the bitrate. |
82 uint32_t last_bitrate_update_time_ms_ GUARDED_BY(crit_); | 83 uint32_t last_bitrate_update_time_ms_ RTC_GUARDED_BY(crit_); |
83 // The number of frames since the last time we tried to adjust the bitrate. | 84 // The number of frames since the last time we tried to adjust the bitrate. |
84 uint32_t frames_since_last_update_ GUARDED_BY(crit_); | 85 uint32_t frames_since_last_update_ RTC_GUARDED_BY(crit_); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace webrtc | 88 } // namespace webrtc |
88 | 89 |
89 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_BITRATE_ADJUSTER_H_ | 90 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_BITRATE_ADJUSTER_H_ |
OLD | NEW |