OLD | NEW |
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 Loading... |
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 Loading... |
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.enabled = true; |
| 202 // apm->ApplyConfig(config) |
| 203 // |
208 // apm->high_pass_filter()->Enable(true); | 204 // apm->high_pass_filter()->Enable(true); |
209 // | 205 // |
210 // apm->echo_cancellation()->enable_drift_compensation(false); | 206 // apm->echo_cancellation()->enable_drift_compensation(false); |
211 // apm->echo_cancellation()->Enable(true); | 207 // apm->echo_cancellation()->Enable(true); |
212 // | 208 // |
213 // apm->noise_reduction()->set_level(kHighSuppression); | 209 // apm->noise_reduction()->set_level(kHighSuppression); |
214 // apm->noise_reduction()->Enable(true); | 210 // apm->noise_reduction()->Enable(true); |
215 // | 211 // |
216 // apm->gain_control()->set_analog_level_limits(0, 255); | 212 // apm->gain_control()->set_analog_level_limits(0, 255); |
217 // apm->gain_control()->set_mode(kAdaptiveAnalog); | 213 // apm->gain_control()->set_mode(kAdaptiveAnalog); |
(...skipping 19 matching lines...) Expand all Loading... |
237 // | 233 // |
238 // // Repeate render and capture processing for the duration of the call... | 234 // // Repeate render and capture processing for the duration of the call... |
239 // // Start a new call... | 235 // // Start a new call... |
240 // apm->Initialize(); | 236 // apm->Initialize(); |
241 // | 237 // |
242 // // Close the application... | 238 // // Close the application... |
243 // delete apm; | 239 // delete apm; |
244 // | 240 // |
245 class AudioProcessing { | 241 class AudioProcessing { |
246 public: | 242 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 |
247 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone. | 258 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone. |
248 enum ChannelLayout { | 259 enum ChannelLayout { |
249 kMono, | 260 kMono, |
250 // Left, right. | 261 // Left, right. |
251 kStereo, | 262 kStereo, |
252 // Mono, keyboard mic. | 263 // Mono, keyboard, and mic. |
253 kMonoAndKeyboard, | 264 kMonoAndKeyboard, |
254 // Left, right, keyboard mic. | 265 // Left, right, keyboard, and mic. |
255 kStereoAndKeyboard | 266 kStereoAndKeyboard |
256 }; | 267 }; |
257 | 268 |
258 // Creates an APM instance. Use one instance for every primary audio stream | 269 // Creates an APM instance. Use one instance for every primary audio stream |
259 // requiring processing. On the client-side, this would typically be one | 270 // 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 | 271 // 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 | 272 // stream which requires processing. On the server-side, this would typically |
262 // be one instance for every incoming stream. | 273 // be one instance for every incoming stream. |
263 static AudioProcessing* Create(); | 274 static AudioProcessing* Create(); |
264 // Allows passing in an optional configuration at create-time. | 275 // Allows passing in an optional configuration at create-time. |
265 static AudioProcessing* Create(const Config& config); | 276 static AudioProcessing* Create(const webrtc::Config& config); |
266 // Only for testing. | 277 // Only for testing. |
267 static AudioProcessing* Create(const Config& config, | 278 static AudioProcessing* Create(const webrtc::Config& config, |
268 NonlinearBeamformer* beamformer); | 279 NonlinearBeamformer* beamformer); |
269 virtual ~AudioProcessing() {} | 280 virtual ~AudioProcessing() {} |
270 | 281 |
271 // Initializes internal states, while retaining all user settings. This | 282 // Initializes internal states, while retaining all user settings. This |
272 // should be called before beginning to process a new audio stream. However, | 283 // 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 | 284 // it is not necessary to call before processing the first stream after |
274 // creation. | 285 // creation. |
275 // | 286 // |
276 // It is also not necessary to call if the audio parameters (sample | 287 // It is also not necessary to call if the audio parameters (sample |
277 // rate and number of channels) have changed. Passing updated parameters | 288 // rate and number of channels) have changed. Passing updated parameters |
(...skipping 15 matching lines...) Expand all Loading... |
293 // Initialize with unpacked parameters. See Initialize() above for details. | 304 // Initialize with unpacked parameters. See Initialize() above for details. |
294 // | 305 // |
295 // TODO(mgraczyk): Remove once clients are updated to use the new interface. | 306 // TODO(mgraczyk): Remove once clients are updated to use the new interface. |
296 virtual int Initialize(int input_sample_rate_hz, | 307 virtual int Initialize(int input_sample_rate_hz, |
297 int output_sample_rate_hz, | 308 int output_sample_rate_hz, |
298 int reverse_sample_rate_hz, | 309 int reverse_sample_rate_hz, |
299 ChannelLayout input_layout, | 310 ChannelLayout input_layout, |
300 ChannelLayout output_layout, | 311 ChannelLayout output_layout, |
301 ChannelLayout reverse_layout) = 0; | 312 ChannelLayout reverse_layout) = 0; |
302 | 313 |
| 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 |
303 // Pass down additional options which don't have explicit setters. This | 318 // Pass down additional options which don't have explicit setters. This |
304 // ensures the options are applied immediately. | 319 // ensures the options are applied immediately. |
305 virtual void SetExtraOptions(const Config& config) = 0; | 320 virtual void SetExtraOptions(const webrtc::Config& config) = 0; |
306 | 321 |
307 // TODO(ajm): Only intended for internal use. Make private and friend the | 322 // TODO(ajm): Only intended for internal use. Make private and friend the |
308 // necessary classes? | 323 // necessary classes? |
309 virtual int proc_sample_rate_hz() const = 0; | 324 virtual int proc_sample_rate_hz() const = 0; |
310 virtual int proc_split_sample_rate_hz() const = 0; | 325 virtual int proc_split_sample_rate_hz() const = 0; |
311 virtual size_t num_input_channels() const = 0; | 326 virtual size_t num_input_channels() const = 0; |
312 virtual size_t num_proc_channels() const = 0; | 327 virtual size_t num_proc_channels() const = 0; |
313 virtual size_t num_output_channels() const = 0; | 328 virtual size_t num_output_channels() const = 0; |
314 virtual size_t num_reverse_channels() const = 0; | 329 virtual size_t num_reverse_channels() const = 0; |
315 | 330 |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 // This does not impact the size of frames passed to |ProcessStream()|. | 989 // This does not impact the size of frames passed to |ProcessStream()|. |
975 virtual int set_frame_size_ms(int size) = 0; | 990 virtual int set_frame_size_ms(int size) = 0; |
976 virtual int frame_size_ms() const = 0; | 991 virtual int frame_size_ms() const = 0; |
977 | 992 |
978 protected: | 993 protected: |
979 virtual ~VoiceDetection() {} | 994 virtual ~VoiceDetection() {} |
980 }; | 995 }; |
981 } // namespace webrtc | 996 } // namespace webrtc |
982 | 997 |
983 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ | 998 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ |
OLD | NEW |