echo_control_mobile.h 7.8 KB

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