| OLD | NEW |
| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 const size_t delay_samples = | 346 const size_t delay_samples = |
| 347 packet_buffer_->NumSamplesInBuffer(decoder_database_.get(), | 347 packet_buffer_->NumSamplesInBuffer(decoder_database_.get(), |
| 348 decoder_frame_length_) + | 348 decoder_frame_length_) + |
| 349 sync_buffer_->FutureLength(); | 349 sync_buffer_->FutureLength(); |
| 350 // The division below will truncate. | 350 // The division below will truncate. |
| 351 const int delay_ms = | 351 const int delay_ms = |
| 352 static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000); | 352 static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000); |
| 353 return delay_ms; | 353 return delay_ms; |
| 354 } | 354 } |
| 355 | 355 |
| 356 int NetEqImpl::FilteredCurrentDelayMs() const { |
| 357 rtc::CritScope lock(&crit_sect_); |
| 358 // Calculate the filtered packet buffer level in samples. The value from |
| 359 // |buffer_level_filter_| is in number of packets, represented in Q8. |
| 360 const size_t packet_buffer_samples = |
| 361 (buffer_level_filter_->filtered_current_level() * |
| 362 decoder_frame_length_) >> |
| 363 8; |
| 364 // Sum up the filtered packet buffer level with the future length of the sync |
| 365 // buffer, and divide the sum by the sample rate. |
| 366 const size_t delay_samples = |
| 367 packet_buffer_samples + sync_buffer_->FutureLength(); |
| 368 // The division below will truncate. The return value is in ms. |
| 369 return static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000); |
| 370 } |
| 371 |
| 356 // Deprecated. | 372 // Deprecated. |
| 357 // TODO(henrik.lundin) Delete. | 373 // TODO(henrik.lundin) Delete. |
| 358 void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) { | 374 void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) { |
| 359 rtc::CritScope lock(&crit_sect_); | 375 rtc::CritScope lock(&crit_sect_); |
| 360 if (mode != playout_mode_) { | 376 if (mode != playout_mode_) { |
| 361 playout_mode_ = mode; | 377 playout_mode_ = mode; |
| 362 CreateDecisionLogic(); | 378 CreateDecisionLogic(); |
| 363 } | 379 } |
| 364 } | 380 } |
| 365 | 381 |
| (...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 } | 2139 } |
| 2124 } | 2140 } |
| 2125 | 2141 |
| 2126 void NetEqImpl::CreateDecisionLogic() { | 2142 void NetEqImpl::CreateDecisionLogic() { |
| 2127 decision_logic_.reset(DecisionLogic::Create( | 2143 decision_logic_.reset(DecisionLogic::Create( |
| 2128 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), | 2144 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), |
| 2129 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), | 2145 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), |
| 2130 tick_timer_.get())); | 2146 tick_timer_.get())); |
| 2131 } | 2147 } |
| 2132 } // namespace webrtc | 2148 } // namespace webrtc |
| OLD | NEW |