2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_
14 #include "webrtc/typedefs.h"
17 #define AEC_UNSPECIFIED_ERROR 12000
18 #define AEC_UNSUPPORTED_FUNCTION_ERROR 12001
19 #define AEC_UNINITIALIZED_ERROR 12002
20 #define AEC_NULL_POINTER_ERROR 12003
21 #define AEC_BAD_PARAMETER_ERROR 12004
24 #define AEC_BAD_PARAMETER_WARNING 12050
27 kAecNlpConservative = 0,
38 int16_t nlpMode; // default kAecNlpModerate
39 int16_t skewMode; // default kAecFalse
40 int16_t metricsMode; // default kAecFalse
41 int delay_logging; // default kAecFalse
66 * Allocates the memory needed by the AEC. The memory needs to be initialized
67 * separately using the WebRtcAec_Init() function.
70 * -------------------------------------------------------------------
71 * void** aecInst Pointer to the AEC instance to be created
75 * -------------------------------------------------------------------
76 * int32_t return 0: OK
79 int32_t WebRtcAec_Create(void** aecInst);
82 * This function releases the memory allocated by WebRtcAec_Create().
85 * -------------------------------------------------------------------
86 * void* aecInst Pointer to the AEC instance
89 * -------------------------------------------------------------------
90 * int32_t return 0: OK
93 int32_t WebRtcAec_Free(void* aecInst);
96 * Initializes an AEC instance.
99 * -------------------------------------------------------------------
100 * void* aecInst Pointer to the AEC instance
101 * int32_t sampFreq Sampling frequency of data
102 * int32_t scSampFreq Soundcard sampling frequency
104 * Outputs Description
105 * -------------------------------------------------------------------
106 * int32_t return 0: OK
109 int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq);
112 * Inserts an 80 or 160 sample block of data into the farend buffer.
115 * -------------------------------------------------------------------
116 * void* aecInst Pointer to the AEC instance
117 * const float* farend In buffer containing one frame of
118 * farend signal for L band
119 * int16_t nrOfSamples Number of samples in farend buffer
121 * Outputs Description
122 * -------------------------------------------------------------------
123 * int32_t return 0: OK
126 int32_t WebRtcAec_BufferFarend(void* aecInst,
128 int16_t nrOfSamples);
131 * Runs the echo canceller on an 80 or 160 sample blocks of data.
134 * -------------------------------------------------------------------
135 * void* aecInst Pointer to the AEC instance
136 * float* nearend In buffer containing one frame of
137 * nearend+echo signal for L band
138 * float* nearendH In buffer containing one frame of
139 * nearend+echo signal for H band
140 * int16_t nrOfSamples Number of samples in nearend buffer
141 * int16_t msInSndCardBuf Delay estimate for sound card and
143 * int16_t skew Difference between number of samples played
144 * and recorded at the soundcard (for clock skew
147 * Outputs Description
148 * -------------------------------------------------------------------
149 * float* out Out buffer, one frame of processed nearend
151 * float* outH Out buffer, one frame of processed nearend
153 * int32_t return 0: OK
156 int32_t WebRtcAec_Process(void* aecInst,
157 const float* nearend,
158 const float* nearendH,
162 int16_t msInSndCardBuf,
166 * This function enables the user to set certain parameters on-the-fly.
169 * -------------------------------------------------------------------
170 * void* handle Pointer to the AEC instance
171 * AecConfig config Config instance that contains all
172 * properties to be set
174 * Outputs Description
175 * -------------------------------------------------------------------
179 int WebRtcAec_set_config(void* handle, AecConfig config);
182 * Gets the current echo status of the nearend signal.
185 * -------------------------------------------------------------------
186 * void* handle Pointer to the AEC instance
188 * Outputs Description
189 * -------------------------------------------------------------------
190 * int* status 0: Almost certainly nearend single-talk
191 * 1: Might not be neared single-talk
195 int WebRtcAec_get_echo_status(void* handle, int* status);
198 * Gets the current echo metrics for the session.
201 * -------------------------------------------------------------------
202 * void* handle Pointer to the AEC instance
204 * Outputs Description
205 * -------------------------------------------------------------------
206 * AecMetrics* metrics Struct which will be filled out with the
207 * current echo metrics.
211 int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics);
214 * Gets the current delay metrics for the session.
217 * -------------------------------------------------------------------
218 * void* handle Pointer to the AEC instance
220 * Outputs Description
221 * -------------------------------------------------------------------
222 * int* median Delay median value.
223 * int* std Delay standard deviation.
228 int WebRtcAec_GetDelayMetrics(void* handle, int* median, int* std);
231 * Gets the last error code.
234 * -------------------------------------------------------------------
235 * void* aecInst Pointer to the AEC instance
237 * Outputs Description
238 * -------------------------------------------------------------------
239 * int32_t return 11000-11100: error code
241 int32_t WebRtcAec_get_error_code(void* aecInst);
243 // Returns a pointer to the low level AEC handle.
246 // - handle : Pointer to the AEC instance.
249 // - AecCore pointer : NULL for error.
251 struct AecCore* WebRtcAec_aec_core(void* handle);
256 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_