diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-04-15 10:37:19 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-04-15 10:37:19 +0000 |
commit | 8c50bcffcb9c15bd1575f88296534048b540ce7c (patch) | |
tree | e9885fffb590909c7b8c77c9b25993691b2918a8 /pjsip | |
parent | e91435553f8ef0d86f5ac01c298071dd3ea28bb2 (diff) |
Use the smart Contact header for TCP/TLS
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1931 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_acc.c | 6 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 44 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_pres.c | 36 |
3 files changed, 58 insertions, 28 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index 77d8d2b3..ec226521 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -571,6 +571,7 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc, if (acc->regc != NULL) { pjsip_regc_destroy(acc->regc); acc->regc = NULL; + acc->contact.slen = 0; } /* Update account's Contact header */ @@ -859,6 +860,7 @@ static void regc_cb(struct pjsip_regc_cbparam *param) param->status); pjsip_regc_destroy(acc->regc); acc->regc = NULL; + acc->contact.slen = 0; /* Stop keep-alive timer if any. */ update_keep_alive(acc, PJ_FALSE, NULL); @@ -869,6 +871,7 @@ static void regc_cb(struct pjsip_regc_cbparam *param) (int)param->reason.slen, param->reason.ptr)); pjsip_regc_destroy(acc->regc); acc->regc = NULL; + acc->contact.slen = 0; /* Stop keep-alive timer if any. */ update_keep_alive(acc, PJ_FALSE, NULL); @@ -878,6 +881,7 @@ static void regc_cb(struct pjsip_regc_cbparam *param) if (param->expiration < 1) { pjsip_regc_destroy(acc->regc); acc->regc = NULL; + acc->contact.slen = 0; /* Stop keep-alive timer if any. */ update_keep_alive(acc, PJ_FALSE, NULL); @@ -946,6 +950,7 @@ static pj_status_t pjsua_regc_init(int acc_id) if (acc->regc) { pjsip_regc_destroy(acc->regc); acc->regc = NULL; + acc->contact.slen = 0; } /* initialize SIP registration if registrar is configured */ @@ -992,6 +997,7 @@ static pj_status_t pjsua_regc_init(int acc_id) pjsip_regc_destroy(acc->regc); pj_pool_release(pool); acc->regc = NULL; + acc->contact.slen = 0; return status; } diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index cfbe30b3..6183a1d1 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -405,13 +405,20 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id, /* Reset first response time */ call->res_time.sec = 0; - /* Create suitable Contact header */ - status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact, - acc_id, dest_uri); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); - PJSUA_UNLOCK(); - return status; + /* Create suitable Contact header unless a Contact header has been + * set in the account. + */ + if (acc->contact.slen) { + contact = acc->contact; + } else { + status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact, + acc_id, dest_uri); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to generate Contact header", + status); + PJSUA_UNLOCK(); + return status; + } } /* Create outgoing dialog: */ @@ -787,15 +794,20 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) /* Get suitable Contact header */ - status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact, - acc_id, rdata); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); - pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, - NULL, NULL); - pjsua_media_channel_deinit(call->index); - PJSUA_UNLOCK(); - return PJ_TRUE; + if (pjsua_var.acc[acc_id].contact.slen) { + contact = pjsua_var.acc[acc_id].contact; + } else { + status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact, + acc_id, rdata); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to generate Contact header", + status); + pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, + NULL, NULL); + pjsua_media_channel_deinit(call->index); + PJSUA_UNLOCK(); + return PJ_TRUE; + } } /* Create dialog: */ diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c index d41e1ddc..7a6d928c 100644 --- a/pjsip/src/pjsua-lib/pjsua_pres.c +++ b/pjsip/src/pjsua-lib/pjsua_pres.c @@ -552,12 +552,17 @@ static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata) acc_id)); /* Create suitable Contact header */ - status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact, - acc_id, rdata); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); - PJSUA_UNLOCK(); - return PJ_TRUE; + if (acc->contact.slen) { + contact = acc->contact; + } else { + status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact, + acc_id, rdata); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to generate Contact header", + status); + PJSUA_UNLOCK(); + return PJ_TRUE; + } } /* Create UAS dialog: */ @@ -1123,12 +1128,19 @@ static void subscribe_buddy_presence(unsigned index) PJ_LOG(4,(THIS_FILE, "Using account %d for buddy %d subscription", acc_id, index)); - /* Generate suitable Contact header */ - status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact, - acc_id, &buddy->uri); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); - return; + /* Generate suitable Contact header unless one is already set in + * the account + */ + if (acc->contact.slen) { + contact = acc->contact; + } else { + status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact, + acc_id, &buddy->uri); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to generate Contact header", + status); + return; + } } /* Create UAC dialog */ |