speex_jitter_buffer.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright (C) 2002 Jean-Marc Valin */
  2. /**
  3. @file speex_jitter_buffer.h
  4. @brief Adaptive jitter buffer for Speex packets only
  5. */
  6. #include <speex/speex_jitter.h>
  7. #include <speex/speex.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /** @defgroup SpeexJitter SpeexJitter: Adaptive jitter buffer specifically for Speex
  12. * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size
  13. * to maintain good quality and low latency. This is a simplified version that works only
  14. * with Speex, but is much easier to use.
  15. * @{
  16. */
  17. /** Speex jitter-buffer state. Never use it directly! */
  18. typedef struct SpeexJitter {
  19. SpeexBits current_packet; /**< Current Speex packet */
  20. int valid_bits; /**< True if Speex bits are valid */
  21. JitterBuffer *packets; /**< Generic jitter buffer state */
  22. void *dec; /**< Pointer to Speex decoder */
  23. spx_int32_t frame_size; /**< Frame size of Speex decoder */
  24. } SpeexJitter;
  25. /** Initialise jitter buffer
  26. *
  27. * @param jitter State of the Speex jitter buffer
  28. * @param decoder Speex decoder to call
  29. * @param sampling_rate Sampling rate used by the decoder
  30. */
  31. void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate);
  32. /** Destroy jitter buffer */
  33. void speex_jitter_destroy(SpeexJitter *jitter);
  34. /** Put one packet into the jitter buffer */
  35. void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int timestamp);
  36. /** Get one packet from the jitter buffer */
  37. void speex_jitter_get(SpeexJitter *jitter, spx_int16_t *out, int *start_offset);
  38. /** Get pointer timestamp of jitter buffer */
  39. int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. /* @} */