blob: caf713b045f670992d70f0a4eb3cc053ea0cdebe [file] [log] [blame]
Ruslan Burakov428dcb22019-04-18 15:49:491/*
2 * Copyright 2019 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef PC_JITTER_BUFFER_DELAY_H_
12#define PC_JITTER_BUFFER_DELAY_H_
13
14#include <stdint.h>
15
16#include "absl/types/optional.h"
Tommi4ccdf9322021-05-17 12:50:1017#include "api/sequence_checker.h"
18#include "rtc_base/system/no_unique_address.h"
Harald Alvestrandc24a2182022-02-23 13:44:5919#include "rtc_base/thread_annotations.h"
Ruslan Burakov428dcb22019-04-18 15:49:4920
21namespace webrtc {
22
23// JitterBufferDelay converts delay from seconds to milliseconds for the
24// underlying media channel. It also handles cases when user sets delay before
Tommi4ccdf9322021-05-17 12:50:1025// the start of media_channel by caching its request.
26class JitterBufferDelay {
Ruslan Burakov428dcb22019-04-18 15:49:4927 public:
Tommic8482682023-03-23 21:20:3928 JitterBufferDelay() = default;
Ruslan Burakov428dcb22019-04-18 15:49:4929
Tommi4ccdf9322021-05-17 12:50:1030 void Set(absl::optional<double> delay_seconds);
31 int GetMs() const;
Ruslan Burakov428dcb22019-04-18 15:49:4932
33 private:
Tommic8482682023-03-23 21:20:3934 RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_{
35 SequenceChecker::kDetached};
Tommi4ccdf9322021-05-17 12:50:1036 absl::optional<double> cached_delay_seconds_
37 RTC_GUARDED_BY(&worker_thread_checker_);
Ruslan Burakov428dcb22019-04-18 15:49:4938};
39
40} // namespace webrtc
41
42#endif // PC_JITTER_BUFFER_DELAY_H_