• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 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_MAIN_SOURCE_AUDIO_PROCESSING_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_PROCESSING_IMPL_H_
13 
14 #include <list>
15 
16 #include "audio_processing.h"
17 
18 namespace webrtc {
19 class CriticalSectionWrapper;
20 class FileWrapper;
21 
22 class AudioBuffer;
23 class EchoCancellationImpl;
24 class EchoControlMobileImpl;
25 class GainControlImpl;
26 class HighPassFilterImpl;
27 class LevelEstimatorImpl;
28 class NoiseSuppressionImpl;
29 class ProcessingComponent;
30 class VoiceDetectionImpl;
31 
32 class AudioProcessingImpl : public AudioProcessing {
33  public:
34   enum {
35     kSampleRate8kHz = 8000,
36     kSampleRate16kHz = 16000,
37     kSampleRate32kHz = 32000
38   };
39 
40   explicit AudioProcessingImpl(int id);
41   virtual ~AudioProcessingImpl();
42 
43   CriticalSectionWrapper* crit() const;
44 
45   int split_sample_rate_hz() const;
46   bool was_stream_delay_set() const;
47 
48   // AudioProcessing methods.
49   virtual int Initialize();
50   virtual int InitializeLocked();
51   virtual int set_sample_rate_hz(int rate);
52   virtual int sample_rate_hz() const;
53   virtual int set_num_channels(int input_channels, int output_channels);
54   virtual int num_input_channels() const;
55   virtual int num_output_channels() const;
56   virtual int set_num_reverse_channels(int channels);
57   virtual int num_reverse_channels() const;
58   virtual int ProcessStream(AudioFrame* frame);
59   virtual int AnalyzeReverseStream(AudioFrame* frame);
60   virtual int set_stream_delay_ms(int delay);
61   virtual int stream_delay_ms() const;
62   virtual int StartDebugRecording(const char filename[kMaxFilenameSize]);
63   virtual int StopDebugRecording();
64   virtual EchoCancellation* echo_cancellation() const;
65   virtual EchoControlMobile* echo_control_mobile() const;
66   virtual GainControl* gain_control() const;
67   virtual HighPassFilter* high_pass_filter() const;
68   virtual LevelEstimator* level_estimator() const;
69   virtual NoiseSuppression* noise_suppression() const;
70   virtual VoiceDetection* voice_detection() const;
71 
72   // Module methods.
73   virtual WebRtc_Word32 Version(WebRtc_Word8* version,
74                               WebRtc_UWord32& remainingBufferInBytes,
75                               WebRtc_UWord32& position) const;
76   virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id);
77 
78  private:
79   int id_;
80 
81   EchoCancellationImpl* echo_cancellation_;
82   EchoControlMobileImpl* echo_control_mobile_;
83   GainControlImpl* gain_control_;
84   HighPassFilterImpl* high_pass_filter_;
85   LevelEstimatorImpl* level_estimator_;
86   NoiseSuppressionImpl* noise_suppression_;
87   VoiceDetectionImpl* voice_detection_;
88 
89   std::list<ProcessingComponent*> component_list_;
90 
91   FileWrapper* debug_file_;
92   CriticalSectionWrapper* crit_;
93 
94   AudioBuffer* render_audio_;
95   AudioBuffer* capture_audio_;
96 
97   int sample_rate_hz_;
98   int split_sample_rate_hz_;
99   int samples_per_channel_;
100   int stream_delay_ms_;
101   bool was_stream_delay_set_;
102 
103   int num_render_input_channels_;
104   int num_capture_input_channels_;
105   int num_capture_output_channels_;
106 };
107 }  // namespace webrtc
108 
109 #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_PROCESSING_IMPL_H_
110