Ignore:
Timestamp:
Mar 15, 2007 10:23:15 AM (17 years ago)
Author:
bennylp
Message:

Fixed ticket #176: RTP port number is not reset in pjsua media (thanks Binu KS)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsua-lib/pjsua_media.c

    r974 r1065  
    2727#define DEFAULT_RTP_PORT    4000 
    2828 
     29/* Next RTP port to be used */ 
     30static pj_uint16_t next_rtp_port; 
    2931 
    3032/* Close existing sound device */ 
     
    209211    }; 
    210212    int i; 
    211     static pj_uint16_t rtp_port; 
    212213    pj_sockaddr_in bound_addr; 
    213214    pj_sockaddr_in mapped_addr[2]; 
     
    215216    pj_sock_t sock[2]; 
    216217 
    217     if (rtp_port == 0) 
    218         rtp_port = (pj_uint16_t)cfg->port; 
     218    if (next_rtp_port == 0) 
     219        next_rtp_port = (pj_uint16_t)cfg->port; 
    219220 
    220221    for (i=0; i<2; ++i) 
     
    232233 
    233234    /* Loop retry to bind RTP and RTCP sockets. */ 
    234     for (i=0; i<RTP_RETRY; ++i, rtp_port += 2) { 
     235    for (i=0; i<RTP_RETRY; ++i, next_rtp_port += 2) { 
    235236 
    236237        /* Create and bind RTP socket. */ 
     
    242243 
    243244        status = pj_sock_bind_in(sock[0], bound_addr.sin_addr.s_addr,  
    244                                  rtp_port); 
     245                                 next_rtp_port); 
    245246        if (status != PJ_SUCCESS) { 
    246247            pj_sock_close(sock[0]);  
     
    258259 
    259260        status = pj_sock_bind_in(sock[1], bound_addr.sin_addr.s_addr,  
    260                                  (pj_uint16_t)(rtp_port+1)); 
     261                                 (pj_uint16_t)(next_rtp_port+1)); 
    261262        if (status != PJ_SUCCESS) { 
    262263            pj_sock_close(sock[0]);  
     
    300301 
    301302            status = pj_sockaddr_in_init(&mapped_addr[0], &cfg->public_addr, 
    302                                          (pj_uint16_t)rtp_port); 
     303                                         (pj_uint16_t)next_rtp_port); 
    303304            if (status != PJ_SUCCESS) 
    304305                goto on_error; 
    305306 
    306307            status = pj_sockaddr_in_init(&mapped_addr[1], &cfg->public_addr, 
    307                                          (pj_uint16_t)(rtp_port+1)); 
     308                                         (pj_uint16_t)(next_rtp_port+1)); 
    308309            if (status != PJ_SUCCESS) 
    309310                goto on_error; 
     
    322323                mapped_addr[i].sin_addr = addr; 
    323324 
    324             mapped_addr[0].sin_port=pj_htons((pj_uint16_t)rtp_port); 
    325             mapped_addr[1].sin_port=pj_htons((pj_uint16_t)(rtp_port+1)); 
     325            mapped_addr[0].sin_port=pj_htons((pj_uint16_t)next_rtp_port); 
     326            mapped_addr[1].sin_port=pj_htons((pj_uint16_t)(next_rtp_port+1)); 
    326327            break; 
    327328        } 
     
    350351              pj_ntohs(skinfo->rtcp_addr_name.sin_port))); 
    351352 
    352     rtp_port += 2; 
     353    next_rtp_port += 2; 
    353354    return PJ_SUCCESS; 
    354355 
     
    480481    /* Deinitialize sound subsystem */ 
    481482    pjmedia_snd_deinit(); 
     483 
     484    /* Reset RTP port */ 
     485    next_rtp_port = 0; 
    482486 
    483487    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.