oslec.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * OSLEC - A line echo canceller. This code is being developed
  4. * against and partially complies with G168. Using code from SpanDSP
  5. *
  6. * Written by Steve Underwood <steveu@coppice.org>
  7. * and David Rowe <david_at_rowetel_dot_com>
  8. *
  9. * Copyright (C) 2001 Steve Underwood and 2007-2008 David Rowe
  10. *
  11. * All rights reserved.
  12. */
  13. #ifndef __OSLEC_H
  14. #define __OSLEC_H
  15. /* Mask bits for the adaption mode */
  16. #define ECHO_CAN_USE_ADAPTION 0x01
  17. #define ECHO_CAN_USE_NLP 0x02
  18. #define ECHO_CAN_USE_CNG 0x04
  19. #define ECHO_CAN_USE_CLIP 0x08
  20. #define ECHO_CAN_USE_TX_HPF 0x10
  21. #define ECHO_CAN_USE_RX_HPF 0x20
  22. #define ECHO_CAN_DISABLE 0x40
  23. /**
  24. * oslec_state: G.168 echo canceller descriptor.
  25. *
  26. * This defines the working state for a line echo canceller.
  27. */
  28. struct oslec_state;
  29. /**
  30. * oslec_create - Create a voice echo canceller context.
  31. * @len: The length of the canceller, in samples.
  32. * @return: The new canceller context, or NULL if the canceller could not be
  33. * created.
  34. */
  35. struct oslec_state *oslec_create(int len, int adaption_mode);
  36. /**
  37. * oslec_free - Free a voice echo canceller context.
  38. * @ec: The echo canceller context.
  39. */
  40. void oslec_free(struct oslec_state *ec);
  41. /**
  42. * oslec_flush - Flush (reinitialise) a voice echo canceller context.
  43. * @ec: The echo canceller context.
  44. */
  45. void oslec_flush(struct oslec_state *ec);
  46. /**
  47. * oslec_adaption_mode - set the adaption mode of a voice echo canceller context.
  48. * @ec The echo canceller context.
  49. * @adaption_mode: The mode.
  50. */
  51. void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode);
  52. void oslec_snapshot(struct oslec_state *ec);
  53. /**
  54. * oslec_update: Process a sample through a voice echo canceller.
  55. * @ec: The echo canceller context.
  56. * @tx: The transmitted audio sample.
  57. * @rx: The received audio sample.
  58. *
  59. * The return value is the clean (echo cancelled) received sample.
  60. */
  61. int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx);
  62. /**
  63. * oslec_hpf_tx: Process to high pass filter the tx signal.
  64. * @ec: The echo canceller context.
  65. * @tx: The transmitted auio sample.
  66. *
  67. * The return value is the HP filtered transmit sample, send this to your D/A.
  68. */
  69. int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx);
  70. #endif /* __OSLEC_H */