diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-04-02 11:22:49 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-04-02 11:22:49 +0000 |
commit | e452e50a2e87683f5a28e08263aeda9fbc567817 (patch) | |
tree | cedc96a6e81e0594805f8e856f70dae10b2844b9 | |
parent | c9af503006232e2232e3173d1ec4f62b80cc213e (diff) |
Added PJSUA API to create request using account config
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/pjproject-0.5-stable@1122 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjsip-apps/src/pjsua/pjsua_app.c | 11 | ||||
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 19 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_acc.c | 39 |
3 files changed, 59 insertions, 10 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c index 50efe7fb..8b93f8ca 100644 --- a/pjsip-apps/src/pjsua/pjsua_app.c +++ b/pjsip-apps/src/pjsua/pjsua_app.c @@ -2081,7 +2081,6 @@ static void send_request(char *cstr_method, const pj_str_t *dst_uri) pj_str_t str_method; pjsip_method method; pjsip_tx_data *tdata; - pjsua_acc_info acc_info; pjsip_endpoint *endpt; pj_status_t status; @@ -2090,15 +2089,7 @@ static void send_request(char *cstr_method, const pj_str_t *dst_uri) str_method = pj_str(cstr_method); pjsip_method_init_np(&method, &str_method); - pjsua_acc_get_info(current_acc, &acc_info); - - status = pjsip_endpt_create_request(endpt, &method, dst_uri, - &acc_info.acc_uri, dst_uri, - NULL, NULL, -1, NULL, &tdata); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to create request", status); - return; - } + status = pjsua_acc_create_request(current_acc, &method, dst_uri, &tdata); status = pjsip_endpt_send_request(endpt, tdata, -1, NULL, NULL); if (status != PJ_SUCCESS) { diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 55cf6264..562a1954 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -2288,6 +2288,25 @@ PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); /** + * Create arbitrary requests using the account. Application should only use + * this function to create auxiliary requests outside dialog, such as + * OPTIONS, and use the call or presence API to create dialog related + * requests. + * + * @param acc_id The account ID. + * @param method The SIP method of the request. + * @param target Target URI. + * @param p_tdata Pointer to receive the request. + * + * @return PJ_SUCCESS or the error code. + */ +PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id, + const pjsip_method *method, + const pj_str_t *target, + pjsip_tx_data **p_tdata); + + +/** * Create a suitable URI to be put as Contact based on the specified * target URI for the specified account. * diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index 3e39b15f..b2b63740 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -925,6 +925,45 @@ PJ_DEF(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata) } +/* + * Create arbitrary requests for this account. + */ +PJ_DEF(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id, + const pjsip_method *method, + const pj_str_t *target, + pjsip_tx_data **p_tdata) +{ + pjsip_tx_data *tdata; + pjsua_acc *acc; + pjsip_route_hdr *r; + pj_status_t status; + + PJ_ASSERT_RETURN(method && target && p_tdata, PJ_EINVAL); + PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); + + acc = &pjsua_var.acc[acc_id]; + + status = pjsip_endpt_create_request(pjsua_var.endpt, method, target, + &acc->cfg.id, target, + NULL, NULL, -1, NULL, &tdata); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to create request", status); + return status; + } + + /* Copy routeset */ + r = acc->route_set.next; + while (r != &acc->route_set) { + pjsip_msg_add_hdr(tdata->msg, pjsip_hdr_clone(tdata->pool, r)); + r = r->next; + } + + /* Done */ + *p_tdata = tdata; + return PJ_SUCCESS; +} + + PJ_DEF(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, pj_str_t *contact, pjsua_acc_id acc_id, |