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

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

Issue 2292863002: Introduced new scheme for controlling the functionality inside the audio processing module (Closed)
Patch Set: Changes in response to reviewer comments Created 4 years, 3 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
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // EchoControlMobile. It can be set in the constructor 84 // EchoControlMobile. It can be set in the constructor
85 // or using AudioProcessing::SetExtraOptions(). 85 // or using AudioProcessing::SetExtraOptions().
86 struct RefinedAdaptiveFilter { 86 struct RefinedAdaptiveFilter {
87 RefinedAdaptiveFilter() : enabled(false) {} 87 RefinedAdaptiveFilter() : enabled(false) {}
88 explicit RefinedAdaptiveFilter(bool enabled) : enabled(enabled) {} 88 explicit RefinedAdaptiveFilter(bool enabled) : enabled(enabled) {}
89 static const ConfigOptionID identifier = 89 static const ConfigOptionID identifier =
90 ConfigOptionID::kAecRefinedAdaptiveFilter; 90 ConfigOptionID::kAecRefinedAdaptiveFilter;
91 bool enabled; 91 bool enabled;
92 }; 92 };
93 93
94 // Enables the adaptive level controller.
95 struct LevelControl {
96 LevelControl() : enabled(false) {}
97 explicit LevelControl(bool enabled) : enabled(enabled) {}
98 static const ConfigOptionID identifier = ConfigOptionID::kLevelControl;
99 bool enabled;
100 };
101
102 // Enables delay-agnostic echo cancellation. This feature relies on internally 94 // Enables delay-agnostic echo cancellation. This feature relies on internally
103 // estimated delays between the process and reverse streams, thus not relying 95 // estimated delays between the process and reverse streams, thus not relying
104 // on reported system delays. This configuration only applies to 96 // on reported system delays. This configuration only applies to
105 // EchoCancellation and not EchoControlMobile. It can be set in the constructor 97 // EchoCancellation and not EchoControlMobile. It can be set in the constructor
106 // or using AudioProcessing::SetExtraOptions(). 98 // or using AudioProcessing::SetExtraOptions().
107 struct DelayAgnostic { 99 struct DelayAgnostic {
108 DelayAgnostic() : enabled(false) {} 100 DelayAgnostic() : enabled(false) {}
109 explicit DelayAgnostic(bool enabled) : enabled(enabled) {} 101 explicit DelayAgnostic(bool enabled) : enabled(enabled) {}
110 static const ConfigOptionID identifier = ConfigOptionID::kDelayAgnostic; 102 static const ConfigOptionID identifier = ConfigOptionID::kDelayAgnostic;
111 bool enabled; 103 bool enabled;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // 2. Parameter getters are never called concurrently with the corresponding 190 // 2. Parameter getters are never called concurrently with the corresponding
199 // setter. 191 // setter.
200 // 192 //
201 // APM accepts only linear PCM audio data in chunks of 10 ms. The int16 193 // APM accepts only linear PCM audio data in chunks of 10 ms. The int16
202 // interfaces use interleaved data, while the float interfaces use deinterleaved 194 // interfaces use interleaved data, while the float interfaces use deinterleaved
203 // data. 195 // data.
204 // 196 //
205 // Usage example, omitting error checking: 197 // Usage example, omitting error checking:
206 // AudioProcessing* apm = AudioProcessing::Create(0); 198 // AudioProcessing* apm = AudioProcessing::Create(0);
207 // 199 //
200 // AudioProcessing::Config config;
201 // config.level_controller.enable = true;
202 // bool valid_config = config.Validate();
203 // if (valid_config) {
the sun 2016/09/02 09:37:05 This doesn't make sense to me. Why would a client
hlundin-webrtc 2016/09/06 08:56:04 I agree that it isn't necessary to do that before
peah-webrtc 2016/09/07 05:42:59 See my comment below.
peah-webrtc 2016/09/07 05:43:00 I think it makes sense to do it like that. Eventua
204 // RTC_CHECK(apm->ApplyConfig(config));
205 // }
206 //
208 // apm->high_pass_filter()->Enable(true); 207 // apm->high_pass_filter()->Enable(true);
209 // 208 //
210 // apm->echo_cancellation()->enable_drift_compensation(false); 209 // apm->echo_cancellation()->enable_drift_compensation(false);
211 // apm->echo_cancellation()->Enable(true); 210 // apm->echo_cancellation()->Enable(true);
212 // 211 //
213 // apm->noise_reduction()->set_level(kHighSuppression); 212 // apm->noise_reduction()->set_level(kHighSuppression);
214 // apm->noise_reduction()->Enable(true); 213 // apm->noise_reduction()->Enable(true);
215 // 214 //
216 // apm->gain_control()->set_analog_level_limits(0, 255); 215 // apm->gain_control()->set_analog_level_limits(0, 255);
217 // apm->gain_control()->set_mode(kAdaptiveAnalog); 216 // apm->gain_control()->set_mode(kAdaptiveAnalog);
(...skipping 19 matching lines...) Expand all
237 // 236 //
238 // // Repeate render and capture processing for the duration of the call... 237 // // Repeate render and capture processing for the duration of the call...
239 // // Start a new call... 238 // // Start a new call...
240 // apm->Initialize(); 239 // apm->Initialize();
241 // 240 //
242 // // Close the application... 241 // // Close the application...
243 // delete apm; 242 // delete apm;
244 // 243 //
245 class AudioProcessing { 244 class AudioProcessing {
246 public: 245 public:
246 // The struct below constitutes the new parameter scheme for the
247 // audio processing functionality. It is being introduced gradually and
248 // until it is fully introduced, it is prone to change.
249 //
250 // The parameters and behavior of the audio processing module are controlled
251 // by changing the default values in the AudioProcessing::ApmConfig struct.
hlundin-webrtc 2016/09/06 08:56:04 Not called ApmConfig anymore.
peah-webrtc 2016/09/07 05:42:59 Done.
252 // The config is applied by passing the struct to the ApplyConfig method in
253 // the
hlundin-webrtc 2016/09/06 08:56:04 Incomplete sentence.
peah-webrtc 2016/09/07 05:43:00 Done.
254 // It is possible to verify the specified parameters by calling the
255 // Validate() method.
256 struct Config {
257 struct LevelController {
258 bool enabled = false;
259 } level_controller;
260 bool Validate() const;
261 };
262
247 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone. 263 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone.
248 enum ChannelLayout { 264 enum ChannelLayout {
249 kMono, 265 kMono,
250 // Left, right. 266 // Left, right.
251 kStereo, 267 kStereo,
252 // Mono, keyboard mic. 268 // Mono, keyboard mic.
253 kMonoAndKeyboard, 269 kMonoAndKeyboard,
254 // Left, right, keyboard mic. 270 // Left, right, keyboard mic.
255 kStereoAndKeyboard 271 kStereoAndKeyboard
256 }; 272 };
257 273
258 // Creates an APM instance. Use one instance for every primary audio stream 274 // Creates an APM instance. Use one instance for every primary audio stream
259 // requiring processing. On the client-side, this would typically be one 275 // requiring processing. On the client-side, this would typically be one
260 // instance for the near-end stream, and additional instances for each far-end 276 // instance for the near-end stream, and additional instances for each far-end
261 // stream which requires processing. On the server-side, this would typically 277 // stream which requires processing. On the server-side, this would typically
262 // be one instance for every incoming stream. 278 // be one instance for every incoming stream.
263 static AudioProcessing* Create(); 279 static AudioProcessing* Create();
264 // Allows passing in an optional configuration at create-time. 280 // Allows passing in an optional configuration at create-time.
265 static AudioProcessing* Create(const Config& config); 281 static AudioProcessing* Create(const webrtc::Config& config);
266 // Only for testing. 282 // Only for testing.
267 static AudioProcessing* Create(const Config& config, 283 static AudioProcessing* Create(const webrtc::Config& config,
268 NonlinearBeamformer* beamformer); 284 NonlinearBeamformer* beamformer);
269 virtual ~AudioProcessing() {} 285 virtual ~AudioProcessing() {}
270 286
271 // Initializes internal states, while retaining all user settings. This 287 // Initializes internal states, while retaining all user settings. This
272 // should be called before beginning to process a new audio stream. However, 288 // should be called before beginning to process a new audio stream. However,
273 // it is not necessary to call before processing the first stream after 289 // it is not necessary to call before processing the first stream after
274 // creation. 290 // creation.
275 // 291 //
276 // It is also not necessary to call if the audio parameters (sample 292 // It is also not necessary to call if the audio parameters (sample
277 // rate and number of channels) have changed. Passing updated parameters 293 // rate and number of channels) have changed. Passing updated parameters
(...skipping 15 matching lines...) Expand all
293 // Initialize with unpacked parameters. See Initialize() above for details. 309 // Initialize with unpacked parameters. See Initialize() above for details.
294 // 310 //
295 // TODO(mgraczyk): Remove once clients are updated to use the new interface. 311 // TODO(mgraczyk): Remove once clients are updated to use the new interface.
296 virtual int Initialize(int input_sample_rate_hz, 312 virtual int Initialize(int input_sample_rate_hz,
297 int output_sample_rate_hz, 313 int output_sample_rate_hz,
298 int reverse_sample_rate_hz, 314 int reverse_sample_rate_hz,
299 ChannelLayout input_layout, 315 ChannelLayout input_layout,
300 ChannelLayout output_layout, 316 ChannelLayout output_layout,
301 ChannelLayout reverse_layout) = 0; 317 ChannelLayout reverse_layout) = 0;
302 318
319 // TODO(peah): This method is a temporary solution used to take control
320 // over the parameters in the audio processing module and is likely to change.
321 virtual bool ApplyConfig(const Config& config) = 0;
322
303 // Pass down additional options which don't have explicit setters. This 323 // Pass down additional options which don't have explicit setters. This
304 // ensures the options are applied immediately. 324 // ensures the options are applied immediately.
305 virtual void SetExtraOptions(const Config& config) = 0; 325 virtual void SetExtraOptions(const webrtc::Config& config) = 0;
306 326
307 // TODO(ajm): Only intended for internal use. Make private and friend the 327 // TODO(ajm): Only intended for internal use. Make private and friend the
308 // necessary classes? 328 // necessary classes?
309 virtual int proc_sample_rate_hz() const = 0; 329 virtual int proc_sample_rate_hz() const = 0;
310 virtual int proc_split_sample_rate_hz() const = 0; 330 virtual int proc_split_sample_rate_hz() const = 0;
311 virtual size_t num_input_channels() const = 0; 331 virtual size_t num_input_channels() const = 0;
312 virtual size_t num_proc_channels() const = 0; 332 virtual size_t num_proc_channels() const = 0;
313 virtual size_t num_output_channels() const = 0; 333 virtual size_t num_output_channels() const = 0;
314 virtual size_t num_reverse_channels() const = 0; 334 virtual size_t num_reverse_channels() const = 0;
315 335
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 // This does not impact the size of frames passed to |ProcessStream()|. 994 // This does not impact the size of frames passed to |ProcessStream()|.
975 virtual int set_frame_size_ms(int size) = 0; 995 virtual int set_frame_size_ms(int size) = 0;
976 virtual int frame_size_ms() const = 0; 996 virtual int frame_size_ms() const = 0;
977 997
978 protected: 998 protected:
979 virtual ~VoiceDetection() {} 999 virtual ~VoiceDetection() {}
980 }; 1000 };
981 } // namespace webrtc 1001 } // namespace webrtc
982 1002
983 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ 1003 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698