Ignore:
Timestamp:
Feb 4, 2014 10:13:56 AM (10 years ago)
Author:
bennylp
Message:

Misc (re #1630): Fixing warnings about variable set but not used with recent gcc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r4724 r4728  
    11/* $Id$ */ 
    2 /*  
     2/* 
    33 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    44 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919 */ 
    2020#include <pjsua-lib/pjsua.h> 
     
    3939 * The INFO method. 
    4040 */ 
    41 const pjsip_method pjsip_info_method =  
     41const pjsip_method pjsip_info_method = 
    4242{ 
    4343    PJSIP_OTHER_METHOD, 
     
    4949 * session state has changed. 
    5050 */ 
    51 static void pjsua_call_on_state_changed(pjsip_inv_session *inv,  
     51static void pjsua_call_on_state_changed(pjsip_inv_session *inv, 
    5252                                        pjsip_event *e); 
    5353 
     
    5555 * has forked. 
    5656 */ 
    57 static void pjsua_call_on_forked( pjsip_inv_session *inv,  
     57static void pjsua_call_on_forked( pjsip_inv_session *inv, 
    5858                                  pjsip_event *e); 
    5959 
     
    164164    /* Check the route URI's and force loose route if required */ 
    165165    for (i=0; i<pjsua_var.ua_cfg.outbound_proxy_cnt; ++i) { 
    166         status = normalize_route_uri(pjsua_var.pool,  
     166        status = normalize_route_uri(pjsua_var.pool, 
    167167                                     &pjsua_var.ua_cfg.outbound_proxy[i]); 
    168168        if (status != PJ_SUCCESS) 
     
    258258#if 1 
    259259    /* New algorithm: round-robin */ 
    260     if (pjsua_var.next_call_id >= (int)pjsua_var.ua_cfg.max_calls ||  
     260    if (pjsua_var.next_call_id >= (int)pjsua_var.ua_cfg.max_calls || 
    261261        pjsua_var.next_call_id < 0) 
    262262    { 
     
    264264    } 
    265265 
    266     for (cid=pjsua_var.next_call_id;  
    267          cid<(int)pjsua_var.ua_cfg.max_calls;  
    268          ++cid)  
     266    for (cid=pjsua_var.next_call_id; 
     267         cid<(int)pjsua_var.ua_cfg.max_calls; 
     268         ++cid) 
    269269    { 
    270270        if (pjsua_var.calls[cid].inv == NULL && 
     
    310310    if (pj_stristr(dst_uri, &sips)) 
    311311        return 2; 
    312      
     312 
    313313    if (!pj_list_empty(&acc->route_set)) { 
    314314        pjsip_route_hdr *r = acc->route_set.next; 
    315315        pjsip_uri *uri = r->name_addr.uri; 
    316316        pjsip_sip_uri *sip_uri; 
    317          
     317 
    318318        sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri); 
    319319        if (pj_stricmp2(&sip_uri->transport_param, "tls")==0) 
     
    338338        pjsip_uri *uri = r->name_addr.uri; 
    339339        pjsip_sip_uri *sip_uri; 
    340          
     340 
    341341        sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri); 
    342342        if (pj_stricmp2(&sip_uri->transport_param, "tls")==0) 
     
    468468    /* Set credentials: */ 
    469469    if (acc->cred_cnt) { 
    470         pjsip_auth_clt_set_credentials( &dlg->auth_sess,  
     470        pjsip_auth_clt_set_credentials( &dlg->auth_sess, 
    471471                                        acc->cred_cnt, acc->cred); 
    472472    } 
     
    479479    status = pjsip_inv_invite(inv, &tdata); 
    480480    if (status != PJ_SUCCESS) { 
    481         pjsua_perror(THIS_FILE, "Unable to create initial INVITE request",  
     481        pjsua_perror(THIS_FILE, "Unable to create initial INVITE request", 
    482482                     status); 
    483483        goto on_error; 
     
    499499        cb_called = PJ_TRUE; 
    500500 
    501         /* Upon failure to send first request, the invite  
     501        /* Upon failure to send first request, the invite 
    502502         * session would have been cleared. 
    503503         */ 
     
    617617 
    618618    /* Check that account is valid */ 
    619     PJ_ASSERT_RETURN(acc_id>=0 || acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc),  
     619    PJ_ASSERT_RETURN(acc_id>=0 || acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc), 
    620620                     PJ_EINVAL); 
    621621 
     
    631631 
    632632    /* Create sound port if none is instantiated, to check if sound device 
    633      * can be used. But only do this with the conference bridge, as with  
    634      * audio switchboard (i.e. APS-Direct), we can only open the sound  
     633     * can be used. But only do this with the conference bridge, as with 
     634     * audio switchboard (i.e. APS-Direct), we can only open the sound 
    635635     * device once the correct format has been known 
    636636     */ 
    637     if (!pjsua_var.is_mswitch && pjsua_var.snd_port==NULL &&  
    638         pjsua_var.null_snd==NULL && !pjsua_var.no_snd)  
     637    if (!pjsua_var.is_mswitch && pjsua_var.snd_port==NULL && 
     638        pjsua_var.null_snd==NULL && !pjsua_var.no_snd) 
    639639    { 
    640640        status = pjsua_set_snd_dev(pjsua_var.cap_dev, pjsua_var.play_dev); 
     
    679679    tmp_pool = pjsua_pool_create("tmpcall10", 512, 256); 
    680680 
    681     /* Verify that destination URI is valid before calling  
    682      * pjsua_acc_create_uac_contact, or otherwise there   
     681    /* Verify that destination URI is valid before calling 
     682     * pjsua_acc_create_uac_contact, or otherwise there 
    683683     * a misleading "Invalid Contact URI" error will be printed 
    684684     * when pjsua_acc_create_uac_contact() fails. 
     
    692692 
    693693        if (uri == NULL) { 
    694             pjsua_perror(THIS_FILE, "Unable to make call",  
     694            pjsua_perror(THIS_FILE, "Unable to make call", 
    695695                         PJSIP_EINVALIDREQURI); 
    696696            status = PJSIP_EINVALIDREQURI; 
     
    714714                                              acc_id, dest_uri); 
    715715        if (status != PJ_SUCCESS) { 
    716             pjsua_perror(THIS_FILE, "Unable to generate Contact header",  
     716            pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
    717717                         status); 
    718718            goto on_error; 
     
    721721 
    722722    /* Create outgoing dialog: */ 
    723     status = pjsip_dlg_create_uac( pjsip_ua_instance(),  
     723    status = pjsip_dlg_create_uac( pjsip_ua_instance(), 
    724724                                   &acc->cfg.id, &contact, 
    725725                                   dest_uri, 
     
    745745    /* Attach user data */ 
    746746    call->user_data = user_data; 
    747      
     747 
    748748    /* Store variables required for the callback after the async 
    749749     * media transport creation is completed. 
     
    762762 
    763763    /* Init media channel */ 
    764     status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC,  
     764    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 
    765765                                      call->secure_level, dlg->pool, 
    766766                                      NULL, NULL, PJ_TRUE, 
     
    813813 
    814814/* Get the NAT type information in remote's SDP */ 
    815 static void update_remote_nat_type(pjsua_call *call,  
     815static void update_remote_nat_type(pjsua_call *call, 
    816816                                   const pjmedia_sdp_session *sdp) 
    817817{ 
     
    900900{ 
    901901    struct call_answer *answer, *next; 
    902      
     902 
    903903    answer = call->async_call.call_var.inc_call.answers.next; 
    904904    while (answer != &call->async_call.call_var.inc_call.answers) { 
     
    906906        pjsua_call_answer2(call->index, answer->opt, answer->code, 
    907907                           answer->reason, answer->msg_data); 
    908          
     908 
    909909        /* Call might have been disconnected if application is answering 
    910910         * with 200/OK and the media failed to start. 
     
    953953 
    954954    status = pjsua_media_channel_create_sdp(call_id, 
    955                                             call->async_call.dlg->pool,  
     955                                            call->async_call.dlg->pool, 
    956956                                            offer, &answer, &sip_err_code); 
    957957    if (status != PJ_SUCCESS) { 
     
    977977        sip_err_code = PJSIP_ERRNO_TO_SIP_STATUS(status); 
    978978        goto on_return; 
    979     }  
     979    } 
    980980 
    981981on_return: 
     
    10071007        if (call->async_call.call_var.inc_call.replaced_dlg) { 
    10081008            /* Process pending call replace */ 
    1009             pjsip_dialog *replaced_dlg =  
     1009            pjsip_dialog *replaced_dlg = 
    10101010                        call->async_call.call_var.inc_call.replaced_dlg; 
    10111011            process_incoming_call_replace(call, replaced_dlg); 
     
    10541054    /* Don't want to accept the call if shutdown is in progress */ 
    10551055    if (pjsua_var.thread_quit_flag) { 
    1056         pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,  
     1056        pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 
    10571057                                      PJSIP_SC_TEMPORARILY_UNAVAILABLE, NULL, 
    10581058                                      NULL, NULL); 
     
    10691069 
    10701070    if (call_id == PJSUA_INVALID_ID) { 
    1071         pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,  
     1071        pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 
    10721072                                      PJSIP_SC_BUSY_HERE, NULL, 
    10731073                                      NULL, NULL); 
    1074         PJ_LOG(2,(THIS_FILE,  
     1074        PJ_LOG(2,(THIS_FILE, 
    10751075                  "Unable to accept incoming call (too many calls)")); 
    10761076        goto on_return; 
     
    10981098 
    10991099            pjsip_get_response_addr(response->pool, rdata, &res_addr); 
    1100             pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response,  
     1100            pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response, 
    11011101                                      NULL, NULL); 
    11021102 
     
    11521152                st_text = *pjsip_get_status_text(st_code); 
    11531153 
    1154             pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata,  
     1154            pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 
    11551155                                st_code, &st_text, NULL, NULL, NULL); 
    11561156            goto on_return; 
     
    11581158    } 
    11591159 
    1160     /*  
     1160    /* 
    11611161     * Get which account is most likely to be associated with this incoming 
    11621162     * call. We need the account to find which contact URI to put for 
     
    11901190            pjsip_warning_hdr *w; 
    11911191 
    1192             pjsua_perror(THIS_FILE, "Bad SDP in incoming INVITE",  
     1192            pjsua_perror(THIS_FILE, "Bad SDP in incoming INVITE", 
    11931193                         status); 
    11941194 
    1195             w = pjsip_warning_hdr_create_from_status(rdata->tp_info.pool,  
     1195            w = pjsip_warning_hdr_create_from_status(rdata->tp_info.pool, 
    11961196                                             pjsip_endpt_name(pjsua_var.endpt), 
    11971197                                             status); 
     
    11991199            pj_list_push_back(&hdr_list, w); 
    12001200 
    1201             pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400,  
     1201            pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, 
    12021202                                &reason, &hdr_list, NULL, NULL); 
    12031203            goto on_return; 
    12041204        } 
    12051205 
    1206         /* Do quick checks on SDP before passing it to transports. More elabore  
     1206        /* Do quick checks on SDP before passing it to transports. More elabore 
    12071207         * checks will be done in pjsip_inv_verify_request2() below. 
    12081208         */ 
    12091209        if (offer->media_count==0) { 
    12101210            const pj_str_t reason = pj_str("Missing media in SDP"); 
    1211             pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, &reason,  
     1211            pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, &reason, 
    12121212                                NULL, NULL, NULL); 
    12131213            goto on_return; 
     
    12411241 
    12421242            pjsip_get_response_addr(response->pool, rdata, &res_addr); 
    1243             pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response,  
     1243            pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response, 
    12441244                                      NULL, NULL); 
    12451245 
     
    12511251 
    12521252        goto on_return; 
    1253     }  
     1253    } 
    12541254 
    12551255    /* Get suitable Contact header */ 
     
    12601260                                              acc_id, rdata); 
    12611261        if (status != PJ_SUCCESS) { 
    1262             pjsua_perror(THIS_FILE, "Unable to generate Contact header",  
     1262            pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
    12631263                         status); 
    12641264            pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, 
     
    12861286    /* Set credentials */ 
    12871287    if (pjsua_var.acc[acc_id].cred_cnt) { 
    1288         pjsip_auth_clt_set_credentials(&dlg->auth_sess,  
     1288        pjsip_auth_clt_set_credentials(&dlg->auth_sess, 
    12891289                                       pjsua_var.acc[acc_id].cred_cnt, 
    12901290                                       pjsua_var.acc[acc_id].cred); 
     
    12921292 
    12931293    /* Set preference */ 
    1294     pjsip_auth_clt_set_prefs(&dlg->auth_sess,  
     1294    pjsip_auth_clt_set_prefs(&dlg->auth_sess, 
    12951295                             &pjsua_var.acc[acc_id].cfg.auth_pref); 
    12961296 
     
    12981298     * did not require it. 
    12991299     */ 
    1300     if (pjsua_var.acc[acc_id].cfg.use_timer == PJSUA_SIP_TIMER_INACTIVE &&  
     1300    if (pjsua_var.acc[acc_id].cfg.use_timer == PJSUA_SIP_TIMER_INACTIVE && 
    13011301        (options & PJSIP_INV_REQUIRE_TIMER) == 0) 
    13021302    { 
     
    13231323        pjsip_warning_hdr *w; 
    13241324 
    1325         w = pjsip_warning_hdr_create_from_status(dlg->pool,  
     1325        w = pjsip_warning_hdr_create_from_status(dlg->pool, 
    13261326                                                 pjsip_endpt_name(pjsua_var.endpt), 
    13271327                                                 status); 
     
    13611361     */ 
    13621362    if (offer || replaced_dlg) { 
    1363         status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS,  
    1364                                           call->secure_level,  
     1363        status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 
     1364                                          call->secure_level, 
    13651365                                          rdata->tp_info.pool, 
    13661366                                          offer, 
     
    13771377                 */ 
    13781378                pjsip_dlg_respond(dlg, rdata, sip_err_code, NULL, NULL, NULL); 
    1379                 pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE);  
     1379                pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE); 
    13801380                call->inv = NULL; 
    13811381                call->async_call.dlg = NULL; 
     
    13851385            pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
    13861386            pjsip_dlg_respond(dlg, rdata, sip_err_code, NULL, NULL, NULL); 
    1387             pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE);  
    1388             call->inv = NULL;  
     1387            pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE); 
     1388            call->inv = NULL; 
    13891389            call->async_call.dlg = NULL; 
    13901390            goto on_return; 
     
    13931393 
    13941394    /* Create answer */ 
    1395 /*   
    1396     status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool,  
     1395/* 
     1396    status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool, 
    13971397                                            offer, &answer, &sip_err_code); 
    13981398    if (status != PJ_SUCCESS) { 
     
    14051405 
    14061406    /* Init Session Timers */ 
    1407     status = pjsip_timer_init_session(inv,  
     1407    status = pjsip_timer_init_session(inv, 
    14081408                                    &pjsua_var.acc[acc_id].cfg.timer_setting); 
    14091409    if (status != PJ_SUCCESS) { 
     
    14201420 
    14211421    /* Update NAT type of remote endpoint, only when there is SDP in 
    1422      * incoming INVITE!  
     1422     * incoming INVITE! 
    14231423     */ 
    14241424    if (pjsua_var.ua_cfg.nat_type_in_sdp && inv->neg && 
    1425         pjmedia_sdp_neg_get_state(inv->neg) > PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER)  
     1425        pjmedia_sdp_neg_get_state(inv->neg) > PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) 
    14261426    { 
    14271427        const pjmedia_sdp_session *remote_sdp; 
     
    14891489        } 
    14901490    } else { 
    1491         /* Notify application if on_incoming_call() is overriden,  
     1491        /* Notify application if on_incoming_call() is overriden, 
    14921492         * otherwise hangup the call with 480 
    14931493         */ 
     
    14951495            pjsua_var.ua_cfg.cb.on_incoming_call(acc_id, call_id, rdata); 
    14961496        } else { 
    1497             pjsua_call_hangup(call_id, PJSIP_SC_TEMPORARILY_UNAVAILABLE,  
     1497            pjsua_call_hangup(call_id, PJSIP_SC_TEMPORARILY_UNAVAILABLE, 
    14981498                              NULL, NULL); 
    14991499        } 
     
    15511551                break; 
    15521552        } 
    1553          
     1553 
    15541554        has_pjsua_lock = PJ_FALSE; 
    15551555 
     
    15961596        return PJ_ETIMEDOUT; 
    15971597    } 
    1598      
     1598 
    15991599    *p_call = call; 
    16001600    *p_dlg = dlg; 
     
    17011701                   sizeof(info->buf_.last_status_text)); 
    17021702    } 
    1703      
     1703 
    17041704    /* Audio & video count offered by remote */ 
    17051705    info->rem_offerer   = call->rem_offerer; 
     
    17271727            pjmedia_vid_dev_index cap_dev = PJMEDIA_VID_INVALID_DEV; 
    17281728 
    1729             info->media[info->media_cnt].stream.vid.win_in =  
     1729            info->media[info->media_cnt].stream.vid.win_in = 
    17301730                                                call_med->strm.v.rdr_win_id; 
    17311731 
     
    17631763            pjmedia_vid_dev_index cap_dev = PJMEDIA_VID_INVALID_DEV; 
    17641764 
    1765             info->prov_media[info->prov_media_cnt].stream.vid.win_in =  
     1765            info->prov_media[info->prov_media_cnt].stream.vid.win_in = 
    17661766                                                call_med->strm.v.rdr_win_id; 
    17671767 
     
    18741874 * Get media transport info for the specified media index. 
    18751875 */ 
    1876 PJ_DEF(pj_status_t)  
     1876PJ_DEF(pj_status_t) 
    18771877pjsua_call_get_med_transport_info(pjsua_call_id call_id, 
    18781878                                  unsigned med_idx, 
     
    18901890 
    18911891    call = &pjsua_var.calls[call_id]; 
    1892      
     1892 
    18931893    if (med_idx >= call->med_cnt) { 
    18941894        PJSUA_UNLOCK(); 
     
    19001900    pjmedia_transport_info_init(t); 
    19011901    status = pjmedia_transport_get_info(call_med->tp, t); 
    1902      
     1902 
    19031903    PJSUA_UNLOCK(); 
    19041904    return status; 
     
    19321932 
    19331933    status = pjsua_media_channel_create_sdp(call_id, 
    1934                                             call->async_call.dlg->pool,  
     1934                                            call->async_call.dlg->pool, 
    19351935                                            NULL, &sdp, &sip_err_code); 
    19361936    if (status != PJ_SUCCESS) { 
     
    19841984 * Send response to incoming INVITE request. 
    19851985 */ 
    1986 PJ_DEF(pj_status_t) pjsua_call_answer( pjsua_call_id call_id,  
     1986PJ_DEF(pj_status_t) pjsua_call_answer( pjsua_call_id call_id, 
    19871987                                       unsigned code, 
    19881988                                       const pj_str_t *reason, 
     
    20422042     *   answer code 183 or 2xx is issued 
    20432043     */ 
    2044     if (!call->med_ch_cb &&  
     2044    if (!call->med_ch_cb && 
    20452045        (call->opt_inited || (code==183 || code/100==2)) && 
    20462046        (!call->inv->neg || 
    2047          pjmedia_sdp_neg_get_state(call->inv->neg) ==  
     2047         pjmedia_sdp_neg_get_state(call->inv->neg) == 
    20482048                PJMEDIA_SDP_NEG_STATE_NULL)) 
    20492049    { 
     
    20762076    if (call->med_ch_cb) { 
    20772077        struct call_answer *answer; 
    2078          
     2078 
    20792079        PJ_LOG(4,(THIS_FILE, "Pending answering call %d upon completion " 
    20802080                             "of media transport", call_id)); 
     
    21142114    status = pjsip_inv_answer(call->inv, code, reason, NULL, &tdata); 
    21152115    if (status != PJ_SUCCESS) { 
    2116         pjsua_perror(THIS_FILE, "Error creating response",  
     2116        pjsua_perror(THIS_FILE, "Error creating response", 
    21172117                     status); 
    21182118        goto on_return; 
     
    21312131    status = pjsip_inv_send_msg(call->inv, tdata); 
    21322132    if (status != PJ_SUCCESS) 
    2133         pjsua_perror(THIS_FILE, "Error sending response",  
     2133        pjsua_perror(THIS_FILE, "Error sending response", 
    21342134                     status); 
    21352135 
     
    21602160                             call_id)); 
    21612161    } 
    2162      
     2162 
    21632163    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
    21642164                     PJ_EINVAL); 
     
    21862186                       sizeof(call->last_text_buf_)); 
    21872187        } 
    2188          
     2188 
    21892189        goto on_return; 
    21902190    } 
     
    22012201    status = pjsip_inv_end_session(call->inv, code, reason, &tdata); 
    22022202    if (status != PJ_SUCCESS) { 
    2203         pjsua_perror(THIS_FILE,  
    2204                      "Failed to create end session message",  
     2203        pjsua_perror(THIS_FILE, 
     2204                     "Failed to create end session message", 
    22052205                     status); 
    22062206        goto on_return; 
    22072207    } 
    22082208 
    2209     /* pjsip_inv_end_session may return PJ_SUCCESS with NULL  
     2209    /* pjsip_inv_end_session may return PJ_SUCCESS with NULL 
    22102210     * as p_tdata when INVITE transaction has not been answered 
    22112211     * with any provisional responses. 
     
    22202220    status = pjsip_inv_send_msg(call->inv, tdata); 
    22212221    if (status != PJ_SUCCESS) { 
    2222         pjsua_perror(THIS_FILE,  
    2223                      "Failed to send end session message",  
     2222        pjsua_perror(THIS_FILE, 
     2223                     "Failed to send end session message", 
    22242224                     status); 
    22252225        goto on_return; 
     
    22522252                     PJ_EINVAL); 
    22532253 
    2254     status = acquire_call("pjsua_call_process_redirect()", call_id,  
     2254    status = acquire_call("pjsua_call_process_redirect()", call_id, 
    22552255                          &call, &dlg); 
    22562256    if (status != PJ_SUCCESS) 
     
    23982398        goto on_return; 
    23992399    } 
    2400  
    2401     status = apply_call_setting(call, opt, NULL); 
    2402     if (status != PJ_SUCCESS) { 
    2403         pjsua_perror(THIS_FILE, "Failed to apply call setting", status); 
    2404         goto on_return; 
    2405     } 
    2406  
    2407     /* Create SDP */ 
    2408     if (call->local_hold && (call->opt.flag & PJSUA_CALL_UNHOLD)==0) { 
    2409         status = create_sdp_of_call_hold(call, &sdp); 
    2410     } else { 
    2411         status = pjsua_media_channel_create_sdp(call->index,  
    2412                                                 call->inv->pool_prov, 
    2413                                                 NULL, &sdp, NULL); 
    2414         call->local_hold = PJ_FALSE; 
    2415     } 
    2416     if (status != PJ_SUCCESS) { 
    2417         pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",  
    2418                      status); 
    2419         goto on_return; 
    2420     } 
    2421  
    2422     if ((call->opt.flag & PJSUA_CALL_UPDATE_CONTACT) && 
    2423             pjsua_acc_is_valid(call->acc_id)) 
    2424     { 
    2425         new_contact = &pjsua_var.acc[call->acc_id].contact; 
    2426     } 
    2427  
    2428     /* Create re-INVITE with new offer */ 
    2429     status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata); 
    2430     if (status != PJ_SUCCESS) { 
    2431         pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status); 
    2432         goto on_return; 
    2433     } 
    2434  
    2435     /* Add additional headers etc */ 
    2436     pjsua_process_msg_data( tdata, msg_data); 
    2437  
    2438     /* Send the request */ 
    2439     status = pjsip_inv_send_msg( call->inv, tdata); 
    2440     if (status != PJ_SUCCESS) { 
    2441         pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status); 
    2442         goto on_return; 
    2443     } 
    2444  
    2445 on_return: 
    2446     if (dlg) pjsip_dlg_dec_lock(dlg); 
    2447     pj_log_pop_indent(); 
    2448     return status; 
    2449 } 
    2450  
    2451  
    2452 /* 
    2453  * Send UPDATE request. 
    2454  */ 
    2455 PJ_DEF(pj_status_t) pjsua_call_update( pjsua_call_id call_id, 
    2456                                        unsigned options, 
    2457                                        const pjsua_msg_data *msg_data) 
    2458 { 
    2459     pjsua_call *call; 
    2460     pjsip_dialog *dlg = NULL; 
    2461     pj_status_t status; 
    2462  
    2463     status = acquire_call("pjsua_call_update()", call_id, &call, &dlg); 
    2464     if (status != PJ_SUCCESS) 
    2465         goto on_return; 
    2466  
    2467     if (options != call->opt.flag) 
    2468         call->opt.flag = options; 
    2469  
    2470     status = pjsua_call_update2(call_id, NULL, msg_data); 
    2471  
    2472 on_return: 
    2473     if (dlg) pjsip_dlg_dec_lock(dlg); 
    2474     return status; 
    2475 } 
    2476  
    2477  
    2478 /* 
    2479  * Send UPDATE request. 
    2480  */ 
    2481 PJ_DEF(pj_status_t) pjsua_call_update2(pjsua_call_id call_id, 
    2482                                        const pjsua_call_setting *opt, 
    2483                                        const pjsua_msg_data *msg_data) 
    2484 { 
    2485     pjmedia_sdp_session *sdp; 
    2486     pj_str_t *new_contact = NULL; 
    2487     pjsip_tx_data *tdata; 
    2488     pjsua_call *call; 
    2489     pjsip_dialog *dlg = NULL; 
    2490     pj_status_t status; 
    2491  
    2492     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
    2493                      PJ_EINVAL); 
    2494  
    2495     PJ_LOG(4,(THIS_FILE, "Sending UPDATE on call %d", call_id)); 
    2496     pj_log_push_indent(); 
    2497  
    2498     status = acquire_call("pjsua_call_update2()", call_id, &call, &dlg); 
    2499     if (status != PJ_SUCCESS) 
    2500         goto on_return; 
    25012400 
    25022401    status = apply_call_setting(call, opt, NULL); 
     
    25152414        call->local_hold = PJ_FALSE; 
    25162415    } 
    2517  
    25182416    if (status != PJ_SUCCESS) { 
    25192417        pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", 
     
    25282426    } 
    25292427 
    2530     /* Create UPDATE with new offer */ 
    2531     status = pjsip_inv_update(call->inv, new_contact, sdp, &tdata); 
    2532     if (status != PJ_SUCCESS) { 
    2533         pjsua_perror(THIS_FILE, "Unable to create UPDATE request", status); 
     2428    /* Create re-INVITE with new offer */ 
     2429    status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata); 
     2430    if (status != PJ_SUCCESS) { 
     2431        pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status); 
    25342432        goto on_return; 
    25352433    } 
     
    25412439    status = pjsip_inv_send_msg( call->inv, tdata); 
    25422440    if (status != PJ_SUCCESS) { 
    2543         pjsua_perror(THIS_FILE, "Unable to send UPDATE request", status); 
     2441        pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status); 
    25442442        goto on_return; 
    25452443    } 
     
    25532451 
    25542452/* 
     2453 * Send UPDATE request. 
     2454 */ 
     2455PJ_DEF(pj_status_t) pjsua_call_update( pjsua_call_id call_id, 
     2456                                       unsigned options, 
     2457                                       const pjsua_msg_data *msg_data) 
     2458{ 
     2459    pjsua_call *call; 
     2460    pjsip_dialog *dlg = NULL; 
     2461    pj_status_t status; 
     2462 
     2463    status = acquire_call("pjsua_call_update()", call_id, &call, &dlg); 
     2464    if (status != PJ_SUCCESS) 
     2465        goto on_return; 
     2466 
     2467    if (options != call->opt.flag) 
     2468        call->opt.flag = options; 
     2469 
     2470    status = pjsua_call_update2(call_id, NULL, msg_data); 
     2471 
     2472on_return: 
     2473    if (dlg) pjsip_dlg_dec_lock(dlg); 
     2474    return status; 
     2475} 
     2476 
     2477 
     2478/* 
     2479 * Send UPDATE request. 
     2480 */ 
     2481PJ_DEF(pj_status_t) pjsua_call_update2(pjsua_call_id call_id, 
     2482                                       const pjsua_call_setting *opt, 
     2483                                       const pjsua_msg_data *msg_data) 
     2484{ 
     2485    pjmedia_sdp_session *sdp; 
     2486    pj_str_t *new_contact = NULL; 
     2487    pjsip_tx_data *tdata; 
     2488    pjsua_call *call; 
     2489    pjsip_dialog *dlg = NULL; 
     2490    pj_status_t status; 
     2491 
     2492    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
     2493                     PJ_EINVAL); 
     2494 
     2495    PJ_LOG(4,(THIS_FILE, "Sending UPDATE on call %d", call_id)); 
     2496    pj_log_push_indent(); 
     2497 
     2498    status = acquire_call("pjsua_call_update2()", call_id, &call, &dlg); 
     2499    if (status != PJ_SUCCESS) 
     2500        goto on_return; 
     2501 
     2502    status = apply_call_setting(call, opt, NULL); 
     2503    if (status != PJ_SUCCESS) { 
     2504        pjsua_perror(THIS_FILE, "Failed to apply call setting", status); 
     2505        goto on_return; 
     2506    } 
     2507 
     2508    /* Create SDP */ 
     2509    if (call->local_hold && (call->opt.flag & PJSUA_CALL_UNHOLD)==0) { 
     2510        status = create_sdp_of_call_hold(call, &sdp); 
     2511    } else { 
     2512        status = pjsua_media_channel_create_sdp(call->index, 
     2513                                                call->inv->pool_prov, 
     2514                                                NULL, &sdp, NULL); 
     2515        call->local_hold = PJ_FALSE; 
     2516    } 
     2517 
     2518    if (status != PJ_SUCCESS) { 
     2519        pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", 
     2520                     status); 
     2521        goto on_return; 
     2522    } 
     2523 
     2524    if ((call->opt.flag & PJSUA_CALL_UPDATE_CONTACT) && 
     2525            pjsua_acc_is_valid(call->acc_id)) 
     2526    { 
     2527        new_contact = &pjsua_var.acc[call->acc_id].contact; 
     2528    } 
     2529 
     2530    /* Create UPDATE with new offer */ 
     2531    status = pjsip_inv_update(call->inv, new_contact, sdp, &tdata); 
     2532    if (status != PJ_SUCCESS) { 
     2533        pjsua_perror(THIS_FILE, "Unable to create UPDATE request", status); 
     2534        goto on_return; 
     2535    } 
     2536 
     2537    /* Add additional headers etc */ 
     2538    pjsua_process_msg_data( tdata, msg_data); 
     2539 
     2540    /* Send the request */ 
     2541    status = pjsip_inv_send_msg( call->inv, tdata); 
     2542    if (status != PJ_SUCCESS) { 
     2543        pjsua_perror(THIS_FILE, "Unable to send UPDATE request", status); 
     2544        goto on_return; 
     2545    } 
     2546 
     2547on_return: 
     2548    if (dlg) pjsip_dlg_dec_lock(dlg); 
     2549    pj_log_pop_indent(); 
     2550    return status; 
     2551} 
     2552 
     2553 
     2554/* 
    25552555 * Initiate call transfer to the specified address. 
    25562556 */ 
    2557 PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,  
     2557PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id, 
    25582558                                     const pj_str_t *dest, 
    25592559                                     const pjsua_msg_data *msg_data) 
     
    25712571    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls && 
    25722572                     dest, PJ_EINVAL); 
    2573      
     2573 
    25742574    PJ_LOG(4,(THIS_FILE, "Transferring call %d to %.*s", call_id, 
    25752575                         (int)dest->slen, dest->ptr)); 
     
    25792579    if (status != PJ_SUCCESS) 
    25802580        goto on_return; 
    2581     
     2581 
    25822582    /* Create xfer client subscription. */ 
    25832583    pj_bzero(&xfer_cb, sizeof(xfer_cb)); 
     
    26182618    } 
    26192619 
    2620     /* For simplicity (that's what this program is intended to be!),  
     2620    /* For simplicity (that's what this program is intended to be!), 
    26212621     * leave the original invite session as it is. More advanced application 
    26222622     * may want to hold the INVITE, or terminate the invite, or whatever. 
     
    26332633 * Initiate attended call transfer to the specified address. 
    26342634 */ 
    2635 PJ_DEF(pj_status_t) pjsua_call_xfer_replaces( pjsua_call_id call_id,  
     2635PJ_DEF(pj_status_t) pjsua_call_xfer_replaces( pjsua_call_id call_id, 
    26362636                                              pjsua_call_id dest_call_id, 
    26372637                                              unsigned options, 
     
    26452645    pjsip_uri *uri; 
    26462646    pj_status_t status; 
    2647      
     2647 
    26482648 
    26492649    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
    26502650                     PJ_EINVAL); 
    2651     PJ_ASSERT_RETURN(dest_call_id>=0 &&  
     2651    PJ_ASSERT_RETURN(dest_call_id>=0 && 
    26522652                      dest_call_id<(int)pjsua_var.ua_cfg.max_calls, 
    26532653                     PJ_EINVAL); 
    2654      
     2654 
    26552655    PJ_LOG(4,(THIS_FILE, "Transferring call %d replacing with call %d", 
    26562656                         call_id, dest_call_id)); 
    26572657    pj_log_push_indent(); 
    26582658 
    2659     status = acquire_call("pjsua_call_xfer_replaces()", dest_call_id,  
     2659    status = acquire_call("pjsua_call_xfer_replaces()", dest_call_id, 
    26602660                          &dest_call, &dest_dlg); 
    26612661    if (status != PJ_SUCCESS) { 
     
    26632663        return status; 
    26642664    } 
    2665          
    2666     /*  
     2665 
     2666    /* 
    26672667     * Create REFER destination URI with Replaces field. 
    26682668     */ 
     
    26722672                      dest_dlg->call_id->id.slen + 
    26732673                      dest_dlg->remote.info->tag.slen + 
    2674                       dest_dlg->local.info->tag.slen + 32  
     2674                      dest_dlg->local.info->tag.slen + 32 
    26752675                      < (long)sizeof(str_dest_buf), 
    26762676                      { status=PJSIP_EURITOOLONG; goto on_error; }); 
     
    26812681 
    26822682    uri = (pjsip_uri*) pjsip_uri_get_uri(dest_dlg->remote.info->uri); 
    2683     len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, uri,  
     2683    len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, uri, 
    26842684                          str_dest_buf+1, sizeof(str_dest_buf)-1); 
    26852685    if (len < 0) { 
     
    26922692 
    26932693    /* Build the URI */ 
    2694     len = pj_ansi_snprintf(str_dest_buf + str_dest.slen,  
     2694    len = pj_ansi_snprintf(str_dest_buf + str_dest.slen, 
    26952695                           sizeof(str_dest_buf) - str_dest.slen, 
    26962696                           "?%s" 
     
    27092709    PJ_ASSERT_ON_FAIL(len > 0 && len <= (int)sizeof(str_dest_buf)-str_dest.slen, 
    27102710                      { status=PJSIP_EURITOOLONG; goto on_error; }); 
    2711      
     2711 
    27122712    str_dest.ptr = str_dest_buf; 
    27132713    str_dest.slen += len; 
    27142714 
    27152715    pjsip_dlg_dec_lock(dest_dlg); 
    2716      
     2716 
    27172717    status = pjsua_call_xfer(call_id, &str_dest, msg_data); 
    27182718 
     
    27302730 * Send instant messaging inside INVITE session. 
    27312731 */ 
    2732 PJ_DEF(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,  
     2732PJ_DEF(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id, 
    27332733                                        const pj_str_t *mime_type, 
    27342734                                        const pj_str_t *content, 
     
    27542754    if (status != PJ_SUCCESS) 
    27552755        goto on_return; 
    2756      
     2756 
    27572757    /* Set default media type if none is specified */ 
    27582758    if (mime_type == NULL) { 
     
    27692769 
    27702770    /* Add accept header. */ 
    2771     pjsip_msg_add_hdr( tdata->msg,  
     2771    pjsip_msg_add_hdr( tdata->msg, 
    27722772                       (pjsip_hdr*)pjsua_im_create_accept(tdata->pool)); 
    27732773 
     
    27972797 
    27982798    /* Send the request. */ 
    2799     status = pjsip_dlg_send_request( call->inv->dlg, tdata,  
     2799    status = pjsip_dlg_send_request( call->inv->dlg, tdata, 
    28002800                                     pjsua_var.mod.id, im_data); 
    28012801    if (status != PJ_SUCCESS) { 
     
    28142814 * Send IM typing indication inside INVITE session. 
    28152815 */ 
    2816 PJ_DEF(pj_status_t) pjsua_call_send_typing_ind( pjsua_call_id call_id,  
     2816PJ_DEF(pj_status_t) pjsua_call_send_typing_ind( pjsua_call_id call_id, 
    28172817                                                pj_bool_t is_typing, 
    28182818                                                const pjsua_msg_data*msg_data) 
     
    30993099        pjmedia_transport_info tpinfo; 
    31003100        pjmedia_ice_transport_info *ice_info; 
    3101          
     3101 
    31023102        if (call_med->tp_st == PJSUA_MED_TP_NULL || 
    31033103            call_med->tp_st == PJSUA_MED_TP_DISABLED || 
     
    31063106            continue; 
    31073107        } 
    3108          
     3108 
    31093109        pjmedia_transport_info_init(&tpinfo); 
    31103110        pjmedia_transport_get_info(call_med->tp, &tpinfo); 
     
    31223122            break; 
    31233123        } 
    3124          
     3124 
    31253125        /* Check if ICE needs to send reinvite */ 
    31263126        if (!ice_need_reinv && 
     
    31373137        } 
    31383138    } 
    3139      
     3139 
    31403140    if (ice_complete && need_reinv) 
    31413141        *need_reinv = ice_need_reinv; 
    3142      
     3142 
    31433143    return ice_complete; 
    31443144} 
     
    31773177     * remote does not support UPDATE method. 
    31783178     */ 
    3179     if (inv->state == PJSIP_INV_STATE_EARLY &&  
     3179    if (inv->state == PJSIP_INV_STATE_EARLY && 
    31803180        pjsip_dlg_remote_has_cap(inv->dlg, PJSIP_H_ALLOW, NULL, &ST_UPDATE)!= 
    31813181        PJSIP_DIALOG_CAP_SUPPORTED) 
     
    31973197        return PJ_SUCCESS; 
    31983198 
    3199      
     3199 
    32003200    /* Okay! So we need to send re-INVITE/UPDATE */ 
    32013201 
     
    32183218                  )); 
    32193219    } 
    3220      
     3220 
    32213221    /* Generate SDP re-offer */ 
    32223222    status = pjsua_media_channel_create_sdp(call->index, pool, NULL, 
     
    32353235    if (need_lock_codec) { 
    32363236        const pjmedia_sdp_session *ref_sdp; 
    3237          
     3237 
    32383238        /* Get local active SDP as reference */ 
    32393239        status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &ref_sdp); 
    32403240        if (status != PJ_SUCCESS) 
    32413241            return status; 
    3242          
     3242 
    32433243        /* Verify media count. Note that remote may add/remove media line 
    32443244         * in the answer. When answer has less media, it must have been 
     
    32623262            pjmedia_sdp_media *m = new_offer->media[i]; 
    32633263            pjsua_call_media *call_med = &call->media[i]; 
    3264      
     3264 
    32653265            /* Verify if media is deactivated */ 
    32663266            if (call_med->state == PJSUA_CALL_MEDIA_NONE || 
     
    32703270                continue; 
    32713271            } 
    3272      
     3272 
    32733273            /* Reset formats */ 
    32743274            m->desc.fmt_count = 0; 
    32753275            pjmedia_sdp_attr_remove_all(&m->attr_count, m->attr, "rtpmap"); 
    32763276            pjmedia_sdp_attr_remove_all(&m->attr_count, m->attr, "fmtp"); 
    3277              
     3277 
    32783278            /* Copy only the first format + any non-AV formats from 
    32793279             * the active local SDP. 
     
    32843284                if (is_non_av_fmt(ref_m, fmt) || (++codec_cnt == 1)) { 
    32853285                    pjmedia_sdp_attr *a; 
    3286                      
     3286 
    32873287                    m->desc.fmt[m->desc.fmt_count++] = *fmt; 
    32883288                    a = pjmedia_sdp_attr_find2(ref_m->attr_count, ref_m->attr, 
     
    33003300    { 
    33013301        const pjmedia_sdp_session *cur_sdp; 
    3302          
     3302 
    33033303        /* Get local active SDP */ 
    33043304        status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &cur_sdp); 
     
    33563356    } 
    33573357 
    3358      
     3358 
    33593359    if (rem_can_update) { 
    33603360        status = pjsip_inv_update(inv, NULL, new_offer, &tdata); 
     
    33883388    if (need_lock_codec) 
    33893389        ++call->lock_codec.retry_cnt; 
    3390      
     3390 
    33913391    return PJ_SUCCESS; 
    33923392} 
     
    33973397 * session state has changed. 
    33983398 */ 
    3399 static void pjsua_call_on_state_changed(pjsip_inv_session *inv,  
     3399static void pjsua_call_on_state_changed(pjsip_inv_session *inv, 
    34003400                                        pjsip_event *e) 
    34013401{ 
     
    34183418            if (call->res_time.sec == 0) 
    34193419                pj_gettimeofday(&call->res_time); 
    3420             call->last_code = (pjsip_status_code)  
     3420            call->last_code = (pjsip_status_code) 
    34213421                              e->body.tsx_state.tsx->status_code; 
    3422             pj_strncpy(&call->last_text,  
     3422            pj_strncpy(&call->last_text, 
    34233423                       &e->body.tsx_state.tsx->status_text, 
    34243424                       sizeof(call->last_text_buf_)); 
     
    34393439            if (call->res_time.sec == 0) 
    34403440                pj_gettimeofday(&call->res_time); 
    3441             if (e->type == PJSIP_EVENT_TSX_STATE &&  
    3442                 e->body.tsx_state.tsx->status_code > call->last_code)  
     3441            if (e->type == PJSIP_EVENT_TSX_STATE && 
     3442                e->body.tsx_state.tsx->status_code > call->last_code) 
    34433443            { 
    3444                 call->last_code = (pjsip_status_code)  
     3444                call->last_code = (pjsip_status_code) 
    34453445                                  e->body.tsx_state.tsx->status_code; 
    3446                 pj_strncpy(&call->last_text,  
     3446                pj_strncpy(&call->last_text, 
    34473447                           &e->body.tsx_state.tsx->status_text, 
    34483448                           sizeof(call->last_text_buf_)); 
     
    34613461            break; 
    34623462        default: 
    3463             call->last_code = (pjsip_status_code)  
     3463            call->last_code = (pjsip_status_code) 
    34643464                              e->body.tsx_state.tsx->status_code; 
    3465             pj_strncpy(&call->last_text,  
     3465            pj_strncpy(&call->last_text, 
    34663466                       &e->body.tsx_state.tsx->status_text, 
    34673467                       sizeof(call->last_text_buf_)); 
     
    34753475        int st_code = -1; 
    34763476        pjsip_evsub_state ev_state = PJSIP_EVSUB_STATE_ACTIVE; 
    3477          
     3477 
    34783478 
    34793479        switch (call->inv->state) { 
     
    35543554 
    35553555        PJSUA_LOCK(); 
    3556          
     3556 
    35573557        pjsua_media_channel_deinit(call->index); 
    35583558 
     
    35773577 * has forked. 
    35783578 */ 
    3579 static void pjsua_call_on_forked( pjsip_inv_session *inv,  
     3579static void pjsua_call_on_forked( pjsip_inv_session *inv, 
    35803580                                  pjsip_event *e) 
    35813581{ 
     
    35923592pjsip_dialog* on_dlg_forked(pjsip_dialog *dlg, pjsip_rx_data *res) 
    35933593{ 
    3594     if (dlg->uac_has_2xx &&  
     3594    if (dlg->uac_has_2xx && 
    35953595        res->msg_info.cseq->method.id == PJSIP_INVITE_METHOD && 
    35963596        pjsip_rdata_get_tsx(res) == NULL && 
    3597         res->msg_info.msg->line.status.code/100 == 2)  
     3597        res->msg_info.msg->line.status.code/100 == 2) 
    35983598    { 
    35993599        pjsip_dialog *forked_dlg; 
     
    36313631 * Disconnect call upon error. 
    36323632 */ 
    3633 static void call_disconnect( pjsip_inv_session *inv,  
     3633static void call_disconnect( pjsip_inv_session *inv, 
    36343634                             int code ) 
    36353635{ 
    3636     pjsua_call *call; 
    36373636    pjsip_tx_data *tdata; 
    36383637    pj_status_t status; 
    3639  
    3640     call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id]; 
    36413638 
    36423639    status = pjsip_inv_end_session(inv, code, NULL, &tdata); 
     
    36443641        return; 
    36453642 
     3643#if DISABLED_FOR_TICKET_1185 
     3644    pjsua_call *call; 
     3645 
    36463646    /* Add SDP in 488 status */ 
    3647 #if DISABLED_FOR_TICKET_1185 
     3647    call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id]; 
     3648 
    36483649    if (call && call->tp && tdata->msg->type==PJSIP_RESPONSE_MSG && 
    3649         code==PJSIP_SC_NOT_ACCEPTABLE_HERE)  
     3650        code==PJSIP_SC_NOT_ACCEPTABLE_HERE) 
    36503651    { 
    36513652        pjmedia_sdp_session *local_sdp; 
     
    36543655        pjmedia_transport_info_init(&ti); 
    36553656        pjmedia_transport_get_info(call->med_tp, &ti); 
    3656         status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool,  
     3657        status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool, 
    36573658                                          1, &ti.sock_info, &local_sdp); 
    36583659        if (status == PJ_SUCCESS) { 
     
    36993700 
    37003701        /* Disconnect call if we're not in the middle of initializing an 
    3701          * UAS dialog and if this is not a re-INVITE  
     3702         * UAS dialog and if this is not a re-INVITE 
    37023703         */ 
    37033704        if (inv->state != PJSIP_INV_STATE_NULL && 
    3704             inv->state != PJSIP_INV_STATE_CONFIRMED)  
     3705            inv->state != PJSIP_INV_STATE_CONFIRMED) 
    37053706        { 
    37063707            call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 
     
    37143715    status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &local_sdp); 
    37153716    if (status != PJ_SUCCESS) { 
    3716         pjsua_perror(THIS_FILE,  
    3717                      "Unable to retrieve currently active local SDP",  
     3717        pjsua_perror(THIS_FILE, 
     3718                     "Unable to retrieve currently active local SDP", 
    37183719                     status); 
    37193720        //call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 
     
    37233724    status = pjmedia_sdp_neg_get_active_remote(call->inv->neg, &remote_sdp); 
    37243725    if (status != PJ_SUCCESS) { 
    3725         pjsua_perror(THIS_FILE,  
    3726                      "Unable to retrieve currently active remote SDP",  
     3726        pjsua_perror(THIS_FILE, 
     3727                     "Unable to retrieve currently active remote SDP", 
    37273728                     status); 
    37283729        //call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 
     
    37383739    status = pjsua_media_channel_update(call->index, local_sdp, remote_sdp); 
    37393740    if (status != PJ_SUCCESS) { 
    3740         pjsua_perror(THIS_FILE, "Unable to create media session",  
     3741        pjsua_perror(THIS_FILE, "Unable to create media session", 
    37413742                     status); 
    37423743        call_disconnect(inv, PJSIP_SC_NOT_ACCEPTABLE_HERE); 
     
    37683769    unsigned mi; 
    37693770 
    3770     /* Call-hold is done by set the media direction to 'sendonly'  
    3771      * (PJMEDIA_DIR_ENCODING), except when current media direction is  
     3771    /* Call-hold is done by set the media direction to 'sendonly' 
     3772     * (PJMEDIA_DIR_ENCODING), except when current media direction is 
    37723773     * 'inactive' (PJMEDIA_DIR_NONE). 
    37733774     * (See RFC 3264 Section 8.4 and RFC 4317 Section 3.1) 
    37743775     */ 
    3775     /* http://trac.pjsip.org/repos/ticket/880  
     3776    /* http://trac.pjsip.org/repos/ticket/880 
    37763777       if (call->dir != PJMEDIA_DIR_ENCODING) { 
    37773778     */ 
     
    38833884        pjsip_status_code code = PJSIP_SC_OK; 
    38843885        pjsua_call_setting opt = call->opt; 
    3885          
     3886 
    38863887        (*pjsua_var.ua_cfg.cb.on_call_rx_offer)(call->index, offer, NULL, 
    38873888                                                &code, &opt); 
     
    38953896        call->opt = opt; 
    38963897    } 
    3897      
     3898 
    38983899    /* Re-init media for the new remote offer before creating SDP */ 
    38993900    status = apply_call_setting(call, &call->opt, offer); 
     
    39013902        goto on_return; 
    39023903 
    3903     status = pjsua_media_channel_create_sdp(call->index,  
    3904                                             call->inv->pool_prov,  
     3904    status = pjsua_media_channel_create_sdp(call->index, 
     3905                                            call->inv->pool_prov, 
    39053906                                            offer, &answer, NULL); 
    39063907    if (status != PJ_SUCCESS) { 
     
    39723973    /* See if we've put call on hold. */ 
    39733974    if (call->local_hold) { 
    3974         PJ_LOG(4,(THIS_FILE,  
     3975        PJ_LOG(4,(THIS_FILE, 
    39753976                  "Call %d: call is on-hold locally, creating call-hold SDP ", 
    39763977                  call->index)); 
     
    39803981                  call->index)); 
    39813982 
    3982         status = pjsua_media_channel_create_sdp(call->index,  
    3983                                                 call->inv->pool_prov,  
     3983        status = pjsua_media_channel_create_sdp(call->index, 
     3984                                                call->inv->pool_prov, 
    39843985                                                NULL, offer, NULL); 
    39853986    } 
     
    40014002static void xfer_client_on_evsub_state( pjsip_evsub *sub, pjsip_event *event) 
    40024003{ 
    4003      
     4004 
    40044005    PJ_UNUSED_ARG(event); 
    40054006 
     
    40074008 
    40084009    /* 
    4009      * When subscription is accepted (got 200/OK to REFER), check if  
     4010     * When subscription is accepted (got 200/OK to REFER), check if 
    40104011     * subscription suppressed. 
    40114012     */ 
     
    40204021 
    40214022        /* Must be receipt of response message */ 
    4022         pj_assert(event->type == PJSIP_EVENT_TSX_STATE &&  
     4023        pj_assert(event->type == PJSIP_EVENT_TSX_STATE && 
    40234024                  event->body.tsx_state.type == PJSIP_EVENT_RX_MSG); 
    40244025        rdata = event->body.tsx_state.src.rdata; 
     
    40264027        /* Find Refer-Sub header */ 
    40274028        refer_sub = (pjsip_generic_string_hdr*) 
    4028                     pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,  
     4029                    pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, 
    40294030                                               &REFER_SUB, NULL); 
    40304031 
     
    40374038                const pj_str_t ACCEPTED = { "Accepted", 8 }; 
    40384039                pj_bool_t cont = PJ_FALSE; 
    4039                 (*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index,  
     4040                (*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index, 
    40404041                                                               200, 
    40414042                                                               &ACCEPTED, 
     
    40524053 
    40534054        } else { 
    4054             /* Notify application about call transfer progress.  
     4055            /* Notify application about call transfer progress. 
    40554056             * Initially notify with 100/Accepted status. 
    40564057             */ 
     
    40584059                const pj_str_t ACCEPTED = { "Accepted", 8 }; 
    40594060                pj_bool_t cont = PJ_FALSE; 
    4060                 (*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index,  
     4061                (*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index, 
    40614062                                                               100, 
    40624063                                                               &ACCEPTED, 
     
    40704071     */ 
    40714072    else if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_ACTIVE || 
    4072              pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED)  
     4073             pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) 
    40734074    { 
    40744075        pjsua_call *call; 
     
    40824083        call = (pjsua_call*) pjsip_evsub_get_mod_data(sub, pjsua_var.mod.id); 
    40834084 
    4084         /* When subscription is terminated, clear the xfer_sub member of  
     4085        /* When subscription is terminated, clear the xfer_sub member of 
    40854086         * the inv_data. 
    40864087         */ 
     
    41084109            body = msg->body; 
    41094110            if (!body) { 
    4110                 PJ_LOG(2,(THIS_FILE,  
     4111                PJ_LOG(2,(THIS_FILE, 
    41114112                          "Warning: received NOTIFY without message body")); 
    41124113                goto on_return; 
     
    41174118                pj_stricmp2(&body->content_type.subtype, "sipfrag") != 0) 
    41184119            { 
    4119                 PJ_LOG(2,(THIS_FILE,  
     4120                PJ_LOG(2,(THIS_FILE, 
    41204121                          "Warning: received NOTIFY with non message/sipfrag " 
    41214122                          "content")); 
     
    41244125 
    41254126            /* Try to parse the content */ 
    4126             status = pjsip_parse_status_line((char*)body->data, body->len,  
     4127            status = pjsip_parse_status_line((char*)body->data, body->len, 
    41274128                                             &status_line); 
    41284129            if (status != PJ_SUCCESS) { 
    4129                 PJ_LOG(2,(THIS_FILE,  
     4130                PJ_LOG(2,(THIS_FILE, 
    41304131                          "Warning: received NOTIFY with invalid " 
    41314132                          "message/sipfrag content")); 
     
    41414142        is_last = (pjsip_evsub_get_state(sub)==PJSIP_EVSUB_STATE_TERMINATED); 
    41424143        cont = !is_last; 
    4143         (*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index,  
     4144        (*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index, 
    41444145                                                       status_line.code, 
    41454146                                                       &status_line.reason, 
     
    41564157            pjsip_tx_data *tdata; 
    41574158 
    4158             status = pjsip_evsub_initiate(sub, &pjsip_subscribe_method,  
     4159            status = pjsip_evsub_initiate(sub, &pjsip_subscribe_method, 
    41594160                                          0, &tdata); 
    41604161            if (status == PJ_SUCCESS) 
     
    41794180 
    41804181    /* 
    4181      * When subscription is terminated, clear the xfer_sub member of  
     4182     * When subscription is terminated, clear the xfer_sub member of 
    41824183     * the inv_data. 
    41834184     */ 
     
    42544255     */ 
    42554256    ref_by_hdr = (pjsip_hdr*) 
    4256                  pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_ref_by,  
     4257                 pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_ref_by, 
    42574258                                            NULL); 
    42584259 
     
    42614262    if (pjsua_var.ua_cfg.cb.on_call_transfer_request) { 
    42624263        (*pjsua_var.ua_cfg.cb.on_call_transfer_request)(existing_call->index, 
    4263                                                         &refer_to->hvalue,  
     4264                                                        &refer_to->hvalue, 
    42644265                                                        &code); 
    42654266    } 
     
    42684269    if (pjsua_var.ua_cfg.cb.on_call_transfer_request2) { 
    42694270        (*pjsua_var.ua_cfg.cb.on_call_transfer_request2)(existing_call->index, 
    4270                                                          &refer_to->hvalue,  
     4271                                                         &refer_to->hvalue, 
    42714272                                                         &code, 
    42724273                                                         &call_opt); 
     
    42844285              (int)inv->dlg->remote.info_str.slen, 
    42854286              inv->dlg->remote.info_str.ptr, 
    4286               (int)refer_to->hvalue.slen,  
     4287              (int)refer_to->hvalue.slen, 
    42874288              refer_to->hvalue.ptr)); 
    42884289 
     
    42954296        pjsip_hdr *hdr; 
    42964297 
    4297         status = pjsip_dlg_create_response(inv->dlg, rdata, code, NULL,  
     4298        status = pjsip_dlg_create_response(inv->dlg, rdata, code, NULL, 
    42984299                                           &tdata); 
    42994300        if (status != PJ_SUCCESS) { 
     
    43044305 
    43054306        /* Add Refer-Sub header */ 
    4306         hdr = (pjsip_hdr*)  
     4307        hdr = (pjsip_hdr*) 
    43074308               pjsip_generic_string_hdr_create(tdata->pool, &str_refer_sub, 
    43084309                                              &str_false); 
     
    43484349            pjsip_hdr *hdr; 
    43494350 
    4350             hdr = (pjsip_hdr*)  
    4351                    pjsip_generic_string_hdr_create(inv->dlg->pool,  
     4351            hdr = (pjsip_hdr*) 
     4352                   pjsip_generic_string_hdr_create(inv->dlg->pool, 
    43524353                                                   &str_refer_sub, 
    43534354                                                   &str_true); 
     
    43634364                                    100, NULL, &tdata); 
    43644365        if (status != PJ_SUCCESS) { 
    4365             pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER",  
     4366            pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", 
    43664367                         status); 
    43674368            goto on_return; 
     
    43794380     * We need to get a null terminated string from a pj_str_t. 
    43804381     * So grab the pointer from the hvalue and NULL terminate it, knowing 
    4381      * that the NULL position will be occupied by a newline.  
     4382     * that the NULL position will be occupied by a newline. 
    43824383     */ 
    43834384    uri = refer_to->hvalue.ptr; 
     
    43994400    tmp = pj_str(uri); 
    44004401    status = pjsua_call_make_call(existing_call->acc_id, &tmp, &call_opt, 
    4401                                   existing_call->user_data, &msg_data,  
     4402                                  existing_call->user_data, &msg_data, 
    44024403                                  &new_call); 
    44034404    if (status != PJ_SUCCESS) { 
     
    44084409                                       500, NULL, &tdata); 
    44094410            if (status != PJ_SUCCESS) { 
    4410                 pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER",  
     4411                pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", 
    44114412                              status); 
    44124413                goto on_return; 
     
    44144415            status = pjsip_xfer_send_request(sub, tdata); 
    44154416            if (status != PJ_SUCCESS) { 
    4416                 pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER",  
     4417                pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER", 
    44174418                              status); 
    44184419                goto on_return; 
     
    44304431 
    44314432        /* Put the invite_data in the subscription. */ 
    4432         pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id,  
     4433        pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id, 
    44334434                                 &pjsua_var.calls[new_call]); 
    44344435    } 
     
    45124513            pj_list_push_back(&hdr_list, accept_hdr); 
    45134514 
    4514             pjsip_dlg_respond( inv->dlg, rdata, PJSIP_SC_NOT_ACCEPTABLE_HERE,  
     4515            pjsip_dlg_respond( inv->dlg, rdata, PJSIP_SC_NOT_ACCEPTABLE_HERE, 
    45154516                               NULL, &hdr_list, NULL ); 
    45164517            goto on_return; 
     
    45184519 
    45194520        /* Respond with 200 first, so that remote doesn't retransmit in case 
    4520          * the UI takes too long to process the message.  
     4521         * the UI takes too long to process the message. 
    45214522         */ 
    45224523        pjsip_dlg_respond( inv->dlg, rdata, 200, NULL, NULL, NULL); 
     
    46264627 
    46274628    if (pjsua_var.ua_cfg.cb.on_call_redirected) { 
    4628         op = (*pjsua_var.ua_cfg.cb.on_call_redirected)(call->index,  
     4629        op = (*pjsua_var.ua_cfg.cb.on_call_redirected)(call->index, 
    46294630                                                         target, e); 
    46304631    } else { 
Note: See TracChangeset for help on using the changeset viewer.