bdimad.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. /**
  2. * @file bdIMADpj.h
  3. * @brief bdSound IMproved Audio Device for PJSIP.
  4. */
  5. /**
  6. * @defgroup bd_IMAD bdIMADpj bdSound IMproved Audio Device for PJSIP.
  7. * @ingroup audio_device_api
  8. *
  9. * <b>bdSound IMproved Audio Device</b> is a multi-platform audio interface
  10. * created to integrate in <b>PJSIP</b> library with no effort.
  11. * \n Porting <b>bdIMADpj</b> across the main operating systems is
  12. * straightforward, without the need of change a single line of code.
  13. *
  14. * - <b>Features</b>
  15. * - Echo cancellation (Full Duplex)
  16. * - Noise reduction
  17. * - Automatic Gain Control
  18. * - Audio Enhancement
  19. *
  20. * - <b>Supported operating systems</b>
  21. * - Windows
  22. * - Android
  23. * - MacOS X
  24. * - iOS
  25. * - Linux / Alsa
  26. *
  27. * - <b>Supported platforms</b>
  28. * - x86
  29. * - x64
  30. * - ARM Cortex-A8/A9/A15 with NEON
  31. *
  32. * Visit <a href="http:/www.bdsound.com" target="new">bdSound</a> for updated
  33. * features, supported operating systems and platforms.
  34. *
  35. * <b>Using PJSIP with bdIMAD audio device</b>
  36. *
  37. * - <b>Integration</b>
  38. * \n Using <b>bdIMAD</b> within <b>PJSIP</b> is simple:
  39. * -# Download trial bdIMADpj library from
  40. * <a href="http:/www.bdsound.com" target="new">bdSound</a>;
  41. * -# Follow the integration instructions at
  42. * <a href="http:/www.bdsound.com/support" target="new">bdSound</a>:
  43. *
  44. * - <b>Usage</b>
  45. * \n There are only a couple of things the customer have to pay attention on
  46. * when using bdIMAD library.
  47. *
  48. * - <b>Initialization</b>
  49. * \n Since the bdIMAD library provides itself the echo cancellation
  50. * and the latency management, is necessary to disable these features
  51. * in the PJSIP library applications.
  52. * \n For example in PJSUA sample application there is the need
  53. * to provide the following commands:
  54. * <pre>
  55. * --ec-tail=0
  56. * --no-vad
  57. * --capture-lat=0
  58. * --playback-lat=0
  59. * </pre>
  60. *
  61. * - <b>Supported set capability</b>
  62. * - <code>PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING</code>
  63. * \n Setting speaker volume.
  64. * - <code>PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING</code>
  65. * \n Setting microphone volume.
  66. * - <code>PJMEDIA_AUD_DEV_CAP_EC</code>
  67. * \n Enable/disable echo cancellation.
  68. * - <code>PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE</code>
  69. * \n Support for audio output routing in mobile application(e.g. loudspeaker vs earpiece).
  70. *
  71. * For additional information visit
  72. * <a href="http:/www.bdsound.com" target="new">www.bdsound.com</a>
  73. * or write to info@bdsound.com
  74. *
  75. * @author bdSound
  76. * @version 2.0.0 rev.1618
  77. * @copyright 2015 bdSound srl. All rights reserved.
  78. *
  79. */
  80. /**
  81. * @defgroup groupFunction Functions
  82. * @ingroup bd_IMAD
  83. *
  84. * Functions defined in bdIMAD.
  85. */
  86. /**
  87. * @defgroup groupCallback Callbacks
  88. * @ingroup bd_IMAD
  89. *
  90. * Callbacks defined in bdIMAD.
  91. */
  92. /**
  93. * @defgroup groupStructEnum Structs and Enums
  94. * @ingroup bd_IMAD
  95. *
  96. * Struct and Enum defined in bdIMAD.
  97. */
  98. #ifndef BD_IMAD_PJ_H__
  99. #define BD_IMAD_PJ_H__
  100. /**
  101. * @brief Macro for Windows DLL Support.
  102. */
  103. #ifdef _BDIMADPJ_EXPORTDLL
  104. #ifdef WIN32
  105. #define BDIMADPJ_API __declspec(dllexport)
  106. #else
  107. #define BDIMADPJ_API __attribute__((visibility("default")))
  108. #endif
  109. #else
  110. #define BDIMADPJ_API
  111. #endif
  112. #define BD_IMAD_CAPTURE_DEVICES 1
  113. #define BD_IMAD_PLAYBACK_DEVICES 0
  114. #define BD_IMAD_DIAGNOSTIC_ENABLE 1
  115. #define BD_IMAD_DIAGNOSTIC_DISABLE 0
  116. #define BD_IMAD_BITS_X_SAMPLE 16 /**< Bits per sample */
  117. typedef void* bdIMADpj;
  118. /**
  119. * @addtogroup groupCallback
  120. * @{
  121. */
  122. /**
  123. * @brief Callback used to fill the playback buffer of bdIMAD.
  124. * The function is called by bdIMAD each time are required sample to be played.
  125. *
  126. * @param[in] *buffer pointer to the buffer with the audio
  127. * samples to be played (short type).
  128. *
  129. * @param[in] nSamples number of samples required.
  130. *
  131. * @param[in] user_data pointer to the user data structure
  132. * defined in the bdIMADpj_Setting_t structure.
  133. *
  134. * @return none.
  135. */
  136. typedef int (* cb_fillPlayBackB_t) (void *buffer, int nSamples,
  137. void *user_data);
  138. /**
  139. * @brief Callback used to retrieve the capture buffer of bdIMAD. The function
  140. * is called by bdIMAD each time processed microphone samples are available.
  141. *
  142. * @param[out] *buffer pointer to the buffer with the audio
  143. * samples to be downloaded (short type).
  144. *
  145. * @param[in] nSamples number of samples processed to be downloaded.
  146. *
  147. * @param[in] user_data pointer to the user data structure
  148. * defined in the bdIMADpj_Setting_t structure.
  149. *
  150. * @return none.
  151. */
  152. typedef void (* cb_emptyCaptureB_t) (void *buffer, int nSamples,
  153. void *user_data);
  154. /**
  155. * @}
  156. */
  157. /**
  158. * @addtogroup groupStructEnum
  159. * @{
  160. */
  161. /**
  162. * @brief Error status returned by some functions in the library.
  163. */
  164. typedef enum bdIMADpj_Status {
  165. /** No error. */
  166. BD_PJ_OK = 0,
  167. /** The warnings can be find in the bdIMADpj_Warnings_t structure . */
  168. BD_PJ_WARN_BDIMAD_WARNING_ASSERTED = 1,
  169. /** Error not identified. */
  170. BD_PJ_ERROR_GENERIC = 2,
  171. /** The pointer passed is NULL. */
  172. BD_PJ_ERROR_NULL_POINTER = 3,
  173. /** Allocation procedure failed. */
  174. BD_PJ_ERROR_ALLOCATION = 4,
  175. /** The parameter is not existent or the set/get function is not active. */
  176. BD_PJ_ERROR_PARAMETER_NOT_FOUND = 5,
  177. /** No capture device found. */
  178. BD_PJ_ERROR_IMAD_NONE_CAPTURE_DEV = 10,
  179. /** No play device found. */
  180. BD_PJ_ERROR_IMAD_NONE_PLAY_DEV = 11,
  181. /** Frame size not allowed. */
  182. BD_PJ_ERROR_IMAD_FRAME_SIZE = 12,
  183. /** Sample frequency not allowed. */
  184. BD_PJ_ERROR_IMAD_SAMPLE_FREQ = 13,
  185. /** Samples missing. */
  186. BD_PJ_ERROR_IMAD_MISSING_SAMPLES = 14,
  187. /** Device list is empty. */
  188. BD_PJ_ERROR_IMAD_DEVICE_LIST_EMPTY = 15,
  189. /** Library not authorized, entering demo mode. */
  190. BD_PJ_ERROR_IMAD_LIB_NOT_AUTHORIZED = 16,
  191. /** The input channel memory has not been allocated. */
  192. BD_PJ_ERROR_IMAD_INPUT_CH_NOT_ALLOCATED = 17,
  193. /** The library has expired, entering demo mode. */
  194. BD_PJ_ERROR_IMAD_LICENSE_EXPIRED = 18,
  195. /** Open of capture device failed. */
  196. BD_PJ_ERROR_IMAD_OPEN_CAPTURE_DEV_FAILED = 19,
  197. /** Open of play device failed. */
  198. BD_PJ_ERROR_IMAD_OPEN_PLAY_DEV_FAILED = 20,
  199. /** Start of play device failed. */
  200. BD_PJ_ERROR_IMAD_START_PLAY_DEV_FAILED = 21,
  201. /** Start of capture device failed. */
  202. BD_PJ_ERROR_IMAD_START_CAPTURE_DEV_FAILED = 22,
  203. /** Start of time process failed. */
  204. BD_PJ_ERROR_IMAD_START_TIME_PROCESS_FAILED = 23,
  205. /** Start of thread process failed. */
  206. BD_PJ_ERROR_IMAD_THREAD_PROCESS_FAILED = 24,
  207. /** No volume control available. */
  208. BD_PJ_ERROR_IMAD_NO_VOL_CONTROL_AVAILABLE = 25,
  209. } bdIMADpj_Status;
  210. /**
  211. * @brief Parameter to pass to set and get parameter functions.
  212. *
  213. * For each enumeration are defined the data type and the supported operations
  214. * on that parameter (set and get).
  215. */
  216. typedef enum bdIMADpj_Parameter {
  217. /** int* \n set/get \n 1 enable / 0 disable echo cancellation. */
  218. BD_PARAM_IMAD_PJ_AEC_ENABLE = 0,
  219. /** int* \n set/get \n 0 -> 256 ms of echo tail. */
  220. BD_PARAM_IMAD_PJ_AEC_ECHO_TAIL_MS = 1,
  221. /** int* \n set/get \n 0 -> 400 ms of delay offset. */
  222. BD_PARAM_IMAD_PJ_AEC_DELAY_OFFSET_MS = 2,
  223. /** int* \n set/get \n 1 enable / 0 disable automatic delay estimation. */
  224. BD_PARAM_IMAD_PJ_AEC_AUTO_DELAY_ESTIMATION_ENABLE = 3,
  225. /** int* \n get \n estimated delay in ms. */
  226. BD_PARAM_IMAD_PJ_AEC_AUTO_DELAY_ESTIMATION_VALUE = 4,
  227. /** int* \n get \n 1 is stable / 0 not yet stable estimated delay. */
  228. BD_PARAM_IMAD_PJ_AEC_AUTO_DELAY_ESTIMATION_IS_STABLE = 5,
  229. /** int* \n set/get \n 1 enable / 0 disable Noise Reduction. */
  230. BD_PARAM_IMAD_PJ_NR_ENABLE = 6,
  231. /** int* \n set/get \n 0 low / 1 medium / 2 high / 3 very high / 4 adaptive level of Noise Reduction. */
  232. BD_PARAM_IMAD_PJ_NR_LEVEL = 7,
  233. /** int* \n set/get \n 1 enable / 0 disable Comfort Noise Generator. */
  234. BD_PARAM_IMAD_PJ_CNG_ENABLE = 8,
  235. /** int* \n set/get \n 1 adaptive / 0 not adaptive mode of Comfort Noise Generator. */
  236. BD_PARAM_IMAD_PJ_CNG_SET_ADAPTIVE = 9,
  237. /** int* \n set/get \n -40 -> -100 dBFS fixed power level of Comfort Noise Generator, when adaptive mode is disabled. */
  238. BD_PARAM_IMAD_PJ_CNG_FIXED_LEVEL_DB = 10,
  239. /** int* \n set/get \n 0 minimal / 1 low / 2 intermediate / 3 high / 4 aggressive effort level of Residual Echo Canceller. */
  240. BD_PARAM_IMAD_PJ_REC_EFFORT_LEVEL = 11,
  241. /** int* \n set/get \n 1 enable / 0 disable Non Linear Processor. */
  242. BD_PARAM_IMAD_PJ_NLP_ENABLE = 12,
  243. /** float* \n set/get \n 6.0f -> 24.0f dB Double Talk Detector sensitivity. */
  244. BD_PARAM_IMAD_PJ_NLP_DTD_SENSITIVITY = 13,
  245. /** float* \n set/get \n -50.0f -> 0.0f dB maximum applicable gain by the Non Linear Processor. */
  246. BD_PARAM_IMAD_PJ_NLP_GAIN = 14,
  247. /** int* \n set/get \n 1 enable / 0 disable microphone control
  248. * (when possible). */
  249. BD_PARAM_IMAD_PJ_MIC_CONTROL_ENABLE = 15,
  250. /** float* \n set/get \n 0.0f -> 1.0f volume of
  251. * the microphone(when possible). */
  252. BD_PARAM_IMAD_PJ_MIC_VOLUME = 16,
  253. /** int* \n set/get \n 0 mute / 1 not mute on microphone
  254. * (when possible). */
  255. BD_PARAM_IMAD_PJ_MIC_MUTE = 17,
  256. /** float* \n set/get \n 0.0f -> 1.0f volume of the speaker. */
  257. BD_PARAM_IMAD_PJ_SPK_VOLUME = 18,
  258. /** int* \n set/get \n 0 mute / 1 not mute on speaker. */
  259. BD_PARAM_IMAD_PJ_SPK_MUTE = 19,
  260. } bdIMADpj_Parameter;
  261. /**
  262. * @brief Direction path of the parameter to be used in set and get audio process parameter functions.
  263. *
  264. */
  265. typedef enum bdIMADpj_DirPath {
  266. /** Indicates the send direction path (microphone). */
  267. BD_IMAD_PJ_DIR_PATH_SEND = 0,
  268. /** Indicates the receive direction path (speaker). */
  269. BD_IMAD_PJ_DIR_PATH_RECV = 1,
  270. } bdIMADpj_DirPath;
  271. /**
  272. * @brief Audio processing parameter to pass to set and get audio processing parameter functions.
  273. *
  274. * For each enumeration are defined the data type and the supported operations
  275. * on that parameter (set and get).
  276. */
  277. typedef enum bdIMADpj_AudioProcessParameter {
  278. /** int* \n set/get \n 1 enable / 0 disable whole audio processing chain. */
  279. BD_AP_PARAM_IMAD_PJ_AUDIO_PROC_ENABLE = 200,
  280. /** int* \n set/get \n 1 enable / 0 disable digital gain. */
  281. BD_AP_PARAM_IMAD_PJ_GAIN_ENABLE = 201,
  282. /** float* \n set/get \n 0.0f -> 20.0f dB digital gain value. */
  283. BD_AP_PARAM_IMAD_PJ_GAIN_VALUE_DB = 202,
  284. /** int* \n set/get \n 1 enable / 0 disable Automatic Gain Control. */
  285. BD_AP_PARAM_IMAD_PJ_AGC_ENABLE = 203,
  286. /** float* \n set/get \n 0.0f -> -30.0f dBFS target RMS power of the Automatic Gain Control. */
  287. BD_AP_PARAM_IMAD_PJ_AGC_TARGET_RMS_DB = 204,
  288. /** float* \n set/get \n 0.0f -> 15.0f dB maximum applicable gain by the Automatic Gain Control. */
  289. BD_AP_PARAM_IMAD_PJ_AGC_MAX_GAIN_DB = 205,
  290. /** int* \n set/get \n 1 enable / 0 disable Graphic Equalizer (10 bands). */
  291. BD_AP_PARAM_IMAD_PJ_GEQ_ENABLE = 206,
  292. /** float* \n set/get \n Graphic Equalizer (10 bands) frequencies and gains. \n
  293. Float array of 30 elements, composed by 10 triplets (enable, frequency, gain_dB). \n
  294. First field, enable: 1.0f enable / 0.0f disable the frequency filter. \n
  295. Second field, frequency: 0.0f -> Fs/2 Hz centre frequency of the filter. \n
  296. Third field, gain_dB: -18.0f -> 18.0f dB gain of the filter.
  297. Frequency values in ascending order. \n */
  298. BD_AP_PARAM_IMAD_PJ_GEQ_FREQ_GAIN = 207,
  299. /** int* \n set/get \n 1 enable / 0 disable Compander. */
  300. BD_AP_PARAM_IMAD_PJ_CMP_ENABLE = 208,
  301. /** float* \n set/get \n 0.0f -> 5000.0f ms attack time of gain processor of the Compander. */
  302. BD_AP_PARAM_IMAD_PJ_CMP_ATTACK_TIME_GAIN_MS = 209,
  303. /** float* \n set/get \n 0.0f -> 5000.0f ms release time of gain processor of the Compander. */
  304. BD_AP_PARAM_IMAD_PJ_CMP_RELEASE_TIME_GAIN_MS = 210,
  305. /** float* \n set/get \n 0.0f -> 5000.0f ms attack time of level measurement of the Compander. */
  306. BD_AP_PARAM_IMAD_PJ_CMP_ATTACK_TIME_LEVEL_MS = 211,
  307. /** float* \n set/get \n 0.0f -> 5000.0f ms release time of level measurement of the Compander. */
  308. BD_AP_PARAM_IMAD_PJ_CMP_RELEASE_TIME_LEVEL_MS = 212,
  309. /** int* \n set/get \n 0 -> 10 ms lookahead time of the Compander. */
  310. BD_AP_PARAM_IMAD_PJ_CMP_LOOK_AHEAD_MS = 213,
  311. /** int* \n set/get \n 1 RMS / 0 peak detector of the Compander selected. */
  312. BD_AP_PARAM_IMAD_PJ_CMP_RMS_DETECTOR = 214,
  313. /** float* \n set/get \n 0.0f -> 12.0f dB compensation gain of the Compander. */
  314. BD_AP_PARAM_IMAD_PJ_CMP_COMPENSATION_GAIN_DB = 215,
  315. /** float* \n set/get \n Float sorted array of static gain curve points in dB - up to 4 points: input0, output0, … , input3, output3.
  316. Gain values: 0.0f -> -100.0f dB. */
  317. BD_AP_PARAM_IMAD_PJ_CMP_TABLE = 216,
  318. /** int* \n set/get \n 1 enable / 0 disable Limiter. */
  319. BD_AP_PARAM_IMAD_PJ_LIM_ENABLE = 217,
  320. /** float* \n set/get \n 0.0f -> -40.0f dBFS threshold value of the Limiter. */
  321. BD_AP_PARAM_IMAD_PJ_LIM_THRESHOLD = 218,
  322. } bdIMADpj_AudioProcessParameter;
  323. /**
  324. * @brief Test signal type to be used in set and get test parameter functions.
  325. *
  326. */
  327. typedef enum bdIMADpj_TestSignalType {
  328. /** Indicates a sine wave. */
  329. BD_IMAD_PJ_TS_SINE = 0,
  330. /** Indicates a White Gaussian Noise. */
  331. BD_IMAD_PJ_TS_WGN = 1,
  332. } bdIMADpj_TestSignalType;
  333. /**
  334. * @brief Test parameter to pass to set and get test parameter functions.
  335. *
  336. * For each enumeration are defined the data type and the supported operations
  337. * on that parameter (set and get).
  338. */
  339. typedef enum bdIMADpj_TestParameter {
  340. /** int* \n set/get \n 1 enable / 0 disable Test Signal. */
  341. BD_TEST_PARAM_IMAD_PJ_TEST_SIGNAL_ENABLE = 400,
  342. /** bdIMADpj_TestSignalType* \n set/get \n Test Signal type: sine or Wgn. */
  343. BD_TEST_PARAM_IMAD_PJ_TEST_SIGNAL_TYPE = 401,
  344. /** int* \n set/get \n 0 -> -100 dBFS amplitude of Test Signal. */
  345. BD_TEST_PARAM_IMAD_PJ_TEST_SIGNAL_AMPLITUDE = 402,
  346. /** float* \n set/get \n 0 -> Fs/2 Hz frequency of sine Test Signal . */
  347. BD_TEST_PARAM_IMAD_PJ_TEST_SIGNAL_FREQUENCY = 403,
  348. } bdIMADpj_TestParameter;
  349. /**
  350. * @brief Side to be used in get VU meter level value function.
  351. *
  352. */
  353. typedef enum bdIMADpj_Side {
  354. /** Indicates the input side of a direction path. */
  355. BD_IMAD_PJ_SIDE_INPUT = 0,
  356. /** Indicates the output side of a direction path. */
  357. BD_IMAD_PJ_SIDE_OUTPUT = 1,
  358. } bdIMADpj_Side;
  359. /**
  360. * @brief Instance structure for the information regarding the AEC engine.
  361. */
  362. typedef struct bdIMADpj_Setting_t {
  363. /** Sample frequency (8kHz - 16kHz - 32kHz - 44.1kHz - 48kHz). */
  364. int SamplingFrequency;
  365. /** Audio buffer managed by the AEC bdIMAD functions.
  366. * (from 16ms to 80ms, 16ms recommended). */
  367. int FrameSize_ms;
  368. /** Pointer to the validation functions in the validation library. */
  369. void *validate;
  370. /** Pointer to the the callback function used for filling
  371. * the playback buffer of bdIMAD. */
  372. cb_fillPlayBackB_t cb_fillPlayBackBuffer;
  373. /** Pointer to user data to pass to the callback (playback). */
  374. void *cb_fillPlayBackBuffer_user_data;
  375. /** Pointer to the callback function used for retrieve the processed
  376. * audio present in the capture buffer of bdIMAD. */
  377. cb_emptyCaptureB_t cb_emptyCaptureBuffer;
  378. /** Pointer to user data to pass to the callback (capture). */
  379. void *cb_emptyCaptureBuffer_user_data;
  380. /** Is a wide char pointer to the capture device name. */
  381. wchar_t *CaptureDevice;
  382. /** Is a wide char pointer to the play device name. */
  383. wchar_t *PlayDevice;
  384. /** True to enable diagnostic, false to disable. */
  385. int DiagnosticEnable;
  386. /** Directory which will contains the files generated for diagnostic. */
  387. wchar_t *DiagnosticFolderPath;
  388. /** Is an auxiliary settings pointer used internally by bdIMAD. */
  389. void *bdIMADwr_SettingsData;
  390. } bdIMADpj_Setting_t;
  391. /**
  392. * @brief Instance structure for the warnings generated by the initialization
  393. * functions.
  394. */
  395. typedef struct bdIMADpj_Warnings_t {
  396. /** The capture device indicated can't be opened, then the default capture device
  397. * has been selected. */
  398. int DefaultCaptureDeviceAutomaticallySelected;
  399. /** The capture device opened has not volume control. */
  400. int CaptureDeviceWithoutVolumeControl;
  401. /** The play device indicated can't be opened, then the default play device
  402. * has been selected. */
  403. int DefaultPlayDeviceAutomaticallySelected;
  404. /** The number of channels requested is out of range. The number of
  405. * channels opened is equal to the maximum. */
  406. int NumberOfChannelsOutOfRange;
  407. /** The diagnostic files could not be saved. */
  408. int DiagnosticSaveNotAllowed;
  409. /** The nlp level requested is not allowed, it has been automatically
  410. * changed to the default value. */
  411. int nlpLevelChangeSettting;
  412. /** No capture device is present. Anyway the bdSES has been instantiated
  413. * only for playback. */
  414. int NoCaptureDevicePresent;
  415. /** The CPU is not adapt to run the AEC engine, the AEC has been disabled.
  416. * This happens for very old CPU like pentium III. */
  417. int oldCPUdetected_AECdisable;
  418. /** Windows Direct Sound error. */
  419. long directSoundError;
  420. /** Windows Direct Sound volume error. */
  421. long directSoundLevel;
  422. /** No play device is present. Anyway the bdSES has been instantiated
  423. * only for capture. */
  424. int NoPlayDevicePresent;
  425. } bdIMADpj_Warnings_t;
  426. /**
  427. * @brief Instance structure for the library version
  428. */
  429. typedef struct bdIMADpj_libVersion_t {
  430. int major; /**< major version. */
  431. int minor; /**< minor version. */
  432. int build; /**< build number. */
  433. char *name; /**< name "bdIMADpj ver.X". */
  434. char *version; /**< beta, RC, release. */
  435. char *buildDate; /**< build date. */
  436. } bdIMADpj_libVersion_t;
  437. /**
  438. * @brief Audio output routing setting to pass to set and get route output device functions.
  439. */
  440. typedef enum bdIMADpj_out_dev_route {
  441. /** Default route */
  442. BD_AUD_DEV_ROUTE_DEFAULT = 0,
  443. /** Route to loudspeaker */
  444. BD_AUD_DEV_ROUTE_LOUDSPEAKER = 1,
  445. /** Route to earpiece */
  446. BD_AUD_DEV_ROUTE_EARPIECE = 2
  447. }bdIMADpj_out_dev_route;
  448. /**
  449. * @}
  450. */
  451. /**
  452. * @addtogroup groupFunction
  453. * @{
  454. */
  455. #ifdef __cplusplus
  456. extern "C" {
  457. #endif
  458. /**
  459. * @brief Must be used to allocate and set to default parameter the memory
  460. * for the bdIMAD.
  461. *
  462. * The function generates a structure bdIMADpj_Setting_t filled with the
  463. * default settings.
  464. * \n The user can change this settings according to the need and then
  465. * launch the ::bdIMADpj_InitAEC.
  466. * \n The function generates also a warning structure (::bdIMADpj_Warnings_t)
  467. * that could be used in ::bdIMADpj_InitAEC to handle eventual warnings.
  468. *
  469. * @param[out] **ppSettings Pointer to the pointer of the
  470. * allocated ::bdIMADpj_Setting_t.
  471. *
  472. * @param[out] **ppWarningMessages Pointer to the pointer of the
  473. * allocated ::bdIMADpj_Warnings_t.
  474. *
  475. * @return ::BD_PJ_OK if the function has been
  476. * performed successfully, otherwise return
  477. * an error (refer to ::bdIMADpj_Status).
  478. */
  479. BDIMADPJ_API bdIMADpj_Status bdIMADpj_CreateStructures(
  480. bdIMADpj_Setting_t **ppSettings,
  481. bdIMADpj_Warnings_t **ppWarningMessages);
  482. /**
  483. * @brief Is used to free the memory for the ::bdIMADpj_Setting_t structure and
  484. * ::bdIMADpj_Warnings_t structure allocated with
  485. * the ::bdIMADpj_CreateStructures.
  486. * @param[in] **ppSettings Pointer to a memory location filled
  487. * with the address of the
  488. * ::bdIMADpj_Setting_t structure to free.
  489. * This address will be set to NULL.
  490. *
  491. * @param[in] **ppWarningMessages Pointer to a memory location filled
  492. * with the address of the allocated
  493. * ::bdIMADpj_Warnings_t structure to free.
  494. * This address will be set to NULL.
  495. *
  496. * @return ::BD_PJ_OK if the function has been
  497. * performed successfully, otherwise return
  498. * an error (refer to ::bdIMADpj_Status).
  499. */
  500. BDIMADPJ_API bdIMADpj_Status bdIMADpj_FreeStructures(
  501. bdIMADpj_Setting_t **ppSettings,
  502. bdIMADpj_Warnings_t **ppWarningMessages);
  503. /**
  504. * @brief Is used to initialize the memory for bdIMAD with the settings
  505. * contained in the <code>ppSettings</code>.
  506. *
  507. * @param[out] *pBdIMADInstance Is the pointer to the bdIMAD object.
  508. *
  509. * @param[in] **ppSettings Pointer to pointer to a
  510. * ::bdIMADpj_Setting_t structure, filled
  511. * with initialization settings to be
  512. * applied to the bdIMAD.
  513. * \n Note, the <code>pBdIMADInstance</code>
  514. * is modified with the applied settings.
  515. *
  516. * @param[out] **ppWarningMessages Pointer to pointer to a
  517. * ::bdIMADpj_Warnings_t structure,
  518. * which reports the warnings after the
  519. * initialization.
  520. *
  521. * @return ::BD_PJ_OK if the function has been
  522. * performed successfully, otherwise return
  523. * an error (refer to ::bdIMADpj_Status).
  524. * \n If the error is
  525. * ::BD_PJ_WARN_BDIMAD_WARNING_ASSERTED
  526. * the init function has been performed with success,
  527. * but with a different settings
  528. * respect to the ones required.
  529. * This mainly happens if the audio
  530. * device opened is different to the
  531. * one requested.
  532. */
  533. BDIMADPJ_API bdIMADpj_Status bdIMADpj_InitAEC(bdIMADpj *pBdIMADInstance,
  534. bdIMADpj_Setting_t **ppSettings,
  535. bdIMADpj_Warnings_t **ppWarningMessages);
  536. /**
  537. * @brief Is used to free the bdIMAD object pointed by the
  538. * <code>pBdIMADInstance</code>.
  539. *
  540. * @param[in] *pBdIMADInstance Pointer to the bdIMAD object to free.
  541. *
  542. * @return ::BD_PJ_OK if the function has been
  543. * performed successfully, otherwise return
  544. * an error (refer to ::bdIMADpj_Status).
  545. */
  546. BDIMADPJ_API bdIMADpj_Status bdIMADpj_FreeAEC(bdIMADpj *pBdIMADInstance);
  547. /**
  548. * @brief Is used to make a list of capture and play devices available
  549. * on the system.
  550. *
  551. * @param[in] captureDevice Set to 1 to get the list of capture
  552. * devices. Set to 0 to get the list of
  553. * play devices.
  554. *
  555. * @param[in] **deviceName Pointer to pointer to a wide char
  556. * containing the names of capture/play
  557. * devices.
  558. *
  559. * @return ::BD_PJ_OK if the function has been
  560. * performed successfully, otherwise return
  561. * an error (refer to ::bdIMADpj_Status).
  562. */
  563. BDIMADPJ_API bdIMADpj_Status bdIMADpj_getDeviceName(int captureDevice,
  564. wchar_t **deviceName);
  565. /**
  566. * @brief Is used to freeze the bdIMAD, stopping the audio playback
  567. * and recording.
  568. *
  569. * @param[in] bdIMADInstance bdIMAD object.
  570. *
  571. * @return ::BD_PJ_OK if the function has been
  572. * performed successfully, otherwise return
  573. * an error (refer to ::bdIMADpj_Status).
  574. */
  575. BDIMADPJ_API bdIMADpj_Status bdIMADpj_stop(bdIMADpj bdIMADInstance);
  576. /**
  577. * @brief Is used to put back in play the audio after it has been stopped by the
  578. * ::bdIMADpj_stop functions.
  579. * @param[in] bdIMADInstance bdIMAD object.
  580. * @return ::BD_PJ_OK if the function has been
  581. * performed successfully, otherwise
  582. * return an error (refer to
  583. * ::bdIMADpj_Status).
  584. */
  585. BDIMADPJ_API bdIMADpj_Status bdIMADpj_run(bdIMADpj bdIMADInstance);
  586. /**
  587. * @brief Print on a standard output the warning messages.
  588. *
  589. * @param[in] *pWarningMessages Pointer to the warning structure
  590. * to be printed.
  591. *
  592. * @return ::BD_PJ_OK if the function has been
  593. * performed successfully, otherwise return
  594. * an error (refer to ::bdIMADpj_Status).
  595. */
  596. BDIMADPJ_API bdIMADpj_Status bdIMADpj_DisplayWarnings(
  597. bdIMADpj_Warnings_t *pWarningMessages);
  598. /**
  599. * @brief Clear the warning structure after being read.
  600. *
  601. * @param[out] **ppWarningMessages Pointer to pointer to the warning
  602. * structure to be cleared.
  603. *
  604. * @return ::BD_PJ_OK if the function has been
  605. * performed successfully, otherwise return
  606. * an error (refer to ::bdIMADpj_Status).
  607. */
  608. BDIMADPJ_API bdIMADpj_Status bdIMADpj_ClearAllWarnings(
  609. bdIMADpj_Warnings_t **ppWarningMessages);
  610. /**
  611. * @brief Is used to set a parameter of the bdIMAD object pointed by the
  612. * <code>pBdIMADInstance</code>.
  613. *
  614. * @param[in] bdIMADInstance bdIMAD object.
  615. *
  616. * @param[in] parameterName Indicates the parameter to be set.
  617. *
  618. * @param[in] *pValue Is a pointer to the value to be set.
  619. * \n In the ::bdIMADpj_Parameter
  620. * declaration is indicated the type of
  621. * the value, depending on the
  622. * <code>parameterName</code>.
  623. *
  624. * @return ::BD_PJ_OK if the function has been
  625. * performed successfully, otherwise return
  626. * an error (refer to ::bdIMADpj_Status).
  627. */
  628. BDIMADPJ_API bdIMADpj_Status bdIMADpj_setParameter(bdIMADpj bdIMADInstance,
  629. bdIMADpj_Parameter parameterName, void *pValue);
  630. /**
  631. * @brief Is used to get a parameter of the bdIMAD object pointed by the
  632. * <code>pBdIMADInstance</code>.
  633. *
  634. * @param[in] bdIMADInstance bdIMAD object.
  635. *
  636. * @param[in] parameterName Indicates the parameter to be get.
  637. *
  638. * @param[out] *pValue Is a pointer to the value to be get.
  639. * \n In the ::bdIMADpj_Parameter
  640. * declaration is indicated the type of
  641. * the value, depending on the
  642. * <code>parameterName</code>.
  643. *
  644. * @return ::BD_PJ_OK if the function has been
  645. * performed successfully, otherwise return
  646. * an error (refer to ::bdIMADpj_Status).
  647. */
  648. BDIMADPJ_API bdIMADpj_Status bdIMADpj_getParameter(bdIMADpj bdIMADInstance,
  649. bdIMADpj_Parameter parameterName, void *pValue);
  650. /**
  651. * @brief Is used to set an audio processing parameter of the bdIMAD object pointed by the
  652. * <code>pBdIMADInstance</code>.
  653. *
  654. * @param[in] bdIMADInstance bdIMAD object.
  655. *
  656. * @param[in] parameterName Indicates the parameter to be set.
  657. *
  658. * @param[in] directionPath Indicates the send/receive direction path.
  659. * The parameter will be set to the audio process block
  660. * located in the selected path.
  661. *
  662. * @param[in] *pValue Is a pointer to the value to be set.
  663. * \n In the ::bdIMADpj_AudioProcessParameter
  664. * declaration is indicated the real type of
  665. * the value, depending on the
  666. * <code>parameterName</code>.
  667. *
  668. * @return ::BD_PJ_OK if the function has been
  669. * performed successfully, otherwise return
  670. * an error (refer to ::bdIMADpj_Status).
  671. */
  672. BDIMADPJ_API bdIMADpj_Status bdIMADpj_setAudioProcessParameter(bdIMADpj bdIMADInstance,
  673. bdIMADpj_AudioProcessParameter parameterName, bdIMADpj_DirPath directionPath, void *pValue);
  674. /**
  675. * @brief Is used to get an audio processing parameter of the bdIMAD object pointed by the
  676. * <code>pBdIMADInstance</code>.
  677. *
  678. * @param[in] bdIMADInstance bdIMAD object.
  679. *
  680. * @param[in] parameterName Indicates the parameter to be get.
  681. *
  682. * @param[in] directionPath Indicates the send/receive direction path.
  683. * The parameter will be get from the audio process block
  684. * located in the selected path.
  685. *
  686. * @param[out] *pValue Is a pointer to the value to be get.
  687. * \n In the ::bdIMADpj_AudioProcessParameter
  688. * declaration is indicated the real type of
  689. * the value, depending on the
  690. * <code>parameterName</code>.
  691. *
  692. * @return ::BD_PJ_OK if the function has been
  693. * performed successfully, otherwise return
  694. * an error (refer to ::bdIMADpj_Status).
  695. */
  696. BDIMADPJ_API bdIMADpj_Status bdIMADpj_getAudioProcessParameter(bdIMADpj bdIMADInstance,
  697. bdIMADpj_AudioProcessParameter parameterName, bdIMADpj_DirPath directionPath, void *pValue);
  698. /**
  699. * @brief Is used to set a test parameter of the bdIMAD object pointed by the
  700. * <code>pBdIMADInstance</code>.
  701. *
  702. * @param[in] bdIMADInstance bdIMAD object.
  703. *
  704. * @param[in] parameterName Indicates the parameter to be set.
  705. *
  706. * @param[in] directionPath Indicates the send/receive direction path.
  707. * The parameter will be set to the test generator block
  708. * located in the selected path.
  709. *
  710. * @param[in] *pValue Is a pointer to the value to be set.
  711. * \n In the ::bdIMADpj_TestParameter
  712. * declaration is indicated the real type of
  713. * the value, depending on the
  714. * <code>parameterName</code>.
  715. *
  716. * @return ::BD_PJ_OK if the function has been
  717. * performed successfully, otherwise return
  718. * an error (refer to ::bdIMADpj_Status).
  719. */
  720. BDIMADPJ_API bdIMADpj_Status bdIMADpj_setTestParameter(bdIMADpj bdIMADInstance, bdIMADpj_TestParameter parameterName, bdIMADpj_DirPath directionPath, void* pValue);
  721. /**
  722. * @brief Is used to get a test parameter of the bdIMAD object pointed by the
  723. * <code>pBdIMADInstance</code>.
  724. *
  725. * @param[in] bdIMADInstance bdIMAD object.
  726. *
  727. * @param[in] parameterName Indicates the parameter to be get.
  728. *
  729. * @param[in] directionPath Indicates the send/receive direction path.
  730. * The parameter will be get from the test generator block
  731. * located in the selected path.
  732. *
  733. * @param[out] *pValue Is a pointer to the value to be get.
  734. * \n In the ::bdIMADpj_TestParameter
  735. * declaration is indicated the real type of
  736. * the value, depending on the
  737. * <code>parameterName</code>.
  738. *
  739. * @return ::BD_PJ_OK if the function has been
  740. * performed successfully, otherwise return
  741. * an error (refer to ::bdIMADpj_Status).
  742. */
  743. BDIMADPJ_API bdIMADpj_Status bdIMADpj_getTestParameter(bdIMADpj bdIMADInstance, bdIMADpj_TestParameter parameterName, bdIMADpj_DirPath directionPath, void* pValue);
  744. /**
  745. * @brief Is used to get the VU meter level value located at the input/output
  746. * of the send/receive path of the bdIMAD object pointed by the
  747. * <code>pBdIMADInstance</code>.
  748. *
  749. * @param[in] bdIMADInstance bdIMAD object.
  750. *
  751. * @param[in] directionPath Indicates the send/receive direction path.
  752. * The level value will be get from
  753. * the VU meter located in the selected path.
  754. *
  755. * @param[in] side Indicates the input/output side.
  756. * The level value will be get from
  757. * the VU meter located at the selected
  758. * side of the selected path.
  759. *
  760. * @param[out] *pValue Is a pointer to the float level value to be get.
  761. *
  762. * @return ::BD_PJ_OK if the function has been
  763. * performed successfully, otherwise return
  764. * an error (refer to ::bdIMADpj_Status).
  765. */
  766. BDIMADPJ_API bdIMADpj_Status bdIMADpj_getVuMeterLevelValue(bdIMADpj bdIMADInstance, bdIMADpj_DirPath directionPath, bdIMADpj_Side side, float* pValue);
  767. /**
  768. * @brief Is used to enable/disable socket communication with GUI of the bdIMAD object pointed by the
  769. * <code>pBdIMADInstance</code>.
  770. *
  771. * @param[in] bdIMADInstance bdIMAD object.
  772. *
  773. * @param[in] port Receive port number to be used for socket communication (bdController).
  774. *
  775. * @param[in] enable Set 1 to enable, 0 to disable the socket communication [default=disabled].
  776. *
  777. * @return ::BD_PJ_OK if the function has been
  778. * performed successfully, otherwise return
  779. * an error (refer to ::bdIMADpj_Status).
  780. */
  781. BDIMADPJ_API bdIMADpj_Status bdIMADpj_enableGuiSocketCommunication(bdIMADpj bdIMADInstance, int port, int enable);
  782. /**
  783. * @brief Is used to set the route of the output device of the bdIMAD object pointed by the
  784. * <code>pBdIMADInstance</code>.
  785. *
  786. * @param[in] bdIMADInstance bdIMAD object.
  787. *
  788. * @param[in] outputRoute Indicates the route of the output device to be set.
  789. *
  790. * @param[out] **ppWarningMessages Pointer to pointer to a
  791. * ::bdIMADpj_Warnings_t structure,
  792. * which reports the warnings after the
  793. * set function.
  794. *
  795. * @return ::BD_PJ_OK if the function has been
  796. * performed successfully, otherwise return
  797. * an error (refer to ::bdIMADpj_Status).
  798. */
  799. BDIMADPJ_API bdIMADpj_Status bdIMADpj_setRouteOutputDevice(bdIMADpj bdIMADInstance, bdIMADpj_out_dev_route outputRoute, bdIMADpj_Warnings_t **ppWarningMessages);
  800. /**
  801. * @brief Is used to get the route of the output device of the bdIMAD object pointed by the
  802. * <code>pBdIMADInstance</code>.
  803. *
  804. * @param[in] bdIMADInstance bdIMAD object.
  805. *
  806. * @param[out] *outputRoute Pointer to the route of the output device currently set.
  807. *
  808. * @return ::BD_PJ_OK if the function has been
  809. * performed successfully, otherwise return
  810. * an error (refer to ::bdIMADpj_Status).
  811. */
  812. BDIMADPJ_API bdIMADpj_Status bdIMADpj_getRouteOutputDevice(bdIMADpj bdIMADInstance, bdIMADpj_out_dev_route *outputRoute);
  813. /**
  814. * @brief Is used to get the device capabilities of capture/playback device of the bdIMAD object pointed by the
  815. * <code>pBdIMADInstance</code>.
  816. *
  817. * @param[in] captureDevice Set to 1 to get the capabilities of capture
  818. * devices. Set to 0 to get the capabilities of
  819. * play devices.
  820. *
  821. * @caps[out] *caps Is a pointer to the device capabilities,
  822. * as bitmask combination of #pjmedia_aud_dev_cap.
  823. *
  824. * @return ::BD_PJ_OK if the function has been
  825. * performed successfully, otherwise return
  826. * an error (refer to ::bdIMADpj_Status).
  827. */
  828. BDIMADPJ_API bdIMADpj_Status bdIMADpj_getDeviceCapabilities(int captureDevice, unsigned *caps);
  829. #ifdef __cplusplus
  830. }
  831. #endif
  832. /**
  833. * @}
  834. */
  835. #endif //BD_IMAD_PJ_H__