blob: 07477d2f829ddb286ac959183b075598e303d817 [file] [log] [blame]
aleloi868f32f2017-05-23 07:20:05 -07001/*
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_INCLUDE_AEC_DUMP_H_
12#define MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_
aleloi868f32f2017-05-23 07:20:05 -070013
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020015
aleloi868f32f2017-05-23 07:20:05 -070016#include <string>
aleloi868f32f2017-05-23 07:20:05 -070017
Danil Chapovalove9041612021-02-22 12:43:39 +010018#include "absl/base/attributes.h"
Alex Loikoe36e8bb2018-02-16 11:54:07 +010019#include "modules/audio_processing/include/audio_frame_view.h"
Alex Loiko1aec5942018-05-15 13:13:22 +020020#include "modules/audio_processing/include/audio_processing.h"
aleloi868f32f2017-05-23 07:20:05 -070021
22namespace webrtc {
23
aleloi868f32f2017-05-23 07:20:05 -070024// Struct for passing current config from APM without having to
25// include protobuf headers.
26struct InternalAPMConfig {
27 InternalAPMConfig();
28 InternalAPMConfig(const InternalAPMConfig&);
29 InternalAPMConfig(InternalAPMConfig&&);
30
31 InternalAPMConfig& operator=(const InternalAPMConfig&);
32 InternalAPMConfig& operator=(InternalAPMConfig&&) = delete;
33
Peter Kasting662d7f12022-05-04 12:57:00 -070034 bool operator==(const InternalAPMConfig& other) const;
aleloi868f32f2017-05-23 07:20:05 -070035
36 bool aec_enabled = false;
37 bool aec_delay_agnostic_enabled = false;
38 bool aec_drift_compensation_enabled = false;
39 bool aec_extended_filter_enabled = false;
40 int aec_suppression_level = 0;
41 bool aecm_enabled = false;
42 bool aecm_comfort_noise_enabled = false;
43 int aecm_routing_mode = 0;
44 bool agc_enabled = false;
45 int agc_mode = 0;
46 bool agc_limiter_enabled = false;
47 bool hpf_enabled = false;
48 bool ns_enabled = false;
49 int ns_level = 0;
50 bool transient_suppression_enabled = false;
aleloi868f32f2017-05-23 07:20:05 -070051 bool noise_robust_agc_enabled = false;
Alex Loiko5feb30e2018-04-16 13:52:32 +020052 bool pre_amplifier_enabled = false;
53 float pre_amplifier_fixed_gain_factor = 1.f;
aleloi868f32f2017-05-23 07:20:05 -070054 std::string experiments_description = "";
55};
56
aleloi868f32f2017-05-23 07:20:05 -070057// An interface for recording configuration and input/output streams
58// of the Audio Processing Module. The recordings are called
59// 'aec-dumps' and are stored in a protobuf format defined in
60// debug.proto.
61// The Write* methods are always safe to call concurrently or
62// otherwise for all implementing subclasses. The intended mode of
63// operation is to create a protobuf object from the input, and send
64// it away to be written to file asynchronously.
65class AecDump {
66 public:
67 struct AudioProcessingState {
68 int delay;
69 int drift;
70 int level;
71 bool keypress;
72 };
73
74 virtual ~AecDump() = default;
75
76 // Logs Event::Type INIT message.
Minyue Li656d6092018-08-10 15:38:52 +020077 virtual void WriteInitMessage(const ProcessingConfig& api_format,
78 int64_t time_now_ms) = 0;
Danil Chapovalove9041612021-02-22 12:43:39 +010079 ABSL_DEPRECATED("")
80 void WriteInitMessage(const ProcessingConfig& api_format) {
Minyue Li656d6092018-08-10 15:38:52 +020081 WriteInitMessage(api_format, 0);
82 }
aleloi868f32f2017-05-23 07:20:05 -070083
84 // Logs Event::Type STREAM message. To log an input/output pair,
85 // call the AddCapture* and AddAudioProcessingState methods followed
86 // by a WriteCaptureStreamMessage call.
Alex Loikoe36e8bb2018-02-16 11:54:07 +010087 virtual void AddCaptureStreamInput(
88 const AudioFrameView<const float>& src) = 0;
89 virtual void AddCaptureStreamOutput(
90 const AudioFrameView<const float>& src) = 0;
Per Åhgren645f24c2020-03-16 12:06:02 +010091 virtual void AddCaptureStreamInput(const int16_t* const data,
92 int num_channels,
93 int samples_per_channel) = 0;
94 virtual void AddCaptureStreamOutput(const int16_t* const data,
95 int num_channels,
96 int samples_per_channel) = 0;
aleloi868f32f2017-05-23 07:20:05 -070097 virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0;
98 virtual void WriteCaptureStreamMessage() = 0;
99
100 // Logs Event::Type REVERSE_STREAM message.
Per Åhgren645f24c2020-03-16 12:06:02 +0100101 virtual void WriteRenderStreamMessage(const int16_t* const data,
102 int num_channels,
103 int samples_per_channel) = 0;
Alex Loikoe36e8bb2018-02-16 11:54:07 +0100104 virtual void WriteRenderStreamMessage(
105 const AudioFrameView<const float>& src) = 0;
aleloi868f32f2017-05-23 07:20:05 -0700106
Alex Loiko62347222018-09-10 10:18:07 +0200107 virtual void WriteRuntimeSetting(
108 const AudioProcessing::RuntimeSetting& runtime_setting) = 0;
109
aleloi868f32f2017-05-23 07:20:05 -0700110 // Logs Event::Type CONFIG message.
111 virtual void WriteConfig(const InternalAPMConfig& config) = 0;
112};
113} // namespace webrtc
114
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200115#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_