smoother.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2005, Digium, Inc.
  5. *
  6. * Mark Spencer <markster@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*! \file
  19. * \brief Asterisk internal frame definitions.
  20. * \arg For an explanation of frames, see \ref Def_Frame
  21. * \arg Frames are send of Asterisk channels, see \ref Def_Channel
  22. */
  23. #ifndef _ASTERISK_SMOOTHER_H
  24. #define _ASTERISK_SMOOTHER_H
  25. #if defined(__cplusplus) || defined(c_plusplus)
  26. extern "C" {
  27. #endif
  28. #include "asterisk/endian.h"
  29. #define AST_SMOOTHER_FLAG_G729 (1 << 0)
  30. #define AST_SMOOTHER_FLAG_BE (1 << 1)
  31. #define AST_SMOOTHER_FLAG_FORCED (1 << 2)
  32. /*! \name AST_Smoother
  33. */
  34. /*@{ */
  35. /*! \page ast_smooth The AST Frame Smoother
  36. The ast_smoother interface was designed specifically
  37. to take frames of variant sizes and produce frames of a single expected
  38. size, precisely what you want to do.
  39. The basic interface is:
  40. - Initialize with ast_smoother_new()
  41. - Queue input frames with ast_smoother_feed()
  42. - Get output frames with ast_smoother_read()
  43. - when you're done, free the structure with ast_smoother_free()
  44. - Also see ast_smoother_test_flag(), ast_smoother_set_flags(), ast_smoother_get_flags(), ast_smoother_reset()
  45. */
  46. struct ast_smoother;
  47. struct ast_frame;
  48. struct ast_smoother *ast_smoother_new(int bytes);
  49. void ast_smoother_set_flags(struct ast_smoother *smoother, int flags);
  50. int ast_smoother_get_flags(struct ast_smoother *smoother);
  51. int ast_smoother_test_flag(struct ast_smoother *s, int flag);
  52. void ast_smoother_free(struct ast_smoother *s);
  53. void ast_smoother_reset(struct ast_smoother *s, int bytes);
  54. /*!
  55. * \brief Reconfigure an existing smoother to output a different number of bytes per frame
  56. * \param s the smoother to reconfigure
  57. * \param bytes the desired number of bytes per output frame
  58. * \return nothing
  59. *
  60. */
  61. void ast_smoother_reconfigure(struct ast_smoother *s, int bytes);
  62. int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap);
  63. struct ast_frame *ast_smoother_read(struct ast_smoother *s);
  64. #define ast_smoother_feed(s,f) __ast_smoother_feed(s, f, 0)
  65. #if __BYTE_ORDER == __LITTLE_ENDIAN
  66. #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 1)
  67. #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 0)
  68. #else
  69. #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 0)
  70. #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 1)
  71. #endif
  72. /*@} Doxygen marker */
  73. #if defined(__cplusplus) || defined(c_plusplus)
  74. }
  75. #endif
  76. #endif /* _ASTERISK_SMOOTHER_H */