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
|
|
|
#ifndef PC_JITTER_BUFFER_DELAY_H_
|
|
|
|
|
#define PC_JITTER_BUFFER_DELAY_H_
|
2019-02-27 15:32:48 +01:00
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
#include <optional>
|
|
|
|
|
|
2021-05-17 14:50:10 +02:00
|
|
|
#include "api/sequence_checker.h"
|
|
|
|
|
#include "rtc_base/system/no_unique_address.h"
|
2022-02-23 13:44:59 +00:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
2019-02-27 15:32:48 +01:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2019-04-18 17:49:49 +02:00
|
|
|
// JitterBufferDelay converts delay from seconds to milliseconds for the
|
|
|
|
|
// underlying media channel. It also handles cases when user sets delay before
|
2021-05-17 14:50:10 +02:00
|
|
|
// the start of media_channel by caching its request.
|
|
|
|
|
class JitterBufferDelay {
|
2019-02-27 15:32:48 +01:00
|
|
|
public:
|
2023-03-23 22:20:39 +01:00
|
|
|
JitterBufferDelay() = default;
|
2019-02-27 15:32:48 +01:00
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
void Set(std::optional<double> delay_seconds);
|
2021-05-17 14:50:10 +02:00
|
|
|
int GetMs() const;
|
2019-02-27 15:32:48 +01:00
|
|
|
|
|
|
|
|
private:
|
2023-03-23 22:20:39 +01:00
|
|
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_{
|
|
|
|
|
SequenceChecker::kDetached};
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<double> cached_delay_seconds_
|
2021-05-17 14:50:10 +02:00
|
|
|
RTC_GUARDED_BY(&worker_thread_checker_);
|
2019-02-27 15:32:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2019-04-18 17:49:49 +02:00
|
|
|
#endif // PC_JITTER_BUFFER_DELAY_H_
|