src/spandsp/jitter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #if !defined(_SPANDSP_JITTERBUFFER_H_)
00031 #define _SPANDSP_JITTERBUFFER_H_
00032
00033
00034
00035
00036
00037
00038
00039
00040 #define INITIAL_JITTER 640 // 80 miliseconds
00041 #define MAX_JITTER 16000 // 2 seconds
00042 #define RESYNC_THRESHOLD 2
00043
00044 typedef struct
00045 {
00046 int16_t data[AUDIO_BUFFER_SIZE*2];
00047 uint32_t size;
00048 uint32_t ts;
00049 public:
00050 packet_t *next;
00051 packet_t *prev;
00052 void init(const int16_t *data, uint32_t size, uint32_t ts);
00053
00054 uint32_t size() const { return size; }
00055 int16_t *data() { return data; }
00056
00057 bool operator < (const Packet&) const;
00058 } packet_t;
00059
00060 typedef struct
00061 {
00062 private:
00063 packet_t packets[MAX_JITTER/80];
00064 packet_t *free_packets;
00065
00066 public:
00067 packet_allocator(void);
00068 packet_t *alloc(const int16_t *data, uint32_t size, uint32_t ts);
00069 } packet_allocator_t;
00070
00071 typedef struct
00072 {
00073 packet_allocator_t allocator;
00074 packet_t *head;
00075 packet_t *tail;
00076 int ts_inited;
00077 timestamp_t last_ts;
00078 timestamp_t last_resync_ts;
00079 timestamp_t last_audio_ts;
00080 timestamp_t ts_delta;
00081 int ts_delta_inited;
00082 int delay_count;
00083 uint32_t jitter;
00084 int force_resync;
00085 #ifdef DEBUG_PLAYOUTBUF
00086 uint32_t ts_delta_start;
00087 #endif
00088 } playout_state_t;
00089
00090 #if defined(__cplusplus)
00091 extern "C"
00092 {
00093 #endif
00094
00095 void playout_put(playout_state_t *s, const int16_t *data, timestamp_t size, timestamp_t ts, int begin_talk);
00096 int playout_get(playout_state_t *s, timestamp_t ts, uint32_t ms, int16_t *out, uint32_t *size, timestamp_t *out_ts);
00097
00098 #if defined(__cplusplus)
00099 }
00100 #endif
00101
00102 #endif
00103