fixedjitterbuf.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2005, Attractel OOD
  3. *
  4. * Contributors:
  5. * Slav Klenov <slav@securax.org>
  6. *
  7. * Copyright on this file is disclaimed to Digium for inclusion in Asterisk
  8. *
  9. * See http://www.asterisk.org for more information about
  10. * the Asterisk project. Please do not directly contact
  11. * any of the maintainers of this project for assistance;
  12. * the project provides a web site, mailing lists and IRC
  13. * channels for your use.
  14. *
  15. * This program is free software, distributed under the terms of
  16. * the GNU General Public License Version 2. See the LICENSE file
  17. * at the top of the source tree.
  18. */
  19. /*! \file
  20. *
  21. * \brief Jitterbuffering algorithm.
  22. *
  23. */
  24. #ifndef _FIXEDJITTERBUF_H_
  25. #define _FIXEDJITTERBUF_H_
  26. #if defined(__cplusplus) || defined(c_plusplus)
  27. extern "C" {
  28. #endif
  29. /* return codes */
  30. enum {
  31. FIXED_JB_OK,
  32. FIXED_JB_DROP,
  33. FIXED_JB_INTERP,
  34. FIXED_JB_NOFRAME
  35. };
  36. /* defaults */
  37. #define FIXED_JB_SIZE_DEFAULT 200
  38. #define FIXED_JB_RESYNCH_THRESHOLD_DEFAULT 1000
  39. /* jb configuration properties */
  40. struct fixed_jb_conf
  41. {
  42. long jbsize;
  43. long resync_threshold;
  44. };
  45. struct fixed_jb_frame
  46. {
  47. void *data;
  48. long ts;
  49. long ms;
  50. long delivery;
  51. struct fixed_jb_frame *next;
  52. struct fixed_jb_frame *prev;
  53. };
  54. struct fixed_jb;
  55. /* jb interface */
  56. struct fixed_jb * fixed_jb_new(struct fixed_jb_conf *conf);
  57. void fixed_jb_destroy(struct fixed_jb *jb);
  58. int fixed_jb_put_first(struct fixed_jb *jb, void *data, long ms, long ts, long now);
  59. int fixed_jb_put(struct fixed_jb *jb, void *data, long ms, long ts, long now);
  60. int fixed_jb_get(struct fixed_jb *jb, struct fixed_jb_frame *frame, long now, long interpl);
  61. long fixed_jb_next(struct fixed_jb *jb);
  62. int fixed_jb_remove(struct fixed_jb *jb, struct fixed_jb_frame *frameout);
  63. void fixed_jb_set_force_resynch(struct fixed_jb *jb);
  64. /*! \brief Checks if the given time stamp is late */
  65. int fixed_jb_is_late(struct fixed_jb *jb, long ts);
  66. #if defined(__cplusplus) || defined(c_plusplus)
  67. }
  68. #endif
  69. #endif /* _FIXEDJITTERBUF_H_ */