Changeset 3969


Ignore:
Timestamp:
Mar 8, 2012 8:34:30 AM (12 years ago)
Author:
nanang
Message:

Fix #1440:

  • Use separate buffer for outgoing RTCP. Previously, RTCP generation might override outgoing RTP payload (because of shared buffer).
  • Use exact size for RTCP-XR content buffer. Previously RTCP-XR content buffer size was set to PJMEDIA_MAX_MTU, quite huge wasted space.
Location:
pjproject/branches/1.x/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjmedia/include/pjmedia/rtcp_xr.h

    r3553 r3969  
    201201} pjmedia_rtcp_xr_rb_voip_mtc; 
    202202 
     203 
     204/** 
     205 * Constant of RTCP-XR content size. 
     206 */ 
     207#define PJMEDIA_RTCP_XR_BUF_SIZE \ 
     208    sizeof(pjmedia_rtcp_xr_rb_rr_time) + \ 
     209    sizeof(pjmedia_rtcp_xr_rb_dlrr) + \ 
     210    sizeof(pjmedia_rtcp_xr_rb_stats) + \ 
     211    sizeof(pjmedia_rtcp_xr_rb_voip_mtc) 
     212 
     213 
    203214/** 
    204215 * This structure declares RTCP XR (Extended Report) packet. 
     
    222233    } common; 
    223234 
    224     pj_int8_t            buf[PJMEDIA_MAX_MTU];/**< Content buffer   */ 
     235    pj_int8_t            buf[PJMEDIA_RTCP_XR_BUF_SIZE]; 
     236                                        /**< Content buffer   */ 
    225237} pjmedia_rtcp_xr_pkt; 
    226238 
  • pjproject/branches/1.x/pjmedia/src/pjmedia/stream.c

    r3960 r3969  
    145145    pj_bool_t                initial_rr;    /**< Initial RTCP RR sent       */ 
    146146    pj_bool_t                rtcp_sdes_bye_disabled;/**< Send RTCP SDES/BYE?*/ 
     147    void                    *out_rtcp_pkt;  /**< Outgoing RTCP packet.      */ 
     148    unsigned                 out_rtcp_pkt_size; 
     149                                            /**< Outgoing RTCP packet size. */ 
    147150 
    148151    /* RFC 2833 DTMF transmission queue: */ 
     
    927930 
    928931    if (with_sdes || with_bye || with_xr) { 
    929         pkt = (pj_uint8_t*) stream->enc->out_pkt; 
     932        pkt = (pj_uint8_t*) stream->out_rtcp_pkt; 
    930933        pj_memcpy(pkt, sr_rr_pkt, len); 
    931         max_len = stream->enc->out_pkt_size; 
     934        max_len = stream->out_rtcp_pkt_size; 
    932935    } else { 
    933936        pkt = sr_rr_pkt; 
     
    18901893    pjmedia_channel *channel; 
    18911894    pj_status_t status; 
    1892     unsigned min_out_pkt_size; 
    18931895     
    18941896    /* Allocate memory for channel descriptor */ 
     
    19141916    if (channel->out_pkt_size > PJMEDIA_MAX_MTU) 
    19151917        channel->out_pkt_size = PJMEDIA_MAX_MTU; 
    1916  
    1917     /* It should big enough to hold (minimally) RTCP SR with an SDES. */ 
    1918     min_out_pkt_size =  sizeof(pjmedia_rtcp_sr_pkt) + 
    1919                         sizeof(pjmedia_rtcp_common) + 
    1920                         (4 + stream->cname.slen) + 
    1921                         32; 
    1922  
    1923     if (channel->out_pkt_size < min_out_pkt_size) 
    1924         channel->out_pkt_size = min_out_pkt_size; 
    19251918 
    19261919    channel->out_pkt = pj_pool_alloc(pool, channel->out_pkt_size); 
     
    22612254        } 
    22622255    } 
     2256 
     2257    /* Allocate outgoing RTCP buffer, should be enough to hold SR/RR, SDES, 
     2258     * BYE, and XR. 
     2259     */ 
     2260    stream->out_rtcp_pkt_size =  sizeof(pjmedia_rtcp_sr_pkt) + 
     2261                                 sizeof(pjmedia_rtcp_common) + 
     2262                                 (4 + stream->cname.slen) + 
     2263                                 32; 
     2264#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 
     2265    if (info->rtcp_xr_enabled) { 
     2266        stream->out_rtcp_pkt_size += sizeof(pjmedia_rtcp_xr_pkt); 
     2267    } 
     2268#endif 
     2269 
     2270    if (stream->out_rtcp_pkt_size > PJMEDIA_MAX_MTU) 
     2271        stream->out_rtcp_pkt_size = PJMEDIA_MAX_MTU; 
     2272 
     2273    stream->out_rtcp_pkt = pj_pool_alloc(pool, stream->out_rtcp_pkt_size); 
    22632274 
    22642275    /* Only attach transport when stream is ready. */ 
Note: See TracChangeset for help on using the changeset viewer.