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

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

Issue 2747123007: Test submission of complete AEC-dump refactoring. (Closed)
Patch Set: Changed interface and build structure after reviewer comments. Created 3 years, 8 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 <memory> 15 #include <memory>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/criticalsection.h" 19 #include "webrtc/base/criticalsection.h"
20 #include "webrtc/base/function_view.h" 20 #include "webrtc/base/function_view.h"
21 #include "webrtc/base/gtest_prod_util.h" 21 #include "webrtc/base/gtest_prod_util.h"
22 #include "webrtc/base/ignore_wundef.h" 22 #include "webrtc/base/ignore_wundef.h"
23 #include "webrtc/base/swap_queue.h" 23 #include "webrtc/base/swap_queue.h"
24 #include "webrtc/base/thread_annotations.h" 24 #include "webrtc/base/thread_annotations.h"
25 #include "webrtc/modules/audio_processing/audio_buffer.h" 25 #include "webrtc/modules/audio_processing/audio_buffer.h"
26 #include "webrtc/modules/audio_processing/include/aec_dump.h"
26 #include "webrtc/modules/audio_processing/include/audio_processing.h" 27 #include "webrtc/modules/audio_processing/include/audio_processing.h"
27 #include "webrtc/modules/audio_processing/render_queue_item_verifier.h" 28 #include "webrtc/modules/audio_processing/render_queue_item_verifier.h"
28 #include "webrtc/modules/audio_processing/rms_level.h" 29 #include "webrtc/modules/audio_processing/rms_level.h"
29 #include "webrtc/system_wrappers/include/file_wrapper.h" 30 #include "webrtc/system_wrappers/include/file_wrapper.h"
30 31
31 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
32 // Files generated at build-time by the protobuf compiler.
33 RTC_PUSH_IGNORING_WUNDEF()
34 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
35 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
36 #else
37 #include "webrtc/modules/audio_processing/debug.pb.h"
38 #endif
39 RTC_POP_IGNORING_WUNDEF()
40 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
41
42 namespace webrtc { 32 namespace webrtc {
43 33
44 class AgcManagerDirect; 34 class AgcManagerDirect;
45 class AudioConverter; 35 class AudioConverter;
46 36
47 class NonlinearBeamformer; 37 class NonlinearBeamformer;
48 38
49 class AudioProcessingImpl : public AudioProcessing { 39 class AudioProcessingImpl : public AudioProcessing {
50 public: 40 public:
51 // Methods forcing APM to run in a single-threaded manner. 41 // Methods forcing APM to run in a single-threaded manner.
52 // Acquires both the render and capture locks. 42 // Acquires both the render and capture locks.
53 explicit AudioProcessingImpl(const webrtc::Config& config); 43 explicit AudioProcessingImpl(const webrtc::Config& config);
54 // AudioProcessingImpl takes ownership of beamformer. 44 // AudioProcessingImpl takes ownership of beamformer.
55 AudioProcessingImpl(const webrtc::Config& config, 45 AudioProcessingImpl(const webrtc::Config& config,
56 NonlinearBeamformer* beamformer); 46 NonlinearBeamformer* beamformer);
57 ~AudioProcessingImpl() override; 47 ~AudioProcessingImpl() override;
58 int Initialize() override; 48 int Initialize() override;
59 int Initialize(int capture_input_sample_rate_hz, 49 int Initialize(int capture_input_sample_rate_hz,
60 int capture_output_sample_rate_hz, 50 int capture_output_sample_rate_hz,
61 int render_sample_rate_hz, 51 int render_sample_rate_hz,
62 ChannelLayout capture_input_layout, 52 ChannelLayout capture_input_layout,
63 ChannelLayout capture_output_layout, 53 ChannelLayout capture_output_layout,
64 ChannelLayout render_input_layout) override; 54 ChannelLayout render_input_layout) override;
65 int Initialize(const ProcessingConfig& processing_config) override; 55 int Initialize(const ProcessingConfig& processing_config) override;
66 void ApplyConfig(const AudioProcessing::Config& config) override; 56 void ApplyConfig(const AudioProcessing::Config& config) override;
67 void SetExtraOptions(const webrtc::Config& config) override; 57 void SetExtraOptions(const webrtc::Config& config) override;
68 void UpdateHistogramsOnCallEnd() override; 58 void UpdateHistogramsOnCallEnd() override;
69 int StartDebugRecording(const char filename[kMaxFilenameSize], 59 void StartDebugRecording(std::unique_ptr<AecDump> aec_dump) override;
70 int64_t max_log_size_bytes) override; 60 void StopDebugRecording() override;
71 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override;
72 int StartDebugRecording(FILE* handle) override;
73 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override;
74 int StopDebugRecording() override;
75 61
76 // Capture-side exclusive methods possibly running APM in a 62 // Capture-side exclusive methods possibly running APM in a
77 // multi-threaded manner. Acquire the capture lock. 63 // multi-threaded manner. Acquire the capture lock.
78 int ProcessStream(AudioFrame* frame) override; 64 int ProcessStream(AudioFrame* frame) override;
79 int ProcessStream(const float* const* src, 65 int ProcessStream(const float* const* src,
80 size_t samples_per_channel, 66 size_t samples_per_channel,
81 int input_sample_rate_hz, 67 int input_sample_rate_hz,
82 ChannelLayout input_layout, 68 ChannelLayout input_layout,
83 int output_sample_rate_hz, 69 int output_sample_rate_hz,
84 ChannelLayout output_layout, 70 ChannelLayout output_layout,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 254
269 // Render-side exclusive methods possibly running APM in a multi-threaded 255 // Render-side exclusive methods possibly running APM in a multi-threaded
270 // manner that are called with the render lock already acquired. 256 // manner that are called with the render lock already acquired.
271 // TODO(ekm): Remove once all clients updated to new interface. 257 // TODO(ekm): Remove once all clients updated to new interface.
272 int AnalyzeReverseStreamLocked(const float* const* src, 258 int AnalyzeReverseStreamLocked(const float* const* src,
273 const StreamConfig& input_config, 259 const StreamConfig& input_config,
274 const StreamConfig& output_config) 260 const StreamConfig& output_config)
275 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 261 EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
276 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 262 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
277 263
278 // Debug dump methods that are internal and called without locks. 264 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
279 // TODO(peah): Make thread safe.
280 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
281 // TODO(andrew): make this more graceful. Ideally we would split this stuff
282 // out into a separate class with an "enabled" and "disabled" implementation.
283 static int WriteMessageToDebugFile(FileWrapper* debug_file,
284 int64_t* filesize_limit_bytes,
285 rtc::CriticalSection* crit_debug,
286 ApmDebugDumpThreadState* debug_state);
287 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
288 265
289 // Writes Config message. If not |forced|, only writes the current config if 266 // TODO(aleloi) doc.
290 // it is different from the last saved one; if |forced|, writes the config 267 std::unique_ptr<AecDump> aec_dump_;
291 // regardless of the last saved.
292 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_)
293 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
294
295 // Critical section.
296 rtc::CriticalSection crit_debug_;
297
298 // Debug dump state.
299 ApmDebugDumpState debug_dump_;
300 #endif
301 268
302 // Critical sections. 269 // Critical sections.
303 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); 270 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_);
304 rtc::CriticalSection crit_capture_; 271 rtc::CriticalSection crit_capture_;
305 272
306 // Struct containing the Config specifying the behavior of APM. 273 // Struct containing the Config specifying the behavior of APM.
307 AudioProcessing::Config config_; 274 AudioProcessing::Config config_;
308 275
309 // Class containing information about what submodules are active. 276 // Class containing information about what submodules are active.
310 ApmSubmoduleStates submodule_states_; 277 ApmSubmoduleStates submodule_states_;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 std::unique_ptr< 395 std::unique_ptr<
429 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> 396 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
430 agc_render_signal_queue_; 397 agc_render_signal_queue_;
431 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> 398 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
432 red_render_signal_queue_; 399 red_render_signal_queue_;
433 }; 400 };
434 401
435 } // namespace webrtc 402 } // namespace webrtc
436 403
437 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ 404 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698