Ignore:
Timestamp:
Feb 9, 2006 2:01:40 PM (18 years ago)
Author:
bennylp
Message:

Updated with new jitter buffer, and statistics in pjsua

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/jbuf.h

    r121 r169  
    3131 */ 
    3232 
    33 #include <pj/types.h> 
     33#include <pjmedia/types.h> 
    3434 
    3535 
     
    3737 
    3838 
    39 /** 
    40  * Opaque declaration of internal frame type used by jitter buffer.  
    41  */ 
    42 struct pj_jbframe; 
     39enum pjmedia_jb_frame_type  
     40{ 
     41    PJMEDIA_JB_MISSING_FRAME   = 0, 
     42    PJMEDIA_JB_NORMAL_FRAME    = 1, 
     43    PJMEDIA_JB_ZERO_FRAME      = 2, 
     44}; 
    4345 
    4446 
    45 /** 
    46  * Miscelaneous operation result/status.  
    47  */  
    48 typedef enum jb_op_status 
    49 { 
    50     PJ_JB_STATUS_TOO_OLD = -2,          /** The packet is too old. */ 
    51     PJ_JB_STATUS_TOO_SOON = -3,         /** The packet is too soon. */ 
    52     PJ_JB_STATUS_FRAME_NULL = -4,       /** No packet can be retrieved */ 
    53     PJ_JB_STATUS_FRAME_MISSING = -5,    /** The specified packet is missing/lost */ 
    54 } jb_op_status; 
     47#define PJMEDIA_JB_DEFAULT_INIT_PREFETCH    15 
    5548 
    5649 
    57 /* 
    58  * Frame list, container abstraction for ordered list with fixed maximum 
    59  * size. It is used internally by the jitter buffer. 
    60  */   
    61 typedef struct pj_jbframelist 
    62 { 
    63     unsigned            head, count, maxcount; 
    64     struct pj_jbframe  *frames; 
    65 } pj_jbframelist; 
    66  
    67  
    68 /** 
    69  * Jitter buffer implementation. 
    70  */  
    71 typedef struct pj_jitter_buffer 
    72 { 
    73     pj_jbframelist  lst;            /** The frame list. */ 
    74     int             level;          /** Current, real-time jitter level. */ 
    75     int             max_level;      /** Maximum level for the period.    */ 
    76     unsigned        prefetch;       /** Prefetch count currently used. */ 
    77     unsigned        get_cnt;        /** Number of get operation during prefetch state. */ 
    78     unsigned        min;            /** Minimum jitter size, in packets. */ 
    79     unsigned        max;            /** Maximum jitter size, in packets. */ 
    80     pj_uint32_t     lastseq;        /** Last sequence number put to jitter buffer. */ 
    81     unsigned        upd_count;      /** Internal counter to manage update interval. */ 
    82     int             state;          /** Jitter buffer state (1==operational) */ 
    83     int             last_op;        /** Last jitter buffer operation. */ 
    84 } pj_jitter_buffer; 
    85  
    86  
    87 /** 
    88  * Initialize jitter buffer with the specified parameters. 
    89  * This function will allocate internal frame buffer from the specified pool. 
    90  * @param jb The jitter buffer to be initialized. 
    91  * @param pool Pool where memory will be allocated for the frame buffer. 
    92  * @param min The minimum value of jitter buffer, in packets. 
    93  * @param max The maximum value of jitter buffer, in packets. 
    94  * @param maxcount The maximum number of delay, in packets, which must be 
    95  *                 greater than max. 
    96  * @return PJ_SUCCESS on success. 
    97  */ 
    98 PJ_DECL(pj_status_t) pj_jb_init(pj_jitter_buffer *jb, pj_pool_t *pool,  
    99                                 unsigned min, unsigned max, unsigned maxcount); 
    100  
    101 /** 
    102  * Reset jitter buffer according to the parameters specified when the jitter 
    103  * buffer was initialized. Any packets currently in the buffer will be  
    104  * discarded. 
    105  */ 
    106 PJ_DECL(void) pj_jb_reset(pj_jitter_buffer *jb); 
    107  
    108 /** 
    109  * Put a pointer to the buffer with the specified sequence number. The pointer 
    110  * normally points to a buffer held by application, and this pointer will be 
    111  * returned later on when pj_jb_get() is called. The jitter buffer will not try 
    112  * to interpret the content of this pointer. 
    113  * @return: 
    114  *   - PJ_SUCCESS on success. 
    115  *   - PJ_JB_STATUS_TOO_OLD when the packet is too old. 
    116  *   - PJ_JB_STATUS_TOO_SOON when the packet is too soon. 
    117  */ 
    118 PJ_DECL(pj_status_t) pj_jb_put( pj_jitter_buffer *jb, pj_uint32_t extseq, void *buf ); 
    119  
    120 /** 
    121  * Get the earliest data from the jitter buffer. ONLY when the operation succeeds, 
    122  * the function returns both sequence number and a pointer in the parameters. 
    123  * This returned data corresponds to sequence number and pointer that were 
    124  * given to jitter buffer in the previous pj_jb_put operation. 
    125  * @return  
    126  *  - PJ_SUCCESS on success 
    127  *  - PJ_JB_STATUS_FRAME_NULL when there is no frames to be returned. 
    128  *  - PJ_JB_STATUS_FRAME_MISSING if the jitter buffer detects that the packet  
    129  *     is lost. Application may run packet concealment algorithm when it  
    130  *     receives this status. 
    131  */ 
    132 PJ_DECL(pj_status_t) pj_jb_get( pj_jitter_buffer *jb, pj_uint32_t *extseq, void **buf ); 
     50PJ_DECL(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool,  
     51                                        int frame_size,  
     52                                        int initial_prefetch,  
     53                                        int max_count, 
     54                                        pjmedia_jbuf **p_jb); 
     55PJ_DECL(pj_status_t) pjmedia_jbuf_destroy(pjmedia_jbuf *jb); 
     56PJ_DECL(pj_status_t) pjmedia_jbuf_put_frame(pjmedia_jbuf *jb,  
     57                                            const void *frame,  
     58                                            pj_size_t frame_size,  
     59                                            int frame_seq); 
     60PJ_DECL(pj_status_t) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb,  
     61                                             void *frame,  
     62                                             char *p_frame_type); 
     63PJ_DECL(unsigned)    pjmedia_jbuf_get_prefetch_size(pjmedia_jbuf *jb); 
     64PJ_DECL(unsigned)    pjmedia_jbuf_get_current_size(pjmedia_jbuf *jb); 
    13365 
    13466 
Note: See TracChangeset for help on using the changeset viewer.