summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-22 16:55:42 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-22 16:55:42 +0000
commite7e08fc3b6b09d3dba5dce0307dfc0dbad5f9aef (patch)
tree28e16b92c48230f140485586c3267db86188b372
parent8f0078e1663ab2d5d6b25a0d5745f5c14ed9ab18 (diff)
Fixed few bugs that seem to have been introduced by new dialog
locking algorithm: - Fixed crash in PJSUA-API when initiating client subscription - Fixed another crash in PJSUA-API when hanging-up call Also fixed SDP negotiator: - add a=inactive when rejecting media line Also increase maximum log size from 1500 to 2000 since some SIP packet is quite large. A little bit of Warning: ** THIS MAY AFFECT APPLICATION'S STACK USAGE ** git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@734 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/include/pj/config.h4
-rw-r--r--pjmedia/src/pjmedia/sdp_neg.c9
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c91
-rw-r--r--pjsip/src/pjsua-lib/pjsua_pres.c20
4 files changed, 71 insertions, 53 deletions
diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h
index 71bf37c3..15fa638a 100644
--- a/pjlib/include/pj/config.h
+++ b/pjlib/include/pj/config.h
@@ -344,10 +344,10 @@
* This may affect the stack usage, depending whether PJ_LOG_USE_STACK_BUFFER
* flag is set.
*
- * Default: 1500
+ * Default: 2000
*/
#ifndef PJ_LOG_MAX_SIZE
-# define PJ_LOG_MAX_SIZE 1500
+# define PJ_LOG_MAX_SIZE 2000
#endif
/**
diff --git a/pjmedia/src/pjmedia/sdp_neg.c b/pjmedia/src/pjmedia/sdp_neg.c
index 5ce44164..8b362ba9 100644
--- a/pjmedia/src/pjmedia/sdp_neg.c
+++ b/pjmedia/src/pjmedia/sdp_neg.c
@@ -894,6 +894,8 @@ static pj_status_t create_answer( pj_pool_t *pool,
/* No matching media.
* Reject the offer by setting the port to zero in the answer.
*/
+ pjmedia_sdp_attr *a;
+
/* For simplicity in the construction of the answer, we'll
* just clone the media from the offer. Anyway receiver will
* ignore anything in the media once it sees that the port
@@ -902,8 +904,11 @@ static pj_status_t create_answer( pj_pool_t *pool,
am = pjmedia_sdp_media_clone(pool, om);
am->desc.port = 0;
- /* Match direction */
- update_media_direction(pool, om, am);
+ /* Remove direction attribute, and replace with inactive */
+ remove_all_media_directions(am);
+
+ a = pjmedia_sdp_attr_create(pool, "inactive", NULL);
+ pjmedia_sdp_media_add_attr(am, a);
} else {
/* The answer is in am */
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 8fda9d3e..35eee940 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -581,7 +581,8 @@ PJ_DEF(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id)
/* Acquire lock to the specified call_id */
static pj_status_t acquire_call(const char *title,
pjsua_call_id call_id,
- pjsua_call **p_call)
+ pjsua_call **p_call,
+ pjsip_dialog **p_dlg)
{
enum { MAX_RETRY=50 };
unsigned retry;
@@ -633,6 +634,7 @@ static pj_status_t acquire_call(const char *title,
}
*p_call = call;
+ *p_dlg = call->inv->dlg;
return PJ_SUCCESS;
}
@@ -645,18 +647,19 @@ PJ_DEF(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id)
{
pjsua_call *call;
pjsua_conf_port_id port_id;
+ pjsip_dialog *dlg;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_get_conf_port()", call_id, &call);
+ status = acquire_call("pjsua_call_get_conf_port()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return PJSUA_INVALID_ID;
port_id = call->conf_slot;
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return port_id;
}
@@ -670,6 +673,7 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id,
pjsua_call_info *info)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
@@ -677,7 +681,7 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id,
pj_bzero(info, sizeof(*info));
- status = acquire_call("pjsua_call_get_info()", call_id, &call);
+ status = acquire_call("pjsua_call_get_info()", call_id, &call, &dlg);
if (status != PJ_SUCCESS) {
return status;
}
@@ -776,7 +780,7 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id,
PJ_TIME_VAL_SUB(info->total_duration, call->start_time);
}
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_SUCCESS;
}
@@ -816,13 +820,14 @@ PJ_DEF(pj_status_t) pjsua_call_answer( pjsua_call_id call_id,
const pjsua_msg_data *msg_data)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
pjsip_tx_data *tdata;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_answer()", call_id, &call);
+ status = acquire_call("pjsua_call_answer()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
@@ -834,7 +839,7 @@ PJ_DEF(pj_status_t) pjsua_call_answer( pjsua_call_id call_id,
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error creating response",
status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -847,7 +852,7 @@ PJ_DEF(pj_status_t) pjsua_call_answer( pjsua_call_id call_id,
pjsua_perror(THIS_FILE, "Error sending response",
status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -863,6 +868,7 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
const pjsua_msg_data *msg_data)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
pj_status_t status;
pjsip_tx_data *tdata;
@@ -875,7 +881,7 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_hangup()", call_id, &call);
+ status = acquire_call("pjsua_call_hangup()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
@@ -893,7 +899,7 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
pjsua_perror(THIS_FILE,
"Failed to create end session message",
status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -902,7 +908,7 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
* with any provisional responses.
*/
if (tdata == NULL) {
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_SUCCESS;
}
@@ -915,11 +921,11 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
pjsua_perror(THIS_FILE,
"Failed to send end session message",
status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_SUCCESS;
}
@@ -933,26 +939,27 @@ PJ_DEF(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
{
pjmedia_sdp_session *sdp;
pjsua_call *call;
+ pjsip_dialog *dlg;
pjsip_tx_data *tdata;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_set_hold()", call_id, &call);
+ status = acquire_call("pjsua_call_set_hold()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
if (call->inv->state != PJSIP_INV_STATE_CONFIRMED) {
PJ_LOG(3,(THIS_FILE, "Can not hold call that is not confirmed"));
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJSIP_ESESSIONSTATE;
}
status = create_inactive_sdp(call, &sdp);
if (status != PJ_SUCCESS) {
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -960,7 +967,7 @@ PJ_DEF(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
status = pjsip_inv_reinvite( call->inv, NULL, sdp, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -971,11 +978,11 @@ PJ_DEF(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
status = pjsip_inv_send_msg( call->inv, tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_SUCCESS;
}
@@ -991,19 +998,20 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite( pjsua_call_id call_id,
pjmedia_sdp_session *sdp;
pjsip_tx_data *tdata;
pjsua_call *call;
+ pjsip_dialog *dlg;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_reinvite()", call_id, &call);
+ status = acquire_call("pjsua_call_reinvite()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
if (call->inv->state != PJSIP_INV_STATE_CONFIRMED) {
PJ_LOG(3,(THIS_FILE, "Can not re-INVITE call that is not confirmed"));
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJSIP_ESESSIONSTATE;
}
@@ -1015,7 +1023,7 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite( pjsua_call_id call_id,
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",
status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1023,7 +1031,7 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite( pjsua_call_id call_id,
status = pjsip_inv_reinvite( call->inv, NULL, sdp, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1034,11 +1042,11 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite( pjsua_call_id call_id,
status = pjsip_inv_send_msg( call->inv, tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_SUCCESS;
}
@@ -1054,6 +1062,7 @@ PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
pjsip_evsub *sub;
pjsip_tx_data *tdata;
pjsua_call *call;
+ pjsip_dialog *dlg;
struct pjsip_evsub_user xfer_cb;
pj_status_t status;
@@ -1061,7 +1070,7 @@ PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_xfer()", call_id, &call);
+ status = acquire_call("pjsua_call_xfer()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
@@ -1073,7 +1082,7 @@ PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
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);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1083,7 +1092,7 @@ PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
status = pjsip_xfer_initiate(sub, dest, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create REFER request", status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1094,7 +1103,7 @@ PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
status = pjsip_xfer_send_request(sub, tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to send REFER request", status);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1103,7 +1112,7 @@ PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
* may want to hold the INVITE, or terminate the invite, or whatever.
*/
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_SUCCESS;
@@ -1117,24 +1126,25 @@ PJ_DEF(pj_status_t) pjsua_call_dial_dtmf( pjsua_call_id call_id,
const pj_str_t *digits)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_dial_dtmf()", call_id, &call);
+ status = acquire_call("pjsua_call_dial_dtmf()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
if (!call->session) {
PJ_LOG(3,(THIS_FILE, "Media is not established yet!"));
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_EINVALIDOP;
}
status = pjmedia_session_dial_dtmf( call->session, 0, digits);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1150,6 +1160,7 @@ PJ_DEF(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
void *user_data)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
const pj_str_t mime_text_plain = pj_str("text/plain");
pjsip_media_type ctype;
pjsua_im_data *im_data;
@@ -1160,7 +1171,7 @@ PJ_DEF(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_send_im", call_id, &call);
+ status = acquire_call("pjsua_call_send_im()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
@@ -1214,7 +1225,7 @@ PJ_DEF(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
}
on_return:
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1227,13 +1238,14 @@ PJ_DEF(pj_status_t) pjsua_call_send_typing_ind( pjsua_call_id call_id,
const pjsua_msg_data*msg_data)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
pjsip_tx_data *tdata;
pj_status_t status;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_send_typing_ind", call_id, &call);
+ status = acquire_call("pjsua_call_send_typing_ind", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
@@ -1260,7 +1272,7 @@ PJ_DEF(pj_status_t) pjsua_call_send_typing_ind( pjsua_call_id call_id,
}
on_return:
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return status;
}
@@ -1534,6 +1546,7 @@ PJ_DEF(pj_status_t) pjsua_call_dump( pjsua_call_id call_id,
const char *indent)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
pj_time_val duration, res_delay, con_delay;
char tmp[128];
char *p, *end;
@@ -1543,7 +1556,7 @@ PJ_DEF(pj_status_t) pjsua_call_dump( pjsua_call_id call_id,
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
PJ_EINVAL);
- status = acquire_call("pjsua_call_dump()", call_id, &call);
+ status = acquire_call("pjsua_call_dump()", call_id, &call, &dlg);
if (status != PJ_SUCCESS)
return status;
@@ -1601,7 +1614,7 @@ PJ_DEF(pj_status_t) pjsua_call_dump( pjsua_call_id call_id,
if (with_media && call->session)
dump_media_session(indent, p, end-p, call->session);
- pjsip_dlg_dec_lock(call->inv->dlg);
+ pjsip_dlg_dec_lock(dlg);
return PJ_SUCCESS;
}
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index b3205cc5..78f913d1 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -978,6 +978,16 @@ static void subscribe_buddy_presence(unsigned index)
return;
}
+ status = pjsip_pres_create_uac( dlg, &pres_callback,
+ PJSIP_EVSUB_NO_EVENT_ID, &buddy->sub);
+ if (status != PJ_SUCCESS) {
+ pjsua_var.buddy[index].sub = NULL;
+ pjsua_perror(THIS_FILE, "Unable to create presence client",
+ status);
+ pjsip_dlg_terminate(dlg);
+ return;
+ }
+
/* Set route-set */
if (!pj_list_empty(&acc->route_set)) {
pjsip_dlg_set_route_set(dlg, &acc->route_set);
@@ -989,16 +999,6 @@ static void subscribe_buddy_presence(unsigned index)
acc->cred_cnt, acc->cred);
}
- status = pjsip_pres_create_uac( dlg, &pres_callback,
- PJSIP_EVSUB_NO_EVENT_ID, &buddy->sub);
- if (status != PJ_SUCCESS) {
- pjsua_var.buddy[index].sub = NULL;
- pjsua_perror(THIS_FILE, "Unable to create presence client",
- status);
- pjsip_dlg_terminate(dlg);
- return;
- }
-
pjsip_evsub_set_mod_data(buddy->sub, pjsua_var.mod.id, buddy);
status = pjsip_pres_initiate(buddy->sub, -1, &tdata);