blob: 2035bf4742f30992166bf5eaff96b8ce0ab15f42 [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"
Alex Loikoe36e8bb2018-02-16 11:54:07 +010019#include "modules/audio_processing/include/audio_frame_view.h"
aleloi868f32f2017-05-23 07:20:05 -070020
21namespace webrtc {
22
23class AudioFrame;
24
25// Struct for passing current config from APM without having to
26// include protobuf headers.
27struct InternalAPMConfig {
28 InternalAPMConfig();
29 InternalAPMConfig(const InternalAPMConfig&);
30 InternalAPMConfig(InternalAPMConfig&&);
31
32 InternalAPMConfig& operator=(const InternalAPMConfig&);
33 InternalAPMConfig& operator=(InternalAPMConfig&&) = delete;
34
35 bool operator==(const InternalAPMConfig& other);
36
37 bool aec_enabled = false;
38 bool aec_delay_agnostic_enabled = false;
39 bool aec_drift_compensation_enabled = false;
40 bool aec_extended_filter_enabled = false;
41 int aec_suppression_level = 0;
42 bool aecm_enabled = false;
43 bool aecm_comfort_noise_enabled = false;
44 int aecm_routing_mode = 0;
45 bool agc_enabled = false;
46 int agc_mode = 0;
47 bool agc_limiter_enabled = false;
48 bool hpf_enabled = false;
49 bool ns_enabled = false;
50 int ns_level = 0;
51 bool transient_suppression_enabled = false;
52 bool intelligibility_enhancer_enabled = false;
53 bool noise_robust_agc_enabled = false;
54 std::string experiments_description = "";
55};
56
57struct InternalAPMStreamsConfig {
58 int input_sample_rate = 0;
59 int output_sample_rate = 0;
60 int render_input_sample_rate = 0;
61 int render_output_sample_rate = 0;
62
63 size_t input_num_channels = 0;
64 size_t output_num_channels = 0;
65 size_t render_input_num_channels = 0;
66 size_t render_output_num_channels = 0;
67};
68
aleloi868f32f2017-05-23 07:20:05 -070069// An interface for recording configuration and input/output streams
70// of the Audio Processing Module. The recordings are called
71// 'aec-dumps' and are stored in a protobuf format defined in
72// debug.proto.
73// The Write* methods are always safe to call concurrently or
74// otherwise for all implementing subclasses. The intended mode of
75// operation is to create a protobuf object from the input, and send
76// it away to be written to file asynchronously.
77class AecDump {
78 public:
79 struct AudioProcessingState {
80 int delay;
81 int drift;
82 int level;
83 bool keypress;
84 };
85
86 virtual ~AecDump() = default;
87
88 // Logs Event::Type INIT message.
89 virtual void WriteInitMessage(
90 const InternalAPMStreamsConfig& streams_config) = 0;
91
92 // Logs Event::Type STREAM message. To log an input/output pair,
93 // call the AddCapture* and AddAudioProcessingState methods followed
94 // by a WriteCaptureStreamMessage call.
Alex Loikoe36e8bb2018-02-16 11:54:07 +010095 virtual void AddCaptureStreamInput(
96 const AudioFrameView<const float>& src) = 0;
97 virtual void AddCaptureStreamOutput(
98 const AudioFrameView<const float>& src) = 0;
aleloi868f32f2017-05-23 07:20:05 -070099 virtual void AddCaptureStreamInput(const AudioFrame& frame) = 0;
100 virtual void AddCaptureStreamOutput(const AudioFrame& frame) = 0;
101 virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0;
102 virtual void WriteCaptureStreamMessage() = 0;
103
104 // Logs Event::Type REVERSE_STREAM message.
105 virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0;
Alex Loikoe36e8bb2018-02-16 11:54:07 +0100106 virtual void WriteRenderStreamMessage(
107 const AudioFrameView<const float>& src) = 0;
aleloi868f32f2017-05-23 07:20:05 -0700108
109 // Logs Event::Type CONFIG message.
110 virtual void WriteConfig(const InternalAPMConfig& config) = 0;
111};
112} // namespace webrtc
113
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200114#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_