Go to the source code of this file.
Data Structures | |
struct | jb_conf |
struct | jb_frame |
struct | jb_info |
struct | jitterbuf |
Defines | |
#define | JB_ADJUST_DELAY 40 |
#define | JB_DROP 4 |
#define | JB_EMPTY 1 |
#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_HISTORY_SZ 500 |
#define | JB_INTERP 3 |
#define | JB_NOFRAME 2 |
#define | JB_OK 0 |
#define | JB_SCHED 5 |
#define | JB_TARGET_EXTRA 40 |
#define | JB_TYPE_CONTROL 0 |
#define | JB_TYPE_SILENCE 3 |
#define | JB_TYPE_VIDEO 2 |
#define | JB_TYPE_VOICE 1 |
Typedefs | |
typedef void(*) | jb_output_function_t (const char *fmt,...) |
Functions | |
void | jb_destroy (jitterbuf *jb) |
int | jb_get (jitterbuf *jb, jb_frame *frame, long now, long interpl) |
int | jb_getall (jitterbuf *jb, jb_frame *frameout) |
int | jb_getinfo (jitterbuf *jb, jb_info *stats) |
jitterbuf * | jb_new (void) |
long | jb_next (jitterbuf *jb) |
int | jb_put (jitterbuf *jb, void *data, int type, long ms, long ts, long now) |
void | jb_reset (jitterbuf *jb) |
int | jb_setconf (jitterbuf *jb, jb_conf *conf) |
void | jb_setoutput (jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg) |
#define JB_ADJUST_DELAY 40 |
#define JB_DROP 4 |
Definition at line 44 of file jitterbuf.h.
Referenced by _jb_get(), get_from_jb(), jb_get(), and jb_put().
#define JB_EMPTY 1 |
#define JB_HISTORY_DROPPCT 3 |
#define JB_HISTORY_DROPPCT_MAX 4 |
Definition at line 30 of file jitterbuf.h.
#define JB_HISTORY_MAXBUF_SZ JB_HISTORY_SZ * JB_HISTORY_DROPPCT_MAX / 100 |
#define JB_HISTORY_SZ 500 |
Definition at line 25 of file jitterbuf.h.
Referenced by history_calc_maxbuf(), history_get(), and history_put().
#define JB_INTERP 3 |
#define JB_NOFRAME 2 |
#define JB_OK 0 |
Definition at line 40 of file jitterbuf.h.
Referenced by _jb_get(), complete_transfer(), get_from_jb(), iax2_destroy(), jb_get(), jb_getall(), jb_getinfo(), jb_put(), and jb_setconf().
#define JB_SCHED 5 |
#define JB_TARGET_EXTRA 40 |
#define JB_TYPE_CONTROL 0 |
Definition at line 48 of file jitterbuf.h.
#define JB_TYPE_SILENCE 3 |
#define JB_TYPE_VIDEO 2 |
Definition at line 50 of file jitterbuf.h.
#define JB_TYPE_VOICE 1 |
typedef void(*) jb_output_function_t(const char *fmt,...) |
Definition at line 152 of file jitterbuf.h.
void jb_destroy | ( | jitterbuf * | jb | ) |
Definition at line 100 of file jitterbuf.c.
References free, jitterbuf::free, jb_dbg2, and jb_frame::next.
Referenced by iax2_destroy().
00101 { 00102 jb_frame *frame; 00103 jb_dbg2("jb_destroy(%x)\n", jb); 00104 00105 /* free all the frames on the "free list" */ 00106 frame = jb->free; 00107 while (frame != NULL) { 00108 jb_frame *next = frame->next; 00109 free(frame); 00110 frame = next; 00111 } 00112 00113 /* free ourselves! */ 00114 free(jb); 00115 }
Definition at line 779 of file jitterbuf.c.
References _jb_get(), jitterbuf::info, JB_DROP, JB_INTERP, JB_OK, jb_warn, jb_info::last_voice_ms, jb_frame::ms, and jb_frame::ts.
Referenced by get_from_jb().
00780 { 00781 int ret = _jb_get(jb,frameout,now,interpl); 00782 #if 0 00783 static int lastts=0; 00784 int thists = ((ret == JB_OK) || (ret == JB_DROP)) ? frameout->ts : 0; 00785 jb_warn("jb_get(%x,%x,%ld) = %d (%d)\n", jb, frameout, now, ret, thists); 00786 if (thists && thists < lastts) jb_warn("XXXX timestamp roll-back!!!\n"); 00787 lastts = thists; 00788 #endif 00789 if(ret == JB_INTERP) 00790 frameout->ms = jb->info.last_voice_ms; 00791 00792 return ret; 00793 }
Definition at line 795 of file jitterbuf.c.
References JB_NOFRAME, JB_OK, and queue_getall().
Referenced by complete_transfer(), and iax2_destroy().
00796 { 00797 jb_frame *frame; 00798 frame = queue_getall(jb); 00799 00800 if (!frame) { 00801 return JB_NOFRAME; 00802 } 00803 00804 *frameout = *frame; 00805 return JB_OK; 00806 }
Definition at line 809 of file jitterbuf.c.
References history_get(), jitterbuf::info, and JB_OK.
Referenced by ast_cli_netstats(), construct_rr(), and iax2_show_channels().
00810 { 00811 00812 history_get(jb); 00813 00814 *stats = jb->info; 00815 00816 return JB_OK; 00817 }
jitterbuf* jb_new | ( | void | ) |
Definition at line 85 of file jitterbuf.c.
References jb_dbg2, jb_reset(), and malloc.
Referenced by new_iax().
00086 { 00087 jitterbuf *jb; 00088 00089 00090 jb = malloc(sizeof(jitterbuf)); 00091 if (!jb) 00092 return NULL; 00093 00094 jb_reset(jb); 00095 00096 jb_dbg2("jb_new() = %x\n", jb); 00097 return jb; 00098 }
long jb_next | ( | jitterbuf * | jb | ) |
Definition at line 761 of file jitterbuf.c.
References jb_info::current, history_get(), jitterbuf::info, JB_LONGMAX, JB_TARGET_EXTRA, jb_info::last_adjustment, jb_info::next_voice_ts, queue_next(), jb_info::silence_begin_ts, and jb_info::target.
Referenced by get_from_jb(), and update_jbsched().
00762 { 00763 if (jb->info.silence_begin_ts) { 00764 long next = queue_next(jb); 00765 if (next > 0) { 00766 history_get(jb); 00767 /* shrink during silence */ 00768 if (jb->info.target - jb->info.current < -JB_TARGET_EXTRA) 00769 return jb->info.last_adjustment + 10; 00770 return next + jb->info.target; 00771 } 00772 else 00773 return JB_LONGMAX; 00774 } else { 00775 return jb->info.next_voice_ts; 00776 } 00777 }
int jb_put | ( | jitterbuf * | jb, | |
void * | data, | |||
int | type, | |||
long | ms, | |||
long | ts, | |||
long | now | |||
) |
Definition at line 518 of file jitterbuf.c.
References jb_info::frames_in, history_put(), jitterbuf::info, jb_dbg2, JB_DROP, JB_OK, JB_SCHED, JB_TYPE_VOICE, and queue_put().
00519 { 00520 jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now); 00521 00522 jb->info.frames_in++; 00523 00524 if (type == JB_TYPE_VOICE) { 00525 /* presently, I'm only adding VOICE frames to history and drift calculations; mostly because with the 00526 * IAX integrations, I'm sending retransmitted control frames with their awkward timestamps through */ 00527 if (history_put(jb,ts,now,ms)) 00528 return JB_DROP; 00529 } 00530 00531 /* if put into head of queue, caller needs to reschedule */ 00532 if (queue_put(jb,data,type,ms,ts)) { 00533 return JB_SCHED; 00534 } 00535 return JB_OK; 00536 }
void jb_reset | ( | jitterbuf * | jb | ) |
Definition at line 73 of file jitterbuf.c.
References jb_info::conf, jb_info::current, jitterbuf::info, JB_TARGET_EXTRA, s, jb_info::silence_begin_ts, and jb_info::target.
Referenced by complete_transfer(), and jb_new().
00074 { 00075 /* only save settings */ 00076 jb_conf s = jb->info.conf; 00077 memset(jb,0,sizeof(jitterbuf)); 00078 jb->info.conf = s; 00079 00080 /* initialize length */ 00081 jb->info.current = jb->info.target = JB_TARGET_EXTRA; 00082 jb->info.silence_begin_ts = -1; 00083 }
Definition at line 819 of file jitterbuf.c.
References jb_info::conf, jitterbuf::info, JB_OK, jb_conf::max_contig_interp, jb_conf::max_jitterbuf, and jb_conf::resync_threshold.
Referenced by new_iax().
00820 { 00821 /* take selected settings from the struct */ 00822 00823 jb->info.conf.max_jitterbuf = conf->max_jitterbuf; 00824 jb->info.conf.resync_threshold = conf->resync_threshold; 00825 jb->info.conf.max_contig_interp = conf->max_contig_interp; 00826 00827 return JB_OK; 00828 }
void jb_setoutput | ( | jb_output_function_t | err, | |
jb_output_function_t | warn, | |||
jb_output_function_t | dbg | |||
) |
Definition at line 56 of file jitterbuf.c.
Referenced by iax2_do_jb_debug(), iax2_no_jb_debug(), and load_module().