blob: d4d45692b8de51b70ccbbff869d8d2a5eaf5ef30 [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
14#include <memory>
15#include <string>
16#include <vector>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "api/array_view.h"
Fredrik Solenbergbbf21a32018-04-12 22:44:09 +020019#include "api/audio/audio_frame.h"
Alex Loikoe36e8bb2018-02-16 11:54:07 +010020#include "modules/audio_processing/include/audio_frame_view.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
34 bool operator==(const InternalAPMConfig& other);
35
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;
51 bool intelligibility_enhancer_enabled = false;
52 bool noise_robust_agc_enabled = false;
53 std::string experiments_description = "";
54};
55
56struct InternalAPMStreamsConfig {
57 int input_sample_rate = 0;
58 int output_sample_rate = 0;
59 int render_input_sample_rate = 0;
60 int render_output_sample_rate = 0;
61
62 size_t input_num_channels = 0;
63 size_t output_num_channels = 0;
64 size_t render_input_num_channels = 0;
65 size_t render_output_num_channels = 0;
66};
67
aleloi868f32f2017-05-23 07:20:05 -070068// An interface for recording configuration and input/output streams
69// of the Audio Processing Module. The recordings are called
70// 'aec-dumps' and are stored in a protobuf format defined in
71// debug.proto.
72// The Write* methods are always safe to call concurrently or
73// otherwise for all implementing subclasses. The intended mode of
74// operation is to create a protobuf object from the input, and send
75// it away to be written to file asynchronously.
76class AecDump {
77 public:
78 struct AudioProcessingState {
79 int delay;
80 int drift;
81 int level;
82 bool keypress;
83 };
84
85 virtual ~AecDump() = default;
86
87 // Logs Event::Type INIT message.
88 virtual void WriteInitMessage(
89 const InternalAPMStreamsConfig& streams_config) = 0;
90
91 // Logs Event::Type STREAM message. To log an input/output pair,
92 // call the AddCapture* and AddAudioProcessingState methods followed
93 // by a WriteCaptureStreamMessage call.
Alex Loikoe36e8bb2018-02-16 11:54:07 +010094 virtual void AddCaptureStreamInput(
95 const AudioFrameView<const float>& src) = 0;
96 virtual void AddCaptureStreamOutput(
97 const AudioFrameView<const float>& src) = 0;
aleloi868f32f2017-05-23 07:20:05 -070098 virtual void AddCaptureStreamInput(const AudioFrame& frame) = 0;
99 virtual void AddCaptureStreamOutput(const AudioFrame& frame) = 0;
100 virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0;
101 virtual void WriteCaptureStreamMessage() = 0;
102
103 // Logs Event::Type REVERSE_STREAM message.
104 virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0;
Alex Loikoe36e8bb2018-02-16 11:54:07 +0100105 virtual void WriteRenderStreamMessage(
106 const AudioFrameView<const float>& src) = 0;
aleloi868f32f2017-05-23 07:20:05 -0700107
108 // Logs Event::Type CONFIG message.
109 virtual void WriteConfig(const InternalAPMConfig& config) = 0;
110};
111} // namespace webrtc
112
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200113#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_