Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 WEBRTC_MODULES_AUDIO_PROCESSING_AEC_DUMPER_AEC_DUMPER_H_ | |
| 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_DUMPER_AEC_DUMPER_H_ | |
| 13 | |
| 14 #include <memory> | |
| 15 #include <string> | |
| 16 #include <vector> | |
| 17 | |
| 18 #include "webrtc/base/array_view.h" | |
| 19 #include "webrtc/modules/audio_processing/include/audio_processing.h" | |
| 20 | |
| 21 namespace audioproc { | |
| 22 class Event; | |
| 23 } // namespace audioproc | |
| 24 | |
| 25 namespace rtc { | |
| 26 class TaskQueue; | |
| 27 } // namespace rtc | |
| 28 | |
| 29 namespace webrtc { | |
| 30 | |
| 31 class AudioFrame; | |
| 32 | |
| 33 // Struct for passing current config from APM without having to | |
| 34 // include protobuf headers. | |
| 35 struct InternalAPMConfig { | |
| 36 InternalAPMConfig(); | |
| 37 InternalAPMConfig(InternalAPMConfig&); | |
|
kwiberg-webrtc
2017/03/28 08:54:58
Is this intended to be a copy constructor? In that
aleloi
2017/03/29 08:41:31
I now pass by const ref and have deleted the other
| |
| 38 ~InternalAPMConfig(); | |
| 39 | |
| 40 bool aec_enabled = false; | |
| 41 bool aec_delay_agnostic_enabled = false; | |
| 42 bool aec_drift_compensation_enabled = false; | |
| 43 bool aec_extended_filter_enabled = false; | |
| 44 int aec_suppression_level = 0; | |
| 45 bool aecm_enabled = false; | |
| 46 bool aecm_comfort_noise_enabled = false; | |
| 47 int aecm_routing_mode = 0; | |
| 48 bool agc_enabled = false; | |
| 49 int agc_mode = 0; | |
| 50 bool agc_limiter_enabled = false; | |
| 51 bool hpf_enabled = false; | |
| 52 bool ns_enabled = false; | |
| 53 int ns_level = 0; | |
| 54 bool transient_suppression_enabled = false; | |
| 55 bool intelligibility_enhancer_enabled = false; | |
| 56 bool noise_robust_agc_enabled = false; | |
| 57 std::string experiments_description = ""; | |
| 58 }; | |
| 59 | |
| 60 inline InternalAPMConfig::InternalAPMConfig(InternalAPMConfig&) = default; | |
| 61 inline InternalAPMConfig::InternalAPMConfig() = default; | |
| 62 inline InternalAPMConfig::~InternalAPMConfig() = default; | |
|
kwiberg-webrtc
2017/03/28 08:54:58
Either drop the "inline" and move these lines to t
aleloi
2017/03/29 08:41:31
I've moved them to a cc file. I think the chrome s
| |
| 63 | |
| 64 class AecDumper { | |
| 65 public: | |
| 66 // A capture stream frame is logged before and after processing in | |
| 67 // the same protobuf message. To facilitate that, a | |
| 68 // CaptureStreamInfo instance is first filled with Input, then | |
| 69 // Output. | |
| 70 // | |
| 71 // To log an input/output pair, first call | |
| 72 // AecDumper::GetCaptureStreamInfo. Add the input and output to | |
| 73 // it. Then call AecDumper::WriteCaptureStreamMessage. | |
| 74 class CaptureStreamInfo { | |
| 75 public: | |
| 76 CaptureStreamInfo() = default; | |
|
kwiberg-webrtc
2017/03/28 08:54:58
This is a pure interface, so don't try to add a co
aleloi
2017/03/29 08:41:31
Thanks! I've just read tip of the week #131. There
| |
| 77 virtual ~CaptureStreamInfo() = default; | |
| 78 virtual void AddInput( | |
| 79 const std::vector<rtc::ArrayView<const float>> src) = 0; | |
| 80 virtual void AddOutput( | |
| 81 const std::vector<rtc::ArrayView<const float>> src) = 0; | |
|
kwiberg-webrtc
2017/03/28 08:54:59
Drop the outermost "const" here. You're simply tak
aleloi
2017/03/29 08:41:31
Done.
| |
| 82 | |
| 83 virtual void AddInput(const AudioFrame& frame) = 0; | |
| 84 virtual void AddOutput(const AudioFrame& frame) = 0; | |
| 85 | |
| 86 virtual void set_delay(int delay) = 0; | |
| 87 virtual void set_drift(int drift) = 0; | |
| 88 virtual void set_level(int level) = 0; | |
| 89 virtual void set_keypress(bool keypress) = 0; | |
| 90 }; | |
| 91 | |
| 92 AecDumper() = default; | |
|
kwiberg-webrtc
2017/03/28 08:54:58
Again: pure interface, so no need to even mention
aleloi
2017/03/29 08:41:31
Done.
| |
| 93 | |
| 94 virtual ~AecDumper() = default; | |
| 95 | |
| 96 // TODO(aleloi): update comments to new creation scheme. | |
| 97 // If called when a recording is active, that file is closed, and a | |
| 98 // new file is opened. Messages waiting to be written asynchronously | |
| 99 // to the old file may be lost. Returns true iff opening file for | |
| 100 // writing succeeded. | |
| 101 | |
| 102 // Closes associated file. Messages waiting to be written to file | |
| 103 // asynchronously may be lost. This method is safe to call when no | |
| 104 // recording is active. A recording does not have to be closed | |
| 105 // manually with this method; instead the AecDumper instance may be | |
| 106 // destroyed. | |
| 107 static std::unique_ptr<AecDumper> Create(std::string file_name, | |
| 108 int64_t max_log_size_bytes, | |
| 109 rtc::TaskQueue* worker_queue); | |
| 110 static std::unique_ptr<AecDumper> Create(FILE* handle, | |
| 111 int64_t max_log_size_bytes, | |
| 112 rtc::TaskQueue* worker_queue); | |
| 113 | |
| 114 static std::unique_ptr<AecDumper> CreateNullDumper(); | |
|
kwiberg-webrtc
2017/03/28 08:54:58
For modularity, consider having the interface and
aleloi
2017/03/29 08:41:31
The whole interface is rather specialized for use
| |
| 115 | |
| 116 virtual std::unique_ptr<CaptureStreamInfo> GetCaptureStreamInfo() = 0; | |
| 117 | |
| 118 // The Write* methods are always safe to call. If no recording is in | |
| 119 // progress, calls will have no effect. Messages are written to file | |
| 120 // in a 'best effort' manner. If the AecDumper can't keep up with | |
| 121 // the flow of messages, some will be silently dropped. | |
| 122 virtual void WriteInitMessage(const ProcessingConfig& api_format) = 0; | |
| 123 | |
| 124 virtual void WriteReverseStreamMessage(const AudioFrame& frame) = 0; | |
| 125 | |
| 126 virtual void WriteReverseStreamMessage( | |
| 127 const std::vector<rtc::ArrayView<const float>> src) = 0; | |
|
kwiberg-webrtc
2017/03/28 08:54:59
The comment for AddInput/AddOutput applies here to
aleloi
2017/03/29 08:41:31
Done.
| |
| 128 | |
| 129 virtual void WriteCaptureStreamMessage( | |
| 130 std::unique_ptr<CaptureStreamInfo> stream_info) = 0; | |
| 131 | |
| 132 // If not |forced|, only writes the current config if it is | |
| 133 // different from the last saved one; if |forced|, writes the config | |
| 134 // regardless of the last saved. | |
| 135 virtual void WriteConfig(InternalAPMConfig config, bool forced) = 0; | |
|
kwiberg-webrtc
2017/03/28 08:54:59
InternalAPMConfig is somewhat big, so isn't exactl
aleloi
2017/03/29 08:41:31
Done.
| |
| 136 }; | |
| 137 } // namespace webrtc | |
| 138 | |
| 139 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_DUMPER_AEC_DUMPER_H_ | |
| OLD | NEW |