blob: dc10e3d2ba27617af4e8b5a5747bae9bf71c375a [file] [log] [blame]
Ruslan Burakov428dcb22019-04-18 17:49:49 +02001/*
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"
Tommi4ccdf932021-05-17 14:50:10 +020017#include "api/sequence_checker.h"
18#include "rtc_base/system/no_unique_address.h"
Ruslan Burakov428dcb22019-04-18 17:49:49 +020019
20namespace webrtc {
21
22// JitterBufferDelay converts delay from seconds to milliseconds for the
23// underlying media channel. It also handles cases when user sets delay before
Tommi4ccdf932021-05-17 14:50:10 +020024// the start of media_channel by caching its request.
25class JitterBufferDelay {
Ruslan Burakov428dcb22019-04-18 17:49:49 +020026 public:
Tommi4ccdf932021-05-17 14:50:10 +020027 JitterBufferDelay();
Ruslan Burakov428dcb22019-04-18 17:49:49 +020028
Tommi4ccdf932021-05-17 14:50:10 +020029 void Set(absl::optional<double> delay_seconds);
30 int GetMs() const;
Ruslan Burakov428dcb22019-04-18 17:49:49 +020031
32 private:
Tommi4ccdf932021-05-17 14:50:10 +020033 RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_;
34 absl::optional<double> cached_delay_seconds_
35 RTC_GUARDED_BY(&worker_thread_checker_);
Ruslan Burakov428dcb22019-04-18 17:49:49 +020036};
37
38} // namespace webrtc
39
40#endif // PC_JITTER_BUFFER_DELAY_H_