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

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

Issue 2778783002: AecDump interface (Closed)
Patch Set: Comment formatting. Created 3 years, 7 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 <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 21 matching lines...) Expand all
57 int Initialize(int capture_input_sample_rate_hz, 58 int Initialize(int capture_input_sample_rate_hz,
58 int capture_output_sample_rate_hz, 59 int capture_output_sample_rate_hz,
59 int render_sample_rate_hz, 60 int render_sample_rate_hz,
60 ChannelLayout capture_input_layout, 61 ChannelLayout capture_input_layout,
61 ChannelLayout capture_output_layout, 62 ChannelLayout capture_output_layout,
62 ChannelLayout render_input_layout) override; 63 ChannelLayout render_input_layout) override;
63 int Initialize(const ProcessingConfig& processing_config) override; 64 int Initialize(const ProcessingConfig& processing_config) override;
64 void ApplyConfig(const AudioProcessing::Config& config) override; 65 void ApplyConfig(const AudioProcessing::Config& config) override;
65 void SetExtraOptions(const webrtc::Config& config) override; 66 void SetExtraOptions(const webrtc::Config& config) override;
66 void UpdateHistogramsOnCallEnd() override; 67 void UpdateHistogramsOnCallEnd() override;
68 void AttachAecDump(std::unique_ptr<AecDump> aec_dump) override;
69 void DetachAecDump() override;
67 int StartDebugRecording(const char filename[kMaxFilenameSize], 70 int StartDebugRecording(const char filename[kMaxFilenameSize],
68 int64_t max_log_size_bytes) override; 71 int64_t max_log_size_bytes) override;
69 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override; 72 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override;
70 int StartDebugRecording(FILE* handle) override; 73 int StartDebugRecording(FILE* handle) override;
71 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; 74 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override;
72 int StopDebugRecording() override; 75 int StopDebugRecording() override;
73 76
74 // Capture-side exclusive methods possibly running APM in a 77 // Capture-side exclusive methods possibly running APM in a
75 // multi-threaded manner. Acquire the capture lock. 78 // multi-threaded manner. Acquire the capture lock.
76 int ProcessStream(AudioFrame* frame) override; 79 int ProcessStream(AudioFrame* frame) override;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 274
272 // Render-side exclusive methods possibly running APM in a multi-threaded 275 // Render-side exclusive methods possibly running APM in a multi-threaded
273 // manner that are called with the render lock already acquired. 276 // manner that are called with the render lock already acquired.
274 // TODO(ekm): Remove once all clients updated to new interface. 277 // TODO(ekm): Remove once all clients updated to new interface.
275 int AnalyzeReverseStreamLocked(const float* const* src, 278 int AnalyzeReverseStreamLocked(const float* const* src,
276 const StreamConfig& input_config, 279 const StreamConfig& input_config,
277 const StreamConfig& output_config) 280 const StreamConfig& output_config)
278 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 281 EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
279 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 282 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
280 283
284 // Collects configuration settings from public and private
285 // submodules to be saved as an audioproc::Config message on the
286 // AecDump if it is attached. If not |forced|, only writes the current
287 // config if it is different from the last saved one; if |forced|,
288 // writes the config regardless of the last saved.
289 void WriteAecDumpConfigMessage(bool forced)
290 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
291
292 // Notifies attached AecDump of current configuration and capture data.
293 void RecordUnprocessedCaptureStream(const float* const* capture_stream)
294 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
295
296 void RecordUnprocessedCaptureStream(const AudioFrame& capture_frame)
297 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
298
299 // Notifies attached AecDump of current configuration and
300 // processed capture data and issues a capture stream recording
301 // request.
302 void RecordProcessedCaptureStream(
303 const float* const* processed_capture_stream)
304 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
305
306 void RecordProcessedCaptureStream(const AudioFrame& processed_capture_frame)
307 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
308
309 // Notifies attached AecDump about current state (delay, drift, etc).
310 void RecordAudioProcessingState() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
311
281 // Debug dump methods that are internal and called without locks. 312 // Debug dump methods that are internal and called without locks.
282 // TODO(peah): Make thread safe. 313 // TODO(peah): Make thread safe.
283 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 314 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
284 // TODO(andrew): make this more graceful. Ideally we would split this stuff 315 // TODO(andrew): make this more graceful. Ideally we would split this stuff
285 // out into a separate class with an "enabled" and "disabled" implementation. 316 // out into a separate class with an "enabled" and "disabled" implementation.
286 static int WriteMessageToDebugFile(FileWrapper* debug_file, 317 static int WriteMessageToDebugFile(FileWrapper* debug_file,
287 int64_t* filesize_limit_bytes, 318 int64_t* filesize_limit_bytes,
288 rtc::CriticalSection* crit_debug, 319 rtc::CriticalSection* crit_debug,
289 ApmDebugDumpThreadState* debug_state); 320 ApmDebugDumpThreadState* debug_state);
290 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); 321 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
291 322
292 // Writes Config message. If not |forced|, only writes the current config if 323 // Writes Config message. If not |forced|, only writes the current config if
293 // it is different from the last saved one; if |forced|, writes the config 324 // it is different from the last saved one; if |forced|, writes the config
294 // regardless of the last saved. 325 // regardless of the last saved.
295 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) 326 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_)
296 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); 327 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
297 328
298 // Critical section. 329 // Critical section.
299 rtc::CriticalSection crit_debug_; 330 rtc::CriticalSection crit_debug_;
300 331
301 // Debug dump state. 332 // Debug dump state.
302 ApmDebugDumpState debug_dump_; 333 ApmDebugDumpState debug_dump_;
303 #endif 334 #endif
304 335
336 // AecDump instance used for optionally logging APM config, input
337 // and output to file in the AEC-dump format defined in debug.proto.
338 std::unique_ptr<AecDump> aec_dump_;
339
340 // Hold the last config written with AecDump for avoiding writing
341 // the same config twice.
342 InternalAPMConfig apm_config_for_aec_dump_ GUARDED_BY(crit_capture_);
343
305 // Critical sections. 344 // Critical sections.
306 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); 345 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_);
307 rtc::CriticalSection crit_capture_; 346 rtc::CriticalSection crit_capture_;
308 347
309 // Struct containing the Config specifying the behavior of APM. 348 // Struct containing the Config specifying the behavior of APM.
310 AudioProcessing::Config config_; 349 AudioProcessing::Config config_;
311 350
312 // Class containing information about what submodules are active. 351 // Class containing information about what submodules are active.
313 ApmSubmoduleStates submodule_states_; 352 ApmSubmoduleStates submodule_states_;
314 353
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 std::unique_ptr< 473 std::unique_ptr<
435 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> 474 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
436 agc_render_signal_queue_; 475 agc_render_signal_queue_;
437 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> 476 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
438 red_render_signal_queue_; 477 red_render_signal_queue_;
439 }; 478 };
440 479
441 } // namespace webrtc 480 } // namespace webrtc
442 481
443 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ 482 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/BUILD.gn ('k') | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698