blob: dbbb1a8b1c23423e6dac2797163d9b4f447638cf [file] [log] [blame]
peah69221db2017-01-27 03:28:19 -08001/*
2 * Copyright (c) 2017 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_
12#define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_
peah69221db2017-01-27 03:28:19 -080013
Danil Chapovalovdb9f7ab2018-06-19 10:50:11 +020014#include "absl/types/optional.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "api/array_view.h"
Gustaf Ullberg3646f972018-02-14 15:19:04 +010016#include "api/audio/echo_canceller3_config.h"
Per Åhgrena76ef9d2018-01-25 07:01:34 +010017#include "modules/audio_processing/aec3/delay_estimate.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "modules/audio_processing/aec3/downsampled_render_buffer.h"
19#include "modules/audio_processing/aec3/render_delay_buffer.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/audio_processing/logging/apm_data_dumper.h"
peah69221db2017-01-27 03:28:19 -080021
22namespace webrtc {
23
24// Class for aligning the render and capture signal using a RenderDelayBuffer.
25class RenderDelayController {
26 public:
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020027 static RenderDelayController* Create(const EchoCanceller3Config& config,
28 int sample_rate_hz);
peah69221db2017-01-27 03:28:19 -080029 virtual ~RenderDelayController() = default;
30
Per Åhgren8b7d2062018-10-30 23:44:40 +010031 // Resets the delay controller. If the delay confidence is reset, the reset
32 // behavior is as if the call is restarted.
33 virtual void Reset(bool reset_delay_confidence) = 0;
peah69221db2017-01-27 03:28:19 -080034
Per Åhgren47127762018-02-13 12:59:33 +010035 // Logs a render call.
36 virtual void LogRenderCall() = 0;
37
peahcf02cf12017-04-05 14:18:07 -070038 // Aligns the render buffer content with the capture signal.
Danil Chapovalovdb9f7ab2018-06-19 10:50:11 +020039 virtual absl::optional<DelayEstimate> GetDelay(
Per Åhgrenc59a5762017-12-11 21:34:19 +010040 const DownsampledRenderBuffer& render_buffer,
Per Åhgren5c532d32018-03-22 00:29:25 +010041 size_t render_delay_buffer_delay,
Gustaf Ullbergee84d392019-09-10 09:36:43 +020042 const std::vector<std::vector<float>>& capture) = 0;
Gustaf Ullberg777cf262018-11-22 16:02:34 +010043
44 // Returns true if clockdrift has been detected.
45 virtual bool HasClockdrift() const = 0;
peah69221db2017-01-27 03:28:19 -080046};
47} // namespace webrtc
48
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020049#endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_