2019-02-27 15:32:48 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright 2019 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-04-18 17:49:49 +02:00
|
|
|
#include "pc/jitter_buffer_delay.h"
|
2019-02-27 15:32:48 +01:00
|
|
|
|
2021-02-10 14:31:24 +01:00
|
|
|
#include "api/sequence_checker.h"
|
2019-02-27 15:32:48 +01:00
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/numerics/safe_conversions.h"
|
2019-04-08 11:38:46 +02:00
|
|
|
#include "rtc_base/numerics/safe_minmax.h"
|
2019-02-27 15:32:48 +01:00
|
|
|
|
|
|
|
|
namespace {
|
2019-04-18 17:49:49 +02:00
|
|
|
constexpr int kDefaultDelay = 0;
|
2019-04-03 19:55:33 +02:00
|
|
|
constexpr int kMaximumDelayMs = 10000;
|
2019-02-27 15:32:48 +01:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
void JitterBufferDelay::Set(std::optional<double> delay_seconds) {
|
2021-05-17 14:50:10 +02:00
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2019-04-18 17:49:49 +02:00
|
|
|
cached_delay_seconds_ = delay_seconds;
|
2021-05-17 14:50:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int JitterBufferDelay::GetMs() const {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
2025-02-20 09:42:51 +00:00
|
|
|
return SafeClamp(rtc::saturated_cast<int>(
|
|
|
|
|
cached_delay_seconds_.value_or(kDefaultDelay) * 1000),
|
|
|
|
|
0, kMaximumDelayMs);
|
2019-02-27 15:32:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|