Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_ | |
| 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_ | |
| 13 | |
| 14 #include <memory> | |
| 15 #include <string> | |
| 16 #include <vector> | |
| 17 | |
| 18 #include "webrtc/base/array_view.h" | |
| 19 | |
| 20 namespace webrtc { | |
| 21 | |
| 22 class AudioFrame; | |
| 23 | |
| 24 // Struct for passing current config from APM without having to | |
| 25 // include protobuf headers. | |
| 26 struct InternalAPMConfig { | |
| 27 InternalAPMConfig(); | |
| 28 InternalAPMConfig(const InternalAPMConfig&); | |
| 29 InternalAPMConfig(InternalAPMConfig&&); | |
| 30 | |
| 31 InternalAPMConfig& operator=(const InternalAPMConfig&); | |
| 32 InternalAPMConfig& operator=(InternalAPMConfig&&); | |
| 33 | |
| 34 bool Equals(const InternalAPMConfig& other); | |
|
the sun
2017/05/23 12:00:22
operator== ?
aleloi
2017/05/23 12:24:09
Done. I thought the style guide discouraged that,
| |
| 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 | |
| 56 struct 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 | |
| 68 // Class to pass audio data in float** format. This is to avoid | |
| 69 // dependence on AudioBuffer, and avoid problems associated with | |
| 70 // rtc::ArrayView<rtc::ArrayView>. | |
| 71 class FloatAudioFrame { | |
| 72 public: | |
| 73 // |num_channels| and |channel_size| describe the float** | |
| 74 // |audio_samples|. |audio_samples| is assumed to point to a | |
| 75 // two-dimensional |num_channels * channel_size| array of floats. | |
| 76 FloatAudioFrame(const float* const* audio_samples, | |
| 77 size_t num_channels, | |
| 78 size_t channel_size) | |
| 79 : audio_samples_(audio_samples), | |
| 80 num_channels_(num_channels), | |
| 81 channel_size_(channel_size) {} | |
| 82 | |
| 83 size_t num_channels() const { return num_channels_; } | |
| 84 | |
| 85 rtc::ArrayView<const float> channel(size_t idx) const { | |
| 86 RTC_DCHECK_LE(0, idx); | |
| 87 RTC_DCHECK_LE(idx, num_channels_); | |
| 88 return rtc::ArrayView<const float>(audio_samples_[idx], channel_size_); | |
| 89 } | |
| 90 | |
| 91 private: | |
| 92 const float* const* audio_samples_; | |
| 93 size_t num_channels_; | |
| 94 size_t channel_size_; | |
|
the sun
2017/05/23 12:00:22
Default init or = delete on default ctor
aleloi
2017/05/23 12:24:09
Done.
| |
| 95 }; | |
| 96 | |
| 97 // An interface for recording configuration and input/output streams | |
| 98 // of the Audio Processing Module. The recordings are called | |
| 99 // 'aec-dumps' and are stored in a protobuf format defined in | |
| 100 // debug.proto. | |
| 101 class AecDump { | |
| 102 public: | |
| 103 struct AudioProcessingState { | |
| 104 int delay; | |
| 105 int drift; | |
| 106 int level; | |
| 107 bool keypress; | |
| 108 }; | |
| 109 | |
| 110 virtual ~AecDump() = default; | |
| 111 | |
| 112 // The Write* methods are always safe to call concurrently or | |
| 113 // otherwise for all implementing subclasses. The intended mode of | |
| 114 // operation is to create a protobuf object from the input, and send | |
| 115 // it away to be written to file asynchronously. | |
| 116 virtual void WriteInitMessage( | |
| 117 const InternalAPMStreamsConfig& streams_config) = 0; | |
| 118 | |
| 119 // To log an input/output pair, call the AddCapture* methods | |
| 120 // followed by a WriteCaptureStreamMessage call. | |
| 121 virtual void AddCaptureStreamInput(const FloatAudioFrame& src) = 0; | |
| 122 virtual void AddCaptureStreamOutput(const FloatAudioFrame& src) = 0; | |
| 123 virtual void AddCaptureStreamInput(const AudioFrame& frame) = 0; | |
| 124 virtual void AddCaptureStreamOutput(const AudioFrame& frame) = 0; | |
| 125 virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0; | |
| 126 virtual void WriteCaptureStreamMessage() = 0; | |
| 127 | |
| 128 virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0; | |
|
the sun
2017/05/23 12:00:22
nit: clean up order and everything in this interfa
| |
| 129 | |
| 130 virtual void WriteRenderStreamMessage(const FloatAudioFrame& src) = 0; | |
| 131 | |
| 132 virtual void WriteConfig(const InternalAPMConfig& config) = 0; | |
| 133 }; | |
| 134 } // namespace webrtc | |
| 135 | |
| 136 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_ | |
| OLD | NEW |