2013-01-29 12:09:21 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2012 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_NETEQ_DELAY_MANAGER_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_NETEQ_DELAY_MANAGER_H_
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2016-04-28 23:19:20 -07:00
|
|
|
#include <memory>
|
2024-08-29 13:00:40 +00:00
|
|
|
#include <optional>
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2024-08-13 15:28:50 +02:00
|
|
|
#include "api/field_trials_view.h"
|
2019-10-31 14:38:11 +01:00
|
|
|
#include "api/neteq/tick_timer.h"
|
2021-09-08 16:35:50 +02:00
|
|
|
#include "modules/audio_coding/neteq/reorder_optimizer.h"
|
2021-09-07 14:24:56 +02:00
|
|
|
#include "modules/audio_coding/neteq/underrun_optimizer.h"
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class DelayManager {
|
|
|
|
|
public:
|
2021-09-07 14:24:56 +02:00
|
|
|
struct Config {
|
2024-08-13 15:28:50 +02:00
|
|
|
explicit Config(const FieldTrialsView& field_trials);
|
2021-09-07 14:24:56 +02:00
|
|
|
void Log();
|
|
|
|
|
|
|
|
|
|
// Options that can be configured via field trial.
|
2021-11-09 12:58:45 +01:00
|
|
|
double quantile = 0.95;
|
|
|
|
|
double forget_factor = 0.983;
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<double> start_forget_weight = 2;
|
|
|
|
|
std::optional<int> resample_interval_ms = 500;
|
2021-09-07 14:24:56 +02:00
|
|
|
|
2021-09-08 16:35:50 +02:00
|
|
|
bool use_reorder_optimizer = true;
|
|
|
|
|
double reorder_forget_factor = 0.9993;
|
|
|
|
|
int ms_per_loss_percent = 20;
|
2021-09-07 14:24:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DelayManager(const Config& config, const TickTimer* tick_timer);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2013-07-31 15:54:00 +00:00
|
|
|
virtual ~DelayManager();
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2022-01-21 09:49:39 +09:00
|
|
|
DelayManager(const DelayManager&) = delete;
|
|
|
|
|
DelayManager& operator=(const DelayManager&) = delete;
|
|
|
|
|
|
2022-05-25 21:06:14 +02:00
|
|
|
// Updates the delay manager that a new packet arrived with delay
|
|
|
|
|
// `arrival_delay_ms`. This updates the statistics and a new target buffer
|
|
|
|
|
// level is calculated. The `reordered` flag indicates if the packet was
|
|
|
|
|
// reordered.
|
|
|
|
|
virtual void Update(int arrival_delay_ms, bool reordered);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2020-10-09 13:41:06 +02:00
|
|
|
// Resets all state.
|
2013-01-29 12:09:21 +00:00
|
|
|
virtual void Reset();
|
|
|
|
|
|
2022-07-19 16:33:10 +02:00
|
|
|
// Gets the target buffer level in milliseconds. If a minimum or maximum delay
|
|
|
|
|
// has been set, the target delay reported here also respects the configured
|
|
|
|
|
// min/max delay.
|
2020-10-09 13:41:06 +02:00
|
|
|
virtual int TargetDelayMs() const;
|
2020-10-07 12:46:42 +00:00
|
|
|
|
2018-10-04 11:31:03 +02:00
|
|
|
private:
|
2021-09-07 14:24:56 +02:00
|
|
|
UnderrunOptimizer underrun_optimizer_;
|
2021-09-08 16:35:50 +02:00
|
|
|
std::unique_ptr<ReorderOptimizer> reorder_optimizer_;
|
2022-07-19 16:33:10 +02:00
|
|
|
int target_level_ms_ = 0; // Currently preferred buffer level.
|
2013-01-29 12:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_NETEQ_DELAY_MANAGER_H_
|