Change PlayoutLatency setLatency zero-threshold value.
This is needed to match behaviour described in this spec: https://github.com/henbos/webrtc-timing/pull/2 Bug: webrtc:10287 Change-Id: Idce9af2ec63705dfbfb500b7dbbf755ed3eab571 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131336 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Ruslan Burakov <kuddai@google.com> Cr-Commit-Position: refs/heads/master@{#27480}
This commit is contained in:

committed by
Commit Bot

parent
8b9f51132a
commit
1e2d436cbf
@ -212,6 +212,7 @@ rtc_static_library("peerconnection") {
|
||||
"../rtc_base",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base:safe_minmax",
|
||||
"../rtc_base/system:rtc_export",
|
||||
"../rtc_base/third_party/base64",
|
||||
"../rtc_base/third_party/sigslot",
|
||||
|
@ -14,13 +14,13 @@
|
||||
#include "rtc_base/location.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/numerics/safe_minmax.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
|
||||
namespace {
|
||||
constexpr int kDefaultLatency = 0;
|
||||
constexpr int kMaximumDelayMs = 10000;
|
||||
constexpr int kRoundToZeroThresholdMs = 10;
|
||||
} // namespace
|
||||
|
||||
namespace webrtc {
|
||||
@ -53,16 +53,7 @@ void PlayoutLatency::SetLatency(double latency) {
|
||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||
|
||||
int delay_ms = rtc::dchecked_cast<int>(latency * 1000);
|
||||
// In JitterBuffer 0 delay has special meaning of being unconstrained value
|
||||
// that is why we round delay to 0 if it is small enough during conversion
|
||||
// from latency.
|
||||
if (delay_ms <= kRoundToZeroThresholdMs) {
|
||||
delay_ms = 0;
|
||||
}
|
||||
|
||||
if (delay_ms > kMaximumDelayMs) {
|
||||
delay_ms = kMaximumDelayMs;
|
||||
}
|
||||
delay_ms = rtc::SafeClamp(delay_ms, 0, kMaximumDelayMs);
|
||||
|
||||
cached_latency_ = latency;
|
||||
if (media_channel_ && ssrc_) {
|
||||
|
@ -90,16 +90,6 @@ TEST_F(PlayoutLatencyTest, Caching) {
|
||||
EXPECT_DOUBLE_EQ(4.0, latency_->GetLatency());
|
||||
}
|
||||
|
||||
TEST_F(PlayoutLatencyTest, Rounding) {
|
||||
latency_->OnStart(&delayable_, kSsrc);
|
||||
// In Jitter Buffer (Audio or Video) delay 0 has a special meaning of
|
||||
// unconstrained variable, that is why here if latency is small enough we
|
||||
// round it to 0 delay.
|
||||
EXPECT_CALL(delayable_, SetBaseMinimumPlayoutDelayMs(kSsrc, 0))
|
||||
.WillOnce(Return(true));
|
||||
latency_->SetLatency(0.005);
|
||||
}
|
||||
|
||||
TEST_F(PlayoutLatencyTest, Clamping) {
|
||||
latency_->OnStart(&delayable_, kSsrc);
|
||||
|
||||
@ -109,6 +99,11 @@ TEST_F(PlayoutLatencyTest, Clamping) {
|
||||
.WillOnce(Return(true));
|
||||
latency_->SetLatency(10.5);
|
||||
|
||||
// Boundary value in seconds to milliseconds conversion.
|
||||
EXPECT_CALL(delayable_, SetBaseMinimumPlayoutDelayMs(kSsrc, 0))
|
||||
.WillOnce(Return(true));
|
||||
latency_->SetLatency(0.0009);
|
||||
|
||||
EXPECT_CALL(delayable_, SetBaseMinimumPlayoutDelayMs(kSsrc, 0))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
|
Reference in New Issue
Block a user