summaryrefslogtreecommitdiff
path: root/pjsip/src
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-25 13:40:12 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-25 13:40:12 +0000
commitcf3c435e0093cf2f1fb8add2298ee468f8c6afc5 (patch)
tree93bbdb60b762ce015dc8f55147eed38bb034d1ca /pjsip/src
parente3f862fca94af0cb4812796055b18d2ba107b613 (diff)
Tests with other user agents revealed some bugs which
have been fixed below: - some UAs sends "telephone-event/8000/1" instead of "telephone-event/8000", which caused SDP negotiation to fail. Fixed in sdp_neg.c. - codec name was (incorrectly) compared case-sensitively, causing negotiation to fail. Fixed in sdp_neg.c. - Also improved error reporting in SDP negotiation by introducing few more error codes. - Added Warning header in Not Acceptable response sent by pjsip_inv_session when SDP negotiation fails. - PJSUA-LIB will try to negotiate both SDPs before sending 100 response. - Fixed bug in iLBC codec when setting the mode to 30. Also: - Echo cancellation by default is disabled now since it doesn't seem to work. Further investigation needed. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@738 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r--pjsip/src/pjsip-ua/sip_inv.c32
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c64
2 files changed, 62 insertions, 34 deletions
diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c
index e363eb90..97507458 100644
--- a/pjsip/src/pjsip-ua/sip_inv.c
+++ b/pjsip/src/pjsip-ua/sip_inv.c
@@ -614,7 +614,6 @@ PJ_DEF(pj_status_t) pjsip_inv_verify_request(pjsip_rx_data *rdata,
/* Incompatible media */
code = PJSIP_SC_NOT_ACCEPTABLE_HERE;
- status = PJSIP_ERRNO_FROM_SIP_STATUS(code);
if (p_tdata) {
pjsip_accept_hdr *acc;
@@ -2414,9 +2413,38 @@ static void inv_on_state_confirmed( pjsip_inv_session *inv, pjsip_event *e)
/* Process SDP in the answer */
status = process_answer(inv, 200, tdata, NULL);
- if (status != PJ_SUCCESS)
+
+ if (status != PJ_SUCCESS) {
+ /*
+ * SDP negotiation has failed.
+ */
+ pj_status_t rc;
+ pj_str_t reason;
+
+ /* Delete the 2xx answer */
+ pjsip_tx_data_dec_ref(tdata);
+
+ /* Create 500 response */
+ reason = pj_str("SDP negotiation failed");
+ rc = pjsip_dlg_create_response(dlg, rdata, 500, &reason,
+ &tdata);
+ if (rc == PJ_SUCCESS) {
+ pjsip_warning_hdr *w;
+ const pj_str_t *endpt_name;
+
+ endpt_name = pjsip_endpt_name(dlg->endpt);
+ w = pjsip_warning_hdr_create_from_status(tdata->pool,
+ endpt_name,
+ status);
+ if (w)
+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)w);
+
+ pjsip_inv_send_msg(inv, tdata);
+ }
return;
+ }
+ /* Send 2xx regardless of the status of negotiation */
status = pjsip_inv_send_msg(inv, tdata);
}
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index bb2ccd18..d3b88a7b 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -394,38 +394,6 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
PJSUA_LOCK();
- /* Verify that we can handle the request. */
- status = pjsip_inv_verify_request(rdata, &options, NULL, NULL,
- pjsua_var.endpt, &response);
- if (status != PJ_SUCCESS) {
-
- /*
- * No we can't handle the incoming INVITE request.
- */
-
- if (response) {
- pjsip_response_addr res_addr;
-
- pjsip_get_response_addr(response->pool, rdata, &res_addr);
- pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response,
- NULL, NULL);
-
- } else {
-
- /* Respond with 500 (Internal Server Error) */
- pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,
- NULL, NULL);
- }
-
- PJSUA_UNLOCK();
- return PJ_TRUE;
- }
-
-
- /*
- * Yes we can handle the incoming INVITE request.
- */
-
/* Find free call slot. */
for (call_id=0; call_id<(int)pjsua_var.ua_cfg.max_calls; ++call_id) {
if (pjsua_var.calls[call_id].inv == NULL)
@@ -461,6 +429,35 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
return PJ_TRUE;
}
+
+ /* Verify that we can handle the request. */
+ status = pjsip_inv_verify_request(rdata, &options, answer, NULL,
+ pjsua_var.endpt, &response);
+ if (status != PJ_SUCCESS) {
+
+ /*
+ * No we can't handle the incoming INVITE request.
+ */
+
+ if (response) {
+ pjsip_response_addr res_addr;
+
+ pjsip_get_response_addr(response->pool, rdata, &res_addr);
+ pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response,
+ NULL, NULL);
+
+ } else {
+
+ /* Respond with 500 (Internal Server Error) */
+ pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,
+ NULL, NULL);
+ }
+
+ PJSUA_UNLOCK();
+ return PJ_TRUE;
+ }
+
+
/*
* Get which account is most likely to be associated with this incoming
* call. We need the account to find which contact URI to put for
@@ -1837,6 +1834,9 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv,
pjsua_perror(THIS_FILE, "SDP negotiation has failed", status);
+ /* Stop/destroy media, if any */
+ call_destroy_media(call->index);
+
/* Disconnect call if we're not in the middle of initializing an
* UAS dialog and if this is not a re-INVITE
*/