Changeset 4197


Ignore:
Timestamp:
Jul 5, 2012 7:26:29 AM (7 years ago)
Author:
nanang
Message:

Fix #1547:

  • Added PJMEDIA_MAX_MRU to specify maximum packet size in receiving direction.
  • Added max_pkt_size into pj_turn_sock_cfg, default is PJ_TURN_MAX_PKT_LEN.
  • Fixed hardcoded MTU settings in media transport SRTP.
  • Added MIN_CHUNKS_PER_FRM constant in video stream.

Notes:

  • PJMEDIA_MAX_MTU & PJMEDIA_MAX_MRU to specify max packet size for TX and RX dir.
  • For ICE media transport, TURN session limits outgoing packet size to PJ_TURN_MAX_PKT_LEN (the size of internal buffer for inserting TURN overheads).
Location:
pjproject/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/config.h

    r4130 r4197  
    372372 
    373373/** 
    374  * Max packet size to support. 
     374 * Max packet size for transmitting direction. 
    375375 */ 
    376376#ifndef PJMEDIA_MAX_MTU                  
    377377#  define PJMEDIA_MAX_MTU                       1500 
     378#endif 
     379 
     380 
     381/** 
     382 * Max packet size for receiving direction. 
     383 */ 
     384#ifndef PJMEDIA_MAX_MRU                  
     385#  define PJMEDIA_MAX_MRU                       2000 
    378386#endif 
    379387 
  • pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c

    r3999 r4197  
    3535#define THIS_FILE   "transport_srtp.c" 
    3636 
    37 /* Maximum size of packet */ 
    38 #define MAX_RTP_BUFFER_LEN          1500 
    39 #define MAX_RTCP_BUFFER_LEN         1500 
     37/* Maximum size of outgoing packet */ 
     38#define MAX_RTP_BUFFER_LEN          PJMEDIA_MAX_MTU 
     39#define MAX_RTCP_BUFFER_LEN         PJMEDIA_MAX_MTU 
     40 
     41/* Maximum SRTP crypto key length */ 
    4042#define MAX_KEY_LEN                 32 
    4143 
     
    778780        return pjmedia_transport_send_rtp(srtp->member_tp, pkt, size); 
    779781 
    780     if (size > sizeof(srtp->rtp_tx_buffer)) 
     782    if (size > sizeof(srtp->rtp_tx_buffer) - 10) 
    781783        return PJ_ETOOBIG; 
    782784 
     
    792794 
    793795    if (err == err_status_ok) { 
    794         status = pjmedia_transport_send_rtp(srtp->member_tp, srtp->rtp_tx_buffer, len); 
     796        status = pjmedia_transport_send_rtp(srtp->member_tp,  
     797                                            srtp->rtp_tx_buffer, len); 
    795798    } else { 
    796799        status = PJMEDIA_ERRNO_FROM_LIBSRTP(err); 
     
    823826    } 
    824827 
    825     if (size > sizeof(srtp->rtcp_tx_buffer)) 
     828    if (size > sizeof(srtp->rtcp_tx_buffer) - 10) 
    826829        return PJ_ETOOBIG; 
    827830 
  • pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c

    r3841 r4197  
    3030 
    3131/* Maximum size of incoming RTP packet */ 
    32 #define RTP_LEN     PJMEDIA_MAX_MTU 
     32#define RTP_LEN     PJMEDIA_MAX_MRU 
    3333 
    3434/* Maximum size of incoming RTCP packet */ 
     
    4343typedef struct pending_write 
    4444{ 
    45     char                buffer[RTP_LEN]; 
     45    char                buffer[PJMEDIA_MAX_MTU]; 
    4646    pj_ioqueue_op_key_t op_key; 
    4747} pending_write; 
     
    753753 
    754754    /* Check that the size is supported */ 
    755     PJ_ASSERT_RETURN(size <= RTP_LEN, PJ_ETOOBIG); 
     755    PJ_ASSERT_RETURN(size <= PJMEDIA_MAX_MTU, PJ_ETOOBIG); 
    756756 
    757757    /* Simulate packet lost on TX direction */ 
  • pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c

    r4123 r4197  
    6969#endif 
    7070 
     71/* Due to network MTU limitation, a picture bitstream may be splitted into 
     72 * several chunks for RTP delivery. The chunk number may vary depend on the 
     73 * picture resolution and MTU. This constant specifies the minimum chunk 
     74 * number to be allocated to store a picture bitstream in decoding direction. 
     75 */ 
     76#define MIN_CHUNKS_PER_FRM      30 
     77 
    7178/* Video stream keep-alive feature is currently disabled. */ 
    7279#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA != 0 
     
    13581365    pjmedia_video_format_detail *vfd_enc, *vfd_dec; 
    13591366    char *p; 
    1360     unsigned dec_mtu; 
    13611367    pj_status_t status; 
    13621368 
     
    14111417        info->codec_param->enc_mtu = PJMEDIA_MAX_MTU; 
    14121418 
    1413     /* MTU estimation for decoding direction */ 
    1414     dec_mtu = PJMEDIA_MAX_MTU; 
    1415  
     1419    /* Packet size estimation for decoding direction */ 
    14161420    vfd_enc = pjmedia_format_get_video_format_detail( 
    14171421                                        &info->codec_param->enc_fmt, PJ_TRUE); 
     
    15291533    /* Init jitter buffer parameters: */ 
    15301534    frm_ptime       = 1000 * vfd_enc->fps.denum / vfd_enc->fps.num; 
    1531     chunks_per_frm  = stream->frame_size / dec_mtu; 
    1532     if (chunks_per_frm == 0) chunks_per_frm = 1; 
     1535    chunks_per_frm  = stream->frame_size / PJMEDIA_MAX_MRU; 
     1536    if (chunks_per_frm < MIN_CHUNKS_PER_FRM) 
     1537        chunks_per_frm = MIN_CHUNKS_PER_FRM; 
    15331538 
    15341539    /* JB max count, default 500ms */ 
     
    15651570    /* Create jitter buffer */ 
    15661571    status = pjmedia_jbuf_create(pool, &stream->dec->port.info.name, 
    1567                                  dec_mtu + PJMEDIA_STREAM_RESV_PAYLOAD_LEN, 
     1572                                 PJMEDIA_MAX_MRU, 
    15681573                                 1000 * vfd_enc->fps.denum / vfd_enc->fps.num, 
    15691574                                 jb_max, &stream->jb); 
  • pjproject/trunk/pjnath/include/pjnath/stun_sock.h

    r3553 r4197  
    219219{ 
    220220    /** 
    221      * Packet buffer size. Default value is PJ_STUN_SOCK_PKT_LEN. 
     221     * Packet buffer size. 
     222     * 
     223     * Default value is PJ_STUN_SOCK_PKT_LEN. 
    222224     */ 
    223225    unsigned max_pkt_size; 
  • pjproject/trunk/pjnath/include/pjnath/turn_sock.h

    r3553 r4197  
    109109typedef struct pj_turn_sock_cfg 
    110110{ 
     111    /** 
     112     * Packet buffer size. 
     113     * 
     114     * Default value is PJ_TURN_MAX_PKT_LEN. 
     115     */ 
     116    unsigned max_pkt_size; 
     117 
    111118    /** 
    112119     * QoS traffic type to be set on this transport. When application wants 
  • pjproject/trunk/pjnath/src/pjnath/turn_sock.c

    r3841 r4197  
    9898{ 
    9999    pj_bzero(cfg, sizeof(*cfg)); 
     100    cfg->max_pkt_size = PJ_TURN_MAX_PKT_LEN; 
    100101    cfg->qos_type = PJ_QOS_TYPE_BEST_EFFORT; 
    101102    cfg->qos_ignore_error = PJ_TRUE; 
     
    475476    /* Kick start pending read operation */ 
    476477    status = pj_activesock_start_read(asock, turn_sock->pool,  
    477                                       PJ_TURN_MAX_PKT_LEN, 0); 
     478                                      turn_sock->setting.max_pkt_size, 0); 
    478479 
    479480    /* Init send_key */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r4196 r4197  
    720720                  sizeof(cfg->qos_params)); 
    721721    } 
     722 
     723    /* Configure packet size for STUN and TURN sockets */ 
     724    ice_cfg.stun.cfg.max_pkt_size = PJMEDIA_MAX_MRU; 
     725    ice_cfg.turn.cfg.max_pkt_size = PJMEDIA_MAX_MRU; 
    722726 
    723727    pj_bzero(&ice_cb, sizeof(pjmedia_ice_cb)); 
Note: See TracChangeset for help on using the changeset viewer.