Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.h

Issue 1253573005: Revert of Allow more than 2 input channels in AudioProcessing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
17 16
18 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/base/thread_annotations.h" 18 #include "webrtc/base/thread_annotations.h"
20 #include "webrtc/modules/audio_processing/include/audio_processing.h" 19 #include "webrtc/modules/audio_processing/include/audio_processing.h"
21 20
22 namespace webrtc { 21 namespace webrtc {
23 22
24 class AgcManagerDirect; 23 class AgcManagerDirect;
25 class AudioBuffer; 24 class AudioBuffer;
26 25
(...skipping 14 matching lines...) Expand all
41 class VoiceDetectionImpl; 40 class VoiceDetectionImpl;
42 41
43 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 42 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
44 namespace audioproc { 43 namespace audioproc {
45 44
46 class Event; 45 class Event;
47 46
48 } // namespace audioproc 47 } // namespace audioproc
49 #endif 48 #endif
50 49
50 class AudioRate {
51 public:
52 explicit AudioRate(int sample_rate_hz) { set(sample_rate_hz); }
53 virtual ~AudioRate() {}
54
55 void set(int rate) {
56 rate_ = rate;
57 samples_per_channel_ = AudioProcessing::kChunkSizeMs * rate_ / 1000;
58 }
59
60 int rate() const { return rate_; }
61 int samples_per_channel() const { return samples_per_channel_; }
62
63 private:
64 int rate_;
65 int samples_per_channel_;
66 };
67
68 class AudioFormat : public AudioRate {
69 public:
70 AudioFormat(int sample_rate_hz, int num_channels)
71 : AudioRate(sample_rate_hz),
72 num_channels_(num_channels) {}
73 virtual ~AudioFormat() {}
74
75 void set(int rate, int num_channels) {
76 AudioRate::set(rate);
77 num_channels_ = num_channels;
78 }
79
80 int num_channels() const { return num_channels_; }
81
82 private:
83 int num_channels_;
84 };
85
51 class AudioProcessingImpl : public AudioProcessing { 86 class AudioProcessingImpl : public AudioProcessing {
52 public: 87 public:
53 explicit AudioProcessingImpl(const Config& config); 88 explicit AudioProcessingImpl(const Config& config);
54 89
55 // AudioProcessingImpl takes ownership of beamformer. 90 // AudioProcessingImpl takes ownership of beamformer.
56 AudioProcessingImpl(const Config& config, Beamformer<float>* beamformer); 91 AudioProcessingImpl(const Config& config, Beamformer<float>* beamformer);
57 virtual ~AudioProcessingImpl(); 92 virtual ~AudioProcessingImpl();
58 93
59 // AudioProcessing methods. 94 // AudioProcessing methods.
60 int Initialize() override; 95 int Initialize() override;
61 int Initialize(int input_sample_rate_hz, 96 int Initialize(int input_sample_rate_hz,
62 int output_sample_rate_hz, 97 int output_sample_rate_hz,
63 int reverse_sample_rate_hz, 98 int reverse_sample_rate_hz,
64 ChannelLayout input_layout, 99 ChannelLayout input_layout,
65 ChannelLayout output_layout, 100 ChannelLayout output_layout,
66 ChannelLayout reverse_layout) override; 101 ChannelLayout reverse_layout) override;
67 int Initialize(const ProcessingConfig& processing_config) override;
68 void SetExtraOptions(const Config& config) override; 102 void SetExtraOptions(const Config& config) override;
69 int set_sample_rate_hz(int rate) override; 103 int set_sample_rate_hz(int rate) override;
70 int input_sample_rate_hz() const override; 104 int input_sample_rate_hz() const override;
71 int sample_rate_hz() const override; 105 int sample_rate_hz() const override;
72 int proc_sample_rate_hz() const override; 106 int proc_sample_rate_hz() const override;
73 int proc_split_sample_rate_hz() const override; 107 int proc_split_sample_rate_hz() const override;
74 int num_input_channels() const override; 108 int num_input_channels() const override;
75 int num_output_channels() const override; 109 int num_output_channels() const override;
76 int num_reverse_channels() const override; 110 int num_reverse_channels() const override;
77 void set_output_will_be_muted(bool muted) override; 111 void set_output_will_be_muted(bool muted) override;
78 bool output_will_be_muted() const override; 112 bool output_will_be_muted() const override;
79 int ProcessStream(AudioFrame* frame) override; 113 int ProcessStream(AudioFrame* frame) override;
80 int ProcessStream(const float* const* src, 114 int ProcessStream(const float* const* src,
81 int samples_per_channel, 115 int samples_per_channel,
82 int input_sample_rate_hz, 116 int input_sample_rate_hz,
83 ChannelLayout input_layout, 117 ChannelLayout input_layout,
84 int output_sample_rate_hz, 118 int output_sample_rate_hz,
85 ChannelLayout output_layout, 119 ChannelLayout output_layout,
86 float* const* dest) override; 120 float* const* dest) override;
87 int ProcessStream(const float* const* src,
88 const StreamConfig& input_config,
89 const StreamConfig& output_config,
90 float* const* dest) override;
91 int AnalyzeReverseStream(AudioFrame* frame) override; 121 int AnalyzeReverseStream(AudioFrame* frame) override;
92 int AnalyzeReverseStream(const float* const* data, 122 int AnalyzeReverseStream(const float* const* data,
93 int samples_per_channel, 123 int samples_per_channel,
94 int sample_rate_hz, 124 int sample_rate_hz,
95 ChannelLayout layout) override; 125 ChannelLayout layout) override;
96 int AnalyzeReverseStream(const float* const* data,
97 const StreamConfig& reverse_config) override;
98 int set_stream_delay_ms(int delay) override; 126 int set_stream_delay_ms(int delay) override;
99 int stream_delay_ms() const override; 127 int stream_delay_ms() const override;
100 bool was_stream_delay_set() const override; 128 bool was_stream_delay_set() const override;
101 void set_delay_offset_ms(int offset) override; 129 void set_delay_offset_ms(int offset) override;
102 int delay_offset_ms() const override; 130 int delay_offset_ms() const override;
103 void set_stream_key_pressed(bool key_pressed) override; 131 void set_stream_key_pressed(bool key_pressed) override;
104 bool stream_key_pressed() const override; 132 bool stream_key_pressed() const override;
105 int StartDebugRecording(const char filename[kMaxFilenameSize]) override; 133 int StartDebugRecording(const char filename[kMaxFilenameSize]) override;
106 int StartDebugRecording(FILE* handle) override; 134 int StartDebugRecording(FILE* handle) override;
107 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; 135 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override;
108 int StopDebugRecording() override; 136 int StopDebugRecording() override;
109 void UpdateHistogramsOnCallEnd() override; 137 void UpdateHistogramsOnCallEnd() override;
110 EchoCancellation* echo_cancellation() const override; 138 EchoCancellation* echo_cancellation() const override;
111 EchoControlMobile* echo_control_mobile() const override; 139 EchoControlMobile* echo_control_mobile() const override;
112 GainControl* gain_control() const override; 140 GainControl* gain_control() const override;
113 HighPassFilter* high_pass_filter() const override; 141 HighPassFilter* high_pass_filter() const override;
114 LevelEstimator* level_estimator() const override; 142 LevelEstimator* level_estimator() const override;
115 NoiseSuppression* noise_suppression() const override; 143 NoiseSuppression* noise_suppression() const override;
116 VoiceDetection* voice_detection() const override; 144 VoiceDetection* voice_detection() const override;
117 145
118 protected: 146 protected:
119 // Overridden in a mock. 147 // Overridden in a mock.
120 virtual int InitializeLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); 148 virtual int InitializeLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_);
121 149
122 private: 150 private:
123 int InitializeLocked(const ProcessingConfig& config) 151 int InitializeLocked(int input_sample_rate_hz,
152 int output_sample_rate_hz,
153 int reverse_sample_rate_hz,
154 int num_input_channels,
155 int num_output_channels,
156 int num_reverse_channels)
124 EXCLUSIVE_LOCKS_REQUIRED(crit_); 157 EXCLUSIVE_LOCKS_REQUIRED(crit_);
125 int MaybeInitializeLocked(const ProcessingConfig& config) 158 int MaybeInitializeLocked(int input_sample_rate_hz,
159 int output_sample_rate_hz,
160 int reverse_sample_rate_hz,
161 int num_input_channels,
162 int num_output_channels,
163 int num_reverse_channels)
126 EXCLUSIVE_LOCKS_REQUIRED(crit_); 164 EXCLUSIVE_LOCKS_REQUIRED(crit_);
127 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); 165 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_);
128 int AnalyzeReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); 166 int AnalyzeReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_);
129 167
130 bool is_data_processed() const; 168 bool is_data_processed() const;
131 bool output_copy_needed(bool is_data_processed) const; 169 bool output_copy_needed(bool is_data_processed) const;
132 bool synthesis_needed(bool is_data_processed) const; 170 bool synthesis_needed(bool is_data_processed) const;
133 bool analysis_needed(bool is_data_processed) const; 171 bool analysis_needed(bool is_data_processed) const;
134 void InitializeExperimentalAgc() EXCLUSIVE_LOCKS_REQUIRED(crit_); 172 void InitializeExperimentalAgc() EXCLUSIVE_LOCKS_REQUIRED(crit_);
135 void InitializeTransient() EXCLUSIVE_LOCKS_REQUIRED(crit_); 173 void InitializeTransient() EXCLUSIVE_LOCKS_REQUIRED(crit_);
(...skipping 16 matching lines...) Expand all
152 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 190 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
153 // TODO(andrew): make this more graceful. Ideally we would split this stuff 191 // TODO(andrew): make this more graceful. Ideally we would split this stuff
154 // out into a separate class with an "enabled" and "disabled" implementation. 192 // out into a separate class with an "enabled" and "disabled" implementation.
155 int WriteMessageToDebugFile(); 193 int WriteMessageToDebugFile();
156 int WriteInitMessage(); 194 int WriteInitMessage();
157 rtc::scoped_ptr<FileWrapper> debug_file_; 195 rtc::scoped_ptr<FileWrapper> debug_file_;
158 rtc::scoped_ptr<audioproc::Event> event_msg_; // Protobuf message. 196 rtc::scoped_ptr<audioproc::Event> event_msg_; // Protobuf message.
159 std::string event_str_; // Memory for protobuf serialization. 197 std::string event_str_; // Memory for protobuf serialization.
160 #endif 198 #endif
161 199
162 // Format of processing streams at input/output call sites. 200 AudioFormat fwd_in_format_;
163 ProcessingConfig api_format_; 201 // This one is an AudioRate, because the forward processing number of channels
164 202 // is mutable and is tracked by the capture_audio_.
165 // Only the rate and samples fields of fwd_proc_format_ are used because the 203 AudioRate fwd_proc_format_;
166 // forward processing number of channels is mutable and is tracked by the 204 AudioFormat fwd_out_format_;
167 // capture_audio_. 205 AudioFormat rev_in_format_;
168 StreamConfig fwd_proc_format_; 206 AudioFormat rev_proc_format_;
169 StreamConfig rev_proc_format_;
170 int split_rate_; 207 int split_rate_;
171 208
172 int stream_delay_ms_; 209 int stream_delay_ms_;
173 int delay_offset_ms_; 210 int delay_offset_ms_;
174 bool was_stream_delay_set_; 211 bool was_stream_delay_set_;
175 int last_stream_delay_ms_; 212 int last_stream_delay_ms_;
176 int last_aec_system_delay_ms_; 213 int last_aec_system_delay_ms_;
177 int stream_delay_jumps_; 214 int stream_delay_jumps_;
178 int aec_system_delay_jumps_; 215 int aec_system_delay_jumps_;
179 216
(...skipping 11 matching lines...) Expand all
191 const bool beamformer_enabled_; 228 const bool beamformer_enabled_;
192 rtc::scoped_ptr<Beamformer<float>> beamformer_; 229 rtc::scoped_ptr<Beamformer<float>> beamformer_;
193 const std::vector<Point> array_geometry_; 230 const std::vector<Point> array_geometry_;
194 231
195 const bool supports_48kHz_; 232 const bool supports_48kHz_;
196 }; 233 };
197 234
198 } // namespace webrtc 235 } // namespace webrtc
199 236
200 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ 237 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_buffer.cc ('k') | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698