Changeset 5493 for pjproject


Ignore:
Timestamp:
Dec 6, 2016 11:23:39 AM (8 years ago)
Author:
ming
Message:

Fixed #1983: Add option to update call Via address

Location:
pjproject/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/swig/symbols.i

    r5491 r5493  
    164164typedef enum pjsua_vid_req_keyframe_method {PJSUA_VID_REQ_KEYFRAME_SIP_INFO = 1, PJSUA_VID_REQ_KEYFRAME_RTCP_PLI = 2} pjsua_vid_req_keyframe_method; 
    165165 
    166 typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4, PJSUA_CALL_NO_SDP_OFFER = 8, PJSUA_CALL_REINIT_MEDIA = 16} pjsua_call_flag; 
     166typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4, PJSUA_CALL_NO_SDP_OFFER = 8, PJSUA_CALL_REINIT_MEDIA = 16, PJSUA_CALL_UPDATE_VIA = 32} pjsua_call_flag; 
    167167 
    168168typedef enum pjsua_create_media_transport_flag {PJSUA_MED_TP_CLOSE_MEMBER = 1} pjsua_create_media_transport_flag; 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r5490 r5493  
    42984298     * reverted. 
    42994299     */ 
    4300     PJSUA_CALL_REINIT_MEDIA = 16 
     4300    PJSUA_CALL_REINIT_MEDIA = 16, 
     4301     
     4302    /** 
     4303     * Update the local invite session's Via with the via address from 
     4304     * the account. This flag is only valid for #pjsua_call_set_hold2(), 
     4305     * #pjsua_call_reinvite() and #pjsua_call_update(). Similar to 
     4306     * the flag PJSUA_CALL_UPDATE_CONTACT above, this flag is useful 
     4307     * in IP address change situation, after the local account's Via has 
     4308     * been updated (typically with re-registration). 
     4309     */ 
     4310    PJSUA_CALL_UPDATE_VIA = 32 
    43014311 
    43024312} pjsua_call_flag; 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r5492 r5493  
    570570{ 
    571571    opt->flag &= ~(PJSUA_CALL_UNHOLD | PJSUA_CALL_UPDATE_CONTACT | 
    572                    PJSUA_CALL_NO_SDP_OFFER | PJSUA_CALL_REINIT_MEDIA); 
     572                   PJSUA_CALL_NO_SDP_OFFER | PJSUA_CALL_REINIT_MEDIA | 
     573                   PJSUA_CALL_UPDATE_VIA); 
    573574} 
    574575 
     
    637638 
    638639    return PJ_SUCCESS; 
     640} 
     641 
     642static void dlg_set_via(pjsip_dialog *dlg, pjsua_acc *acc) 
     643{ 
     644    if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 
     645        pjsip_dlg_set_via_sent_by(dlg, &acc->via_addr, acc->via_tp); 
     646    } else if (!pjsua_sip_acc_is_using_stun(acc->index)) { 
     647        /* Choose local interface to use in Via if acc is not using 
     648         * STUN. See https://trac.pjsip.org/repos/ticket/1804 
     649         */ 
     650        pjsip_host_port via_addr; 
     651        const void *via_tp; 
     652 
     653        if (pjsua_acc_get_uac_addr(acc->index, dlg->pool, &acc->cfg.id, 
     654                                   &via_addr, NULL, NULL, 
     655                                   &via_tp) == PJ_SUCCESS) 
     656        { 
     657            pjsip_dlg_set_via_sent_by(dlg, &via_addr, 
     658                                      (pjsip_transport*)via_tp); 
     659        } 
     660    } 
    639661} 
    640662 
     
    778800    pjsip_dlg_inc_lock(dlg); 
    779801 
    780     if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 
    781         pjsip_dlg_set_via_sent_by(dlg, &acc->via_addr, acc->via_tp); 
    782     } else if (!pjsua_sip_acc_is_using_stun(acc_id)) { 
    783         /* Choose local interface to use in Via if acc is not using 
    784          * STUN. See https://trac.pjsip.org/repos/ticket/1804 
    785          */ 
    786         pjsip_host_port via_addr; 
    787         const void *via_tp; 
    788  
    789         if (pjsua_acc_get_uac_addr(acc_id, dlg->pool, &acc->cfg.id, 
    790                                    &via_addr, NULL, NULL, 
    791                                    &via_tp) == PJ_SUCCESS) 
    792         { 
    793             pjsip_dlg_set_via_sent_by(dlg, &via_addr, 
    794                                       (pjsip_transport*)via_tp); 
    795         } 
    796     } 
     802    dlg_set_via(dlg, acc); 
    797803 
    798804    /* Calculate call's secure level */ 
     
    25002506    } 
    25012507 
     2508    if ((options & PJSUA_CALL_UPDATE_VIA) && 
     2509        pjsua_acc_is_valid(call->acc_id)) 
     2510    { 
     2511        dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 
     2512    } 
     2513 
    25022514    /* Create re-INVITE with new offer */ 
    25032515    status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata); 
     
    26212633    } 
    26222634 
     2635    if ((call->opt.flag & PJSUA_CALL_UPDATE_VIA) && 
     2636        pjsua_acc_is_valid(call->acc_id)) 
     2637    { 
     2638        dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 
     2639    } 
     2640 
    26232641    /* Create re-INVITE with new offer */ 
    26242642    status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata); 
     
    27282746    { 
    27292747        new_contact = &pjsua_var.acc[call->acc_id].contact; 
     2748    } 
     2749 
     2750    if ((call->opt.flag & PJSUA_CALL_UPDATE_VIA) && 
     2751        pjsua_acc_is_valid(call->acc_id)) 
     2752    { 
     2753        dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 
    27302754    } 
    27312755 
Note: See TracChangeset for help on using the changeset viewer.