Allow to change base minimum delay on NetEq.
This is first step to allow to set latency from client code in Chromium. Existing minimum latency hasn't been used because it can clash with video syncronization code. Bug: webrtc:10287 Change-Id: Ia38906506069a1abfa01698dc62df283fc15cfbc Reviewed-on: https://webrtc-review.googlesource.com/c/121423 Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Commit-Queue: Ruslan Burakov <kuddai@google.com> Cr-Commit-Position: refs/heads/master@{#26536}
This commit is contained in:
committed by
Commit Bot
parent
d8b980464c
commit
edbea46295
@ -482,16 +482,19 @@ DelayManager::IATVector DelayManager::ScaleHistogram(const IATVector& histogram,
|
||||
return new_histogram;
|
||||
}
|
||||
|
||||
bool DelayManager::IsValidMinimumDelay(int delay_ms) {
|
||||
const int q75 =
|
||||
rtc::dchecked_cast<int>(3 * max_packets_in_buffer_ * packet_len_ms_ / 4);
|
||||
return delay_ms >= 0 &&
|
||||
(maximum_delay_ms_ <= 0 || delay_ms <= maximum_delay_ms_) &&
|
||||
(packet_len_ms_ <= 0 || delay_ms <= q75);
|
||||
}
|
||||
|
||||
bool DelayManager::SetMinimumDelay(int delay_ms) {
|
||||
// Minimum delay shouldn't be more than maximum delay, if any maximum is set.
|
||||
// Also, if possible check |delay| to less than 75% of
|
||||
// |max_packets_in_buffer_|.
|
||||
if ((maximum_delay_ms_ > 0 && delay_ms > maximum_delay_ms_) ||
|
||||
(packet_len_ms_ > 0 &&
|
||||
delay_ms >
|
||||
static_cast<int>(3 * max_packets_in_buffer_ * packet_len_ms_ / 4))) {
|
||||
if (!IsValidMinimumDelay(delay_ms)) {
|
||||
return false;
|
||||
}
|
||||
// Ensure that minimum_delay_ms is no bigger than base_min_target_delay_ms_
|
||||
minimum_delay_ms_ = std::max(delay_ms, base_min_target_delay_ms_);
|
||||
return true;
|
||||
}
|
||||
@ -509,6 +512,21 @@ bool DelayManager::SetMaximumDelay(int delay_ms) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DelayManager::SetBaseMinimumDelay(int delay_ms) {
|
||||
if (!IsValidMinimumDelay(delay_ms)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
base_min_target_delay_ms_ = delay_ms;
|
||||
// Ensure that minimum_delay_ms is no bigger than base_min_target_delay_ms_
|
||||
minimum_delay_ms_ = std::max(delay_ms, base_min_target_delay_ms_);
|
||||
return true;
|
||||
}
|
||||
|
||||
int DelayManager::GetBaseMinimumDelay() const {
|
||||
return base_min_target_delay_ms_;
|
||||
}
|
||||
|
||||
int DelayManager::base_target_level() const {
|
||||
return base_target_level_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user