| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 13 matching lines...) Expand all Loading... |
| 24 // at least as large as the current estimation * percent_increase | 24 // at least as large as the current estimation * percent_increase |
| 25 // for at least time_between_increase time. If a sampled bandwidth | 25 // for at least time_between_increase time. If a sampled bandwidth |
| 26 // is less than our current estimation we immediately decrease our estimation | 26 // is less than our current estimation we immediately decrease our estimation |
| 27 // to that sampled value. | 27 // to that sampled value. |
| 28 // We retain the initial bandwidth guess as our current bandwidth estimation | 28 // We retain the initial bandwidth guess as our current bandwidth estimation |
| 29 // until we have received (min_sample_count_percent * samples_count_to_average) | 29 // until we have received (min_sample_count_percent * samples_count_to_average) |
| 30 // number of samples. Min_sample_count_percent must be in range [0, 1]. | 30 // number of samples. Min_sample_count_percent must be in range [0, 1]. |
| 31 class BandwidthSmoother { | 31 class BandwidthSmoother { |
| 32 public: | 32 public: |
| 33 BandwidthSmoother(int initial_bandwidth_guess, | 33 BandwidthSmoother(int initial_bandwidth_guess, |
| 34 uint32 time_between_increase, | 34 uint32_t time_between_increase, |
| 35 double percent_increase, | 35 double percent_increase, |
| 36 size_t samples_count_to_average, | 36 size_t samples_count_to_average, |
| 37 double min_sample_count_percent); | 37 double min_sample_count_percent); |
| 38 ~BandwidthSmoother(); | 38 ~BandwidthSmoother(); |
| 39 | 39 |
| 40 // Samples a new bandwidth measurement. | 40 // Samples a new bandwidth measurement. |
| 41 // bandwidth is expected to be non-negative. | 41 // bandwidth is expected to be non-negative. |
| 42 // returns true if the bandwidth estimation changed | 42 // returns true if the bandwidth estimation changed |
| 43 bool Sample(uint32 sample_time, int bandwidth); | 43 bool Sample(uint32_t sample_time, int bandwidth); |
| 44 | 44 |
| 45 int get_bandwidth_estimation() const { | 45 int get_bandwidth_estimation() const { |
| 46 return bandwidth_estimation_; | 46 return bandwidth_estimation_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 uint32 time_between_increase_; | 50 uint32_t time_between_increase_; |
| 51 double percent_increase_; | 51 double percent_increase_; |
| 52 uint32 time_at_last_change_; | 52 uint32_t time_at_last_change_; |
| 53 int bandwidth_estimation_; | 53 int bandwidth_estimation_; |
| 54 RollingAccumulator<int> accumulator_; | 54 RollingAccumulator<int> accumulator_; |
| 55 double min_sample_count_percent_; | 55 double min_sample_count_percent_; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 } // namespace rtc | 58 } // namespace rtc |
| 59 | 59 |
| 60 #endif // WEBRTC_BASE_BANDWIDTHSMOOTHER_H_ | 60 #endif // WEBRTC_BASE_BANDWIDTHSMOOTHER_H_ |
| OLD | NEW |