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