Ignore:
Timestamp:
Jun 6, 2018 8:38:29 AM (6 years 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/stream.c

    r5799 r5803  
    8787    unsigned                out_pkt_size;   /**< Size of output buffer.     */ 
    8888    void                   *out_pkt;        /**< Output buffer.             */ 
    89     unsigned                out_pkt_len;    /**< Length of data in buffer.  */ 
    9089    pjmedia_rtp_session     rtp;            /**< RTP session.               */ 
    9190}; 
     
    531530    for (samples_count=0; samples_count < samples_required;) { 
    532531        char frame_type; 
    533         pj_size_t frame_size; 
     532        pj_size_t frame_size = channel->out_pkt_size; 
    534533        pj_uint32_t bit_info; 
    535534 
     
    822821    while (f->samples_cnt < samples_required) { 
    823822        char frame_type; 
    824         pj_size_t frame_size; 
     823        pj_size_t frame_size = channel->out_pkt_size; 
    825824        pj_uint32_t bit_info; 
    826825 
     
    20772076 
    20782077    if (param->type == PJMEDIA_TYPE_AUDIO) { 
    2079         channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) + 
    2080                                 stream->codec_param.info.max_bps * 
    2081                                 PJMEDIA_MAX_FRAME_DURATION_MS / 
    2082                                 8 / 1000; 
     2078        unsigned max_rx_based_size; 
     2079        unsigned max_bps_based_size; 
     2080 
     2081        /* out_pkt buffer is used for sending and receiving, so lets calculate 
     2082         * its size based on both. For receiving, we have stream->frame_size, 
     2083         * which is used in configuring jitter buffer frame length. 
     2084         * For sending, it is based on codec max_bps info. 
     2085         */ 
     2086        max_rx_based_size = stream->frame_size; 
     2087        max_bps_based_size = stream->codec_param.info.max_bps * 
     2088                             PJMEDIA_MAX_FRAME_DURATION_MS / 8 / 1000; 
     2089        channel->out_pkt_size = PJ_MAX(max_rx_based_size, max_bps_based_size); 
     2090 
     2091        /* Also include RTP header size (for sending) */ 
     2092        channel->out_pkt_size += sizeof(pjmedia_rtp_hdr); 
     2093 
    20832094        if (channel->out_pkt_size > PJMEDIA_MAX_MTU - 
    20842095                                    PJMEDIA_STREAM_RESV_PAYLOAD_LEN) 
Note: See TracChangeset for help on using the changeset viewer.