Changeset 188 for pjproject/trunk/pjmedia/include/pjmedia/jbuf.h
- Timestamp:
- Feb 15, 2006 12:24:23 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/jbuf.h
r169 r188 25 25 * @brief Adaptive jitter buffer implementation. 26 26 */ 27 #include <pjmedia/types.h> 28 27 29 /** 28 30 * @defgroup PJMED_JBUF Adaptive jitter buffer 29 31 * @ingroup PJMEDIA 30 32 * @{ 33 * 31 34 */ 32 33 #include <pjmedia/types.h>34 35 35 36 … … 37 38 38 39 40 /** 41 * Types of frame returned by the jitter buffer. 42 */ 39 43 enum pjmedia_jb_frame_type 40 44 { 41 PJMEDIA_JB_MISSING_FRAME = 0, 42 PJMEDIA_JB_NORMAL_FRAME = 1, 43 PJMEDIA_JB_ZERO_FRAME = 2, 45 PJMEDIA_JB_MISSING_FRAME = 0, /**< No frame because it's missing. */ 46 PJMEDIA_JB_NORMAL_FRAME = 1, /**< Normal frame is being returned. */ 47 PJMEDIA_JB_ZERO_FRAME = 2, /**< Zero frame is being returned. */ 44 48 }; 45 49 46 50 47 #define PJMEDIA_JB_DEFAULT_INIT_PREFETCH 15 51 /** 52 * The constant PJMEDIA_JB_DEFAULT_INIT_DELAY specifies default jitter 53 * buffer prefetch count during jitter buffer creation. 54 */ 55 #define PJMEDIA_JB_DEFAULT_INIT_DELAY 15 48 56 49 57 58 /** 59 * Create the jitter buffer. This function may allocate large chunk of 60 * memory to keep the frames in the buffer. 61 * 62 * @param pool The pool to allocate memory. 63 * @param frame_size The size of each frame that will be kept in the 64 * jitter buffer. The value here normaly corresponds 65 * to the RTP payload size according to the codec 66 * being used. 67 * @param init_delay Initial jitter buffer delay, in number of frames. 68 * @param max_count Maximum jitter buffer delay, in number of frames. 69 * @param p_jb Pointer to receive jitter buffer instance. 70 * 71 * @return PJ_SUCCESS on success. 72 */ 50 73 PJ_DECL(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool, 51 74 int frame_size, 52 int init ial_prefetch,75 int init_delay, 53 76 int max_count, 54 77 pjmedia_jbuf **p_jb); 78 79 /** 80 * Destroy jitter buffer instance. 81 * 82 * @param jb The jitter buffer. 83 * 84 * @return PJ_SUCCESS on success. 85 */ 55 86 PJ_DECL(pj_status_t) pjmedia_jbuf_destroy(pjmedia_jbuf *jb); 87 88 89 /** 90 * Put a frame to the jitter buffer. If the frame can be accepted (based 91 * on the sequence number), the jitter buffer will copy the frame and put 92 * it in the appropriate position in the buffer. 93 * 94 * Application MUST manage it's own synchronization when multiple threads 95 * are accessing the jitter buffer at the same time. 96 * 97 * @param jb The jitter buffer. 98 * @param frame Pointer to frame buffer to be stored in the jitter 99 * buffer. 100 * @param size The frame size. 101 * @param frame_seq The frame sequence number. 102 * 103 * @return PJ_SUCCESS on success. 104 */ 56 105 PJ_DECL(pj_status_t) pjmedia_jbuf_put_frame(pjmedia_jbuf *jb, 57 106 const void *frame, 58 pj_size_t frame_size,107 pj_size_t size, 59 108 int frame_seq); 109 110 /** 111 * Get a frame from the jitter buffer. The jitter buffer will return the 112 * oldest frame from it's buffer, when it is available. 113 * 114 * Application MUST manage it's own synchronization when multiple threads 115 * are accessing the jitter buffer at the same time. 116 * 117 * @param jb The jitter buffer. 118 * @param frame Buffer to receive the payload from the jitter buffer. 119 * Application MUST make sure that the buffer has 120 * appropriate size (i.e. not less than the frame size, 121 * as specified when the jitter buffer was created). 122 * The jitter buffer only copied a frame to this 123 * buffer when the frame type returned by this function 124 * is PJMEDIA_JB_NORMAL_FRAME. 125 * @param p_frm_type Pointer to receive frame type. If jitter buffer is 126 * currently empty or bufferring, the frame type will 127 * be set to PJMEDIA_JB_ZERO_FRAME, and no frame will 128 * be copied. If the jitter buffer detects that frame is 129 * missing with current sequence number, the frame type 130 * will be set to PJMEDIA_JB_MISSING_FRAME, and no 131 * frame will be copied. If there is a frame, the jitter 132 * buffer will copy the frame to the buffer, and frame 133 * type will be set to PJMEDIA_JB_NORMAL_FRAME. 134 * 135 * @return Always returns PJ_SUCCESS. 136 */ 60 137 PJ_DECL(pj_status_t) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb, 61 138 void *frame, 62 char *p_frame_type); 63 PJ_DECL(unsigned) pjmedia_jbuf_get_prefetch_size(pjmedia_jbuf *jb); 64 PJ_DECL(unsigned) pjmedia_jbuf_get_current_size(pjmedia_jbuf *jb); 139 char *p_frm_type); 140 141 /** 142 * Retrieve the current value of jitter buffer minimum delay, in number 143 * of frames. 144 * 145 * @param jb The jitter buffer. 146 * 147 * @return Number of frames, indicating the minimum delay that 148 * will be applied by the jitter buffer between frame 149 * arrival and frame retrieval. 150 */ 151 PJ_DECL(unsigned) pjmedia_jbuf_get_min_delay_size(pjmedia_jbuf *jb); 152 153 154 /** 155 * Retrieve the current delay value, in number of frames. 156 * 157 * @param jb The jitter buffer. 158 * 159 * @return Number of frames, indicating the delay between frame 160 * arrival and frame retrieval. 161 */ 162 PJ_DECL(unsigned) pjmedia_jbuf_get_delay(pjmedia_jbuf *jb); 65 163 66 164
Note: See TracChangeset
for help on using the changeset viewer.