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

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

Issue 2778783002: AecDump interface (Closed)
Patch Set: Put capture logging in methods. 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 <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
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 StartDebugRecording(std::unique_ptr<AecDump> aec_dump) override;
the sun 2017/04/28 11:06:00 nit: perhaps "Start" isn't the right verb here. "S
aleloi 2017/05/03 13:58:19 Ok, changing to SetAecDump().
69 int StartDebugRecording(const char filename[kMaxFilenameSize], 71 int StartDebugRecording(const char filename[kMaxFilenameSize],
70 int64_t max_log_size_bytes) override; 72 int64_t max_log_size_bytes) override;
71 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override; 73 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override;
72 int StartDebugRecording(FILE* handle) override; 74 int StartDebugRecording(FILE* handle) override;
73 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; 75 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override;
74 int StopDebugRecording() override; 76 int StopDebugRecording() override;
75 77
76 // Capture-side exclusive methods possibly running APM in a 78 // Capture-side exclusive methods possibly running APM in a
77 // multi-threaded manner. Acquire the capture lock. 79 // multi-threaded manner. Acquire the capture lock.
78 int ProcessStream(AudioFrame* frame) override; 80 int ProcessStream(AudioFrame* frame) override;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 270
269 // Render-side exclusive methods possibly running APM in a multi-threaded 271 // Render-side exclusive methods possibly running APM in a multi-threaded
270 // manner that are called with the render lock already acquired. 272 // manner that are called with the render lock already acquired.
271 // TODO(ekm): Remove once all clients updated to new interface. 273 // TODO(ekm): Remove once all clients updated to new interface.
272 int AnalyzeReverseStreamLocked(const float* const* src, 274 int AnalyzeReverseStreamLocked(const float* const* src,
273 const StreamConfig& input_config, 275 const StreamConfig& input_config,
274 const StreamConfig& output_config) 276 const StreamConfig& output_config)
275 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 277 EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
276 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 278 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
277 279
280 // Collects configuration settings from public and private
281 // submodules to be saved as an audioproc::Config message.
282 InternalAPMConfig CollectApmConfig() const
283 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_)
284 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
285
286 // Creates and returns new CaptureStreamInfo filled with the capture
287 // stream and data (delay, drift etc).
288 std::unique_ptr<AecDump::CaptureStreamInfo> RecordUnprocessedCaptureStream(
289 const float* const* capture_stream) const
290 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
291
292 std::unique_ptr<AecDump::CaptureStreamInfo> RecordUnprocessedCaptureStream(
293 const AudioFrame& capture_frame) const
294 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
295
296 // Fills the CaptureStreamInfo object with the processed capture
297 // stream and sends it to be written with AecDump.
298 void RecordProcessedCaptureStream(
299 const float* const* processed_capture_stream,
300 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info) const
301 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
302
303 void RecordProcessedCaptureStream(
304 const AudioFrame& processed_capture_frame,
305 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info) const
306 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
307
308 // Copies data (delay, drift, etc) into the |stream_info| object.
309 void PopulateStreamInfoWithConfig(AecDump::CaptureStreamInfo* stream_info)
310 const EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
311
278 // Debug dump methods that are internal and called without locks. 312 // Debug dump methods that are internal and called without locks.
279 // TODO(peah): Make thread safe. 313 // TODO(peah): Make thread safe.
280 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 314 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
281 // 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
282 // out into a separate class with an "enabled" and "disabled" implementation. 316 // out into a separate class with an "enabled" and "disabled" implementation.
283 static int WriteMessageToDebugFile(FileWrapper* debug_file, 317 static int WriteMessageToDebugFile(FileWrapper* debug_file,
284 int64_t* filesize_limit_bytes, 318 int64_t* filesize_limit_bytes,
285 rtc::CriticalSection* crit_debug, 319 rtc::CriticalSection* crit_debug,
286 ApmDebugDumpThreadState* debug_state); 320 ApmDebugDumpThreadState* debug_state);
287 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); 321 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
288 322
289 // 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
290 // 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
291 // regardless of the last saved. 325 // regardless of the last saved.
292 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) 326 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_)
293 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); 327 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
294 328
295 // Critical section. 329 // Critical section.
296 rtc::CriticalSection crit_debug_; 330 rtc::CriticalSection crit_debug_;
297 331
298 // Debug dump state. 332 // Debug dump state.
299 ApmDebugDumpState debug_dump_; 333 ApmDebugDumpState debug_dump_;
300 #endif 334 #endif
301 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_;
the sun 2017/04/28 11:06:00 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_captur
aleloi 2017/05/03 13:58:19 Calling methods concurrently on a AecDump instance
339
302 // Critical sections. 340 // Critical sections.
303 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); 341 rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_);
304 rtc::CriticalSection crit_capture_; 342 rtc::CriticalSection crit_capture_;
305 343
306 // Struct containing the Config specifying the behavior of APM. 344 // Struct containing the Config specifying the behavior of APM.
307 AudioProcessing::Config config_; 345 AudioProcessing::Config config_;
308 346
309 // Class containing information about what submodules are active. 347 // Class containing information about what submodules are active.
310 ApmSubmoduleStates submodule_states_; 348 ApmSubmoduleStates submodule_states_;
311 349
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 std::unique_ptr< 468 std::unique_ptr<
431 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> 469 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
432 agc_render_signal_queue_; 470 agc_render_signal_queue_;
433 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> 471 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
434 red_render_signal_queue_; 472 red_render_signal_queue_;
435 }; 473 };
436 474
437 } // namespace webrtc 475 } // namespace webrtc
438 476
439 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ 477 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698