Ignore:
Timestamp:
Oct 13, 2011 9:02:41 AM (13 years ago)
Author:
nanang
Message:

Re #1378:

  • Implemented new algorithm for JB progressive discard.
  • Added new API and for setting JB discard algorithm at run-time.
  • Updated JB test for the new algorithm.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjmedia/include/pjmedia/jbuf.h

    r3553 r3814  
    4949 * Types of frame returned by the jitter buffer. 
    5050 */ 
    51 enum pjmedia_jb_frame_type  
     51typedef enum pjmedia_jb_frame_type  
    5252{ 
    5353    PJMEDIA_JB_MISSING_FRAME       = 0, /**< No frame because it's missing  */ 
     
    5757    PJMEDIA_JB_ZERO_EMPTY_FRAME    = 3  /**< Zero frame is being returned 
    5858                                             because JB is empty.           */ 
    59 }; 
    60  
    61  
    62 /** 
    63  * @see pjmedia_jb_frame_type. 
    64  */ 
    65 typedef enum pjmedia_jb_frame_type pjmedia_jb_frame_type; 
     59} pjmedia_jb_frame_type; 
     60 
     61 
     62/** 
     63 * Enumeration of jitter buffer discard algorithm. The jitter buffer 
     64 * continuously calculates the jitter level to get the optimum latency at 
     65 * any time and in order to adjust the latency, the jitter buffer may need 
     66 * to discard some frames. 
     67 */ 
     68typedef enum pjmedia_jb_discard_algo 
     69{ 
     70    /** 
     71     * Jitter buffer should not discard any frame, except when the jitter 
     72     * buffer is full and a new frame arrives, one frame will be discarded 
     73     * to make space for the new frame. 
     74     */ 
     75    PJMEDIA_JB_DISCARD_NONE        = 0, 
     76 
     77    /** 
     78     * Only discard one frame in at least 200ms when the latency is considered 
     79     * much higher than it should be. When the jitter buffer is full and a new 
     80     * frame arrives, one frame will be discarded to make space for the new 
     81     * frame. 
     82     */ 
     83    PJMEDIA_JB_DISCARD_STATIC, 
     84 
     85    /** 
     86     * The discard rate is dynamically calculated based on actual parameters 
     87     * such as jitter level and latency. When the jitter buffer is full and 
     88     * a new frame arrives, one frame will be discarded to make space for the 
     89     * new frame. 
     90     */ 
     91    PJMEDIA_JB_DISCARD_PROGRESSIVE 
     92 
     93} pjmedia_jb_discard_algo; 
    6694 
    6795 
     
    6997 * This structure describes jitter buffer state. 
    7098 */ 
    71 struct pjmedia_jb_state 
     99typedef struct pjmedia_jb_state 
    72100{ 
    73101    /* Setting */ 
     
    90118    unsigned    discard;            /**< Number of discarded frames.        */ 
    91119    unsigned    empty;              /**< Number of empty on GET events.     */ 
    92 }; 
    93  
    94  
    95 /** 
    96  * @see pjmedia_jb_state 
    97  */ 
    98 typedef struct pjmedia_jb_state pjmedia_jb_state; 
     120} pjmedia_jb_state; 
    99121 
    100122 
     
    114136 * Create an adaptive jitter buffer according to the specification. If 
    115137 * application wants to have a fixed jitter buffer, it may call 
    116  * #pjmedia_jbuf_set_fixed() after the jitter buffer is created. 
     138 * #pjmedia_jbuf_set_fixed() after the jitter buffer is created. Also 
     139 * if application wants to alter the discard algorithm, which the default 
     140 * PJMEDIA_JB_DISCARD_PROGRESSIVE, it may call #pjmedia_jbuf_set_discard(). 
    117141 * 
    118142 * This function may allocate large chunk of memory to keep the frames in  
     
    178202                                                unsigned min_prefetch, 
    179203                                                unsigned max_prefetch); 
     204 
     205 
     206/** 
     207 * Set the jitter buffer discard algorithm. The default discard algorithm, 
     208 * set in jitter buffer creation, is PJMEDIA_JB_DISCARD_PROGRESSIVE. 
     209 * 
     210 * @param jb            The jitter buffer. 
     211 * @param algo          The discard algorithm to be used. 
     212 * 
     213 * @return              PJ_SUCCESS on success. 
     214 */ 
     215PJ_DECL(pj_status_t) pjmedia_jbuf_set_discard(pjmedia_jbuf *jb, 
     216                                              pjmedia_jb_discard_algo algo); 
    180217 
    181218 
Note: See TracChangeset for help on using the changeset viewer.