Ignore:
Timestamp:
Jun 6, 2018 8:38:29 AM (13 months ago)
Author:
nanang
Message:

Fixed #2118:

  • Stream buffer calculation is now based on maximum bitrate and maximum receiving frame size.
  • Added buffer size check when getting frame from jitter buffer, pjmedia_jbuf_get_frame*() specification has been updated that 'size' param is now input and output (was output only).
File:
1 edited

Legend:

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

    r5734 r5803  
    296296                    *bit_info = 0; 
    297297            } else { 
     298                pj_size_t frm_size = framelist->content_len[framelist->head]; 
     299                pj_size_t max_size = size? *size : frm_size; 
     300                pj_size_t copy_size = PJ_MIN(max_size, frm_size); 
     301 
     302                /* Buffer size should not be smaller than frame size. */ 
     303                if (max_size < frm_size) { 
     304                    pj_assert(!"Buffer too small"); 
     305                    PJ_LOG(4, (THIS_FILE, "Warning: buffer too small for the " 
     306                                          "retrieved frame!")); 
     307                } 
     308 
    298309                pj_memcpy(frame, 
    299310                          framelist->content + 
    300311                          framelist->head * framelist->frame_size, 
    301                           framelist->frame_size); 
     312                          copy_size); 
    302313                *p_type = (pjmedia_jb_frame_type) 
    303314                          framelist->frame_type[framelist->head]; 
    304315                if (size) 
    305                     *size   = framelist->content_len[framelist->head]; 
     316                    *size = copy_size; 
    306317                if (bit_info) 
    307318                    *bit_info = framelist->bit_info[framelist->head]; 
     
    988999    cur_size = jb_framelist_eff_size(&jb->jb_framelist); 
    9891000 
     1001    /* Check if frame size is larger than JB frame size */ 
     1002    if (frame_size > jb->jb_frame_size) { 
     1003        PJ_LOG(4, (THIS_FILE, "Warning: frame too large for jitter buffer, " 
     1004                   "it will be truncated!")); 
     1005    } 
     1006 
    9901007    /* Attempt to store the frame */ 
    9911008    min_frame_size = PJ_MIN(frame_size, jb->jb_frame_size); 
Note: See TracChangeset for help on using the changeset viewer.