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 <memory> 15 #include <string> 16 #include <vector> 17 18 #include "modules/audio_processing/aec_dump/capture_stream_info.h" 19 #include "modules/audio_processing/aec_dump/write_to_file_task.h" 20 #include "modules/audio_processing/include/aec_dump.h" 21 #include "rtc_base/ignore_wundef.h" 22 #include "rtc_base/race_checker.h" 23 #include "rtc_base/system/file_wrapper.h" 24 #include "rtc_base/task_queue.h" 25 #include "rtc_base/thread_annotations.h" 26 27 // Files generated at build-time by the protobuf compiler. 28 RTC_PUSH_IGNORING_WUNDEF() 29 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 30 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" 31 #else 32 #include "modules/audio_processing/debug.pb.h" 33 #endif RTC_POP_IGNORING_WUNDEF()34RTC_POP_IGNORING_WUNDEF() 35 36 namespace rtc { 37 class TaskQueue; 38 } // namespace rtc 39 40 namespace webrtc { 41 42 // Task-queue based implementation of AecDump. It is thread safe by 43 // relying on locks in TaskQueue. 44 class AecDumpImpl : public AecDump { 45 public: 46 // Does member variables initialization shared across all c-tors. 47 AecDumpImpl(FileWrapper debug_file, 48 int64_t max_log_size_bytes, 49 rtc::TaskQueue* worker_queue); 50 51 ~AecDumpImpl() override; 52 53 void WriteInitMessage(const ProcessingConfig& api_format, 54 int64_t time_now_ms) override; 55 void AddCaptureStreamInput(const AudioFrameView<const float>& src) override; 56 void AddCaptureStreamOutput(const AudioFrameView<const float>& src) override; 57 void AddCaptureStreamInput(const int16_t* const data, 58 int num_channels, 59 int samples_per_channel) override; 60 void AddCaptureStreamOutput(const int16_t* const data, 61 int num_channels, 62 int samples_per_channel) override; 63 void AddAudioProcessingState(const AudioProcessingState& state) override; 64 void WriteCaptureStreamMessage() override; 65 66 void WriteRenderStreamMessage(const int16_t* const data, 67 int num_channels, 68 int samples_per_channel) override; 69 void WriteRenderStreamMessage( 70 const AudioFrameView<const float>& src) override; 71 72 void WriteConfig(const InternalAPMConfig& config) override; 73 74 void WriteRuntimeSetting( 75 const AudioProcessing::RuntimeSetting& runtime_setting) override; 76 77 private: 78 std::unique_ptr<WriteToFileTask> CreateWriteToFileTask(); 79 80 FileWrapper debug_file_; 81 int64_t num_bytes_left_for_log_ = 0; 82 rtc::RaceChecker race_checker_; 83 rtc::TaskQueue* worker_queue_; 84 CaptureStreamInfo capture_stream_info_; 85 }; 86 } // namespace webrtc 87 88 #endif // MODULES_AUDIO_PROCESSING_AEC_DUMP_AEC_DUMP_IMPL_H_ 89