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