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

Side by Side Diff: webrtc/modules/audio_coding/neteq/delay_manager.h

Issue 1228843002: Update audio code to use size_t more correctly, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments Created 5 years, 4 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
OLDNEW
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 14 matching lines...) Expand all
25 class DelayPeakDetector; 25 class DelayPeakDetector;
26 26
27 class DelayManager { 27 class DelayManager {
28 public: 28 public:
29 typedef std::vector<int> IATVector; 29 typedef std::vector<int> IATVector;
30 30
31 // Create a DelayManager object. Notify the delay manager that the packet 31 // Create a DelayManager object. Notify the delay manager that the packet
32 // buffer can hold no more than |max_packets_in_buffer| packets (i.e., this 32 // buffer can hold no more than |max_packets_in_buffer| packets (i.e., this
33 // is the number of packet slots in the buffer). Supply a PeakDetector 33 // is the number of packet slots in the buffer). Supply a PeakDetector
34 // object to the DelayManager. 34 // object to the DelayManager.
35 DelayManager(int max_packets_in_buffer, DelayPeakDetector* peak_detector); 35 DelayManager(size_t max_packets_in_buffer, DelayPeakDetector* peak_detector);
36 36
37 virtual ~DelayManager(); 37 virtual ~DelayManager();
38 38
39 // Read the inter-arrival time histogram. Mainly for testing purposes. 39 // Read the inter-arrival time histogram. Mainly for testing purposes.
40 virtual const IATVector& iat_vector() const; 40 virtual const IATVector& iat_vector() const;
41 41
42 // Updates the delay manager with a new incoming packet, with 42 // Updates the delay manager with a new incoming packet, with
43 // |sequence_number| and |timestamp| from the RTP header. This updates the 43 // |sequence_number| and |timestamp| from the RTP header. This updates the
44 // inter-arrival time histogram and other statistics, as well as the 44 // inter-arrival time histogram and other statistics, as well as the
45 // associated DelayPeakDetector. A new target buffer level is calculated. 45 // associated DelayPeakDetector. A new target buffer level is calculated.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // equal to |iat_packets| (in integer packets) is increased slightly, while 125 // equal to |iat_packets| (in integer packets) is increased slightly, while
126 // all other entries are decreased. This method is called by Update(). 126 // all other entries are decreased. This method is called by Update().
127 void UpdateHistogram(size_t iat_packets); 127 void UpdateHistogram(size_t iat_packets);
128 128
129 // Makes sure that |target_level_| is not too large, taking 129 // Makes sure that |target_level_| is not too large, taking
130 // |max_packets_in_buffer_| and |extra_delay_ms_| into account. This method is 130 // |max_packets_in_buffer_| and |extra_delay_ms_| into account. This method is
131 // called by Update(). 131 // called by Update().
132 void LimitTargetLevel(); 132 void LimitTargetLevel();
133 133
134 bool first_packet_received_; 134 bool first_packet_received_;
135 const int max_packets_in_buffer_; // Capacity of the packet buffer. 135 const size_t max_packets_in_buffer_; // Capacity of the packet buffer.
136 IATVector iat_vector_; // Histogram of inter-arrival times. 136 IATVector iat_vector_; // Histogram of inter-arrival times.
137 int iat_factor_; // Forgetting factor for updating the IAT histogram (Q15). 137 int iat_factor_; // Forgetting factor for updating the IAT histogram (Q15).
138 int packet_iat_count_ms_; // Milliseconds elapsed since last packet. 138 int packet_iat_count_ms_; // Milliseconds elapsed since last packet.
139 int base_target_level_; // Currently preferred buffer level before peak 139 int base_target_level_; // Currently preferred buffer level before peak
140 // detection and streaming mode (Q0). 140 // detection and streaming mode (Q0).
141 // TODO(turajs) change the comment according to the implementation of 141 // TODO(turajs) change the comment according to the implementation of
142 // minimum-delay. 142 // minimum-delay.
143 int target_level_; // Currently preferred buffer level in (fractions) 143 int target_level_; // Currently preferred buffer level in (fractions)
144 // of packets (Q8), before adding any extra delay. 144 // of packets (Q8), before adding any extra delay.
145 int packet_len_ms_; // Length of audio in each incoming packet [ms]. 145 int packet_len_ms_; // Length of audio in each incoming packet [ms].
146 bool streaming_mode_; 146 bool streaming_mode_;
147 uint16_t last_seq_no_; // Sequence number for last received packet. 147 uint16_t last_seq_no_; // Sequence number for last received packet.
148 uint32_t last_timestamp_; // Timestamp for the last received packet. 148 uint32_t last_timestamp_; // Timestamp for the last received packet.
149 int minimum_delay_ms_; // Externally set minimum delay. 149 int minimum_delay_ms_; // Externally set minimum delay.
150 int least_required_delay_ms_; // Smallest preferred buffer level (same unit 150 int least_required_delay_ms_; // Smallest preferred buffer level (same unit
151 // as |target_level_|), before applying 151 // as |target_level_|), before applying
152 // |minimum_delay_ms_| and/or |maximum_delay_ms_|. 152 // |minimum_delay_ms_| and/or |maximum_delay_ms_|.
153 int maximum_delay_ms_; // Externally set maximum allowed delay. 153 int maximum_delay_ms_; // Externally set maximum allowed delay.
154 int iat_cumulative_sum_; // Cumulative sum of delta inter-arrival times. 154 int iat_cumulative_sum_; // Cumulative sum of delta inter-arrival times.
155 int max_iat_cumulative_sum_; // Max of |iat_cumulative_sum_|. 155 int max_iat_cumulative_sum_; // Max of |iat_cumulative_sum_|.
156 int max_timer_ms_; // Time elapsed since maximum was observed. 156 int max_timer_ms_; // Time elapsed since maximum was observed.
157 DelayPeakDetector& peak_detector_; 157 DelayPeakDetector& peak_detector_;
158 int last_pack_cng_or_dtmf_; 158 int last_pack_cng_or_dtmf_;
159 159
160 DISALLOW_COPY_AND_ASSIGN(DelayManager); 160 DISALLOW_COPY_AND_ASSIGN(DelayManager);
161 }; 161 };
162 162
163 } // namespace webrtc 163 } // namespace webrtc
164 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DELAY_MANAGER_H_ 164 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DELAY_MANAGER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/decision_logic_normal.cc ('k') | webrtc/modules/audio_coding/neteq/delay_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698