Improve buffer level estimation with DTX and add CNG time stretching.
The functionality is hidden behind field trial for experimentation. Bug: webrtc:10736 Change-Id: I1daf60966717c3ea43bf6ee16d190290ab740ce7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144059 Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Reviewed-by: Minyue Li <minyue@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28474}
This commit is contained in:
committed by
Commit Bot
parent
3d642f8442
commit
46dda83bcb
@ -26,6 +26,7 @@
|
||||
#include "modules/audio_coding/neteq/tick_timer.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
@ -287,14 +288,22 @@ size_t PacketBuffer::NumSamplesInBuffer(size_t last_decoded_length) const {
|
||||
return num_samples;
|
||||
}
|
||||
|
||||
size_t PacketBuffer::GetSpanSamples(size_t last_decoded_length) const {
|
||||
size_t PacketBuffer::GetSpanSamples(size_t last_decoded_length,
|
||||
size_t sample_rate,
|
||||
bool count_dtx_waiting_time) const {
|
||||
if (buffer_.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t span = buffer_.back().timestamp - buffer_.front().timestamp;
|
||||
if (buffer_.back().frame && buffer_.back().frame->Duration() > 0) {
|
||||
span += buffer_.back().frame->Duration();
|
||||
size_t duration = buffer_.back().frame->Duration();
|
||||
if (count_dtx_waiting_time && buffer_.back().frame->IsDtxPacket()) {
|
||||
size_t waiting_time_samples = rtc::dchecked_cast<size_t>(
|
||||
buffer_.back().waiting_time->ElapsedMs() * (sample_rate / 1000));
|
||||
duration = std::max(duration, waiting_time_samples);
|
||||
}
|
||||
span += duration;
|
||||
} else {
|
||||
span += last_decoded_length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user