Ticket #464: jbuf.patch
File jbuf.patch, 4.1 KB (added by nanang, 17 years ago) |
---|
-
pjmedia/include/pjmedia/jbuf.h
235 235 void *frame, 236 236 char *p_frm_type); 237 237 238 /** 239 * Get a frame from the jitter buffer. The jitter buffer will return the 240 * oldest frame from it's buffer, when it is available. 241 * 242 * @param jb The jitter buffer. 243 * @param frame Buffer to receive the payload from the jitter buffer. 244 * @see pjmedia_jbuf_get_frame(). 245 * @param size Pointer to receive frame size. 246 * @param p_frm_type Pointer to receive frame type. 247 * @see pjmedia_jbuf_get_frame(). 248 */ 249 PJ_DECL(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb, 250 void *frame, 251 pj_size_t *size, 252 char *p_frm_type); 238 253 254 239 255 /** 240 256 * Get jitter buffer current state/settings. 241 257 * -
pjmedia/src/pjmedia/jbuf.c
34 34 { 35 35 char *flist_buffer; 36 36 int *flist_frame_type; 37 pj_size_t *flist_content_len; 37 38 unsigned flist_frame_size; 38 39 unsigned flist_max_count; 39 40 unsigned flist_empty; … … 109 110 pj_pool_zalloc(pool, sizeof(framelist->flist_frame_type[0]) * 110 111 framelist->flist_max_count); 111 112 113 framelist->flist_content_len = (pj_size_t*) 114 pj_pool_zalloc(pool, sizeof(framelist->flist_content_len[0]) * 115 framelist->flist_max_count); 116 112 117 framelist->flist_empty = 1; 113 118 114 119 return PJ_SUCCESS; … … 134 139 135 140 136 141 static pj_bool_t jb_framelist_get(jb_framelist_t *framelist, 137 void *frame, 142 void *frame, pj_size_t *size, 138 143 pjmedia_jb_frame_type *p_type) 139 144 { 140 145 if (!framelist->flist_empty) { … … 144 149 framelist->flist_frame_size); 145 150 *p_type = (pjmedia_jb_frame_type) 146 151 framelist->flist_frame_type[framelist->flist_head]; 152 *size = framelist->flist_content_len[framelist->flist_head]; 147 153 148 154 pj_bzero(framelist->flist_buffer + 149 155 framelist->flist_head * framelist->flist_frame_size, 150 156 framelist->flist_frame_size); 151 157 framelist->flist_frame_type[framelist->flist_head] = 152 158 PJMEDIA_JB_MISSING_FRAME; 159 framelist->flist_content_len[framelist->flist_head] = 0; 153 160 154 161 framelist->flist_origin++; 155 162 framelist->flist_head = (framelist->flist_head + 1 ) % … … 194 201 pj_memset(framelist->flist_frame_type+framelist->flist_head, 195 202 PJMEDIA_JB_MISSING_FRAME, 196 203 step1*sizeof(framelist->flist_frame_type[0])); 204 pj_bzero(framelist->flist_content_len+framelist->flist_head, 205 step1*sizeof(framelist->flist_content_len[0])); 197 206 198 207 if (step2) { 199 208 pj_bzero( framelist->flist_buffer, … … 201 210 pj_memset(framelist->flist_frame_type, 202 211 PJMEDIA_JB_MISSING_FRAME, 203 212 step2*sizeof(framelist->flist_frame_type[0])); 213 pj_bzero (framelist->flist_content_len, 214 step2*sizeof(framelist->flist_content_len[0])); 204 215 } 205 216 206 217 // update pointers … … 257 268 frame, frame_size); 258 269 259 270 framelist->flist_frame_type[where] = PJMEDIA_JB_NORMAL_FRAME; 271 framelist->flist_content_len[where] = frame_size; 260 272 261 273 return PJ_TRUE; 262 274 } … … 510 522 void *frame, 511 523 char *p_frame_type) 512 524 { 525 pj_size_t size; 526 527 pjmedia_jbuf_get_frame2(jb, frame, &size, p_frame_type); 528 } 529 530 /* 531 * Get frame from jitter buffer. 532 */ 533 PJ_DEF(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb, 534 void *frame, 535 pj_size_t *size, 536 char *p_frame_type) 537 { 513 538 pjmedia_jb_frame_type ftype; 514 539 515 540 jb->jb_level--; … … 530 555 else 531 556 *p_frame_type = PJMEDIA_JB_ZERO_PREFETCH_FRAME; 532 557 558 *size = 0; 559 533 560 return; 534 561 } 535 562 536 563 /* Retrieve a frame from frame list */ 537 if (jb_framelist_get(&jb->jb_framelist,frame, &ftype) == PJ_FALSE) {564 if (jb_framelist_get(&jb->jb_framelist,frame,size,&ftype) == PJ_FALSE) { 538 565 /* Can't return frame because jitter buffer is empty! */ 539 566 pj_bzero(frame, jb->jb_frame_size); 540 567 *p_frame_type = PJMEDIA_JB_ZERO_EMPTY_FRAME; 568 *size = 0; 541 569 542 570 return; 543 571 }