From 749bed5a7d59953dcce70a211942a239f5199525 Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Wed, 10 Jul 2013 04:27:05 +0000 Subject: Closed #1688: Add support for different To and Target URI in outgoing call and sending IM git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4555 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua.h | 7 +++++++ pjsip/src/pjsua-lib/pjsua_call.c | 5 ++++- pjsip/src/pjsua-lib/pjsua_core.c | 2 ++ pjsip/src/pjsua-lib/pjsua_im.c | 4 +++- 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'pjsip') diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index ef408764..e6698b72 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -1684,6 +1684,13 @@ PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool, */ struct pjsua_msg_data { + /** + * Optional remote target URI (i.e. Target header). If NULL, the target + * will be set to the remote URI (To header). At the moment this field + * is only used by #pjsua_call_make_call() and #pjsua_im_send(). + */ + pj_str_t target_uri; + /** * Additional message headers as linked list. Application can add * headers to the list by creating the header, either from the heap/pool diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index d91ec0ab..ada805f6 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -722,7 +722,10 @@ PJ_DEF(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id, /* Create outgoing dialog: */ status = pjsip_dlg_create_uac( pjsip_ua_instance(), &acc->cfg.id, &contact, - dest_uri, dest_uri, &dlg); + dest_uri, + (msg_data->target_uri.slen? + &msg_data->target_uri: dest_uri), + &dlg); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Dialog creation failed", status); goto on_error; diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index 348c9d51..d170b664 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -162,6 +162,8 @@ PJ_DEF(pjsua_msg_data*) pjsua_msg_data_clone(pj_pool_t *pool, msg_data = PJ_POOL_ZALLOC_T(pool, pjsua_msg_data); PJ_ASSERT_RETURN(msg_data != NULL, NULL); + pj_strdup(pool, &msg_data->target_uri, &rhs->target_uri); + pj_list_init(&msg_data->hdr_list); hdr = rhs->hdr_list.next; while (hdr != &rhs->hdr_list) { diff --git a/pjsip/src/pjsua-lib/pjsua_im.c b/pjsip/src/pjsua-lib/pjsua_im.c index fa2e8142..e271efff 100644 --- a/pjsip/src/pjsua-lib/pjsua_im.c +++ b/pjsip/src/pjsua-lib/pjsua_im.c @@ -524,7 +524,9 @@ PJ_DEF(pj_status_t) pjsua_im_send( pjsua_acc_id acc_id, /* Create request. */ status = pjsip_endpt_create_request(pjsua_var.endpt, - &pjsip_message_method, to, + &pjsip_message_method, + (msg_data->target_uri.slen? + &msg_data->target_uri: to), &acc->cfg.id, to, NULL, NULL, -1, NULL, &tdata); if (status != PJ_SUCCESS) { -- cgit v1.2.3