| 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 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
| 19 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
| 20 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 20 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 21 | 21 |
| 22 namespace webrtc { | 22 namespace webrtc { |
| 23 | 23 |
| 24 class AgcManagerDirect; | 24 class AgcManagerDirect; |
| 25 class AudioBuffer; | 25 class AudioBuffer; |
| 26 class AudioConverter; |
| 26 | 27 |
| 27 template<typename T> | 28 template<typename T> |
| 28 class Beamformer; | 29 class Beamformer; |
| 29 | 30 |
| 30 class CriticalSectionWrapper; | 31 class CriticalSectionWrapper; |
| 31 class EchoCancellationImpl; | 32 class EchoCancellationImpl; |
| 32 class EchoControlMobileImpl; | 33 class EchoControlMobileImpl; |
| 33 class FileWrapper; | 34 class FileWrapper; |
| 34 class GainControlImpl; | 35 class GainControlImpl; |
| 35 class GainControlForNewAgc; | 36 class GainControlForNewAgc; |
| 36 class HighPassFilterImpl; | 37 class HighPassFilterImpl; |
| 37 class LevelEstimatorImpl; | 38 class LevelEstimatorImpl; |
| 38 class NoiseSuppressionImpl; | 39 class NoiseSuppressionImpl; |
| 39 class ProcessingComponent; | 40 class ProcessingComponent; |
| 40 class TransientSuppressor; | 41 class TransientSuppressor; |
| 41 class VoiceDetectionImpl; | 42 class VoiceDetectionImpl; |
| 43 class IntelligibilityEnhancer; |
| 42 | 44 |
| 43 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 45 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 44 namespace audioproc { | 46 namespace audioproc { |
| 45 | 47 |
| 46 class Event; | 48 class Event; |
| 47 | 49 |
| 48 } // namespace audioproc | 50 } // namespace audioproc |
| 49 #endif | 51 #endif |
| 50 | 52 |
| 51 class AudioProcessingImpl : public AudioProcessing { | 53 class AudioProcessingImpl : public AudioProcessing { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 82 int input_sample_rate_hz, | 84 int input_sample_rate_hz, |
| 83 ChannelLayout input_layout, | 85 ChannelLayout input_layout, |
| 84 int output_sample_rate_hz, | 86 int output_sample_rate_hz, |
| 85 ChannelLayout output_layout, | 87 ChannelLayout output_layout, |
| 86 float* const* dest) override; | 88 float* const* dest) override; |
| 87 int ProcessStream(const float* const* src, | 89 int ProcessStream(const float* const* src, |
| 88 const StreamConfig& input_config, | 90 const StreamConfig& input_config, |
| 89 const StreamConfig& output_config, | 91 const StreamConfig& output_config, |
| 90 float* const* dest) override; | 92 float* const* dest) override; |
| 91 int AnalyzeReverseStream(AudioFrame* frame) override; | 93 int AnalyzeReverseStream(AudioFrame* frame) override; |
| 94 int ProcessReverseStream(AudioFrame* frame) override; |
| 92 int AnalyzeReverseStream(const float* const* data, | 95 int AnalyzeReverseStream(const float* const* data, |
| 93 int samples_per_channel, | 96 int samples_per_channel, |
| 94 int sample_rate_hz, | 97 int sample_rate_hz, |
| 95 ChannelLayout layout) override; | 98 ChannelLayout layout) override; |
| 96 int AnalyzeReverseStream(const float* const* data, | 99 int ProcessReverseStream(const float* const* src, |
| 97 const StreamConfig& reverse_config) override; | 100 const StreamConfig& reverse_input_config, |
| 101 const StreamConfig& reverse_output_config, |
| 102 float* const* dest) override; |
| 98 int set_stream_delay_ms(int delay) override; | 103 int set_stream_delay_ms(int delay) override; |
| 99 int stream_delay_ms() const override; | 104 int stream_delay_ms() const override; |
| 100 bool was_stream_delay_set() const override; | 105 bool was_stream_delay_set() const override; |
| 101 void set_delay_offset_ms(int offset) override; | 106 void set_delay_offset_ms(int offset) override; |
| 102 int delay_offset_ms() const override; | 107 int delay_offset_ms() const override; |
| 103 void set_stream_key_pressed(bool key_pressed) override; | 108 void set_stream_key_pressed(bool key_pressed) override; |
| 104 bool stream_key_pressed() const override; | 109 bool stream_key_pressed() const override; |
| 105 int StartDebugRecording(const char filename[kMaxFilenameSize]) override; | 110 int StartDebugRecording(const char filename[kMaxFilenameSize]) override; |
| 106 int StartDebugRecording(FILE* handle) override; | 111 int StartDebugRecording(FILE* handle) override; |
| 107 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; | 112 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; |
| 108 int StopDebugRecording() override; | 113 int StopDebugRecording() override; |
| 109 void UpdateHistogramsOnCallEnd() override; | 114 void UpdateHistogramsOnCallEnd() override; |
| 110 EchoCancellation* echo_cancellation() const override; | 115 EchoCancellation* echo_cancellation() const override; |
| 111 EchoControlMobile* echo_control_mobile() const override; | 116 EchoControlMobile* echo_control_mobile() const override; |
| 112 GainControl* gain_control() const override; | 117 GainControl* gain_control() const override; |
| 113 HighPassFilter* high_pass_filter() const override; | 118 HighPassFilter* high_pass_filter() const override; |
| 114 LevelEstimator* level_estimator() const override; | 119 LevelEstimator* level_estimator() const override; |
| 115 NoiseSuppression* noise_suppression() const override; | 120 NoiseSuppression* noise_suppression() const override; |
| 116 VoiceDetection* voice_detection() const override; | 121 VoiceDetection* voice_detection() const override; |
| 117 | 122 |
| 118 protected: | 123 protected: |
| 119 // Overridden in a mock. | 124 // Overridden in a mock. |
| 120 virtual int InitializeLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 125 virtual int InitializeLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 121 | 126 |
| 122 private: | 127 private: |
| 123 int InitializeLocked(const ProcessingConfig& config) | 128 int InitializeLocked(const ProcessingConfig& config) |
| 124 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 129 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 125 int MaybeInitializeLocked(const ProcessingConfig& config) | 130 int MaybeInitializeLocked(const ProcessingConfig& config) |
| 126 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 131 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 132 // TODO(ekm): Remove once all clients updated to new interface. |
| 133 int AnalyzeReverseStream(const float* const* src, |
| 134 const StreamConfig& input_config, |
| 135 const StreamConfig& output_config, |
| 136 const float* const* dest); |
| 127 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 137 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 128 int AnalyzeReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 138 int ProcessReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 129 | 139 |
| 130 bool is_data_processed() const; | 140 bool is_data_processed() const; |
| 131 bool output_copy_needed(bool is_data_processed) const; | 141 bool output_copy_needed(bool is_data_processed) const; |
| 132 bool synthesis_needed(bool is_data_processed) const; | 142 bool synthesis_needed(bool is_data_processed) const; |
| 133 bool analysis_needed(bool is_data_processed) const; | 143 bool analysis_needed(bool is_data_processed) const; |
| 144 bool is_rev_processed() const; |
| 145 bool rev_conversion_needed() const; |
| 134 void InitializeExperimentalAgc() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 146 void InitializeExperimentalAgc() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 135 void InitializeTransient() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 147 void InitializeTransient() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 136 void InitializeBeamformer() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 148 void InitializeBeamformer() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 149 void InitializeIntelligibility() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 137 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 150 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 138 | 151 |
| 139 EchoCancellationImpl* echo_cancellation_; | 152 EchoCancellationImpl* echo_cancellation_; |
| 140 EchoControlMobileImpl* echo_control_mobile_; | 153 EchoControlMobileImpl* echo_control_mobile_; |
| 141 GainControlImpl* gain_control_; | 154 GainControlImpl* gain_control_; |
| 142 HighPassFilterImpl* high_pass_filter_; | 155 HighPassFilterImpl* high_pass_filter_; |
| 143 LevelEstimatorImpl* level_estimator_; | 156 LevelEstimatorImpl* level_estimator_; |
| 144 NoiseSuppressionImpl* noise_suppression_; | 157 NoiseSuppressionImpl* noise_suppression_; |
| 145 VoiceDetectionImpl* voice_detection_; | 158 VoiceDetectionImpl* voice_detection_; |
| 146 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc_; | 159 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc_; |
| 147 | 160 |
| 148 std::list<ProcessingComponent*> component_list_; | 161 std::list<ProcessingComponent*> component_list_; |
| 149 CriticalSectionWrapper* crit_; | 162 CriticalSectionWrapper* crit_; |
| 150 rtc::scoped_ptr<AudioBuffer> render_audio_; | 163 rtc::scoped_ptr<AudioBuffer> render_audio_; |
| 151 rtc::scoped_ptr<AudioBuffer> capture_audio_; | 164 rtc::scoped_ptr<AudioBuffer> capture_audio_; |
| 165 rtc::scoped_ptr<AudioConverter> render_converter_; |
| 152 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 166 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 153 // TODO(andrew): make this more graceful. Ideally we would split this stuff | 167 // TODO(andrew): make this more graceful. Ideally we would split this stuff |
| 154 // out into a separate class with an "enabled" and "disabled" implementation. | 168 // out into a separate class with an "enabled" and "disabled" implementation. |
| 155 int WriteMessageToDebugFile(); | 169 int WriteMessageToDebugFile(); |
| 156 int WriteInitMessage(); | 170 int WriteInitMessage(); |
| 157 rtc::scoped_ptr<FileWrapper> debug_file_; | 171 rtc::scoped_ptr<FileWrapper> debug_file_; |
| 158 rtc::scoped_ptr<audioproc::Event> event_msg_; // Protobuf message. | 172 rtc::scoped_ptr<audioproc::Event> event_msg_; // Protobuf message. |
| 159 std::string event_str_; // Memory for protobuf serialization. | 173 std::string event_str_; // Memory for protobuf serialization. |
| 160 #endif | 174 #endif |
| 161 | 175 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 184 // Only set through the constructor's Config parameter. | 198 // Only set through the constructor's Config parameter. |
| 185 const bool use_new_agc_; | 199 const bool use_new_agc_; |
| 186 rtc::scoped_ptr<AgcManagerDirect> agc_manager_ GUARDED_BY(crit_); | 200 rtc::scoped_ptr<AgcManagerDirect> agc_manager_ GUARDED_BY(crit_); |
| 187 int agc_startup_min_volume_; | 201 int agc_startup_min_volume_; |
| 188 | 202 |
| 189 bool transient_suppressor_enabled_; | 203 bool transient_suppressor_enabled_; |
| 190 rtc::scoped_ptr<TransientSuppressor> transient_suppressor_; | 204 rtc::scoped_ptr<TransientSuppressor> transient_suppressor_; |
| 191 const bool beamformer_enabled_; | 205 const bool beamformer_enabled_; |
| 192 rtc::scoped_ptr<Beamformer<float>> beamformer_; | 206 rtc::scoped_ptr<Beamformer<float>> beamformer_; |
| 193 const std::vector<Point> array_geometry_; | 207 const std::vector<Point> array_geometry_; |
| 208 |
| 209 bool intelligibility_enabled_; |
| 210 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer_; |
| 194 }; | 211 }; |
| 195 | 212 |
| 196 } // namespace webrtc | 213 } // namespace webrtc |
| 197 | 214 |
| 198 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 215 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
| OLD | NEW |