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

Unified 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, 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/neteq/neteq_impl.cc
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 422252c5ac54c4a7d25aa9745b4a3ed135e3a3c6..b2c1b2cf76fad2c77adbcac7153cc9e294bd8fbd 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -358,6 +358,22 @@ int NetEqImpl::CurrentDelayMs() const {
return delay_ms;
}
+int NetEqImpl::FilteredCurrentDelayMs() const {
+ rtc::CritScope lock(&crit_sect_);
+ // Calculate the filtered packet buffer level in samples. The value from
+ // |buffer_level_filter_| is in number of packets, represented in Q8.
+ const size_t packet_buffer_samples =
+ (buffer_level_filter_->filtered_current_level() *
+ decoder_frame_length_) >>
+ 8;
+ // Sum up the filtered packet buffer level with the future length of the sync
+ // buffer, and divide the sum by the sample rate.
+ const size_t delay_samples =
+ packet_buffer_samples + sync_buffer_->FutureLength();
+ // The division below will truncate. The return value is in ms.
+ return static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000);
+}
+
// Deprecated.
// TODO(henrik.lundin) Delete.
void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
« 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