blob: 95c010b0a3ebbb94d9c9b25a3d6e10d89e4c2735 [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"
Alex Loiko1aec5942018-05-15 13:13:22 +020021#include "modules/audio_processing/include/audio_processing.h"
aleloi868f32f2017-05-23 07:20:05 -070022
23namespace webrtc {
24
aleloi868f32f2017-05-23 07:20:05 -070025// 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;
Alex Loiko5feb30e2018-04-16 13:52:32 +020054 bool pre_amplifier_enabled = false;
55 float pre_amplifier_fixed_gain_factor = 1.f;
aleloi868f32f2017-05-23 07:20:05 -070056 std::string experiments_description = "";
57};
58
aleloi868f32f2017-05-23 07:20:05 -070059// An interface for recording configuration and input/output streams
60// of the Audio Processing Module. The recordings are called
61// 'aec-dumps' and are stored in a protobuf format defined in
62// debug.proto.
63// The Write* methods are always safe to call concurrently or
64// otherwise for all implementing subclasses. The intended mode of
65// operation is to create a protobuf object from the input, and send
66// it away to be written to file asynchronously.
67class AecDump {
68 public:
69 struct AudioProcessingState {
70 int delay;
71 int drift;
72 int level;
73 bool keypress;
74 };
75
76 virtual ~AecDump() = default;
77
78 // Logs Event::Type INIT message.
Minyue Li656d6092018-08-10 15:38:52 +020079 virtual void WriteInitMessage(const ProcessingConfig& api_format,
80 int64_t time_now_ms) = 0;
81 RTC_DEPRECATED void WriteInitMessage(const ProcessingConfig& api_format) {
82 WriteInitMessage(api_format, 0);
83 }
aleloi868f32f2017-05-23 07:20:05 -070084
85 // Logs Event::Type STREAM message. To log an input/output pair,
86 // call the AddCapture* and AddAudioProcessingState methods followed
87 // by a WriteCaptureStreamMessage call.
Alex Loikoe36e8bb2018-02-16 11:54:07 +010088 virtual void AddCaptureStreamInput(
89 const AudioFrameView<const float>& src) = 0;
90 virtual void AddCaptureStreamOutput(
91 const AudioFrameView<const float>& src) = 0;
aleloi868f32f2017-05-23 07:20:05 -070092 virtual void AddCaptureStreamInput(const AudioFrame& frame) = 0;
93 virtual void AddCaptureStreamOutput(const AudioFrame& frame) = 0;
94 virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0;
95 virtual void WriteCaptureStreamMessage() = 0;
96
97 // Logs Event::Type REVERSE_STREAM message.
98 virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0;
Alex Loikoe36e8bb2018-02-16 11:54:07 +010099 virtual void WriteRenderStreamMessage(
100 const AudioFrameView<const float>& src) = 0;
aleloi868f32f2017-05-23 07:20:05 -0700101
102 // Logs Event::Type CONFIG message.
103 virtual void WriteConfig(const InternalAPMConfig& config) = 0;
104};
105} // namespace webrtc
106
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200107#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_