summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-22 12:48:18 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-22 12:48:18 +0000
commit8f0078e1663ab2d5d6b25a0d5745f5c14ed9ab18 (patch)
treebf730c7a2d1e80bcb1c86adef32a4b49ad1d0109
parent720911bf3037d52a6ba0298e540f5ab196e14bc7 (diff)
In pjsua, outgoing REFER now always put Refer-Sub: false
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@733 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/src/pj/config.c2
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c14
-rw-r--r--pjsip/docs/PJSUA-TESTING.txt5
-rw-r--r--pjsip/src/pjsip-simple/evsub.c3
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c64
-rw-r--r--pjsip/src/test-pjsip/test.h6
6 files changed, 73 insertions, 21 deletions
diff --git a/pjlib/src/pj/config.c b/pjlib/src/pj/config.c
index 9e74d723..882f579f 100644
--- a/pjlib/src/pj/config.c
+++ b/pjlib/src/pj/config.c
@@ -21,7 +21,7 @@
#include <pj/ioqueue.h>
static const char *id = "config.c";
-const char *PJ_VERSION = "0.5.7.7";
+const char *PJ_VERSION = "0.5.7.8";
PJ_DEF(void) pj_dump_config(void)
{
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 0a495b03..be4cc418 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -2104,6 +2104,10 @@ void console_app_main(const pj_str_t *uri_to_call)
} else {
int call = current_call;
+ pjsua_msg_data msg_data;
+ pjsip_generic_string_hdr refer_sub;
+ pj_str_t STR_REFER_SUB = { "Refer-Sub", 9 };
+ pj_str_t STR_FALSE = { "false", 5 };
ui_input_url("Transfer to URL", buf, sizeof(buf), &result);
@@ -2114,19 +2118,25 @@ void console_app_main(const pj_str_t *uri_to_call)
continue;
}
+ /* Add Refer-Sub: false in outgoing REFER request */
+ pjsua_msg_data_init(&msg_data);
+ pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB,
+ &STR_FALSE);
+ pj_list_push_back(&msg_data.hdr_list, &refer_sub);
+
if (result.nb_result != NO_NB) {
if (result.nb_result == -1 || result.nb_result == 0)
puts("You can't do that with transfer call!");
else {
pjsua_buddy_info binfo;
pjsua_buddy_get_info(result.nb_result-1, &binfo);
- pjsua_call_xfer( current_call, &binfo.uri, NULL);
+ pjsua_call_xfer( current_call, &binfo.uri, &msg_data);
}
} else if (result.uri_result) {
pj_str_t tmp;
tmp = pj_str(result.uri_result);
- pjsua_call_xfer( current_call, &tmp, NULL);
+ pjsua_call_xfer( current_call, &tmp, &msg_data);
}
}
break;
diff --git a/pjsip/docs/PJSUA-TESTING.txt b/pjsip/docs/PJSUA-TESTING.txt
index 72fb797e..fabefb36 100644
--- a/pjsip/docs/PJSUA-TESTING.txt
+++ b/pjsip/docs/PJSUA-TESTING.txt
@@ -16,6 +16,11 @@ BASIC FLOW TEST (compaq1.cfg, compaq2.cfg);
- hold and being held
- DTMF send/receive
- IM and typing
+- Call transfer (with and without norefersub)
+- Call Hold
+- Re-Invite
+- DTMF
+- RTCP
- TCP (if there's UDP route, then Contact will be UDP)
- Repeat basic flow test without Route set (to wheter TCP is correctly specified in the contact etc)
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index a69409de..632384cd 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -879,11 +879,14 @@ PJ_DEF(pj_status_t) pjsip_evsub_terminate( pjsip_evsub *sub,
pjsip_dlg_inc_lock(sub->dlg);
+ /* I think it's pretty safe to disable this check.
+
if (sub->pending_tsx) {
pj_assert(!"Unable to terminate when there's pending tsx");
pjsip_dlg_dec_lock(sub->dlg);
return PJ_EINVALIDOP;
}
+ */
sub->call_cb = notify;
set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL);
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index d9faeb0c..8fda9d3e 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -67,6 +67,11 @@ static pj_status_t call_destroy_media(int call_id);
static pj_status_t create_inactive_sdp(pjsua_call *call,
pjmedia_sdp_session **p_answer);
+/*
+ * Callback called by event framework when the xfer subscription state
+ * has changed.
+ */
+static void xfer_on_evsub_state( pjsip_evsub *sub, pjsip_event *event);
/*
* Reset call descriptor.
@@ -580,9 +585,9 @@ static pj_status_t acquire_call(const char *title,
{
enum { MAX_RETRY=50 };
unsigned retry;
- pjsua_call *call;
- pj_bool_t has_pjsua_lock;
- pj_status_t status;
+ pjsua_call *call = NULL;
+ pj_bool_t has_pjsua_lock = PJ_FALSE;
+ pj_status_t status = PJ_SUCCESS;
for (retry=0; retry<MAX_RETRY; ++retry) {
@@ -647,7 +652,7 @@ PJ_DEF(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id)
status = acquire_call("pjsua_call_get_conf_port()", call_id, &call);
if (status != PJ_SUCCESS)
- return -1;
+ return PJSUA_INVALID_ID;
port_id = call->conf_slot;
@@ -1049,23 +1054,23 @@ PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
pjsip_evsub *sub;
pjsip_tx_data *tdata;
pjsua_call *call;
+ struct pjsip_evsub_user xfer_cb;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- pjsip_dlg_dec_lock(call->inv->dlg);
status = acquire_call("pjsua_call_xfer()", call_id, &call);
if (status != PJ_SUCCESS)
return status;
- /* Create xfer client subscription.
- * We're not interested in knowing the transfer result, so we
- * put NULL as the callback.
- */
- status = pjsip_xfer_create_uac(call->inv->dlg, NULL, &sub);
+ /* Create xfer client subscription. */
+ pj_bzero(&xfer_cb, sizeof(xfer_cb));
+ xfer_cb.on_evsub_state = &xfer_on_evsub_state;
+
+ status = pjsip_xfer_create_uac(call->inv->dlg, &xfer_cb, &sub);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create xfer", status);
pjsip_dlg_dec_lock(call->inv->dlg);
@@ -1121,8 +1126,6 @@ PJ_DEF(pj_status_t) pjsua_call_dial_dtmf( pjsua_call_id call_id,
if (status != PJ_SUCCESS)
return status;
- call = &pjsua_var.calls[call_id];
-
if (!call->session) {
PJ_LOG(3,(THIS_FILE, "Media is not established yet!"));
pjsip_dlg_dec_lock(call->inv->dlg);
@@ -2130,8 +2133,8 @@ static void xfer_on_evsub_state( pjsip_evsub *sub, pjsip_event *event)
PJ_UNUSED_ARG(event);
/*
- * We're only interested when subscription is terminated, to
- * clear the xfer_sub member of the inv_data.
+ * When subscription is terminated, clear the xfer_sub member of
+ * the inv_data.
*/
if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) {
pjsua_call *call;
@@ -2143,7 +2146,38 @@ static void xfer_on_evsub_state( pjsip_evsub *sub, pjsip_event *event)
pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id, NULL);
call->xfer_sub = NULL;
- PJ_LOG(3,(THIS_FILE, "Xfer subscription terminated"));
+ PJ_LOG(4,(THIS_FILE, "Xfer subscription terminated"));
+
+ }
+ /*
+ * When subscription is accepted (got 200/OK to REFER), check if
+ * subscription suppressed.
+ */
+ else if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_ACCEPTED) {
+
+ pjsip_rx_data *rdata;
+ pjsip_generic_string_hdr *refer_sub;
+ const pj_str_t REFER_SUB = { "Refer-Sub", 9 };
+
+ /* Must be receipt of response message */
+ pj_assert(event->type == PJSIP_EVENT_TSX_STATE &&
+ event->body.tsx_state.type == PJSIP_EVENT_RX_MSG);
+ rdata = event->body.tsx_state.src.rdata;
+
+ /* Find Refer-Sub header */
+ refer_sub = (pjsip_generic_string_hdr*)
+ pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
+ &REFER_SUB, NULL);
+
+ /* Check if subscription is suppressed */
+ if (refer_sub && pj_stricmp2(&refer_sub->hvalue, "false")==0) {
+ /* Yes, subscription is suppressed.
+ * Terminate our subscription now.
+ */
+ PJ_LOG(4,(THIS_FILE, "Xfer subscription suppressed, terminating "
+ "event subcription..."));
+ pjsip_evsub_terminate(sub, PJ_TRUE);
+ }
}
}
diff --git a/pjsip/src/test-pjsip/test.h b/pjsip/src/test-pjsip/test.h
index 84d9e1ef..fc0901c1 100644
--- a/pjsip/src/test-pjsip/test.h
+++ b/pjsip/src/test-pjsip/test.h
@@ -36,9 +36,9 @@ extern pjsip_endpoint *endpt;
-#define INCLUDE_MESSAGING_GROUP 1
-#define INCLUDE_TRANSPORT_GROUP 1
-#define INCLUDE_TSX_GROUP 0
+#define INCLUDE_MESSAGING_GROUP 0
+#define INCLUDE_TRANSPORT_GROUP 0
+#define INCLUDE_TSX_GROUP 1
/*
* Include tests that normally would fail under certain gcc