| 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/criticalsection.h" |
| 18 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
| 19 #include "webrtc/base/thread_annotations.h" | 20 #include "webrtc/base/thread_annotations.h" |
| 21 #include "webrtc/modules/audio_processing/audio_buffer.h" |
| 20 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 22 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 23 #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 24 |
| 25 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 26 // Files generated at build-time by the protobuf compiler. |
| 27 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
| 28 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" |
| 29 #else |
| 30 #include "webrtc/audio_processing/debug.pb.h" |
| 31 #endif |
| 32 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 21 | 33 |
| 22 namespace webrtc { | 34 namespace webrtc { |
| 23 | 35 |
| 24 class AgcManagerDirect; | 36 class AgcManagerDirect; |
| 25 class AudioBuffer; | |
| 26 class AudioConverter; | 37 class AudioConverter; |
| 27 | 38 |
| 28 template<typename T> | 39 template<typename T> |
| 29 class Beamformer; | 40 class Beamformer; |
| 30 | 41 |
| 31 class CriticalSectionWrapper; | |
| 32 class EchoCancellationImpl; | 42 class EchoCancellationImpl; |
| 33 class EchoControlMobileImpl; | 43 class EchoControlMobileImpl; |
| 34 class FileWrapper; | |
| 35 class GainControlImpl; | 44 class GainControlImpl; |
| 36 class GainControlForNewAgc; | 45 class GainControlForNewAgc; |
| 37 class HighPassFilterImpl; | 46 class HighPassFilterImpl; |
| 38 class LevelEstimatorImpl; | 47 class LevelEstimatorImpl; |
| 39 class NoiseSuppressionImpl; | 48 class NoiseSuppressionImpl; |
| 40 class ProcessingComponent; | 49 class ProcessingComponent; |
| 41 class TransientSuppressor; | 50 class TransientSuppressor; |
| 42 class VoiceDetectionImpl; | 51 class VoiceDetectionImpl; |
| 43 class IntelligibilityEnhancer; | 52 class IntelligibilityEnhancer; |
| 44 | 53 |
| 45 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | |
| 46 namespace audioproc { | |
| 47 | |
| 48 class Event; | |
| 49 | |
| 50 } // namespace audioproc | |
| 51 #endif | |
| 52 | |
| 53 class AudioProcessingImpl : public AudioProcessing { | 54 class AudioProcessingImpl : public AudioProcessing { |
| 54 public: | 55 public: |
| 56 // Methods forcing APM to run in a single-threaded manner. |
| 57 // Acquires both the render and capture locks. |
| 55 explicit AudioProcessingImpl(const Config& config); | 58 explicit AudioProcessingImpl(const Config& config); |
| 56 | |
| 57 // AudioProcessingImpl takes ownership of beamformer. | 59 // AudioProcessingImpl takes ownership of beamformer. |
| 58 AudioProcessingImpl(const Config& config, Beamformer<float>* beamformer); | 60 AudioProcessingImpl(const Config& config, Beamformer<float>* beamformer); |
| 59 virtual ~AudioProcessingImpl(); | 61 virtual ~AudioProcessingImpl(); |
| 60 | |
| 61 // AudioProcessing methods. | |
| 62 int Initialize() override; | 62 int Initialize() override; |
| 63 int Initialize(int input_sample_rate_hz, | 63 int Initialize(int input_sample_rate_hz, |
| 64 int output_sample_rate_hz, | 64 int output_sample_rate_hz, |
| 65 int reverse_sample_rate_hz, | 65 int reverse_sample_rate_hz, |
| 66 ChannelLayout input_layout, | 66 ChannelLayout input_layout, |
| 67 ChannelLayout output_layout, | 67 ChannelLayout output_layout, |
| 68 ChannelLayout reverse_layout) override; | 68 ChannelLayout reverse_layout) override; |
| 69 int Initialize(const ProcessingConfig& processing_config) override; | 69 int Initialize(const ProcessingConfig& processing_config) override; |
| 70 void SetExtraOptions(const Config& config) override; | 70 void SetExtraOptions(const Config& config) override; |
| 71 int proc_sample_rate_hz() const override; | 71 void UpdateHistogramsOnCallEnd() override; |
| 72 int proc_split_sample_rate_hz() const override; | 72 int StartDebugRecording(const char filename[kMaxFilenameSize]) override; |
| 73 int num_input_channels() const override; | 73 int StartDebugRecording(FILE* handle) override; |
| 74 int num_output_channels() const override; | 74 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; |
| 75 int num_reverse_channels() const override; | 75 int StopDebugRecording() override; |
| 76 void set_output_will_be_muted(bool muted) override; | 76 |
| 77 // Capture-side exclusive methods possibly running APM in a |
| 78 // multi-threaded manner. Acquire the capture lock. |
| 77 int ProcessStream(AudioFrame* frame) override; | 79 int ProcessStream(AudioFrame* frame) override; |
| 78 int ProcessStream(const float* const* src, | 80 int ProcessStream(const float* const* src, |
| 79 size_t samples_per_channel, | 81 size_t samples_per_channel, |
| 80 int input_sample_rate_hz, | 82 int input_sample_rate_hz, |
| 81 ChannelLayout input_layout, | 83 ChannelLayout input_layout, |
| 82 int output_sample_rate_hz, | 84 int output_sample_rate_hz, |
| 83 ChannelLayout output_layout, | 85 ChannelLayout output_layout, |
| 84 float* const* dest) override; | 86 float* const* dest) override; |
| 85 int ProcessStream(const float* const* src, | 87 int ProcessStream(const float* const* src, |
| 86 const StreamConfig& input_config, | 88 const StreamConfig& input_config, |
| 87 const StreamConfig& output_config, | 89 const StreamConfig& output_config, |
| 88 float* const* dest) override; | 90 float* const* dest) override; |
| 91 void set_output_will_be_muted(bool muted) override; |
| 92 int set_stream_delay_ms(int delay) override; |
| 93 void set_delay_offset_ms(int offset) override; |
| 94 int delay_offset_ms() const override; |
| 95 void set_stream_key_pressed(bool key_pressed) override; |
| 96 |
| 97 // Render-side exclusive methods possibly running APM in a |
| 98 // multi-threaded manner. Acquire the render lock. |
| 89 int AnalyzeReverseStream(AudioFrame* frame) override; | 99 int AnalyzeReverseStream(AudioFrame* frame) override; |
| 90 int ProcessReverseStream(AudioFrame* frame) override; | 100 int ProcessReverseStream(AudioFrame* frame) override; |
| 91 int AnalyzeReverseStream(const float* const* data, | 101 int AnalyzeReverseStream(const float* const* data, |
| 92 size_t samples_per_channel, | 102 size_t samples_per_channel, |
| 93 int sample_rate_hz, | 103 int sample_rate_hz, |
| 94 ChannelLayout layout) override; | 104 ChannelLayout layout) override; |
| 95 int ProcessReverseStream(const float* const* src, | 105 int ProcessReverseStream(const float* const* src, |
| 96 const StreamConfig& reverse_input_config, | 106 const StreamConfig& reverse_input_config, |
| 97 const StreamConfig& reverse_output_config, | 107 const StreamConfig& reverse_output_config, |
| 98 float* const* dest) override; | 108 float* const* dest) override; |
| 99 int set_stream_delay_ms(int delay) override; | 109 |
| 110 // Methods only accessed from APM submodules or |
| 111 // from AudioProcessing tests in a single-threaded manner. |
| 112 // Hence there is no need for locks in these. |
| 113 int proc_sample_rate_hz() const override; |
| 114 int proc_split_sample_rate_hz() const override; |
| 115 int num_input_channels() const override; |
| 116 int num_output_channels() const override; |
| 117 int num_reverse_channels() const override; |
| 100 int stream_delay_ms() const override; | 118 int stream_delay_ms() const override; |
| 101 bool was_stream_delay_set() const override; | 119 bool was_stream_delay_set() const override |
| 102 void set_delay_offset_ms(int offset) override; | 120 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 103 int delay_offset_ms() const override; | 121 |
| 104 void set_stream_key_pressed(bool key_pressed) override; | 122 // Methods returning pointers to APM submodules. |
| 105 int StartDebugRecording(const char filename[kMaxFilenameSize]) override; | 123 // No locks are aquired in those, as those locks |
| 106 int StartDebugRecording(FILE* handle) override; | 124 // would offer no protection (the submodules are |
| 107 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; | 125 // created only once in a single-treaded manner |
| 108 int StopDebugRecording() override; | 126 // during APM creation). |
| 109 void UpdateHistogramsOnCallEnd() override; | |
| 110 EchoCancellation* echo_cancellation() const override; | 127 EchoCancellation* echo_cancellation() const override; |
| 111 EchoControlMobile* echo_control_mobile() const override; | 128 EchoControlMobile* echo_control_mobile() const override; |
| 112 GainControl* gain_control() const override; | 129 GainControl* gain_control() const override; |
| 113 HighPassFilter* high_pass_filter() const override; | 130 HighPassFilter* high_pass_filter() const override; |
| 114 LevelEstimator* level_estimator() const override; | 131 LevelEstimator* level_estimator() const override; |
| 115 NoiseSuppression* noise_suppression() const override; | 132 NoiseSuppression* noise_suppression() const override; |
| 116 VoiceDetection* voice_detection() const override; | 133 VoiceDetection* voice_detection() const override; |
| 117 | 134 |
| 118 protected: | 135 protected: |
| 119 // Overridden in a mock. | 136 // Overridden in a mock. |
| 120 virtual int InitializeLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 137 virtual int InitializeLocked() |
| 138 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 121 | 139 |
| 122 private: | 140 private: |
| 141 struct ApmPublicSubmodules; |
| 142 struct ApmPrivateSubmodules; |
| 143 |
| 144 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 145 // State for the debug dump. |
| 146 struct ApmDebugDumpThreadState { |
| 147 ApmDebugDumpThreadState() : event_msg(new audioproc::Event()) {} |
| 148 rtc::scoped_ptr<audioproc::Event> event_msg; // Protobuf message. |
| 149 std::string event_str; // Memory for protobuf serialization. |
| 150 |
| 151 // Serialized string of last saved APM configuration. |
| 152 std::string last_serialized_config; |
| 153 }; |
| 154 |
| 155 struct ApmDebugDumpState { |
| 156 ApmDebugDumpState() : debug_file(FileWrapper::Create()) {} |
| 157 rtc::scoped_ptr<FileWrapper> debug_file; |
| 158 ApmDebugDumpThreadState render; |
| 159 ApmDebugDumpThreadState capture; |
| 160 }; |
| 161 #endif |
| 162 |
| 163 // Method for modifying the formats struct that are called from both |
| 164 // the render and capture threads. The check for whether modifications |
| 165 // are needed is done while holding the render lock only, thereby avoiding |
| 166 // that the capture thread blocks the render thread. |
| 167 // The struct is modified in a single-threaded manner by holding both the |
| 168 // render and capture locks. |
| 169 int MaybeInitialize(const ProcessingConfig& config) |
| 170 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 171 |
| 172 int MaybeInitializeRender(const ProcessingConfig& processing_config) |
| 173 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 174 |
| 175 int MaybeInitializeCapture(const ProcessingConfig& processing_config) |
| 176 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 177 |
| 178 // Method for checking for the need of conversion. Accesses the formats |
| 179 // structs in a read manner but the requirement for the render lock to be held |
| 180 // was added as it currently anyway is always called in that manner. |
| 181 bool rev_conversion_needed() const EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 182 bool render_check_rev_conversion_needed() const |
| 183 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 184 |
| 185 // Methods requiring APM running in a single-threaded manner. |
| 186 // Are called with both the render and capture locks already |
| 187 // acquired. |
| 188 void InitializeExperimentalAgc() |
| 189 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 190 void InitializeTransient() |
| 191 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 192 void InitializeBeamformer() |
| 193 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 194 void InitializeIntelligibility() |
| 195 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 123 int InitializeLocked(const ProcessingConfig& config) | 196 int InitializeLocked(const ProcessingConfig& config) |
| 124 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 197 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 125 int MaybeInitializeLockedRender(const ProcessingConfig& config) | 198 |
| 126 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 199 // Capture-side exclusive methods possibly running APM in a multi-threaded |
| 127 int MaybeInitializeLockedCapture(const ProcessingConfig& config) | 200 // manner that are called with the render lock already acquired. |
| 128 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 201 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 129 int MaybeInitializeLocked(const ProcessingConfig& config) | 202 bool output_copy_needed(bool is_data_processed) const |
| 130 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 203 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 204 bool is_data_processed() const EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 205 bool synthesis_needed(bool is_data_processed) const |
| 206 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 207 bool analysis_needed(bool is_data_processed) const |
| 208 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 209 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 210 |
| 211 // Render-side exclusive methods possibly running APM in a multi-threaded |
| 212 // manner that are called with the render lock already acquired. |
| 131 // TODO(ekm): Remove once all clients updated to new interface. | 213 // TODO(ekm): Remove once all clients updated to new interface. |
| 132 int AnalyzeReverseStream(const float* const* src, | 214 int AnalyzeReverseStreamLocked(const float* const* src, |
| 133 const StreamConfig& input_config, | 215 const StreamConfig& input_config, |
| 134 const StreamConfig& output_config); | 216 const StreamConfig& output_config) |
| 135 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 217 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 136 int ProcessReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 218 bool is_rev_processed() const EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 137 | 219 int ProcessReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 138 bool is_data_processed() const; | 220 |
| 139 bool output_copy_needed(bool is_data_processed) const; | 221 // Debug dump methods that are internal and called without locks. |
| 140 bool synthesis_needed(bool is_data_processed) const; | 222 // TODO(peah): Make thread safe. |
| 141 bool analysis_needed(bool is_data_processed) const; | |
| 142 bool is_rev_processed() const; | |
| 143 bool rev_conversion_needed() const; | |
| 144 // TODO(peah): Add EXCLUSIVE_LOCKS_REQUIRED for the method below. | |
| 145 bool render_check_rev_conversion_needed() const; | |
| 146 void InitializeExperimentalAgc() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 147 void InitializeTransient() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 148 void InitializeBeamformer() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 149 void InitializeIntelligibility() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 150 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 151 | |
| 152 EchoCancellationImpl* echo_cancellation_; | |
| 153 EchoControlMobileImpl* echo_control_mobile_; | |
| 154 GainControlImpl* gain_control_; | |
| 155 HighPassFilterImpl* high_pass_filter_; | |
| 156 LevelEstimatorImpl* level_estimator_; | |
| 157 NoiseSuppressionImpl* noise_suppression_; | |
| 158 VoiceDetectionImpl* voice_detection_; | |
| 159 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc_; | |
| 160 | |
| 161 std::list<ProcessingComponent*> component_list_; | |
| 162 CriticalSectionWrapper* crit_; | |
| 163 rtc::scoped_ptr<AudioBuffer> render_audio_; | |
| 164 rtc::scoped_ptr<AudioBuffer> capture_audio_; | |
| 165 rtc::scoped_ptr<AudioConverter> render_converter_; | |
| 166 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 223 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 167 // TODO(andrew): make this more graceful. Ideally we would split this stuff | 224 // TODO(andrew): make this more graceful. Ideally we would split this stuff |
| 168 // out into a separate class with an "enabled" and "disabled" implementation. | 225 // out into a separate class with an "enabled" and "disabled" implementation. |
| 169 int WriteMessageToDebugFile(); | 226 static int WriteMessageToDebugFile(FileWrapper* debug_file, |
| 170 int WriteInitMessage(); | 227 rtc::CriticalSection* crit_debug, |
| 228 ApmDebugDumpThreadState* debug_state); |
| 229 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 171 | 230 |
| 172 // Writes Config message. If not |forced|, only writes the current config if | 231 // Writes Config message. If not |forced|, only writes the current config if |
| 173 // it is different from the last saved one; if |forced|, writes the config | 232 // it is different from the last saved one; if |forced|, writes the config |
| 174 // regardless of the last saved. | 233 // regardless of the last saved. |
| 175 int WriteConfigMessage(bool forced); | 234 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) |
| 176 | 235 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 177 rtc::scoped_ptr<FileWrapper> debug_file_; | 236 |
| 178 rtc::scoped_ptr<audioproc::Event> event_msg_; // Protobuf message. | 237 // Critical section. |
| 179 std::string event_str_; // Memory for protobuf serialization. | 238 mutable rtc::CriticalSection crit_debug_; |
| 180 | 239 |
| 181 // Serialized string of last saved APM configuration. | 240 // Debug dump state. |
| 182 std::string last_serialized_config_; | 241 ApmDebugDumpState debug_dump_; |
| 183 #endif | 242 #endif |
| 184 | 243 |
| 244 // Critical sections. |
| 245 mutable rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); |
| 246 mutable rtc::CriticalSection crit_capture_; |
| 247 |
| 248 // Structs containing the pointers to the submodules. |
| 249 rtc::scoped_ptr<ApmPublicSubmodules> public_submodules_; |
| 250 rtc::scoped_ptr<ApmPrivateSubmodules> private_submodules_ |
| 251 GUARDED_BY(crit_capture_); |
| 252 |
| 185 // State that is written to while holding both the render and capture locks | 253 // State that is written to while holding both the render and capture locks |
| 186 // but can be read while holding only one of the locks. | 254 // but can be read without any lock being held. |
| 187 struct SharedState { | 255 // As this is only accessed internally of APM, and all internal methods in APM |
| 188 SharedState() | 256 // either are holding the render or capture locks, this construct is safe as |
| 257 // it is not possible to read the variables while writing them. |
| 258 struct ApmFormatState { |
| 259 ApmFormatState() |
| 189 : // Format of processing streams at input/output call sites. | 260 : // Format of processing streams at input/output call sites. |
| 190 api_format_({{{kSampleRate16kHz, 1, false}, | 261 api_format({{{kSampleRate16kHz, 1, false}, |
| 191 {kSampleRate16kHz, 1, false}, | 262 {kSampleRate16kHz, 1, false}, |
| 192 {kSampleRate16kHz, 1, false}, | 263 {kSampleRate16kHz, 1, false}, |
| 193 {kSampleRate16kHz, 1, false}}}) {} | 264 {kSampleRate16kHz, 1, false}}}), |
| 194 ProcessingConfig api_format_; | 265 rev_proc_format(kSampleRate16kHz, 1) {} |
| 195 } shared_state_; | 266 ProcessingConfig api_format; |
| 196 | 267 StreamConfig rev_proc_format; |
| 197 // Only the rate and samples fields of fwd_proc_format_ are used because the | 268 } formats_; |
| 198 // forward processing number of channels is mutable and is tracked by the | 269 |
| 199 // capture_audio_. | 270 // APM constants. |
| 200 StreamConfig fwd_proc_format_; | 271 const struct ApmConstants { |
| 201 StreamConfig rev_proc_format_; | 272 ApmConstants(int agc_startup_min_volume, |
| 202 int split_rate_; | 273 const std::vector<Point> array_geometry, |
| 203 | 274 SphericalPointf target_direction, |
| 204 int stream_delay_ms_; | 275 bool use_new_agc, |
| 205 int delay_offset_ms_; | 276 bool intelligibility_enabled, |
| 206 bool was_stream_delay_set_; | 277 bool beamformer_enabled) |
| 207 int last_stream_delay_ms_; | 278 : // Format of processing streams at input/output call sites. |
| 208 int last_aec_system_delay_ms_; | 279 agc_startup_min_volume(agc_startup_min_volume), |
| 209 int stream_delay_jumps_; | 280 array_geometry(array_geometry), |
| 210 int aec_system_delay_jumps_; | 281 target_direction(target_direction), |
| 211 | 282 use_new_agc(use_new_agc), |
| 212 bool output_will_be_muted_ GUARDED_BY(crit_); | 283 intelligibility_enabled(intelligibility_enabled), |
| 213 | 284 beamformer_enabled(beamformer_enabled) {} |
| 214 bool key_pressed_; | 285 int agc_startup_min_volume; |
| 215 | 286 std::vector<Point> array_geometry; |
| 216 // Only set through the constructor's Config parameter. | 287 SphericalPointf target_direction; |
| 217 const bool use_new_agc_; | 288 bool use_new_agc; |
| 218 rtc::scoped_ptr<AgcManagerDirect> agc_manager_ GUARDED_BY(crit_); | 289 bool intelligibility_enabled; |
| 219 int agc_startup_min_volume_; | 290 bool beamformer_enabled; |
| 220 | 291 } constants_; |
| 221 bool transient_suppressor_enabled_; | 292 |
| 222 rtc::scoped_ptr<TransientSuppressor> transient_suppressor_; | 293 struct ApmCaptureState { |
| 223 const bool beamformer_enabled_; | 294 ApmCaptureState(bool transient_suppressor_enabled) |
| 224 rtc::scoped_ptr<Beamformer<float>> beamformer_; | 295 : aec_system_delay_jumps(-1), |
| 225 const std::vector<Point> array_geometry_; | 296 delay_offset_ms(0), |
| 226 const SphericalPointf target_direction_; | 297 was_stream_delay_set(false), |
| 227 | 298 last_stream_delay_ms(0), |
| 228 bool intelligibility_enabled_; | 299 last_aec_system_delay_ms(0), |
| 229 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer_; | 300 stream_delay_jumps(-1), |
| 301 output_will_be_muted(false), |
| 302 key_pressed(false), |
| 303 transient_suppressor_enabled(transient_suppressor_enabled), |
| 304 fwd_proc_format(kSampleRate16kHz), |
| 305 split_rate(kSampleRate16kHz) {} |
| 306 int aec_system_delay_jumps; |
| 307 int delay_offset_ms; |
| 308 bool was_stream_delay_set; |
| 309 int last_stream_delay_ms; |
| 310 int last_aec_system_delay_ms; |
| 311 int stream_delay_jumps; |
| 312 bool output_will_be_muted; |
| 313 bool key_pressed; |
| 314 bool transient_suppressor_enabled; |
| 315 rtc::scoped_ptr<AudioBuffer> capture_audio; |
| 316 // Only the rate and samples fields of fwd_proc_format_ are used because the |
| 317 // forward processing number of channels is mutable and is tracked by the |
| 318 // capture_audio_. |
| 319 StreamConfig fwd_proc_format; |
| 320 int split_rate; |
| 321 } capture_ GUARDED_BY(crit_capture_); |
| 322 |
| 323 struct ApmCaptureNonLockedState { |
| 324 ApmCaptureNonLockedState() |
| 325 : fwd_proc_format(kSampleRate16kHz), |
| 326 split_rate(kSampleRate16kHz), |
| 327 stream_delay_ms(0) {} |
| 328 // Only the rate and samples fields of fwd_proc_format_ are used because the |
| 329 // forward processing number of channels is mutable and is tracked by the |
| 330 // capture_audio_. |
| 331 StreamConfig fwd_proc_format; |
| 332 int split_rate; |
| 333 int stream_delay_ms; |
| 334 } capture_nonlocked_; |
| 335 |
| 336 struct ApmRenderState { |
| 337 rtc::scoped_ptr<AudioConverter> render_converter; |
| 338 rtc::scoped_ptr<AudioBuffer> render_audio; |
| 339 } render_ GUARDED_BY(crit_render_); |
| 230 }; | 340 }; |
| 231 | 341 |
| 232 } // namespace webrtc | 342 } // namespace webrtc |
| 233 | 343 |
| 234 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 344 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
| OLD | NEW |