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_WRITE_TO_FILE_TASK_H_
12 #define MODULES_AUDIO_PROCESSING_AEC_DUMP_WRITE_TO_FILE_TASK_H_
13 
14 #include <memory>
15 #include <string>
16 #include <utility>
17 
18 #include "api/task_queue/queued_task.h"
19 #include "rtc_base/checks.h"
20 #include "rtc_base/event.h"
21 #include "rtc_base/ignore_wundef.h"
22 #include "rtc_base/system/file_wrapper.h"
23 
24 // Files generated at build-time by the protobuf compiler.
25 RTC_PUSH_IGNORING_WUNDEF()
26 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
27 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
28 #else
29 #include "modules/audio_processing/debug.pb.h"
30 #endif
RTC_POP_IGNORING_WUNDEF()31 RTC_POP_IGNORING_WUNDEF()
32 
33 namespace webrtc {
34 
35 class WriteToFileTask : public QueuedTask {
36  public:
37   WriteToFileTask(webrtc::FileWrapper* debug_file,
38                   int64_t* num_bytes_left_for_log);
39   ~WriteToFileTask() override;
40 
41   audioproc::Event* GetEvent();
42 
43  private:
44   bool IsRoomForNextEvent(size_t event_byte_size) const;
45 
46   void UpdateBytesLeft(size_t event_byte_size);
47 
48   bool Run() override;
49 
50   webrtc::FileWrapper* const debug_file_;
51   audioproc::Event event_;
52   int64_t* const num_bytes_left_for_log_;
53 };
54 
55 }  // namespace webrtc
56 
57 #endif  // MODULES_AUDIO_PROCESSING_AEC_DUMP_WRITE_TO_FILE_TASK_H_
58