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_CAPTURE_STREAM_INFO_H_
12 #define MODULES_AUDIO_PROCESSING_AEC_DUMP_CAPTURE_STREAM_INFO_H_
13 
14 #include <memory>
15 #include <utility>
16 #include <vector>
17 
18 #include "modules/audio_processing/aec_dump/write_to_file_task.h"
19 #include "modules/audio_processing/include/aec_dump.h"
20 #include "rtc_base/checks.h"
21 #include "rtc_base/ignore_wundef.h"
22 #include "rtc_base/logging.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 CaptureStreamInfo {
36  public:
37   explicit CaptureStreamInfo(std::unique_ptr<WriteToFileTask> task);
38   ~CaptureStreamInfo();
39   void AddInput(const AudioFrameView<const float>& src);
40   void AddOutput(const AudioFrameView<const float>& src);
41 
42   void AddInput(const int16_t* const data,
43                 int num_channels,
44                 int samples_per_channel);
45   void AddOutput(const int16_t* const data,
46                  int num_channels,
47                  int samples_per_channel);
48 
49   void AddAudioProcessingState(const AecDump::AudioProcessingState& state);
50 
51   std::unique_ptr<WriteToFileTask> GetTask() {
52     RTC_DCHECK(task_);
53     return std::move(task_);
54   }
55 
56   void SetTask(std::unique_ptr<WriteToFileTask> task) {
57     RTC_DCHECK(!task_);
58     RTC_DCHECK(task);
59     task_ = std::move(task);
60     task_->GetEvent()->set_type(audioproc::Event::STREAM);
61   }
62 
63  private:
64   std::unique_ptr<WriteToFileTask> task_;
65 };
66 
67 }  // namespace webrtc
68 
69 #endif  // MODULES_AUDIO_PROCESSING_AEC_DUMP_CAPTURE_STREAM_INFO_H_
70