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 <memory> | 15 #include <memory> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
19 #include "webrtc/base/function_view.h" | 19 #include "webrtc/base/function_view.h" |
20 #include "webrtc/base/gtest_prod_util.h" | 20 #include "webrtc/base/gtest_prod_util.h" |
21 #include "webrtc/base/ignore_wundef.h" | 21 #include "webrtc/base/ignore_wundef.h" |
22 #include "webrtc/base/protobuf_utils.h" | 22 #include "webrtc/base/protobuf_utils.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 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
32 // *.pb.h files are generated at build-time by the protobuf compiler. | 33 // *.pb.h files are generated at build-time by the protobuf compiler. |
33 RTC_PUSH_IGNORING_WUNDEF() | 34 RTC_PUSH_IGNORING_WUNDEF() |
34 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 35 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
35 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" | 36 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" |
(...skipping 23 matching lines...) Expand all Loading... |
59 int Initialize(int capture_input_sample_rate_hz, | 60 int Initialize(int capture_input_sample_rate_hz, |
60 int capture_output_sample_rate_hz, | 61 int capture_output_sample_rate_hz, |
61 int render_sample_rate_hz, | 62 int render_sample_rate_hz, |
62 ChannelLayout capture_input_layout, | 63 ChannelLayout capture_input_layout, |
63 ChannelLayout capture_output_layout, | 64 ChannelLayout capture_output_layout, |
64 ChannelLayout render_input_layout) override; | 65 ChannelLayout render_input_layout) override; |
65 int Initialize(const ProcessingConfig& processing_config) override; | 66 int Initialize(const ProcessingConfig& processing_config) override; |
66 void ApplyConfig(const AudioProcessing::Config& config) override; | 67 void ApplyConfig(const AudioProcessing::Config& config) override; |
67 void SetExtraOptions(const webrtc::Config& config) override; | 68 void SetExtraOptions(const webrtc::Config& config) override; |
68 void UpdateHistogramsOnCallEnd() override; | 69 void UpdateHistogramsOnCallEnd() override; |
| 70 void AttachAecDump(std::unique_ptr<AecDump> aec_dump) override; |
| 71 void DetachAecDump() override; |
69 int StartDebugRecording(const char filename[kMaxFilenameSize], | 72 int StartDebugRecording(const char filename[kMaxFilenameSize], |
70 int64_t max_log_size_bytes) override; | 73 int64_t max_log_size_bytes) override; |
71 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override; | 74 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override; |
72 int StartDebugRecording(FILE* handle) override; | 75 int StartDebugRecording(FILE* handle) override; |
73 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; | 76 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; |
74 int StopDebugRecording() override; | 77 int StopDebugRecording() override; |
75 | 78 |
76 // Capture-side exclusive methods possibly running APM in a | 79 // Capture-side exclusive methods possibly running APM in a |
77 // multi-threaded manner. Acquire the capture lock. | 80 // multi-threaded manner. Acquire the capture lock. |
78 int ProcessStream(AudioFrame* frame) override; | 81 int ProcessStream(AudioFrame* frame) override; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 273 |
271 // Render-side exclusive methods possibly running APM in a multi-threaded | 274 // Render-side exclusive methods possibly running APM in a multi-threaded |
272 // manner that are called with the render lock already acquired. | 275 // manner that are called with the render lock already acquired. |
273 // TODO(ekm): Remove once all clients updated to new interface. | 276 // TODO(ekm): Remove once all clients updated to new interface. |
274 int AnalyzeReverseStreamLocked(const float* const* src, | 277 int AnalyzeReverseStreamLocked(const float* const* src, |
275 const StreamConfig& input_config, | 278 const StreamConfig& input_config, |
276 const StreamConfig& output_config) | 279 const StreamConfig& output_config) |
277 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | 280 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
278 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | 281 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
279 | 282 |
| 283 // Collects configuration settings from public and private |
| 284 // submodules to be saved as an audioproc::Config message. |
| 285 InternalAPMConfig CollectApmConfig() const |
| 286 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) |
| 287 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 288 |
| 289 // Notifies attached AecDump of current configuration and capture data. |
| 290 void RecordUnprocessedCaptureStream(const float* const* capture_stream) |
| 291 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 292 |
| 293 void RecordUnprocessedCaptureStream(const AudioFrame& capture_frame) |
| 294 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 295 |
| 296 // Notifies attached AecDump of current configuration and |
| 297 // processed capture data and issues a capture stream recording |
| 298 // request. |
| 299 void RecordProcessedCaptureStream( |
| 300 const float* const* processed_capture_stream) |
| 301 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 302 |
| 303 void RecordProcessedCaptureStream(const AudioFrame& processed_capture_frame) |
| 304 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 305 |
| 306 // Notifies attached AecDump about current state (delay, drift, etc). |
| 307 void RecordAudioProcessingState() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 308 |
280 // Debug dump methods that are internal and called without locks. | 309 // Debug dump methods that are internal and called without locks. |
281 // TODO(peah): Make thread safe. | 310 // TODO(peah): Make thread safe. |
282 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 311 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
283 // TODO(andrew): make this more graceful. Ideally we would split this stuff | 312 // TODO(andrew): make this more graceful. Ideally we would split this stuff |
284 // out into a separate class with an "enabled" and "disabled" implementation. | 313 // out into a separate class with an "enabled" and "disabled" implementation. |
285 static int WriteMessageToDebugFile(FileWrapper* debug_file, | 314 static int WriteMessageToDebugFile(FileWrapper* debug_file, |
286 int64_t* filesize_limit_bytes, | 315 int64_t* filesize_limit_bytes, |
287 rtc::CriticalSection* crit_debug, | 316 rtc::CriticalSection* crit_debug, |
288 ApmDebugDumpThreadState* debug_state); | 317 ApmDebugDumpThreadState* debug_state); |
289 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 318 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
290 | 319 |
291 // Writes Config message. If not |forced|, only writes the current config if | 320 // Writes Config message. If not |forced|, only writes the current config if |
292 // it is different from the last saved one; if |forced|, writes the config | 321 // it is different from the last saved one; if |forced|, writes the config |
293 // regardless of the last saved. | 322 // regardless of the last saved. |
294 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) | 323 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) |
295 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | 324 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
296 | 325 |
297 // Critical section. | 326 // Critical section. |
298 rtc::CriticalSection crit_debug_; | 327 rtc::CriticalSection crit_debug_; |
299 | 328 |
300 // Debug dump state. | 329 // Debug dump state. |
301 ApmDebugDumpState debug_dump_; | 330 ApmDebugDumpState debug_dump_; |
302 #endif | 331 #endif |
303 | 332 |
| 333 // AecDump instance used for optionally logging APM config, input |
| 334 // and output to file in the AEC-dump format defined in debug.proto. |
| 335 std::unique_ptr<AecDump> aec_dump_; |
| 336 |
304 // Critical sections. | 337 // Critical sections. |
305 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); | 338 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); |
306 rtc::CriticalSection crit_capture_; | 339 rtc::CriticalSection crit_capture_; |
307 | 340 |
308 // Struct containing the Config specifying the behavior of APM. | 341 // Struct containing the Config specifying the behavior of APM. |
309 AudioProcessing::Config config_; | 342 AudioProcessing::Config config_; |
310 | 343 |
311 // Class containing information about what submodules are active. | 344 // Class containing information about what submodules are active. |
312 ApmSubmoduleStates submodule_states_; | 345 ApmSubmoduleStates submodule_states_; |
313 | 346 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 std::unique_ptr< | 465 std::unique_ptr< |
433 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> | 466 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> |
434 agc_render_signal_queue_; | 467 agc_render_signal_queue_; |
435 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> | 468 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> |
436 red_render_signal_queue_; | 469 red_render_signal_queue_; |
437 }; | 470 }; |
438 | 471 |
439 } // namespace webrtc | 472 } // namespace webrtc |
440 | 473 |
441 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 474 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
OLD | NEW |