Ignore:
Timestamp:
May 17, 2008 2:54:18 PM (16 years ago)
Author:
nanang
Message:

More on ticket #535: updated files using and related to math.h

File:
1 edited

Legend:

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

    r1942 r1961  
    2525#include <pj/assert.h> 
    2626#include <pj/log.h> 
     27#include <pj/math.h> 
    2728#include <pj/string.h> 
    2829 
     
    6768    int             jb_max_prefetch;      // Maximum allowable prefetch 
    6869    int             jb_status;            // status is 'init' until the first 'put' operation 
    69  
    70     int             jb_max_size;          // Maximum frames buffered ever 
     70    pj_math_stat    jb_delay;             // Delay statistics of jitter buffer (in frame unit) 
    7171}; 
    7272 
     
    7474#define JB_STATUS_INITIALIZING  0 
    7575#define JB_STATUS_PROCESSING    1 
    76  
    77 #define PJ_ABS(x)       ((x > 0) ? (x) : -(x)) 
    78 #define PJ_MAX(x, y)    ((x > y) ? (x) : (y)) 
    79 #define PJ_MIN(x, y)    ((x < y) ? (x) : (y)) 
    80  
    8176 
    8277/* Enabling this would log the jitter buffer state about once per  
     
    314309    jb->jb_max_count     = max_count; 
    315310 
     311    pj_math_stat_init(&jb->jb_delay); 
     312 
    316313    *p_jb = jb; 
    317314    return PJ_SUCCESS; 
     
    369366    jb->jb_status        = JB_STATUS_INITIALIZING; 
    370367    jb->jb_max_hist_level = 0; 
    371     jb->jb_max_size      = 0; 
    372368 
    373369    jb_framelist_remove_head(&jb->jb_framelist,  
    374370                             jb_framelist_size(&jb->jb_framelist)); 
     371 
     372    pj_math_stat_init(&jb->jb_delay); 
     373     
    375374    return PJ_SUCCESS; 
    376375} 
     
    389388    /* Update jb_max_size */ 
    390389    cur_size = jb_framelist_size(&jb->jb_framelist); 
    391     if (cur_size > jb->jb_max_size) 
    392         jb->jb_max_size = cur_size; 
    393390 
    394391    /* Only apply burst-level calculation on PUT operation since if VAD is  
     
    457454        jb_framelist_remove_head(&jb->jb_framelist, diff); 
    458455 
     456        pj_math_stat_update(&jb->jb_delay, cur_size - diff); 
     457 
    459458        TRACE__((jb->name.ptr,  
    460459                 "JB shrinking %d frame(s), size=%d", diff, 
    461460                 jb_framelist_size(&jb->jb_framelist))); 
     461    } else { 
     462        pj_math_stat_update(&jb->jb_delay, cur_size); 
    462463    } 
    463464 
     
    612613    state->max_prefetch = jb->jb_max_prefetch; 
    613614    state->size = jb_framelist_size(&jb->jb_framelist); 
    614     state->max_size = jb->jb_max_size; 
     615    state->avg_delay = jb->jb_delay.mean * jb->jb_frame_ptime; 
     616    state->min_delay = jb->jb_delay.min * jb->jb_frame_ptime; 
     617    state->max_delay = jb->jb_delay.max * jb->jb_frame_ptime; 
     618    state->dev_delay = pj_math_stat_get_stddev(&jb->jb_delay) *  
     619                       jb->jb_frame_ptime; 
    615620 
    616621    return PJ_SUCCESS; 
    617622} 
    618  
Note: See TracChangeset for help on using the changeset viewer.