diff -urN --exclude=.svn asterisk-lastjb/abstract_jb.c asterisk-jb/abstract_jb.c --- asterisk-lastjb/abstract_jb.c 2006-02-28 17:13:17.000000000 +0100 +++ asterisk-jb/abstract_jb.c 2006-02-28 15:41:37.000000000 +0100 @@ -341,13 +341,22 @@ return -1; } - if(!f->has_timing_info || f->len < 2) + /* We consider an enabled jitterbuffer should receive frames with valid timing info. */ + if(!f->has_timing_info || f->len < 2 || f->ts < 0) { - /* TODO: Shouldn't we disable the jb here? Or we can produce timestamp and seqno? */ + ast_log(LOG_WARNING, "Recieved frame with invalid timing info: " + "has_timing_info=%d, len=%ld, ts=%ld\n", f->has_timing_info, f->len, f->ts); return -1; } - frr = ast_frisolate(f); + if(f->mallocd & AST_MALLOCD_HDR) + { + frr = ast_frdup(f); + } + else + { + frr = ast_frisolate(f); + } if(frr == NULL) { ast_log(LOG_ERROR, "Failed to isolate frame for the jitterbuffer on channel '%s'\n", chan->name); diff -urN --exclude=.svn asterisk-lastjb/scx_jitterbuf.c asterisk-jb/scx_jitterbuf.c --- asterisk-lastjb/scx_jitterbuf.c 2006-02-28 17:13:17.000000000 +0100 +++ asterisk-jb/scx_jitterbuf.c 2006-02-28 15:41:37.000000000 +0100 @@ -305,8 +305,6 @@ int scx_jb_get(struct scx_jb *jb, struct scx_jb_frame *frame, long now, long interpl) { - long halflen; - assert(now >= 0); assert(interpl >= 2); @@ -326,10 +324,8 @@ return SCX_JB_INTERP; } - halflen = (long) ((double) jb->frames->ms / 2.0); - /* Isn't it too late for the first frame available in the jb? */ - if(now > jb->frames->delivery + halflen) + if(now > jb->frames->delivery + jb->frames->ms) { /* yes - should drop this frame and update next to point the next frame (get_jb_head() does it) */ get_jb_head(jb, frame); @@ -338,7 +334,7 @@ } /* isn't it too early to play the first frame available? */ - if(now < jb->frames->delivery - halflen) + if(now < jb->frames->delivery) { /* yes - should interpolate one frame */ /* update next */