aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_ |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "api/array_view.h" |
Fredrik Solenberg | bbf21a3 | 2018-04-12 22:44:09 +0200 | [diff] [blame] | 19 | #include "api/audio/audio_frame.h" |
Alex Loiko | e36e8bb | 2018-02-16 11:54:07 +0100 | [diff] [blame] | 20 | #include "modules/audio_processing/include/audio_frame_view.h" |
Alex Loiko | 1aec594 | 2018-05-15 13:13:22 +0200 | [diff] [blame] | 21 | #include "modules/audio_processing/include/audio_processing.h" |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 25 | // Struct for passing current config from APM without having to |
| 26 | // include protobuf headers. |
| 27 | struct 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; |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 52 | bool noise_robust_agc_enabled = false; |
Alex Loiko | 5feb30e | 2018-04-16 13:52:32 +0200 | [diff] [blame] | 53 | bool pre_amplifier_enabled = false; |
| 54 | float pre_amplifier_fixed_gain_factor = 1.f; |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 55 | std::string experiments_description = ""; |
| 56 | }; |
| 57 | |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 58 | // An interface for recording configuration and input/output streams |
| 59 | // of the Audio Processing Module. The recordings are called |
| 60 | // 'aec-dumps' and are stored in a protobuf format defined in |
| 61 | // debug.proto. |
| 62 | // The Write* methods are always safe to call concurrently or |
| 63 | // otherwise for all implementing subclasses. The intended mode of |
| 64 | // operation is to create a protobuf object from the input, and send |
| 65 | // it away to be written to file asynchronously. |
| 66 | class AecDump { |
| 67 | public: |
| 68 | struct AudioProcessingState { |
| 69 | int delay; |
| 70 | int drift; |
| 71 | int level; |
| 72 | bool keypress; |
| 73 | }; |
| 74 | |
| 75 | virtual ~AecDump() = default; |
| 76 | |
| 77 | // Logs Event::Type INIT message. |
Minyue Li | 656d609 | 2018-08-10 15:38:52 +0200 | [diff] [blame] | 78 | virtual void WriteInitMessage(const ProcessingConfig& api_format, |
| 79 | int64_t time_now_ms) = 0; |
| 80 | RTC_DEPRECATED void WriteInitMessage(const ProcessingConfig& api_format) { |
| 81 | WriteInitMessage(api_format, 0); |
| 82 | } |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 83 | |
| 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 Loiko | e36e8bb | 2018-02-16 11:54:07 +0100 | [diff] [blame] | 87 | virtual void AddCaptureStreamInput( |
| 88 | const AudioFrameView<const float>& src) = 0; |
| 89 | virtual void AddCaptureStreamOutput( |
| 90 | const AudioFrameView<const float>& src) = 0; |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 91 | virtual void AddCaptureStreamInput(const AudioFrame& frame) = 0; |
| 92 | virtual void AddCaptureStreamOutput(const AudioFrame& frame) = 0; |
| 93 | virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0; |
| 94 | virtual void WriteCaptureStreamMessage() = 0; |
| 95 | |
| 96 | // Logs Event::Type REVERSE_STREAM message. |
| 97 | virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0; |
Alex Loiko | e36e8bb | 2018-02-16 11:54:07 +0100 | [diff] [blame] | 98 | virtual void WriteRenderStreamMessage( |
| 99 | const AudioFrameView<const float>& src) = 0; |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 100 | |
Alex Loiko | 6234722 | 2018-09-10 10:18:07 +0200 | [diff] [blame^] | 101 | virtual void WriteRuntimeSetting( |
| 102 | const AudioProcessing::RuntimeSetting& runtime_setting) = 0; |
| 103 | |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 104 | // Logs Event::Type CONFIG message. |
| 105 | virtual void WriteConfig(const InternalAPMConfig& config) = 0; |
| 106 | }; |
| 107 | } // namespace webrtc |
| 108 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 109 | #endif // MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_ |