Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: webrtc/modules/audio_processing/include/aec_dump.h

Issue 2778783002: AecDump interface (Closed)
Patch Set: New FloatAudioFrame class for passing float** audio. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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&) = delete;
32 InternalAPMConfig& operator=(const InternalAPMConfig&&) = delete;
33
34 bool aec_enabled = false;
35 bool aec_delay_agnostic_enabled = false;
36 bool aec_drift_compensation_enabled = false;
37 bool aec_extended_filter_enabled = false;
38 int aec_suppression_level = 0;
39 bool aecm_enabled = false;
40 bool aecm_comfort_noise_enabled = false;
41 int aecm_routing_mode = 0;
42 bool agc_enabled = false;
43 int agc_mode = 0;
44 bool agc_limiter_enabled = false;
45 bool hpf_enabled = false;
46 bool ns_enabled = false;
47 int ns_level = 0;
48 bool transient_suppression_enabled = false;
49 bool intelligibility_enhancer_enabled = false;
50 bool noise_robust_agc_enabled = false;
51 std::string experiments_description = "";
52 };
53
54 struct InternalAPMStreamsConfig {
55 int input_sample_rate = 0;
56 int output_sample_rate = 0;
57 int render_input_sample_rate = 0;
58 int render_output_sample_rate = 0;
59
60 size_t input_num_channels = 0;
61 size_t output_num_channels = 0;
62 size_t render_input_num_channels = 0;
63 size_t render_output_num_channels = 0;
64 };
65
66 // Class to pass audio data in float** format. This is to avoid
67 // dependence on AudioBuffer, and avoid problems associated with
68 // rtc::ArrayView<rtc::ArrayView>.
69 class FloatAudioFrame {
70 public:
71 FloatAudioFrame(const float* const* audio_samples,
72 size_t num_channels,
73 size_t channel_size)
kwiberg-webrtc 2017/05/03 18:57:57 These are nontrivial arguments. Document them?
aleloi 2017/05/04 08:56:40 Done.
74 : audio_samples_(audio_samples),
75 num_channels_(num_channels),
76 channel_size_(channel_size) {}
77
78 size_t num_channels() const { return num_channels_; }
79
80 rtc::ArrayView<const float> channel(size_t idx) const {
81 RTC_DCHECK_LE(0, idx);
82 RTC_DCHECK_LE(idx, num_channels_);
83 return rtc::ArrayView<const float>(audio_samples_[idx], channel_size_);
84 }
85
86 private:
87 const float* const* audio_samples_;
88 size_t num_channels_;
89 size_t channel_size_;
90 };
kwiberg-webrtc 2017/05/03 18:57:57 This is exactly what I had in mind when we spoke:
91
92 // An interface for recording configuration and input/output streams
93 // of the Audio Processing Module. The recordings are called
94 // 'aec-dumps' and are stored in a protobuf format defined in
95 // debug.proto.
96 class AecDump {
97 public:
98 // A capture stream frame is logged before and after processing in
99 // the same protobuf message. To facilitate that, a CaptureStreamInfo
100 // instance is first filled with Input, then Output.
101 //
102 // To log an input/output pair, first call
103 // AecDump::GetCaptureStreamInfo. Add the input and output to
104 // it. Then call AecDump::WriteCaptureStreamMessage.
105 class CaptureStreamInfo {
106 public:
107 virtual ~CaptureStreamInfo() = default;
108 virtual void AddInput(FloatAudioFrame src) = 0;
peah-webrtc 2017/05/04 06:19:08 These calls are made by copying the FloatAudioFram
aleloi 2017/05/04 08:56:40 I think no copies are made here because of return
109 virtual void AddOutput(FloatAudioFrame src) = 0;
110
111 virtual void AddInput(const AudioFrame& frame) = 0;
112 virtual void AddOutput(const AudioFrame& frame) = 0;
113
114 virtual void set_delay(int delay) = 0;
115 virtual void set_drift(int drift) = 0;
peah-webrtc 2017/05/04 06:19:08 I think it would make sense to combine these 4 set
aleloi 2017/05/04 08:56:40 I think a set_state(int, int, int, bool) method wo
peah-webrtc 2017/05/04 10:57:51 I don't think the style guide comment really appli
116 virtual void set_level(int level) = 0;
117 virtual void set_keypress(bool keypress) = 0;
118 };
119
120 virtual ~AecDump() = default;
121
122 virtual std::unique_ptr<CaptureStreamInfo> GetCaptureStreamInfo() const = 0;
peah-webrtc 2017/05/04 06:19:08 Does the GetCaptureStreamInfo() method create Capt
aleloi 2017/05/04 08:56:40 Yes, it should be called 'CreateCaptureStreamInfo'
123
124 // The Write* methods are always safe to call concurrently or
125 // otherwise for all implementing subclasses. The intended mode of
126 // operation is to create a protobuf object from the input, and send
127 // it away to be written to file asynchronously.
128 virtual void WriteInitMessage(
129 const InternalAPMStreamsConfig& streams_config) = 0;
130
131 virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0;
132
133 virtual void WriteRenderStreamMessage(FloatAudioFrame src) = 0;
134
135 virtual void WriteCaptureStreamMessage(
136 std::unique_ptr<CaptureStreamInfo> stream_info) = 0;
137
138 // If not |forced|, only writes the current config if it is
139 // different from the last saved one; if |forced|, writes the config
140 // regardless of the last saved.
141 virtual void WriteConfig(const InternalAPMConfig& config, bool forced) = 0;
142 };
143 } // namespace webrtc
144
145 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698