enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now) { long numts; jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now); jb->info.frames_in++; if (jb->frames && jb->dropem) return JB_DROP; jb->dropem = 0; if (type == JB_TYPE_VOICE) { /* presently, I'm only adding VOICE frames to history and drift calculations; mostly because with the * IAX integrations, I'm sending retransmitted control frames with their awkward timestamps through */ if (history_put(jb,ts,now,ms)) return JB_DROP; } numts = 0; if (jb->frames) numts = jb->frames->prev->ts - jb->frames->ts; if (numts >= jb->info.conf.max_jitterbuf) { ast_log(LOG_DEBUG, "Attempting to exceed Jitterbuf max %ld timeslots\n", jb->info.conf.max_jitterbuf); jb->dropem = 1; return JB_DROP; } /* if put into head of queue, caller needs to reschedule */ if (queue_put(jb,data,type,ms,ts)) { return JB_SCHED; } return JB_OK; }
jitterbuf * jb_new() { jitterbuf *jb; if (!(jb = ast_malloc(sizeof(*jb)))) return NULL; jb_reset(jb); jb_dbg2("jb_new() = %x\n", jb); return jb; }
jitterbuf * jb_new() { jitterbuf *jb; jb = malloc(sizeof(jitterbuf)); if (!jb) return NULL; jb_reset(jb); jb_dbg2("jb_new() = %x\n", jb); return jb; }
jitterbuf * jb_new() { jitterbuf *jb; if (!(jb = (jitterbuf *)malloc(sizeof(*jb)))) return NULL; jb->info.conf.target_extra = JB_TARGET_EXTRA; jb_reset(jb); jb_dbg2("jb_new() = %x\n", jb); return jb; }
void jb_destroy(jitterbuf *jb) { jb_frame *frame; jb_dbg2("jb_destroy(%x)\n", jb); /* free all the frames on the "free list" */ frame = jb->free; while (frame != NULL) { jb_frame *next = frame->next; free(frame); frame = next; } /* free ourselves! */ free(jb); }
int jb_put(jitterbuf *jb, void *data, int type, long ms, long ts, long now) { jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now); jb->info.frames_in++; if (type == JB_TYPE_VOICE) { /* presently, I'm only adding VOICE frames to history and drift calculations; mostly because with the * IAX integrations, I'm sending retransmitted control frames with their awkward timestamps through */ if (history_put(jb,ts,now,ms)) return JB_DROP; } /* if put into head of queue, caller needs to reschedule */ if (queue_put(jb,data,type,ms,ts)) { return JB_SCHED; } return JB_OK; }
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now) { long delay = now - (ts - jb->info.resync_offset); jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now); if (check_resync(jb, ts, now, ms, type, &delay)) { return JB_DROP; } if (type == JB_TYPE_VOICE) { /* presently, I'm only adding VOICE frames to history and drift calculations; mostly because with the * IAX integrations, I'm sending retransmitted control frames with their awkward timestamps through */ history_put(jb, ts, now, ms, delay); } jb->info.frames_in++; /* if put into head of queue, caller needs to reschedule */ if (queue_put(jb,data,type,ms,ts)) { return JB_SCHED; } return JB_OK; }