OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 134 matching lines...) Loading... |
145 void DecisionLogic::ExpandDecision(Operations operation) { | 145 void DecisionLogic::ExpandDecision(Operations operation) { |
146 if (operation == kExpand) { | 146 if (operation == kExpand) { |
147 num_consecutive_expands_++; | 147 num_consecutive_expands_++; |
148 } else { | 148 } else { |
149 num_consecutive_expands_ = 0; | 149 num_consecutive_expands_ = 0; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 void DecisionLogic::FilterBufferLevel(size_t buffer_size_samples, | 153 void DecisionLogic::FilterBufferLevel(size_t buffer_size_samples, |
154 Modes prev_mode) { | 154 Modes prev_mode) { |
155 const int elapsed_time_ms = | |
156 static_cast<int>(output_size_samples_ / (8 * fs_mult_)); | |
157 delay_manager_->UpdateCounters(elapsed_time_ms); | |
158 | |
159 // Do not update buffer history if currently playing CNG since it will bias | 155 // Do not update buffer history if currently playing CNG since it will bias |
160 // the filtered buffer level. | 156 // the filtered buffer level. |
161 if ((prev_mode != kModeRfc3389Cng) && (prev_mode != kModeCodecInternalCng)) { | 157 if ((prev_mode != kModeRfc3389Cng) && (prev_mode != kModeCodecInternalCng)) { |
162 buffer_level_filter_->SetTargetBufferLevel( | 158 buffer_level_filter_->SetTargetBufferLevel( |
163 delay_manager_->base_target_level()); | 159 delay_manager_->base_target_level()); |
164 | 160 |
165 size_t buffer_size_packets = 0; | 161 size_t buffer_size_packets = 0; |
166 if (packet_length_samples_ > 0) { | 162 if (packet_length_samples_ > 0) { |
167 // Calculate size in packets. | 163 // Calculate size in packets. |
168 buffer_size_packets = buffer_size_samples / packet_length_samples_; | 164 buffer_size_packets = buffer_size_samples / packet_length_samples_; |
169 } | 165 } |
170 int sample_memory_local = 0; | 166 int sample_memory_local = 0; |
171 if (prev_time_scale_) { | 167 if (prev_time_scale_) { |
172 sample_memory_local = sample_memory_; | 168 sample_memory_local = sample_memory_; |
173 timescale_hold_off_ = kMinTimescaleInterval; | 169 timescale_hold_off_ = kMinTimescaleInterval; |
174 } | 170 } |
175 buffer_level_filter_->Update(buffer_size_packets, sample_memory_local, | 171 buffer_level_filter_->Update(buffer_size_packets, sample_memory_local, |
176 packet_length_samples_); | 172 packet_length_samples_); |
177 prev_time_scale_ = false; | 173 prev_time_scale_ = false; |
178 } | 174 } |
179 | 175 |
180 timescale_hold_off_ = std::max(timescale_hold_off_ - 1, 0); | 176 timescale_hold_off_ = std::max(timescale_hold_off_ - 1, 0); |
181 } | 177 } |
182 | 178 |
183 } // namespace webrtc | 179 } // namespace webrtc |
OLD | NEW |