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

Unified Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 2262203002: Add NetEq::FilteredCurrentDelayMs() and use it in VoiceEngine (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
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
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 024c73d23dcaeaabf89087313829a36515534626..9cd73b640963a3f655ec65aba6998d3757b60f77 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -353,6 +353,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) {

Powered by Google App Engine
This is Rietveld 408576698