In pjsua, outgoing REFER now always put Refer-Sub: false
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@733 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
9b9db6ba43
commit
d524e82949
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue