Revert "Change buffer level filter to store current level in number of samples."

This reverts commit 87977dd06e702ed517f26235c12e37bd927527c7.

Reason for revert: Breaks downstream project

Original change's description:
> Change buffer level filter to store current level in number of samples.
> 
> The buffer level should not be converted back and forth between samples and packets in case of variable packet lengths.
> 
> Bug: webrtc:10736
> Change-Id: Ia08dcfac3d8104dc79fbad0704a5f6f12a050a01
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/142178
> Reviewed-by: Minyue Li <minyue@webrtc.org>
> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28368}

TBR=henrik.lundin@webrtc.org,minyue@webrtc.org,jakobi@webrtc.org

Change-Id: I3900c9f6071fce51d13fb3b7c886157304d7a5c3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10736
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143786
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28369}
This commit is contained in:
Jakob Ivarsson
2019-06-25 12:32:48 +00:00
committed by Commit Bot
parent 87977dd06e
commit d3fc161c16
9 changed files with 213 additions and 136 deletions

View File

@ -310,12 +310,18 @@ int NetEqImpl::TargetDelayMs() const {
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.
const int delay_samples = buffer_level_filter_->filtered_current_level() +
sync_buffer_->FutureLength();
// 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 delay_samples / rtc::CheckedDivExact(fs_hz_, 1000);
return static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000);
}
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {