11#include <promeki/config.h>
12#if PROMEKI_ENABLE_CORE
19PROMEKI_NAMESPACE_BEGIN
30enum class PacingVerdict {
53 PacingVerdict verdict = PacingVerdict::OnTime;
89 Error error = Error::Ok;
146 static constexpr int DefaultReanchorMultiple = 8;
149 PacingGate() =
default;
156 explicit PacingGate(
const Clock::Ptr &clock,
const Duration &period = Duration::zero());
170 void setClock(
const Clock::Ptr &clock);
173 const Clock::Ptr &clock()
const {
return _clock; }
176 bool hasClock()
const {
return _clock.isValid(); }
191 void setPeriod(
const Duration &period);
194 const Duration &period()
const {
return _period; }
203 void setSkipThreshold(
const Duration &t);
206 const Duration &skipThreshold()
const {
return _skipThreshold; }
216 void setReanchorThreshold(
const Duration &t);
219 const Duration &reanchorThreshold()
const {
return _reanchorThreshold; }
257 PacingResult wait(
const Duration &advance);
263 PacingResult wait() {
return wait(_period); }
300 bool tryAcquire(
const Duration &advance);
306 bool tryAcquire() {
return tryAcquire(_period); }
311 int64_t ticksOnTime()
const {
return _ticksOnTime; }
314 int64_t ticksLate()
const {
return _ticksLate; }
317 int64_t ticksSkipped()
const {
return _ticksSkipped; }
320 int64_t reanchors()
const {
return _reanchors; }
323 int64_t tryAcquireRejected()
const {
return _tryAcquireRejected; }
326 bool isArmed()
const {
return _armed; }
336 const MediaTimeStamp &anchor()
const {
return _anchor; }
339 const Duration &accumulated()
const {
return _accumulated; }
347 Duration _period = Duration::zero();
348 Duration _skipThreshold = Duration::zero();
349 Duration _reanchorThreshold = Duration::zero();
350 MediaTimeStamp _anchor;
354 Duration _accumulated = Duration::zero();
356 bool _customSkipThreshold =
false;
357 bool _customReanchorThreshold =
false;
358 int64_t _ticksOnTime = 0;
359 int64_t _ticksLate = 0;
360 int64_t _ticksSkipped = 0;
361 int64_t _reanchors = 0;
362 int64_t _tryAcquireRejected = 0;