echo_control_mobile.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Copyright (c) 2012 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. #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_
  11. #define WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_
  12. #include "typedefs.h"
  13. enum {
  14. AecmFalse = 0,
  15. AecmTrue
  16. };
  17. // Errors
  18. #define AECM_UNSPECIFIED_ERROR 12000
  19. #define AECM_UNSUPPORTED_FUNCTION_ERROR 12001
  20. #define AECM_UNINITIALIZED_ERROR 12002
  21. #define AECM_NULL_POINTER_ERROR 12003
  22. #define AECM_BAD_PARAMETER_ERROR 12004
  23. // Warnings
  24. #define AECM_BAD_PARAMETER_WARNING 12100
  25. typedef struct {
  26. WebRtc_Word16 cngMode; // AECM_FALSE, AECM_TRUE (default)
  27. WebRtc_Word16 echoMode; // 0, 1, 2, 3 (default), 4
  28. } AecmConfig;
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /*
  33. * Allocates the memory needed by the AECM. The memory needs to be
  34. * initialized separately using the WebRtcAecm_Init() function.
  35. *
  36. * Inputs Description
  37. * -------------------------------------------------------------------
  38. * void **aecmInst Pointer to the AECM instance to be
  39. * created and initialized
  40. *
  41. * Outputs Description
  42. * -------------------------------------------------------------------
  43. * WebRtc_Word32 return 0: OK
  44. * -1: error
  45. */
  46. WebRtc_Word32 WebRtcAecm_Create(void **aecmInst);
  47. /*
  48. * This function releases the memory allocated by WebRtcAecm_Create()
  49. *
  50. * Inputs Description
  51. * -------------------------------------------------------------------
  52. * void *aecmInst Pointer to the AECM instance
  53. *
  54. * Outputs Description
  55. * -------------------------------------------------------------------
  56. * WebRtc_Word32 return 0: OK
  57. * -1: error
  58. */
  59. WebRtc_Word32 WebRtcAecm_Free(void *aecmInst);
  60. /*
  61. * Initializes an AECM instance.
  62. *
  63. * Inputs Description
  64. * -------------------------------------------------------------------
  65. * void *aecmInst Pointer to the AECM instance
  66. * WebRtc_Word32 sampFreq Sampling frequency of data
  67. *
  68. * Outputs Description
  69. * -------------------------------------------------------------------
  70. * WebRtc_Word32 return 0: OK
  71. * -1: error
  72. */
  73. WebRtc_Word32 WebRtcAecm_Init(void* aecmInst,
  74. WebRtc_Word32 sampFreq);
  75. /*
  76. * Inserts an 80 or 160 sample block of data into the farend buffer.
  77. *
  78. * Inputs Description
  79. * -------------------------------------------------------------------
  80. * void *aecmInst Pointer to the AECM instance
  81. * WebRtc_Word16 *farend In buffer containing one frame of
  82. * farend signal
  83. * WebRtc_Word16 nrOfSamples Number of samples in farend buffer
  84. *
  85. * Outputs Description
  86. * -------------------------------------------------------------------
  87. * WebRtc_Word32 return 0: OK
  88. * -1: error
  89. */
  90. WebRtc_Word32 WebRtcAecm_BufferFarend(void* aecmInst,
  91. const WebRtc_Word16* farend,
  92. WebRtc_Word16 nrOfSamples);
  93. /*
  94. * Runs the AECM on an 80 or 160 sample blocks of data.
  95. *
  96. * Inputs Description
  97. * -------------------------------------------------------------------
  98. * void *aecmInst Pointer to the AECM instance
  99. * WebRtc_Word16 *nearendNoisy In buffer containing one frame of
  100. * reference nearend+echo signal. If
  101. * noise reduction is active, provide
  102. * the noisy signal here.
  103. * WebRtc_Word16 *nearendClean In buffer containing one frame of
  104. * nearend+echo signal. If noise
  105. * reduction is active, provide the
  106. * clean signal here. Otherwise pass a
  107. * NULL pointer.
  108. * WebRtc_Word16 nrOfSamples Number of samples in nearend buffer
  109. * WebRtc_Word16 msInSndCardBuf Delay estimate for sound card and
  110. * system buffers
  111. *
  112. * Outputs Description
  113. * -------------------------------------------------------------------
  114. * WebRtc_Word16 *out Out buffer, one frame of processed nearend
  115. * WebRtc_Word32 return 0: OK
  116. * -1: error
  117. */
  118. WebRtc_Word32 WebRtcAecm_Process(void* aecmInst,
  119. const WebRtc_Word16* nearendNoisy,
  120. const WebRtc_Word16* nearendClean,
  121. WebRtc_Word16* out,
  122. WebRtc_Word16 nrOfSamples,
  123. WebRtc_Word16 msInSndCardBuf);
  124. /*
  125. * This function enables the user to set certain parameters on-the-fly
  126. *
  127. * Inputs Description
  128. * -------------------------------------------------------------------
  129. * void *aecmInst Pointer to the AECM instance
  130. * AecmConfig config Config instance that contains all
  131. * properties to be set
  132. *
  133. * Outputs Description
  134. * -------------------------------------------------------------------
  135. * WebRtc_Word32 return 0: OK
  136. * -1: error
  137. */
  138. WebRtc_Word32 WebRtcAecm_set_config(void* aecmInst,
  139. AecmConfig config);
  140. /*
  141. * This function enables the user to set certain parameters on-the-fly
  142. *
  143. * Inputs Description
  144. * -------------------------------------------------------------------
  145. * void *aecmInst Pointer to the AECM instance
  146. *
  147. * Outputs Description
  148. * -------------------------------------------------------------------
  149. * AecmConfig *config Pointer to the config instance that
  150. * all properties will be written to
  151. * WebRtc_Word32 return 0: OK
  152. * -1: error
  153. */
  154. WebRtc_Word32 WebRtcAecm_get_config(void *aecmInst,
  155. AecmConfig *config);
  156. /*
  157. * This function enables the user to set the echo path on-the-fly.
  158. *
  159. * Inputs Description
  160. * -------------------------------------------------------------------
  161. * void* aecmInst Pointer to the AECM instance
  162. * void* echo_path Pointer to the echo path to be set
  163. * size_t size_bytes Size in bytes of the echo path
  164. *
  165. * Outputs Description
  166. * -------------------------------------------------------------------
  167. * WebRtc_Word32 return 0: OK
  168. * -1: error
  169. */
  170. WebRtc_Word32 WebRtcAecm_InitEchoPath(void* aecmInst,
  171. const void* echo_path,
  172. size_t size_bytes);
  173. /*
  174. * This function enables the user to get the currently used echo path
  175. * on-the-fly
  176. *
  177. * Inputs Description
  178. * -------------------------------------------------------------------
  179. * void* aecmInst Pointer to the AECM instance
  180. * void* echo_path Pointer to echo path
  181. * size_t size_bytes Size in bytes of the echo path
  182. *
  183. * Outputs Description
  184. * -------------------------------------------------------------------
  185. * WebRtc_Word32 return 0: OK
  186. * -1: error
  187. */
  188. WebRtc_Word32 WebRtcAecm_GetEchoPath(void* aecmInst,
  189. void* echo_path,
  190. size_t size_bytes);
  191. /*
  192. * This function enables the user to get the echo path size in bytes
  193. *
  194. * Outputs Description
  195. * -------------------------------------------------------------------
  196. * size_t return : size in bytes
  197. */
  198. size_t WebRtcAecm_echo_path_size_bytes();
  199. /*
  200. * Gets the last error code.
  201. *
  202. * Inputs Description
  203. * -------------------------------------------------------------------
  204. * void *aecmInst Pointer to the AECM instance
  205. *
  206. * Outputs Description
  207. * -------------------------------------------------------------------
  208. * WebRtc_Word32 return 11000-11100: error code
  209. */
  210. WebRtc_Word32 WebRtcAecm_get_error_code(void *aecmInst);
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214. #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_