Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: webrtc/modules/audio_processing/include/aec_dump.h

Issue 2778783002: AecDump interface (Closed)
Patch Set: Next version; large changes to interface. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_INCLUDE_AEC_DUMP_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_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 webrtc {
26
27 class AudioFrame;
28
29 // Struct for passing current config from APM without having to
30 // include protobuf headers.
31 struct InternalAPMConfig {
32 InternalAPMConfig();
33
34 InternalAPMConfig(const InternalAPMConfig&) = delete;
35 InternalAPMConfig(const InternalAPMConfig&&) = delete;
36 InternalAPMConfig& operator=(const InternalAPMConfig&) = delete;
37 InternalAPMConfig& operator=(const InternalAPMConfig&&) = delete;
38
39 bool aec_enabled = false;
40 bool aec_delay_agnostic_enabled = false;
41 bool aec_drift_compensation_enabled = false;
42 bool aec_extended_filter_enabled = false;
43 int aec_suppression_level = 0;
44 bool aecm_enabled = false;
45 bool aecm_comfort_noise_enabled = false;
46 int aecm_routing_mode = 0;
47 bool agc_enabled = false;
48 int agc_mode = 0;
49 bool agc_limiter_enabled = false;
50 bool hpf_enabled = false;
51 bool ns_enabled = false;
52 int ns_level = 0;
53 bool transient_suppression_enabled = false;
54 bool intelligibility_enhancer_enabled = false;
55 bool noise_robust_agc_enabled = false;
56 std::string experiments_description = "";
57 };
58
59 class AecDump {
60 public:
61 // A capture stream frame is logged before and after processing in
62 // the same protobuf message. To facilitate that, a CaptureStreamInfo
63 // instance is first filled with Input, then Output.
64 //
65 // To log an input/output pair, first call
66 // AecDump::GetCaptureStreamInfo. Add the input and output to
67 // it. Then call AecDump::WriteCaptureStreamMessage.
68 class CaptureStreamInfo {
69 public:
70 virtual ~CaptureStreamInfo() = default;
71 virtual void AddInput(
72 const std::vector<rtc::ArrayView<const float>>& src) = 0;
73 virtual void AddOutput(
74 const std::vector<rtc::ArrayView<const float>>& src) = 0;
75
76 virtual void AddInput(const AudioFrame& frame) = 0;
77 virtual void AddOutput(const AudioFrame& frame) = 0;
78
79 virtual void set_delay(int delay) = 0;
80 virtual void set_drift(int drift) = 0;
81 virtual void set_level(int level) = 0;
82 virtual void set_keypress(bool keypress) = 0;
83 };
84
85 virtual ~AecDump() = default;
86
87 static std::unique_ptr<AecDump> CreateNullDump();
88
89 virtual std::unique_ptr<CaptureStreamInfo> GetCaptureStreamInfo() = 0;
90
91 // The Write* methods are always safe to call. If no recording is in
92 // progress, calls will have no effect. Messages are written to file
93 // in a 'best effort' manner. If the AecDump can't keep up with
94 // the flow of messages, some will be silently dropped.
peah-webrtc 2017/04/07 12:57:16 I'm not that happy that messages will be dropped.
aleloi 2017/04/12 11:05:29 Sorry, missed to update the comment after I remove
95 virtual void WriteInitMessage(const ProcessingConfig& api_format) = 0;
peah-webrtc 2017/04/07 12:57:16 Even though the ProcessingConfig class contains al
aleloi 2017/04/12 11:05:29 I have added a new type similar to InternalAPMConf
96
97 virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0;
98
99 virtual void WriteRenderStreamMessage(
100 std::vector<rtc::ArrayView<const float>> src) = 0;
peah-webrtc 2017/04/07 12:57:16 This call will copy a vector. Is that desired? Wou
aleloi 2017/04/12 11:05:29 I have changed this to take the value by const& ex
101
102 virtual void WriteCaptureStreamMessage(
103 std::unique_ptr<CaptureStreamInfo> stream_info) = 0;
104
105 // If not |forced|, only writes the current config if it is
106 // different from the last saved one; if |forced|, writes the config
107 // regardless of the last saved.
108 virtual void WriteConfig(const InternalAPMConfig& config, bool forced) = 0;
109 };
110
111 class NullCaptureStreamInfo final : public AecDump::CaptureStreamInfo {
peah-webrtc 2017/04/07 12:57:16 Where is this classed used?
aleloi 2017/04/12 11:05:30 It was previously used for AecDumps that did nothi
112 void AddInput(const std::vector<rtc::ArrayView<const float>>& src) override{};
113 void AddOutput(
114 const std::vector<rtc::ArrayView<const float>>& src) override{};
115
116 void AddInput(const AudioFrame& frame) override{};
117 void AddOutput(const AudioFrame& frame) override{};
118 void set_delay(int delay) override{};
119 void set_drift(int drift) override{};
120 void set_level(int level) override{};
121 void set_keypress(bool keypress) override{};
122 };
123
124 // Implementation of AecDump that doesn't do anything. It is used to
125 // avoid handling special cases for when logging is enabled/disabled
126 // in AudioProcessingImpl.
127 class NullAecDump final : public AecDump {
128 public:
129 ~NullAecDump() override = default;
130
131 std::unique_ptr<CaptureStreamInfo> GetCaptureStreamInfo() override;
peah-webrtc 2017/04/07 12:57:16 This should also need an implementation, right?
aleloi 2017/04/12 11:05:29 It was previously in aec_dump.cc. Now it's removed
132
133 void WriteInitMessage(const ProcessingConfig& api_format) override{};
peah-webrtc 2017/04/07 12:57:15 I assume that this method, as well as the ones bel
aleloi 2017/04/12 11:05:30 I checked by compiling in release-mode and disasse
134
135 void WriteRenderStreamMessage(const AudioFrame& frame) override{};
136
137 void WriteRenderStreamMessage(
138 std::vector<rtc::ArrayView<const float>> src) override{};
peah-webrtc 2017/04/07 12:57:16 This call will copy a vector. Is that desired? Wou
aleloi 2017/04/12 11:05:29 Changed.
139
140 void WriteCaptureStreamMessage(
141 std::unique_ptr<CaptureStreamInfo> stream_info) override{};
142
143 void WriteConfig(const InternalAPMConfig& config, bool forced) override{};
144 };
145 } // namespace webrtc
146
147 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698