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

Side by Side Diff: webrtc/base/bandwidthsmoother.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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
« no previous file with comments | « webrtc/base/bandwidthsmoother.h ('k') | webrtc/base/basictypes_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "webrtc/base/bandwidthsmoother.h" 11 #include "webrtc/base/bandwidthsmoother.h"
12 12
13 #include <limits.h> 13 #include <limits.h>
14 #include <algorithm> 14 #include <algorithm>
15 15
16 namespace rtc { 16 namespace rtc {
17 17
18 BandwidthSmoother::BandwidthSmoother(int initial_bandwidth_guess, 18 BandwidthSmoother::BandwidthSmoother(int initial_bandwidth_guess,
19 uint32 time_between_increase, 19 uint32_t time_between_increase,
20 double percent_increase, 20 double percent_increase,
21 size_t samples_count_to_average, 21 size_t samples_count_to_average,
22 double min_sample_count_percent) 22 double min_sample_count_percent)
23 : time_between_increase_(time_between_increase), 23 : time_between_increase_(time_between_increase),
24 percent_increase_(std::max(1.0, percent_increase)), 24 percent_increase_(std::max(1.0, percent_increase)),
25 time_at_last_change_(0), 25 time_at_last_change_(0),
26 bandwidth_estimation_(initial_bandwidth_guess), 26 bandwidth_estimation_(initial_bandwidth_guess),
27 accumulator_(samples_count_to_average), 27 accumulator_(samples_count_to_average),
28 min_sample_count_percent_( 28 min_sample_count_percent_(
29 std::min(1.0, std::max(0.0, min_sample_count_percent))) { 29 std::min(1.0, std::max(0.0, min_sample_count_percent))) {
30 } 30 }
31 31
32 BandwidthSmoother::~BandwidthSmoother() = default; 32 BandwidthSmoother::~BandwidthSmoother() = default;
33 33
34 // Samples a new bandwidth measurement 34 // Samples a new bandwidth measurement
35 // returns true if the bandwidth estimation changed 35 // returns true if the bandwidth estimation changed
36 bool BandwidthSmoother::Sample(uint32 sample_time, int bandwidth) { 36 bool BandwidthSmoother::Sample(uint32_t sample_time, int bandwidth) {
37 if (bandwidth < 0) { 37 if (bandwidth < 0) {
38 return false; 38 return false;
39 } 39 }
40 40
41 accumulator_.AddSample(bandwidth); 41 accumulator_.AddSample(bandwidth);
42 42
43 if (accumulator_.count() < static_cast<size_t>( 43 if (accumulator_.count() < static_cast<size_t>(
44 accumulator_.max_count() * min_sample_count_percent_)) { 44 accumulator_.max_count() * min_sample_count_percent_)) {
45 // We have not collected enough samples yet. 45 // We have not collected enough samples yet.
46 return false; 46 return false;
(...skipping 30 matching lines...) Expand all
77 } else { 77 } else {
78 bandwidth_estimation_ = increase_threshold; 78 bandwidth_estimation_ = increase_threshold;
79 } 79 }
80 } 80 }
81 // Else don't make a change. 81 // Else don't make a change.
82 82
83 return old_bandwidth_estimation != bandwidth_estimation_; 83 return old_bandwidth_estimation != bandwidth_estimation_;
84 } 84 }
85 85
86 } // namespace rtc 86 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/bandwidthsmoother.h ('k') | webrtc/base/basictypes_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698