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.enable = true; | |
202 // bool config_ok = config.Validate(); | |
203 // RTC_DCHECK(config_ok); | |
204 // if (config_ok { | |
the sun
2016/08/30 18:05:35
No. The client should not be burdened with validat
peah-webrtc
2016/08/31 08:08:32
Done.
| |
205 // apm->ApplyConfig(config); | |
206 // } | |
207 // | |
208 // apm->high_pass_filter()->Enable(true); | 208 // apm->high_pass_filter()->Enable(true); |
209 // | 209 // |
210 // apm->echo_cancellation()->enable_drift_compensation(false); | 210 // apm->echo_cancellation()->enable_drift_compensation(false); |
211 // apm->echo_cancellation()->Enable(true); | 211 // apm->echo_cancellation()->Enable(true); |
212 // | 212 // |
213 // apm->noise_reduction()->set_level(kHighSuppression); | 213 // apm->noise_reduction()->set_level(kHighSuppression); |
214 // apm->noise_reduction()->Enable(true); | 214 // apm->noise_reduction()->Enable(true); |
215 // | 215 // |
216 // apm->gain_control()->set_analog_level_limits(0, 255); | 216 // apm->gain_control()->set_analog_level_limits(0, 255); |
217 // apm->gain_control()->set_mode(kAdaptiveAnalog); | 217 // apm->gain_control()->set_mode(kAdaptiveAnalog); |
(...skipping 19 matching lines...) Expand all Loading... | |
237 // | 237 // |
238 // // Repeate render and capture processing for the duration of the call... | 238 // // Repeate render and capture processing for the duration of the call... |
239 // // Start a new call... | 239 // // Start a new call... |
240 // apm->Initialize(); | 240 // apm->Initialize(); |
241 // | 241 // |
242 // // Close the application... | 242 // // Close the application... |
243 // delete apm; | 243 // delete apm; |
244 // | 244 // |
245 class AudioProcessing { | 245 class AudioProcessing { |
246 public: | 246 public: |
247 // The struct below constitutes the new parameter scheme for the | |
248 // audio processing functionality. It is being introduced gradually and | |
249 // until it is fully introduced, it is prone to change. | |
250 // | |
251 // The parameters and behavior of the audio processing module are controlled | |
252 // by changing the default values in the ApmConfig struct. It is possible | |
the sun
2016/08/30 18:05:35
Update comment.
peah-webrtc
2016/08/31 08:08:31
Done.
| |
253 // to verify the specified parameters by calling the IsOk method for each | |
254 // substruct. The config are applied by passing the struct to the | |
255 // ApplyConfig method in the audio processing interface. The IsOk() | |
256 // method of the main struct calls all of the IsOk() methods in the | |
257 // substructs. | |
258 struct Config { | |
259 struct LevelController { | |
260 bool enabled = false; | |
261 bool Validate() const; | |
the sun
2016/08/30 18:05:35
Again, the *knowledge* about a sane state for each
peah-webrtc
2016/08/31 08:08:32
Done.
| |
262 } level_controller; | |
263 bool Validate() const; | |
264 }; | |
265 | |
247 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone. | 266 // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone. |
248 enum ChannelLayout { | 267 enum ChannelLayout { |
249 kMono, | 268 kMono, |
250 // Left, right. | 269 // Left, right. |
251 kStereo, | 270 kStereo, |
252 // Mono, keyboard mic. | 271 // Mono, keyboard mic. |
253 kMonoAndKeyboard, | 272 kMonoAndKeyboard, |
254 // Left, right, keyboard mic. | 273 // Left, right, keyboard mic. |
255 kStereoAndKeyboard | 274 kStereoAndKeyboard |
256 }; | 275 }; |
257 | 276 |
258 // Creates an APM instance. Use one instance for every primary audio stream | 277 // Creates an APM instance. Use one instance for every primary audio stream |
259 // requiring processing. On the client-side, this would typically be one | 278 // 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 | 279 // 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 | 280 // stream which requires processing. On the server-side, this would typically |
262 // be one instance for every incoming stream. | 281 // be one instance for every incoming stream. |
263 static AudioProcessing* Create(); | 282 static AudioProcessing* Create(); |
264 // Allows passing in an optional configuration at create-time. | 283 // Allows passing in an optional configuration at create-time. |
265 static AudioProcessing* Create(const Config& config); | 284 static AudioProcessing* Create(const webrtc::Config& config); |
266 // Only for testing. | 285 // Only for testing. |
267 static AudioProcessing* Create(const Config& config, | 286 static AudioProcessing* Create(const webrtc::Config& config, |
268 NonlinearBeamformer* beamformer); | 287 NonlinearBeamformer* beamformer); |
269 virtual ~AudioProcessing() {} | 288 virtual ~AudioProcessing() {} |
270 | 289 |
290 // TODO(peah): This method is a temporary solution used to take control | |
291 // over the parameters in the audio processing module and is likely to change. | |
292 virtual bool ApplyConfig(const Config& config) = 0; | |
the sun
2016/08/30 18:05:35
nit: Does it really belong before Initialize() ?
peah-webrtc
2016/08/31 08:08:31
Good point! I'll put it by SetExtraOptions
Done.
| |
293 | |
271 // Initializes internal states, while retaining all user settings. This | 294 // Initializes internal states, while retaining all user settings. This |
272 // should be called before beginning to process a new audio stream. However, | 295 // 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 | 296 // it is not necessary to call before processing the first stream after |
274 // creation. | 297 // creation. |
275 // | 298 // |
276 // It is also not necessary to call if the audio parameters (sample | 299 // It is also not necessary to call if the audio parameters (sample |
277 // rate and number of channels) have changed. Passing updated parameters | 300 // rate and number of channels) have changed. Passing updated parameters |
278 // directly to |ProcessStream()| and |ProcessReverseStream()| is permissible. | 301 // directly to |ProcessStream()| and |ProcessReverseStream()| is permissible. |
279 // If the parameters are known at init-time though, they may be provided. | 302 // If the parameters are known at init-time though, they may be provided. |
280 virtual int Initialize() = 0; | 303 virtual int Initialize() = 0; |
(...skipping 14 matching lines...) Expand all Loading... | |
295 // TODO(mgraczyk): Remove once clients are updated to use the new interface. | 318 // TODO(mgraczyk): Remove once clients are updated to use the new interface. |
296 virtual int Initialize(int input_sample_rate_hz, | 319 virtual int Initialize(int input_sample_rate_hz, |
297 int output_sample_rate_hz, | 320 int output_sample_rate_hz, |
298 int reverse_sample_rate_hz, | 321 int reverse_sample_rate_hz, |
299 ChannelLayout input_layout, | 322 ChannelLayout input_layout, |
300 ChannelLayout output_layout, | 323 ChannelLayout output_layout, |
301 ChannelLayout reverse_layout) = 0; | 324 ChannelLayout reverse_layout) = 0; |
302 | 325 |
303 // Pass down additional options which don't have explicit setters. This | 326 // Pass down additional options which don't have explicit setters. This |
304 // ensures the options are applied immediately. | 327 // ensures the options are applied immediately. |
305 virtual void SetExtraOptions(const Config& config) = 0; | 328 virtual void SetExtraOptions(const webrtc::Config& config) = 0; |
306 | 329 |
307 // TODO(ajm): Only intended for internal use. Make private and friend the | 330 // TODO(ajm): Only intended for internal use. Make private and friend the |
308 // necessary classes? | 331 // necessary classes? |
309 virtual int proc_sample_rate_hz() const = 0; | 332 virtual int proc_sample_rate_hz() const = 0; |
310 virtual int proc_split_sample_rate_hz() const = 0; | 333 virtual int proc_split_sample_rate_hz() const = 0; |
311 virtual size_t num_input_channels() const = 0; | 334 virtual size_t num_input_channels() const = 0; |
312 virtual size_t num_proc_channels() const = 0; | 335 virtual size_t num_proc_channels() const = 0; |
313 virtual size_t num_output_channels() const = 0; | 336 virtual size_t num_output_channels() const = 0; |
314 virtual size_t num_reverse_channels() const = 0; | 337 virtual size_t num_reverse_channels() const = 0; |
315 | 338 |
(...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()|. | 997 // This does not impact the size of frames passed to |ProcessStream()|. |
975 virtual int set_frame_size_ms(int size) = 0; | 998 virtual int set_frame_size_ms(int size) = 0; |
976 virtual int frame_size_ms() const = 0; | 999 virtual int frame_size_ms() const = 0; |
977 | 1000 |
978 protected: | 1001 protected: |
979 virtual ~VoiceDetection() {} | 1002 virtual ~VoiceDetection() {} |
980 }; | 1003 }; |
981 } // namespace webrtc | 1004 } // namespace webrtc |
982 | 1005 |
983 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ | 1006 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ |
OLD | NEW |