Changeset 4229


Ignore:
Timestamp:
Aug 13, 2012 9:15:39 AM (12 years ago)
Author:
bennylp
Message:

More #1412: also handle the case for presence subscription, publish, and mwi when the account does not have registration

Location:
pjproject/trunk/pjsip/src/pjsua-lib
Files:
2 edited

Legend:

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

    r4218 r4229  
    486486        if (pjsua_var.acc[id].cfg.mwi_enabled) 
    487487            pjsua_start_mwi(id, PJ_TRUE); 
     488 
     489        /* Start publish too */ 
     490        if (acc->cfg.publish_enabled) 
     491            pjsua_pres_init_publish_acc(id); 
    488492    } 
    489493 
     
    27042708        tdata->via_addr = pjsua_var.acc[acc_id].via_addr; 
    27052709        tdata->via_tp = pjsua_var.acc[acc_id].via_tp; 
     2710    } else if (!pjsua_sip_acc_is_using_stun(acc_id)) { 
     2711        /* Choose local interface to use in Via if acc is not using 
     2712         * STUN 
     2713         */ 
     2714        pjsua_acc_get_uac_addr(acc_id, tdata->pool, 
     2715                               target, 
     2716                               &tdata->via_addr, 
     2717                               NULL, NULL, 
     2718                               &tdata->via_tp); 
    27062719    } 
    27072720 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c

    r4186 r4229  
    865865    } 
    866866 
    867     if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) 
     867    if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 
    868868        pjsip_dlg_set_via_sent_by(dlg, &acc->via_addr, acc->via_tp); 
     869    } else if (!pjsua_sip_acc_is_using_stun(acc_id)) { 
     870        /* Choose local interface to use in Via if acc is not using 
     871         * STUN. See https://trac.pjsip.org/repos/ticket/1412 
     872         */ 
     873        char target_buf[PJSIP_MAX_URL_SIZE]; 
     874        pj_str_t target; 
     875        pjsip_host_port via_addr; 
     876        const void *via_tp; 
     877 
     878        target.ptr = target_buf; 
     879        target.slen = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, 
     880                                      dlg->target, 
     881                                      target_buf, sizeof(target_buf)); 
     882        if (target.slen < 0) target.slen = 0; 
     883 
     884        if (pjsua_acc_get_uac_addr(acc_id, dlg->pool, &target, 
     885                                   &via_addr, NULL, NULL, 
     886                                   &via_tp) == PJ_SUCCESS) 
     887        { 
     888            pjsip_dlg_set_via_sent_by(dlg, &via_addr, (void*)via_tp); 
     889        } 
     890    } 
    869891 
    870892    /* Set credentials and preference. */ 
     
    12371259        pjsip_publishc_set_via_sent_by(acc->publish_sess, &acc->via_addr, 
    12381260                                       acc->via_tp); 
     1261    } else if (!pjsua_sip_acc_is_using_stun(acc_id)) { 
     1262        /* Choose local interface to use in Via if acc is not using 
     1263         * STUN. See https://trac.pjsip.org/repos/ticket/1412 
     1264         */ 
     1265        pjsip_host_port via_addr; 
     1266        const void *via_tp; 
     1267 
     1268        if (pjsua_acc_get_uac_addr(acc_id, acc->pool, &acc_cfg->id, 
     1269                                   &via_addr, NULL, NULL, 
     1270                                   &via_tp) == PJ_SUCCESS) 
     1271        { 
     1272            pjsip_publishc_set_via_sent_by(acc->publish_sess, &via_addr, 
     1273                                           (void*)via_tp); 
     1274        } 
    12391275    } 
    12401276 
     
    17901826    pjsip_dlg_inc_lock(buddy->dlg); 
    17911827 
    1792     if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) 
     1828    if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 
    17931829        pjsip_dlg_set_via_sent_by(buddy->dlg, &acc->via_addr, acc->via_tp); 
     1830    } else if (!pjsua_sip_acc_is_using_stun(acc_id)) { 
     1831        /* Choose local interface to use in Via if acc is not using 
     1832         * STUN. See https://trac.pjsip.org/repos/ticket/1412 
     1833         */ 
     1834        pjsip_host_port via_addr; 
     1835        const void *via_tp; 
     1836 
     1837        if (pjsua_acc_get_uac_addr(acc_id, buddy->dlg->pool, &buddy->uri, 
     1838                                   &via_addr, NULL, NULL, 
     1839                                   &via_tp) == PJ_SUCCESS) 
     1840        { 
     1841            pjsip_dlg_set_via_sent_by(buddy->dlg, &via_addr, (void*)via_tp); 
     1842        } 
     1843    } 
     1844 
    17941845 
    17951846    status = pjsip_pres_create_uac( buddy->dlg, &pres_callback,  
     
    21152166    pjsip_dlg_inc_lock(acc->mwi_dlg); 
    21162167 
    2117     if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) 
     2168    if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 
    21182169        pjsip_dlg_set_via_sent_by(acc->mwi_dlg, &acc->via_addr, acc->via_tp); 
     2170    } else if (!pjsua_sip_acc_is_using_stun(acc_id)) { 
     2171        /* Choose local interface to use in Via if acc is not using 
     2172         * STUN. See https://trac.pjsip.org/repos/ticket/1412 
     2173         */ 
     2174        pjsip_host_port via_addr; 
     2175        const void *via_tp; 
     2176 
     2177        if (pjsua_acc_get_uac_addr(acc_id, acc->mwi_dlg->pool, &acc->cfg.id, 
     2178                                   &via_addr, NULL, NULL, 
     2179                                   &via_tp) == PJ_SUCCESS) 
     2180        { 
     2181            pjsip_dlg_set_via_sent_by(acc->mwi_dlg, &via_addr, 
     2182                                      (void*)via_tp); 
     2183        } 
     2184    } 
    21192185 
    21202186    /* Create UAC subscription */ 
Note: See TracChangeset for help on using the changeset viewer.