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

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 2287243002: Add NetEq::FilteredCurrentDelayMs() and use it in VoiceEngine (Closed)
Patch Set: Created 4 years, 3 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/modules/audio_coding/neteq/neteq_impl.h ('k') | webrtc/voice_engine/channel.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 (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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 const size_t delay_samples = 351 const size_t delay_samples =
352 packet_buffer_->NumSamplesInBuffer(decoder_database_.get(), 352 packet_buffer_->NumSamplesInBuffer(decoder_database_.get(),
353 decoder_frame_length_) + 353 decoder_frame_length_) +
354 sync_buffer_->FutureLength(); 354 sync_buffer_->FutureLength();
355 // The division below will truncate. 355 // The division below will truncate.
356 const int delay_ms = 356 const int delay_ms =
357 static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000); 357 static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000);
358 return delay_ms; 358 return delay_ms;
359 } 359 }
360 360
361 int NetEqImpl::FilteredCurrentDelayMs() const {
362 rtc::CritScope lock(&crit_sect_);
363 // Calculate the filtered packet buffer level in samples. The value from
364 // |buffer_level_filter_| is in number of packets, represented in Q8.
365 const size_t packet_buffer_samples =
366 (buffer_level_filter_->filtered_current_level() *
367 decoder_frame_length_) >>
368 8;
369 // Sum up the filtered packet buffer level with the future length of the sync
370 // buffer, and divide the sum by the sample rate.
371 const size_t delay_samples =
372 packet_buffer_samples + sync_buffer_->FutureLength();
373 // The division below will truncate. The return value is in ms.
374 return static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000);
375 }
376
361 // Deprecated. 377 // Deprecated.
362 // TODO(henrik.lundin) Delete. 378 // TODO(henrik.lundin) Delete.
363 void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) { 379 void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
364 rtc::CritScope lock(&crit_sect_); 380 rtc::CritScope lock(&crit_sect_);
365 if (mode != playout_mode_) { 381 if (mode != playout_mode_) {
366 playout_mode_ = mode; 382 playout_mode_ = mode;
367 CreateDecisionLogic(); 383 CreateDecisionLogic();
368 } 384 }
369 } 385 }
370 386
(...skipping 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 } 2182 }
2167 } 2183 }
2168 2184
2169 void NetEqImpl::CreateDecisionLogic() { 2185 void NetEqImpl::CreateDecisionLogic() {
2170 decision_logic_.reset(DecisionLogic::Create( 2186 decision_logic_.reset(DecisionLogic::Create(
2171 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), 2187 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(),
2172 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), 2188 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(),
2173 tick_timer_.get())); 2189 tick_timer_.get()));
2174 } 2190 }
2175 } // namespace webrtc 2191 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.h ('k') | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698