summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2013-07-10 04:27:05 +0000
committerLiong Sauw Ming <ming@teluu.com>2013-07-10 04:27:05 +0000
commit749bed5a7d59953dcce70a211942a239f5199525 (patch)
tree75b38ce0610b7086d800f253fd2e5cf0a5ebbdb4
parentfc938ab05ef6ea7e2c81c5d1e72a75eb89b03b13 (diff)
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
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h7
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c5
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_im.c4
4 files changed, 16 insertions, 2 deletions
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
@@ -1685,6 +1685,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
* or from temporary local variable, and add the header using
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) {