Changeset 5721


Ignore:
Timestamp:
Jan 8, 2018 4:08:35 AM (7 years ago)
Author:
nanang
Message:

Close #2080: Added call flag PJSUA_CALL_UPDATE_TARGET for updating remote target, the new remote target can be specified in pjsua_msg_data.target_uri.

Location:
pjproject/trunk
Files:
3 edited

Legend:

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

    r5677 r5721  
    172172typedef 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; 
    173173 
    174 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_UPDATE_VIA = 32} pjsua_call_flag; 
     174typedef 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_UPDATE_TARGET = 64} pjsua_call_flag; 
    175175 
    176176typedef 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

    r5717 r5721  
    19851985    /** 
    19861986     * Optional remote target URI (i.e. Target header). If NULL, the target 
    1987      * will be set to the remote URI (To header). At the moment this field 
    1988      * is only used by #pjsua_call_make_call() and #pjsua_im_send(). 
     1987     * will be set to the remote URI (To header). This field is used by 
     1988     * pjsua_call_make_call(), pjsua_im_send(), pjsua_call_reinvite(), 
     1989     * pjsua_call_set_hold(), and pjsua_call_update(). 
    19891990     */ 
    19901991    pj_str_t    target_uri; 
     
    46404641     * been updated (typically with re-registration). 
    46414642     */ 
    4642     PJSUA_CALL_UPDATE_VIA = 32 
     4643    PJSUA_CALL_UPDATE_VIA = 32, 
     4644 
     4645    /** 
     4646     * Update dialog target to URI specified in pjsua_msg_data.target_uri. 
     4647     * This flag is only valid for pjsua_call_set_hold(), 
     4648     * pjsua_call_reinvite(), and pjsua_call_update(). This flag can be 
     4649     * useful in IP address change scenario where IP version has been changed 
     4650     * and application needs to update target IP address. 
     4651     */ 
     4652    PJSUA_CALL_UPDATE_TARGET = 64 
    46434653 
    46444654} pjsua_call_flag; 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r5710 r5721  
    664664    } 
    665665} 
     666 
     667 
     668static pj_status_t dlg_set_target(pjsip_dialog *dlg, const pj_str_t *target) 
     669{ 
     670    pjsip_uri *target_uri; 
     671    pj_str_t tmp; 
     672    pj_status_t status; 
     673 
     674    /* Parse target & verify */ 
     675    pj_strdup_with_null(dlg->pool, &tmp, target); 
     676    target_uri = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen, 0); 
     677    if (!target_uri) { 
     678        return PJSIP_EINVALIDURI; 
     679    } 
     680    if (!PJSIP_URI_SCHEME_IS_SIP(target_uri) && 
     681        !PJSIP_URI_SCHEME_IS_SIPS(target_uri)) 
     682    { 
     683        return PJSIP_EINVALIDSCHEME; 
     684    } 
     685 
     686    /* Add the new target */ 
     687    status = pjsip_target_set_add_uri(&dlg->target_set, dlg->pool, 
     688                                      target_uri, 0); 
     689    if (status != PJ_SUCCESS) 
     690        return status; 
     691 
     692    /* Set it as current target */ 
     693    status = pjsip_target_set_set_current(&dlg->target_set, 
     694                            pjsip_target_set_get_next(&dlg->target_set)); 
     695    if (status != PJ_SUCCESS) 
     696        return status; 
     697 
     698    /* Update dialog target URI */ 
     699    dlg->target = target_uri; 
     700 
     701    return PJ_SUCCESS; 
     702} 
     703 
     704 
     705/* Get account contact for call and update dialog transport */ 
     706void call_update_contact(pjsua_call *call, pj_str_t **new_contact) 
     707{ 
     708    pjsip_tpselector tp_sel; 
     709    pjsua_acc *acc = &pjsua_var.acc[call->acc_id]; 
     710 
     711    if (acc->cfg.force_contact.slen) 
     712        *new_contact = &acc->cfg.force_contact; 
     713    else if (acc->contact.slen) 
     714        *new_contact = &acc->contact; 
     715 
     716    /* When contact is changed, the account transport may have been 
     717     * changed too, so let's update the dialog's transport too. 
     718     */ 
     719    pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 
     720    pjsip_dlg_set_transport(call->inv->dlg, &tp_sel); 
     721} 
     722 
     723 
    666724 
    667725/* 
     
    25122570        pjsua_acc_is_valid(call->acc_id)) 
    25132571    { 
    2514         new_contact = &pjsua_var.acc[call->acc_id].contact; 
     2572        call_update_contact(call, &new_contact); 
    25152573    } 
    25162574 
     
    25192577    { 
    25202578        dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 
     2579    } 
     2580 
     2581    if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) && 
     2582        msg_data && msg_data->target_uri.slen) 
     2583    { 
     2584        status = dlg_set_target(dlg, &msg_data->target_uri); 
     2585        if (status != PJ_SUCCESS) { 
     2586            pjsua_perror(THIS_FILE, "Unable to set new target", status); 
     2587            goto on_return; 
     2588        } 
    25212589    } 
    25222590 
     
    26392707            pjsua_acc_is_valid(call->acc_id)) 
    26402708    { 
    2641         new_contact = &pjsua_var.acc[call->acc_id].contact; 
     2709        call_update_contact(call, &new_contact); 
    26422710    } 
    26432711 
     
    26462714    { 
    26472715        dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 
     2716    } 
     2717 
     2718    if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) && 
     2719        msg_data && msg_data->target_uri.slen) 
     2720    { 
     2721        status = dlg_set_target(dlg, &msg_data->target_uri); 
     2722        if (status != PJ_SUCCESS) { 
     2723            pjsua_perror(THIS_FILE, "Unable to set new target", status); 
     2724            goto on_return; 
     2725        } 
    26482726    } 
    26492727 
     
    27572835            pjsua_acc_is_valid(call->acc_id)) 
    27582836    { 
    2759         new_contact = &pjsua_var.acc[call->acc_id].contact; 
     2837        call_update_contact(call, &new_contact); 
    27602838    } 
    27612839 
     
    27642842    { 
    27652843        dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]); 
     2844    } 
     2845 
     2846    if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) && 
     2847        msg_data && msg_data->target_uri.slen) 
     2848    { 
     2849        status = dlg_set_target(dlg, &msg_data->target_uri); 
     2850        if (status != PJ_SUCCESS) { 
     2851            pjsua_perror(THIS_FILE, "Unable to set new target", status); 
     2852            goto on_return; 
     2853        } 
    27662854    } 
    27672855 
Note: See TracChangeset for help on using the changeset viewer.