123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- #ifndef _JITTERBUF_H_
- #define _JITTERBUF_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #define JB_HISTORY_SZ 500
-
- #define JB_HISTORY_DROPPCT 3
-
- #define JB_HISTORY_DROPPCT_MAX 4
-
- #define JB_HISTORY_MAXBUF_SZ JB_HISTORY_SZ * JB_HISTORY_DROPPCT_MAX / 100
-
- #define JB_TARGET_EXTRA 40
-
- #define JB_ADJUST_DELAY 40
- enum jb_return_code {
-
- JB_OK,
- JB_EMPTY,
- JB_NOFRAME,
- JB_INTERP,
- JB_DROP,
- JB_SCHED
- };
- enum jb_frame_type {
-
- JB_TYPE_CONTROL,
- JB_TYPE_VOICE,
- JB_TYPE_VIDEO,
- JB_TYPE_SILENCE
- };
- typedef struct jb_conf {
-
- long max_jitterbuf;
- long resync_threshold;
- long max_contig_interp;
- long target_extra ;
- } jb_conf;
- typedef struct jb_info {
- jb_conf conf;
-
- long frames_in;
- long frames_out;
- long frames_late;
- long frames_lost;
- long frames_dropped;
- long frames_ooo;
- long frames_cur;
- long jitter;
- long min;
- long current;
- long target;
- long losspct;
- long next_voice_ts;
- long last_voice_ms;
- long silence_begin_ts;
- long last_adjustment;
- long last_delay;
- long cnt_delay_discont;
- long resync_offset;
- long cnt_contig_interp;
- } jb_info;
- typedef struct jb_frame {
- void *data;
- long ts;
- long ms;
- enum jb_frame_type type;
- struct jb_frame *next, *prev;
- } jb_frame;
- typedef struct jitterbuf {
- jb_info info;
-
- long history[JB_HISTORY_SZ];
- int hist_ptr;
- long hist_maxbuf[JB_HISTORY_MAXBUF_SZ];
- long hist_minbuf[JB_HISTORY_MAXBUF_SZ];
- int hist_maxbuf_valid;
- unsigned int dropem:1;
- jb_frame *frames;
- jb_frame *free;
- } jitterbuf;
- jitterbuf * jb_new(void);
- void jb_destroy(jitterbuf *jb);
- void jb_reset(jitterbuf *jb);
- enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now);
- enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl);
- enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout);
- long jb_next(jitterbuf *jb);
- enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats);
- enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf);
- typedef void __attribute__((format(printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...);
- void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg);
- #ifdef __cplusplus
- }
- #endif
- #endif
|