Beispiel #1
0
static int jb_put_fixed(void *jb, struct ast_frame *fin, long now)
{
	struct fixed_jb *fixedjb = (struct fixed_jb *) jb;
	int res;

	res = fixed_jb_put(fixedjb, fin, fin->len, fin->ts, now);

	return fixed_to_abstract_code[res];
}
Beispiel #2
0
int fixed_jb_put_first(struct fixed_jb *jb, void *data, long ms, long ts, long now)
{
	/* this is our first frame - set the base of the receivers time */
	jb->rxcore = now - ts;
	
	/* init next for a first time - it should be the time the first frame should be played */
	jb->next_delivery = now + jb->delay;
	
	/* put the frame */
	return fixed_jb_put(jb, data, ms, ts, now);
}
Beispiel #3
0
static int resynch_jb(struct fixed_jb *jb, void *data, long ms, long ts, long now)
{
	long diff, offset;
	struct fixed_jb_frame *frame;
	
	/* If jb is empty, just reinitialize the jb */
	if (!jb->frames) {
		/* debug check: tail should also be NULL */
		ASSERT(jb->tail == NULL);
		
		return fixed_jb_put_first(jb, data, ms, ts, now);
	}
	
	/* Adjust all jb state just as the new frame is with delivery = the delivery of the last
	   frame (e.g. this one with max delivery) + the length of the last frame. */
	
	/* Get the diff in timestamps */
	diff = ts - jb->tail->ts;
	
	/* Ideally this should be just the length of the last frame. The deviation is the desired
	   offset */
	offset = diff - jb->tail->ms;
	
	/* Do we really need to resynch, or this is just a frame for dropping? */
	if (!jb->force_resynch && (offset < jb->conf.resync_threshold && offset > -jb->conf.resync_threshold))
		return FIXED_JB_DROP;
	
	/* Reset the force resynch flag */
	jb->force_resynch = 0;
	
	/* apply the offset to the jb state */
	jb->rxcore -= offset;
	frame = jb->frames;
	while (frame) {
		frame->ts += offset;
		frame = frame->next;
	}
	
	/* now jb_put() should add the frame at a last position */
	return fixed_jb_put(jb, data, ms, ts, now);
}