Ignore:
Timestamp:
May 14, 2006 6:23:34 PM (18 years ago)
Author:
bennylp
Message:

Fixed more bugs with multiple frame handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/jbuf.c

    r438 r442  
    5151    jb_framelist    jb_framelist; 
    5252    pj_size_t       jb_frame_size;        // frame size  
     53    unsigned        jb_frame_ptime;       // frame duration. 
    5354    pj_size_t       jb_max_count;         // max frames in the jitter framelist->flist_buffer 
    5455 
     
    8182 
    8283 
     84/* Enabling this would log the jitter buffer state about once per  
     85 * second. 
     86 */ 
     87#if 0 
     88#  define TRACE__(args)     PJ_LOG(4,args) 
     89#else 
     90#  define TRACE__(args) 
     91#endif 
     92 
    8393 
    8494static pj_status_t jb_framelist_init( pj_pool_t *pool, 
     
    268278                                        const pj_str_t *name, 
    269279                                        unsigned frame_size,  
     280                                        unsigned ptime, 
    270281                                        unsigned max_count, 
    271282                                        pjmedia_jbuf **p_jb) 
     
    282293    pj_strdup_with_null(pool, &jb->name, name); 
    283294    jb->jb_frame_size    = frame_size; 
     295    jb->jb_frame_ptime   = ptime; 
    284296    jb->jb_last_seq_no   = -1; 
    285297    jb->jb_level         = 0; 
     
    368380static void jbuf_calculate_jitter(pjmedia_jbuf *jb) 
    369381{ 
    370     enum { STABLE_HISTORY_LIMIT = (100*2) }; 
     382    unsigned stable_history_limit; 
     383 
     384    stable_history_limit = 1000 / jb->jb_frame_ptime; 
    371385 
    372386    jb->jb_last_jitter = PJ_ABS(jb->jb_level-jb->jb_last_level); 
     
    377391    if (jb->jb_last_jitter < jb->jb_prefetch) { 
    378392        jb->jb_stable_hist += jb->jb_last_jitter; 
    379         if (jb->jb_stable_hist > STABLE_HISTORY_LIMIT) { 
     393        if (jb->jb_stable_hist > (int)stable_history_limit) { 
    380394            int seq_diff = (jb->jb_prefetch - jb->jb_max_hist_jitter)/3; 
    381395            if (seq_diff<1) seq_diff = 1; 
     
    388402            jb->jb_max_hist_jitter = 0; 
    389403 
    390             if (jb->jb_op_count >= STABLE_HISTORY_LIMIT*2 && 
     404            TRACE__((THIS_FILE,"jb updated(1), prefetch=%d, size=%d",  
     405                     jb->jb_prefetch, jb_framelist_size(&jb->jb_framelist))); 
     406 
     407            /* These code is used to shorten the delay in the jitter buffer. 
     408 
     409            if (jb->jb_op_count >= stable_history_limit*2 && 
    391410                (int)jb_framelist_size(&jb->jb_framelist) > jb->jb_prefetch+2) 
    392411            { 
     
    399418                jb->jb_op_count = 0; 
    400419            } 
     420            */ 
    401421 
    402422        } 
     
    409429        jb->jb_max_hist_jitter = 0; 
    410430 
    411         if (jb->jb_op_count >= STABLE_HISTORY_LIMIT * 2) { 
     431        TRACE__((THIS_FILE,"jb updated(2), prefetch=%d, size=%d",  
     432                 jb->jb_prefetch, jb_framelist_size(&jb->jb_framelist))); 
     433 
     434        /* These code is used to shorten the delay in the jitter buffer 
     435           when the current size is larger than the prefetch. But it does 
     436           not really work when the stream supports multiple frames, since 
     437           the size may grow only temporarily. 
     438 
     439        if (jb->jb_op_count >= stable_history_limit * 2) { 
    412440            if ((int)jb_framelist_size(&jb->jb_framelist) > jb->jb_prefetch+2)  
    413441            { 
     
    422450            jb->jb_op_count = 0; 
    423451        } 
     452        */ 
    424453    } 
    425454} 
Note: See TracChangeset for help on using the changeset viewer.