40#define JB_LONGMAX 2147483647L 
   41#define JB_LONGMIN (-JB_LONGMAX - 1L) 
   43#define jb_warn(...) (warnf ? warnf(__VA_ARGS__) : (void)0) 
   44#define jb_err(...) (errf ? errf(__VA_ARGS__) : (void)0) 
   45#define jb_dbg(...) (dbgf ? dbgf(__VA_ARGS__) : (void)0) 
   48#define jb_dbg2(...) (dbgf ? dbgf(__VA_ARGS__) : (void)0) 
   50#define jb_dbg2(...) ((void)0) 
   77    memset(jb, 0, 
sizeof(*jb));
 
 
  102    jb_dbg2(
"jb_destroy(%x)\n", jb);
 
  106    while (frame != 
NULL) {
 
 
  128            ast_debug(1, 
"Attempting to exceed Jitterbuf max %ld timeslots\n",
 
 
  266                if (toins < jb->hist_minbuf[j]) {
 
  281            fprintf(stderr, 
"toins = %ld\n", toins);
 
  282            fprintf(stderr, 
"maxbuf =");
 
  285            fprintf(stderr, 
"\nminbuf =");
 
  288            fprintf(stderr, 
"\n");
 
 
  344    if ((frame = jb->
free)) {
 
  346    } 
else if (!(frame = 
ast_malloc(
sizeof(*frame)))) {
 
  347        jb_err(
"cannot allocate frame\n");
 
  354    frame->
ts = resync_ts;
 
  368    } 
else if (resync_ts < jb->
frames->ts) {
 
  386        while (resync_ts < p->prev->ts && p->
prev != jb->
frames)
 
 
  424    if (all || ts >= frame->
ts) {
 
  429        if (frame->
next == frame)
 
 
  466    jb_dbg(
"\njb info: fin=%ld fout=%ld flate=%ld flost=%ld fdrop=%ld fcur=%ld\n",
 
  469    jb_dbg(
"jitter=%ld current=%ld target=%ld min=%ld sil=%d len=%d len/fcur=%ld\n",
 
  473        jb_dbg(
"jb info: Loss PCT = %ld%%, Late PCT = %ld%%\n",
 
  476    jb_dbg(
"jb info: queue %d -> %d.  last_ts %d (queue len: %d) last_ms %d\n",
 
  497            jb_err(
"Queue is BROKEN at item [%d]", i);
 
  528    jb_dbg2(
"jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now);
 
 
  554    static int dbg_cnt = 0;
 
  559    if (dbg_cnt && dbg_cnt % 50 == 0) {
 
  641        if (frame && frame->
ms > 0) {
 
  649        if (diff < -jb->info.conf.target_extra &&
 
  727        if (diff < -jb->info.conf.target_extra &&
 
 
  790    int thists = ((ret == 
JB_OK) || (ret == 
JB_DROP)) ? frameout->
ts : 0;
 
  791    jb_warn(
"jb_get(%x,%x,%ld) = %d (%d)\n", jb, frameout, now, ret, thists);
 
  792    if (thists && thists < lastts) 
jb_warn(
"XXXX timestamp roll-back!!!\n");
 
 
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ast_debug(level,...)
Log a DEBUG message.
static jb_output_function_t dbgf
static void history_get(jitterbuf *jb)
static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
static int history_put(jitterbuf *jb, long ts, long now, long ms, long delay)
int jb_is_late(jitterbuf *jb, long ts)
Checks if the given time stamp is late.
static jb_output_function_t errf
void jb_destroy(jitterbuf *jb)
destroy jitterbuf
static void history_calc_maxbuf(jitterbuf *jb)
void jb_reset(jitterbuf *jb)
reset jitterbuf
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg)
static jb_output_function_t warnf
static long queue_last(jitterbuf *jb)
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now)
queue a frame
long jb_next(jitterbuf *jb)
when is the next frame due out, in receiver's time (0=EMPTY) This value may change as frames are adde...
static long queue_next(jitterbuf *jb)
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
set jitterbuf conf
static int check_resync(jitterbuf *jb, long ts, long now, long ms, const enum jb_frame_type type, long *delay)
static jb_frame * _queue_get(jitterbuf *jb, long ts, int all)
static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts)
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
unconditionally get frames from jitterbuf until empty
static void increment_losspct(jitterbuf *jb)
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frameout, long now, long interpl)
get a frame for time now (receiver's time) return value is one of JB_OK: You've got frame!...
static jb_frame * queue_get(jitterbuf *jb, long ts)
static void decrement_losspct(jitterbuf *jb)
jitterbuf * jb_new()
new jitterbuf
static jb_frame * queue_getall(jitterbuf *jb)
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
get jitterbuf info: only "statistics" may be valid
jitterbuf: an application-independent jitterbuffer jitterbuf.c
void(* jb_output_function_t)(const char *fmt,...)
#define JB_HISTORY_MAXBUF_SZ
#define JB_HISTORY_DROPPCT
All configuration options for http media cache.
long history[JB_HISTORY_SZ]
long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]
long hist_minbuf[JB_HISTORY_MAXBUF_SZ]