aec_dump_impl.h (3626B)
1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_AUDIO_PROCESSING_AEC_DUMP_AEC_DUMP_IMPL_H_ 12 #define MODULES_AUDIO_PROCESSING_AEC_DUMP_AEC_DUMP_IMPL_H_ 13 14 #include <cstdint> 15 #include <memory> 16 17 #include "absl/base/nullability.h" 18 #include "api/audio/audio_processing.h" 19 #include "api/audio/audio_view.h" 20 #include "api/task_queue/task_queue_base.h" 21 #include "modules/audio_processing/aec_dump/capture_stream_info.h" 22 #include "modules/audio_processing/include/aec_dump.h" 23 #include "modules/audio_processing/include/audio_frame_view.h" 24 #include "rtc_base/race_checker.h" 25 #include "rtc_base/system/file_wrapper.h" 26 27 // Files generated at build-time by the protobuf compiler. 28 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 29 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" 30 #else 31 #include "modules/audio_processing/debug.pb.h" 32 #endif 33 34 namespace webrtc { 35 36 // Task-queue based implementation of AecDump. It is thread safe by 37 // relying on locks in TaskQueue. 38 class AecDumpImpl : public AecDump { 39 public: 40 // `max_log_size_bytes` - maximum number of bytes to write to the debug file, 41 // `max_log_size_bytes == -1` means the log size will be unlimited. 42 AecDumpImpl(FileWrapper debug_file, 43 int64_t max_log_size_bytes, 44 TaskQueueBase* absl_nonnull worker_queue); 45 AecDumpImpl(const AecDumpImpl&) = delete; 46 AecDumpImpl& operator=(const AecDumpImpl&) = delete; 47 ~AecDumpImpl() override; 48 49 void WriteInitMessage(const ProcessingConfig& api_format, 50 int64_t time_now_ms) override; 51 void AddCaptureStreamInput(const AudioFrameView<const float>& src) override; 52 void AddCaptureStreamInput(MonoView<const float> channel) override; 53 void AddCaptureStreamOutput(const AudioFrameView<const float>& src) override; 54 void AddCaptureStreamOutput(MonoView<const float> channel) override; 55 void AddCaptureStreamInput(const int16_t* const data, 56 int num_channels, 57 int samples_per_channel) override; 58 void AddCaptureStreamOutput(const int16_t* const data, 59 int num_channels, 60 int samples_per_channel) override; 61 void AddAudioProcessingState(const AudioProcessingState& state) override; 62 void WriteCaptureStreamMessage() override; 63 64 void WriteRenderStreamMessage(const int16_t* const data, 65 int num_channels, 66 int samples_per_channel) override; 67 void WriteRenderStreamMessage( 68 const AudioFrameView<const float>& src) override; 69 void WriteRenderStreamMessage(const float* const* data, 70 int num_channels, 71 int samples_per_channel) override; 72 73 void WriteConfig(const InternalAPMConfig& config) override; 74 75 void WriteRuntimeSetting( 76 const AudioProcessing::RuntimeSetting& runtime_setting) override; 77 78 private: 79 void PostWriteToFileTask(std::unique_ptr<audioproc::Event> event); 80 81 FileWrapper debug_file_; 82 int64_t num_bytes_left_for_log_ = 0; 83 RaceChecker race_checker_; 84 TaskQueueBase* absl_nonnull worker_queue_; 85 CaptureStreamInfo capture_stream_info_; 86 }; 87 } // namespace webrtc 88 89 #endif // MODULES_AUDIO_PROCESSING_AEC_DUMP_AEC_DUMP_IMPL_H_