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

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

Issue 2334583002: Revert of Introduced new scheme for controlling the functionality inside the audio processing module (Closed)
Patch Set: 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
94 // Enables delay-agnostic echo cancellation. This feature relies on internally 102 // Enables delay-agnostic echo cancellation. This feature relies on internally
95 // estimated delays between the process and reverse streams, thus not relying 103 // estimated delays between the process and reverse streams, thus not relying
96 // on reported system delays. This configuration only applies to 104 // on reported system delays. This configuration only applies to
97 // EchoCancellation and not EchoControlMobile. It can be set in the constructor 105 // EchoCancellation and not EchoControlMobile. It can be set in the constructor
98 // or using AudioProcessing::SetExtraOptions(). 106 // or using AudioProcessing::SetExtraOptions().
99 struct DelayAgnostic { 107 struct DelayAgnostic {
100 DelayAgnostic() : enabled(false) {} 108 DelayAgnostic() : enabled(false) {}
101 explicit DelayAgnostic(bool enabled) : enabled(enabled) {} 109 explicit DelayAgnostic(bool enabled) : enabled(enabled) {}
102 static const ConfigOptionID identifier = ConfigOptionID::kDelayAgnostic; 110 static const ConfigOptionID identifier = ConfigOptionID::kDelayAgnostic;
103 bool enabled; 111 bool enabled;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // 2. Parameter getters are never called concurrently with the corresponding 198 // 2. Parameter getters are never called concurrently with the corresponding
191 // setter. 199 // setter.
192 // 200 //
193 // APM accepts only linear PCM audio data in chunks of 10 ms. The int16 201 // APM accepts only linear PCM audio data in chunks of 10 ms. The int16
194 // interfaces use interleaved data, while the float interfaces use deinterleaved 202 // interfaces use interleaved data, while the float interfaces use deinterleaved
195 // data. 203 // data.
196 // 204 //
197 // Usage example, omitting error checking: 205 // Usage example, omitting error checking:
198 // AudioProcessing* apm = AudioProcessing::Create(0); 206 // AudioProcessing* apm = AudioProcessing::Create(0);
199 // 207 //
200 // AudioProcessing::Config config;
201 // config.level_controller.enabled = true;
202 // apm->ApplyConfig(config)
203 //
204 // apm->high_pass_filter()->Enable(true); 208 // apm->high_pass_filter()->Enable(true);
205 // 209 //
206 // apm->echo_cancellation()->enable_drift_compensation(false); 210 // apm->echo_cancellation()->enable_drift_compensation(false);
207 // apm->echo_cancellation()->Enable(true); 211 // apm->echo_cancellation()->Enable(true);
208 // 212 //
209 // apm->noise_reduction()->set_level(kHighSuppression); 213 // apm->noise_reduction()->set_level(kHighSuppression);
210 // apm->noise_reduction()->Enable(true); 214 // apm->noise_reduction()->Enable(true);
211 // 215 //
212 // apm->gain_control()->set_analog_level_limits(0, 255); 216 // apm->gain_control()->set_analog_level_limits(0, 255);
213 // apm->gain_control()->set_mode(kAdaptiveAnalog); 217 // apm->gain_control()->set_mode(kAdaptiveAnalog);
(...skipping 19 matching lines...) Expand all
233 // 237 //
234 // // Repeate render and capture processing for the duration of the call... 238 // // Repeate render and capture processing for the duration of the call...
235 // // Start a new call... 239 // // Start a new call...
236 // apm->Initialize(); 240 // apm->Initialize();
237 // 241 //
238 // // Close the application... 242 // // Close the application...
239 // delete apm; 243 // delete apm;
240 // 244 //
241 class AudioProcessing { 245 class AudioProcessing {
242 public: 246 public:
243 // The struct below constitutes the new parameter scheme for the audio
244 // processing. It is being introduced gradually and until it is fully
245 // introduced, it is prone to change.
246 // TODO(peah): Remove this comment once the new config scheme is fully rolled
247 // out.
248 //
249 // The parameters and behavior of the audio processing module are controlled
250 // by changing the default values in the AudioProcessing::Config struct.
251 // The config is applied by passing the struct to the ApplyConfig method.
252 struct Config {
253 struct LevelController {
254 bool enabled = false;
255 } level_controller;
256 };
257
258 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone. 247 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone.
259 enum ChannelLayout { 248 enum ChannelLayout {
260 kMono, 249 kMono,
261 // Left, right. 250 // Left, right.
262 kStereo, 251 kStereo,
263 // Mono, keyboard, and mic. 252 // Mono, keyboard mic.
264 kMonoAndKeyboard, 253 kMonoAndKeyboard,
265 // Left, right, keyboard, and mic. 254 // Left, right, keyboard mic.
266 kStereoAndKeyboard 255 kStereoAndKeyboard
267 }; 256 };
268 257
269 // Creates an APM instance. Use one instance for every primary audio stream 258 // Creates an APM instance. Use one instance for every primary audio stream
270 // requiring processing. On the client-side, this would typically be one 259 // requiring processing. On the client-side, this would typically be one
271 // instance for the near-end stream, and additional instances for each far-end 260 // instance for the near-end stream, and additional instances for each far-end
272 // stream which requires processing. On the server-side, this would typically 261 // stream which requires processing. On the server-side, this would typically
273 // be one instance for every incoming stream. 262 // be one instance for every incoming stream.
274 static AudioProcessing* Create(); 263 static AudioProcessing* Create();
275 // Allows passing in an optional configuration at create-time. 264 // Allows passing in an optional configuration at create-time.
276 static AudioProcessing* Create(const webrtc::Config& config); 265 static AudioProcessing* Create(const Config& config);
277 // Only for testing. 266 // Only for testing.
278 static AudioProcessing* Create(const webrtc::Config& config, 267 static AudioProcessing* Create(const Config& config,
279 NonlinearBeamformer* beamformer); 268 NonlinearBeamformer* beamformer);
280 virtual ~AudioProcessing() {} 269 virtual ~AudioProcessing() {}
281 270
282 // Initializes internal states, while retaining all user settings. This 271 // Initializes internal states, while retaining all user settings. This
283 // should be called before beginning to process a new audio stream. However, 272 // should be called before beginning to process a new audio stream. However,
284 // it is not necessary to call before processing the first stream after 273 // it is not necessary to call before processing the first stream after
285 // creation. 274 // creation.
286 // 275 //
287 // It is also not necessary to call if the audio parameters (sample 276 // It is also not necessary to call if the audio parameters (sample
288 // rate and number of channels) have changed. Passing updated parameters 277 // rate and number of channels) have changed. Passing updated parameters
(...skipping 15 matching lines...) Expand all
304 // Initialize with unpacked parameters. See Initialize() above for details. 293 // Initialize with unpacked parameters. See Initialize() above for details.
305 // 294 //
306 // TODO(mgraczyk): Remove once clients are updated to use the new interface. 295 // TODO(mgraczyk): Remove once clients are updated to use the new interface.
307 virtual int Initialize(int input_sample_rate_hz, 296 virtual int Initialize(int input_sample_rate_hz,
308 int output_sample_rate_hz, 297 int output_sample_rate_hz,
309 int reverse_sample_rate_hz, 298 int reverse_sample_rate_hz,
310 ChannelLayout input_layout, 299 ChannelLayout input_layout,
311 ChannelLayout output_layout, 300 ChannelLayout output_layout,
312 ChannelLayout reverse_layout) = 0; 301 ChannelLayout reverse_layout) = 0;
313 302
314 // TODO(peah): This method is a temporary solution used to take control
315 // over the parameters in the audio processing module and is likely to change.
316 virtual void ApplyConfig(const Config& config) = 0;
317
318 // Pass down additional options which don't have explicit setters. This 303 // Pass down additional options which don't have explicit setters. This
319 // ensures the options are applied immediately. 304 // ensures the options are applied immediately.
320 virtual void SetExtraOptions(const webrtc::Config& config) = 0; 305 virtual void SetExtraOptions(const Config& config) = 0;
321 306
322 // TODO(ajm): Only intended for internal use. Make private and friend the 307 // TODO(ajm): Only intended for internal use. Make private and friend the
323 // necessary classes? 308 // necessary classes?
324 virtual int proc_sample_rate_hz() const = 0; 309 virtual int proc_sample_rate_hz() const = 0;
325 virtual int proc_split_sample_rate_hz() const = 0; 310 virtual int proc_split_sample_rate_hz() const = 0;
326 virtual size_t num_input_channels() const = 0; 311 virtual size_t num_input_channels() const = 0;
327 virtual size_t num_proc_channels() const = 0; 312 virtual size_t num_proc_channels() const = 0;
328 virtual size_t num_output_channels() const = 0; 313 virtual size_t num_output_channels() const = 0;
329 virtual size_t num_reverse_channels() const = 0; 314 virtual size_t num_reverse_channels() const = 0;
330 315
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 // This does not impact the size of frames passed to |ProcessStream()|. 974 // This does not impact the size of frames passed to |ProcessStream()|.
990 virtual int set_frame_size_ms(int size) = 0; 975 virtual int set_frame_size_ms(int size) = 0;
991 virtual int frame_size_ms() const = 0; 976 virtual int frame_size_ms() const = 0;
992 977
993 protected: 978 protected:
994 virtual ~VoiceDetection() {} 979 virtual ~VoiceDetection() {}
995 }; 980 };
996 } // namespace webrtc 981 } // namespace webrtc
997 982
998 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ 983 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698